Skip to content

Commit 08c3b1a

Browse files
committed
[LLDB] Display artificial __promise and __coro_frame variables.
See the discussion in #69309.
1 parent 81a7690 commit 08c3b1a

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
4141
: LanguageRuntime(process) {}
4242

4343
bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
44-
return name == g_this;
44+
// FIXME: use a list when the list grows more.
45+
return name == g_this ||
46+
// Artificial coroutine-related variables emitted by clang.
47+
name == ConstString("__promise") ||
48+
name == ConstString("__coro_frame");
4549
}
4650

4751
bool CPPLanguageRuntime::GetObjectDescription(Stream &str,

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,19 @@ 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, process, "// Break at co_yield", lldb.SBFileSpec("main.cpp", False)
86+
)
87+
# Expect artificial variables to be displayed
88+
self.expect(
89+
"frame variable",
90+
substrs=['__promise', '__coro_frame']
91+
)
92+
93+
# Run until after the `co_yield`
8394
lldbutil.continue_to_source_breakpoint(
8495
self, process, "// Break after co_yield", lldb.SBFileSpec("main.cpp", False)
8596
)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct int_generator {
3333
~int_generator() { hdl.destroy(); }
3434
};
3535

36-
int_generator my_generator_func() { co_yield 42; }
36+
int_generator my_generator_func() { co_yield 42; } // Break at co_yield
3737

3838
// This is an empty function which we call just so the debugger has
3939
// a place to reliably set a breakpoint on.

0 commit comments

Comments
 (0)