[Lldb-commits] [lldb] r134909 - in /lldb/trunk/test: lldbtest.py python_api/target/TestTargetAPI.py

Johnny Chen johnny.chen at apple.com
Mon Jul 11 12:15:11 PDT 2011


Author: johnny
Date: Mon Jul 11 14:15:11 2011
New Revision: 134909

URL: http://llvm.org/viewvc/llvm-project?rev=134909&view=rev
Log:
Update the test scenario for find_global_variables() to now start the inferior process
before issuing API calls to find the global variable and to get its value.

rdar://problem/9700873 has been updated to reflect the latest status.  The dwarf case
now does not seg fault if the inferior is not started; instead, for dwarf case, the
value retrieved from the global variable is None.

Modified:
    lldb/trunk/test/lldbtest.py
    lldb/trunk/test/python_api/target/TestTargetAPI.py

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=134909&r1=134908&r2=134909&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Mon Jul 11 14:15:11 2011
@@ -938,7 +938,7 @@
     # Misc. helper methods for debugging test execution
     # =================================================
 
-    def DebugSBValue(self, frame, val):
+    def DebugSBValue(self, val):
         """Debug print a SBValue object, if traceAlways is True."""
         from lldbutil import value_type_to_str
 
@@ -950,11 +950,11 @@
         err.write('\t' + "TypeName      -> " + val.GetTypeName()            + '\n')
         err.write('\t' + "ByteSize      -> " + str(val.GetByteSize())       + '\n')
         err.write('\t' + "NumChildren   -> " + str(val.GetNumChildren())    + '\n')
-        err.write('\t' + "Value         -> " + str(val.GetValue(frame))     + '\n')
+        err.write('\t' + "Value         -> " + str(val.GetValue())          + '\n')
         err.write('\t' + "ValueType     -> " + value_type_to_str(val.GetValueType()) + '\n')
-        err.write('\t' + "Summary       -> " + str(val.GetSummary(frame))   + '\n')
+        err.write('\t' + "Summary       -> " + str(val.GetSummary())        + '\n')
         err.write('\t' + "IsPointerType -> " + str(val.TypeIsPointerType()) + '\n')
-        err.write('\t' + "Location      -> " + val.GetLocation(frame)       + '\n')
+        err.write('\t' + "Location      -> " + val.GetLocation()            + '\n')
 
     def DebugPExpect(self, child):
         """Debug the spwaned pexpect object."""

Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=134909&r1=134908&r2=134909&view=diff
==============================================================================
--- lldb/trunk/test/python_api/target/TestTargetAPI.py (original)
+++ lldb/trunk/test/python_api/target/TestTargetAPI.py Mon Jul 11 14:15:11 2011
@@ -22,7 +22,12 @@
         self.find_global_variables('a.out')
 
     #rdar://problem/9700873
-    @unittest2.skip("segmentation fault -- skipping")
+    # Find global variable value fails for dwarf if inferior not started
+    # (Was CrashTracer: [USER] 1 crash in Python at _lldb.so: lldb_private::MemoryCache::Read + 94)
+    #
+    # It does not segfaults now.  But for dwarf, the variable value is None if
+    # the inferior process does not exist yet.  The radar has been updated.
+    #@unittest232.skip("segmentation fault -- skipping")
     @python_api_test
     def test_find_global_variables_with_dwarf(self):
         """Exercise SBTarget.FindGlobalVariables() API."""
@@ -102,9 +107,24 @@
         target = self.dbg.CreateTarget(exe)
         self.assertTrue(target, VALID_TARGET)
 
+        #rdar://problem/9700873
+        # Find global variable value fails for dwarf if inferior not started
+        # (Was CrashTracer: [USER] 1 crash in Python at _lldb.so: lldb_private::MemoryCache::Read + 94)
+        #
+        # Remove the lines to create a breakpoint and to start the inferior
+        # which are workarounds for the dwarf case.
+
+        breakpoint = target.BreakpointCreateByLocation('main.c', self.line1)
+        self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+        # Now launch the process, and do not stop at entry point.
+        process = target.LaunchSimple(None, None, os.getcwd())
+        self.assertTrue(process, PROCESS_IS_VALID)
+
         value_list = target.FindGlobalVariables('my_global_var_of_char_type', 3)
         self.assertTrue(value_list.GetSize() == 1)
         my_global_var = value_list.GetValueAtIndex(0)
+        self.DebugSBValue(my_global_var)
         self.assertTrue(my_global_var)
         self.expect(my_global_var.GetName(), exe=False,
             startstr = "my_global_var_of_char_type")





More information about the lldb-commits mailing list