Parse Mach-O debug map

How are debug maps saved in Mach-O files? I'm trying to essentially recreate the output of dsymutil -dump-debug-map.

Replies

How are debug maps saved in Mach-O files? I'm trying to essentially recreate the output of dsymutil --dump-debug-map.

To what end?

Debugging symbols are a staggeringly complex topic, so it’s best to avoid writing code to deal with them if at all possible. So, for example, if dsymutil produces the output you need, why not invoke it and parse the output? After all, it produces YAML which is intended to be machine readable.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for the reply! I wish I could avoid writing code to deal with them however I'm in the unfortunate boat of writing a stacktrace library :(

Parsing dsymutil could work. I'm trying to avoid the external dependency of invoking external programs, if possible. Out of curiosity, is dsymutil guaranteed to always exist?

Looking through Mach-O, it looks like the LC_SYMTAB load command may contain the info I need. dsymutil -s myprogram seems like it makes sense relative to the dump-debug-map output, but I can only guess at the schema. Is this documented somewhere? I have not been able to find anything on the symbol table format yet.

Thank you

however I'm in the unfortunate boat of writing a stacktrace library

My sympathies.

Are you trying to do this from within the target process? Or offline?

My general advice is that you do this stuff offline. That is, have you debugging infrastructure record:

  • Any addresses it wants to symbolicate

  • The UUIDs of all the libraries loaded in the process

With that information you can do your symbolication later, in a stable environment.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I am interested in scanning debug maps as well. As part of a post-build step, I am working on a tool that scans the application artifact and its dynamic dependencies for possible ODR violations. I have DWARF symbol scanning in place already, and need the debug maps to tie the artifact and the DWARF scanning together. Any tips on where the debug maps are stored would be most helpful.