coreir icon indicating copy to clipboard operation
coreir copied to clipboard

[Proposal] Use Backward for printing pretty stack trace

Open splhack opened this issue 6 years ago • 2 comments

The current ASSERT stack trace is not demangled, so it is hard to debug. This proposal is introducing https://github.com/bombela/backward-cpp to print pretty stack trace instead. This PR uses libdw from elfutils because it supports Linux and macOS (I think.)

Sample output on unit test.

Stack trace (most recent call last):
#6    Object "", at 0xffffffffffffffff, in
#5    Object "/home/kaz/coreir/tests/unit/build/blackbox_verilog", at 0x56310e758419, in _start
#4    Source "../csu/libc-start.c", line 310, in __libc_start_main
#3    Source "/home/kaz/coreir/tests/unit/blackbox_verilog.cpp", line 41, in main
         38: }
         39:
         40: int main() {
      >  41:   testBlackboxVerilog();
         42: }
#2    Source "/home/kaz/coreir/tests/unit/blackbox_verilog.cpp", line 34, in testBlackboxVerilog
         31:   std::ifstream golden_stream("blackbox_verilog_golden.v");
         32:   std::string golden((std::istreambuf_iterator<char>(golden_stream)),
         33:                      std::istreambuf_iterator<char>());
      >  34:   ASSERT(golden == verilog,
         35:          "Expected '" + golden + "' but got '" + verilog + "'");
         36:
         37:   deleteContext(c);
#1    Source "../../include/coreir/tools/backward.hpp", line 751, in load_here

splhack avatar Mar 02 '19 22:03 splhack

This looks great! I just want to confirm that if someone does not have libdw, it will still work correctly.

rdaly525 avatar Mar 14 '19 16:03 rdaly525

Yeah it works without libdw (less information though, just the same as the current stack trace). And CMakefying(#654) would help to enable linking libdw by user easily!

splhack avatar Mar 15 '19 04:03 splhack