[Lldb-commits] [lldb] 699ce16 - [lldb] Fix crash missing MSInheritanceAttr with DWARF on Windows (#112928)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 23 04:21:25 PDT 2024
Author: Stefan Gränitz
Date: 2024-10-23T13:21:22+02:00
New Revision: 699ce16b6284377e0cd9969b9f95e7367632a622
URL: https://github.com/llvm/llvm-project/commit/699ce16b6284377e0cd9969b9f95e7367632a622
DIFF: https://github.com/llvm/llvm-project/commit/699ce16b6284377e0cd9969b9f95e7367632a622.diff
LOG: [lldb] Fix crash missing MSInheritanceAttr with DWARF on Windows (#112928)
Member pointers refer to data or function members of a `CXXRecordDecl` and
require a `MSInheritanceAttr` in order to be complete. Without that we
cannot calculate their size in memory. The attempt has been causing a crash
further down in the clang AST context. In order to implement the feature,
DWARF will need a new attribtue to convey the information. For the moment,
this patch teaches LLDB to handle to situation and avoid the crash.
Added:
lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
Modified:
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index e710f976ccc4c1..436797abb1d7e1 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;
}
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..817833d4fa7515
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
@@ -0,0 +1,24 @@
+// 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 mp" | FileCheck %s
+//
+// 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 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.
+
+struct SI {
+ char si;
+};
+
+char SI::*mp = &SI::si;
+
+int main() { return 0; }
More information about the lldb-commits
mailing list