[llvm-branch-commits] [lldb] 7ad54d1 - [lldb][wasm] Parse DWO section names

Pavel Labath via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jan 13 23:57:54 PST 2021


Author: Philip Pfaffe
Date: 2021-01-14T08:45:02+01:00
New Revision: 7ad54d193871ce69968565ea46372e81c9f1ce62

URL: https://github.com/llvm/llvm-project/commit/7ad54d193871ce69968565ea46372e81c9f1ce62
DIFF: https://github.com/llvm/llvm-project/commit/7ad54d193871ce69968565ea46372e81c9f1ce62.diff

LOG: [lldb][wasm] Parse DWO section names

Mirror ELF section parsing to support DWARF section names for
debug fission.

Reviewed By: labath

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

Added: 
    

Modified: 
    lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
    lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
index 91150fa02ebc..6c29c2326212 100644
--- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -253,6 +253,43 @@ bool ObjectFileWasm::ParseHeader() {
 
 Symtab *ObjectFileWasm::GetSymtab() { return nullptr; }
 
+static SectionType GetSectionTypeFromName(llvm::StringRef Name) {
+  if (Name.consume_front(".debug_") || Name.consume_front(".zdebug_")) {
+    return llvm::StringSwitch<SectionType>(Name)
+        .Case("abbrev", eSectionTypeDWARFDebugAbbrev)
+        .Case("abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo)
+        .Case("addr", eSectionTypeDWARFDebugAddr)
+        .Case("aranges", eSectionTypeDWARFDebugAranges)
+        .Case("cu_index", eSectionTypeDWARFDebugCuIndex)
+        .Case("frame", eSectionTypeDWARFDebugFrame)
+        .Case("info", eSectionTypeDWARFDebugInfo)
+        .Case("info.dwo", eSectionTypeDWARFDebugInfoDwo)
+        .Cases("line", "line.dwo", eSectionTypeDWARFDebugLine)
+        .Cases("line_str", "line_str.dwo", eSectionTypeDWARFDebugLineStr)
+        .Case("loc", eSectionTypeDWARFDebugLoc)
+        .Case("loc.dwo", eSectionTypeDWARFDebugLocDwo)
+        .Case("loclists", eSectionTypeDWARFDebugLocLists)
+        .Case("loclists.dwo", eSectionTypeDWARFDebugLocListsDwo)
+        .Case("macinfo", eSectionTypeDWARFDebugMacInfo)
+        .Cases("macro", "macro.dwo", eSectionTypeDWARFDebugMacro)
+        .Case("names", eSectionTypeDWARFDebugNames)
+        .Case("pubnames", eSectionTypeDWARFDebugPubNames)
+        .Case("pubtypes", eSectionTypeDWARFDebugPubTypes)
+        .Case("ranges", eSectionTypeDWARFDebugRanges)
+        .Case("rnglists", eSectionTypeDWARFDebugRngLists)
+        .Case("rnglists.dwo", eSectionTypeDWARFDebugRngListsDwo)
+        .Case("str", eSectionTypeDWARFDebugStr)
+        .Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
+        .Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)
+        .Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
+        .Case("tu_index", eSectionTypeDWARFDebugTuIndex)
+        .Case("types", eSectionTypeDWARFDebugTypes)
+        .Case("types.dwo", eSectionTypeDWARFDebugTypesDwo)
+        .Default(eSectionTypeOther);
+  }
+  return eSectionTypeOther;
+}
+
 void ObjectFileWasm::CreateSections(SectionList &unified_section_list) {
   if (m_sections_up)
     return;
@@ -280,29 +317,7 @@ void ObjectFileWasm::CreateSections(SectionList &unified_section_list) {
       // Code section.
       vm_addr = 0;
     } else {
-      section_type =
-          llvm::StringSwitch<SectionType>(sect_info.name.GetStringRef())
-              .Case(".debug_abbrev", eSectionTypeDWARFDebugAbbrev)
-              .Case(".debug_addr", eSectionTypeDWARFDebugAddr)
-              .Case(".debug_aranges", eSectionTypeDWARFDebugAranges)
-              .Case(".debug_cu_index", eSectionTypeDWARFDebugCuIndex)
-              .Case(".debug_frame", eSectionTypeDWARFDebugFrame)
-              .Case(".debug_info", eSectionTypeDWARFDebugInfo)
-              .Case(".debug_line", eSectionTypeDWARFDebugLine)
-              .Case(".debug_line_str", eSectionTypeDWARFDebugLineStr)
-              .Case(".debug_loc", eSectionTypeDWARFDebugLoc)
-              .Case(".debug_loclists", eSectionTypeDWARFDebugLocLists)
-              .Case(".debug_macinfo", eSectionTypeDWARFDebugMacInfo)
-              .Case(".debug_macro", eSectionTypeDWARFDebugMacro)
-              .Case(".debug_names", eSectionTypeDWARFDebugNames)
-              .Case(".debug_pubnames", eSectionTypeDWARFDebugPubNames)
-              .Case(".debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
-              .Case(".debug_ranges", eSectionTypeDWARFDebugRanges)
-              .Case(".debug_rnglists", eSectionTypeDWARFDebugRngLists)
-              .Case(".debug_str", eSectionTypeDWARFDebugStr)
-              .Case(".debug_str_offsets", eSectionTypeDWARFDebugStrOffsets)
-              .Case(".debug_types", eSectionTypeDWARFDebugTypes)
-              .Default(eSectionTypeOther);
+      section_type = GetSectionTypeFromName(sect_info.name.GetStringRef());
       if (section_type == eSectionTypeOther)
         continue;
       section_name = sect_info.name;

diff  --git a/lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml b/lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
index f3edf18770b1..0773dc001656 100644
--- a/lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
+++ b/lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
@@ -40,6 +40,73 @@
 # CHECK: VM size: 0
 # CHECK: File size: 3
 
+# CHECK: Name: .debug_abbrev.dwo
+# CHECK: Type: dwarf-abbrev-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_info.dwo
+# CHECK: Type: dwarf-info-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_line.dwo
+# CHECK: Type: dwarf-line
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_line_str.dwo
+# CHECK: Type: dwarf-line-str
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_loc.dwo
+# CHECK: Type: dwarf-loc-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_loclists.dwo
+# CHECK: Type: dwarf-loclists-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_macro.dwo
+# CHECK: Type: dwarf-macro
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_rnglists.dwo
+# CHECK: Type: dwarf-rnglists-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_str.dwo
+# CHECK: Type: dwarf-str-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_str_offsets.dwo
+# CHECK: Type: dwarf-str-offsets-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_types.dwo
+# CHECK: Type: dwarf-types-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+
 --- !WASM
 FileHeader:
   Version:         0x00000001
@@ -64,4 +131,37 @@ Sections:
   - Type:            CUSTOM
     Name:            .debug_str
     Payload:         636CFF
+  - Type:            CUSTOM
+    Name:            .debug_abbrev.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_info.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_line.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_line_str.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_loc.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_loclists.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_macro.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_rnglists.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_str.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_str_offsets.dwo
+    Payload:         DEADBEEF
+  - Type:            CUSTOM
+    Name:            .debug_types.dwo
+    Payload:         DEADBEEF
 ...


        


More information about the llvm-branch-commits mailing list