Author: grimar
Date: Wed Nov 14 02:35:14 2018
New Revision: 346848

URL: http://llvm.org/viewvc/llvm-project?rev=346848&view=rev
Log:
[LLDB] - Support the single file split DWARF.

DWARF5 spec describes a single file split dwarf case
(when .dwo sections are in the .o files).

Problem is that LLDB does not work correctly in that case.
The issue is that, for example, both .debug_info and .debug_info.dwo
has the same type: eSectionTypeDWARFDebugInfo. And when code searches
section by type it might find the regular debug section
and not the .dwo one.

The patch fixes that. With it, LLDB is able to work with
output compiled with -gsplit-dwarf=single flag correctly.

Differential revision: https://reviews.llvm.org/D52296

Added:
    lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
    lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
    lldb/trunk/lit/Breakpoint/single-file-split-dwarf.test
Modified:
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/source/Core/Section.cpp
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
    lldb/trunk/source/Symbol/ObjectFile.cpp

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=346848&r1=346847&r2=346848&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Nov 14 02:35:14 2018
@@ -708,6 +708,10 @@ enum SectionType {
   eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str
   eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists
   eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists
+  eSectionTypeDWARFDebugAbbrevDwo,
+  eSectionTypeDWARFDebugInfoDwo,
+  eSectionTypeDWARFDebugStrDwo,
+  eSectionTypeDWARFDebugStrOffsetsDwo,
 };
 
 FLAGS_ENUM(EmulateInstructionOptions){

Added: lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml?rev=346848&view=auto
==============================================================================
--- lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml (added)
+++ lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml Wed Nov 14 
02:35:14 2018
@@ -0,0 +1,84 @@
+--- !ELF
+FileHeader:      
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_X86_64
+Sections:        
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x0000000000000010
+    Content:         554889E531C0C745FC000000005DC390554889E55DC3
+  - Name:            .debug_str_offsets
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         0C000000050000000000000000000000
+  - Name:            .debug_str
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_MERGE, SHF_STRINGS ]
+    AddressAlign:    0x0000000000000001
+    Content:         
746573742E6F002F686F6D652F756D622F74657374735F323031382F39355F6C6C64622F726570726F2F6477617266355F73706C69745F73696E676C655F66696C652F707265706172655F73616D706C65006D61696E00666F6F005F5A33666F6F7600696E7400
+  - Name:            .debug_loc.dwo
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_EXCLUDE ]
+    AddressAlign:    0x0000000000000001
+    Content:         ''
+  - Name:            .debug_abbrev
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         01110010177217B042251B25B44219B3421711011206000000
+  - Name:            .debug_info
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         
2B00000005000408000000003F4B7684A29835B9010000000000000000000100000000000000000000000016000000
+  - Name:            .debug_macinfo
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         '00'
+  - Name:            .debug_str_offsets.dwo
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_EXCLUDE ]
+    AddressAlign:    0x0000000000000001
+    Content:         
200000000500000000000000070000002A00000033000000380000003C00000044000000
+  - Name:            .debug_str.dwo
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ]
+    AddressAlign:    0x0000000000000001
+    Content:         
746573742E6F00636C616E672076657273696F6E20382E302E3020287472756E6B203334323731382900746573742E637070006D61696E00696E74005F5A33666F6F7600666F6F00
+  - Name:            .debug_info.dwo
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_EXCLUDE ]
+    AddressAlign:    0x0000000000000001
+    Content:         
3600000005000508000000003F4B7684A29835B901000104000202000F0000000156030101350000000301060000000156050601050404050400
+  - Name:            .debug_abbrev.dwo
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_EXCLUDE ]
+    AddressAlign:    0x0000000000000001
+    Content:         
011101B042252525130503250000022E0011813E1206401803253A0B3B0B49133F190000032E0011813E120640186E2503253A0B3B0B3F19000004240003253E0B0B0B000000
+  - Name:            .debug_addr
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         '140000000500080000000000000000000000000000000000'
+  - Name:            .debug_names
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000004
+    Content:         
A00000000500000001000000000000000000000004000000040000000D000000080000004C4C564D3037303000000000010000000200000003000000040000003080880B8973880B6A7F9A7C0B3D06B5000000000000000000000000000000000000000009000000120000001B0000002E2E03130000242403130000002435000000000000002E29000000000000002E1A000000000000002E2900000000000000000000
+  - Name:            .debug_gnu_pubnames
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         
210000000200000000002F0000002900000030666F6F001A000000306D61696E0000000000
+  - Name:            .debug_gnu_pubtypes
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         170000000200000000002F0000003500000090696E740000000000
+  - Name:            .debug_line
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         
70000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E020000000000FD7C0F2E46BA561F7BDA351B04E677090000000000FD7C0F2E46BA561F7BDA351B04E6770900090200000000000000000105030AC905003F05010A4B0202000101
+  - Name:            .debug_line_str
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_MERGE, SHF_STRINGS ]
+    AddressAlign:    0x0000000000000001
+    Content:         
2F686F6D652F756D622F74657374735F323031382F39355F6C6C64622F726570726F2F6477617266355F73706C69745F73696E676C655F66696C652F707265706172655F73616D706C6500746573742E63707000
+...

Added: lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml?rev=346848&view=auto
==============================================================================
--- lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml (added)
+++ lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml Wed Nov 14 
02:35:14 2018
@@ -0,0 +1,61 @@
+--- !ELF
+FileHeader:      
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+  Entry:           0x0000000000400440
+Sections:        
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x0000000000400440
+    AddressAlign:    0x0000000000000010
+    Content:         
31ED4989D15E4889E24883E4F0505449C7C0B005400048C7C14005400048C7C720054000E8B7FFFFFFF4660F1F44000055B820204000483D202040004889E57417B8000000004885C0740D5DBF20204000FFE00F1F4400005DC3660F1F440000BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF20204000FFE00F1F005DC3660F1F440000803D391B0000007517554889E5E87EFFFFFFC605271B0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89660F1F840000000000554889E531C0C745FC000000005DC390554889E55DC3662E0F1F840000000000415741564189FF415541544C8D25B618000055488D2DB6180000534989F64989D54C29E54883EC0848C1FD03E87FFEFFFF4885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3
+  - Name:            .debug_str_offsets
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         0C000000050000000000000007000000
+  - Name:            .debug_str
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_MERGE, SHF_STRINGS ]
+    AddressAlign:    0x0000000000000001
+    Content:         
746573742E6F002F686F6D652F756D622F74657374735F323031382F39355F6C6C64622F726570726F2F6477617266355F73706C69745F73696E676C655F66696C652F707265706172655F73616D706C65006D61696E00666F6F005F5A33666F6F7600696E7400
+  - Name:            .debug_abbrev
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         01110010177217B042251B25B44219B3421711011206000000
+  - Name:            .debug_info
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         
2B00000005000408000000003F4B7684A29835B9010000000008000000000108000000200540000000000016000000
+  - Name:            .debug_macinfo
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         '00'
+  - Name:            .debug_addr
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         '140000000500080020054000000000003005400000000000'
+  - Name:            .debug_names
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000004
+    Content:         
A00000000500000001000000000000000000000004000000040000000D000000080000004C4C564D3037303000000000010000000200000003000000040000003080880B8973880B6A7F9A7C0B3D06B56300000057000000520000005B0000000000000009000000120000001B0000002E2E03130000242403130000002435000000000000002E29000000000000002E1A000000000000002E2900000000000000000000
+  - Name:            .debug_gnu_pubnames
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         
210000000200000000002F0000002900000030666F6F001A000000306D61696E0000000000
+  - Name:            .debug_gnu_pubtypes
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         170000000200000000002F0000003500000090696E740000000000
+  - Name:            .debug_line
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         
70000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E024B00000000FD7C0F2E46BA561F7BDA351B04E677094B00000000FD7C0F2E46BA561F7BDA351B04E6770900090220054000000000000105030AC905003F05010A4B0202000101
+  - Name:            .debug_line_str
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_MERGE, SHF_STRINGS ]
+    AddressAlign:    0x0000000000000001
+    Content:         
2F686F6D652F756D622F74657374735F323031382F39355F6C6C64622F726570726F2F6477617266355F73706C69745F73696E676C655F66696C652F707265706172655F73616D706C6500746573742E63707000
+...

Added: lldb/trunk/lit/Breakpoint/single-file-split-dwarf.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/single-file-split-dwarf.test?rev=346848&view=auto
==============================================================================
--- lldb/trunk/lit/Breakpoint/single-file-split-dwarf.test (added)
+++ lldb/trunk/lit/Breakpoint/single-file-split-dwarf.test Wed Nov 14 02:35:14 
2018
@@ -0,0 +1,38 @@
+# RUN: yaml2obj %p/Inputs/single-file-split-dwarf.yaml > %ttest
+# RUN: yaml2obj %p/Inputs/single-file-split-dwarf.o.yaml > %ttest.o
+# RUN: lldb-test breakpoints %ttest %s | FileCheck %s
+
+# This test checks that source code location is shown correctly
+# when single split file debug information is used (when .dwo sections are in 
.o files).
+#
+# single-file-split-dwarf.yaml and single-file-split-dwarf.o.yaml are
+# reduced yaml files produces from the object file and the corresponding 
executable.
+#
+# The following code was used initially:
+# int main() {
+#   return 0;
+# }
+# 
+# void foo() {
+# }
+#
+# Invocation used to produce .o file was:
+# clang test.cpp -gdwarf-5 -gsplit-dwarf=single -c -o test.o -v
+#
+# Invocation used to produce the executable was:
+# "/usr/local/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 
-dynamic-linker
+#  /lib64/ld-linux-x86-64.so.2 -o test 
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crt1.o
+#  /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crti.o 
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/crtbegin.o
+#  -L/usr/lib/gcc/x86_64-linux-gnu/7.3.0 
-L/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu
+#  -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu 
-L/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../..
+#  -L/home/umb/LLVM/build/bin/../lib -L/lib -L/usr/lib test.o -lgcc 
--as-needed -lgcc_s --no-as-needed -lc -lgcc
+#  --as-needed -lgcc_s --no-as-needed 
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/crtend.o
+#  /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crtn.o
+
+b main
+# CHECK-LABEL: b main
+# CHECK: Address: {{.*}}main + 13 at test.cpp:2:3
+
+b foo
+# CHECK-LABEL: b foo
+# CHECK: Address: {{.*}}foo() + 4 at test.cpp:6:1

Modified: lldb/trunk/source/Core/Section.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=346848&r1=346847&r2=346848&view=diff
==============================================================================
--- lldb/trunk/source/Core/Section.cpp (original)
+++ lldb/trunk/source/Core/Section.cpp Wed Nov 14 02:35:14 2018
@@ -61,6 +61,8 @@ const char *Section::GetTypeAsCString()
     return "objc-cfstrings";
   case eSectionTypeDWARFDebugAbbrev:
     return "dwarf-abbrev";
+  case eSectionTypeDWARFDebugAbbrevDwo:
+    return "dwarf-abbrev-dwo";
   case eSectionTypeDWARFDebugAddr:
     return "dwarf-addr";
   case eSectionTypeDWARFDebugAranges:
@@ -71,6 +73,8 @@ const char *Section::GetTypeAsCString()
     return "dwarf-frame";
   case eSectionTypeDWARFDebugInfo:
     return "dwarf-info";
+  case eSectionTypeDWARFDebugInfoDwo:
+    return "dwarf-info-dwo";
   case eSectionTypeDWARFDebugLine:
     return "dwarf-line";
   case eSectionTypeDWARFDebugLineStr:
@@ -93,8 +97,12 @@ const char *Section::GetTypeAsCString()
     return "dwarf-rnglists";
   case eSectionTypeDWARFDebugStr:
     return "dwarf-str";
+  case eSectionTypeDWARFDebugStrDwo:
+    return "dwarf-str-dwo";
   case eSectionTypeDWARFDebugStrOffsets:
     return "dwarf-str-offsets";
+  case eSectionTypeDWARFDebugStrOffsetsDwo:
+    return "dwarf-str-offsets-dwo";
   case eSectionTypeDWARFDebugTypes:
     return "dwarf-types";
   case eSectionTypeDWARFDebugNames:

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=346848&r1=346847&r2=346848&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Nov 14 
02:35:14 2018
@@ -1897,9 +1897,9 @@ void ObjectFileELF::CreateSections(Secti
       else if (name == g_sect_name_dwarf_debug_str_offsets)
         sect_type = eSectionTypeDWARFDebugStrOffsets;
       else if (name == g_sect_name_dwarf_debug_abbrev_dwo)
-        sect_type = eSectionTypeDWARFDebugAbbrev;
+        sect_type = eSectionTypeDWARFDebugAbbrevDwo;
       else if (name == g_sect_name_dwarf_debug_info_dwo)
-        sect_type = eSectionTypeDWARFDebugInfo;
+        sect_type = eSectionTypeDWARFDebugInfoDwo;
       else if (name == g_sect_name_dwarf_debug_line_dwo)
         sect_type = eSectionTypeDWARFDebugLine;
       else if (name == g_sect_name_dwarf_debug_line_str_dwo)
@@ -1911,9 +1911,9 @@ void ObjectFileELF::CreateSections(Secti
       else if (name == g_sect_name_dwarf_debug_loclists_dwo)
         sect_type = eSectionTypeDWARFDebugLocLists;
       else if (name == g_sect_name_dwarf_debug_str_dwo)
-        sect_type = eSectionTypeDWARFDebugStr;
+        sect_type = eSectionTypeDWARFDebugStrDwo;
       else if (name == g_sect_name_dwarf_debug_str_offsets_dwo)
-        sect_type = eSectionTypeDWARFDebugStrOffsets;
+        sect_type = eSectionTypeDWARFDebugStrOffsetsDwo;
       else if (name == g_sect_name_eh_frame)
         sect_type = eSectionTypeEHFrame;
       else if (name == g_sect_name_arm_exidx)

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=346848&r1=346847&r2=346848&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Nov 14 
02:35:14 2018
@@ -1187,11 +1187,13 @@ AddressClass ObjectFileMachO::GetAddress
 
           case eSectionTypeDebug:
           case eSectionTypeDWARFDebugAbbrev:
+          case eSectionTypeDWARFDebugAbbrevDwo:
           case eSectionTypeDWARFDebugAddr:
           case eSectionTypeDWARFDebugAranges:
           case eSectionTypeDWARFDebugCuIndex:
           case eSectionTypeDWARFDebugFrame:
           case eSectionTypeDWARFDebugInfo:
+          case eSectionTypeDWARFDebugInfoDwo:
           case eSectionTypeDWARFDebugLine:
           case eSectionTypeDWARFDebugLineStr:
           case eSectionTypeDWARFDebugLoc:
@@ -1204,7 +1206,9 @@ AddressClass ObjectFileMachO::GetAddress
           case eSectionTypeDWARFDebugRanges:
           case eSectionTypeDWARFDebugRngLists:
           case eSectionTypeDWARFDebugStr:
+          case eSectionTypeDWARFDebugStrDwo:
           case eSectionTypeDWARFDebugStrOffsets:
+          case eSectionTypeDWARFDebugStrOffsetsDwo:
           case eSectionTypeDWARFDebugTypes:
           case eSectionTypeDWARFAppleNames:
           case eSectionTypeDWARFAppleTypes:

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=346848&r1=346847&r2=346848&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Nov 14 
02:35:14 2018
@@ -233,11 +233,11 @@ public:
 
   uint32_t GetPluginVersion() override;
 
-  const lldb_private::DWARFDataExtractor &get_debug_abbrev_data();
-  const lldb_private::DWARFDataExtractor &get_debug_addr_data();
+  virtual const lldb_private::DWARFDataExtractor &get_debug_abbrev_data();
+  virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
   const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
-  const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  virtual const lldb_private::DWARFDataExtractor &get_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
@@ -245,8 +245,8 @@ public:
   const lldb_private::DWARFDataExtractor &get_debug_loclists_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
-  const lldb_private::DWARFDataExtractor &get_debug_str_data();
-  const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
+  virtual const lldb_private::DWARFDataExtractor &get_debug_str_data();
+  virtual const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
   const lldb_private::DWARFDataExtractor &get_debug_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_names_data();
   const lldb_private::DWARFDataExtractor &get_apple_types_data();

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp?rev=346848&r1=346847&r2=346848&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp Wed Nov 
14 02:35:14 2018
@@ -61,14 +61,6 @@ SymbolFileDWARFDwo::ParseCompileUnit(DWA
 }
 
 DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() {
-  // A clang module is found via a skeleton CU, but is not a proper DWO.
-  // Clang modules have a .debug_info section instead of the *_dwo variant.
-  if (auto *section_list = m_obj_file->GetSectionList(false))
-    if (auto section_sp =
-            section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true))
-      if (!section_sp->GetName().GetStringRef().endswith("dwo"))
-        return nullptr;
-
   // Only dwo files with 1 compile unit is supported
   if (GetNumCompileUnits() == 1)
     return DebugInfo()->GetCompileUnitAtIndex(0);
@@ -126,6 +118,37 @@ DWARFUnit *SymbolFileDWARFDwo::GetBaseCo
   return m_base_dwarf_cu;
 }
 
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_abbrev_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugAbbrevDwo,
+                              m_data_debug_abbrev);
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() {
+  // For single file split dwarf case (when we have .dwo sections in a .o),
+  // we do not want to use the .debug_addr section from .o file,
+  // but want to get one from the final executable.
+  // For regular split debug case, .dwo file does not contain the
+  // .debug_addr, so we would always fall back to such lookup anyways.
+  llvm::call_once(m_data_debug_addr.m_flag, [this] {
+    SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr,
+                                     std::ref(m_data_debug_addr.m_data));
+  });
+  return m_data_debug_addr.m_data;
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, 
m_data_debug_info);
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugStrDwo, m_data_debug_str);
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_offsets_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugStrOffsetsDwo,
+                              m_data_debug_str_offsets);
+}
+
 SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
   return m_base_dwarf_cu->GetSymbolFileDWARF();
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h?rev=346848&r1=346847&r2=346848&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h Wed Nov 14 
02:35:14 2018
@@ -46,6 +46,12 @@ public:
 
   DWARFUnit *GetBaseCompileUnit() override;
 
+  const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_info_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_str_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() 
override;
+
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
                        lldb_private::DWARFDataExtractor &data) override;

Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=346848&r1=346847&r2=346848&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
+++ lldb/trunk/source/Symbol/ObjectFile.cpp Wed Nov 14 02:35:14 2018
@@ -345,11 +345,13 @@ AddressClass ObjectFile::GetAddressClass
             return AddressClass::eData;
           case eSectionTypeDebug:
           case eSectionTypeDWARFDebugAbbrev:
+          case eSectionTypeDWARFDebugAbbrevDwo:
           case eSectionTypeDWARFDebugAddr:
           case eSectionTypeDWARFDebugAranges:
           case eSectionTypeDWARFDebugCuIndex:
           case eSectionTypeDWARFDebugFrame:
           case eSectionTypeDWARFDebugInfo:
+          case eSectionTypeDWARFDebugInfoDwo:
           case eSectionTypeDWARFDebugLine:
           case eSectionTypeDWARFDebugLineStr:
           case eSectionTypeDWARFDebugLoc:
@@ -362,7 +364,9 @@ AddressClass ObjectFile::GetAddressClass
           case eSectionTypeDWARFDebugRanges:
           case eSectionTypeDWARFDebugRngLists:
           case eSectionTypeDWARFDebugStr:
+          case eSectionTypeDWARFDebugStrDwo:
           case eSectionTypeDWARFDebugStrOffsets:
+          case eSectionTypeDWARFDebugStrOffsetsDwo:
           case eSectionTypeDWARFDebugTypes:
           case eSectionTypeDWARFAppleNames:
           case eSectionTypeDWARFAppleTypes:


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to