Re: [PATCH 1/3] libdw: Make srclines use a stable sort

2014-12-11 Thread Josh Stone
BTW, I want to point out this change in compare_lines: > - return (*p1)->addr - (*p2)->addr; [...] > + if (line1->addr != line2->addr) > +return (line1->addr < line2->addr) ? -1 : 1; Since addr is 64-bit unsigned, and comparison functions return int, it is possible for the difference to be

[PATCH 0/3] Make line searching more predictable

2014-12-11 Thread Josh Stone
This set changes dwarf_getsrclines into a stable sort, adjusts the binary search in dwfl_module_getsrc to pick the last match, and finally adds a test for earlier addr2line fixes. --- libdw/ChangeLog | 7 libdw/dwarf_getsrclines.c | 52 +--

[PATCH 3/3] tests: Test addr2line -i with lexical blocks present

2014-12-11 Thread Josh Stone
This test is for the fix in commit aecdf2670c02, but it was hampered by unlucky sorting of line records. With the new stable sort, the test now gets the desired line numbers. Signed-off-by: Josh Stone --- tests/ChangeLog | 8 + tests/Makefile.am | 4 ++-

[PATCH 1/3] libdw: Make srclines use a stable sort

2014-12-11 Thread Josh Stone
This adds a sequence number to the linked-list entries, so the original order can break ties in sorting, making this a stable sort. Signed-off-by: Josh Stone --- libdw/ChangeLog | 7 +++ libdw/dwarf_getsrclines.c | 52 --- 2 files change

[PATCH 2/3] libdwfl: Search for the last matching address in lines

2014-12-11 Thread Josh Stone
Now that libdw's srclines use a stable sort, we can reliably choose the *last* matching line record for a given address, which should be the innermost where inlines are concerned. Signed-off-by: Josh Stone --- libdwfl/ChangeLog| 5 + libdwfl/dwfl_module_getsrc.c | 51 +++

Re: [PATCH] libdw: Fix __libdw_form_val_len endp pointer.

2014-12-11 Thread Josh Stone
On 12/11/2014 03:05 PM, Mark Wielaard wrote: > While rebasing my work on top of Josh attrabbrev reading speedups > I noticed a typo/thinko in my form_val_len bound checking patch. > > We should check against the die->cu->endp, not the abbrev endp. In that case, I don't think you need endp as a pa

[PATCH] libdw: Make sure end of next cu doesn't overflow section data size.

2014-12-11 Thread Mark Wielaard
An invalid or trucated debug info/type section could cause the cu endp to point beyond the end of section data. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 4 libdw/libdw_findcu.c | 6 ++ 2 files changed, 10 insertions(+) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index

[PATCH] libdw: Fix __libdw_form_val_len endp pointer.

2014-12-11 Thread Mark Wielaard
While rebasing my work on top of Josh attrabbrev reading speedups I noticed a typo/thinko in my form_val_len bound checking patch. We should check against the die->cu->endp, not the abbrev endp. Signed-off-by: Mark Wielaard --- libdw/ChangeLog| 6 ++ libdw/dwarf_child.c| 2 +- l

Re: [PATCH 0/2] Tweak addr2line function names

2014-12-11 Thread Josh Stone
On 12/10/2014 11:41 AM, Josh Stone wrote: > As previously discussed, these patches fix the function names for addr2line. > For addr2line -i, it now walks as many scopes as necessary to find the > containing function, instead of assuming it's the next scope. Also, addr2line > now prefers linkage_na

Re: [PATCH 0/3] libdw: Tweaks for optimization and clarity

2014-12-11 Thread Josh Stone
On 12/10/2014 06:48 PM, Josh Stone wrote: > While looking at performance for Mark's form-len patch, I found a few areas > that I felt could be cleaned up a bit. > > 1. die->abbrev initialization was duplicated in a few places. > 2. dwarf_hasattr needn't look at the die at all, just abbrev. > 3. CU

[PATCH] readelf: Check TType base offset and Action table are sane in exception table.

2014-12-11 Thread Mark Wielaard
Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 + src/readelf.c | 11 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0ae7e46..cc6bf13 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2014-12-11 Mark Wielaar

[PATCH] readelf: Don't print more augmentation characters than there are.

2014-12-11 Thread Mark Wielaard
Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 + src/readelf.c | 7 --- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 456e5a4..0ae7e46 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-12-11 Mark Wielaard + +

[PATCH] libelf: Correct ELF64 section offset check in file_read_elf.

2014-12-11 Thread Mark Wielaard
The ELF64 case didn't check for overflow and accidentially used the 32bit Shdr size. Signed-off-by: Mark Wielaard --- libelf/ChangeLog | 4 libelf/elf_begin.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libelf/ChangeLog b/libelf/ChangeLog index e4c5849..cf168e

[PATCH] libelf: Add some ar header sanity checking.

2014-12-11 Thread Mark Wielaard
Don't allow entries or size to overflow the parent file size. Signed-off-by: Mark Wielaard --- libelf/ChangeLog | 6 ++ libelf/elf_begin.c | 15 --- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 4860530..e4c5849 10064

Re: [PATCH] readelf: DW_OP_call_ref and DW_OP_GNU_implicit_pointer are invalid for CFA.

2014-12-11 Thread Mark Wielaard
On Sun, 2014-12-07 at 23:46 +0100, Mark Wielaard wrote: > print_cfa_program might call print_ops with zero offset size. We don't > need (and don't know) the DWARF offset size in that case. DW_OP_call_ref > and DW_OP_GNU_implicit_pointer need to know the offset size because they > reference a DIE. B

Re: [PATCH] readelf: maximum operations per instruction cannot be zero in .debug_line.

2014-12-11 Thread Mark Wielaard
On Sun, 2014-12-07 at 23:46 +0100, Mark Wielaard wrote: > 2014-12-07 Mark Wielaard > > + * readelf.c (print_debug_line_section): max_ops_per_instr cannot > + be zero. I pushed this to master.

Re: [PATCH] libdwfl: Check actually used ehsize, shentsize and phentsize in relocate.c

2014-12-11 Thread Mark Wielaard
On Sun, 2014-12-07 at 23:45 +0100, Mark Wielaard wrote: > In relocate_section we check relocation sections don't overlap any of the > ELF headers. We should check against the actually used ehsize, shentsize > and phentsize. Not the possibly bogus values in the file ehdr itself. > > 2014-12-07 Mar

Re: [PATCH] libdwfl: Never relocate value against section zero (load address).

2014-12-11 Thread Mark Wielaard
On Sun, 2014-12-07 at 23:45 +0100, Mark Wielaard wrote: > This really is just a robustify patch in case section zero got the > wrong section flags set. In that case __libdwfl_relocate_value might > call dwfl_offline_section_address which might assert (because it isn't > prepared to handle section z

Re: [PATCH] libdw: Add overflow checking to __libdw_form_val_len.

2014-12-11 Thread Mark Wielaard
On Tue, 2014-12-09 at 18:44 -0800, Josh Stone wrote: > Ok, well my former optimizations went into 0.158. Here are some quick > runs of "varlocs -k >/dev/null" on kernel-3.17.4-301.fc21.x86_64: > > 0.157 96.00user 0.12system 1:36.08elapsed > 0.158 70.22user 0.12system 1:10.32elapsed > 0.159 71.40u

Re: [PATCH 3/3] libdw: save startp/endp boundaries in Dwarf_CU

2014-12-11 Thread Mark Wielaard
On Wed, 2014-12-10 at 18:48 -0800, Josh Stone wrote: > Rather than looking up section data every time, we can simply save the > range of each CU as pointers in Dwarf_CU. > > 2014-12-10 Josh Stone > + * libdwP.h (Dwarf_CU): Add startp and endp boundaries. > + * libdw_findcu.c (__libdw_in

Re: [PATCH 2/3] libdw: optimize dwarf_hasattr to just look at abbrev

2014-12-11 Thread Mark Wielaard
On Wed, 2014-12-10 at 18:48 -0800, Josh Stone wrote: > To just check the presence of an attribute, we only need to look at the > abbreviation data. This optimization avoids reading over die data at all, > except possibly just to get the abbrev code. > > 2014-12-10 Josh Stone > + * dwarf_ha

Re: [PATCH 1/3] libdw: unify die->abbrev lookups

2014-12-11 Thread Mark Wielaard
On Wed, 2014-12-10 at 18:48 -0800, Josh Stone wrote: > Add a new internal function, __libdw_dieabbrev, which deals with checking > a die for an abbrev, and setting it as needed. > > +2014-12-10 Josh Stone > + > + * libdwP.h (__libdw_dieabbrev): New die->abbrev lookup function. > + * dwar

Re: [PATCH 0/3] libdw: Tweaks for optimization and clarity

2014-12-11 Thread Mark Wielaard
On Wed, 2014-12-10 at 18:48 -0800, Josh Stone wrote: > These patches get me back down to about 71s for "varlocs -k > >/dev/null". :) Nice! But I am sure I'll take some of that speedup away again when I finish my checked leb128 work :) Your cleanups will actually help with that. I'll rebase my work

Re: [PATCH 2/2] addr2line: Always prefer linkage_name over plain names

2014-12-11 Thread Mark Wielaard
Hi Josh, On Wed, 2014-12-10 at 11:41 -0800, Josh Stone wrote: > 2014-12-10 Josh Stone > > - * addr2line.c (handle_address): Find the proper inline parents. > + * addr2line.c (get_diename): New, get linkage_name or name. > + * addr2line.c (print_dwarf_function): Use get_diename.

Re: [PATCH 1/2] addr2line: Iterate scopes for inline's parent function

2014-12-11 Thread Mark Wielaard
On Wed, 2014-12-10 at 11:41 -0800, Josh Stone wrote: > The function which contains an inline might not be the immediate next > die scope. For instance, there may be a lexical scope in between. > Instead, iterate the remaining scopes until an appropriate tag is found. > > +2014-12-10 Josh Stone