Bug 21318 – Add ability to get raw stack trace from TraceInfo

Status
NEW
Severity
enhancement
Priority
P4
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-10-16T18:17:17Z
Last change time
2024-12-07T13:40:46Z
Assigned to
No Owner
Creator
KytoDragon
Moved to GitHub: dmd#17415 →

Comments

Comment #0 by kytodragon — 2020-10-16T18:17:17Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17415 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB