[Lldb-commits] [lldb] fallback to assembly when source code is not available (PR #136494)
via lldb-commits
lldb-commits at lists.llvm.org
Sun Apr 20 14:02:30 PDT 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 HEAD~1...HEAD lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- TestDAP_stackTraceDisassemblyDisplay.py 2025-04-20 20:59:48.000000 +0000
+++ TestDAP_stackTraceDisassemblyDisplay.py 2025-04-20 21:01:59.997663 +0000
@@ -23,10 +23,11 @@
return b; // Break here
}
"""
+
@contextmanager
def delete_file_on_exit(path):
try:
yield path
finally:
@@ -45,76 +46,150 @@
f.write(OTHER_C_SOURCE_CODE)
breakpoint_line = line_number(other_source_file, "// Break here")
program = self.getBuildArtifact("a.out")
- init_commands = [f"settings set stop-disassembly-display {stop_disassembly_display}"]
+ init_commands = [
+ f"settings set stop-disassembly-display {stop_disassembly_display}"
+ ]
self.build_and_launch(program, initCommands=init_commands)
- breakpoint_ids = self.set_source_breakpoints(other_source_file, [breakpoint_line])
+ breakpoint_ids = self.set_source_breakpoints(
+ other_source_file, [breakpoint_line]
+ )
self.assertEqual(
len(breakpoint_ids), 1, "expect correct number of breakpoints"
)
self.continue_to_breakpoints(breakpoint_ids)
-
+
frames = self.get_stackFrames()
- self.assertLessEqual(
- 2, len(frames), "expect at least 2 frames"
+ self.assertLessEqual(2, len(frames), "expect at least 2 frames")
+
+ self.assertIn(
+ "path",
+ frames[0]["source"],
+ "Expect source path to always be in frame (other.c)",
)
-
- self.assertIn("path", frames[0]["source"], "Expect source path to always be in frame (other.c)")
- self.assertIn("path", frames[1]["source"], "Expect source path in always be in frame (main.c)")
+ self.assertIn(
+ "path",
+ frames[1]["source"],
+ "Expect source path in always be in frame (main.c)",
+ )
return frames
@skipIfWindows
def test_stopDisassemblyDispay_noSource(self):
"""
Test that with with stop-disassembly-display = no-source - frames without source available give assembly code.
"""
frames = self.build_and_run_until_breakpoint("no-source")
- self.assertNotIn("other.c", frames[0]["source"]["path"], "Expect original source path to not be in unavailable source frame (other.c)")
- self.assertIn("sourceReference", frames[0]["source"], "Expect sourceReference source path in to be in unavailable source frame (other.c)")
-
- self.assertIn("main.c", frames[1]["source"]["path"], "Expect original source path to be in source code frame (main.c)")
- self.assertNotIn("sourceReference", frames[1]["source"], "Expect no sourceReference in source code frame (main.c)")
+ self.assertNotIn(
+ "other.c",
+ frames[0]["source"]["path"],
+ "Expect original source path to not be in unavailable source frame (other.c)",
+ )
+ self.assertIn(
+ "sourceReference",
+ frames[0]["source"],
+ "Expect sourceReference source path in to be in unavailable source frame (other.c)",
+ )
+
+ self.assertIn(
+ "main.c",
+ frames[1]["source"]["path"],
+ "Expect original source path to be in source code frame (main.c)",
+ )
+ self.assertNotIn(
+ "sourceReference",
+ frames[1]["source"],
+ "Expect no sourceReference in source code frame (main.c)",
+ )
@skipIfWindows
def test_stopDisassemblyDispay_noDebuginfo(self):
"""
Test that with with stop-disassembly-display = no-debuginfo - all frames give source code even when source not available.
"""
frames = self.build_and_run_until_breakpoint("no-debuginfo")
- self.assertIn("other.c", frames[0]["source"]["path"], "Expect original source path to be in unavailable source frame (other.c)")
- self.assertNotIn("sourceReference", frames[0]["source"], "Expect sourceReference source path in to be in unavailable source frame (other.c)")
-
- self.assertIn("main.c", frames[1]["source"]["path"], "Expect original source path to be in source code frame (main.c)")
- self.assertNotIn("sourceReference", frames[1]["source"], "Expect no sourceReference in source code frame (main.c)")
+ self.assertIn(
+ "other.c",
+ frames[0]["source"]["path"],
+ "Expect original source path to be in unavailable source frame (other.c)",
+ )
+ self.assertNotIn(
+ "sourceReference",
+ frames[0]["source"],
+ "Expect sourceReference source path in to be in unavailable source frame (other.c)",
+ )
+
+ self.assertIn(
+ "main.c",
+ frames[1]["source"]["path"],
+ "Expect original source path to be in source code frame (main.c)",
+ )
+ self.assertNotIn(
+ "sourceReference",
+ frames[1]["source"],
+ "Expect no sourceReference in source code frame (main.c)",
+ )
@skipIfWindows
def test_stopDisassemblyDispay_never(self):
"""
Test that with with stop-disassembly-display = never - all frames don't give assembly code.
"""
frames = self.build_and_run_until_breakpoint("never")
- self.assertIn("other.c", frames[0]["source"]["path"], "Expect original source path to be in unavailable source frame (other.c)")
- self.assertNotIn("sourceReference", frames[0]["source"], "Expect sourceReference source path in to be in unavailable source frame (other.c)")
-
- self.assertIn("main.c", frames[1]["source"]["path"], "Expect original source path to be in source code frame (main.c)")
- self.assertNotIn("sourceReference", frames[1]["source"], "Expect no sourceReference in source code frame (main.c)")
+ self.assertIn(
+ "other.c",
+ frames[0]["source"]["path"],
+ "Expect original source path to be in unavailable source frame (other.c)",
+ )
+ self.assertNotIn(
+ "sourceReference",
+ frames[0]["source"],
+ "Expect sourceReference source path in to be in unavailable source frame (other.c)",
+ )
+
+ self.assertIn(
+ "main.c",
+ frames[1]["source"]["path"],
+ "Expect original source path to be in source code frame (main.c)",
+ )
+ self.assertNotIn(
+ "sourceReference",
+ frames[1]["source"],
+ "Expect no sourceReference in source code frame (main.c)",
+ )
@skipIfWindows
def test_stopDisassemblyDispay_always(self):
"""
Test that with with stop-disassembly-display = always - all frames give source code.
"""
frames = self.build_and_run_until_breakpoint("always")
- self.assertNotIn("other.c", frames[0]["source"]["path"], "Expect original source path to not be in unavailable source frame (other.c)")
- self.assertIn("sourceReference", frames[0]["source"], "Expect sourceReference source path in to be in unavailable source frame (other.c)")
-
- self.assertNotIn("main.c", frames[1]["source"]["path"], "Expect original source path to not be in source code frame (main.c)")
- self.assertIn("sourceReference", frames[1]["source"], "Expect sourceReference in source code frame (main.c)")
+ self.assertNotIn(
+ "other.c",
+ frames[0]["source"]["path"],
+ "Expect original source path to not be in unavailable source frame (other.c)",
+ )
+ self.assertIn(
+ "sourceReference",
+ frames[0]["source"],
+ "Expect sourceReference source path in to be in unavailable source frame (other.c)",
+ )
+
+ self.assertNotIn(
+ "main.c",
+ frames[1]["source"]["path"],
+ "Expect original source path to not be in source code frame (main.c)",
+ )
+ self.assertIn(
+ "sourceReference",
+ frames[1]["source"],
+ "Expect sourceReference in source code frame (main.c)",
+ )
``````````
</details>
https://github.com/llvm/llvm-project/pull/136494
More information about the lldb-commits
mailing list