[PATCH] D147270: [DebugInfo] Support more than 2 operands in DWARF operations
Carlos Alberto Enciso via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 17 00:39:58 PDT 2023
CarlosAlbertoEnciso added a comment.
In D147270#4346528 <https://reviews.llvm.org/D147270#4346528>, @scott.linder wrote:
> I did a little digging and it seems like there is a faulty assumption in `LVELFReader`:
>
> // We are assuming that DW_AT_specification, DW_AT_abstract_origin,
> // DW_AT_type and DW_AT_extension do not appear at the same time
> // in the same DIE.
Thanks very much for your analysis and for creating a small reproducible test.
> This seems true for GCC, but not for Clang, at least for the simplest reproducer I could create:
>
> $ cat a.cpp
> struct S {
> static const int Arr[];
> };
> const int S::Arr[] = {
> 0, 1, 2
> };
> $ gcc -g -c a.cpp -o a.o
> $ build/bin/llvm-dwarfdump --debug-info a.o | grep -B1 -A2 DW_AT_specification
> 0x00000053: DW_TAG_variable
> DW_AT_specification (0x00000028 "Arr")
> DW_AT_decl_line (4)
> DW_AT_decl_column (0x0b)
> $ clang++ -g -c a.cpp -o a.o
> $ build/bin/llvm-dwarfdump --debug-info a.o | grep -B1 -A2 DW_AT_specification
> 0x0000001e: DW_TAG_variable
> DW_AT_specification (0x0000003e "Arr")
> DW_AT_type (0x00000068 "const int[3]")
> DW_AT_location (DW_OP_addr 0x0)
>
> It seems like the code could be adapted to track these independently, rather than assume only one is present? I can prepare a patch if that sounds reasonable to you!
I am happy with your proposal and a patch.
> Edit: This may also be a Clang bug. I haven't read the relevant DWARF sections with enough detail to say whether the DWARF itself is valid or not, but either way it seems nice to support it in llvm-debuginfo-analyzer, especially considering how much flexibility the tool already affords in terms of input
I compiled your test case with the latest Clang:
0x0000001e: DW_TAG_variable
DW_AT_specification (0x00000031 "Arr")
DW_AT_type (0x00000052 "const int[3]")
DW_AT_location (DW_OP_addrx 0x0)
DW_AT_linkage_name ("_ZN1S3ArrE")
0x00000031: DW_TAG_member
DW_AT_name ("Arr")
DW_AT_type (0x0000003a "const int[]")
DW_AT_decl_file ("/data/projects/sandbox/pr-62716.cpp")
DW_AT_decl_line (2)
DW_AT_external (true)
DW_AT_declaration (true)
>From the DWARF section for DW_AT_specification:
A debugging information entry with a DW_AT_specification attribute does not need to duplicate information provided by the debugging information entry referenced by that specification attribute.
Clang:
- Added an extra entry for DW_AT_type which seems redundant in DIE (0x1e) as by following the DW_AT_specification we can get the type
- The referenced types are pointing to different DIEs (0x52 and 0x3a).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147270/new/
https://reviews.llvm.org/D147270
More information about the llvm-commits
mailing list