[Lldb-commits] [lldb] r146719 - /lldb/trunk/test/python_api/process/TestProcessAPI.py

Johnny Chen johnny.chen at apple.com
Thu Dec 15 17:56:27 PST 2011


Author: johnny
Date: Thu Dec 15 19:56:27 2011
New Revision: 146719

URL: http://llvm.org/viewvc/llvm-project?rev=146719&view=rev
Log:
Simplify the setup leading to the testing of ReadMemory(), ReadCStringFromMemory(), and ReadUnsignedFromMemory().
Instead of getting the location of the variable and converting the hex string to an int, just use
val.AddressOf().GetValueAsUnsigned() to compute the address of the memory region to read from.

Modified:
    lldb/trunk/test/python_api/process/TestProcessAPI.py

Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/TestProcessAPI.py?rev=146719&r1=146718&r2=146719&view=diff
==============================================================================
--- lldb/trunk/test/python_api/process/TestProcessAPI.py (original)
+++ lldb/trunk/test/python_api/process/TestProcessAPI.py Thu Dec 15 19:56:27 2011
@@ -85,17 +85,11 @@
         val = frame.FindValue("my_char", lldb.eValueTypeVariableGlobal)
         self.DebugSBValue(val)
 
-        # If the variable does not have a load address, there's no sense continuing.
-        if not val.GetLocation().startswith("0x"):
-            return
-
-        # OK, let's get the hex location of the variable.
-        location = int(val.GetLocation(), 16)
-
         # Due to the typemap magic (see lldb.swig), we pass in 1 to ReadMemory and
         # expect to get a Python string as the result object!
         error = lldb.SBError()
-        content = process.ReadMemory(location, 1, error)
+        self.assertFalse(val.TypeIsPointerType())
+        content = process.ReadMemory(val.AddressOf().GetValueAsUnsigned(), 1, error)
         if not error.Success():
             self.fail("SBProcess.ReadMemory() failed")
         if self.TraceOn():
@@ -122,16 +116,10 @@
         val = frame.FindValue("my_cstring", lldb.eValueTypeVariableGlobal)
         self.DebugSBValue(val)
 
-        # If the variable does not have a load address, there's no sense continuing.
-        if not val.GetLocation().startswith("0x"):
-            return
-
-        # OK, let's get the hex location of the variable.
-        location = int(val.GetLocation(), 16)
-
         # Due to the typemap magic (see lldb.swig), we pass in 256 to read at most 256 bytes
         # from the address, and expect to get a Python string as the result object!
-        cstring = process.ReadCStringFromMemory(location, 256, error)
+        self.assertFalse(val.TypeIsPointerType())
+        cstring = process.ReadCStringFromMemory(val.AddressOf().GetValueAsUnsigned(), 256, error)
         if not error.Success():
             self.fail("SBProcess.ReadCStringFromMemory() failed")
         if self.TraceOn():
@@ -145,16 +133,10 @@
         val = frame.FindValue("my_uint32", lldb.eValueTypeVariableGlobal)
         self.DebugSBValue(val)
 
-        # If the variable does not have a load address, there's no sense continuing.
-        if not val.GetLocation().startswith("0x"):
-            return
-
-        # OK, let's get the hex location of the variable.
-        location = int(val.GetLocation(), 16)
-
-        # Due to the typemap magic (see lldb.swig), we pass in 4 to read at 4 bytes
+        # Due to the typemap magic (see lldb.swig), we pass in 4 to read 4 bytes
         # from the address, and expect to get an int as the result!
-        my_uint32 = process.ReadUnsignedFromMemory(location, 4, error)
+        self.assertFalse(val.TypeIsPointerType())
+        my_uint32 = process.ReadUnsignedFromMemory(val.AddressOf().GetValueAsUnsigned(), 4, error)
         if not error.Success():
             self.fail("SBProcess.ReadCStringFromMemory() failed")
         if self.TraceOn():





More information about the lldb-commits mailing list