Stacktrace on win32 #10612
Labels
kind:feature
platform:windows
Windows support based on the MSVC toolchain / Win32 API
topic:stdlib:runtime
Exception handling on win32 works, but we still don't have backtraces.
I've been experimenting with that, how we can implement that.
The typical tool on Windows seems to be
StackWalk
fromdbghlp.dll
. That library file should generally be available on Windows systems, but may be an older version, so it's recommended to ship a recent library with an application if you use it. That complicates things a bit for distributing Windows executables, but I don't think there's a really feasible alternative.(As I understand it, Go may have their own implementation, but it's not totally clear to me what exactly they're doing.)
Anyway, this is the output I get for the
backtrace_sample
test program:The frame addresses don't look completely unreasonable, but they're pretty close together and are resolved to the same symbol. Not sure if there's an issue with the addresses or the symbol lookup. I'd suspect the latter.
But I'm really leaving my turf here 😅 Getting the basic implementation was doable, even without knowing anything about win32 debugging. But I'm not sure how I could figure out how to get correct output. So any help is welcome =)
The code is available at https://github.com/straight-shoota/crystal/tree/feature/win32-callstack
In order to get any symbol info, you need to pass
--link-flags="/Z7"
to the build command which generates a.pdb
containing the debug information.crystal.exe spec/std/data/backtrace_sample --link-flags="/Z7"
The text was updated successfully, but these errors were encountered: