[Lldb-commits] [lldb] b837361 - [LLDB] Display artificial __promise and __coro_frame variables. (#71928)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 14 00:06:44 PST 2023
Author: Haojian Wu
Date: 2023-11-14T09:06:40+01:00
New Revision: b837361b80f6db162969f8226e28fb5253b8db0b
URL: https://github.com/llvm/llvm-project/commit/b837361b80f6db162969f8226e28fb5253b8db0b
DIFF: https://github.com/llvm/llvm-project/commit/b837361b80f6db162969f8226e28fb5253b8db0b.diff
LOG: [LLDB] Display artificial __promise and __coro_frame variables. (#71928)
See the discussion in #69309.
Added:
Modified:
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
Removed:
################################################################################
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c2488eaa9f5b50d..e65b99f44be6dc4 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -34,6 +34,9 @@ using namespace lldb;
using namespace lldb_private;
static ConstString g_this = ConstString("this");
+// Artificial coroutine-related variables emitted by clang.
+static ConstString g_promise = ConstString("__promise");
+static ConstString g_coro_frame = ConstString("__coro_frame");
char CPPLanguageRuntime::ID = 0;
@@ -41,7 +44,7 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
: LanguageRuntime(process) {}
bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
- return name == g_this;
+ return name == g_this || name == g_promise || name == g_coro_frame;
}
bool CPPLanguageRuntime::GetObjectDescription(Stream &str,
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
index 2dbbf969dfcdae2..ae1a0c86b45d899 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
@@ -78,8 +78,20 @@ def do_test(self, stdlib_type):
],
)
- # Run until after the `co_yield`
process = self.process()
+
+ # Break at a coroutine body
+ lldbutil.continue_to_source_breakpoint(
+ self,
+ process,
+ "int_generator my_generator_func",
+ lldb.SBFileSpec("main.cpp", False),
+ )
+
+ # Expect artificial variables to be displayed
+ self.expect("frame variable", substrs=["__promise", "__coro_frame"])
+
+ # Run until after the `co_yield`
lldbutil.continue_to_source_breakpoint(
self, process, "// Break after co_yield", lldb.SBFileSpec("main.cpp", False)
)
More information about the lldb-commits
mailing list