================ @@ -112,3 +112,48 @@ 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() + + # Get the 'not_a_ptr' writable variablle reference address. + ptr_deref = self.dap_server.request_evaluate("not_a_ptr")["body"] + memref = ptr_deref["memoryReference"] + + # Write the Base64-encoded string "Mg==", which decodes to binary 0x32 ---------------- santhoshe447 wrote:
> Instead of a magic variable, you could add a helper to `lldbdap_testcase.py` > that uses the [base64](https://docs.python.org/3/library/base64.html) python > module to encode byte strings. E.g. your example is: > > ``` > $ python3 > >>> import base64 > >>> base64.b64encode(b'2') > b'Mg==' > ``` > > And it might be a bit more clear to the reader whats happening. > > Something along the lines of: > > ``` > def writeMemory(self, memory_reference, data, offset=None, > allow_partial=None): > encodedData = base64.b64encode > resp = self.dap_server.request_writeMemory(memory_reference, > offset=offset, allow_partial=allow_partial, data=encodedData) > self.assertTrue(resp['success']) > self.assertEqual(resp['body']['bytesWritten'], len(data)) > ``` Thanks for your suggestion. I will update accordingly. https://github.com/llvm/llvm-project/pull/131820 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits