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

Address the FIXME, this will allow lldb to print all fields of the
generated coroutine frame structure.

Fixes #69309.
This commit is contained in:
Haojian Wu 2023-11-10 10:53:03 +01:00 committed by GitHub
parent c4e57b11f4
commit 66acd1e4dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View File

@ -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) {
@ -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;
}

View File

@ -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: }