backward-cpp
backward-cpp copied to clipboard
Is possible to read debug info (function names) from a .map file?
I use the backtrace() functions and the map to retrieve returned symbols, I wanted to switch to this library but it doesn't seem possible to do the same.
- Is possible to read some debug info (ie function names) from a generated .map file?
- How translate the returned memory address (i cant link any library) to .map function address?
I think map files are external debug information outside of the executable on Microsoft Windows? I don't think backward-cpp supports that (I don't know much about Windows). But you might be able to propose a patch to support it. See https://github.com/bombela/backward-cpp/blob/90398eef20f4e7e0e939322d7e84f9c52078a325/backward.hpp#L3566 for the Microsoft Windows specifics. There is also some interesting executable/debug file finding in the Linux specific section: https://github.com/bombela/backward-cpp/blob/90398eef20f4e7e0e939322d7e84f9c52078a325/backward.hpp#L1261.
For the second question, if you cannot link to any library, then you cannot do anything. You are basically saying that you cannot include code to do the work. No code, no work. I might have misunderstood your question though.
A .map file is a linker (ie ld
) generated file that map from memory location to code location.
It gives you the name of the function at a given memory address. Due to optimizations, it may not be extremely accurate, but it gives you a place to start in terms of looking for bugs that cause the crash.
I use the .map to translate the backtrace() returned address to function names. So for example:
Object ./SBL at 0x073F03279 --> my_foo_bar_func()
I was wondering if this library could do the same. if a .map file is found and no other library are linked.