[Lldb-commits] [lldb] a136699 - [nfc] [lldb] Align `user_id_t` format to the current `DIERef` format

Jan Kratochvil via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 30 08:51:02 PDT 2020


Author: Jan Kratochvil
Date: 2020-10-30T16:50:52+01:00
New Revision: a136699b2a989631f4fd84aa099fc1e731b493c2

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

LOG: [nfc] [lldb] Align `user_id_t` format to the current `DIERef` format

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

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

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 9d6733e6a4f0..b19881ff929f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1267,8 +1267,9 @@ user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
   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;
 }
 
@@ -1297,9 +1298,10 @@ SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) {
   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}};
 }

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s
index df089668cd96..ad9b20be4056 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s
+++ b/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:

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/array-sizes.s b/lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
index b810527b5535..b02be7b8ab0d 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
+++ b/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];"

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s b/lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s
index e87f8c8569db..6091cbb5b50e 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s
+++ b/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

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s b/lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s
index 9de61e48ef7b..490338232ceb 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s
+++ b/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

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s b/lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s
index 98d4e91c3e11..39e989e26eb0 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s
+++ b/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

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s b/lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s
index 13eea1b80706..2e410994eb02 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s
+++ b/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

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s b/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s
index 17ed6a76b7eb..f9f55cf2aa6b 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s
+++ b/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:

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s b/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s
index 1d718054a587..56be1c02daae 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s
+++ b/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

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s b/lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s
index 4093ea059808..edda075c20f1 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s
+++ b/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

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s b/lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s
index c7450655457e..a046ca6b1496 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s
+++ b/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


        


More information about the lldb-commits mailing list