Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
rt.dwarfeh
Exception handling support for Dwarf-style portable exceptions.
License:
Distributed under the
Boost Software License 1.0.
(See accompanying file LICENSE)
Authors:
Walter Bright
Source rt/dwarfeh.d
- struct
ExceptionHeader; - Wrap the unwinder's data with our own compiler specific struct with our own data.
- static @nogc ExceptionHeader*
create(Throwableo); - Allocate and initialize an ExceptionHeader.Parameters:
Throwable othrown object Returns:allocated and initalized ExceptionHeader - static void
free(ExceptionHeader*eh); - Free ExceptionHeader that was created by create().Parameters:
ExceptionHeader* ehExceptionHeader to free - void
push(); - Push this onto stack of chained exceptions.
- static ExceptionHeader*
pop(); - Pop and return top of chained exception stack.
- static ExceptionHeader*
toExceptionHeader(_Unwind_Exception*eo); - Convert from pointer to exception_object to pointer to ExceptionHeader that it is embedded inside of.Parameters:
_Unwind_Exception* eopointer to exception_object field Returns:pointer to ExceptionHeader that eo points into.
- Throwable
__dmd_begin_catch(_Unwind_Exception*exceptionObject); - The first thing a catch handler does is call this.Parameters:
_Unwind_Exception* exceptionObjectvalue passed to catch handler by unwinder Returns:object that was caught - nothrow @nogc void*
_d_eh_swapContextDwarf(void*newContext); - Called when fibers switch contexts.Parameters:
void* newContextstack to switch to Returns:previous value of stack - void
_d_throwdwarf(Throwableo); - Called by D code to throw an exception via
throw o;
Parameters:Throwable oObject to throw Returns:doesn't return - _Unwind_Reason_Code
__dmd_personality_v0(intver, _Unwind_Actionactions, _Unwind_Exception_ClassexceptionClass, _Unwind_Exception*exceptionObject, _Unwind_Context*context); - "personality" function, specific to each language. This one, of course, is specific to DMD.Parameters:
int verversion must be 1 _Unwind_Action actionsbitwise OR of the 4 actions UA_xxx. UA_SEARCH_PHASE means return URC_HANDLER_FOUND if current frame has a handler, URC_CONTINUE_UNWIND if not. Cannot be used with UA_CLEANUP_PHASE. UA_CLEANUP_PHASE means perform cleanup for current frame by calling nested functions and returning URC_CONTINUE_UNWIND. Or, set up registers and IP for Landing Pad and return URC_INSTALL_CONTEXT. UA_HANDLER_FRAME means this frame was the one with the handler in Phase 1, and now it is Phase 2 and the handler must be run. UA_FORCE_UNWIND means unwinding the stack for longjmp or thread cancellation. Run finally clauses, not catch clauses, finallys must end with call to Uwind_Resume(). _Unwind_Exception_Class exceptionClass8 byte value indicating type of thrown exception. If the low 4 bytes are "C++\0", it's a C++ exception. _Unwind_Exception* exceptionObjectlanguage specific exception information _Unwind_Context* contextopaque type of unwinder state information Returns:reason code - ClassInfo
getClassInfo(_Unwind_Exception*exceptionObject, const(ubyte)*currentLsd); - Look at the chain of inflight exceptions and pick the class type that'll be looked for in catch clauses.Parameters:
_Unwind_Exception* exceptionObjectlanguage specific exception information const(ubyte)* currentLsdpointer to LSDA table Returns:class type to look for - _uleb128_t
uLEB128(const(ubyte)**p); - Decode Unsigned LEB128.Parameters:
const(ubyte)** ppointer to data pointer, *p is updated to point past decoded value Returns:decoded valueSee Also: - _sleb128_t
sLEB128(const(ubyte)**p); - Decode Signed LEB128.Parameters:
const(ubyte)** ppointer to data pointer, *p is updated to point past decoded value Returns:decoded valueSee Also: - LsdaResult
scanLSDA(const(ubyte)*lsda, _Unwind_Ptrip, _Unwind_Exception_ClassexceptionClass, boolcleanupsOnly, boolpreferHandler, _Unwind_Exception*exceptionObject, out _Unwind_PtrlandingPad, out inthandler); - Read and extract information from the LSDA (aka gcc_except_table section). The dmd Call Site Table is structurally different from other implementations. It is organized as nested ranges, and one ip can map to multiple ranges. The most nested candidate is selected when searched. Other implementations have one candidate per ip.Parameters:
const(ubyte)* lsdapointer to LSDA table _Unwind_Ptr ipoffset from start of function at which exception happened _Unwind_Exception_Class exceptionClasswhich language threw the exception bool cleanupsOnlyonly look for cleanups bool preferHandlerif a handler encloses a cleanup, prefer the handler _Unwind_Exception* exceptionObjectlanguage specific exception information _Unwind_Ptr landingPadset to landing pad int handlerset to index of which catch clause was matched Returns:LsdaResult - int
actionTableLookup(_Unwind_Exception*exceptionObject, uintactionRecordPtr, const(ubyte)*pActionTable, const(ubyte)*tt, ubyteTType, _Unwind_Exception_ClassexceptionClass, const(ubyte)*lsda); - Look up classType in Action Table.Parameters:
_Unwind_Exception* exceptionObjectlanguage specific exception information uint actionRecordPtrstarting index in Action Table + 1 const(ubyte)* pActionTablepointer to start of Action Table const(ubyte)* ttpointer past end of Type Table ubyte TTypeencoding of entries in Type Table _Unwind_Exception_Class exceptionClasswhich language threw the exception const(ubyte)* lsdapointer to LSDA table Returns:- >=1 means the handler index of the classType
- 0 means classType is not in the Action Table
- <0 means corrupt
- enum _Unwind_Exception_Class
cppExceptionClass; - C++ Support
- void*
getCppPtrToThrownObject(_Unwind_Exception*exceptionObject, CppTypeInfosti); - Get Pointer to Thrown Object if type of thrown object is implicitly convertible to the catch type.Parameters:
_Unwind_Exception* exceptionObjectlanguage specific exception information CppTypeInfo stitype of catch clause Returns:null if not caught, pointer to thrown object if caught - interface
CppTypeInfo; - Access C++ std::type_info's virtual functions from D, being careful to not require linking with libstd++ or interfere with core.stdcpp.typeinfo. So, give it a different name.
- struct
CppExceptionHeader; - The C++ version of D's ExceptionHeader wrapper
- static CppExceptionHeader*
toExceptionHeader(_Unwind_Exception*eo); - Convert from pointer to exception_object field to pointer to CppExceptionHeader that it is embedded inside of.Parameters:
_Unwind_Exception* eopointer to exception_object field Returns:pointer to CppExceptionHeader that eo points into.
Copyright © 1999-2024 by the D Language Foundation | Page generated by
Ddoc on (no date time)