cosmopolitan
cosmopolitan copied to clipboard
Display file and line number information in stack traces on Windows
This works on Linux and WSL, but not on windows. I know that the *.com.dbg binary must be in the same folder.
I've confirmed it's possible to do this.
Here's what needs to happen. First, we need to delete this line:
https://github.com/jart/cosmopolitan/blob/30cd28b1f8a6cfbb20a1819c1d90a975f8d4d77c/libc/log/backtrace2.c#L61
Secondly, we might want to update:
https://github.com/jart/cosmopolitan/blob/30cd28b1f8a6cfbb20a1819c1d90a975f8d4d77c/libc/log/addr2linepath.c#L21-L23
To be a little smarter on Windows. Possibly by explicitly looking for the standard msys2 using fileexists()
and returning that if the environment variable is null.
Note: The way I got the crashreport.com binary on my Windows computer was I built it on Linux first:
~/cosmo$ make -j8 o//examples/crashreport.com && scp o//examples/crashreport.com{,.dbg} win10:
Newcomers: We recommend the Linux (or WSL) build environment, but it is possible to build Cosmopolitan programs on Windows too. Instructions are here: https://justine.lol/cosmopolitan/windows-compiling.html
One further note, if someone wants a more technically challenging problem than hunting addr2line, I would also welcome a contribution that allows Cosmopolitan Libc to read this information directly from the DWARF ELF .com.dbg file itself. I would be thrilled to see that happen, but keep in mind that DWARF is a daunting format.
Reference: https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/Dwarf.h https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/Dwarf.cpp