bombela / backward-cpp

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

MSYS2 libdwarf support #300

Closed mariuszmaximus closed 1 year ago

mariuszmaximus commented 1 year ago

is possible add option to use libdwarf on windows msys2 platform ?

at this moment BACKWARD_HAS_DWARF is inside BACKWARD_SYSTEM_LINUX

I try this https://github.com/davea42/libdwarf-code and sample dwarfdump display all symbol in exe

bombela commented 1 year ago

Indeed right now it is specific to Unix/Linux. The choice of which implementation to compile is done with the preprocessor. You could change the ifdefs in backward.hpp to see how much change would be required.

On Sat, Jun 24, 2023, 02:56 mariuszmaximus @.***> wrote:

is possible add option to use libdwarf on windows msys2 platform ?

at this moment BACKWARD_HAS_DWARF is inside BACKWARD_SYSTEM_LINUX

I try this https://github.com/davea42/libdwarf-code and sample dwarfdump display all symbol in exe

— Reply to this email directly, view it on GitHub https://github.com/bombela/backward-cpp/issues/300, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABUZDCWFDYJXYFGO7NYMHLXM22VRANCNFSM6AAAAAAZSNKXAY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mariuszmaximus commented 1 year ago

I have my first experiments Build with BACKWARD_HAS_DWARF on msys2 and don't link msvcr90

not everything works yet :( no line number :(

Problem is here:

    // Try to get an ELF handle. We need to read the ELF sections
    // because we want to see if there is a .gnu_debuglink section
    // that points to a split debug file
    dwarf_elf_t elf_handle;
    elf_handle.reset(elf_begin(file_handle.get(), ELF_C_READ, NULL));
    if (!elf_handle) {
      return r;
    }

Always return r;

I will think about it

bombela commented 1 year ago

Right, because on MS Windows the executable should be a PE (Portable Executable) file, not ELF (Executable and Linkable Format).The fact it compiled and run is promising.

On Tue, Jun 27, 2023, 14:26 mariuszmaximus @.***> wrote:

I have my first experiments Build with BACKWARD_HAS_DWARF on msys2 and don't link msvcr90

not everything works yet :( no line number :(

Problem is here:

// Try to get an ELF handle. We need to read the ELF sections
// because we want to see if there is a .gnu_debuglink section
// that points to a split debug file
dwarf_elf_t elf_handle;
elf_handle.reset(elf_begin(file_handle.get(), ELF_C_READ, NULL));
if (!elf_handle) {
  return r;
}

Always return r;

I will think about it

— Reply to this email directly, view it on GitHub https://github.com/bombela/backward-cpp/issues/300#issuecomment-1610242231, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABUZDGCOKX2HGZPOYIIBRDXNNFY3ANCNFSM6AAAAAAZSNKXAY . You are receiving this because you commented.Message ID: @.***>

mariuszmaximus commented 1 year ago

Mea culpa I look at samples in https://github.com/davea42/libdwarf-code and cmake find libelf Now I checked ! libelf is not used in any way in libdwarf-code samples

I gave up with libdwarf I found a better solution:https://github.com/bombela/backward-cpp/pull/301