It would be nice if it was possible to directly retrieve the stack trace of a TraceInfo instance as either void*[] or size_t[].
TraceInfo currently only exports a "resolved" version of each frame as a string via its opApply, which can be very lacking and is not @nogc.
Example stack trace on Ubuntu:
Exception: Range violation!
??:? [0x55ed1c6558a5]
??:? [0x55ed1c6611e6]
??:? [0x55ed1c644aed]
??:? [0x55ed1c63d128]
??:? [0x55ed1c63d817]
??:? [0x55ed1c6447bb]
??:? [0x55ed1c6446b2]
??:? [0x55ed1c64450d]
Since both core.runtime.DefautTraceInfo and the members of core.sys.windows.stacktrace.StackTrace are private, the only way to get a good stack trace is something like this (for Posix):
struct DefaultTraceInfo {
void** vfptr;
int numframes;
void*[128] callstack = void;
}
DefaultTraceInfo* info = cast(DefaultTraceInfo*)cast(void*)er.info;
size_t[] trace = cast(size_t[])info.callstack[0..info.numframes];
A standardized way would be appreciated.
Comment #1 by robert.schadek — 2024-12-07T13:40:46Z