diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 9a6874dd89d2..0be459f57c4c 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -938,7 +938,7 @@ class TestBase(unittest2.TestCase): # 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 @@ class TestBase(unittest2.TestCase): 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.""" diff --git a/lldb/test/python_api/target/TestTargetAPI.py b/lldb/test/python_api/target/TestTargetAPI.py index 6c2c4fd47844..81d250b497f2 100644 --- a/lldb/test/python_api/target/TestTargetAPI.py +++ b/lldb/test/python_api/target/TestTargetAPI.py @@ -22,7 +22,12 @@ class TargetAPITestCase(TestBase): 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 @@ class TargetAPITestCase(TestBase): 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")