<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 23, 2018, at 12:19 PM, Andrew Kelley <<a href="mailto:superjoe30@gmail.com" class="">superjoe30@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Thanks David.</div><div class=""><br class=""></div><div class="">I figured it out. Here's the scoop:</div><div class=""><br class=""></div><div class="">The executable has a LC_SYMTAB. One of those nlist_64 entries has the string set to the .o file path, and the n_type set to N_OSO.</div><div class="">So you can go from symbol to .o file.</div></div></div></blockquote><div><br class=""></div><div>Correct. You can use dsymutil -s to dump the symbol table. If you run dsymutil on the binary it will archive the debug info in a .dSYM bundle and then it's safe to remove the .o files.</div><div><br class=""></div><div><a href="http://wiki.dwarfstd.org/index.php?title=Apple%27s_%22Lazy%22_DWARF_Scheme" class="">http://wiki.dwarfstd.org/index.php?title=Apple%27s_%22Lazy%22_DWARF_Scheme</a></div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">Then you go read the .o file, and the first load command is LC_SEGMENT_64. That has some number of sections following it, among which are the DWARF sections.</div><div class=""><br class=""></div><div class="">I had tried this, but I forgot to increment a pointer in a loop, so I thought all the sections were the same as the first one. D'oh!</div><div class=""><br class=""></div><div class="">Regards,<br class=""></div><div class="">-Andrew<br class=""></div><div class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Aug 23, 2018 at 3:15 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">You'll need to go a bit further than the load commands - I don't know much about MachO files, so I'm just reading: <a href="https://lowlevelbits.org/parsing-mach-o-files/" target="_blank" class="">https://lowlevelbits.org/parsing-mach-o-files/</a> and <a href="https://samhuri.net/posts/2010/01/basics-of-the-mach-o-file-format" target="_blank" class="">https://samhuri.net/posts/2010/01/basics-of-the-mach-o-file-format</a> - so inside the section (described by the LC_SEGMENT_64) are probably a bunch of sections, including debug info sections. Tools like llvm-objdump will show you those (llvm-objdump -h), and also tools like llvm-dwarfdump can print the contents of the debug info sections (those with names starting with "__debug") in human-readable form.<br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Aug 23, 2018 at 12:19 AM Andrew Kelley via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="">When I make a simple test program and call abort() and use LLDB to debug it, it has address-to-line mapping. If I then delete the .o file and run LLDB again, it loses the address-to-line mapping. So there must be DWARF info, or otherwise address-to-line info in the .o file.</div><div class=""><br class=""></div><div class="">I'm parsing the MACH-O executable, which has a LC_SYMTAB  entry, and one of the entries is the file path of the .o file. So I can find the file that way. Then I parse the MACH-O .o file, which also has the LC_SYMTAB, as well as an LC_SEGMENT_64 and LC_DATA_IN_CODE, and then finally a LC_DYSYMTAB. But I don't see where the address-to-line information is, or any DWARF information.</div><div class=""><br class=""></div><div class="">Where is LLDB getting this address-to-line info?<br class=""></div></div>
_______________________________________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="">
</blockquote></div></div>
</blockquote></div></div></div>
</div></blockquote></div><br class=""></body></html>