[Lldb-commits] [lldb] [lldb-dap] Support inspecting memory (PR #104317)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 14 15:37:35 PDT 2024
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 82ee31f75ac1316006fa9e21dddfddec37cf7072...e01ea18961bbae0fb747b312670946bd768c5d73 lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-08-14 22:31:50.000000 +0000
+++ packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-08-14 22:37:06.169257 +0000
@@ -689,13 +689,11 @@
}
instructions = self.send_recv(command_dict)["body"]["instructions"]
for inst in instructions:
self.disassembled_instructions[inst["address"]] = inst
- def request_read_memory(
- self, memoryReference, offset, count
- ):
+ def request_read_memory(self, memoryReference, offset, count):
args_dict = {
"memoryReference": memoryReference,
"offset": offset,
"count": count,
}
--- test/API/tools/lldb-dap/memory/TestDAP_memory.py 2024-08-14 22:31:50.000000 +0000
+++ test/API/tools/lldb-dap/memory/TestDAP_memory.py 2024-08-14 22:37:06.268921 +0000
@@ -27,16 +27,16 @@
line_number(source, "// Breakpoint"),
],
)
self.continue_to_next_stop()
- locals = {l['name']: l for l in self.dap_server.get_local_variables()}
- rawptr_ref = locals['rawptr']['memoryReference']
+ locals = {l["name"]: l for l in self.dap_server.get_local_variables()}
+ rawptr_ref = locals["rawptr"]["memoryReference"]
# We can read the complete string
mem = self.dap_server.request_read_memory(rawptr_ref, 0, 5)["body"]
- self.assertEqual(mem["unreadableBytes"], 0);
+ self.assertEqual(mem["unreadableBytes"], 0)
self.assertEqual(b64decode(mem["data"]), b"dead\0")
# Use an offset
mem = self.dap_server.request_read_memory(rawptr_ref, 2, 3)["body"]
self.assertEqual(b64decode(mem["data"]), b"ad\0")
@@ -54,68 +54,84 @@
# Reads at offset 0x0 fail
mem = self.dap_server.request_read_memory("0x0", 0, 6)
self.assertEqual(mem["success"], False)
self.assertTrue(mem["message"].startswith("Unable to read memory: "))
-
def test_memory_refs_variables(self):
"""
Tests memory references for evaluate
"""
program = self.getBuildArtifact("a.out")
self.build_and_launch(program)
source = "main.cpp"
self.source_path = os.path.join(os.getcwd(), source)
self.set_source_breakpoints(
- source, [line_number(source, "// Breakpoint")],
+ source,
+ [line_number(source, "// Breakpoint")],
)
self.continue_to_next_stop()
- locals = {l['name']: l for l in self.dap_server.get_local_variables()}
+ locals = {l["name"]: l for l in self.dap_server.get_local_variables()}
# Pointers should have memory-references
- self.assertIn("memoryReference", locals['rawptr'].keys())
+ self.assertIn("memoryReference", locals["rawptr"].keys())
# Smart-pointers also have memory-references
- self.assertIn("memoryReference", self.dap_server.get_local_variable_child("smartptr", "pointer").keys())
+ self.assertIn(
+ "memoryReference",
+ self.dap_server.get_local_variable_child("smartptr", "pointer").keys(),
+ )
# Non-pointers should not have memory-references
- self.assertNotIn("memoryReference", locals['not_a_ptr'].keys())
-
+ self.assertNotIn("memoryReference", locals["not_a_ptr"].keys())
def test_memory_refs_evaluate(self):
"""
Tests memory references for evaluate
"""
program = self.getBuildArtifact("a.out")
self.build_and_launch(program)
source = "main.cpp"
self.source_path = os.path.join(os.getcwd(), source)
self.set_source_breakpoints(
- source, [line_number(source, "// Breakpoint")],
+ source,
+ [line_number(source, "// Breakpoint")],
)
self.continue_to_next_stop()
# Pointers contain memory references
- self.assertIn("memoryReference", self.dap_server.request_evaluate("rawptr + 1")["body"].keys())
+ self.assertIn(
+ "memoryReference",
+ self.dap_server.request_evaluate("rawptr + 1")["body"].keys(),
+ )
# Non-pointer expressions don't include a memory reference
- self.assertNotIn("memoryReference", self.dap_server.request_evaluate("1 + 3")["body"].keys())
-
+ self.assertNotIn(
+ "memoryReference", self.dap_server.request_evaluate("1 + 3")["body"].keys()
+ )
def test_memory_refs_set_variable(self):
"""
Tests memory references for `setVariable`
"""
program = self.getBuildArtifact("a.out")
self.build_and_launch(program)
source = "main.cpp"
self.source_path = os.path.join(os.getcwd(), source)
self.set_source_breakpoints(
- source, [line_number(source, "// Breakpoint")],
+ source,
+ [line_number(source, "// Breakpoint")],
)
self.continue_to_next_stop()
# Pointers contain memory references
ptr_value = self.get_local_as_int("rawptr")
- self.assertIn("memoryReference", self.dap_server.request_setVariable(1, "rawptr", ptr_value + 2)["body"].keys())
+ self.assertIn(
+ "memoryReference",
+ self.dap_server.request_setVariable(1, "rawptr", ptr_value + 2)[
+ "body"
+ ].keys(),
+ )
# Non-pointer expressions don't include a memory reference
- self.assertNotIn("memoryReference", self.dap_server.request_setVariable(1, "not_a_ptr", 42)["body"].keys())
+ self.assertNotIn(
+ "memoryReference",
+ self.dap_server.request_setVariable(1, "not_a_ptr", 42)["body"].keys(),
+ )
``````````
</details>
https://github.com/llvm/llvm-project/pull/104317
More information about the lldb-commits
mailing list