[Lldb-commits] [lldb] b321b42 - [lldb/Test] Add a trace method to replace print statements.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon May 25 11:11:53 PDT 2020


Author: Jonas Devlieghere
Date: 2020-05-25T11:11:46-07:00
New Revision: b321b429416ec51691a3c5372cb59912bded5f08

URL: https://github.com/llvm/llvm-project/commit/b321b429416ec51691a3c5372cb59912bded5f08
DIFF: https://github.com/llvm/llvm-project/commit/b321b429416ec51691a3c5372cb59912bded5f08.diff

LOG: [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

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/lldbtest.py
    lldb/test/API/benchmarks/stepping/TestSteppingSpeed.py
    lldb/test/API/commands/target/basic/TestTargetCommand.py
    lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
    lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
    lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
    lldb/test/API/functionalities/load_unload/TestLoadUnload.py
    lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
    lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py
    lldb/test/API/lang/objc/blocks/TestObjCIvarsInBlocks.py
    lldb/test/API/lang/objc/foundation/TestSymbolTable.py
    lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py
    lldb/test/API/python_api/event/TestEvents.py
    lldb/test/API/python_api/frame/TestFrames.py
    lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py
    lldb/test/API/python_api/function_symbol/TestDisasmAPI.py
    lldb/test/API/python_api/function_symbol/TestSymbolAPI.py
    lldb/test/API/python_api/target/TestTargetAPI.py
    lldb/test/API/python_api/thread/TestThreadAPI.py
    lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
    lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
    lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
    lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index b02181ae1ffc..639f99463d92 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -505,6 +505,10 @@ def TraceOn(self):
         """Returns True if we are in trace mode (tracing detailed test execution)."""
         return traceAlways
 
+    def trace(self, *args,**kwargs):
+        with recording(self, self.TraceOn()) as sbuf:
+            print(*args, **kwargs, file=sbuf)
+
     @classmethod
     def setUpClass(cls):
         """

diff  --git a/lldb/test/API/benchmarks/stepping/TestSteppingSpeed.py b/lldb/test/API/benchmarks/stepping/TestSteppingSpeed.py
index e5a8f168b646..60e4a42108ae 100644
--- a/lldb/test/API/benchmarks/stepping/TestSteppingSpeed.py
+++ b/lldb/test/API/benchmarks/stepping/TestSteppingSpeed.py
@@ -22,8 +22,8 @@ def setUp(self):
         self.break_spec = '-n main'
         self.count = 50
 
-        #print("self.exe=%s" % self.exe)
-        #print("self.break_spec=%s" % self.break_spec)
+        self.trace("self.exe=%s" % self.exe)
+        self.trace("self.break_spec=%s" % self.break_spec)
 
     @benchmarks_test
     @no_debug_info_test

diff  --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index 9bc9396e19ed..83e27e272464 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -82,7 +82,7 @@ def do_target_command(self):
                 if match:
                     # We will start from (index + 1) ....
                     base = int(match.group(1), 10) + 1
-                    #print("base is:", base)
+                    self.trace("base is:", base)
                     break
 
         self.runCmd("target create " + exe_a, CURRENT_EXECUTABLE_SET)

diff  --git a/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py b/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
index de9a47d8c202..a5f9458c05a0 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
@@ -126,7 +126,7 @@ def breakpoint_conditions_python(self):
 
         # Now create a breakpoint on main.c by name 'c'.
         breakpoint = target.BreakpointCreateByName('c', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() == 1,
                         VALID_BREAKPOINT)
@@ -194,7 +194,7 @@ def breakpoint_invalid_conditions_python(self):
 
         # Now create a breakpoint on main.c by name 'c'.
         breakpoint = target.BreakpointCreateByName('c', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() == 1,
                         VALID_BREAKPOINT)

diff  --git a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index afeccbef3bae..6a3f40ff3a35 100644
--- a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -118,7 +118,7 @@ def check_equivalence(self, source_bps, do_write = True):
             copy_text = copy_desc.GetData()
 
             # 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))
 
     def do_check_resolvers(self):

diff  --git a/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py b/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
index fa13e922ce4a..f5cf525427c8 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
@@ -147,13 +147,13 @@ def cleanup():
             import re
             gcc_version_output = system(
                 [[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):
                 m = re.search('\(Apple Inc\. build ([0-9]+)\)', line)
-                #print("line:", line)
+                self.trace("line:", line)
                 if m:
                     gcc_build = int(m.group(1))
-                    #print("gcc build:", gcc_build)
+                    self.trace("gcc build:", gcc_build)
                     if gcc_build >= 5666:
                         # rdar://problem/9804600"
                         self.skipTest(

diff  --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index e0013ccd93fa..853c0b2cea20 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -267,7 +267,7 @@ def run_lldb_process_load_and_unload_commands(self):
         output = self.res.GetOutput()
         pattern = re.compile("Image ([0-9]+) loaded")
         for l in output.split(os.linesep):
-            #print("l:", l)
+            self.trace("l:", l)
             match = pattern.search(l)
             if match:
                 break

diff  --git a/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py b/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
index af0ad2a08719..51b728be2fe6 100644
--- a/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
+++ b/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
@@ -1,91 +1,11 @@
 """Check that compiler-generated register values work correctly"""
 
-from __future__ import print_function
-
 import re
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 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):
     # Match ({val_type}) ${sum_digits} = {val}
@@ -136,12 +56,12 @@ def test_and_run_command(self):
         # Try some variables that should be visible
         frame = self.dbg.GetSelectedTarget().GetProcess(
         ).GetSelectedThread().GetSelectedFrame()
-        if is_variable_in_register(frame, 'a'):
+        if self.is_variable_in_register(frame, 'a'):
             register_variables_count += 1
             self.expect("expr a", VARIABLES_DISPLAYED_CORRECTLY,
                         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
             self.expect("expr b->m1", VARIABLES_DISPLAYED_CORRECTLY,
                         patterns=[re_expr_equals('int', 3)])
@@ -163,12 +83,12 @@ def test_and_run_command(self):
         # Try some variables that should be visible
         frame = self.dbg.GetSelectedTarget().GetProcess(
         ).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
             self.expect("expr b->m2", VARIABLES_DISPLAYED_CORRECTLY,
                         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
             self.expect("expr c", VARIABLES_DISPLAYED_CORRECTLY,
                         patterns=[re_expr_equals('int', 5)])
@@ -190,7 +110,7 @@ def test_and_run_command(self):
         # Try some variables that should be visible
         frame = self.dbg.GetSelectedTarget().GetProcess(
         ).GetSelectedThread().GetSelectedFrame()
-        if is_variable_in_register(frame, 'f'):
+        if self.is_variable_in_register(frame, 'f'):
             register_variables_count += 1
             self.expect("expr f", VARIABLES_DISPLAYED_CORRECTLY,
                         patterns=[re_expr_equals('float', '3.1')])
@@ -199,6 +119,78 @@ def test_and_run_command(self):
         self.assertTrue(
             register_variables_count > 0,
             "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")
+
+
+    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
+

diff  --git a/lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py b/lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py
index ad187d0394b6..9f3d6806451e 100644
--- a/lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py
+++ b/lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py
@@ -33,8 +33,8 @@ def test_and_run_command(self):
             match = frameRE.search(line)
             if match:
                 function = match.group(1)
-                #print("line:", line)
-                #print("function:", function)
+                self.trace("line:", line)
+                self.trace("function:", function)
                 self.runCmd("disassemble -n '%s'" % function)
 
     @add_test_categories(['pyapi'])

diff  --git a/lldb/test/API/lang/objc/blocks/TestObjCIvarsInBlocks.py b/lldb/test/API/lang/objc/blocks/TestObjCIvarsInBlocks.py
index e790e6e9d96e..9eb8931fb4a0 100644
--- a/lldb/test/API/lang/objc/blocks/TestObjCIvarsInBlocks.py
+++ b/lldb/test/API/lang/objc/blocks/TestObjCIvarsInBlocks.py
@@ -125,7 +125,7 @@ def test_with_python_api(self):
             expr, "Successfully got a local variable in a block in a class method.")
 
         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(
             ret_value_signed == 5,
             "The local variable in the block was what we expected.")

diff  --git a/lldb/test/API/lang/objc/foundation/TestSymbolTable.py b/lldb/test/API/lang/objc/foundation/TestSymbolTable.py
index abfc7621e2e7..b77a8dfc0ed9 100644
--- a/lldb/test/API/lang/objc/foundation/TestSymbolTable.py
+++ b/lldb/test/API/lang/objc/foundation/TestSymbolTable.py
@@ -50,19 +50,3 @@ def test_with_python_api(self):
         module = target.FindModule(filespec)
         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")

diff  --git a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py
index dd5784696343..1c0c334fbeeb 100644
--- a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py
+++ b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py
@@ -25,7 +25,7 @@ def test_breakpoint_is_valid(self):
 
         # Now create a breakpoint on main.c by name 'AFunction'.
         breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() == 1,
                         VALID_BREAKPOINT)
@@ -59,7 +59,7 @@ def test_target_delete(self):
 
         # Now create a breakpoint on main.c by name 'AFunction'.
         breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() == 1,
                         VALID_BREAKPOINT)

diff  --git a/lldb/test/API/python_api/event/TestEvents.py b/lldb/test/API/python_api/event/TestEvents.py
index 97ebe8ffc03d..62ed195729f0 100644
--- a/lldb/test/API/python_api/event/TestEvents.py
+++ b/lldb/test/API/python_api/event/TestEvents.py
@@ -135,7 +135,7 @@ def test_wait_for_event(self):
 
         # Now create a breakpoint on main.c by name 'c'.
         breakpoint = target.BreakpointCreateByName('c', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() == 1,
                         VALID_BREAKPOINT)
@@ -171,9 +171,9 @@ def run(self):
                 # Let's only try at most 3 times to retrieve any kind of event.
                 while not count > 3:
                     if listener.WaitForEvent(5, event):
-                        #print("Got a valid event:", event)
-                        #print("Event data flavor:", event.GetDataFlavor())
-                        #print("Event type:", lldbutil.state_type_to_str(event.GetType()))
+                        self.trace("Got a valid event:", event)
+                        self.trace("Event data flavor:", event.GetDataFlavor())
+                        self.trace("Event type:", lldbutil.state_type_to_str(event.GetType()))
                         listener.Clear()
                         return
                     count = count + 1
@@ -215,7 +215,7 @@ def test_add_listener_to_broadcaster(self):
 
         # Now create a breakpoint on main.c by name 'c'.
         breakpoint = target.BreakpointCreateByName('c', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() == 1,
                         VALID_BREAKPOINT)
@@ -256,7 +256,7 @@ def test_add_listener_to_broadcaster(self):
         class MyListeningThread(threading.Thread):
 
             def run(self):
-                #print("Running MyListeningThread:", self)
+                self.trace("Running MyListeningThread:", self)
 
                 # Regular expression pattern for the event description.
                 pattern = re.compile("data = {.*, state = (.*)}$")
@@ -266,7 +266,7 @@ def run(self):
                 while True:
                     if listener.WaitForEvent(5, event):
                         desc = lldbutil.get_description(event)
-                        #print("Event description:", desc)
+                        self.trace("Event description:", desc)
                         match = pattern.search(desc)
                         if not match:
                             break

diff  --git a/lldb/test/API/python_api/frame/TestFrames.py b/lldb/test/API/python_api/frame/TestFrames.py
index 6d4b7b51f426..1ec66a3ddbeb 100644
--- a/lldb/test/API/python_api/frame/TestFrames.py
+++ b/lldb/test/API/python_api/frame/TestFrames.py
@@ -28,7 +28,7 @@ def test_get_arg_vals_for_call_stack(self):
 
         # Now create a breakpoint on main.c by name 'c'.
         breakpoint = target.BreakpointCreateByName('c', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() == 1,
                         VALID_BREAKPOINT)
@@ -131,7 +131,7 @@ def test_frame_api_boundary_condition(self):
 
         # Now create a breakpoint on main.c by name 'c'.
         breakpoint = target.BreakpointCreateByName('c', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() == 1,
                         VALID_BREAKPOINT)
@@ -173,7 +173,7 @@ def test_frame_api_IsEqual(self):
 
         # Now create a breakpoint on main.c by name 'c'.
         breakpoint = target.BreakpointCreateByName('c', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() == 1,
                         VALID_BREAKPOINT)

diff  --git a/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py b/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py
index da4e9cb06e7b..eb40b4c4993e 100644
--- a/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py
+++ b/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py
@@ -37,7 +37,7 @@ def test_stop_at_outer_inline(self):
 
         # Now create a breakpoint on main.c by the name of 'inner_inline'.
         breakpoint = target.BreakpointCreateByName('inner_inline', 'a.out')
-        #print("breakpoint:", breakpoint)
+        self.trace("breakpoint:", breakpoint)
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() > 1,
                         VALID_BREAKPOINT)

diff  --git a/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py b/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py
index 2278d69fbbe3..01d26da060d2 100644
--- a/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py
+++ b/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py
@@ -38,8 +38,8 @@ def test(self):
         # Now create the two breakpoints inside function 'a'.
         breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
         breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
-        #print("breakpoint1:", breakpoint1)
-        #print("breakpoint2:", breakpoint2)
+        self.trace("breakpoint1:", breakpoint1)
+        self.trace("breakpoint2:", breakpoint2)
         self.assertTrue(breakpoint1 and
                         breakpoint1.GetNumLocations() == 1,
                         VALID_BREAKPOINT)
@@ -64,7 +64,7 @@ def test(self):
         self.assertTrue(lineEntry.GetLine() == self.line1)
 
         address1 = lineEntry.GetStartAddress()
-        #print("address1:", address1)
+        self.trace("address1:", address1)
 
         # Now call SBTarget.ResolveSymbolContextForAddress() with address1.
         context1 = target.ResolveSymbolContextForAddress(
@@ -103,15 +103,11 @@ def test(self):
             print("disassembly=>\n", disasm_output)
 
         sa1 = symbol.GetStartAddress()
-        #print("sa1:", sa1)
-        #print("sa1.GetFileAddress():", hex(sa1.GetFileAddress()))
-        #ea1 = symbol.GetEndAddress()
-        #print("ea1:", ea1)
+        self.trace("sa1:", sa1)
+        self.trace("sa1.GetFileAddress():", hex(sa1.GetFileAddress()))
         sa2 = function.GetStartAddress()
-        #print("sa2:", sa2)
-        #print("sa2.GetFileAddress():", hex(sa2.GetFileAddress()))
-        #ea2 = function.GetEndAddress()
-        #print("ea2:", ea2)
+        self.trace("sa2:", sa2)
+        self.trace("sa2.GetFileAddress():", hex(sa2.GetFileAddress()))
         self.assertTrue(sa1 and sa2 and sa1 == sa2,
                         "The two starting addresses should be the same")
 

diff  --git a/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py b/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py
index 56fa73c84ad6..c5bcb152beb0 100644
--- a/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py
+++ b/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py
@@ -38,8 +38,8 @@ def test(self):
         # Now create the two breakpoints inside function 'a'.
         breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
         breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
-        #print("breakpoint1:", breakpoint1)
-        #print("breakpoint2:", breakpoint2)
+        self.trace("breakpoint1:", breakpoint1)
+        self.trace("breakpoint2:", breakpoint2)
         self.assertTrue(breakpoint1 and
                         breakpoint1.GetNumLocations() == 1,
                         VALID_BREAKPOINT)

diff  --git a/lldb/test/API/python_api/target/TestTargetAPI.py b/lldb/test/API/python_api/target/TestTargetAPI.py
index c5b960528d4b..016754720c8c 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -359,8 +359,8 @@ def resolve_symbol_context_with_address(self):
         # Now create the two breakpoints inside function 'a'.
         breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
         breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
-        #print("breakpoint1:", breakpoint1)
-        #print("breakpoint2:", breakpoint2)
+        self.trace("breakpoint1:", breakpoint1)
+        self.trace("breakpoint2:", breakpoint2)
         self.assertTrue(breakpoint1 and
                         breakpoint1.GetNumLocations() == 1,
                         VALID_BREAKPOINT)
@@ -402,8 +402,8 @@ def resolve_symbol_context_with_address(self):
 
         address2 = lineEntry.GetStartAddress()
 
-        #print("address1:", address1)
-        #print("address2:", address2)
+        self.trace("address1:", address1)
+        self.trace("address2:", address2)
 
         # Now call SBTarget.ResolveSymbolContextForAddress() with the addresses
         # from our line entry.
@@ -413,15 +413,15 @@ def resolve_symbol_context_with_address(self):
             address2, lldb.eSymbolContextEverything)
 
         self.assertTrue(context1 and context2)
-        #print("context1:", context1)
-        #print("context2:", context2)
+        self.trace("context1:", context1)
+        self.trace("context2:", context2)
 
         # Verify that the context point to the same function 'a'.
         symbol1 = context1.GetSymbol()
         symbol2 = context2.GetSymbol()
         self.assertTrue(symbol1 and symbol2)
-        #print("symbol1:", symbol1)
-        #print("symbol2:", symbol2)
+        self.trace("symbol1:", symbol1)
+        self.trace("symbol2:", symbol2)
 
         from lldbsuite.test.lldbutil import get_description
         desc1 = get_description(symbol1)

diff  --git a/lldb/test/API/python_api/thread/TestThreadAPI.py b/lldb/test/API/python_api/thread/TestThreadAPI.py
index 144f062846ae..2101527dee6b 100644
--- a/lldb/test/API/python_api/thread/TestThreadAPI.py
+++ b/lldb/test/API/python_api/thread/TestThreadAPI.py
@@ -100,7 +100,7 @@ def get_process(self):
         self.runCmd("process status")
 
         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()
                         == process.GetProcessID())
 

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
index 1a3a2b293650..b89448fd5ba6 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
@@ -1,6 +1,3 @@
-from __future__ import print_function
-
-
 import gdbremote_testcase
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -119,7 +116,7 @@ def auxv_data_is_correct_size(self):
         # Ensure auxv data is a multiple of 2*word_size (there should be two
         # unsigned long fields per auxv entry).
         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
     def test_auxv_data_is_correct_size_debugserver(self):
@@ -159,7 +156,7 @@ def auxv_keys_look_valid(self):
         for auxv_key in auxv_dict:
             self.assertTrue(auxv_key >= 1)
             self.assertTrue(auxv_key <= 1000)
-        # print("auxv dict: {}".format(auxv_dict))
+        self.trace("auxv dict: {}".format(auxv_dict))
 
     @debugserver_test
     def test_auxv_keys_look_valid_debugserver(self):

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
index 7d8e28c745c9..f74143a3ccee 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
@@ -1,6 +1,3 @@
-from __future__ import print_function
-
-
 import gdbremote_testcase
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -59,7 +56,7 @@ def stop_notification_contains_generic_register(
 
         # Ensure the expedited registers contained it.
         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):
         # Generate a stop reply, parse out expedited registers from stop

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
index 2543ed6e9029..e20948ba38af 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
@@ -1,6 +1,3 @@
-from __future__ import print_function
-
-
 import gdbremote_testcase
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -50,7 +47,7 @@ def grp_register_save_restore_works(self, with_suffix):
             self.assertIsNotNone(threads)
             thread_id = threads[0]
             self.assertIsNotNone(thread_id)
-            # print("Running on thread: 0x{:x}".format(thread_id))
+            self.trace("Running on thread: 0x{:x}".format(thread_id))
         else:
             thread_id = None
 
@@ -64,22 +61,22 @@ def grp_register_save_restore_works(self, with_suffix):
         (success, state_id) = self.parse_QSaveRegisterState_response(context)
         self.assertTrue(success)
         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.
         initial_reg_values = self.read_register_values(
             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.
         (successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
             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)
 
         flipped_reg_values = self.read_register_values(
             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.
         self.reset_test_sequence()
@@ -91,7 +88,7 @@ def grp_register_save_restore_works(self, with_suffix):
         # Verify registers match initial register values.
         final_reg_values = self.read_register_values(
             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.assertEqual(final_reg_values, initial_reg_values)
 

diff  --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index 2b7f28a3aefb..d46123e337c8 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -10,9 +10,6 @@
 the initial set of tests implemented.
 """
 
-from __future__ import division, print_function
-
-
 import unittest2
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -1442,7 +1439,7 @@ def P_writes_all_gpr_registers(self):
         # Write flipped bit pattern of existing value to each register.
         (successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
             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)
 
     # Note: as of this moment, a hefty number of the GPR writes are failing with E32 (everything except rax-rdx, rdi, rsi, rbp).


        


More information about the lldb-commits mailing list