[Lldb-commits] [lldb] [LLDB] Ignore actual-needed artificial members in DWARFASTParserClang::ParseSingleMember (PR #70779)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 9 05:33:50 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Haojian Wu (hokein)
<details>
<summary>Changes</summary>
Part of the fixes #<!-- -->69309.
Address the FIXME, this will allow the lldb print all fields of the generated coroutine frame structure.
---
Full diff: https://github.com/llvm/llvm-project/pull/70779.diff
4 Files Affected:
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+2-3)
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+6)
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h (+4)
- (added) lldb/test/Shell/SymbolFile/DWARF/ignored_artificial_fields.test (+17)
``````````diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 3174c18c97d888c..63260f28a7da85d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3059,9 +3059,8 @@ void DWARFASTParserClang::ParseSingleMember(
// This needs to be done after updating FieldInfo which keeps track of where
// field start/end so we don't later try to fill the space of this
// artificial member with (unnamed bitfield) padding.
- // FIXME: This check should verify that this is indeed an artificial member
- // we are supposed to ignore.
- if (attrs.is_artificial) {
+ if (attrs.is_artificial &&
+ TypeSystemClang::ShouldIgnoreArtificialField(attrs.name)) {
last_field_info.SetIsArtificial(true);
return;
}
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 6f65587c4acedd1..e81fdc7bdfd8e40 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -771,6 +771,12 @@ TypeSystemClang *TypeSystemClang::GetASTContext(clang::ASTContext *ast) {
return clang_ast;
}
+bool TypeSystemClang::ShouldIgnoreArtificialField(llvm::StringRef Name) {
+ return Name.starts_with("_vptr$")
+ // gdb emit vtable pointer as "_vptr.classname"
+ || Name.starts_with("_vptr.");
+}
+
clang::MangleContext *TypeSystemClang::getMangleContext() {
if (m_mangle_ctx_up == nullptr)
m_mangle_ctx_up.reset(getASTContext().createMangleContext());
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 0ec2d026e996105..477b655bb7c86ea 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -154,6 +154,10 @@ class TypeSystemClang : public TypeSystem {
static TypeSystemClang *GetASTContext(clang::ASTContext *ast_ctx);
+ // Returns true if the given artificial field name should be ignored when
+ // parsing the DWARF.
+ static bool ShouldIgnoreArtificialField(llvm::StringRef FieldName);
+
/// Returns the display name of this TypeSystemClang that indicates what
/// purpose it serves in LLDB. Used for example in logs.
llvm::StringRef getDisplayName() const { return m_display_name; }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/ignored_artificial_fields.test b/lldb/test/Shell/SymbolFile/DWARF/ignored_artificial_fields.test
new file mode 100644
index 000000000000000..e7d3bc4b796224a
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/ignored_artificial_fields.test
@@ -0,0 +1,17 @@
+# UNSUPPORTED: system-darwin, system-windows
+
+# Make sure the artifical field `vptr.ClassName` from gcc debug info is ignored.
+# RUN: %build --compiler=gcc %S/Inputs/debug-types-expressions.cpp -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+breakpoint set -n foo
+process launch
+
+# CHECK: Process {{.*}} stopped
+
+frame variable *a
+# CHECK-LABEL: frame variable *a
+# CHECK: (B) *a = {
+# CHECK-NEXT: A = (i = 47)
+# CHECK-NEXT: j = 42
+# CHECK-NEXT: }
``````````
</details>
https://github.com/llvm/llvm-project/pull/70779
More information about the lldb-commits
mailing list