Expose new read memory fucntion through python in SBProcess:

    size_t
    SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);

    uint64_t
    SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);

    lldb::addr_t
    SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &error);

These ReadCStringFromMemory() has some SWIG type magic that makes it return the
python string directly and the "buf" is not needed:

error = SBError()
max_cstr_len = 256
cstr = lldb.process.ReadCStringFromMemory (0x1000, max_cstr_len, error)
if error.Success():
    ....

The other two functions behave as expteced. This will make it easier to get integer values
from the inferior process that are correctly byte swapped. Also for pointers, the correct
pointer byte size will be used.

Also cleaned up a few printf style warnings for the 32 bit lldb build on darwin.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@146636 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/scripts/Python/interface/SBProcess.i b/scripts/Python/interface/SBProcess.i
index b2ab923..920aefb 100644
--- a/scripts/Python/interface/SBProcess.i
+++ b/scripts/Python/interface/SBProcess.i
@@ -208,6 +208,57 @@
     size_t
     WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
 
+    %feature("autodoc", "
+    Reads a NULL terminated C string from the current process's address space.
+    It returns a python string of the exact length, or truncates the string if
+    the maximum character limit is reached. Example:
+    
+    # Read a C string of at most 256 bytes from address '0x1000' 
+    error = lldb.SBError()
+    cstring = process.ReadMemory(0x1000, 256, error)
+    if error.Success():
+        print 'cstring: ', cstring
+    else
+        print 'error: ', error
+    ") ReadCStringFromMemory;
+
+    size_t
+    ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
+
+    %feature("autodoc", "
+    Reads an unsigned integer from memory given a byte size and an address. 
+    Returns the unsigned integer that was read. Example:
+    
+    # Read a 4 byte unsigned integer from address 0x1000
+    error = lldb.SBError()
+    uint = ReadUnsignedFromMemory(0x1000, 4, error)
+    if error.Success():
+        print 'integer: %u' % uint
+    else
+        print 'error: ', error
+
+    ") ReadUnsignedFromMemory;
+
+    uint64_t
+    ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);
+    
+    %feature("autodoc", "
+    Reads a pointer from memory from an address and returns the value. Example:
+    
+    # Read a pointer from address 0x1000
+    error = lldb.SBError()
+    ptr = ReadPointerFromMemory(0x1000, error)
+    if error.Success():
+        print 'pointer: 0x%x' % ptr
+    else
+        print 'error: ', error
+    
+    ") ReadPointerFromMemory;
+    
+    lldb::addr_t
+    ReadPointerFromMemory (addr_t addr, lldb::SBError &error);
+    
+
     // Events
     static lldb::StateType
     GetStateFromEvent (const lldb::SBEvent &event);