-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm-debuginfo-analyzer] Weird output of --compare
#57040
Comments
@llvm/issue-subscribers-debuginfo |
@aheejin Thanks very much for taking the time to try the In order to debug the issue with the comparison
it would be useful if you can attach the |
Few points from looking at the logical views: [002] 1 {TypeAlias} 'INTPTR' -> '* const int' Appears in both logical views with the same attributes (level, name, type), but it is marked as added/missing. Which is incorrect. [003] {Parameter} 'ParamBool' -> 'bool'
[003] {Parameter} 'ParamPtr' -> 'INTPTR'
[003] {Parameter} 'ParamUnsigned' -> 'unsigned int'
[003] 2 {Parameter} 'ParamBool' -> 'bool'
[003] 2 {Parameter} 'ParamPtr' -> 'INTPTR'
[003] 2 {Parameter} 'ParamUnsigned' -> 'unsigned int' For 2 functions to be logically the same, all of its children must be logically the same. [003] {Block}
[004] 4 {TypeAlias} 'INTEGER' -> 'int'
[004] 5 {Variable} 'CONSTANT' -> 'const INTEGER'
[003] {Block}
[004] 5 {Variable} 'CONSTANT' -> 'const INTEGER' The [004] 4 {TypeAlias} 'INTEGER' -> 'int'
[003] 4 {TypeAlias} 'INTEGER' -> 'int' The |
You are raising a very interesting point. For the comparison criteria, those |
As I stated in my previous comment, this seems incorrect. -[002] 1 {TypeAlias} 'INTPTR' -> '* const int'
+[002] 1 {TypeAlias} 'INTPTR' -> '* const int' The comparison is done twice: reference: test-dwarf-clang.o
target: test-dwarf-gcc.o It means the (1) Missing Scopes:
-[002] 2 {Function} extern not_inlined 'foo' -> 'int'
(2) Missing Types:
-[003] 4 {TypeAlias} 'INTEGER' -> 'int' reference: test-dwarf-gcc.o
target: test-dwarf-clang.o It means the (1) Added Scopes:
+[002] 2 {Function} extern not_inlined 'foo' -> 'int'
(2) Added Types:
+[004] 4 {TypeAlias} 'INTEGER' -> 'int' |
Your command line is correct. --coverage: Symbol location coverage.
--gaps: Missing debug location (gaps).
--location: Symbol debug location.
--range: Debug location ranges.
--register: Processor register names.
--offset: Debug information offset. |
Using llvm-debuginfo-analyzer.exe --attribute=level,coverage,gaps,range,offset --print=symbols test-dwarf-clang.o Logical View:
[0x0000000000][000] {File} 'test-dwarf-clang.o'
[0x000000000b][001] {CompileUnit} 'test.cpp'
[0x000000000b][002] {Range} Lines 2:9 [0x0000000000:0x000000003a]
[0x000000002a][002] 2 {Function} extern not_inlined 'foo' -> [0x0000000099]'int'
[0x000000002a][003] {Range} Lines 2:9 [0x0000000000:0x000000003a]
[0x0000000071][003] {Block}
[0x0000000071][004] {Range} Lines 5:8 [0x000000001c:0x000000002f]
[0x000000007e][004] 5 {Variable} 'CONSTANT' -> [0x00000000c3]'const INTEGER'
[0x000000007e][005] {Coverage} 100.00%
[0x000000007f][005] {Location}
[0x000000007f][006] {Entry} fbreg -28
[0x0000000063][003] 2 {Parameter} 'ParamBool' -> [0x00000000bc]'bool'
[0x0000000063][004] {Coverage} 100.00%
[0x0000000064][004] {Location}
[0x0000000064][005] {Entry} fbreg -21
[0x0000000047][003] 2 {Parameter} 'ParamPtr' -> [0x00000000a0]'INTPTR'
[0x0000000047][004] {Coverage} 100.00%
[0x0000000048][004] {Location}
[0x0000000048][005] {Entry} fbreg -16
[0x0000000055][003] 2 {Parameter} 'ParamUnsigned' -> [0x00000000b5]'unsigned int'
[0x0000000055][004] {Coverage} 100.00%
[0x0000000056][004] {Location}
[0x0000000056][005] {Entry} fbreg -20 Note: The |
Oh, I meant to attach the files and forgot it. I zipped test-dwarf-clang.o and test-dwarf-gcc.o and attached it here. (Github apparently doesn't support |
Thank you for checking my report!
[0x0000000055][003] 2 {Parameter} 'ParamUnsigned' -> [0x00000000b5]'unsigned int'
[0x0000000055][004] {Coverage} 100.00%
[0x0000000056][004] {Location}
[0x0000000056][005] {Entry} fbreg -20
|
Thanks for the attached object files. |
There are confirmed issues: [003] {Parameter} 'ParamBool' -> 'bool'
[003] {Parameter} 'ParamPtr' -> 'INTPTR'
[003] {Parameter} 'ParamUnsigned' -> 'unsigned int' b) These -[002] 1 {TypeAlias} 'INTPTR' -> '* const int'
+[002] 1 {TypeAlias} 'INTPTR' -> '* const int' c) The {Function} extern not_inlined 'foo' -> 'int'
|
In general the 90 OpenSteer::PolylineSegmentedPathwaySingleRadius&
91 OpenSteer::PolylineSegmentedPathwaySingleRadius::operator=( PolylineSegmentedPathwaySingleRadius other )
92 {
93 swap( other );
94 return *this;
95 } [002] {Source} 'src/polylinesegmentedpathwaysingleradius.cpp'
[002] 91 {Function} extern not_inlined 'operator=' -> '& PolylineSegmentedPathwaySingleRadius'
[003] {Range} Lines 92:94 [0x0000025370:0x0000025393]
[003] {Parameter} 'this' -> '* PolylineSegmentedPathwaySingleRadius'
[004] {Coverage} 100.00%
[004] {Location}
[005] {Entry} fbreg -8
[003] 91 {Parameter} 'other' -> 'OpenSteer::PolylineSegmentedPathwaySingleRadius'
[004] {Coverage} 71.43%
[004] {Location} Lines 92:94 [0x0000025370:0x0000025389]
[005] {Entry} breg4+0 RSI+0
[004] {Location} Lines 94:94 [0x000002538a:0x0000025393]
[005] {Entry} missing It shows: {Parameter} 'other', {Coverage} 71.43%
{Location} Lines 92:94 [0x0000025370:0x0000025389]
breg4+0 RSI+0
{Location} Lines 94:94 [0x000002538a:0x0000025393]
missing Basically, |
There are no plans to support Wasm. |
@aheejin Using the test cases from #57040 (comment): The GCC version generates debug_abbrev contents:
DW_TAG_formal_parameter DW_CHILDREN_no
...
DW_AT_decl_file DW_FORM_implicit_const 1
DW_AT_decl_line DW_FORM_implicit_const 2
DW_TAG_typedef DW_CHILDREN_no
...
DW_AT_decl_file DW_FORM_implicit_const 1
DW_AT_decl_line DW_FORM_data1 The Clang version generates DW_TAG_formal_parameter DW_CHILDREN_no
...
DW_AT_decl_file DW_FORM_data1
DW_AT_decl_line DW_FORM_data1
DW_TAG_typedef DW_CHILDREN_no
...
DW_AT_decl_file DW_FORM_data1
DW_AT_decl_line DW_FORM_data1 The |
The ELF reader ignored attributes with the DW_FORM_implicit_const form, which caused logical elements to have missing logical data (mainly line/file declaration numbers). The issue is described by llvm/llvm-project#57040 where GCC generates the following abbreviations: .debug_abbrev contents: Abbrev table for offset: 0x00000000 [1] DW_TAG_formal_parameter DW_CHILDREN_no DW_AT_decl_file DW_FORM_implicit_const 1 DW_AT_decl_line DW_FORM_implicit_const 2 [2] DW_TAG_typedef DW_CHILDREN_no DW_AT_decl_file DW_FORM_implicit_const 1 DW_AT_decl_line DW_FORM_data1
To determine if 2 LVElement are the same, the comparison module uses the line number, filename, level, name, qualified name and type attributes. In the case of the object generated by GCC, as the .debug_line is DWARF5, the ELF reader is expecting the file index to be 0-indexed and it does an internal adjustment, which causes the comparison mismatch, as their file indexes are outside the line table boundaries. The issue is described by llvm/llvm-project#57040 The ELF reader uses the .debug_line DWARF version to decide if the internal file index requires any adjustment, as it expects them to be 1-indexed. For the following test case: test.cpp void foo(void ParamPtr) { } * GCC (GNU C++17 11.3.0) - All DW_AT_decl_file use index 1. .debug_info: format = DWARF32, version = 0x0005 DW_TAG_compile_unit DW_AT_name ("test.cpp") DW_TAG_subprogram ("foo") DW_AT_decl_file (1) DW_TAG_formal_parameter ("ParamPtr") DW_AT_decl_file (1) .debug_line: Line table prologue: format (DWARF32), version (5) include_directories[0] = "..." file_names[0]: name ("test.cpp"), dir_index (0) file_names[1]: name ("test.cpp"), dir_index (0) Additional discussions here: https://www.mail-archive.com/dwarf-discuss@lists.dwarfstd.org/msg00883.html For the case of GCC (DWARF5), if the entries[0] and [1] are the same, do not perform any adjustment.
To determine if 2 LVElement are the same, the comparison module uses the line number, filename, level, name, qualified name and type attributes. In the case of the object generated by The ELF reader uses the .debug_line DWARF version to decide if the internal file index requires any adjustment, as it expects them to be 1-indexed. For the following test case: test.cpp void foo(void ParamPtr) { }
* GCC (GNU C++17 11.3.0) - All DW_AT_decl_file use index 1.
.debug_info:
format = DWARF32, version = 0x0005
DW_TAG_compile_unit
DW_AT_name ("test.cpp")
DW_TAG_subprogram ("foo")
DW_AT_decl_file (1)
DW_TAG_formal_parameter ("ParamPtr")
DW_AT_decl_file (1)
.debug_line:
Line table prologue: format (DWARF32), version (5)
include_directories[0] = "..."
file_names[0]: name ("test.cpp"), dir_index (0)
file_names[1]: name ("test.cpp"), dir_index (0) Additional discussions here: |
@aheejin I have uploaded a new series of patches that fixes the issues described:
You can download a single patch that combines all individual patches: https://reviews.llvm.org/D126875 Happy to help with any additional questions or issues. |
Thank you for the fixes! (Sorry for the delayed response) |
Hello. Thank you for making this tool available for LLVM!
I downloaded + applied all patches uploaded in Phabricator and tried to follow the user guide, and I have some questions. I'm following "Comparison Mode" section of
llvm-debuginfo-analyzer.rst
.I built
test.cpp
with both g++ and clang++ instructed in the section. This istest.cpp
, which is the same code in the instruction:This is how I built the object files:
These are my clang++ and g++ versions:
This is the analyzer's output on each of the object files, separately:
It looks gcc lacks debug info compared to clang. So the output here is little different from what the instruction expects, but I think that's fine and this is not what I'd like to ask about.
Then I ran the comparison mode as instructed in "Logical View" section:
This looks weird. Both files have
[002] 2 {Function} extern not_inlined 'foo' -> 'int'
line but somehow it is prepended with-
in one line and+
with another. Alsotest-dwarf-clang.o
has more debug info on{Parameter}
lines, but they are not listed as differences, i.e., not prepended with+
or-
.And then I ran the commands in "Logical Elements" section:
It's very confusing here. As I noted,
[002] 2 {Function} extern not_inlined 'foo' -> 'int'
line is not different in the two files, but it is listed in both "Missing Scopes" and "Added Scopes" section. Also[002] 1 {TypeAlias} 'INTPTR' -> '* const int'
line also occurs in the both files but listed in both "Missing Types" and "Added Types" section.A few more unrelated misc. questions: I'd like to know how high/low the debug info coverage is and any gaps or missing debug info, and I tried
--attribute=coverage,gaps
, but not sure if I am doing it correctly.I tried something like this but I couldn't find the relevant info. It's possible that I just don't know how to use the tool. Is this a correct way of getting this information?
Thank you!
cc @CarlosAlbertoEnciso
The text was updated successfully, but these errors were encountered: