come up with a testing strategy for testing debug info
We need some programmatic way of writing test cases for debug info so that we don't have to manually interact with gdb or other debuggers to verify that debug info is working correctly.
Is there any prior art or example code to sketch out the idea you had in mind?
Would a script doing the following be helpful ?
- takes some zig code that eg contains some constant, generate an executable
- generates a .gdbinit file that print said constant on startup and exit
- starts gdb with the executable and the gdbinit and write stderr to a file
- parses the gdb output and compare it to some expected output
This seems a bit brittle but OTOH it directly tests what the user will see and therefore is probably a good target.
ideally the resulting executables could be examined with std.dwarf and not call out to gdb at all
FYI LLVM does it like I described: https://github.com/llvm/llvm-project/blob/35efe1d806358df6e45dde8218a143138dd8f0a8/cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.gdb In the same folder you have a binary which creates a number of local variables with different types. The gdb script set a breakpoints into the code and display each local.
The FileCheck binary asserts that the output matches the inline comments.
Probably interesting paper (or follow-up papers): "Who’s Debugging the Debuggers? Exposing Debug Information Bugs in Optimized Binaries" by Di Luna et al.