NSException test

master
Andrey Kleshchev 2024-01-19 23:01:06 +02:00 committed by Andrey Kleshchev
parent 337a2356a9
commit fee2dc981c
8 changed files with 57 additions and 0 deletions

View File

@ -5445,6 +5445,13 @@ void LLAppViewer::forceErrorSoftwareException()
LLTHROW(LLException("User selected Force Software Exception"));
}
void LLAppViewer::forceErrorOSSpecificException()
{
// Virtual, MacOS only
const std::string exception_text = "User selected Force OS Exception, Not implemented on this OS";
throw std::runtime_error(exception_text);
}
void LLAppViewer::forceErrorDriverCrash()
{
LL_WARNS() << "Forcing a deliberate driver crash" << LL_ENDL;

View File

@ -156,6 +156,7 @@ public:
virtual void forceErrorBadMemoryAccess();
virtual void forceErrorInfiniteLoop();
virtual void forceErrorSoftwareException();
virtual void forceErrorOSSpecificException();
virtual void forceErrorDriverCrash();
virtual void forceErrorCoroutineCrash();
virtual void forceErrorThreadCrash();

View File

@ -33,4 +33,6 @@
//Why? Because BOOL
void launchApplication(const std::string* app_name, const std::vector<std::string>* args);
void force_ns_sxeption();
#endif // LL_LLAPPVIEWERMACOSX_OBJC_H

View File

@ -71,3 +71,9 @@ void launchApplication(const std::string* app_name, const std::vector<std::strin
[pool release];
return;
}
void force_ns_sxeption()
{
NSException *exception = [NSException exceptionWithName:@"Forced NSException" reason:nullptr userInfo:nullptr];
@throw exception;
}

View File

@ -250,6 +250,11 @@ bool LLAppViewerMacOSX::init()
return LLAppViewer::init();
}
void LLAppViewerMacOSX::forceErrorOSSpecificException()
{
force_ns_sxeption();
}
// MacOSX may add and addition command line arguement for the process serial number.
// The option takes a form like '-psn_0_12345'. The following method should be able to recognize
// and either ignore or return a pair of values for the option.

View File

@ -42,6 +42,8 @@ public:
//
virtual bool init(); // Override to do application initialization
virtual void forceErrorOSSpecificException();
protected:
virtual bool restoreErrorTrap();

View File

@ -292,6 +292,7 @@ void force_error_llerror(void *);
void force_error_bad_memory_access(void *);
void force_error_infinite_loop(void *);
void force_error_software_exception(void *);
void force_error_os_exception(void*);
void force_error_driver_crash(void *);
void force_error_coroutine_crash(void *);
void force_error_thread_crash(void *);
@ -2419,6 +2420,15 @@ class LLAdvancedForceErrorSoftwareException : public view_listener_t
}
};
class LLAdvancedForceOSException: public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
force_error_os_exception(NULL);
return true;
}
};
class LLAdvancedForceErrorSoftwareExceptionCoro : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
@ -3200,6 +3210,15 @@ bool enable_object_select_in_pathfinding_characters()
return LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion() && LLSelectMgr::getInstance()->selectGetViewableCharacters();
}
bool enable_os_exception()
{
#if LL_DARWIN
return true;
#else
return false;
#endif
}
class LLSelfRemoveAllAttachments : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
@ -8371,6 +8390,11 @@ void force_error_software_exception(void *)
LLAppViewer::instance()->forceErrorSoftwareException();
}
void force_error_os_exception(void*)
{
LLAppViewer::instance()->forceErrorOSSpecificException();
}
void force_error_driver_crash(void *)
{
LLAppViewer::instance()->forceErrorDriverCrash();
@ -9598,6 +9622,7 @@ void initialize_menus()
view_listener_t::addMenu(new LLAdvancedForceErrorBadMemoryAccessCoro(), "Advanced.ForceErrorBadMemoryAccessCoro");
view_listener_t::addMenu(new LLAdvancedForceErrorInfiniteLoop(), "Advanced.ForceErrorInfiniteLoop");
view_listener_t::addMenu(new LLAdvancedForceErrorSoftwareException(), "Advanced.ForceErrorSoftwareException");
view_listener_t::addMenu(new LLAdvancedForceOSException(), "Advanced.ForceErrorOSException");
view_listener_t::addMenu(new LLAdvancedForceErrorSoftwareExceptionCoro(), "Advanced.ForceErrorSoftwareExceptionCoro");
view_listener_t::addMenu(new LLAdvancedForceErrorDriverCrash(), "Advanced.ForceErrorDriverCrash");
view_listener_t::addMenu(new LLAdvancedForceErrorCoroutineCrash(), "Advanced.ForceErrorCoroutineCrash");
@ -9779,6 +9804,7 @@ void initialize_menus()
enable.add("VisibleSelectInPathfindingLinksets", boost::bind(&visible_object_select_in_pathfinding_linksets));
commit.add("Pathfinding.Characters.Select", boost::bind(&LLFloaterPathfindingCharacters::openCharactersWithSelectedObjects));
enable.add("EnableSelectInPathfindingCharacters", boost::bind(&enable_object_select_in_pathfinding_characters));
enable.add("Advanced.EnableErrorOSException", boost::bind(&enable_os_exception));
view_listener_t::addMenu(new LLFloaterVisible(), "FloaterVisible");
view_listener_t::addMenu(new LLShowSidetrayPanel(), "ShowSidetrayPanel");

View File

@ -2754,6 +2754,14 @@ function="World.EnvPreset"
<menu_item_call.on_click
function="Advanced.ForceErrorSoftwareException" />
</menu_item_call>
<menu_item_call
label="Force OS Exception"
name="Force OS Exception">
<menu_item_call.on_click
function="Advanced.ForceErrorOSException" />
<menu_item_call.on_visible
function="Advanced.EnableErrorOSException" />
</menu_item_call>
<menu_item_call
label="Force a Crash in a Coroutine"
name="Force a Crash in a Coroutine">