forked from OSchip/llvm-project
[lldb/Test] Add a trace method to replace print statements.
Many tests use (commented out) print statement for debugging the test itself. This patch adds a new trace method to lldbtest to reuse the existing tracing infrastructure and replace these print statements. Differential revision: https://reviews.llvm.org/D80448
This commit is contained in:
parent
5bf2409a4e
commit
b321b42941
|
@ -505,6 +505,10 @@ class Base(unittest2.TestCase):
|
||||||
"""Returns True if we are in trace mode (tracing detailed test execution)."""
|
"""Returns True if we are in trace mode (tracing detailed test execution)."""
|
||||||
return traceAlways
|
return traceAlways
|
||||||
|
|
||||||
|
def trace(self, *args,**kwargs):
|
||||||
|
with recording(self, self.TraceOn()) as sbuf:
|
||||||
|
print(*args, **kwargs, file=sbuf)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -22,8 +22,8 @@ class SteppingSpeedBench(BenchBase):
|
||||||
self.break_spec = '-n main'
|
self.break_spec = '-n main'
|
||||||
self.count = 50
|
self.count = 50
|
||||||
|
|
||||||
#print("self.exe=%s" % self.exe)
|
self.trace("self.exe=%s" % self.exe)
|
||||||
#print("self.break_spec=%s" % self.break_spec)
|
self.trace("self.break_spec=%s" % self.break_spec)
|
||||||
|
|
||||||
@benchmarks_test
|
@benchmarks_test
|
||||||
@no_debug_info_test
|
@no_debug_info_test
|
||||||
|
|
|
@ -82,7 +82,7 @@ class targetCommandTestCase(TestBase):
|
||||||
if match:
|
if match:
|
||||||
# We will start from (index + 1) ....
|
# We will start from (index + 1) ....
|
||||||
base = int(match.group(1), 10) + 1
|
base = int(match.group(1), 10) + 1
|
||||||
#print("base is:", base)
|
self.trace("base is:", base)
|
||||||
break
|
break
|
||||||
|
|
||||||
self.runCmd("target create " + exe_a, CURRENT_EXECUTABLE_SET)
|
self.runCmd("target create " + exe_a, CURRENT_EXECUTABLE_SET)
|
||||||
|
|
|
@ -126,7 +126,7 @@ class BreakpointConditionsTestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by name 'c'.
|
# Now create a breakpoint on main.c by name 'c'.
|
||||||
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() == 1,
|
breakpoint.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
@ -194,7 +194,7 @@ class BreakpointConditionsTestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by name 'c'.
|
# Now create a breakpoint on main.c by name 'c'.
|
||||||
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() == 1,
|
breakpoint.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
|
|
@ -118,7 +118,7 @@ class BreakpointSerialization(TestBase):
|
||||||
copy_text = copy_desc.GetData()
|
copy_text = copy_desc.GetData()
|
||||||
|
|
||||||
# These two should be identical.
|
# These two should be identical.
|
||||||
# print ("Source text for %d is %s."%(i, source_text))
|
self.trace("Source text for %d is %s."%(i, source_text))
|
||||||
self.assertTrue (source_text == copy_text, "Source and dest breakpoints are not identical: \nsource: %s\ndest: %s"%(source_text, copy_text))
|
self.assertTrue (source_text == copy_text, "Source and dest breakpoints are not identical: \nsource: %s\ndest: %s"%(source_text, copy_text))
|
||||||
|
|
||||||
def do_check_resolvers(self):
|
def do_check_resolvers(self):
|
||||||
|
|
|
@ -147,13 +147,13 @@ class SkipSummaryDataFormatterTestCase(TestBase):
|
||||||
import re
|
import re
|
||||||
gcc_version_output = system(
|
gcc_version_output = system(
|
||||||
[[lldbutil.which(self.getCompiler()), "-v"]])[1]
|
[[lldbutil.which(self.getCompiler()), "-v"]])[1]
|
||||||
#print("my output:", gcc_version_output)
|
self.trace("my output:", gcc_version_output)
|
||||||
for line in gcc_version_output.split(os.linesep):
|
for line in gcc_version_output.split(os.linesep):
|
||||||
m = re.search('\(Apple Inc\. build ([0-9]+)\)', line)
|
m = re.search('\(Apple Inc\. build ([0-9]+)\)', line)
|
||||||
#print("line:", line)
|
self.trace("line:", line)
|
||||||
if m:
|
if m:
|
||||||
gcc_build = int(m.group(1))
|
gcc_build = int(m.group(1))
|
||||||
#print("gcc build:", gcc_build)
|
self.trace("gcc build:", gcc_build)
|
||||||
if gcc_build >= 5666:
|
if gcc_build >= 5666:
|
||||||
# rdar://problem/9804600"
|
# rdar://problem/9804600"
|
||||||
self.skipTest(
|
self.skipTest(
|
||||||
|
|
|
@ -267,7 +267,7 @@ class LoadUnloadTestCase(TestBase):
|
||||||
output = self.res.GetOutput()
|
output = self.res.GetOutput()
|
||||||
pattern = re.compile("Image ([0-9]+) loaded")
|
pattern = re.compile("Image ([0-9]+) loaded")
|
||||||
for l in output.split(os.linesep):
|
for l in output.split(os.linesep):
|
||||||
#print("l:", l)
|
self.trace("l:", l)
|
||||||
match = pattern.search(l)
|
match = pattern.search(l)
|
||||||
if match:
|
if match:
|
||||||
break
|
break
|
||||||
|
|
|
@ -1,91 +1,11 @@
|
||||||
"""Check that compiler-generated register values work correctly"""
|
"""Check that compiler-generated register values work correctly"""
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import lldb
|
import lldb
|
||||||
from lldbsuite.test.decorators import *
|
from lldbsuite.test.decorators import *
|
||||||
from lldbsuite.test.lldbtest import *
|
from lldbsuite.test.lldbtest import *
|
||||||
from lldbsuite.test import lldbutil
|
from lldbsuite.test import lldbutil
|
||||||
|
|
||||||
# This method attempts to figure out if a given variable
|
|
||||||
# is in a register.
|
|
||||||
#
|
|
||||||
# Return:
|
|
||||||
# True if the value has a readable value and is in a register
|
|
||||||
# False otherwise
|
|
||||||
|
|
||||||
|
|
||||||
def is_variable_in_register(frame, var_name):
|
|
||||||
# Ensure we can lookup the variable.
|
|
||||||
var = frame.FindVariable(var_name)
|
|
||||||
# print("\nchecking {}...".format(var_name))
|
|
||||||
if var is None or not var.IsValid():
|
|
||||||
# print("{} cannot be found".format(var_name))
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Check that we can get its value. If not, this
|
|
||||||
# may be a variable that is just out of scope at this point.
|
|
||||||
value = var.GetValue()
|
|
||||||
# print("checking value...")
|
|
||||||
if value is None:
|
|
||||||
# print("value is invalid")
|
|
||||||
return False
|
|
||||||
# else:
|
|
||||||
# print("value is {}".format(value))
|
|
||||||
|
|
||||||
# We have a variable and we can get its value. The variable is in
|
|
||||||
# a register if we cannot get an address for it, assuming it is
|
|
||||||
# not a struct pointer. (This is an approximation - compilers can
|
|
||||||
# do other things with spitting up a value into multiple parts of
|
|
||||||
# multiple registers, but what we're verifying here is much more
|
|
||||||
# than it was doing before).
|
|
||||||
var_addr = var.GetAddress()
|
|
||||||
# print("checking address...")
|
|
||||||
if var_addr.IsValid():
|
|
||||||
# We have an address, it must not be in a register.
|
|
||||||
# print("var {} is not in a register: has a valid address {}".format(var_name, var_addr))
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
# We don't have an address but we can read the value.
|
|
||||||
# It is likely stored in a register.
|
|
||||||
# print("var {} is in a register (we don't have an address for it)".format(var_name))
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def is_struct_pointer_in_register(frame, var_name, trace):
|
|
||||||
# Ensure we can lookup the variable.
|
|
||||||
var = frame.FindVariable(var_name)
|
|
||||||
if trace:
|
|
||||||
print("\nchecking {}...".format(var_name))
|
|
||||||
|
|
||||||
if var is None or not var.IsValid():
|
|
||||||
# print("{} cannot be found".format(var_name))
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Check that we can get its value. If not, this
|
|
||||||
# may be a variable that is just out of scope at this point.
|
|
||||||
value = var.GetValue()
|
|
||||||
# print("checking value...")
|
|
||||||
if value is None:
|
|
||||||
if trace:
|
|
||||||
print("value is invalid")
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
if trace:
|
|
||||||
print("value is {}".format(value))
|
|
||||||
|
|
||||||
var_loc = var.GetLocation()
|
|
||||||
if trace:
|
|
||||||
print("checking location: {}".format(var_loc))
|
|
||||||
if var_loc is None or var_loc.startswith("0x"):
|
|
||||||
# The frame var is not in a register but rather a memory location.
|
|
||||||
# print("frame var {} is not in a register".format(var_name))
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
# print("frame var {} is in a register".format(var_name))
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def re_expr_equals(val_type, val):
|
def re_expr_equals(val_type, val):
|
||||||
# Match ({val_type}) ${sum_digits} = {val}
|
# Match ({val_type}) ${sum_digits} = {val}
|
||||||
|
@ -136,12 +56,12 @@ class RegisterVariableTestCase(TestBase):
|
||||||
# Try some variables that should be visible
|
# Try some variables that should be visible
|
||||||
frame = self.dbg.GetSelectedTarget().GetProcess(
|
frame = self.dbg.GetSelectedTarget().GetProcess(
|
||||||
).GetSelectedThread().GetSelectedFrame()
|
).GetSelectedThread().GetSelectedFrame()
|
||||||
if is_variable_in_register(frame, 'a'):
|
if self.is_variable_in_register(frame, 'a'):
|
||||||
register_variables_count += 1
|
register_variables_count += 1
|
||||||
self.expect("expr a", VARIABLES_DISPLAYED_CORRECTLY,
|
self.expect("expr a", VARIABLES_DISPLAYED_CORRECTLY,
|
||||||
patterns=[re_expr_equals('int', 2)])
|
patterns=[re_expr_equals('int', 2)])
|
||||||
|
|
||||||
if is_struct_pointer_in_register(frame, 'b', self.TraceOn()):
|
if self.is_struct_pointer_in_register(frame, 'b', self.TraceOn()):
|
||||||
register_variables_count += 1
|
register_variables_count += 1
|
||||||
self.expect("expr b->m1", VARIABLES_DISPLAYED_CORRECTLY,
|
self.expect("expr b->m1", VARIABLES_DISPLAYED_CORRECTLY,
|
||||||
patterns=[re_expr_equals('int', 3)])
|
patterns=[re_expr_equals('int', 3)])
|
||||||
|
@ -163,12 +83,12 @@ class RegisterVariableTestCase(TestBase):
|
||||||
# Try some variables that should be visible
|
# Try some variables that should be visible
|
||||||
frame = self.dbg.GetSelectedTarget().GetProcess(
|
frame = self.dbg.GetSelectedTarget().GetProcess(
|
||||||
).GetSelectedThread().GetSelectedFrame()
|
).GetSelectedThread().GetSelectedFrame()
|
||||||
if is_struct_pointer_in_register(frame, 'b', self.TraceOn()):
|
if self.is_struct_pointer_in_register(frame, 'b', self.TraceOn()):
|
||||||
register_variables_count += 1
|
register_variables_count += 1
|
||||||
self.expect("expr b->m2", VARIABLES_DISPLAYED_CORRECTLY,
|
self.expect("expr b->m2", VARIABLES_DISPLAYED_CORRECTLY,
|
||||||
patterns=[re_expr_equals('int', 5)])
|
patterns=[re_expr_equals('int', 5)])
|
||||||
|
|
||||||
if is_variable_in_register(frame, 'c'):
|
if self.is_variable_in_register(frame, 'c'):
|
||||||
register_variables_count += 1
|
register_variables_count += 1
|
||||||
self.expect("expr c", VARIABLES_DISPLAYED_CORRECTLY,
|
self.expect("expr c", VARIABLES_DISPLAYED_CORRECTLY,
|
||||||
patterns=[re_expr_equals('int', 5)])
|
patterns=[re_expr_equals('int', 5)])
|
||||||
|
@ -190,7 +110,7 @@ class RegisterVariableTestCase(TestBase):
|
||||||
# Try some variables that should be visible
|
# Try some variables that should be visible
|
||||||
frame = self.dbg.GetSelectedTarget().GetProcess(
|
frame = self.dbg.GetSelectedTarget().GetProcess(
|
||||||
).GetSelectedThread().GetSelectedFrame()
|
).GetSelectedThread().GetSelectedFrame()
|
||||||
if is_variable_in_register(frame, 'f'):
|
if self.is_variable_in_register(frame, 'f'):
|
||||||
register_variables_count += 1
|
register_variables_count += 1
|
||||||
self.expect("expr f", VARIABLES_DISPLAYED_CORRECTLY,
|
self.expect("expr f", VARIABLES_DISPLAYED_CORRECTLY,
|
||||||
patterns=[re_expr_equals('float', '3.1')])
|
patterns=[re_expr_equals('float', '3.1')])
|
||||||
|
@ -199,6 +119,78 @@ class RegisterVariableTestCase(TestBase):
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
register_variables_count > 0,
|
register_variables_count > 0,
|
||||||
"expected to verify at least one variable in a register")
|
"expected to verify at least one variable in a register")
|
||||||
# print("executed {} expressions with values in registers".format(register_variables_count))
|
self.trace("executed {} expressions with values in registers".format(register_variables_count))
|
||||||
|
|
||||||
self.runCmd("kill")
|
self.runCmd("kill")
|
||||||
|
|
||||||
|
|
||||||
|
def is_variable_in_register(self, frame, var_name):
|
||||||
|
# Ensure we can lookup the variable.
|
||||||
|
var = frame.FindVariable(var_name)
|
||||||
|
self.trace("\nchecking {}...".format(var_name))
|
||||||
|
if var is None or not var.IsValid():
|
||||||
|
self.trace("{} cannot be found".format(var_name))
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Check that we can get its value. If not, this
|
||||||
|
# may be a variable that is just out of scope at this point.
|
||||||
|
value = var.GetValue()
|
||||||
|
self.trace("checking value...")
|
||||||
|
if value is None:
|
||||||
|
self.trace("value is invalid")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
self.trace("value is {}".format(value))
|
||||||
|
|
||||||
|
# We have a variable and we can get its value. The variable is in a
|
||||||
|
# register if we cannot get an address for it, assuming it is not a
|
||||||
|
# struct pointer. (This is an approximation - compilers can do other
|
||||||
|
# things with spitting up a value into multiple parts of multiple
|
||||||
|
# registers, but what we're verifying here is much more than it was
|
||||||
|
# doing before).
|
||||||
|
var_addr = var.GetAddress()
|
||||||
|
self.trace("checking address...")
|
||||||
|
if var_addr.IsValid():
|
||||||
|
# We have an address, it must not be in a register.
|
||||||
|
self.trace("var {} is not in a register: has a valid address {}".format(var_name, var_addr))
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
# We don't have an address but we can read the value.
|
||||||
|
# It is likely stored in a register.
|
||||||
|
self.trace("var {} is in a register (we don't have an address for it)".format(var_name))
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def is_struct_pointer_in_register(self, frame, var_name, trace):
|
||||||
|
# Ensure we can lookup the variable.
|
||||||
|
var = frame.FindVariable(var_name)
|
||||||
|
if trace:
|
||||||
|
print("\nchecking {}...".format(var_name))
|
||||||
|
|
||||||
|
if var is None or not var.IsValid():
|
||||||
|
self.trace("{} cannot be found".format(var_name))
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Check that we can get its value. If not, this
|
||||||
|
# may be a variable that is just out of scope at this point.
|
||||||
|
value = var.GetValue()
|
||||||
|
self.trace("checking value...")
|
||||||
|
if value is None:
|
||||||
|
if trace:
|
||||||
|
print("value is invalid")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
if trace:
|
||||||
|
print("value is {}".format(value))
|
||||||
|
|
||||||
|
var_loc = var.GetLocation()
|
||||||
|
if trace:
|
||||||
|
print("checking location: {}".format(var_loc))
|
||||||
|
if var_loc is None or var_loc.startswith("0x"):
|
||||||
|
# The frame var is not in a register but rather a memory location.
|
||||||
|
self.trace("frame var {} is not in a register".format(var_name))
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
self.trace("frame var {} is in a register".format(var_name))
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ class IterateFrameAndDisassembleTestCase(TestBase):
|
||||||
match = frameRE.search(line)
|
match = frameRE.search(line)
|
||||||
if match:
|
if match:
|
||||||
function = match.group(1)
|
function = match.group(1)
|
||||||
#print("line:", line)
|
self.trace("line:", line)
|
||||||
#print("function:", function)
|
self.trace("function:", function)
|
||||||
self.runCmd("disassemble -n '%s'" % function)
|
self.runCmd("disassemble -n '%s'" % function)
|
||||||
|
|
||||||
@add_test_categories(['pyapi'])
|
@add_test_categories(['pyapi'])
|
||||||
|
|
|
@ -125,7 +125,7 @@ class TestObjCIvarsInBlocks(TestBase):
|
||||||
expr, "Successfully got a local variable in a block in a class method.")
|
expr, "Successfully got a local variable in a block in a class method.")
|
||||||
|
|
||||||
ret_value_signed = expr.GetValueAsSigned(error)
|
ret_value_signed = expr.GetValueAsSigned(error)
|
||||||
# print('ret_value_signed = %i' % (ret_value_signed))
|
self.trace('ret_value_signed = %i' % (ret_value_signed))
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
ret_value_signed == 5,
|
ret_value_signed == 5,
|
||||||
"The local variable in the block was what we expected.")
|
"The local variable in the block was what we expected.")
|
||||||
|
|
|
@ -50,19 +50,3 @@ class FoundationSymtabTestCase(TestBase):
|
||||||
module = target.FindModule(filespec)
|
module = target.FindModule(filespec)
|
||||||
self.assertTrue(module, VALID_MODULE)
|
self.assertTrue(module, VALID_MODULE)
|
||||||
|
|
||||||
# Create the set of known symbols. As we iterate through the symbol
|
|
||||||
# table, remove the symbol from the set if it is a known symbol.
|
|
||||||
expected_symbols = set(self.symbols_list)
|
|
||||||
for symbol in module:
|
|
||||||
self.assertTrue(symbol, VALID_SYMBOL)
|
|
||||||
#print("symbol:", symbol)
|
|
||||||
name = symbol.GetName()
|
|
||||||
if name in expected_symbols:
|
|
||||||
#print("Removing %s from known_symbols %s" % (name, expected_symbols))
|
|
||||||
expected_symbols.remove(name)
|
|
||||||
|
|
||||||
# At this point, the known_symbols set should have become an empty set.
|
|
||||||
# If not, raise an error.
|
|
||||||
#print("symbols unaccounted for:", expected_symbols)
|
|
||||||
self.assertTrue(len(expected_symbols) == 0,
|
|
||||||
"All the known symbols are accounted for")
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class BreakpointAPITestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by name 'AFunction'.
|
# Now create a breakpoint on main.c by name 'AFunction'.
|
||||||
breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
|
breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() == 1,
|
breakpoint.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
@ -59,7 +59,7 @@ class BreakpointAPITestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by name 'AFunction'.
|
# Now create a breakpoint on main.c by name 'AFunction'.
|
||||||
breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
|
breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() == 1,
|
breakpoint.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
|
|
@ -135,7 +135,7 @@ class EventAPITestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by name 'c'.
|
# Now create a breakpoint on main.c by name 'c'.
|
||||||
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() == 1,
|
breakpoint.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
@ -171,9 +171,9 @@ class EventAPITestCase(TestBase):
|
||||||
# Let's only try at most 3 times to retrieve any kind of event.
|
# Let's only try at most 3 times to retrieve any kind of event.
|
||||||
while not count > 3:
|
while not count > 3:
|
||||||
if listener.WaitForEvent(5, event):
|
if listener.WaitForEvent(5, event):
|
||||||
#print("Got a valid event:", event)
|
self.trace("Got a valid event:", event)
|
||||||
#print("Event data flavor:", event.GetDataFlavor())
|
self.trace("Event data flavor:", event.GetDataFlavor())
|
||||||
#print("Event type:", lldbutil.state_type_to_str(event.GetType()))
|
self.trace("Event type:", lldbutil.state_type_to_str(event.GetType()))
|
||||||
listener.Clear()
|
listener.Clear()
|
||||||
return
|
return
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
@ -215,7 +215,7 @@ class EventAPITestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by name 'c'.
|
# Now create a breakpoint on main.c by name 'c'.
|
||||||
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() == 1,
|
breakpoint.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
@ -256,7 +256,7 @@ class EventAPITestCase(TestBase):
|
||||||
class MyListeningThread(threading.Thread):
|
class MyListeningThread(threading.Thread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
#print("Running MyListeningThread:", self)
|
self.trace("Running MyListeningThread:", self)
|
||||||
|
|
||||||
# Regular expression pattern for the event description.
|
# Regular expression pattern for the event description.
|
||||||
pattern = re.compile("data = {.*, state = (.*)}$")
|
pattern = re.compile("data = {.*, state = (.*)}$")
|
||||||
|
@ -266,7 +266,7 @@ class EventAPITestCase(TestBase):
|
||||||
while True:
|
while True:
|
||||||
if listener.WaitForEvent(5, event):
|
if listener.WaitForEvent(5, event):
|
||||||
desc = lldbutil.get_description(event)
|
desc = lldbutil.get_description(event)
|
||||||
#print("Event description:", desc)
|
self.trace("Event description:", desc)
|
||||||
match = pattern.search(desc)
|
match = pattern.search(desc)
|
||||||
if not match:
|
if not match:
|
||||||
break
|
break
|
||||||
|
|
|
@ -28,7 +28,7 @@ class FrameAPITestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by name 'c'.
|
# Now create a breakpoint on main.c by name 'c'.
|
||||||
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() == 1,
|
breakpoint.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
@ -131,7 +131,7 @@ class FrameAPITestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by name 'c'.
|
# Now create a breakpoint on main.c by name 'c'.
|
||||||
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() == 1,
|
breakpoint.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
@ -173,7 +173,7 @@ class FrameAPITestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by name 'c'.
|
# Now create a breakpoint on main.c by name 'c'.
|
||||||
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
breakpoint = target.BreakpointCreateByName('c', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() == 1,
|
breakpoint.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
|
|
@ -37,7 +37,7 @@ class InlinedFrameAPITestCase(TestBase):
|
||||||
|
|
||||||
# Now create a breakpoint on main.c by the name of 'inner_inline'.
|
# Now create a breakpoint on main.c by the name of 'inner_inline'.
|
||||||
breakpoint = target.BreakpointCreateByName('inner_inline', 'a.out')
|
breakpoint = target.BreakpointCreateByName('inner_inline', 'a.out')
|
||||||
#print("breakpoint:", breakpoint)
|
self.trace("breakpoint:", breakpoint)
|
||||||
self.assertTrue(breakpoint and
|
self.assertTrue(breakpoint and
|
||||||
breakpoint.GetNumLocations() > 1,
|
breakpoint.GetNumLocations() > 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
|
|
@ -38,8 +38,8 @@ class DisasmAPITestCase(TestBase):
|
||||||
# Now create the two breakpoints inside function 'a'.
|
# Now create the two breakpoints inside function 'a'.
|
||||||
breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
|
breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
|
||||||
breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
|
breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
|
||||||
#print("breakpoint1:", breakpoint1)
|
self.trace("breakpoint1:", breakpoint1)
|
||||||
#print("breakpoint2:", breakpoint2)
|
self.trace("breakpoint2:", breakpoint2)
|
||||||
self.assertTrue(breakpoint1 and
|
self.assertTrue(breakpoint1 and
|
||||||
breakpoint1.GetNumLocations() == 1,
|
breakpoint1.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
@ -64,7 +64,7 @@ class DisasmAPITestCase(TestBase):
|
||||||
self.assertTrue(lineEntry.GetLine() == self.line1)
|
self.assertTrue(lineEntry.GetLine() == self.line1)
|
||||||
|
|
||||||
address1 = lineEntry.GetStartAddress()
|
address1 = lineEntry.GetStartAddress()
|
||||||
#print("address1:", address1)
|
self.trace("address1:", address1)
|
||||||
|
|
||||||
# Now call SBTarget.ResolveSymbolContextForAddress() with address1.
|
# Now call SBTarget.ResolveSymbolContextForAddress() with address1.
|
||||||
context1 = target.ResolveSymbolContextForAddress(
|
context1 = target.ResolveSymbolContextForAddress(
|
||||||
|
@ -103,15 +103,11 @@ class DisasmAPITestCase(TestBase):
|
||||||
print("disassembly=>\n", disasm_output)
|
print("disassembly=>\n", disasm_output)
|
||||||
|
|
||||||
sa1 = symbol.GetStartAddress()
|
sa1 = symbol.GetStartAddress()
|
||||||
#print("sa1:", sa1)
|
self.trace("sa1:", sa1)
|
||||||
#print("sa1.GetFileAddress():", hex(sa1.GetFileAddress()))
|
self.trace("sa1.GetFileAddress():", hex(sa1.GetFileAddress()))
|
||||||
#ea1 = symbol.GetEndAddress()
|
|
||||||
#print("ea1:", ea1)
|
|
||||||
sa2 = function.GetStartAddress()
|
sa2 = function.GetStartAddress()
|
||||||
#print("sa2:", sa2)
|
self.trace("sa2:", sa2)
|
||||||
#print("sa2.GetFileAddress():", hex(sa2.GetFileAddress()))
|
self.trace("sa2.GetFileAddress():", hex(sa2.GetFileAddress()))
|
||||||
#ea2 = function.GetEndAddress()
|
|
||||||
#print("ea2:", ea2)
|
|
||||||
self.assertTrue(sa1 and sa2 and sa1 == sa2,
|
self.assertTrue(sa1 and sa2 and sa1 == sa2,
|
||||||
"The two starting addresses should be the same")
|
"The two starting addresses should be the same")
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@ class SymbolAPITestCase(TestBase):
|
||||||
# Now create the two breakpoints inside function 'a'.
|
# Now create the two breakpoints inside function 'a'.
|
||||||
breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
|
breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
|
||||||
breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
|
breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
|
||||||
#print("breakpoint1:", breakpoint1)
|
self.trace("breakpoint1:", breakpoint1)
|
||||||
#print("breakpoint2:", breakpoint2)
|
self.trace("breakpoint2:", breakpoint2)
|
||||||
self.assertTrue(breakpoint1 and
|
self.assertTrue(breakpoint1 and
|
||||||
breakpoint1.GetNumLocations() == 1,
|
breakpoint1.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
|
|
@ -359,8 +359,8 @@ class TargetAPITestCase(TestBase):
|
||||||
# Now create the two breakpoints inside function 'a'.
|
# Now create the two breakpoints inside function 'a'.
|
||||||
breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
|
breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
|
||||||
breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
|
breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
|
||||||
#print("breakpoint1:", breakpoint1)
|
self.trace("breakpoint1:", breakpoint1)
|
||||||
#print("breakpoint2:", breakpoint2)
|
self.trace("breakpoint2:", breakpoint2)
|
||||||
self.assertTrue(breakpoint1 and
|
self.assertTrue(breakpoint1 and
|
||||||
breakpoint1.GetNumLocations() == 1,
|
breakpoint1.GetNumLocations() == 1,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
|
@ -402,8 +402,8 @@ class TargetAPITestCase(TestBase):
|
||||||
|
|
||||||
address2 = lineEntry.GetStartAddress()
|
address2 = lineEntry.GetStartAddress()
|
||||||
|
|
||||||
#print("address1:", address1)
|
self.trace("address1:", address1)
|
||||||
#print("address2:", address2)
|
self.trace("address2:", address2)
|
||||||
|
|
||||||
# Now call SBTarget.ResolveSymbolContextForAddress() with the addresses
|
# Now call SBTarget.ResolveSymbolContextForAddress() with the addresses
|
||||||
# from our line entry.
|
# from our line entry.
|
||||||
|
@ -413,15 +413,15 @@ class TargetAPITestCase(TestBase):
|
||||||
address2, lldb.eSymbolContextEverything)
|
address2, lldb.eSymbolContextEverything)
|
||||||
|
|
||||||
self.assertTrue(context1 and context2)
|
self.assertTrue(context1 and context2)
|
||||||
#print("context1:", context1)
|
self.trace("context1:", context1)
|
||||||
#print("context2:", context2)
|
self.trace("context2:", context2)
|
||||||
|
|
||||||
# Verify that the context point to the same function 'a'.
|
# Verify that the context point to the same function 'a'.
|
||||||
symbol1 = context1.GetSymbol()
|
symbol1 = context1.GetSymbol()
|
||||||
symbol2 = context2.GetSymbol()
|
symbol2 = context2.GetSymbol()
|
||||||
self.assertTrue(symbol1 and symbol2)
|
self.assertTrue(symbol1 and symbol2)
|
||||||
#print("symbol1:", symbol1)
|
self.trace("symbol1:", symbol1)
|
||||||
#print("symbol2:", symbol2)
|
self.trace("symbol2:", symbol2)
|
||||||
|
|
||||||
from lldbsuite.test.lldbutil import get_description
|
from lldbsuite.test.lldbutil import get_description
|
||||||
desc1 = get_description(symbol1)
|
desc1 = get_description(symbol1)
|
||||||
|
|
|
@ -100,7 +100,7 @@ class ThreadAPITestCase(TestBase):
|
||||||
self.runCmd("process status")
|
self.runCmd("process status")
|
||||||
|
|
||||||
proc_of_thread = thread.GetProcess()
|
proc_of_thread = thread.GetProcess()
|
||||||
#print("proc_of_thread:", proc_of_thread)
|
self.trace("proc_of_thread:", proc_of_thread)
|
||||||
self.assertTrue(proc_of_thread.GetProcessID()
|
self.assertTrue(proc_of_thread.GetProcessID()
|
||||||
== process.GetProcessID())
|
== process.GetProcessID())
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
|
|
||||||
import gdbremote_testcase
|
import gdbremote_testcase
|
||||||
from lldbsuite.test.decorators import *
|
from lldbsuite.test.decorators import *
|
||||||
from lldbsuite.test.lldbtest import *
|
from lldbsuite.test.lldbtest import *
|
||||||
|
@ -119,7 +116,7 @@ class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
|
||||||
# Ensure auxv data is a multiple of 2*word_size (there should be two
|
# Ensure auxv data is a multiple of 2*word_size (there should be two
|
||||||
# unsigned long fields per auxv entry).
|
# unsigned long fields per auxv entry).
|
||||||
self.assertEqual(len(auxv_data) % (2 * word_size), 0)
|
self.assertEqual(len(auxv_data) % (2 * word_size), 0)
|
||||||
# print("auxv contains {} entries".format(len(auxv_data) / (2*word_size)))
|
self.trace("auxv contains {} entries".format(len(auxv_data) / (2*word_size)))
|
||||||
|
|
||||||
@debugserver_test
|
@debugserver_test
|
||||||
def test_auxv_data_is_correct_size_debugserver(self):
|
def test_auxv_data_is_correct_size_debugserver(self):
|
||||||
|
@ -159,7 +156,7 @@ class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
|
||||||
for auxv_key in auxv_dict:
|
for auxv_key in auxv_dict:
|
||||||
self.assertTrue(auxv_key >= 1)
|
self.assertTrue(auxv_key >= 1)
|
||||||
self.assertTrue(auxv_key <= 1000)
|
self.assertTrue(auxv_key <= 1000)
|
||||||
# print("auxv dict: {}".format(auxv_dict))
|
self.trace("auxv dict: {}".format(auxv_dict))
|
||||||
|
|
||||||
@debugserver_test
|
@debugserver_test
|
||||||
def test_auxv_keys_look_valid_debugserver(self):
|
def test_auxv_keys_look_valid_debugserver(self):
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
|
|
||||||
import gdbremote_testcase
|
import gdbremote_testcase
|
||||||
from lldbsuite.test.decorators import *
|
from lldbsuite.test.decorators import *
|
||||||
from lldbsuite.test.lldbtest import *
|
from lldbsuite.test.lldbtest import *
|
||||||
|
@ -59,7 +56,7 @@ class TestGdbRemoteExpeditedRegisters(
|
||||||
|
|
||||||
# Ensure the expedited registers contained it.
|
# Ensure the expedited registers contained it.
|
||||||
self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
|
self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
|
||||||
# print("{} reg_info:{}".format(generic_register_name, reg_info))
|
self.trace("{} reg_info:{}".format(generic_register_name, reg_info))
|
||||||
|
|
||||||
def stop_notification_contains_any_registers(self):
|
def stop_notification_contains_any_registers(self):
|
||||||
# Generate a stop reply, parse out expedited registers from stop
|
# Generate a stop reply, parse out expedited registers from stop
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
|
|
||||||
import gdbremote_testcase
|
import gdbremote_testcase
|
||||||
from lldbsuite.test.decorators import *
|
from lldbsuite.test.decorators import *
|
||||||
from lldbsuite.test.lldbtest import *
|
from lldbsuite.test.lldbtest import *
|
||||||
|
@ -50,7 +47,7 @@ class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
|
||||||
self.assertIsNotNone(threads)
|
self.assertIsNotNone(threads)
|
||||||
thread_id = threads[0]
|
thread_id = threads[0]
|
||||||
self.assertIsNotNone(thread_id)
|
self.assertIsNotNone(thread_id)
|
||||||
# print("Running on thread: 0x{:x}".format(thread_id))
|
self.trace("Running on thread: 0x{:x}".format(thread_id))
|
||||||
else:
|
else:
|
||||||
thread_id = None
|
thread_id = None
|
||||||
|
|
||||||
|
@ -64,22 +61,22 @@ class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
|
||||||
(success, state_id) = self.parse_QSaveRegisterState_response(context)
|
(success, state_id) = self.parse_QSaveRegisterState_response(context)
|
||||||
self.assertTrue(success)
|
self.assertTrue(success)
|
||||||
self.assertIsNotNone(state_id)
|
self.assertIsNotNone(state_id)
|
||||||
# print("saved register state id: {}".format(state_id))
|
self.trace("saved register state id: {}".format(state_id))
|
||||||
|
|
||||||
# Remember initial register values.
|
# Remember initial register values.
|
||||||
initial_reg_values = self.read_register_values(
|
initial_reg_values = self.read_register_values(
|
||||||
gpr_reg_infos, endian, thread_id=thread_id)
|
gpr_reg_infos, endian, thread_id=thread_id)
|
||||||
# print("initial_reg_values: {}".format(initial_reg_values))
|
self.trace("initial_reg_values: {}".format(initial_reg_values))
|
||||||
|
|
||||||
# Flip gpr register values.
|
# Flip gpr register values.
|
||||||
(successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
|
(successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
|
||||||
gpr_reg_infos, endian, thread_id=thread_id)
|
gpr_reg_infos, endian, thread_id=thread_id)
|
||||||
# print("successful writes: {}, failed writes: {}".format(successful_writes, failed_writes))
|
self.trace("successful writes: {}, failed writes: {}".format(successful_writes, failed_writes))
|
||||||
self.assertTrue(successful_writes > 0)
|
self.assertTrue(successful_writes > 0)
|
||||||
|
|
||||||
flipped_reg_values = self.read_register_values(
|
flipped_reg_values = self.read_register_values(
|
||||||
gpr_reg_infos, endian, thread_id=thread_id)
|
gpr_reg_infos, endian, thread_id=thread_id)
|
||||||
# print("flipped_reg_values: {}".format(flipped_reg_values))
|
self.trace("flipped_reg_values: {}".format(flipped_reg_values))
|
||||||
|
|
||||||
# Restore register values.
|
# Restore register values.
|
||||||
self.reset_test_sequence()
|
self.reset_test_sequence()
|
||||||
|
@ -91,7 +88,7 @@ class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
|
||||||
# Verify registers match initial register values.
|
# Verify registers match initial register values.
|
||||||
final_reg_values = self.read_register_values(
|
final_reg_values = self.read_register_values(
|
||||||
gpr_reg_infos, endian, thread_id=thread_id)
|
gpr_reg_infos, endian, thread_id=thread_id)
|
||||||
# print("final_reg_values: {}".format(final_reg_values))
|
self.trace("final_reg_values: {}".format(final_reg_values))
|
||||||
self.assertIsNotNone(final_reg_values)
|
self.assertIsNotNone(final_reg_values)
|
||||||
self.assertEqual(final_reg_values, initial_reg_values)
|
self.assertEqual(final_reg_values, initial_reg_values)
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,6 @@ gdb remote packet functional areas. For now it contains
|
||||||
the initial set of tests implemented.
|
the initial set of tests implemented.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import division, print_function
|
|
||||||
|
|
||||||
|
|
||||||
import unittest2
|
import unittest2
|
||||||
import gdbremote_testcase
|
import gdbremote_testcase
|
||||||
import lldbgdbserverutils
|
import lldbgdbserverutils
|
||||||
|
@ -1442,7 +1439,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
|
||||||
# Write flipped bit pattern of existing value to each register.
|
# Write flipped bit pattern of existing value to each register.
|
||||||
(successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
|
(successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
|
||||||
gpr_reg_infos, endian)
|
gpr_reg_infos, endian)
|
||||||
# print("successful writes: {}, failed writes: {}".format(successful_writes, failed_writes))
|
self.trace("successful writes: {}, failed writes: {}".format(successful_writes, failed_writes))
|
||||||
self.assertTrue(successful_writes > 0)
|
self.assertTrue(successful_writes > 0)
|
||||||
|
|
||||||
# Note: as of this moment, a hefty number of the GPR writes are failing with E32 (everything except rax-rdx, rdi, rsi, rbp).
|
# Note: as of this moment, a hefty number of the GPR writes are failing with E32 (everything except rax-rdx, rdi, rsi, rbp).
|
||||||
|
|
Loading…
Reference in New Issue