aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorSanthosh Kumar Ellendula <quic_sellendu@quicinc.com>2025-07-10 01:59:20 +0530
committerGitHub <noreply@github.com>2025-07-10 01:59:20 +0530
commit76b1dcfac5da469ca198efcfe0c256ada0b7f0cb (patch)
treea4a4d89bdab154575f09bb4d99878b11c6b263df /lldb/packages/Python/lldbsuite/test
parentd193a586c0b41192b031ce6a858bec0f855560ad (diff)
downloadllvm-76b1dcfac5da469ca198efcfe0c256ada0b7f0cb.zip
llvm-76b1dcfac5da469ca198efcfe0c256ada0b7f0cb.tar.gz
llvm-76b1dcfac5da469ca198efcfe0c256ada0b7f0cb.tar.bz2
[lldb][lldb-dap] Added support for "WriteMemory" request. (#131820)
Added debug adapter support for write memory. --------- Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-hyd.qualcomm.com> Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-lv.qualcomm.com>
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py14
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py18
2 files changed, 32 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index d227a66..68f58bf 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -831,6 +831,20 @@ class DebugCommunication(object):
}
return self.send_recv(command_dict)
+ def request_writeMemory(self, memoryReference, data, offset=0, allowPartial=True):
+ args_dict = {
+ "memoryReference": memoryReference,
+ "offset": offset,
+ "allowPartial": allowPartial,
+ "data": data,
+ }
+ command_dict = {
+ "command": "writeMemory",
+ "type": "request",
+ "arguments": args_dict,
+ }
+ return self.send_recv(command_dict)
+
def request_evaluate(self, expression, frameIndex=0, threadId=None, context=None):
stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId)
if stackFrame is None:
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 6299caf..00b01d4 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -8,6 +8,7 @@ from dap_server import Source
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbplatformutil
import lldbgdbserverutils
+import base64
class DAPTestCaseBase(TestBase):
@@ -506,3 +507,20 @@ class DAPTestCaseBase(TestBase):
self.dap_server.request_disconnect(terminateDebuggee=True)
self.assertIsNotNone(server_tool, "debugserver not found.")
return server_tool
+
+ def writeMemory(self, memoryReference, data=None, offset=None, allowPartial=None):
+ # This function accepts data in decimal and hexadecimal format,
+ # converts it to a Base64 string, and send it to the DAP,
+ # which expects Base64 encoded data.
+ encodedData = (
+ ""
+ if data is None
+ else base64.b64encode(
+ # (bit_length + 7 (rounding up to nearest byte) ) //8 = converts to bytes.
+ data.to_bytes((data.bit_length() + 7) // 8, "little")
+ ).decode()
+ )
+ response = self.dap_server.request_writeMemory(
+ memoryReference, encodedData, offset=offset, allowPartial=allowPartial
+ )
+ return response