[Lldb-commits] [PATCH] D144224: [lldb] Extend SWIG SBProcess interface with WriteMemoryAsCString method

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 16 17:16:06 PST 2023


mib updated this revision to Diff 498201.
mib retitled this revision from "[lldb] Extend SWIG SBProcess interface with WriteCStringToMemory method" to "[lldb] Extend SWIG SBProcess interface with WriteMemoryAsCString method".
mib edited the summary of this revision.

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

https://reviews.llvm.org/D144224

Files:
  lldb/bindings/interface/SBProcessExtensions.i


Index: lldb/bindings/interface/SBProcessExtensions.i
===================================================================
--- lldb/bindings/interface/SBProcessExtensions.i
+++ lldb/bindings/interface/SBProcessExtensions.i
@@ -2,6 +2,16 @@
 %extend lldb::SBProcess {
 #ifdef SWIGPYTHON
     %pythoncode %{
+        def WriteMemoryAsCString(self, addr, str, error):
+            '''
+              WriteMemoryAsCString(self, addr, str, error):
+                This functions the same as `WriteMemory` except a null-terminator is appended
+                to the end of the buffer if it is not there already.
+            '''
+            if not str[-1] == '\0':
+                str += '\0'
+            return self.WriteMemory(addr, str, error)
+
         def __get_is_alive__(self):
             '''Returns "True" if the process is currently alive, "False" otherwise'''
             s = self.GetState()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144224.498201.patch
Type: text/x-patch
Size: 903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230217/81047505/attachment.bin>


More information about the lldb-commits mailing list