[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

Stefan Gränitz via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 23 03:42:56 PDT 2024


https://github.com/weliveindetail updated https://github.com/llvm/llvm-project/pull/112928

>From bb66f56138cab9651aff4ac09096ede975c90701 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Fri, 18 Oct 2024 17:44:26 +0200
Subject: [PATCH 1/6] [lldb] Fix crash due to missing MSInheritanceAttr on
 CXXRecordDecl for DWARF on Windows

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fe0c53a7e9a3ea..a23dce97f3f299 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2771,6 +2771,9 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
         ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType(),
         allow_completion);
 
+  case clang::Type::MemberPointer:
+    return !qual_type.getTypePtr()->isIncompleteType();
+
   default:
     break;
   }

>From 6f775566a4face29f85286295aafb16c4367a917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Tue, 22 Oct 2024 11:11:53 +0200
Subject: [PATCH 2/6] Add test based on
 https://reviews.llvm.org/D130942#change-1PvUCFvQjDIO

---
 .../Shell/SymbolFile/DWARF/x86/ms-abi.cpp     | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
new file mode 100644
index 00000000000000..0e51ec99934f4c
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
@@ -0,0 +1,45 @@
+// REQUIRES: lld
+
+// Check that we don't crash on variables without MSInheritanceAttr
+
+// RUN: %clang -c --target=x86_64-windows-msvc -gdwarf %s -o %t.obj
+// RUN: lld-link /out:%t.exe %t.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9"
+
+class SI {
+  int si;
+};
+struct SI2 {
+  int si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+typedef void (SI::*SITYPE)();
+typedef void (MI::*MITYPE)();
+typedef void (MI2::*MI2TYPE)();
+typedef void (VI::*VITYPE)();
+typedef void (VI2::*VI2TYPE)();
+typedef void (UI::*UITYPE)();
+SITYPE mp1 = nullptr;
+MITYPE mp2 = nullptr;
+MI2TYPE mp3 = nullptr;
+VITYPE mp4 = nullptr;
+VI2TYPE mp5 = nullptr;
+UITYPE mp6 = nullptr;
+MITYPE *mp7 = nullptr;
+VI2TYPE *mp8 = nullptr;
+int SI::*mp9 = nullptr;
+
+int main() {}

>From a892f5eba8e79dbc115cffb1eb26501cdef56f80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Tue, 22 Oct 2024 15:27:33 +0200
Subject: [PATCH 3/6] Polish test and add coverage for Itanium

---
 .../SymbolFile/DWARF/x86/member-pointers.cpp  | 48 +++++++++++++++++++
 .../Shell/SymbolFile/DWARF/x86/ms-abi.cpp     | 45 -----------------
 2 files changed, 48 insertions(+), 45 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
 delete mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
new file mode 100644
index 00000000000000..93fa999416b74e
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
@@ -0,0 +1,48 @@
+// REQUIRES: lld
+
+// Microsoft ABI:
+// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
+// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9"
+//
+// DWARF has no representation of MSInheritanceAttr, so we cannot determine the size
+// of member-pointers yet. For the moment, make sure we don't crash on such variables.
+
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: ld.lld %t_linux.o -o %t_linux
+// RUN: %lldb -f %t_linux -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9" | FileCheck %s
+//
+// CHECK: (char SI2::*) mp9 = 0x0000000000000000
+
+class SI {
+  double si;
+};
+struct SI2 {
+  char si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+double SI::* mp1 = nullptr;
+int MI::* mp2 = nullptr;
+int MI2::* mp3 = nullptr;
+int VI::* mp4 = nullptr;
+int VI2::* mp5 = nullptr;
+int UI::* mp6 = nullptr;
+int MI::* mp7 = nullptr;
+int VI2::* mp8 = nullptr;
+char SI2::* mp9 = &SI2::si2;
+
+int main() { return 0; }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
deleted file mode 100644
index 0e51ec99934f4c..00000000000000
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// REQUIRES: lld
-
-// Check that we don't crash on variables without MSInheritanceAttr
-
-// RUN: %clang -c --target=x86_64-windows-msvc -gdwarf %s -o %t.obj
-// RUN: lld-link /out:%t.exe %t.obj /nodefaultlib /entry:main /debug
-// RUN: %lldb -f %t.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9"
-
-class SI {
-  int si;
-};
-struct SI2 {
-  int si2;
-};
-class MI : SI, SI2 {
-  int mi;
-};
-class MI2 : MI {
-  int mi2;
-};
-class VI : virtual MI {
-  int vi;
-};
-class VI2 : virtual SI, virtual SI2 {
-  int vi;
-};
-class /* __unspecified_inheritance*/ UI;
-
-typedef void (SI::*SITYPE)();
-typedef void (MI::*MITYPE)();
-typedef void (MI2::*MI2TYPE)();
-typedef void (VI::*VITYPE)();
-typedef void (VI2::*VI2TYPE)();
-typedef void (UI::*UITYPE)();
-SITYPE mp1 = nullptr;
-MITYPE mp2 = nullptr;
-MI2TYPE mp3 = nullptr;
-VITYPE mp4 = nullptr;
-VI2TYPE mp5 = nullptr;
-UITYPE mp6 = nullptr;
-MITYPE *mp7 = nullptr;
-VI2TYPE *mp8 = nullptr;
-int SI::*mp9 = nullptr;
-
-int main() {}

>From 45a211ef122a5dd77017ac9507d6be1cc9bb7ddc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Tue, 22 Oct 2024 15:43:48 +0200
Subject: [PATCH 4/6] fixup! Polish test and add coverage for Itanium

---
 .../SymbolFile/DWARF/x86/member-pointers.cpp   | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
index 93fa999416b74e..b50c0f990a4cc7 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
@@ -35,14 +35,14 @@ class VI2 : virtual SI, virtual SI2 {
 };
 class /* __unspecified_inheritance*/ UI;
 
-double SI::* mp1 = nullptr;
-int MI::* mp2 = nullptr;
-int MI2::* mp3 = nullptr;
-int VI::* mp4 = nullptr;
-int VI2::* mp5 = nullptr;
-int UI::* mp6 = nullptr;
-int MI::* mp7 = nullptr;
-int VI2::* mp8 = nullptr;
-char SI2::* mp9 = &SI2::si2;
+double SI::*mp1 = nullptr;
+int MI::*mp2 = nullptr;
+int MI2::*mp3 = nullptr;
+int VI::*mp4 = nullptr;
+int VI2::*mp5 = nullptr;
+int UI::*mp6 = nullptr;
+int MI::*mp7 = nullptr;
+int VI2::*mp8 = nullptr;
+char SI2::*mp9 = &SI2::si2;
 
 int main() { return 0; }

>From 5444d5a72809174087e1687c46db27513ff3b04c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Tue, 22 Oct 2024 17:18:37 +0200
Subject: [PATCH 5/6] fixup! Polish test and add coverage for Itanium

---
 .../SymbolFile/DWARF/x86/member-pointers.cpp     | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
index b50c0f990a4cc7..cc1a1b03817625 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
@@ -1,19 +1,17 @@
-// REQUIRES: lld
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: %lldb -f %t_linux.o -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9" | FileCheck %s
+//
+// CHECK: (char SI2::*) mp9 = 0x0000000000000000
 
 // Microsoft ABI:
 // RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
 // RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
-// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9"
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9" | FileCheck --check-prefix=CHECK-MSVC %s
 //
 // DWARF has no representation of MSInheritanceAttr, so we cannot determine the size
 // of member-pointers yet. For the moment, make sure we don't crash on such variables.
-
-// Itanium ABI:
-// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
-// RUN: ld.lld %t_linux.o -o %t_linux
-// RUN: %lldb -f %t_linux -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9" | FileCheck %s
-//
-// CHECK: (char SI2::*) mp9 = 0x0000000000000000
+// CHECK-MSVC: error: Unable to determine byte size.
 
 class SI {
   double si;

>From 39c6e1b2f53d6ba5375ca1bf558e84001d4d68d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Wed, 23 Oct 2024 12:42:25 +0200
Subject: [PATCH 6/6] fixup! Polish test and add coverage for Itanium

---
 .../SymbolFile/DWARF/x86/member-pointers.cpp  | 36 ++++---------------
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
index cc1a1b03817625..9ad2034cbe0f33 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
@@ -1,46 +1,22 @@
 // Itanium ABI:
 // RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
-// RUN: %lldb -f %t_linux.o -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9" | FileCheck %s
+// RUN: %lldb -f %t_linux.o -b -o "target variable mp" | FileCheck %s
 //
-// CHECK: (char SI2::*) mp9 = 0x0000000000000000
+// CHECK: (char SI::*) mp = 0x0000000000000000
 
 // Microsoft ABI:
 // RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
 // RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
-// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9" | FileCheck --check-prefix=CHECK-MSVC %s
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp" | FileCheck --check-prefix=CHECK-MSVC %s
 //
 // DWARF has no representation of MSInheritanceAttr, so we cannot determine the size
 // of member-pointers yet. For the moment, make sure we don't crash on such variables.
 // CHECK-MSVC: error: Unable to determine byte size.
 
-class SI {
-  double si;
+struct SI {
+  char si;
 };
-struct SI2 {
-  char si2;
-};
-class MI : SI, SI2 {
-  int mi;
-};
-class MI2 : MI {
-  int mi2;
-};
-class VI : virtual MI {
-  int vi;
-};
-class VI2 : virtual SI, virtual SI2 {
-  int vi;
-};
-class /* __unspecified_inheritance*/ UI;
 
-double SI::*mp1 = nullptr;
-int MI::*mp2 = nullptr;
-int MI2::*mp3 = nullptr;
-int VI::*mp4 = nullptr;
-int VI2::*mp5 = nullptr;
-int UI::*mp6 = nullptr;
-int MI::*mp7 = nullptr;
-int VI2::*mp8 = nullptr;
-char SI2::*mp9 = &SI2::si2;
+char SI::*mp = &SI::si;
 
 int main() { return 0; }



More information about the lldb-commits mailing list