bombela / backward-cpp

A beautiful stack trace pretty printer for C++
MIT License
3.66k stars 466 forks source link

Looks like this doesn't work with more recent versions of libdwarf #298

Open fzakaria opened 1 year ago

fzakaria commented 1 year ago

I am seeing a bunch of failures with a recent version of libdwarf

In file included from third_party/backward-cpp/suicide.cc:38:
bazel-out/k8-dbg/bin/external/backward-cpp/_virtual_includes/backward-cpp/backward/backward.hpp:2252:12: error: no matching function for call to 'dwarf_finish'
    return dwarf_finish(dwarf, NULL);
           ^~~~~~~~~~~~
bazel-out/k8-dbg/bin/external/libdwarf/_virtual_includes/libdwarf/libdwarf.h:1578:12: note: candidate function not viable: requires single argument 'dw_dbg', but 2 arguments were provided
DW_API int dwarf_finish(Dwarf_Debug dw_dbg);
           ^
In file included from third_party/backward-cpp/suicide.cc:38:
bazel-out/k8-dbg/bin/external/backward-cpp/_virtual_includes/backward-cpp/backward/backward.hpp:2467:57: error: use of undeclared identifier 'DW_DLC_READ'
    int dwarf_result = dwarf_elf_init(elf_handle.get(), DW_DLC_READ, NULL, NULL,
                                                        ^
bazel-out/k8-dbg/bin/external/backward-cpp/_virtual_includes/backward-cpp/backward/backward.hpp:2570:21: error: no matching function for call to 'dwarf_formref'
                if (dwarf_formref(attr_mem, &spec_offset, &error) ==
                    ^~~~~~~~~~~~~
bazel-out/k8-dbg/bin/external/libdwarf/_virtual_includes/libdwarf/libdwarf.h:2694:12: note: candidate function not viable: requires 4 arguments, but 3 were provided
DW_API int dwarf_formref(Dwarf_Attribute dw_attr,
           ^
In file included from third_party/backward-cpp/suicide.cc:38:
bazel-out/k8-dbg/bin/external/backward-cpp/_virtual_includes/backward-cpp/backward/backward.hpp:2584:22: error: use of undeclared identifier 'dwarf_siblingof'
        int result = dwarf_siblingof(dwarf, current_die, &sibling_die, &error);
                     ^
bazel-out/k8-dbg/bin/external/backward-cpp/_virtual_includes/backward-cpp/backward/backward.hpp:2614:18: error: no matching function for call to 'dwarf_formref'
        result = dwarf_formref(attr_mem, &offset, &error);
okeuday commented 1 year ago

@fzakaria Yes, the issue for that is #232 . The newer versions have a completely different API, so it would require a different macro for the support. However, there may not be a significant increase in information when compared to using libbfd instead, to justify adding the new libdwarf API.

fzakaria commented 1 year ago

Cool thanks. Maybe worth a disclaimer..

I also finally got this all working in my own repo with Bazel....not sure if all that effort for Bazel is worth the cost. Love everything about it except third party stuff.

flagarde commented 1 year ago

Recent libdwarf seems to skip libelf as dependency which would simplify compilation from strach of the lib