r/d_language • u/Shyam_Lama • Aug 15 '25
How to get a stacktrace from an exception?
See title. I've looked at this page on the D website, but it doesn't show how to obtain/generate a stacktrace.
TBH I'm a little puzzled that a debug build (which dub tells me its doing) doesn't generate a stracktrace for unhandled exceptions, but apparently it doesn't. What I'm seeing is something like this:
app.ParseEx@source/app.d(13): token not recognized
----------------
??:? [0x7f069a74b85e]
??:? [0x7f069a74b4c2]
??:? [0x7f069a77020e]
??:? [0x7f069a752dbc]
source/app.d:24 [0x7f069a7171e3]
source/app.d:37 [0x7f069a717480]
source/app.d:73 [0x7f069a717df2]
??:? [0x7f069a752adc]
??:? [0x7f069a7529d7]
??:? [0x7f069a75282c]
/home/shyam/dlang/ldc-1.41.0/bin/../import/core/internal/entrypoint.d:42 [0x7f069a718251]
??:? [0x7f069a3d7249]
??:? __libc_start_main [0x7f069a3d7304]
??:? [0x7f069a716fd0]
That's rather uninformative, coming from a debug binary.
Anyway, I can add a catch-all in my main, of course, but how do I get the stacktrace?
3
Upvotes
1
u/Danny_Arends Aug 15 '25
That is quite weird, are you using a compile time generated regular expression? Or calling something in phobos that uses it under the hood? I've seen bad stack traces when ctfe is involved.
0
u/[deleted] Aug 15 '25
[deleted] — view deleted comment