ScriptedFrame get_register_context hides Python exceptions
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
While working on https://github.com/llvm/llvm-project/pull/217659 I noticed that if I had an error that raised an exception in `lldb/test/API/functionalities/scripted_frame_provider/wrapped_frame_register_context/frame_provider.py` `get_register_context` it wouldn't be surfaced. I had to debug it by printing instead.
To reproduce:
```
def get_register_context(self):
"""Forward the wrapped frame's GPRs, packed in register_info order."""
raise RuntimeError()
```
Run the test case:
```
======================================================================
FAIL: test_backtrace_with_forwarded_register_context (TestFrameProviderWrappedFrameRegisterContext.TestFrameProviderWrappedFrameRegisterContext)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/davspi01/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/wrapped_frame_register_context/TestFrameProviderWrappedFrameRegisterContext.py", line 35, in test_backtrace_with_forwarded_register_context
self.expect("bt", substrs=["compute(a=3, b=4)", "main"])
File "/home/davspi01/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2973, in expect
self.fail(log_msg)
AssertionError: Ran command:
"bt"
Got output:
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
* frame #0: 0x0000adff8e4b0730 a.out`compute(a=, b=) at main.c:3:10 [synthetic]
frame #1: 0x0000adff8e4b0758 a.out`main at main.c:6:25
frame #2: 0x0000f96f2fe37400 libc.so.6`___lldb_unnamed_symbol_27390 + 112
frame #3: 0x0000f96f2fe374d8 libc.so.6`__libc_start_main + 152
frame #4: 0x0000adff8e4b0630 a.out`_start + 48
Expecting sub string: "compute(a=3, b=4)" (was not found)
Config=aarch64-/home/davspi01/build-llvm-aarch64/bin/clang
----------------------------------------------------------------------
Ran 1 test in 0.264s
FAILED (failures=1)
```
It fails but there is no indication of why.
This is much like https://github.com/llvm/llvm-project/issues/211789, so it might be the same underlying issue.
FYI @medismailben
Contributor guide
Research direction
Start with lldb/test/API/functionalities/scripted_frame_provider/wrapped_frame_register_context/frame_provider.py and its get_register_context method, then run the named test in TestFrameProviderWrappedFrameRegisterContext.py with the RuntimeError reproduction. Compare the behavior with issue 211789; done means Python exceptions from this callback are surfaced instead of producing only unavailable registers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100