[llvm] Support big endian in llvm-symbolizer's data location dwarf info parser (PR #67284)

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 02:40:08 PDT 2023


https://github.com/chenzheng1030 updated https://github.com/llvm/llvm-project/pull/67284

>From ef8c5d72c7b3be098f5cb2734da5a32474f629c4 Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 25 Sep 2023 01:06:28 -0400
Subject: [PATCH 1/3] base case, nfc

---
 .../llvm-symbolizer/Inputs/xcoff-dwarf.o      | Bin 0 -> 2256 bytes
 llvm/test/tools/llvm-symbolizer/xcoff.test    |  63 ++++++++++++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o
 create mode 100644 llvm/test/tools/llvm-symbolizer/xcoff.test

diff --git a/llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o b/llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o
new file mode 100644
index 0000000000000000000000000000000000000000..04326b6ccedd0462394ebaafb3fe4d6eda50e0c1
GIT binary patch
literal 2256
zcmah~&u<$=6n?YzChK2KTnj;4AX`LAXp at cCWbLGtLQ0fFsz6JVLz|1UYp-L2V_S}s
z=FmeVklI5JIpmNN2gI=l4oKYi6SyEw94c|>-+)8}eDCer-b9Uf(#(AG%{TAO?@_O4
zgv9h;P<+JD>iGvf;Re|jk%|+=e-tJrxoK71o*PKePMq at 4RiXP8n8=WP$?|r01rZ&g
z<dhEU(c;jmK5 at OSzaJrA!rw`xP8jVtbd6T69ig=xk at kp4e_zNk<VtkSM$3=rsEDy0
zK=+f73b{t(haS-vhhz$uFqcqri$QvM)2{6k+T(}clX3VB(G*tUX=UoWvwFpPws(R)
z9@&LY=A2?_KA<JnkZ*+bZ^P0=*~h#t$4D|?l~t2QPLCPmBiD?qx{LtY9L0>)+^6Z=
zsXHkxNfi4K#9}Iy!ldSCHP`2LrB<;ZBiF%|&^USn0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test b/llvm/test/tools/llvm-symbolizer/xcoff.test
new file mode 100644
index 000000000000000..c6b65ac9b789361
--- /dev/null
+++ b/llvm/test/tools/llvm-symbolizer/xcoff.test
@@ -0,0 +1,63 @@
+
+RUN: llvm-symbolizer --obj=%p/Inputs/xcoff-dwarf.o 'DATA 0x60' \
+RUN:    'DATA 0x61' 'DATA 0x64' 'DATA 0X68' 'DATA 0x90' 'DATA 0x94' \
+RUN:    'DATA 0X98' | FileCheck %s
+
+CHECK: bss_global
+CHECK-NEXT: 96 4
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+CHECK: bss_global
+CHECK-NEXT: 96 4
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+CHECK: data_global
+CHECK-NEXT: 100 4
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+CHECK: str
+CHECK-NEXT: 104 4
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+FIXME: fix the wrong size 152
+CHECK: f()::function_global
+CHECK-NEXT: 144 152
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+FIXME: fix the wrong size 152
+CHECK: beta
+CHECK-NEXT: 148 152
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+FIXME: fix the wrong size 152
+CHECK: alpha
+CHECK-NEXT: 152 152
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+The case is from `test/tools/llvm-symbolizer/data-location.yaml`, compiled with:
+ clang++ -g -gdwarf-3 -O3 t.cpp  -nostdlib  -target powerpc-aix-ibm-xcoff \
+   -mllvm -ppc-global-merge=false
+
+     cat t.cpp
+     1	int bss_global;
+     2	int data_global = 2;
+     3
+     4	const char* str =
+     5	  "12345678";
+     6
+     7	int* f() {
+     8	  static int function_global;
+     9	  return &function_global;
+    10	}
+    11
+    12	static int alpha;
+    13	static int beta;
+    14	int *f(bool b) { return beta ? &alpha : β }
+    15

>From ba1dc6efed306c31cdbef3800144a8b8ffc1b67b Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 25 Sep 2023 01:21:28 -0400
Subject: [PATCH 2/3] support big endian while processing data location

---
 llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp     |  2 +-
 llvm/test/tools/llvm-symbolizer/xcoff.test | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 387345a4ac2d601..0cd45bde3e25349 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -784,7 +784,7 @@ void DWARFUnit::updateVariableDieMap(DWARFDie Die) {
 
   for (const DWARFLocationExpression &Location : *Locations) {
     uint8_t AddressSize = getAddressByteSize();
-    DataExtractor Data(Location.Expr, /*IsLittleEndian=*/true, AddressSize);
+    DataExtractor Data(Location.Expr, isLittleEndian(), AddressSize);
     DWARFExpression Expr(Data, AddressSize);
     auto It = Expr.begin();
     if (It == Expr.end())
diff --git a/llvm/test/tools/llvm-symbolizer/xcoff.test b/llvm/test/tools/llvm-symbolizer/xcoff.test
index c6b65ac9b789361..a4c6f89a230af5a 100644
--- a/llvm/test/tools/llvm-symbolizer/xcoff.test
+++ b/llvm/test/tools/llvm-symbolizer/xcoff.test
@@ -5,40 +5,40 @@ RUN:    'DATA 0X98' | FileCheck %s
 
 CHECK: bss_global
 CHECK-NEXT: 96 4
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:1
 CHECK-EMPTY:
 
 CHECK: bss_global
 CHECK-NEXT: 96 4
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:1
 CHECK-EMPTY:
 
 CHECK: data_global
 CHECK-NEXT: 100 4
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:2
 CHECK-EMPTY:
 
 CHECK: str
 CHECK-NEXT: 104 4
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:4
 CHECK-EMPTY:
 
 FIXME: fix the wrong size 152
 CHECK: f()::function_global
 CHECK-NEXT: 144 152
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:8
 CHECK-EMPTY:
 
 FIXME: fix the wrong size 152
 CHECK: beta
 CHECK-NEXT: 148 152
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:13
 CHECK-EMPTY:
 
 FIXME: fix the wrong size 152
 CHECK: alpha
 CHECK-NEXT: 152 152
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:12
 CHECK-EMPTY:
 
 The case is from `test/tools/llvm-symbolizer/data-location.yaml`, compiled with:

>From a93cc5272d8c6f151103ac6e67e66a3d36a0dd4b Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 25 Sep 2023 05:39:47 -0400
Subject: [PATCH 3/3] change the location of the case

---
 .../Symbolize/XCOFF}/Inputs/xcoff-dwarf.o           | Bin
 .../Symbolize/XCOFF}/xcoff.test                     |   0
 2 files changed, 0 insertions(+), 0 deletions(-)
 rename llvm/test/{tools/llvm-symbolizer => DebugInfo/Symbolize/XCOFF}/Inputs/xcoff-dwarf.o (100%)
 rename llvm/test/{tools/llvm-symbolizer => DebugInfo/Symbolize/XCOFF}/xcoff.test (100%)

diff --git a/llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o b/llvm/test/DebugInfo/Symbolize/XCOFF/Inputs/xcoff-dwarf.o
similarity index 100%
rename from llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o
rename to llvm/test/DebugInfo/Symbolize/XCOFF/Inputs/xcoff-dwarf.o
diff --git a/llvm/test/tools/llvm-symbolizer/xcoff.test b/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.test
similarity index 100%
rename from llvm/test/tools/llvm-symbolizer/xcoff.test
rename to llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.test



More information about the llvm-commits mailing list