<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 28, 2017 at 6:49 AM Daniel Olivier via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div>Hi.</div>
<div><br>
</div>
<div>My goal is to process symbol files (i.e. PE-COFF/PDB, ELF/DWARF), and so I sought to examine how this is done in lldb. However, without first studying the code for an unreasonable amount of time, I just want to ask this simple question.</div>
<div><br>
</div>
<div>Consider the header files that pertain to symbol files in llvm (i.e. $LLVM_ROOT/include/llvm/DebugInfo) and lldb (i.e. $LLVM_ROOT/tools/lldb/source/Plugins/SymbolFile/).</div>
<div><br>
</div>
<div>For PDB support, I see only two classes (.cpp/.h file pairs, in $LLDB_ROOT/source/Plugins/SymbolFile/PDB), PDBASTParser and SymbolFilePDB, which appear to leverage the LLVM PDB implementation, and act as a facade to the LLVM implementation. This pattern
doesn't repeat in the case of the DWARF format, where the file and class hierarchy appears duplicated, and yet are also quite different. </div>
<div><br>
</div>
<div>Its hard to describe the differences and similarities I see between the DWARF files, but so far, I can only guess that the differences are historical (forked and never re-merged), and that lldb only ever needed to read these files (the base LLVM implementation
being more complete, in order to be able to generate them in the first place and merge or manipulate them once they are created).</div>
<div><br>
</div>
<div>Can anyone briefly explain the architectural choices made here?</div></div></div></blockquote><div><br></div><div>Your guesses are pretty much accurate. </div><div><br></div><div>By the way, I'll point out that the PDB parsing code in LLDB doesn't technically use the PDB parsing code in LLVM. At least not in the way you might expect.</div><div><br></div><div>This code was added to LLDB before LLVM supported native PDB reading and writing. To make this possible, and planning for the case in the future where LLVM could support native PDB, an interface was added to LLVM that provided access to PDB data, but could be implemented in different ways.</div><div><br></div><div>Since there was no native PDB support in LLVM at the time, the natural path just to get something to work in LLDB was to provide an implementation based ont he Windows DIA SDK, and this is what was done and that is the implementation that LLDB uses today.</div><div><br></div><div>Later, we added all the native PDB support to LLVM, but it was done at a lower level than this interface abstraction, and the implementation to make use of this native PDB reading code from LLVM is incomplete. Work has started on it, and then later stalled as priorities shifted around.</div><div><br></div><div>So, if you want to process PDB files using LLDB, currently you will need to be on Windows. If you want o make it work on non-Windows, the first step will be completing the implementation of this interface in LLVM. After that it should be a matter of changing 1 or 2 lines of code in LLDB to swap the implementation.</div></div></div>