This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libdw: Make dwarf_getfuncs find all (defining) DW_TAG_subprogram DIEs.

On 10/10/2013 02:48 AM, Mark Wielaard wrote:
> On Mon, 2013-10-07 at 10:53 -0700, Josh Stone wrote:
>> BTW, I thought of another corner case which I think will break
>> offset-resuming in dwarf_getfuncs: DW_AT_import+DW_FORM_GNU_ref_alt.
>> The die offsets from the main file and alt file will almost surely
>> overlap, and if you happen to have a subprogram at the same offset in
>> both, then it's not possible to tell which one to resume on.
> Unfortunately you seem to be right, even if that is somewhat unlikely.
>> Must the offsets used by dwarf_getfuncs be die offsets?  After all, they
>> are type ptrdiff_t, not Dwarf_Off.  This particular problem might be
>> solved by instead using die->addr for the "offset" value.
> Yes, that seems to be the correct fix.
> Please check the attached.

AFAICS, the tests you added don't even have any subprograms in their alt
files, let alone colliding DIE offsets.  I grant you, it's hard to craft
such a collision, but I managed it. :P

See attached.  I compiled these like so:

$ gcc -g -O2 test-offset-loop.c -o test-offset-loop
$ cp test-offset-loop test-offset-loop2
$ dwz test-offset-loop test-offset-loop2 -m test-offset-loop.alt

I didn't include loop2 in the tar, as it's just a copy to kick dwz into
action.  The main file has subprograms [2e] "padding" and [63] "main",
where the alt has [5a] "get_errno" and [63] "is_error".

Without your patch, allfcts lists get_errno, is_error, padding, main,
but then main's [63] makes it revert as if it were back at is_error, so
it repeats padding, main, padding, main, ...

With your addr patch, it terminates correctly.

I'm not sure how to add this test though, because while testrun_compare
could see success just fine, it can't handle the unpatched failing case
with infinite output.  Feel free to take and commit my test files if you
can figure this out.


Attachment: test-offset-loop.tar.bz2
Description: application/bzip

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]