[llvm] [llvm-debuginfo-analyzer] Add support for DWARF `DW_AT_byte_size` (PR #139110)

Carlos Alberto Enciso via llvm-commits llvm-commits at lists.llvm.org
Tue May 13 01:53:17 PDT 2025


================
@@ -32,9 +32,9 @@
 ; ONE-NEXT:                                    {File} 'test.cpp'
 ; ONE-NEXT:                                    {Public} 'foo' [0x0000000000:0x000000003a]
 ; ONE-NEXT: [0x000000000b][002]                {Range} Lines 2:9 [0x0000000000:0x000000003a]
-; ONE-NEXT: [0x00000000bc][002]                {BaseType} 'bool'
-; ONE-NEXT: [0x0000000099][002]                {BaseType} 'int'
-; ONE-NEXT: [0x00000000b5][002]                {BaseType} 'unsigned int'
+; ONE-NEXT: [0x00000000bc][002]                {BaseType} 'bool' [Size = 1]
+; ONE-NEXT: [0x0000000099][002]                {BaseType} 'int' [Size = 4]
+; ONE-NEXT: [0x00000000b5][002]                {BaseType} 'unsigned int' [Size = 4]
----------------
CarlosAlbertoEnciso wrote:

This is the logical view for an example using templates (suing your patch):
```
Logical View:
           {File} 'suite_template_01.o'

             {CompileUnit} 'suite_template_01.cpp'
     6         {Struct} 'template_a_class<int>' [Size = 8]
     8           {Struct} 'template_b_class<char>' [Size = 1]
     8             {Member} public 'member_3' -> 'char'
     7           {Member} public 'member_2' -> 'int'
     9           {Member} public 'T3' -> 'template_b_class<char>'
               {BaseType} 'char' [Size = 1]
               {BaseType} 'int' [Size = 4]
    12         {Variable} extern 'MyTemplate_2' -> 'template_a_class<int>'
    14         {Namespace} 'namespace_a_class'
    15           {Struct} 'template_c_class<int>' [Size = 4]
    16             {Member} public 'Member' -> 'int'
    17             {Function} public not_inlined 'template_c_class' -> 'void'
                     {Parameter} '' -> 'int'
    18             {Function} public not_inlined 'operator>' -> 'bool'
                     {Parameter} '' -> '& const template_c_class<int>'
               {BaseType} 'bool' [Size = 1]
    22         {Variable} extern 'MyTemplate_11' -> 'template_c_class<int>'
    23         {Variable} extern 'MyTemplate_12' -> 'template_c_class<int>'
               {Function} extern not_inlined 'operator>' -> 'bool'
    18           {Parameter} 'C' -> '& const template_c_class<int>'
               {Function} extern declared_not_inlined 'template_c_class' -> 'void'
    17           {Parameter} 'Member' -> 'int'
               {Function} declared_not_inlined 'template_c_class' -> 'void'
                 {Parameter} 'this' -> 'const * template_c_class<int>'
                 {Parameter} 'Member' -> 'int'
    24         {Function} extern not_inlined 'FFFF' -> 'bool'
```
Looking at the `byte size` as a special attribute for the type (type, scope), what about if we consider the inclusion of an extra option `--attribute=size`. In that case, the `[Size = 1]` or a variant is fine, as it is requested by the user.


https://github.com/llvm/llvm-project/pull/139110


More information about the llvm-commits mailing list