[Lldb-commits] [lldb] 4a8cc28 - Fix TestProcessAPI.py to only allocate sys.maxsize buffer

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 7 16:05:30 PST 2023


Author: Jason Molenda
Date: 2023-02-07T16:05:24-08:00
New Revision: 4a8cc285e9f3252ca31941dccfddf8fd10c9911b

URL: https://github.com/llvm/llvm-project/commit/4a8cc285e9f3252ca31941dccfddf8fd10c9911b
DIFF: https://github.com/llvm/llvm-project/commit/4a8cc285e9f3252ca31941dccfddf8fd10c9911b.diff

LOG: Fix TestProcessAPI.py to only allocate sys.maxsize buffer

I hardcoded nearly a UINT64_MAX number in this test case,
and python is not able to convert it to a long on some
platforms.  Use sys.maxsize instead; this also would have
failed if the testsuite was run on a 32-bit system.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/python_api/process/TestProcessAPI.py b/lldb/test/API/python_api/process/TestProcessAPI.py
index 36291fcc66b8..66f438a24f5b 100644
--- a/lldb/test/API/python_api/process/TestProcessAPI.py
+++ b/lldb/test/API/python_api/process/TestProcessAPI.py
@@ -3,6 +3,7 @@
 """
 
 import lldb
+import sys
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.lldbutil import get_stopped_thread, state_type_to_str
@@ -76,15 +77,16 @@ def test_read_memory(self):
         # will try to malloc it and fail, we should get an error 
         # result.
         error = lldb.SBError()
+        bigsize = sys.maxsize - 8;
         content = process.ReadMemory(
                 val.AddressOf().GetValueAsUnsigned(), 
-                0xffffffffffffffe8, error)
+                bigsize, error)
         if error.Success():
             self.assertFalse(error.Success(), "SBProcessReadMemory claims to have "
-                      "successfully read 0xffffffffffffffe8 bytes")
+                      "successfully read 0x%x bytes" % bigsize)
         if self.TraceOn():
-            print("Tried to read 0xffffffffffffffe8 bytes, got error message: ",
-                  error.GetCString())
+            print("Tried to read 0x%x bytes, got error message: %s" %
+                  (bigsize, error.GetCString()))
 
         # Read (char *)my_char_ptr.
         val = frame.FindValue("my_char_ptr", lldb.eValueTypeVariableGlobal)


        


More information about the lldb-commits mailing list