[Lldb-commits] [lldb] [LLDB] Don't ignore artificial variables and members for coroutines (PR #70779)
Haojian Wu via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 31 03:33:15 PDT 2023
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/70779
Fixes #69309
* 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;
>From 4cc40aafef4db5133f4360b2fb367e1776dc2901 Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein.wu at gmail.com>
Date: Tue, 31 Oct 2023 11:15:45 +0100
Subject: [PATCH] [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; }
More information about the lldb-commits
mailing list