[Lldb-commits] [lldb] r321353 - Enable TestReadMemCString on non-darwin targets

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 22 02:26:59 PST 2017


Author: labath
Date: Fri Dec 22 02:26:59 2017
New Revision: 321353

URL: http://llvm.org/viewvc/llvm-project?rev=321353&view=rev
Log:
Enable TestReadMemCString on non-darwin targets

The test works fine on linux, and I believe other targets should not
have an issue with as well. If they do, we can start blacklisting
instead of whitelisting.

The idea of using "-1" as the value of the pointer on non-apple targets
backfired, as it fails the "address != LLDB_INVALID_ADDRESS" test (-1 is
the value of LLDB_INVALID_ADDRESS).  However, it should be safe to use
0x100 for other targets as well. The first page of memory is generally
kept unreadable to catch null pointer dereferences.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py
    lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/main.c

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py?rev=321353&r1=321352&r2=321353&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py Fri Dec 22 02:26:59 2017
@@ -12,13 +12,8 @@ from lldbsuite.test import lldbutil
 class TestReadMemCString(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
+    NO_DEBUG_INFO_TESTCASE = True
 
-    def setUp(self):
-        TestBase.setUp(self)
-
-    # Need to have a char* pointer that points to unmapped memory to run
-    # this test on other platforms -- Darwin only for now.
-    @skipUnlessDarwin
     def test_read_memory_c_string(self):
         """Test corner case behavior of SBProcess::ReadCStringFromMemory"""
         self.build()

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/main.c?rev=321353&r1=321352&r2=321353&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/main.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/main.c Fri Dec 22 02:26:59 2017
@@ -3,11 +3,9 @@ int main ()
 {
    const char *empty_string = "";
    const char *one_letter_string = "1";
-#if defined (__APPLE__)
-   const char *invalid_memory_string = (char*)0x100; // lower 4k is always PAGEZERO & unreadable on darwin
-#else
-   const char *invalid_memory_string = -1ULL; // maybe an invalid address on other platforms?
-#endif
+   // This expects that lower 4k of memory will be mapped unreadable, which most
+   // OSs do (to catch null pointer dereferences).
+   const char *invalid_memory_string = (char*)0x100;
 
    return empty_string[0] + one_letter_string[0]; // breakpoint here
 }




More information about the lldb-commits mailing list