Class
GumExceptor
Description [src]
final class Gum.Exceptor : GObject.Object
{
/* No available fields */
}
Catches and handles hardware and software exceptions, such as access violations, illegal instructions and arithmetic errors.
It serves two complementary needs:
- Scoped recovery: wrap risky code in a
gum_exceptor_try()/gum_exceptor_catch()pair to recover from a fault instead of crashing, much like structured exception handling. - Handlers: register a
GumExceptionHandlerwithgum_exceptor_add()to be consulted whenever an exception occurs — the mechanism behindGumMemoryAccessMonitorand the Interceptor’s exception-aware trampolines.
Recovering from a fault
g_autoptr(GumExceptor) exceptor = gum_exceptor_obtain ();
GumExceptorScope scope;
if (gum_exceptor_try (exceptor, &scope))
{
// Risky operation that might fault.
read_possibly_unmapped (ptr);
}
if (gum_exceptor_catch (exceptor, &scope))
{
g_autofree gchar * desc =
gum_exception_details_to_string (&scope.exception);
g_print ("Caught: %s\n", desc);
}
Instance methods
gum_exceptor_catch
Ends an exception-handling scope opened with gum_exceptor_try() and reports
whether an exception was caught. When it returns TRUE, the exception is
described by scope‘s exception field.
gum_exceptor_has_scope
Checks whether the given thread is currently inside a gum_exceptor_try()
scope.
gum_exceptor_reset
Re-installs the exceptor’s backend, reasserting its exception handling in
case something has taken over the relevant signal handlers since it was last
set up. Does nothing in GUM_EXCEPTOR_MODE_OFF.
Signals
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.