[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 18 12:01:58 PDT 2025


================
@@ -112,3 +112,23 @@ def test_readMemory(self):
         # Reads at offset 0x0 fail
         mem = self.dap_server.request_readMemory("0x0", 0, 6)
         self.assertEqual(mem["success"], False)
+
+    def test_writeMemory(self):
+        """
+        Tests the 'writeMemory' request
+        """
+        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")],
+        )
+        self.continue_to_next_stop()
+
+        ptr_deref = self.dap_server.request_evaluate("not_a_ptr")["body"]
+        memref = ptr_deref["memoryReference"]
+
+        mem = self.dap_server.request_writeMemory(memref, 0, "0x11")["body"]
+        self.assertEqual(mem["bytesWritten"], 8)
----------------
ashgti wrote:

Should we also read the value written to make sure it took effect?

Also, are there cases where this is expected to fail? Like writing to memory that is readonly.

https://github.com/llvm/llvm-project/pull/131820


More information about the lldb-commits mailing list