[Lldb-commits] [lldb] 0de1463 - [lldb] Fix Type::GetByteSize for pointer types

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 27 06:41:18 PDT 2020


Author: Pavel Labath
Date: 2020-08-27T15:37:49+02:00
New Revision: 0de1463373918ae424cdcfeaa5b318f45c528696

URL: https://github.com/llvm/llvm-project/commit/0de1463373918ae424cdcfeaa5b318f45c528696
DIFF: https://github.com/llvm/llvm-project/commit/0de1463373918ae424cdcfeaa5b318f45c528696.diff

LOG: [lldb] Fix Type::GetByteSize for pointer types

The function was returning an incorrect (empty) value on the first
invocation. Given that this only affected the first invocation, this
bug/typo went mostly unaffected. DW_AT_const_value were particularly
badly affected by this as the GetByteSize call is
SymbolFileDWARF::ParseVariableDIE is likely to be the first call of this
function, and its effects cannot be undone by retrying.

Depends on D86348.

Differential Revision: https://reviews.llvm.org/D86436

Added: 
    

Modified: 
    lldb/source/Symbol/Type.cpp
    lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s

Removed: 
    


################################################################################
diff  --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index ecf0575b9a57..378523d00896 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -375,6 +375,7 @@ llvm::Optional<uint64_t> Type::GetByteSize(ExecutionContextScope *exe_scope) {
       if (ArchSpec arch = m_symbol_file->GetObjectFile()->GetArchitecture()) {
         m_byte_size = arch.GetAddressByteSize();
         m_byte_size_has_value = true;
+        return m_byte_size;
       }
     } break;
   }

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s
index 67c89b62339b..2275ff25ce97 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s
@@ -5,10 +5,10 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t \
-# RUN:   -o "target variable udata data1 data2 data4 data8 string strp ref4" \
+# RUN:   -o "target variable udata data1 data2 data4 data8 string strp ref4 udata_ptr" \
 # RUN:   -o exit | FileCheck %s
 
-# CHECK-LABEL: target variable udata data1 data2 data4 data8 string strp ref4
+# CHECK-LABEL: target variable
 ## Variable specified via DW_FORM_udata. This is typical for clang (10).
 # CHECK: (unsigned long) udata = 4742474247424742
 ## Variables specified via fixed-size forms. This is typical for gcc (9).
@@ -22,6 +22,8 @@
 # CHECK: (char [7]) strp = "strp"
 ## Bogus attribute form. Let's make sure we don't crash at least.
 # CHECK: (char [7]) ref4 = <empty constant data>
+## A variable of pointer type.
+# CHECK: (unsigned long *) udata_ptr = 0xdeadbeefbaadf00d
 
         .section        .debug_abbrev,"", at progbits
         .byte   1                       # Abbreviation Code
@@ -33,6 +35,13 @@
         .byte   8                       # DW_FORM_string
         .byte   0                       # EOM(1)
         .byte   0                       # EOM(2)
+        .byte   2                       # Abbreviation Code
+        .byte   15                      # DW_TAG_pointer_type
+        .byte   0                       # DW_CHILDREN_no
+        .byte   73                      # DW_AT_type
+        .byte   19                      # DW_FORM_ref4
+        .byte   0                       # EOM(1)
+        .byte   0                       # EOM(2)
         .byte   4                       # Abbreviation Code
         .byte   1                       # DW_TAG_array_type
         .byte   1                       # DW_CHILDREN_yes
@@ -109,6 +118,9 @@
         .asciz  "unsigned long"         # DW_AT_name
         .byte   8                       # DW_AT_byte_size
         .byte   7                       # DW_AT_encoding
+.Lulong_ptr:
+        .byte   2                       # Abbrev DW_TAG_pointer_type
+        .long   .Lulong-.Lcu_begin0     # DW_AT_type
 
         .byte   10                      # Abbrev DW_TAG_variable
         .asciz  "udata"                 # DW_AT_name
@@ -150,6 +162,11 @@
         .long   .Lchar_arr-.Lcu_begin0  # DW_AT_type
         .long   .Lulong-.Lcu_begin0     # DW_AT_const_value
 
+        .byte   10                      # Abbrev DW_TAG_variable
+        .asciz  "udata_ptr"             # DW_AT_name
+        .long   .Lulong_ptr-.Lcu_begin0 # DW_AT_type
+        .uleb128 0xdeadbeefbaadf00d     # DW_AT_const_value
+
         .byte   0                       # End Of Children Mark
 .Ldebug_info_end0:
 


        


More information about the lldb-commits mailing list