On 2012/06/28 12:19:14, bkramer wrote: > Sorry, this was on my review list but I ...
12 years, 4 months ago
(2012-06-29 08:54:39 UTC)
#6
On 2012/06/28 12:19:14, bkramer wrote:
> Sorry, this was on my review list but I didn't get around to it so far.
>
> The approach looks good in general. For the .debug_ranges stuff I'd suggest
> looking at LLDB. libDebugInfo's design is strongly inspired by it, and you can
> certainly take some clues from it as it is a fast and mature DWARF parser.
Thanks for comments and references! I'll take a closer look at interesting parts
of LLDB code.
> One thing that still worries me is the lack of testing (I take most of the
blame
> here). It seems to be possible now to use binary files as test input (see the
> tests in llvm's test/Object), this didn't work reliably a year ago so I didn't
> add any tests. It would be nice to have at least a basic test using a binary
> object and llvm-dwarfdump, so the code doesn't break as easily.
I've added a sketch for the possible test case to the patch (it uses two
pre-built binaries).
>
> I hope the process to add tests for libDebugInfo will become easier when
> yaml2obj lands, but I don't know the current status of that tool.
>
>
http://codereview.appspot.com/6342043/diff/10004/include/llvm/DebugInfo/DICon...
> File include/llvm/DebugInfo/DIContext.h (right):
>
>
http://codereview.appspot.com/6342043/diff/10004/include/llvm/DebugInfo/DICon...
> include/llvm/DebugInfo/DIContext.h:68: return (Flags | spec) > 0;
> This is always true if spec is non-zero. Did you mean to use '&'?
>
>
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFCompileUn...
> File lib/DebugInfo/DWARFCompileUnit.cpp (right):
>
>
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFCompileUn...
> lib/DebugInfo/DWARFCompileUnit.cpp:204: if (DieArray.size() > 0) {
> The idea here was to skip some work if only the CU was parsed so far.
>
> I'd suggest something like "DieArray.size() > unsigned(keep_compile_unit_die)"
> to keep the optimization.
>
>
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFCompileUn...
> lib/DebugInfo/DWARFCompileUnit.cpp:255: }
> This function is really specific, it may be better to add a generic way to get
a
> DIE foor an address out of DWARFCompileUnit. You can take a look at LLDB's
> DWARFCompileUnit::LookupAddress if you need some inspiration.
>
>
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFDebugAran...
> File lib/DebugInfo/DWARFDebugAranges.cpp (right):
>
>
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFDebugAran...
> lib/DebugInfo/DWARFDebugAranges.cpp:96: sort(true, /* overlap size */ 0);
> Ouch, I guess I never really tested this without an .debug_aranges section
> present :(
>
>
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFDebugInfo...
> File lib/DebugInfo/DWARFDebugInfoEntry.cpp (right):
>
>
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFDebugInfo...
> lib/DebugInfo/DWARFDebugInfoEntry.cpp:490: }
> Those functions look good to me.
12 years, 4 months ago
(2012-06-29 08:54:46 UTC)
#7
http://codereview.appspot.com/6342043/diff/10004/include/llvm/DebugInfo/DICon...
File include/llvm/DebugInfo/DIContext.h (right):
http://codereview.appspot.com/6342043/diff/10004/include/llvm/DebugInfo/DICon...
include/llvm/DebugInfo/DIContext.h:68: return (Flags | spec) > 0;
On 2012/06/28 12:19:14, bkramer wrote:
> This is always true if spec is non-zero. Did you mean to use '&'?
Oops. Fixed.
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFCompileUn...
File lib/DebugInfo/DWARFCompileUnit.cpp (right):
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFCompileUn...
lib/DebugInfo/DWARFCompileUnit.cpp:204: if (DieArray.size() > 0) {
On 2012/06/28 12:19:14, bkramer wrote:
> The idea here was to skip some work if only the CU was parsed so far.
>
> I'd suggest something like "DieArray.size() > unsigned(keep_compile_unit_die)"
> to keep the optimization.
Done.
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFCompileUn...
lib/DebugInfo/DWARFCompileUnit.cpp:255: }
On 2012/06/28 12:19:14, bkramer wrote:
> This function is really specific, it may be better to add a generic way to get
a
> DIE foor an address out of DWARFCompileUnit. You can take a look at LLDB's
> DWARFCompileUnit::LookupAddress if you need some inspiration.
Done. In fact, it may worth to save all the parsed DIEs structure after we
return from this function, as we may do more complex stuff than just fetching
the function name (traverse DIE parents to fetch inlining data, for example).
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFDebugAran...
File lib/DebugInfo/DWARFDebugAranges.cpp (right):
http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFDebugAran...
lib/DebugInfo/DWARFDebugAranges.cpp:96: sort(true, /* overlap size */ 0);
On 2012/06/28 12:19:14, bkramer wrote:
> Ouch, I guess I never really tested this without an .debug_aranges section
> present :(
BTW it looks like if we want to build a DWARFContext for an executable (not an
object file), we should pass NULL as a pointer to .debug_aranges to be safe - if
we linked together 10 objects, only one of which had the .debug_aranges section,
then the contents of .debug_aranges section in exec won't cover all actual
address ranges.
On Fri, Jun 29, 2012 at 12:54 PM, <samsonov@google.com> wrote: > > http://codereview.appspot.com/**6342043/diff/10004/include/** > llvm/DebugInfo/DIContext.h<http://codereview.appspot.com/6342043/diff/10004/include/llvm/DebugInfo/DIContext.h> ...
12 years, 4 months ago
(2012-06-29 09:13:57 UTC)
#8
On Fri, Jun 29, 2012 at 12:54 PM, <samsonov@google.com> wrote:
>
> http://codereview.appspot.com/**6342043/diff/10004/include/**
>
llvm/DebugInfo/DIContext.h<http://codereview.appspot.com/6342043/diff/10004/include/llvm/DebugInfo/DIContext.h>
> File include/llvm/DebugInfo/**DIContext.h (right):
>
> http://codereview.appspot.com/**6342043/diff/10004/include/**
>
llvm/DebugInfo/DIContext.h#**newcode68<http://codereview.appspot.com/6342043/diff/10004/include/llvm/DebugInfo/DIContext.h#newcode68>
> include/llvm/DebugInfo/**DIContext.h:68: return (Flags | spec) > 0;
> On 2012/06/28 12:19:14, bkramer wrote:
>
>> This is always true if spec is non-zero. Did you mean to use '&'?
>>
>
> Oops. Fixed.
>
>
> http://codereview.appspot.com/**6342043/diff/10004/lib/**
>
DebugInfo/DWARFCompileUnit.cpp<http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFCompileUnit.cpp>
> File lib/DebugInfo/**DWARFCompileUnit.cpp (right):
>
> http://codereview.appspot.com/**6342043/diff/10004/lib/**
>
DebugInfo/DWARFCompileUnit.**cpp#newcode204<http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFCompileUnit.cpp#newcode204>
> lib/DebugInfo/**DWARFCompileUnit.cpp:204: if (DieArray.size() > 0) {
> On 2012/06/28 12:19:14, bkramer wrote:
>
>> The idea here was to skip some work if only the CU was parsed so far.
>>
>
> I'd suggest something like "DieArray.size() >
>>
> unsigned(keep_compile_unit_**die)"
>
>> to keep the optimization.
>>
>
> Done.
>
> http://codereview.appspot.com/**6342043/diff/10004/lib/**
>
DebugInfo/DWARFCompileUnit.**cpp#newcode255<http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFCompileUnit.cpp#newcode255>
> lib/DebugInfo/**DWARFCompileUnit.cpp:255: }
>
> On 2012/06/28 12:19:14, bkramer wrote:
>
>> This function is really specific, it may be better to add a generic
>>
> way to get a
>
>> DIE foor an address out of DWARFCompileUnit. You can take a look at
>>
> LLDB's
>
>> DWARFCompileUnit::**LookupAddress if you need some inspiration.
>>
>
> Done. In fact, it may worth to save all the parsed DIEs structure after
> we return from this function, as we may do more complex stuff than just
> fetching the function name (traverse DIE parents to fetch inlining data,
> for example).
>
>
> http://codereview.appspot.com/**6342043/diff/10004/lib/**
>
DebugInfo/DWARFDebugAranges.**cpp<http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFDebugAranges.cpp>
> File lib/DebugInfo/**DWARFDebugAranges.cpp (right):
>
> http://codereview.appspot.com/**6342043/diff/10004/lib/**
>
DebugInfo/DWARFDebugAranges.**cpp#newcode96<http://codereview.appspot.com/6342043/diff/10004/lib/DebugInfo/DWARFDebugAranges.cpp#newcode96>
> lib/DebugInfo/**DWARFDebugAranges.cpp:96: sort(true, /* overlap size */
> 0);
> On 2012/06/28 12:19:14, bkramer wrote:
>
>> Ouch, I guess I never really tested this without an .debug_aranges
>>
> section
>
>> present :(
>>
>
> BTW it looks like if we want to build a DWARFContext for an executable
> (not an object file), we should pass NULL as a pointer to .debug_aranges
> to be safe - if we linked together 10 objects, only one of which had the
> .debug_aranges section, then the contents of .debug_aranges section in
> exec won't cover all actual address ranges.
This may slowdown symbolization significantly. I think it's better to
consult .debug_aranges first and then fallback to full parsing.
lldb has the same problem.
Issue 6342043: DebugInfo lib
(Closed)
Created 12 years, 4 months ago by samsonov
Modified 12 years, 4 months ago
Reviewers: dvyukov, bkramer
Base URL: https://llvm.org/svn/llvm-project/llvm/trunk/
Comments: 19