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.

llvm-svn: 134909
This commit is contained in:
Johnny Chen 2011-07-11 19:15:11 +00:00
parent 39c0482680
commit 56b92a7b04
2 changed files with 25 additions and 5 deletions

View File

@ -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."""

View File

@ -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")