jankratochvil created this revision.
jankratochvil added a reviewer: labath.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jankratochvil requested review of this revision.

Current `user_id_t` format is:
`63{isDebugTypes} 62..32{dwo || 7fffffff} 31..0 {die_offset}`
while current `DIERef` format is (I have made up the bit positions but the 
field widths do match):
`63{m_section==isDebugTypes} 62{m_dwo_num_valid} 61..32{m_dwo_num} 31..0 
{m_die_offset}`

Proposing to change `user_id_t` to:
`63{isDebugTypes} 62{dwo_is_valid} 61..32{dwo; 0 if !valid} 31..0 {die_offset}`

There is no benefit of having 31-bits wide `dwo_num` in `user_id_t` when it 
gets converted to 30-bits width in `DIERef`.

This patch is for future DWZ patchset which extends the `dwo_is_valid` bit into 
a 2-bit field (normal, DWO, DWZ, DWZcommon) so that both `user_id_t` and 
`DIERef` can be changed then the same way.

It would be best to somehow unify `user_id_t` and `DIERef` but I do not plan to 
do that. `user_id_t` should probably remain a number for the Python API 
compatibility while there still needs to be some class with all the methods to 
access it.

`SymbolFileDWARF::GetDwpSymbolFile()` and `SymbolFileDWARF::GetDIE` use 
0x3fffffff for DWP but that does not clash:
formerly:

- 31bits32..62:0x7fffffff = normal unit / not any DWO
- 31bits32..62:0x3fffffff = DWP
- 31bits32..62:others = DWO unit number

after this patch:

- bit62=0 30bits32..61:any = normal unit / not any DWO
- bit62=1 30bits32..61:0x3fffffff = DWP
- bit62=1 30bits32..61:others = DWO unit number


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90413

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s
  lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
  lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s
  lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s
  lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s
  lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s
  lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s
  lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s
  lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s
  lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s

Index: lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s
+++ lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s
@@ -16,15 +16,15 @@
 
 # Make sure each entity is present in the index only once.
 # SYMBOLS:      Globals and statics:
-# SYMBOLS-DAG: 3fffffff/INFO/00000023 "A"
-# SYMBOLS-DAG: 3fffffff/INFO/0000005a "A"
+# SYMBOLS-DAG: INFO/00000023 "A"
+# SYMBOLS-DAG: INFO/0000005a "A"
 # SYMBOLS-EMPTY:
 
 # SYMBOLS: Types:
-# SYMBOLS-DAG: 3fffffff/TYPE/00000018 "ENUM0"
-# SYMBOLS-DAG: 3fffffff/TYPE/0000004d "ENUM1"
-# SYMBOLS-DAG: 3fffffff/TYPE/0000002d "int"
-# SYMBOLS-DAG: 3fffffff/TYPE/00000062 "int"
+# SYMBOLS-DAG: TYPE/00000018 "ENUM0"
+# SYMBOLS-DAG: TYPE/0000004d "ENUM1"
+# SYMBOLS-DAG: TYPE/0000002d "int"
+# SYMBOLS-DAG: TYPE/00000062 "int"
 # SYMBOLS-EMPTY:
 
 .ifdef MAIN
Index: lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s
+++ lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s
@@ -6,7 +6,7 @@
 # RUN: ld.lld -m elf_x86_64 %t.o -o %t 
 # RUN: lldb-test symbols %t | FileCheck %s
 
-# CHECK: Variable{0x7fffffff00000011}, name = "color"
+# CHECK: Variable{0x00000011}, name = "color"
 # CHECK-SAME: location = DW_OP_addrx 0x0
 
         .text
Index: lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s
+++ lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s
@@ -5,14 +5,14 @@
 # RUN:   -o "image lookup -v -s lookup_rnglists2" -o exit | FileCheck %s
 
 # CHECK-LABEL: image lookup -v -s lookup_rnglists
-# CHECK:  Function: id = {0x7fffffff00000030}, name = "rnglists", range = [0x0000000000000000-0x0000000000000004)
-# CHECK:    Blocks: id = {0x7fffffff00000030}, range = [0x00000000-0x00000004)
-# CHECK-NEXT:       id = {0x7fffffff00000046}, ranges = [0x00000001-0x00000002)[0x00000003-0x00000004)
+# CHECK:  Function: id = {0x00000030}, name = "rnglists", range = [0x0000000000000000-0x0000000000000004)
+# CHECK:    Blocks: id = {0x00000030}, range = [0x00000000-0x00000004)
+# CHECK-NEXT:       id = {0x00000046}, ranges = [0x00000001-0x00000002)[0x00000003-0x00000004)
 
 # CHECK-LABEL: image lookup -v -s lookup_rnglists2
-# CHECK:  Function: id = {0x7fffffff0000007a}, name = "rnglists2", range = [0x0000000000000004-0x0000000000000007)
-# CHECK:    Blocks: id = {0x7fffffff0000007a}, range = [0x00000004-0x00000007)
-# CHECK-NEXT:       id = {0x7fffffff00000091}, range = [0x00000005-0x00000007)
+# CHECK:  Function: id = {0x0000007a}, name = "rnglists2", range = [0x0000000000000004-0x0000000000000007)
+# CHECK:    Blocks: id = {0x0000007a}, range = [0x00000004-0x00000007)
+# CHECK-NEXT:       id = {0x00000091}, range = [0x00000005-0x00000007)
 
         .text
         .p2align 12
Index: lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s
+++ lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s
@@ -6,9 +6,9 @@
 # RUN:   -o exit | FileCheck %s
 
 # CHECK-LABEL: image lookup -v -s lookup_rnglists
-# CHECK:  Function: id = {0x00000028}, name = "rnglists", range = [0x0000000000000000-0x0000000000000003)
-# CHECK:    Blocks: id = {0x00000028}, range = [0x00000000-0x00000003)
-# CHECK-NEXT:       id = {0x00000037}, range = [0x00000001-0x00000002)
+# CHECK:  Function: id = {0x4000000000000028}, name = "rnglists", range = [0x0000000000000000-0x0000000000000003)
+# CHECK:    Blocks: id = {0x4000000000000028}, range = [0x00000000-0x00000003)
+# CHECK-NEXT:       id = {0x4000000000000037}, range = [0x00000001-0x00000002)
 
         .text
 rnglists:
Index: lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s
+++ lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s
@@ -3,9 +3,9 @@
 # RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
 # RUN: %lldb %t -o "image lookup -v -s lookup_ranges" -o exit | FileCheck %s
 
-# CHECK:  Function: id = {0x7fffffff0000002b}, name = "ranges", range = [0x0000000000000000-0x0000000000000004)
-# CHECK:    Blocks: id = {0x7fffffff0000002b}, range = [0x00000000-0x00000004)
-# CHECK-NEXT:       id = {0x7fffffff0000003f}, ranges = [0x00000001-0x00000002)[0x00000003-0x00000004)
+# CHECK:  Function: id = {0x0000002b}, name = "ranges", range = [0x0000000000000000-0x0000000000000004)
+# CHECK:    Blocks: id = {0x0000002b}, range = [0x00000000-0x00000004)
+# CHECK-NEXT:       id = {0x0000003f}, ranges = [0x00000001-0x00000002)[0x00000003-0x00000004)
 
         .text
         .p2align 12
Index: lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s
+++ lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s
@@ -4,8 +4,8 @@
 # RUN: %lldb %t -o "image lookup -v -s lookup_ranges" -o exit 2>&1 | FileCheck %s
 
 # CHECK: DIE has DW_AT_ranges(0x47) attribute, but range extraction failed (No debug_ranges section),
-# CHECK:  Function: id = {0x7fffffff0000001c}, name = "ranges", range = [0x0000000000000000-0x0000000000000004)
-# CHECK:    Blocks: id = {0x7fffffff0000001c}, range = [0x00000000-0x00000004)
+# CHECK:  Function: id = {0x0000001c}, name = "ranges", range = [0x0000000000000000-0x0000000000000004)
+# CHECK:    Blocks: id = {0x0000001c}, range = [0x00000000-0x00000004)
 
         .text
         .p2align 12
Index: lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s
+++ lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s
@@ -1,8 +1,8 @@
 # RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
 # RUN: %lldb %t -o "image lookup -v -s f1" -o exit | FileCheck %s
 
-# CHECK:  Function: id = {0x7fffffff0000003c}, name = "f1", range = [0x0000000000000000-0x0000000000000001)
-# CHECK:    Blocks: id = {0x7fffffff0000003c}, range = [0x00000000-0x00000001)
+# CHECK:  Function: id = {0x0000003c}, name = "f1", range = [0x0000000000000000-0x0000000000000001)
+# CHECK:    Blocks: id = {0x0000003c}, range = [0x00000000-0x00000001)
 
 
         .text
Index: lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s
+++ lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s
@@ -11,11 +11,11 @@
 # RUN: %lldb %t -o "image lookup -a 0x48000 -v" -o exit | FileCheck %s
 
 # CHECK:   CompileUnit: id = {0x00000001}, file = "/tmp/a.cc", language = "c++"
-# CHECK:      Function: id = {0x7fffffff0000006a}, name = "::_start({{.*}})", range = [0x0000000000048000-0x000000000004800c)
+# CHECK:      Function: id = {0x0000006a}, name = "::_start({{.*}})", range = [0x0000000000048000-0x000000000004800c)
 # CHECK:     LineEntry: [0x0000000000048000-0x000000000004800a): /tmp/a.cc:4
 # CHECK:        Symbol: id = {0x00000002}, range = [0x0000000000048000-0x000000000004800c), name="_start"
-# CHECK:      Variable: id = {0x7fffffff00000075}, name = "v1", {{.*}} decl = a.cc:4
-# CHECK:      Variable: id = {0x7fffffff00000080}, name = "v2", {{.*}} decl = a.cc:4
+# CHECK:      Variable: id = {0x00000075}, name = "v1", {{.*}} decl = a.cc:4
+# CHECK:      Variable: id = {0x00000080}, name = "v2", {{.*}} decl = a.cc:4
 
 
 # Output generated via
Index: lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
+++ lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
@@ -9,8 +9,8 @@
 # RUN: ld.lld %t.o -o %t
 # RUN: lldb-test symbols %t | FileCheck %s
 
-# CHECK: Variable{0x7fffffff0000001e}, name = "X"
-# CHECK-SAME: type = {7fffffff00000033} 0x{{[0-9A-F]*}} (char [56])
+# CHECK: Variable{0x0000001e}, name = "X"
+# CHECK-SAME: type = {0000000000000033} 0x{{[0-9A-F]*}} (char [56])
 
 
 # Generated from "char X[47];"
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s
@@ -5,9 +5,9 @@
 # RUN:   -o exit | FileCheck %s
 
 # CHECK-LABEL: image lookup -v -s lookup_rnglists
-# CHECK:  Function: id = {0x7fffffff0000002d}, name = "rnglists", range = [0x0000000000000000-0x0000000000000003)
-# CHECK:    Blocks: id = {0x7fffffff0000002d}, range = [0x00000000-0x00000003)
-# CHECK-NEXT:       id = {0x7fffffff00000043}, range = [0x00000001-0x00000002)
+# CHECK:  Function: id = {0x0000002d}, name = "rnglists", range = [0x0000000000000000-0x0000000000000003)
+# CHECK:    Blocks: id = {0x0000002d}, range = [0x00000000-0x00000003)
+# CHECK-NEXT:       id = {0x00000043}, range = [0x00000001-0x00000002)
 
         .text
 rnglists:
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1268,8 +1268,9 @@
   if (GetDebugMapSymfile())
     return GetID() | ref.die_offset();
 
-  return user_id_t(GetDwoNum().getValueOr(0x7fffffff)) << 32 |
-         ref.die_offset() |
+  lldbassert(GetDwoNum().getValueOr(0) <= 0x3fffffff);
+  return user_id_t(GetDwoNum().getValueOr(0)) << 32 | ref.die_offset() |
+         lldb::user_id_t(GetDwoNum().hasValue()) << 62 |
          lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63;
 }
 
@@ -1298,9 +1299,10 @@
   DIERef::Section section =
       uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo;
 
-  llvm::Optional<uint32_t> dwo_num = uid >> 32 & 0x7fffffff;
-  if (*dwo_num == 0x7fffffff)
-    dwo_num = llvm::None;
+  llvm::Optional<uint32_t> dwo_num;
+  bool dwo_valid = uid >> 62 & 1;
+  if (dwo_valid)
+    dwo_num = uid >> 32 & 0x3fffffff;
 
   return DecodedUID{*this, {dwo_num, section, die_offset}};
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to