-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLDB] Display artificial __promise and __coro_frame variables. #71928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Is there a way to run the tests under
|
@llvm/pr-subscribers-lldb Author: Haojian Wu (hokein) ChangesSee the discussion in #69309. Full diff: https://github.com/llvm/llvm-project/pull/71928.diff 3 Files Affected:
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.
|
✅ With the latest revision this PR passed the Python code formatter. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
Did you configure your build with |
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we need this FIXME
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, removed.
Thanks! I was able to run the test locally now with |
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
Outdated
Show resolved
Hide resolved
...ionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
Outdated
Show resolved
Hide resolved
d67d907
to
43ab602
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comments.
...ionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (once bots are happy). I think you may need to run git clang-format
or python's black
formatter
Thanks for the review. |
…#71928) See the discussion in llvm#69309.
See the discussion in #69309.