Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows #112928

Conversation

weliveindetail
Copy link
Contributor

In the MS ABI, member pointers to CXXRecordDecls must have a MSInheritanceAttr in order to be complete. Otherwise we cannot query their size in memory. This patch checks MemberPointer types for completeness (eventually looking at the existence of the attribute) to avoid a crash further down in the clang AST context.

@weliveindetail
Copy link
Contributor Author

This PR isn't complete yet, but early feedback is welcome. Next step is to get test coverage. There are similar cases for types like CXXRecord, Enum or ObjCInterface that attempt to query the complete type on the fly. Maybe we should do that for MemberPointer as well?

@weliveindetail
Copy link
Contributor Author

This might be related to #56458 even though my repro is different.

@weliveindetail
Copy link
Contributor Author

The test caused a crash in the past:

> bin/lldb.exe llvm-project-build-main/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/ms-abi.cpp.tmp.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9"
Exception Code: 0x80000003
...
 #6 0x00007ffabb6be846 clang::MSInheritanceAttr::getInheritanceModel llvm-project-build-main\tools\clang\include\clang\AST\Attrs.inc:6878:0
 #7 0x00007ffabb6be846 clang::CXXRecordDecl::getMSInheritanceModel(void) const llvm-project\clang\lib\AST\MicrosoftCXXABI.cpp:235:0
 #8 0x00007ffabb6be8f8 llvm::PointerUnion<clang::Type const *,clang::ExtQuals const *>::getFromOpaqueValue llvm-project\llvm\include\llvm\ADT\PointerUnion.h:196:0
 #9 0x00007ffabb6be8f8 llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::Type const *,clang::ExtQuals const *> >::getFromVoidPointer llvm-project\llvm\include\llvm\ADT\PointerUnion.h:271:0
#10 0x00007ffabb6be8f8 llvm::PointerIntPairInfo<llvm::PointerUnion<clang::Type const *,clang::ExtQuals const *>,3,llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::Type const *,clang::ExtQuals const *> > >::getPointer llvm-project\llvm\include\llvm\ADT\PointerIntPair.h:191:0
#11 0x00007ffabb6be8f8 llvm::PointerIntPair<llvm::PointerUnion<clang::Type const *,clang::ExtQuals const *>,3,unsigned int,llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::Type const *,clang::ExtQuals const *> >,llvm::PointerIntPairInfo<llvm::PointerUnion<clang::Type const *,clang::ExtQuals const *>,3,llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::Type const *,clang::ExtQuals const *> > > >::getPointer llvm-project\llvm\include\llvm\ADT\PointerIntPair.h:94:0
#12 0x00007ffabb6be8f8 clang::QualType::isNull llvm-project\clang\include\clang\AST\Type.h:1013:0
#13 0x00007ffabb6be8f8 clang::QualType::getCommonPtr llvm-project\clang\include\clang\AST\Type.h:961:0
#14 0x00007ffabb6be8f8 clang::QualType::getTypePtr llvm-project\clang\include\clang\AST\Type.h:7923:0
#15 0x00007ffabb6be8f8 clang::QualType::operator-> llvm-project\clang\include\clang\AST\Type.h:1005:0
#16 0x00007ffabb6be8f8 clang::MemberPointerType::isMemberFunctionPointer llvm-project\clang\include\clang\AST\Type.h:3541:0
#17 0x00007ffabb6be8f8 getMSMemberPointerSlots llvm-project\clang\lib\AST\MicrosoftCXXABI.cpp:285:0
#18 0x00007ffabb6bef45 `anonymous namespace'::MicrosoftCXXABI::getMemberPointerInfo llvm-project\clang\lib\AST\MicrosoftCXXABI.cpp:310:0
#19 0x00007ffabb340010 clang::ASTContext::getTypeInfoImpl(class clang::Type const *) const llvm-project\clang\lib\AST\ASTContext.cpp:2305:0
#20 0x00007ffabb33f24c clang::ASTContext::getTypeInfo(class clang::Type const *) const llvm-project\clang\lib\AST\ASTContext.cpp:1930:0
#21 0x00007ffab4a6c2f7 clang::ASTContext::getTypeSize(class clang::QualType) const llvm-project\clang\include\clang\AST\ASTContext.h:2466:0
#22 0x00007ffab4aa9e75 lldb_private::TypeSystemClang::GetBitSize(void *, class lldb_private::ExecutionContextScope *) llvm-project\lldb\source\Plugins\TypeSystem\Clang\TypeSystemClang.cpp:4825:0

Now it survives:

(lldb) target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9
(SITYPE) mp1 = <Unable to determine byte size.>
(MITYPE) mp2 = <Unable to determine byte size.>
(MI2TYPE) mp3 = <Unable to determine byte size.>
(VITYPE) mp4 = <Unable to determine byte size.>
(VI2TYPE) mp5 = <Unable to determine byte size.>
(UITYPE) mp6 = <Unable to determine byte size.>
(MITYPE *) mp7 = 0x0000000000000000
(VI2TYPE *) mp8 = 0x0000000000000000
error: Unable to determine byte size.

Next, we might want to query the complete type on demand to determine the actual byte sizes.

@weliveindetail weliveindetail marked this pull request as ready for review October 22, 2024 09:17
@llvmbot llvmbot added the lldb label Oct 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 22, 2024

@llvm/pr-subscribers-lldb

Author: Stefan Gränitz (weliveindetail)

Changes

In the MS ABI, member pointers to CXXRecordDecls must have a MSInheritanceAttr in order to be complete. Otherwise we cannot query their size in memory. This patch checks MemberPointer types for completeness (eventually looking at the existence of the attribute) to avoid a crash further down in the clang AST context.


Full diff: https://github.com/llvm/llvm-project/pull/112928.diff

2 Files Affected:

  • (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+3)
  • (added) lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp (+45)
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;
   }
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() {}

@mstorsjo mstorsjo requested a review from ZequanWu October 22, 2024 09:28
@@ -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();
Copy link
Member

@Michael137 Michael137 Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so for non-MS ABI isIncompleteType will pretty much work as before, and trivially return true. Otherwise it checks for the MSInheritanceAttr. Seems reasonable to me

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeSystemClang.cpp change LGTM. Though It'd be nice if we added the same test-coverage also for non-MSVC (only found shell tests for PDB, and 1 API test that didn't enumerate all the cases).

I guess a follow-up question is how to set the MSInheritanceAttr. Infer it from the class DIE? Or add a new DWARF attribute? Also, whether we still want to issue a warning when debugging using DWARF and the MS ABI (like suggested in https://reviews.llvm.org/D130942).

@weliveindetail
Copy link
Contributor Author

Thanks for the feedback! Yes, I think fixing the crash is a valuable addition on its own. It broke use-cases where we just want to set a breakpoint and encounter this type on the way, but don't actually care about its byte size.

I guess a follow-up question is how to set the MSInheritanceAttr. Infer it from the class DIE? Or add a new DWARF attribute?
Well, maybe, but not sure. I believe it has a set of attributes that convey the information that MSInheritanceAttr has in the MS ABI. Would such duplication be accepted? And as long as it's just about member pointers, it might not be worth the effort. Let's see.

I did some more digging and now I wonder: Couldn't TypeSystemClang::GetBitSize() just return the pointer-size in bits for clang::Type::MemberPointer? That shouldn't even depend on the object it refers to, right?

@Michael137
Copy link
Member

Michael137 commented Oct 22, 2024

I guess a follow-up question is how to set the MSInheritanceAttr. Infer it from the class DIE? Or add a new DWARF attribute?
Well, maybe, but not sure. I believe it has a set of attributes that convey the information that MSInheritanceAttr has in the MS ABI. Would such duplication be accepted? And as long as it's just about member pointers, it might not be worth the effort. Let's see.

I did some more digging and now I wonder: Couldn't TypeSystemClang::GetBitSize() just return the pointer-size in bits for clang::Type::MemberPointer? That shouldn't even depend on the object it refers to, right?

It is ABI dependent, and we probably do want to rely on Clang to tell us this so we don't reimplement all that logic. E.g., for Itanium, the size would be sizeof(ptrdiff_t) for data members (and double that for function pointers). With the MS ABI it gets more complicated it seems.

@weliveindetail
Copy link
Contributor Author

Ok right, member function pointers are more than just offsets. So, hard-coding clang::Type::MemberPointer to the system pointer size wouldn't work there.

// 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Michael137 You think that's ok as test-coverage also for non-MSVC?

Copy link
Member

@Michael137 Michael137 Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, thanks!

Don't think we even need to link (in either case).

Also lets add a CHECK-MSVC: as well. That'd notify us once that byte-size issue gets fixed on Windows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, added CHECK-MSVC: error: Unable to determine byte size. and dropped link-step for Itanium case. The latter doesn't seem to work for the MS case. It fails early with:

error: unable to resolve the module for file address 0x0 for variable 'mp1' in
S:\path\to\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\member-pointers.cpp.tmp_win.obj

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah fair enough, latest test changes LGTM

Copy link

github-actions bot commented Oct 22, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@weliveindetail
Copy link
Contributor Author

This might be related to #56458 even though my repro is different.

Actually, rather this one: #56449 It adds MSInheritanceAttr support in NativePDB. The patch in this PR is about DWARF and the Microsoft ABI. Let's avoid the crash right now and consider adding a DWARF attribute for MSInheritanceAttr in a next step.

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm (modulo test comment)

Comment on lines 36 to 43
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with all of these? I think we should either CHECK their results or delete them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. They exercise the various MSInheritance cases for the Microsoft ABI, but since there is no support in DWARF yet, we don't really need them. I reduced the test to the case that it checks.

rastogishubham added a commit that referenced this pull request Oct 23, 2024
…ith DWARF on Windows" (#113498)

Reverts #112928

This is because it broke greendragon:
SymbolFile/DWARF/x86/member-pointers.cpp
@rastogishubham
Copy link
Contributor

I reverted this change with #113498

@weliveindetail
Copy link
Contributor Author

Hi @rastogishubham thanks for acting on this! The log of this particular run was deleted already, but https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/13958 likely failed for the same reason:

lldb-build/bin/clang --driver-mode=cl --target=specify-a-target-or-use-a-_host-substitution --target=x86_64-windows-msvc -c -gdwarf /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp -o /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/member-pointers.cpp.tmp_win.obj
clang: warning: '/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp' treated as the '/U' option [-Wslash-u-filename]
clang: note: use '--' to treat subsequent arguments as filenames
clang: error: no input files

Apparently, /U is an option for the clang cl mode driver and this collides with the start of the file name path in /Users/.... Let me prepare a patch for it.

weliveindetail added a commit that referenced this pull request Oct 24, 2024
…ows (#112928)

Member pointers refer to data or function members of a `CXXRecordDecl`,
which require a `MSInheritanceAttr` in order to be complete. Without that
we cannot calculate the size of a member pointer 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.
@weliveindetail
Copy link
Contributor Author

I fixed the test and it now passes for me on macOS. Hope the bots are good now.

@rastogishubham
Copy link
Contributor

@weliveindetail thanks for the fix! I was at the llvm dev meeting so I was slow to respond. The bots are still green so we are good!

@frobtech frobtech mentioned this pull request Oct 25, 2024
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
…m#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.
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
…ith DWARF on Windows" (llvm#113498)

Reverts llvm#112928

This is because it broke greendragon:
SymbolFile/DWARF/x86/member-pointers.cpp
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
…ows (llvm#112928)

Member pointers refer to data or function members of a `CXXRecordDecl`,
which require a `MSInheritanceAttr` in order to be complete. Without that
we cannot calculate the size of a member pointer 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.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 6, 2024
…ows (llvm#112928)

Member pointers refer to data or function members of a `CXXRecordDecl`,
which require a `MSInheritanceAttr` in order to be complete. Without that
we cannot calculate the size of a member pointer 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.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 7, 2024
…ows (llvm#112928)

Member pointers refer to data or function members of a `CXXRecordDecl`,
which require a `MSInheritanceAttr` in order to be complete. Without that
we cannot calculate the size of a member pointer 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.
weliveindetail added a commit that referenced this pull request Nov 18, 2024
#115177)

Following up from #112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 18, 2024
…ows (llvm#112928)

Member pointers refer to data or function members of a `CXXRecordDecl`,
which require a `MSInheritanceAttr` in order to be complete. Without that
we cannot calculate the size of a member pointer 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.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 18, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 27, 2024
…ows (llvm#112928)

Member pointers refer to data or function members of a `CXXRecordDecl`,
which require a `MSInheritanceAttr` in order to be complete. Without that
we cannot calculate the size of a member pointer 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.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 27, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 27, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.
compnerd added a commit to swiftlang/llvm-project that referenced this pull request Dec 2, 2024
…mber-pointers-crash

🍒 [lldb] Fix crash missing MSInheritanceAttr with DWARF on Windows (llvm#112928)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 4, 2024
…ows (llvm#112928)

Member pointers refer to data or function members of a `CXXRecordDecl`,
which require a `MSInheritanceAttr` in order to be complete. Without that
we cannot calculate the size of a member pointer 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.

(cherry picked from commit c39692a)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 4, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.

(cherry picked from commit e9dd419)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 4, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.

(cherry picked from commit e9dd419)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 5, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.

(cherry picked from commit e9dd419)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 5, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.

(cherry picked from commit e9dd419)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 5, 2024
…ows (llvm#112928)

Member pointers refer to data or function members of a `CXXRecordDecl`,
which require a `MSInheritanceAttr` in order to be complete. Without that
we cannot calculate the size of a member pointer 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.

(cherry picked from commit c39692a)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 5, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.

(cherry picked from commit e9dd419)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 5, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.

(cherry picked from commit e9dd419)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 5, 2024
…ows (llvm#112928)

Member pointers refer to data or function members of a `CXXRecordDecl`,
which require a `MSInheritanceAttr` in order to be complete. Without that
we cannot calculate the size of a member pointer 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.

(cherry picked from commit c39692a)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Dec 5, 2024
llvm#115177)

Following up from llvm#112928, we
can reuse the approach from Clang Sema to infer the MSInheritanceModel
and add the necessary attribute manually. This allows the inspection of
member function pointers with DWARF on Windows.

(cherry picked from commit e9dd419)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants