aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorAdrian Vogelsgesang <avogelsgesang@salesforce.com>2022-08-21 10:50:52 -0700
committerAdrian Vogelsgesang <avogelsgesang@salesforce.com>2022-08-24 14:40:53 -0700
commit91389000abe8ef5d06d98cbbefd3fa03ac7e4480 (patch)
tree04c1988a465504c0cf556c8fe18099ec62e8fb20 /lldb/packages/Python/lldbsuite/test
parent94e64df5763b49d750a9a87ecdd4a6583ad6154f (diff)
downloadllvm-91389000abe8ef5d06d98cbbefd3fa03ac7e4480.zip
llvm-91389000abe8ef5d06d98cbbefd3fa03ac7e4480.tar.gz
llvm-91389000abe8ef5d06d98cbbefd3fa03ac7e4480.tar.bz2
[LLDB] Add data formatter for std::coroutine_handle
This patch adds a formatter for `std::coroutine_handle`, both for libc++ and libstdc++. For the type-erased `coroutine_handle<>`, it shows the `resume` and `destroy` function pointers. For a non-type-erased `coroutine_handle<promise_type>` it also shows the `promise` value. With this change, executing the `v t` command on the example from https://clang.llvm.org/docs/DebuggingCoroutines.html now outputs ``` (task) t = { handle = coro frame = 0x55555555b2a0 { resume = 0x0000555555555a10 (a.out`coro_task(int, int) at llvm-example.cpp:36) destroy = 0x0000555555556090 (a.out`coro_task(int, int) at llvm-example.cpp:36) } } ``` instead of just ``` (task) t = { handle = { __handle_ = 0x55555555b2a0 } } ``` Note, how the symbols for the `resume` and `destroy` function pointer reveal which coroutine is stored inside the `std::coroutine_handle`. A follow-up commit will use this fact to infer the coroutine's promise type and the representation of its internal coroutine state based on the `resume` and `destroy` pointers. The same formatter is used for both libc++ and libstdc++. It would also work for MSVC's standard library, however it is not registered for MSVC, given that lldb does not provide pretty printers for other MSVC types, either. The formatter is in a newly added `Coroutines.{h,cpp}` file because there does not seem to be an already existing place where we could share formatters across libc++ and libstdc++. Also, I expect this code to grow as we improve debugging experience for coroutines further. **Testing** * Added API test Differential Revision: https://reviews.llvm.org/D132415
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbtest.py8
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbutil.py15
2 files changed, 21 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 69bb5ac..1c09039 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -292,8 +292,12 @@ class ValueCheck:
test_base.assertEqual(self.expect_type, val.GetDisplayTypeName(),
this_error_msg)
if self.expect_summary:
- test_base.assertEqual(self.expect_summary, val.GetSummary(),
- this_error_msg)
+ if isinstance(self.expect_summary, re.Pattern):
+ test_base.assertRegex(val.GetSummary(), self.expect_summary,
+ this_error_msg)
+ else:
+ test_base.assertEqual(self.expect_summary, val.GetSummary(),
+ this_error_msg)
if self.children is not None:
self.check_value_children(test_base, val, error_msg)
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 8bd49c7..7e64afb 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -988,6 +988,21 @@ def continue_to_breakpoint(process, bkpt):
return get_threads_stopped_at_breakpoint(process, bkpt)
+def continue_to_source_breakpoint(test, process, bkpt_pattern, source_spec):
+ """
+ Sets a breakpoint set by source regex bkpt_pattern, continues the process, and deletes the breakpoint again.
+ Otherwise the same as `continue_to_breakpoint`
+ """
+ breakpoint = process.target.BreakpointCreateBySourceRegex(
+ bkpt_pattern, source_spec, None)
+ test.assertTrue(breakpoint.GetNumLocations() > 0,
+ 'No locations found for source breakpoint: "%s", file: "%s", dir: "%s"'
+ %(bkpt_pattern, source_spec.GetFilename(), source_spec.GetDirectory()))
+ stopped_threads = continue_to_breakpoint(process, breakpoint)
+ process.target.BreakpointDelete(breakpoint.GetID())
+ return stopped_threads
+
+
def get_caller_symbol(thread):
"""
Returns the symbol name for the call site of the leaf function.