Skip to content

Commit b837361

Browse files
authored
[LLDB] Display artificial __promise and __coro_frame variables. (#71928)
See the discussion in #69309.
1 parent a3eeef8 commit b837361

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ using namespace lldb;
3434
using namespace lldb_private;
3535

3636
static ConstString g_this = ConstString("this");
37+
// Artificial coroutine-related variables emitted by clang.
38+
static ConstString g_promise = ConstString("__promise");
39+
static ConstString g_coro_frame = ConstString("__coro_frame");
3740

3841
char CPPLanguageRuntime::ID = 0;
3942

4043
CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
4144
: LanguageRuntime(process) {}
4245

4346
bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
44-
return name == g_this;
47+
return name == g_this || name == g_promise || name == g_coro_frame;
4548
}
4649

4750
bool CPPLanguageRuntime::GetObjectDescription(Stream &str,

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,20 @@ def do_test(self, stdlib_type):
7878
],
7979
)
8080

81-
# Run until after the `co_yield`
8281
process = self.process()
82+
83+
# Break at a coroutine body
84+
lldbutil.continue_to_source_breakpoint(
85+
self,
86+
process,
87+
"int_generator my_generator_func",
88+
lldb.SBFileSpec("main.cpp", False),
89+
)
90+
91+
# Expect artificial variables to be displayed
92+
self.expect("frame variable", substrs=["__promise", "__coro_frame"])
93+
94+
# Run until after the `co_yield`
8395
lldbutil.continue_to_source_breakpoint(
8496
self, process, "// Break after co_yield", lldb.SBFileSpec("main.cpp", False)
8597
)

0 commit comments

Comments
 (0)