<div style="font-family: arial, helvetica, sans-serif"><font size="2">Attaching revised patch (according to dvyukov@'s comments).<br><br><div class="gmail_quote">On Mon, Jun 25, 2012 at 5:58 PM, Alexey Samsonov <span dir="ltr"><<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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/" target="_blank">http://codereview.appspot.com/6342043/</a></div><span class="HOEnZb"><font color="#888888"><div><br></div>
-- <br><div>Alexey Samsonov, MSK</div><br>
</font></span></div></div></div></div></font></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</font></div>