diff options
| author | Pavel Labath <pavel@labath.sk> | 2020-02-21 15:42:07 +0100 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2020-02-21 16:01:17 +0100 |
| commit | de8793b9184ece0d24f46bc2d86711092848f938 (patch) | |
| tree | be56dbe527b5a7dac31fa41fc2ece21422bba8f4 | |
| parent | 175f6e309ab911d43ab21707587615341112f3b5 (diff) | |
| download | llvm-de8793b9184ece0d24f46bc2d86711092848f938.zip llvm-de8793b9184ece0d24f46bc2d86711092848f938.tar.gz llvm-de8793b9184ece0d24f46bc2d86711092848f938.tar.bz2 | |
[lldb/DWARF] Add support for type units in dwp files
all that was needed was to teach lldb's DWARF context about the
debug_tu_index section.
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h | 2 | ||||
| -rw-r--r-- | lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s | 211 |
3 files changed, 219 insertions, 0 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp index 79601e3..37e28a0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp @@ -45,6 +45,11 @@ const DWARFDataExtractor &DWARFContext::getOrLoadCuIndexData() { m_data_debug_cu_index); } +const DWARFDataExtractor &DWARFContext::getOrLoadTuIndexData() { + return LoadOrGetSection(llvm::None, eSectionTypeDWARFDebugTuIndex, + m_data_debug_tu_index); +} + const DWARFDataExtractor &DWARFContext::getOrLoadAbbrevData() { return LoadOrGetSection(eSectionTypeDWARFDebugAbbrev, eSectionTypeDWARFDebugAbbrevDwo, m_data_debug_abbrev); @@ -134,6 +139,7 @@ llvm::DWARFContext &DWARFContext::GetAsLLVM() { AddSection("debug_line_str", getOrLoadLineStrData()); AddSection("debug_cu_index", getOrLoadCuIndexData()); + AddSection("debug_tu_index", getOrLoadTuIndexData()); m_llvm_context = llvm::DWARFContext::create(section_map, addr_size); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h index 8de5e9c..92161a2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h @@ -42,6 +42,7 @@ private: SectionData m_data_debug_rnglists; SectionData m_data_debug_str; SectionData m_data_debug_str_offsets; + SectionData m_data_debug_tu_index; SectionData m_data_debug_types; const DWARFDataExtractor & @@ -50,6 +51,7 @@ private: SectionData &data); const DWARFDataExtractor &getOrLoadCuIndexData(); + const DWARFDataExtractor &getOrLoadTuIndexData(); public: explicit DWARFContext(SectionList *main_section_list, diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s b/lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s new file mode 100644 index 0000000..fd00938 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s @@ -0,0 +1,211 @@ +# REQUIRES: x86 + +# RUN: llvm-mc --filetype=obj --triple x86_64-pc-linux %s -o %t --defsym MAIN=0 +# RUN: llvm-mc --filetype=obj --triple x86_64-pc-linux %s -o %t.dwp --defsym DWP=0 +# RUN: %lldb %t -o "type lookup ENUM0" -o "target variable A" -b | FileCheck %s + +# CHECK-LABEL: type lookup ENUM0 +# CHECK-NEXT: enum ENUM0 { +# CHECK-NEXT: case0 +# CHECK-NEXT: } + +# CHECK-LABEL: target variable A +# CHECK: (ENUM0) A = case0 +# CHECK: (ENUM1) A = case0 + +.ifdef MAIN + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .ascii "\260B" # DW_AT_GNU_dwo_name + .byte 8 # DW_FORM_string + .ascii "\261B" # DW_AT_GNU_dwo_id + .byte 7 # DW_FORM_data8 + .ascii "\263B" # DW_AT_GNU_addr_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + +.irpc I,01 + .data +A\I: + .long 0 + + .section .debug_info,"",@progbits +.Lcu_begin\I: + .long .Ldebug_info_end\I-.Ldebug_info_start\I # Length of Unit +.Ldebug_info_start\I: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] DW_TAG_compile_unit + .asciz "A.dwo" # DW_AT_GNU_dwo_name + .quad \I # DW_AT_GNU_dwo_id + .long .debug_addr # DW_AT_GNU_addr_base +.Ldebug_info_end\I: + + .section .debug_addr,"",@progbits + .quad A\I + +.endr +.endif + +.ifdef DWP +.irpc I,01 + .section .debug_abbrev.dwo,"e",@progbits +.Labbrev\I: + .byte \I*10+1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 8 # DW_FORM_string + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte \I*10+2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte \I*10+3 # Abbreviation Code + .byte 4 # DW_TAG_enumeration_type + .byte 0 # DW_CHILDREN_no + .byte 60 # DW_AT_declaration + .byte 25 # DW_FORM_flag_present + .byte 105 # DW_AT_signature + .byte 32 # DW_FORM_ref_sig8 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte \I*10+4 # Abbreviation Code + .byte 4 # DW_TAG_enumeration_type + .byte 1 # DW_CHILDREN_yes + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte \I*10+5 # Abbreviation Code + .byte 40 # DW_TAG_enumerator + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 28 # DW_AT_const_value + .byte 15 # DW_FORM_udata + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte \I*10+6 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte \I*10+7 # Abbreviation Code + .byte 65 # DW_TAG_type_unit + .byte 1 # DW_CHILDREN_yes + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) +.Labbrev_end\I: + + .section .debug_info.dwo,"e",@progbits +.Lcu_begin\I: + .long .Ldebug_info_end\I-.Ldebug_info_start\I # Length of Unit +.Ldebug_info_start\I: + .short 4 # DWARF version number + .long 0 # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte \I*10+1 # Abbrev DW_TAG_compile_unit + .asciz "Hand-written DWARF" # DW_AT_producer + .byte '0'+\I, '.', 'c', 0 # DW_AT_name + .byte \I*10+2 # Abbrev DW_TAG_variable + .asciz "A" # DW_AT_name + .long .Lenum_ref\I-.Lcu_begin\I# DW_AT_type + .byte 2 # DW_AT_location + .byte 0xfb # DW_OP_GNU_addr_index + .byte \I + +.Lenum_ref\I: + .byte \I*10+3 # Abbrev DW_TAG_enumeration_type + .quad \I # DW_AT_signature + + .byte 0 # End Of Children Mark +.Ldebug_info_end\I: + + .section .debug_types.dwo,"e",@progbits +.Ltu_begin\I: + .long .Ltype_info_end\I-.Ltype_info_start\I # Length of Unit +.Ltype_info_start\I: + .short 4 # DWARF version number + .long 0 # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .quad \I # Type Signature + .long .Lenum\I-.Ltu_begin\I # Type DIE Offset + .byte \I*10+7 # Abbrev DW_TAG_type_unit + +.Lenum\I: + .byte \I*10+4 # Abbrev DW_TAG_enumeration_type + .long .Lint\I-.Ltu_begin\I # DW_AT_type + .byte 'E', 'N', 'U', 'M', '0'+\I, 0# DW_AT_name + .byte 4 # DW_AT_byte_size + + .byte \I*10+5 # Abbrev DW_TAG_enumerator + .asciz "case0" # DW_AT_name + .byte 0 # DW_AT_const_value + .byte 0 # End Of Children Mark + +.Lint\I: + .byte \I*10+6 # Abbrev DW_TAG_base_type + .asciz "int" # DW_AT_name + .byte 7 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + + .byte 0 # End Of Children Mark +.Ltype_info_end\I: +.endr + +.macro index dw_sect, section, contrib, contrib_end + .short 2 # DWARF version number + .short 0 # Reserved + .long 2 # Section count + .long 2 # Unit count + .long 4 # Slot count + + .quad 0, 1, 0, 0 # Hash table + .long 1, 2, 0, 0 # Index table + + .long \dw_sect + .long 3 # DW_SECT_ABBREV + +.irpc I,01 + .long \contrib\I-\section + .long .Labbrev\I-.debug_abbrev.dwo +.endr +.irpc I,01 + .long \contrib_end\I-\contrib\I + .long .Labbrev_end\I-.Labbrev\I +.endr +.endmacro + + .section .debug_cu_index,"e",@progbits + index 1, .debug_info.dwo, .Lcu_begin, .Ldebug_info_end + + .section .debug_tu_index,"e",@progbits + index 2, .debug_types.dwo, .Ltu_begin, .Ltype_info_end +.endif |
