[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 10 03:56:48 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Haojian Wu (hokein)
<details>
<summary>Changes</summary>
See the discussion in #<!-- -->69309.
---
Full diff: https://github.com/llvm/llvm-project/pull/71928.diff
3 Files Affected:
- (modified) lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp (+5-1)
- (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py (+12-1)
- (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp (+1-1)
``````````diff
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c2488eaa9f5b50d..b5dfd07bdff2453 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -41,7 +41,11 @@ 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 ||
+ // Artificial coroutine-related variables emitted by clang.
+ name == ConstString("__promise") ||
+ name == ConstString("__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 42ee32f9ccca58d..bcb1da6dc3838c8 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,19 @@ 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, "// Break at co_yield", 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)
)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
index 8cb81c3bc9f4c4e..4523b7c7baf80aa 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
@@ -33,7 +33,7 @@ struct int_generator {
~int_generator() { hdl.destroy(); }
};
-int_generator my_generator_func() { co_yield 42; }
+int_generator my_generator_func() { co_yield 42; } // Break at co_yield
// This is an empty function which we call just so the debugger has
// a place to reliably set a breakpoint on.
``````````
</details>
https://github.com/llvm/llvm-project/pull/71928
More information about the lldb-commits
mailing list