diff options
author | Johnny Chen <johnny.chen@apple.com> | 2011-12-16 01:56:27 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2011-12-16 01:56:27 +0000 |
commit | 7cc3d31e15a106e132532df1dc85291817665ef2 (patch) | |
tree | 1eca7bd7c525f6b182994d0a035afb40c8186c47 /lldb/test/python_api/process | |
parent | 561dade58d0b142ea0d38001923f8441be3cf2fe (diff) | |
download | bcm5719-llvm-7cc3d31e15a106e132532df1dc85291817665ef2.tar.gz bcm5719-llvm-7cc3d31e15a106e132532df1dc85291817665ef2.zip |
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.
llvm-svn: 146719
Diffstat (limited to 'lldb/test/python_api/process')
-rw-r--r-- | lldb/test/python_api/process/TestProcessAPI.py | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/lldb/test/python_api/process/TestProcessAPI.py b/lldb/test/python_api/process/TestProcessAPI.py index 2c273e5b1ff..35bc0eba264 100644 --- a/lldb/test/python_api/process/TestProcessAPI.py +++ b/lldb/test/python_api/process/TestProcessAPI.py @@ -85,17 +85,11 @@ class ProcessAPITestCase(TestBase): 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 @@ class ProcessAPITestCase(TestBase): 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 @@ class ProcessAPITestCase(TestBase): 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(): |