How do you translate an address on Mac so that you can use addr2line?
I am trying to store a stack trace (which i get via backtrace
). I tried passing that into backtrace_symbols
as many tutorials suggest. I then get a string like "0 MyExecutable 0x00000001004a2ba1 _Z13EventLoop_addPPvP7Event_s + 97"
. When I try and pass the address from there “0x00000001004a2ba1” to addr2line addr2line -e MyExecutable 0x00000001004a2ba1
it is unable to return function+line info. The same is the case with atos. The only case which does work is when I use atos and pass a processId instead of an executable. The reason this doesnt work is because of ASLR. The answer here /a/63856113/516813 shows how to do this for linux, but the solution doesnt work for Mac because dladdr1
doesnt exist and I cant find a way to get the link_map. Does anyone know how to do this for Mac?