[Lldb-commits] [lldb] [lldb] Add support for PC-less scripted frames (PR #170762)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 4 14:16:53 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r origin/main...HEAD lldb/test/API/functionalities/scripted_frame_provider/python_helper.py lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py lldb/test/API/functionalities/scripted_frame_provider/test_frame_providers.py lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- scripted_frame_provider/TestScriptedFrameProvider.py 2025-12-04 22:03:44.000000 +0000
+++ scripted_frame_provider/TestScriptedFrameProvider.py 2025-12-04 22:16:21.579023 +0000
@@ -487,46 +487,32 @@
)
self.assertTrue(frame1.IsSynthetic(), "Frame should be marked as synthetic")
frame2 = thread.GetFrameAtIndex(2)
self.assertIsNotNone(frame2)
- self.assertEqual(
- frame2.GetFunctionName(), "main", "Third frame should be main"
- )
+ self.assertEqual(frame2.GetFunctionName(), "main", "Third frame should be main")
self.assertTrue(frame2.IsSynthetic(), "Frame should be marked as synthetic")
# Verify line entry information is present
line_entry0 = frame0.GetLineEntry()
- self.assertTrue(
- line_entry0.IsValid(), "Frame 0 should have a valid line entry"
- )
- self.assertEqual(
- line_entry0.GetLine(), 7, "Frame 0 should point to line 7"
- )
+ self.assertTrue(line_entry0.IsValid(), "Frame 0 should have a valid line entry")
+ self.assertEqual(line_entry0.GetLine(), 7, "Frame 0 should point to line 7")
file_spec0 = line_entry0.GetFileSpec()
self.assertTrue(file_spec0.IsValid(), "Frame 0 should have valid file spec")
self.assertEqual(
file_spec0.GetFilename(),
"python_helper.py",
"Frame 0 should point to python_helper.py",
)
line_entry1 = frame1.GetLineEntry()
- self.assertTrue(
- line_entry1.IsValid(), "Frame 1 should have a valid line entry"
- )
- self.assertEqual(
- line_entry1.GetLine(), 16, "Frame 1 should point to line 16"
- )
+ self.assertTrue(line_entry1.IsValid(), "Frame 1 should have a valid line entry")
+ self.assertEqual(line_entry1.GetLine(), 16, "Frame 1 should point to line 16")
line_entry2 = frame2.GetLineEntry()
- self.assertTrue(
- line_entry2.IsValid(), "Frame 2 should have a valid line entry"
- )
- self.assertEqual(
- line_entry2.GetLine(), 27, "Frame 2 should point to line 27"
- )
+ self.assertTrue(line_entry2.IsValid(), "Frame 2 should have a valid line entry")
+ self.assertEqual(line_entry2.GetLine(), 27, "Frame 2 should point to line 27")
# Verify the frames display properly in backtrace
# This tests that PC-less frames don't show 0xffffffffffffffff
self.runCmd("bt")
output = self.res.GetOutput()
--- scripted_frame_provider/test_frame_providers.py 2025-12-04 22:03:44.000000 +0000
+++ scripted_frame_provider/test_frame_providers.py 2025-12-04 22:16:21.689264 +0000
@@ -307,12 +307,10 @@
return PythonSourceFrame(
self.thread, 1, "process_data", self.python_file, 16
)
elif index == 2:
# Frame pointing to main function (line 27)
- return PythonSourceFrame(
- self.thread, 2, "main", self.python_file, 27
- )
+ return PythonSourceFrame(self.thread, 2, "main", self.python_file, 27)
elif index - 3 < len(self.input_frames):
# Pass through original frames
return index - 3
return None
--- scripted_process/dummy_scripted_process.py 2025-12-04 22:03:44.000000 +0000
+++ scripted_process/dummy_scripted_process.py 2025-12-04 22:16:21.761247 +0000
@@ -98,21 +98,25 @@
)
# Add a frame with Python source
code = my_python_function.__code__
lineno = code.co_firstlineno
- col_offset = getattr(code, "co_firstcol_offset", 0) # Python ≥3.11 has column info
+ col_offset = getattr(
+ code, "co_firstcol_offset", 0
+ ) # Python ≥3.11 has column info
py_le = lldb.SBLineEntry()
py_le.SetFileSpec(lldb.SBFileSpec(__file__, True))
py_le.SetLine(lineno) # Line where my_python_function is defined
py_le.SetColumn(col_offset)
py_sym_ctx = lldb.SBSymbolContext()
py_sym_ctx.SetLineEntry(py_le)
self.frames.append(
- DummyScriptedFrame(self, args, len(self.frames), "my_python_function", py_sym_ctx)
+ DummyScriptedFrame(
+ self, args, len(self.frames), "my_python_function", py_sym_ctx
+ )
)
def get_thread_id(self) -> int:
return 0x19
``````````
</details>
https://github.com/llvm/llvm-project/pull/170762
More information about the lldb-commits
mailing list