https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/70779
>From 4cc40aafef4db5133f4360b2fb367e1776dc2901 Mon Sep 17 00:00:00 2001 From: Haojian Wu <hokein...@gmail.com> Date: Tue, 31 Oct 2023 11:15:45 +0100 Subject: [PATCH 1/2] [LLDB] Don't ignore artificial variables and members for coroutines * always populate all fields for the generated coroutine frame type; * make the artificial variables `__promise`, `__coro_frame` visible, so that they are present in the `frame var` command; --- .../Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp | 5 ++++- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 3 ++- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 4 ++++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp index c2488eaa9f5b50d..c7d9eb37f9b5199 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp @@ -41,7 +41,10 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process) : LanguageRuntime(process) {} bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) { - return name == g_this; + // FIXME: use a list when the list grows more. + return name == g_this || + name == ConstString("__promise") || + name == ConstString("__coro_frame"); } bool CPPLanguageRuntime::GetObjectDescription(Stream &str, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 182cc6764651747..d2708d183801035 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -3061,7 +3061,8 @@ void DWARFASTParserClang::ParseSingleMember( // 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::IsCoroutineFrameType(class_clang_type)) { 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 f037708efc38007..138f5531db2a9fb 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -771,6 +771,10 @@ TypeSystemClang *TypeSystemClang::GetASTContext(clang::ASTContext *ast) { return clang_ast; } +bool TypeSystemClang::IsCoroutineFrameType(const CompilerType &Type) { + return Type.GetTypeName().GetStringRef().ends_with(".coro_frame_ty"); +} + 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..6168a065eb522e9 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -154,6 +154,9 @@ class TypeSystemClang : public TypeSystem { static TypeSystemClang *GetASTContext(clang::ASTContext *ast_ctx); + // Returns true if the given type is a coroutine frame debug type. + static bool IsCoroutineFrameType(const CompilerType &Type); + /// 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; } >From c145045251683c42008dff49e2f02cf0a8020894 Mon Sep 17 00:00:00 2001 From: Haojian Wu <hokein...@gmail.com> Date: Fri, 3 Nov 2023 12:07:23 +0100 Subject: [PATCH 2/2] Add and use `ShouldIgnoreArtificialField` API to ignore the indeed artificial members we should ignore. --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 4 +--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 4 ++-- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h | 5 +++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index d2708d183801035..0c0566eec56133f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -3059,10 +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 && - !TypeSystemClang::IsCoroutineFrameType(class_clang_type)) { + 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 138f5531db2a9fb..e947e99074a7542 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -771,8 +771,8 @@ TypeSystemClang *TypeSystemClang::GetASTContext(clang::ASTContext *ast) { return clang_ast; } -bool TypeSystemClang::IsCoroutineFrameType(const CompilerType &Type) { - return Type.GetTypeName().GetStringRef().ends_with(".coro_frame_ty"); +bool TypeSystemClang::ShouldIgnoreArtificialField(llvm::StringRef Name) { + return Name.starts_with("_vptr$"); } clang::MangleContext *TypeSystemClang::getMangleContext() { diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 6168a065eb522e9..477b655bb7c86ea 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -154,8 +154,9 @@ class TypeSystemClang : public TypeSystem { static TypeSystemClang *GetASTContext(clang::ASTContext *ast_ctx); - // Returns true if the given type is a coroutine frame debug type. - static bool IsCoroutineFrameType(const CompilerType &Type); + // 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. _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits