labath created this revision. labath added reviewers: aprantl, shafik. Herald added a project: LLDB. labath requested review of this revision. Herald added a subscriber: JDevlieghere.
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 <https://reviews.llvm.org/D86348>. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D86436 Files: lldb/source/Symbol/Type.cpp lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s =================================================================== --- lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s +++ 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,"",@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: Index: lldb/source/Symbol/Type.cpp =================================================================== --- lldb/source/Symbol/Type.cpp +++ lldb/source/Symbol/Type.cpp @@ -375,6 +375,7 @@ if (ArchSpec arch = m_symbol_file->GetObjectFile()->GetArchitecture()) { m_byte_size = arch.GetAddressByteSize(); m_byte_size_has_value = true; + return m_byte_size; } } break; }
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s =================================================================== --- lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s +++ 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,"",@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: Index: lldb/source/Symbol/Type.cpp =================================================================== --- lldb/source/Symbol/Type.cpp +++ lldb/source/Symbol/Type.cpp @@ -375,6 +375,7 @@ if (ArchSpec arch = m_symbol_file->GetObjectFile()->GetArchitecture()) { m_byte_size = arch.GetAddressByteSize(); m_byte_size_has_value = true; + return m_byte_size; } } break; }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits