<div style="font-family: arial, helvetica, sans-serif"><font size="2">Hi!<div><br></div><div>This patch fixes minor issues in libLLVMDebugInfo and adds an interface its clients can use to</div><div>fetch the function name for a given instruction address (analogue to "addr2line -f").</div>
<div><br></div><div>The usage is illustrated by the additional flag to llvm-dwarfdump tool.</div><div><br></div><div>Currently the implementation is straightforward:</div><div>1) get the compile unit for a given address (using pre-built list of address ranges).</div>
<div>2) re-extract all DIEs of this compile unit.</div><div>3) iterate over all DIEs and find a subprogram DIE, such that given address lies in PC range of this subprogram.</div><div><br></div><div>If this patch is ok, I would like to go on further and add functionality to fetch the</div>
<div>file/line info and function names for all the inlined frames. Hopefully, this wouldn't require much code (the code which</div><div>builds a DIE tree for each compile unit is already present). However, the clients of DebugInfo lib would</div>
<div>have to pass an additional section to DIContext ctor - .debug_ranges (in fact, it is necessary even for the</div><div>current code, as compiling with -O2 often breaks PC range of functions into multiple ranges).</div>
<div><div><div><br></div><div><div><div>Codereview: <a href="http://codereview.appspot.com/6342043/">http://codereview.appspot.com/6342043/</a></div><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</div></div></div></div></font></div>