davea42 / libdwarf-code

Contains source for libdwarf, a library for reading DWARF2 and later DWARF. Contains source to create dwarfdump, a program which prints DWARF2 and later DWARF in readable format. Has a very limited DWARF writer set of functions in libdwarfp (producer library). Builds using GNU configure, meson, or cmake.
Other
170 stars 70 forks source link

dwarf error 468 DW_DLE_RNGLISTS_ERROR: rnglists table index of 21 is unusable unless it is in a tied file. Possibly libdwarf is incomplete.FIXME #246

Closed jeremy-rifkin closed 4 months ago

jeremy-rifkin commented 5 months ago

Sorry to open so many issues in quick succession however I've bumped into another issue with debug fission support. Thank you in advance for all the help in tackling these.

I got an error from dwarf_rnglists_get_rle_head today:

dwarf error 468 DW_DLE_RNGLISTS_ERROR: rnglists table index of 21 is unusable unless it is in a tied file. Possibly libdwarf is incomplete.FIXME

It seems to have originated from here:

https://github.com/davea42/libdwarf-code/blob/113726e89a785b3adc682d9ff2b5f95345fb299a/src/lib/libdwarf/dwarf_rnglists.c#L1341-L1354

This occurred while I was working with a dwo file path/to/build/test/CMakeFiles/demo.dir/demo.cpp.dwo with skeleton path/to/build/demo.

It appears to have happened while reading 00010c92 DW_TAG_subprogram trace in the dwo:

< 1><0x00010c92 GOFF=0x00010c92>    DW_TAG_subprogram <abbrev 206 ABGOFF = 0x00000e94 count = 0x0000000a>
                                      DW_AT_external              yes(1) <form DW_FORM_flag_present 25>
                                      DW_AT_name                  (indexed string: 0x00000333)trace <form DW_FORM_strx 26>
                                      DW_AT_decl_file             0x00000008 <form DW_FORM_data1 11>
                                      DW_AT_decl_line             0x00000008 <form DW_FORM_data1 11>
                                      DW_AT_decl_column           0x00000006 <form DW_FORM_data1 11>
                                      DW_AT_linkage_name          (indexed string: 0x0000034c)_Z5tracev <form DW_FORM_strx 26>

path/to/build/src/bin/dwarfdump/dwarfdump ERROR:  Cannot print range attribute for DW_AT_ranges:  DW_DLE_RNGLISTS_ERROR: rnglists table index of 21 is unusable unless it is in a tied file. Possibly libdwarf is incomplete.FIXME. Attempting to continue.

CU Name = (indexed string: 0x000003b6)path/to/test/demo.cpp
CU Producer = (indexed string: 0x0000057a)GNU C++17 13.2.0 -mtune=generic -march=x86-64 -gsplit-dwarf -gdwarf-5 -g -O2 -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection -fcf-protection
DIE OFF = 0x00010c92 GOFF = 0x00010c92, Low PC = unknown   , High PC = unknown   
DW_AT_ranges                <index to debug_rnglists 0x00000015> <form DW_FORM_rnglistx 35>
                                      DW_AT_frame_base            len 0x0001: 0x9c:  <form DW_FORM_exprloc 24>
                                          DW_OP_call_frame_cfa
                                      DW_AT_call_all_calls        yes(1) <form DW_FORM_flag_present 25>
                                      DW_AT_sibling               <0x00011902 GOFF=0x00011902> <form DW_FORM_ref4 19>

Happy to provide more info as needed.

davea42 commented 5 months ago

Yes, working on this.

Made progress yesterday, today is ... really busy with pre-scheduled stuff, so won't be any progress today.

You are the first to present examples and that's great, now I can actually get the code I wrote to work!

The tools to get the rnglists to work are already in the code, but for tied-files the delegation to the tied-file itself are not quite right. And in the process of working on this I noticed A bug in the DWARF5 definition document and proposed an update for DWARF6 to the committee.

davea42 commented 5 months ago

Well. I see what I need to add to cu_context setup. Needs a new internal-to-libdwarf interface. Basically to absorb the key data from .debug_rnglists in each object. Won't get done today.

davea42 commented 5 months ago

The problem was the compiler was using an implicit value for the rnglists_base in the CU-DIE in the case of a dwp object (which you called cpptrace.cpp.dwo ). That is something not clearly called out in the standard, in particular table F.1 implies it's not necessary when the the .dwp object has .debug_rnglists.

I have worked around that surprise and am currently running regression tests. It will take more than an hour to validate all the improvements in dwarfdump output in existing dwp objects in regressiontests once the run has completed.

davea42 commented 5 months ago

There were a few regressions I must investigate. Better, but not entirely correct.

davea42 commented 5 months ago

Not ready for prime time. Will take a bit longer (left indefinite).

davea42 commented 5 months ago

dwarfdump --print-debug-rnglists produces a pretty report which is none-the-less quite useless for verifying correctness. I have to fix that and then create a proper decision tree to think carefully about the section so I actually fix the code properly. Now.

davea42 commented 5 months ago

Running regression tests. We correctly generate an equivalent to DW_AT_rnglists_base when the compiler decided that such was not really needed as was reasonably simple ti generate. I think it's a mistake, but we can work around it just as gdb and others have. Corrects many instances of dwarf-generating ERROR and also changes the format of --print-debug-rnglists to be more useful and easier to read.

davea42 commented 5 months ago

Fixes pushed to github. HOWEVER: reading .debug_loclists section has the same bugs as .debug_rnglists did. I need to fix that immediately.

davea42 commented 5 months ago

.debug_loclists don't correctly deal with the missing-base situation, but the code from dwarf_rnglists to do that wiill work. Otherwise loclists look ok.

the --print-raw-loclists dwarfdump format needs improvement.

davea42 commented 4 months ago

Todays' push to github dealt with this issue.

jeremy-rifkin commented 4 months ago

Thank you so much!