Exception handling support for Dwarf-style portable exceptions.
Wrap the unwinder's data with our own compiler specific struct with our own data.
Allocate and initialize an ExceptionHeader.
Throwable o
| thrown object |
Free ExceptionHeader that was created by create().
ExceptionHeader* eh
| ExceptionHeader to free |
Push this onto stack of chained exceptions.
Pop and return top of chained exception stack.
Convert from pointer to exception_object to pointer to ExceptionHeader that it is embedded inside of.
_Unwind_Exception* eo
| pointer to exception_object field |
The first thing a catch handler does is call this.
_Unwind_Exception* exceptionObject
| value passed to catch handler by unwinder |
Called when fibers switch contexts.
void* newContext
| stack to switch to |
Called by D code to throw an exception via
throw o;
Throwable o
| Object to throw |
"personality" function, specific to each language. This one, of course, is specific to DMD.
int ver
| version must be 1 |
_Unwind_Action actions
| bitwise 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 exceptionClass
| 8 byte value indicating type of thrown exception. If the low 4 bytes are "C++\0", it's a C++ exception. |
_Unwind_Exception* exceptionObject
| language specific exception information |
_Unwind_Context* context
| opaque type of unwinder state information |
Look at the chain of inflight exceptions and pick the class type that'll be looked for in catch clauses.
_Unwind_Exception* exceptionObject
| language specific exception information |
const(ubyte)* currentLsd
| pointer to LSDA table |
Decode Unsigned LEB128.
const(ubyte)** p
| pointer to data pointer, *p is updated to point past decoded value |
Decode Signed LEB128.
const(ubyte)** p
| pointer to data pointer, *p is updated to point past decoded value |
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.
const(ubyte)* lsda
| pointer to LSDA table |
_Unwind_Ptr ip
| offset from start of function at which exception happened |
_Unwind_Exception_Class exceptionClass
| which language threw the exception |
bool cleanupsOnly
| only look for cleanups |
bool preferHandler
| if a handler encloses a cleanup, prefer the handler |
_Unwind_Exception* exceptionObject
| language specific exception information |
_Unwind_Ptr landingPad
| set to landing pad |
int handler
| set to index of which catch clause was matched |
Look up classType in Action Table.
_Unwind_Exception* exceptionObject
| language specific exception information |
uint actionRecordPtr
| starting index in Action Table + 1 |
const(ubyte)* pActionTable
| pointer to start of Action Table |
const(ubyte)* tt
| pointer past end of Type Table |
ubyte TType
| encoding of entries in Type Table |
_Unwind_Exception_Class exceptionClass
| which language threw the exception |
const(ubyte)* lsda
| pointer to LSDA table |
C++ Support
Get Pointer to Thrown Object if type of thrown object is implicitly convertible to the catch type.
_Unwind_Exception* exceptionObject
| language specific exception information |
CppTypeInfo sti
| type of catch clause |
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.
The C++ version of D's ExceptionHeader wrapper
Convert from pointer to exception_object field to pointer to CppExceptionHeader that it is embedded inside of.
_Unwind_Exception* eo
| pointer to exception_object field |
© 1999–2019 The D Language Foundation
Licensed under the Boost License 1.0.
https://dlang.org/phobos/rt_dwarfeh.html