bombela/backward-cpp

Is possible to read debug info (function names) from a .map file?

CncGpp opened this issue · 2 comments

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?

image

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

#ifdef BACKWARD_SYSTEM_WINDOWS
for the Microsoft Windows specifics. There is also some interesting executable/debug file finding in the Linux specific section:
class TraceResolverLinuxBase : public TraceResolverImplBase {
.

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.