Hi Paul, On Fri, Jan 29, 2021 at 02:04:02PM -0600, Paul A. Clarke wrote: > On Fri, Jan 29, 2021 at 12:22:41PM +0100, Mark Wielaard wrote: > > The infinite loop is because off isn't updated to noff before calling > > continue in the while loop. Moving the last line of the loop off = > > noff; to the start of the loop should fix that. > > I noticed that, too. I'll report that over on linux-perf-users. > (That code is about 10 years old, surprisingly.)
Thanks. Note that newer elfutils libdw (since support for DWARF5 was added) provide dwarf_get_units which makes iterating over CUs slightly simpler because it gives you the CU and DIE directly instead of having to deal with offsets. > > Why the call to dwarf_offdie fails is unclear. Try printing the error > > using dwarf_errmsg (-1) when it returns NULL. > > The message is not terribly helpful, to me anyway: > invalid DWARF Yeah, sorry, that is because DWARF5 looks invalid to old versions. > > If you also print out > > off (in hex) and the filename the dbg was created from you can inspect > > the file using [eu-]readelf --debug-dump=info to see how the DIEs look > > at that offset. > > I'm not a DWARF/DIE expert at this point to know what to look for. > -- > Contents of the .debug_info section: > > Compilation Unit @ offset 0x0: > Length: 0x24 (32-bit) > Version: 5 > Abbrev Offset: 0x0 > Pointer Size: 8 > <0><c>: Abbrev Number: 1 (DW_TAG_compile_unit) > <d> DW_AT_stmt_list : 0x0 > <11> DW_AT_low_pc : 0x100089d4 > <19> DW_AT_high_pc : 68 > <1a> DW_AT_name : (indirect string, offset: 0x0): start.S > <1e> DW_AT_comp_dir : (indirect string, offset: 0x8): > /path/to/AT.../sources/glibc/csu > <22> DW_AT_producer : (indirect string, offset: 0x5c): GNU AS 2.36.50 > <26> DW_AT_language : 32769 (MIPS assembler) > ... > > Is there an incompatibility introduced with DWARF5? Yes, the unit header was extended in DWARF5, so the offset given to the first DIE by the old code is invalid. > > BTW. Make sure you have elfutils libdw version 0.172 or newer when > > dealing with DWARF5. Latest elfutils release is 0.182. > > SLES15SP2 has an older version: > $ rpm -qi libdw1 > Name : libdw1 > Version : 0.168 > Release : 4.5.3 Yes, unfortunately 0.168 is too old. It was released in 2016 before the DWARF 5 specification (which is from 2017). Cheers, Mark