Skip to content

[LLDB] Ignore actual-needed artificial members in DWARFASTParserClang::ParseSingleMember #70779

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

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ static lldb::ModuleSP GetContainingClangModule(const DWARFDIE &die) {
return lldb::ModuleSP();
}

// Returns true if the given artificial field name should be ignored when
// parsing the DWARF.
static bool ShouldIgnoreArtificialField(llvm::StringRef FieldName) {
return FieldName.starts_with("_vptr$")
// gdb emit vtable pointer as "_vptr.classname"
|| FieldName.starts_with("_vptr.");
}

TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
const DWARFDIE &die,
Log *log) {
Expand Down Expand Up @@ -3059,9 +3067,7 @@ 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 && ShouldIgnoreArtificialField(attrs.name)) {
last_field_info.SetIsArtificial(true);
return;
}
Expand Down
17 changes: 17 additions & 0 deletions lldb/test/Shell/SymbolFile/DWARF/ignored_artificial_fields.test
Original file line number Diff line number Diff line change
@@ -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: }