[Lldb-commits] [PATCH] D60022: [Process] Fix WriteMemory return value

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 29 19:01:47 PDT 2019


mib updated this revision to Diff 192954.
mib added a comment.

Remove TraceOn and XMLSupport Check


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60022/new/

https://reviews.llvm.org/D60022

Files:
  packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWriteMemory.py
  source/Target/Process.cpp


Index: source/Target/Process.cpp
===================================================================
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -2261,8 +2261,9 @@
       });
 
       if (bytes_written < size)
-        WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written,
-                           size - bytes_written, error);
+        return bytes_written + WriteMemoryPrivate(addr + bytes_written,
+                                                  ubuf + bytes_written,
+                                                  size - bytes_written, error);
     }
   } else {
     return WriteMemoryPrivate(addr, buf, size, error);
Index: packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWriteMemory.py
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWriteMemory.py
@@ -0,0 +1,29 @@
+from __future__ import print_function
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestWriteMemory(GDBRemoteTestBase):
+
+    def test(self):
+
+        class MyResponder(MockGDBServerResponder):
+            def setBreakpoint(self, packet):
+                return "OK"
+
+        self.server.responder = MyResponder()
+        target = self.dbg.CreateTarget('')
+        process = self.connect(target)
+
+        bp = target.BreakpointCreateByAddress(0x1000)
+        self.assertTrue(bp.IsValid())
+        self.assertEqual(bp.GetNumLocations(), 1)
+        bp.SetEnabled(True)
+        self.assertTrue(bp.IsEnabled())
+
+        err = lldb.SBError()
+        data = str("\x01\x02\x03\x04")
+        result = process.WriteMemory(0x1000, data, err)
+        self.assertEqual(result, 4)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60022.192954.patch
Type: text/x-patch
Size: 1816 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190330/5253be0b/attachment.bin>


More information about the lldb-commits mailing list