diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/data-formatter')
76 files changed, 4061 insertions, 2859 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py index 54272e59333..0459058f3ae 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class DataFormatterBoolRefPtr(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,14 +34,15 @@ class DataFormatterBoolRefPtr(TestBase): """Test the formatters we use for BOOL& and BOOL* in Objective-C.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -56,23 +58,24 @@ class DataFormatterBoolRefPtr(TestBase): # Now check that we use the right summary for BOOL& self.expect('frame variable yes_ref', - substrs = ['YES']) + substrs=['YES']) self.expect('frame variable no_ref', - substrs = ['NO']) - if not(isiOS): self.expect('frame variable unset_ref', substrs = ['12']) - + substrs=['NO']) + if not(isiOS): + self.expect('frame variable unset_ref', substrs=['12']) # Now check that we use the right summary for BOOL* self.expect('frame variable yes_ptr', - substrs = ['YES']) + substrs=['YES']) self.expect('frame variable no_ptr', - substrs = ['NO']) - if not(isiOS): self.expect('frame variable unset_ptr', substrs = ['12']) - + substrs=['NO']) + if not(isiOS): + self.expect('frame variable unset_ptr', substrs=['12']) # Now check that we use the right summary for BOOL self.expect('frame variable yes', - substrs = ['YES']) + substrs=['YES']) self.expect('frame variable no', - substrs = ['NO']) - if not(isiOS): self.expect('frame variable unset', substrs = ['12']) + substrs=['NO']) + if not(isiOS): + self.expect('frame variable unset', substrs=['12']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py index 914c5260ac2..9b430c726e1 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class CompactVectorsFormattingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -28,14 +29,15 @@ class CompactVectorsFormattingTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,15 +47,17 @@ class CompactVectorsFormattingTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('frame variable', - substrs = ['(vFloat) valueFL = (1.25, 0, 0.25, 0)', - '(int16_t [8]) valueI16 = (1, 0, 4, 0, 0, 1, 0, 4)', - '(int32_t [4]) valueI32 = (1, 0, 4, 0)', - '(vDouble) valueDL = (1.25, 2.25)', - '(vUInt8) valueU8 = (0x01, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)', - '(vUInt16) valueU16 = (1, 0, 4, 0, 0, 1, 0, 4)', - '(vUInt32) valueU32 = (1, 2, 3, 4)', - "(vSInt8) valueS8 = (1, 0, 4, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0)", - '(vSInt16) valueS16 = (1, 0, 4, 0, 0, 1, 0, 4)', - '(vSInt32) valueS32 = (4, 3, 2, 1)', - '(vBool32) valueBool32 = (0, 1, 0, 1)']) + self.expect( + 'frame variable', + substrs=[ + '(vFloat) valueFL = (1.25, 0, 0.25, 0)', + '(int16_t [8]) valueI16 = (1, 0, 4, 0, 0, 1, 0, 4)', + '(int32_t [4]) valueI32 = (1, 0, 4, 0)', + '(vDouble) valueDL = (1.25, 2.25)', + '(vUInt8) valueU8 = (0x01, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)', + '(vUInt16) valueU16 = (1, 0, 4, 0, 0, 1, 0, 4)', + '(vUInt32) valueU32 = (1, 2, 3, 4)', + "(vSInt8) valueS8 = (1, 0, 4, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0)", + '(vSInt16) valueS16 = (1, 0, 4, 0, 0, 1, 0, 4)', + '(vSInt32) valueS32 = (4, 3, 2, 1)', + '(vBool32) valueBool32 = (0, 1, 0, 1)']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index 8166d1540ca..050f5236445 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class AdvDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,103 +27,116 @@ class AdvDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): self.runCmd('type format clear', check=False) self.runCmd('type summary clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) - + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) self.runCmd("type summary add --summary-string \"pippo\" \"i_am_cool\"") - self.runCmd("type summary add --summary-string \"pluto\" -x \"i_am_cool[a-z]*\"") + self.runCmd( + "type summary add --summary-string \"pluto\" -x \"i_am_cool[a-z]*\"") self.expect("frame variable cool_boy", - substrs = ['pippo']) + substrs=['pippo']) self.expect("frame variable cooler_boy", - substrs = ['pluto']) + substrs=['pluto']) self.runCmd("type summary delete i_am_cool") - + self.expect("frame variable cool_boy", - substrs = ['pluto']) + substrs=['pluto']) self.runCmd("type summary clear") - - self.runCmd("type summary add --summary-string \"${var[]}\" -x \"int \\[[0-9]\\]") + + self.runCmd( + "type summary add --summary-string \"${var[]}\" -x \"int \\[[0-9]\\]") self.expect("frame variable int_array", - substrs = ['1,2,3,4,5']) + substrs=['1,2,3,4,5']) # this will fail if we don't do [] as regex correctly - self.runCmd('type summary add --summary-string "${var[].integer}" "i_am_cool[]') - + self.runCmd( + 'type summary add --summary-string "${var[].integer}" "i_am_cool[]') + self.expect("frame variable cool_array", - substrs = ['1,1,1,1,6']) + substrs=['1,1,1,1,6']) self.runCmd("type summary clear") - - self.runCmd("type summary add --summary-string \"${var[1-0]%x}\" \"int\"") - + + self.runCmd( + "type summary add --summary-string \"${var[1-0]%x}\" \"int\"") + self.expect("frame variable iAmInt", - substrs = ['01']) - - self.runCmd("type summary add --summary-string \"${var[0-1]%x}\" \"int\"") - + substrs=['01']) + + self.runCmd( + "type summary add --summary-string \"${var[0-1]%x}\" \"int\"") + self.expect("frame variable iAmInt", - substrs = ['01']) + substrs=['01']) self.runCmd("type summary clear") self.runCmd("type summary add --summary-string \"${var[0-1]%x}\" int") - self.runCmd("type summary add --summary-string \"${var[0-31]%x}\" float") - + self.runCmd( + "type summary add --summary-string \"${var[0-31]%x}\" float") + self.expect("frame variable *pointer", - substrs = ['0x', - '2']) + substrs=['0x', + '2']) - # check fix for <rdar://problem/11338654> LLDB crashes when using a "type summary" that uses bitfields with no format + # check fix for <rdar://problem/11338654> LLDB crashes when using a + # "type summary" that uses bitfields with no format self.runCmd("type summary add --summary-string \"${var[0-1]}\" int") self.expect("frame variable iAmInt", - substrs = ['9 1']) + substrs=['9 1']) self.expect("frame variable cool_array[3].floating", - substrs = ['0x']) - - self.runCmd("type summary add --summary-string \"low bits are ${*var[0-1]} tgt is ${*var}\" \"int *\"") + substrs=['0x']) + + self.runCmd( + "type summary add --summary-string \"low bits are ${*var[0-1]} tgt is ${*var}\" \"int *\"") self.expect("frame variable pointer", - substrs = ['low bits are', - 'tgt is 6']) + substrs=['low bits are', + 'tgt is 6']) - self.expect("frame variable int_array --summary-string \"${*var[0-1]}\"", - substrs = ['3']) + self.expect( + "frame variable int_array --summary-string \"${*var[0-1]}\"", + substrs=['3']) self.runCmd("type summary clear") - - self.runCmd('type summary add --summary-string \"${var[0-1]}\" -x \"int \[[0-9]\]\"') + + self.runCmd( + 'type summary add --summary-string \"${var[0-1]}\" -x \"int \[[0-9]\]\"') self.expect("frame variable int_array", - substrs = ['1,2']) + substrs=['1,2']) - self.runCmd('type summary add --summary-string \"${var[0-1]}\" "int []"') + self.runCmd( + 'type summary add --summary-string \"${var[0-1]}\" "int []"') self.expect("frame variable int_array", - substrs = ['1,2']) + substrs=['1,2']) self.runCmd("type summary clear") @@ -130,156 +144,179 @@ class AdvDataFormatterTestCase(TestBase): self.runCmd("type summary add -c i_am_cool") self.expect("frame variable cool_array", - substrs = ['[0]', - '[1]', - '[2]', - '[3]', - '[4]', - 'integer', - 'character', - 'floating']) - - self.runCmd("type summary add --summary-string \"int = ${*var.int_pointer}, float = ${*var.float_pointer}\" IWrapPointers") + substrs=['[0]', + '[1]', + '[2]', + '[3]', + '[4]', + 'integer', + 'character', + 'floating']) + + self.runCmd( + "type summary add --summary-string \"int = ${*var.int_pointer}, float = ${*var.float_pointer}\" IWrapPointers") self.expect("frame variable wrapper", - substrs = ['int = 4', - 'float = 1.1']) + substrs=['int = 4', + 'float = 1.1']) + + self.runCmd( + "type summary add --summary-string \"low bits = ${*var.int_pointer[2]}\" IWrapPointers -p") - self.runCmd("type summary add --summary-string \"low bits = ${*var.int_pointer[2]}\" IWrapPointers -p") - self.expect("frame variable wrapper", - substrs = ['low bits = 1']) - + substrs=['low bits = 1']) + self.expect("frame variable *wrap_pointer", - substrs = ['low bits = 1']) + substrs=['low bits = 1']) self.runCmd("type summary clear") - self.expect("frame variable int_array --summary-string \"${var[0][0-2]%hex}\"", - substrs = ['0x', - '7']) + self.expect( + "frame variable int_array --summary-string \"${var[0][0-2]%hex}\"", + substrs=[ + '0x', + '7']) self.runCmd("type summary clear") - self.runCmd("type summary add --summary-string \"${*var[].x[0-3]%hex} is a bitfield on a set of integers\" -x \"SimpleWithPointers \[[0-9]\]\"") + self.runCmd( + "type summary add --summary-string \"${*var[].x[0-3]%hex} is a bitfield on a set of integers\" -x \"SimpleWithPointers \[[0-9]\]\"") - self.expect("frame variable couple --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\"", - substrs = ['1 are low bits of integer 9.', - 'If I pretend it is an array I get [9,']) + self.expect( + "frame variable couple --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\"", + substrs=[ + '1 are low bits of integer 9.', + 'If I pretend it is an array I get [9,']) # if the summary has an error, we still display the value - self.expect("frame variable couple --summary-string \"${*var.sp.foo[0-2]\"", - substrs = ['(Couple) couple = {','x = 0x','y = 0x','z = 0x','s = 0x']) - - - self.runCmd("type summary add --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\" Couple") + self.expect( + "frame variable couple --summary-string \"${*var.sp.foo[0-2]\"", + substrs=[ + '(Couple) couple = {', + 'x = 0x', + 'y = 0x', + 'z = 0x', + 's = 0x']) + + self.runCmd( + "type summary add --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\" Couple") self.expect("frame variable sparray", - substrs = ['[0x0000000f,0x0000000c,0x00000009]']) - - # check that we can format a variable in a summary even if a format is defined for its datatype + substrs=['[0x0000000f,0x0000000c,0x00000009]']) + + # check that we can format a variable in a summary even if a format is + # defined for its datatype self.runCmd("type format add -f hex int") - self.runCmd("type summary add --summary-string \"x=${var.x%d}\" Simple") + self.runCmd( + "type summary add --summary-string \"x=${var.x%d}\" Simple") self.expect("frame variable a_simple_object", - substrs = ['x=3']) + substrs=['x=3']) self.expect("frame variable a_simple_object", matching=False, - substrs = ['0x0']) + substrs=['0x0']) # now check that the default is applied if we do not hand out a format self.runCmd("type summary add --summary-string \"x=${var.x}\" Simple") self.expect("frame variable a_simple_object", matching=False, - substrs = ['x=3']) + substrs=['x=3']) self.expect("frame variable a_simple_object", matching=True, - substrs = ['x=0x00000003']) + substrs=['x=0x00000003']) # check that we can correctly cap the number of children shown self.runCmd("settings set target.max-children-count 5") self.expect('frame variable a_long_guy', matching=True, - substrs = ['a_1', - 'b_1', - 'c_1', - 'd_1', - 'e_1', - '...']) + substrs=['a_1', + 'b_1', + 'c_1', + 'd_1', + 'e_1', + '...']) # check that no further stuff is printed (not ALL values are checked!) self.expect('frame variable a_long_guy', matching=False, - substrs = ['f_1', - 'g_1', - 'h_1', - 'i_1', - 'j_1', - 'q_1', - 'a_2', - 'f_2', - 't_2', - 'w_2']) + substrs=['f_1', + 'g_1', + 'h_1', + 'i_1', + 'j_1', + 'q_1', + 'a_2', + 'f_2', + 't_2', + 'w_2']) self.runCmd("settings set target.max-children-count 1") self.expect('frame variable a_long_guy', matching=True, - substrs = ['a_1', - '...']) + substrs=['a_1', + '...']) self.expect('frame variable a_long_guy', matching=False, - substrs = ['b_1', - 'c_1', - 'd_1', - 'e_1']) + substrs=['b_1', + 'c_1', + 'd_1', + 'e_1']) self.expect('frame variable a_long_guy', matching=False, - substrs = ['f_1', - 'g_1', - 'h_1', - 'i_1', - 'j_1', - 'q_1', - 'a_2', - 'f_2', - 't_2', - 'w_2']) + substrs=['f_1', + 'g_1', + 'h_1', + 'i_1', + 'j_1', + 'q_1', + 'a_2', + 'f_2', + 't_2', + 'w_2']) self.runCmd("settings set target.max-children-count 30") self.expect('frame variable a_long_guy', matching=True, - substrs = ['a_1', - 'b_1', - 'c_1', - 'd_1', - 'e_1', - 'z_1', - 'a_2', - 'b_2', - 'c_2', - 'd_2', - '...']) + substrs=['a_1', + 'b_1', + 'c_1', + 'd_1', + 'e_1', + 'z_1', + 'a_2', + 'b_2', + 'c_2', + 'd_2', + '...']) self.expect('frame variable a_long_guy', matching=False, - substrs = ['e_2', - 'n_2', - 'r_2', - 'i_2', - 'k_2', - 'o_2']) - - # override the cap - self.expect('frame variable a_long_guy --show-all-children', matching=True, - substrs = ['a_1', - 'b_1', - 'c_1', - 'd_1', - 'e_1', - 'z_1', - 'a_2', - 'b_2', - 'c_2', - 'd_2']) - self.expect('frame variable a_long_guy --show-all-children', matching=True, - substrs = ['e_2', - 'n_2', - 'r_2', - 'i_2', - 'k_2', - 'o_2']) - self.expect('frame variable a_long_guy --show-all-children', matching=False, - substrs = ['...']) + substrs=['e_2', + 'n_2', + 'r_2', + 'i_2', + 'k_2', + 'o_2']) + + # override the cap + self.expect( + 'frame variable a_long_guy --show-all-children', + matching=True, + substrs=[ + 'a_1', + 'b_1', + 'c_1', + 'd_1', + 'e_1', + 'z_1', + 'a_2', + 'b_2', + 'c_2', + 'd_2']) + self.expect( + 'frame variable a_long_guy --show-all-children', + matching=True, + substrs=[ + 'e_2', + 'n_2', + 'r_2', + 'i_2', + 'k_2', + 'o_2']) + self.expect( + 'frame variable a_long_guy --show-all-children', + matching=False, + substrs=['...']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py index f8209f03d0c..2d01eb79e18 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class CategoriesDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,14 +28,15 @@ class CategoriesDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case (most of these categories do not @@ -46,286 +48,312 @@ class CategoriesDataFormatterTestCase(TestBase): self.runCmd('type category delete Category2', check=False) self.runCmd('type category delete NewCategory', check=False) self.runCmd("type category delete CircleCategory", check=False) - self.runCmd("type category delete RectangleStarCategory", check=False) + self.runCmd( + "type category delete RectangleStarCategory", + check=False) self.runCmd("type category delete BaseCategory", check=False) - # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # Add a summary to a new category and check that it works - self.runCmd("type summary add Rectangle --summary-string \"ARectangle\" -w NewCategory") + self.runCmd( + "type summary add Rectangle --summary-string \"ARectangle\" -w NewCategory") self.expect("frame variable r1 r2 r3", matching=False, - substrs = ['r1 = ARectangle', - 'r2 = ARectangle', - 'r3 = ARectangle']) - + substrs=['r1 = ARectangle', + 'r2 = ARectangle', + 'r3 = ARectangle']) + self.runCmd("type category enable NewCategory") self.expect("frame variable r1 r2 r3", matching=True, - substrs = ['r1 = ARectangle', - 'r2 = ARectangle', - 'r3 = ARectangle']) - + substrs=['r1 = ARectangle', + 'r2 = ARectangle', + 'r3 = ARectangle']) + # Disable the category and check that the old stuff is there self.runCmd("type category disable NewCategory") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = {', - 'r2 = {', - 'r3 = {']) + substrs=['r1 = {', + 'r2 = {', + 'r3 = {']) # Re-enable the category and check that it works self.runCmd("type category enable NewCategory") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = ARectangle', - 'r2 = ARectangle', - 'r3 = ARectangle']) + substrs=['r1 = ARectangle', + 'r2 = ARectangle', + 'r3 = ARectangle']) # Delete the category and the old stuff should be there self.runCmd("type category delete NewCategory") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = {', - 'r2 = {', - 'r3 = {']) - - # Add summaries to two different categories and check that we can switch - self.runCmd("type summary add --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1") + substrs=['r1 = {', + 'r2 = {', + 'r3 = {']) + + # Add summaries to two different categories and check that we can + # switch + self.runCmd( + "type summary add --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1") self.runCmd("type summary add --python-script \"return 'Area = ' + str( int(valobj.GetChildMemberWithName('w').GetValue()) * int(valobj.GetChildMemberWithName('h').GetValue()) );\" Rectangle -w Category2") # check that enable A B is the same as enable B enable A self.runCmd("type category enable Category1 Category2") - + self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) self.runCmd("type category disable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Area = ', - 'r2 = Area = ', - 'r3 = Area = ']) + substrs=['r1 = Area = ', + 'r2 = Area = ', + 'r3 = Area = ']) # switch again self.runCmd("type category enable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) # Re-enable the category and show that the preference is persisted self.runCmd("type category disable Category2") self.runCmd("type category enable Category2") - + self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Area = ', - 'r2 = Area = ', - 'r3 = Area = ']) + substrs=['r1 = Area = ', + 'r2 = Area = ', + 'r3 = Area = ']) # Now delete the favorite summary self.runCmd("type summary delete Rectangle -w Category2") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) # Delete the summary from the default category (that does not have it) self.runCmd("type summary delete Rectangle", check=False) self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) # Now add another summary to another category and switch back and forth self.runCmd("type category delete Category1 Category2") - self.runCmd("type summary add Rectangle -w Category1 --summary-string \"Category1\"") - self.runCmd("type summary add Rectangle -w Category2 --summary-string \"Category2\"") + self.runCmd( + "type summary add Rectangle -w Category1 --summary-string \"Category1\"") + self.runCmd( + "type summary add Rectangle -w Category2 --summary-string \"Category2\"") self.runCmd("type category enable Category2") self.runCmd("type category enable Category1") - + self.runCmd("type summary list -w Category1") - self.expect("type summary list -w NoSuchCategoryHere", substrs=['no matching results found']) - + self.expect("type summary list -w NoSuchCategoryHere", + substrs=['no matching results found']) + self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Category1', - 'r2 = Category1', - 'r3 = Category1']) + substrs=['r1 = Category1', + 'r2 = Category1', + 'r3 = Category1']) self.runCmd("type category disable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Category2', - 'r2 = Category2', - 'r3 = Category2']) + substrs=['r1 = Category2', + 'r2 = Category2', + 'r3 = Category2']) # Check that re-enabling an enabled category works self.runCmd("type category enable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Category1', - 'r2 = Category1', - 'r3 = Category1']) + substrs=['r1 = Category1', + 'r2 = Category1', + 'r3 = Category1']) self.runCmd("type category delete Category1") self.runCmd("type category delete Category2") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = {', - 'r2 = {', - 'r3 = {']) - - # Check that multiple summaries can go into one category - self.runCmd("type summary add -w Category1 --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle") - self.runCmd("type summary add -w Category1 --summary-string \"Radius = ${var.r}\" Circle") - + substrs=['r1 = {', + 'r2 = {', + 'r3 = {']) + + # Check that multiple summaries can go into one category + self.runCmd( + "type summary add -w Category1 --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle") + self.runCmd( + "type summary add -w Category1 --summary-string \"Radius = ${var.r}\" Circle") + self.runCmd("type category enable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) self.expect("frame variable c1 c2 c3", - substrs = ['c1 = Radius = ', - 'c2 = Radius = ', - 'c3 = Radius = ']) + substrs=['c1 = Radius = ', + 'c2 = Radius = ', + 'c3 = Radius = ']) self.runCmd("type summary delete Circle -w Category1") - + self.expect("frame variable c1 c2 c3", - substrs = ['c1 = {', - 'c2 = {', - 'c3 = {']) + substrs=['c1 = {', + 'c2 = {', + 'c3 = {']) # Add a regex based summary to a category - self.runCmd("type summary add -w Category1 --summary-string \"Radius = ${var.r}\" -x Circle") + self.runCmd( + "type summary add -w Category1 --summary-string \"Radius = ${var.r}\" -x Circle") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) self.expect("frame variable c1 c2 c3", - substrs = ['c1 = Radius = ', - 'c2 = Radius = ', - 'c3 = Radius = ']) + substrs=['c1 = Radius = ', + 'c2 = Radius = ', + 'c3 = Radius = ']) # Delete it self.runCmd("type summary delete Circle -w Category1") self.expect("frame variable c1 c2 c3", - substrs = ['c1 = {', - 'c2 = {', - 'c3 = {']) - - # Change a summary inside a category and check that the change is reflected - self.runCmd("type summary add Circle -w Category1 --summary-string \"summary1\"") + substrs=['c1 = {', + 'c2 = {', + 'c3 = {']) + + # Change a summary inside a category and check that the change is + # reflected + self.runCmd( + "type summary add Circle -w Category1 --summary-string \"summary1\"") self.expect("frame variable c1 c2 c3", - substrs = ['c1 = summary1', - 'c2 = summary1', - 'c3 = summary1']) + substrs=['c1 = summary1', + 'c2 = summary1', + 'c3 = summary1']) + + self.runCmd( + "type summary add Circle -w Category1 --summary-string \"summary2\"") - self.runCmd("type summary add Circle -w Category1 --summary-string \"summary2\"") - self.expect("frame variable c1 c2 c3", - substrs = ['c1 = summary2', - 'c2 = summary2', - 'c3 = summary2']) + substrs=['c1 = summary2', + 'c2 = summary2', + 'c3 = summary2']) # Check that our order of priority works. Start by clearing categories self.runCmd("type category delete Category1") - self.runCmd("type summary add Shape -w BaseCategory --summary-string \"AShape\"") + self.runCmd( + "type summary add Shape -w BaseCategory --summary-string \"AShape\"") self.runCmd("type category enable BaseCategory") self.expect("print (Shape*)&c1", - substrs = ['AShape']) + substrs=['AShape']) self.expect("print (Shape*)&r1", - substrs = ['AShape']) + substrs=['AShape']) self.expect("print (Shape*)c_ptr", - substrs = ['AShape']) + substrs=['AShape']) self.expect("print (Shape*)r_ptr", - substrs = ['AShape']) + substrs=['AShape']) - self.runCmd("type summary add Circle -w CircleCategory --summary-string \"ACircle\"") - self.runCmd("type summary add Rectangle -w RectangleCategory --summary-string \"ARectangle\"") + self.runCmd( + "type summary add Circle -w CircleCategory --summary-string \"ACircle\"") + self.runCmd( + "type summary add Rectangle -w RectangleCategory --summary-string \"ARectangle\"") self.runCmd("type category enable CircleCategory") self.expect("frame variable c1", - substrs = ['ACircle']) + substrs=['ACircle']) self.expect("frame variable c_ptr", - substrs = ['ACircle']) + substrs=['ACircle']) - self.runCmd("type summary add \"Rectangle *\" -w RectangleStarCategory --summary-string \"ARectangleStar\"") + self.runCmd( + "type summary add \"Rectangle *\" -w RectangleStarCategory --summary-string \"ARectangleStar\"") self.runCmd("type category enable RectangleStarCategory") self.expect("frame variable c1 r1 c_ptr r_ptr", - substrs = ['ACircle', - 'ARectangleStar']) + substrs=['ACircle', + 'ARectangleStar']) self.runCmd("type category enable RectangleCategory") self.expect("frame variable c1 r1 c_ptr r_ptr", - substrs = ['ACircle', - 'ACircle', - 'ARectangle']) + substrs=['ACircle', + 'ACircle', + 'ARectangle']) # Check that abruptly deleting an enabled category does not crash us self.runCmd("type category delete RectangleCategory") self.expect("frame variable c1 r1 c_ptr r_ptr", - substrs = ['ACircle', - '(Rectangle) r1 = ', 'w = 5', 'h = 6', - 'ACircle', - 'ARectangleStar']) - + substrs=['ACircle', + '(Rectangle) r1 = ', 'w = 5', 'h = 6', + 'ACircle', + 'ARectangleStar']) + # check that list commands work self.expect("type category list", - substrs = ['RectangleStarCategory (enabled)']) + substrs=['RectangleStarCategory (enabled)']) self.expect("type summary list", - substrs = ['ARectangleStar']) + substrs=['ARectangleStar']) # Disable a category and check that it fallsback self.runCmd("type category disable CircleCategory") - + # check that list commands work self.expect("type category list", - substrs = ['CircleCategory (disabled']) + substrs=['CircleCategory (disabled']) self.expect("frame variable c1 r_ptr", - substrs = ['AShape', - 'ARectangleStar']) + substrs=['AShape', + 'ARectangleStar']) # check that filters work into categories - self.runCmd("type filter add Rectangle --child w --category RectangleCategory") + self.runCmd( + "type filter add Rectangle --child w --category RectangleCategory") self.runCmd("type category enable RectangleCategory") - self.runCmd("type summary add Rectangle --category RectangleCategory --summary-string \" \" -e") + self.runCmd( + "type summary add Rectangle --category RectangleCategory --summary-string \" \" -e") self.expect('frame variable r2', - substrs = ['w = 9']) + substrs=['w = 9']) self.runCmd("type summary add Rectangle --summary-string \" \" -e") self.expect('frame variable r2', matching=False, - substrs = ['h = 16']) + substrs=['h = 16']) # Now delete all categories - self.runCmd("type category delete CircleCategory RectangleStarCategory BaseCategory RectangleCategory") + self.runCmd( + "type category delete CircleCategory RectangleStarCategory BaseCategory RectangleCategory") # check that a deleted category with filter does not blow us up self.expect('frame variable r2', - substrs = ['w = 9', - 'h = 16']) + substrs=['w = 9', + 'h = 16']) # and also validate that one can print formatters for a language - self.expect('type summary list -l c++', substrs=['vector', 'map', 'list', 'string']) + self.expect( + 'type summary list -l c++', + substrs=[ + 'vector', + 'map', + 'list', + 'string']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py index 99443a04f67..0518a75051b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class CppDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,24 +23,27 @@ class CppDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462: Data formatters have problems on Windows") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462: Data formatters have problems on Windows") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) self.expect("frame variable", - substrs = ['(Speed) SPILookHex = 5.55' # Speed by default is 5.55. - ]); + substrs=['(Speed) SPILookHex = 5.55' # Speed by default is 5.55. + ]) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -57,210 +61,238 @@ class CppDataFormatterTestCase(TestBase): # The type format list should show our custom formats. self.expect("type format list", - substrs = ['RealNumber', - 'Speed', - 'BitField', - 'Type1', - 'Type2']) + substrs=['RealNumber', + 'Speed', + 'BitField', + 'Type1', + 'Type2']) self.expect("frame variable", - patterns = ['\(Speed\) SPILookHex = 0x[0-9a-f]+' # Speed should look hex-ish now. - ]); - + patterns=['\(Speed\) SPILookHex = 0x[0-9a-f]+' # Speed should look hex-ish now. + ]) + # gcc4.2 on Mac OS X skips typedef chains in the DWARF output - if self.getCompiler() in ['clang', 'llvm-gcc']: + if self.getCompiler() in ['clang', 'llvm-gcc']: self.expect("frame variable", - patterns = ['\(SignalMask\) SMILookHex = 0x[0-9a-f]+' # SignalMask should look hex-ish now. - ]); + patterns=['\(SignalMask\) SMILookHex = 0x[0-9a-f]+' # SignalMask should look hex-ish now. + ]) self.expect("frame variable", matching=False, - patterns = ['\(Type4\) T4ILookChar = 0x[0-9a-f]+' # Type4 should NOT look hex-ish now. - ]); - + patterns=['\(Type4\) T4ILookChar = 0x[0-9a-f]+' # Type4 should NOT look hex-ish now. + ]) + # Now let's delete the 'Speed' custom format. self.runCmd("type format delete Speed") # The type format list should not show 'Speed' at this point. self.expect("type format list", matching=False, - substrs = ['Speed']) + substrs=['Speed']) # Delete type format for 'Speed', we should expect an error message. self.expect("type format delete Speed", error=True, - substrs = ['no custom formatter for Speed']) - - self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") - + substrs=['no custom formatter for Speed']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") + self.expect("frame variable strarr", - substrs = ['arr = "Hello world!"']) - + substrs=['arr = "Hello world!"']) + self.runCmd("type summary clear") - - self.runCmd("type summary add --summary-string \"ptr = ${var%s}\" \"char *\" -v") - + + self.runCmd( + "type summary add --summary-string \"ptr = ${var%s}\" \"char *\" -v") + self.expect("frame variable strptr", - substrs = ['ptr = "Hello world!"']) - - self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") - + substrs=['ptr = "Hello world!"']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") + self.expect("frame variable strarr", - substrs = ['arr = "Hello world!']) + substrs=['arr = "Hello world!']) - # check that rdar://problem/10011145 (Standard summary format for char[] doesn't work as the result of "expr".) is solved + # check that rdar://problem/10011145 (Standard summary format for + # char[] doesn't work as the result of "expr".) is solved self.expect("p strarr", - substrs = ['arr = "Hello world!']) + substrs=['arr = "Hello world!']) self.expect("frame variable strptr", - substrs = ['ptr = "Hello world!"']) + substrs=['ptr = "Hello world!"']) self.expect("p strptr", - substrs = ['ptr = "Hello world!"']) + substrs=['ptr = "Hello world!"']) - self.expect("p (char*)\"1234567890123456789012345678901234567890123456789012345678901234ABC\"", - substrs = ['(char *) $', ' = ptr = ', ' "1234567890123456789012345678901234567890123456789012345678901234ABC"']) + self.expect( + "p (char*)\"1234567890123456789012345678901234567890123456789012345678901234ABC\"", + substrs=[ + '(char *) $', + ' = ptr = ', + ' "1234567890123456789012345678901234567890123456789012345678901234ABC"']) self.runCmd("type summary add -c Point") - + self.expect("frame variable iAmSomewhere", - substrs = ['x = 4', - 'y = 6']) - + substrs=['x = 4', + 'y = 6']) + self.expect("type summary list", - substrs = ['Point', - 'one-line']) + substrs=['Point', + 'one-line']) self.runCmd("type summary add --summary-string \"y=${var.y%x}\" Point") self.expect("frame variable iAmSomewhere", - substrs = ['y=0x']) - - self.runCmd("type summary add --summary-string \"y=${var.y},x=${var.x}\" Point") - + substrs=['y=0x']) + + self.runCmd( + "type summary add --summary-string \"y=${var.y},x=${var.x}\" Point") + self.expect("frame variable iAmSomewhere", - substrs = ['y=6', - 'x=4']) + substrs=['y=6', + 'x=4']) self.runCmd("type summary add --summary-string \"hello\" Point -e") self.expect("type summary list", - substrs = ['Point', - 'show children']) - + substrs=['Point', + 'show children']) + self.expect("frame variable iAmSomewhere", - substrs = ['hello', - 'x = 4', - '}']) + substrs=['hello', + 'x = 4', + '}']) - self.runCmd("type summary add --summary-string \"Sign: ${var[31]%B} Exponent: ${var[23-30]%x} Mantissa: ${var[0-22]%u}\" ShowMyGuts") + self.runCmd( + "type summary add --summary-string \"Sign: ${var[31]%B} Exponent: ${var[23-30]%x} Mantissa: ${var[0-22]%u}\" ShowMyGuts") self.expect("frame variable cool_pointer->floating", - substrs = ['Sign: true', - 'Exponent: 0x', - '80']) + substrs=['Sign: true', + 'Exponent: 0x', + '80']) self.runCmd("type summary add --summary-string \"a test\" i_am_cool") self.expect("frame variable cool_pointer", - substrs = ['a test']) + substrs=['a test']) + + self.runCmd( + "type summary add --summary-string \"a test\" i_am_cool --skip-pointers") - self.runCmd("type summary add --summary-string \"a test\" i_am_cool --skip-pointers") - self.expect("frame variable cool_pointer", - substrs = ['a test'], - matching = False) + substrs=['a test'], + matching=False) - self.runCmd("type summary add --summary-string \"${var[1-3]}\" \"int [5]\"") + self.runCmd( + "type summary add --summary-string \"${var[1-3]}\" \"int [5]\"") self.expect("frame variable int_array", - substrs = ['2', - '3', - '4']) + substrs=['2', + '3', + '4']) self.runCmd("type summary clear") - self.runCmd("type summary add --summary-string \"${var[0-2].integer}\" \"i_am_cool *\"") - self.runCmd("type summary add --summary-string \"${var[2-4].integer}\" \"i_am_cool [5]\"") + self.runCmd( + "type summary add --summary-string \"${var[0-2].integer}\" \"i_am_cool *\"") + self.runCmd( + "type summary add --summary-string \"${var[2-4].integer}\" \"i_am_cool [5]\"") self.expect("frame variable cool_array", - substrs = ['1,1,6']) + substrs=['1,1,6']) self.expect("frame variable cool_pointer", - substrs = ['3,0,0']) + substrs=['3,0,0']) # test special symbols for formatting variables into summaries - self.runCmd("type summary add --summary-string \"cool object @ ${var%L}\" i_am_cool") + self.runCmd( + "type summary add --summary-string \"cool object @ ${var%L}\" i_am_cool") self.runCmd("type summary delete \"i_am_cool [5]\"") - + # this test might fail if the compiler tries to store # these values into registers.. hopefully this is not # going to be the case self.expect("frame variable cool_array", - substrs = ['[0] = cool object @ 0x', - '[1] = cool object @ 0x', - '[2] = cool object @ 0x', - '[3] = cool object @ 0x', - '[4] = cool object @ 0x']) - - # test getting similar output by exploiting ${var} = 'type @ location' for aggregates + substrs=['[0] = cool object @ 0x', + '[1] = cool object @ 0x', + '[2] = cool object @ 0x', + '[3] = cool object @ 0x', + '[4] = cool object @ 0x']) + + # test getting similar output by exploiting ${var} = 'type @ location' + # for aggregates self.runCmd("type summary add --summary-string \"${var}\" i_am_cool") - + # this test might fail if the compiler tries to store # these values into registers.. hopefully this is not # going to be the case self.expect("frame variable cool_array", - substrs = ['[0] = i_am_cool @ 0x', - '[1] = i_am_cool @ 0x', - '[2] = i_am_cool @ 0x', - '[3] = i_am_cool @ 0x', - '[4] = i_am_cool @ 0x']) - - - # test getting same output by exploiting %T and %L together for aggregates - self.runCmd("type summary add --summary-string \"${var%T} @ ${var%L}\" i_am_cool") - + substrs=['[0] = i_am_cool @ 0x', + '[1] = i_am_cool @ 0x', + '[2] = i_am_cool @ 0x', + '[3] = i_am_cool @ 0x', + '[4] = i_am_cool @ 0x']) + + # test getting same output by exploiting %T and %L together for + # aggregates + self.runCmd( + "type summary add --summary-string \"${var%T} @ ${var%L}\" i_am_cool") + # this test might fail if the compiler tries to store # these values into registers.. hopefully this is not # going to be the case self.expect("frame variable cool_array", - substrs = ['[0] = i_am_cool @ 0x', - '[1] = i_am_cool @ 0x', - '[2] = i_am_cool @ 0x', - '[3] = i_am_cool @ 0x', - '[4] = i_am_cool @ 0x']) - + substrs=['[0] = i_am_cool @ 0x', + '[1] = i_am_cool @ 0x', + '[2] = i_am_cool @ 0x', + '[3] = i_am_cool @ 0x', + '[4] = i_am_cool @ 0x']) + self.runCmd("type summary add --summary-string \"goofy\" i_am_cool") - self.runCmd("type summary add --summary-string \"${var.second_cool%S}\" i_am_cooler") + self.runCmd( + "type summary add --summary-string \"${var.second_cool%S}\" i_am_cooler") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) # check that unwanted type specifiers are removed self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"class i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"class i_am_cool\"") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"enum i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"enum i_am_cool\"") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"struct i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"struct i_am_cool\"") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) # many spaces, but we still do the right thing self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"union i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"union i_am_cool\"") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) # but that not *every* specifier is removed self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"wrong i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"wrong i_am_cool\"") self.expect("frame variable the_coolest_guy", matching=False, - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) - - # check that formats are not sticking since that is the behavior we want - self.expect("frame variable iAmInt --format hex", substrs = ['(int) iAmInt = 0x00000001']) - self.expect("frame variable iAmInt", matching=False, substrs = ['(int) iAmInt = 0x00000001']) - self.expect("frame variable iAmInt", substrs = ['(int) iAmInt = 1']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) + + # check that formats are not sticking since that is the behavior we + # want + self.expect("frame variable iAmInt --format hex", + substrs=['(int) iAmInt = 0x00000001']) + self.expect( + "frame variable iAmInt", + matching=False, + substrs=['(int) iAmInt = 0x00000001']) + self.expect("frame variable iAmInt", substrs=['(int) iAmInt = 1']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py index 2c2e0843117..e192943f381 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class DataFormatterDisablingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,62 +23,69 @@ class DataFormatterDisablingTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Check that we can properly disable all data formatter categories.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): - self.runCmd('type category enable *', check=False) + self.runCmd('type category enable *', check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) #self.runCmd('type category enable system VectorTypes libcxx gnu-libstdc++ CoreGraphics CoreServices AppKit CoreFoundation objc default', check=False) - self.expect('type category list', substrs = ['system','enabled',]) + self.expect('type category list', substrs=['system', 'enabled', ]) self.expect("frame variable numbers", - substrs = ['[0] = 1', '[3] = 1234']) + substrs=['[0] = 1', '[3] = 1234']) - self.expect('frame variable string1', substrs = ['hello world']) + self.expect('frame variable string1', substrs=['hello world']) # now disable them all and check that nothing is formatted self.runCmd('type category disable *') self.expect("frame variable numbers", matching=False, - substrs = ['[0] = 1', '[3] = 1234']) + substrs=['[0] = 1', '[3] = 1234']) + + self.expect( + 'frame variable string1', + matching=False, + substrs=['hello world']) - self.expect('frame variable string1', matching=False, substrs = ['hello world']) + self.expect('type summary list', substrs=[ + 'Category: system (disabled)']) - self.expect('type summary list', substrs=['Category: system (disabled)']) + self.expect('type category list', substrs=['system', 'disabled', ]) - self.expect('type category list', substrs = ['system','disabled',]) - # now enable and check that we are back to normal self.runCmd("type category enable *") - self.expect('type category list', substrs = ['system','enabled']) + self.expect('type category list', substrs=['system', 'enabled']) self.expect("frame variable numbers", - substrs = ['[0] = 1', '[3] = 1234']) + substrs=['[0] = 1', '[3] = 1234']) - self.expect('frame variable string1', substrs = ['hello world']) + self.expect('frame variable string1', substrs=['hello world']) - self.expect('type category list', substrs = ['system','enabled']) + self.expect('type category list', substrs=['system', 'enabled']) # last check - our cleanup will re-enable everything self.runCmd('type category disable *') - self.expect('type category list', substrs = ['system','disabled']) + self.expect('type category list', substrs=['system', 'disabled']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py index 1659ade74a0..710cfa8fe12 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class EnumFormatTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,21 +27,22 @@ class EnumFormatTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) self.expect("frame variable", - substrs = ['(Foo) f = Case45', - '(int) x = 1', - '(int) y = 45', - '(int) z = 43' - ]); + substrs=['(Foo) f = Case45', + '(int) x = 1', + '(int) y = 45', + '(int) z = 43' + ]) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -55,11 +57,11 @@ class EnumFormatTestCase(TestBase): # The type format list should show our custom formats. self.expect("type format list -w default", - substrs = ['int: as type Foo']) + substrs=['int: as type Foo']) self.expect("frame variable", - substrs = ['(Foo) f = Case45', - '(int) x = Case1', - '(int) y = Case45', - '(int) z = 43' - ]); + substrs=['(Foo) f = Case45', + '(int) x = Case1', + '(int) y = Case45', + '(int) z = 43' + ]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py index df3bef091c8..d3d93dabc7f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class GlobalsDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,7 +27,8 @@ class GlobalsDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,27 +43,29 @@ class GlobalsDataFormatterTestCase(TestBase): # Simply check we can get at global variables self.expect("target variable g_point", - substrs = ['JustATest']) + substrs=['JustATest']) self.expect("target variable g_point_pointer", - substrs = ['(Point *) g_point_pointer =']) + substrs=['(Point *) g_point_pointer =']) # Print some information about the variables # (we ignore the actual values) - self.runCmd("type summary add --summary-string \"(x=${var.x},y=${var.y})\" Point") + self.runCmd( + "type summary add --summary-string \"(x=${var.x},y=${var.y})\" Point") self.expect("target variable g_point", - substrs = ['x=', - 'y=']) - + substrs=['x=', + 'y=']) + self.expect("target variable g_point_pointer", - substrs = ['(Point *) g_point_pointer =']) + substrs=['(Point *) g_point_pointer =']) # Test Python code on resulting SBValue - self.runCmd("type summary add --python-script \"return 'x=' + str(valobj.GetChildMemberWithName('x').GetValue());\" Point") + self.runCmd( + "type summary add --python-script \"return 'x=' + str(valobj.GetChildMemberWithName('x').GetValue());\" Point") self.expect("target variable g_point", - substrs = ['x=']) - + substrs=['x=']) + self.expect("target variable g_point_pointer", - substrs = ['(Point *) g_point_pointer =']) + substrs=['(Point *) g_point_pointer =']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py index e9ac79ad08e..f4f0a485989 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class NamedSummariesDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,15 +27,16 @@ class NamedSummariesDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - + substrs=['stopped', + 'stop reason = breakpoint']) + # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): @@ -44,81 +46,88 @@ class NamedSummariesDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add --summary-string \"AllUseIt: x=${var.x} {y=${var.y}} {z=${var.z}}\" --name AllUseIt") - self.runCmd("type summary add --summary-string \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First") - self.runCmd("type summary add --summary-string \"Second: x=${var.x} y=${var.y%hex}\" Second") - self.runCmd("type summary add --summary-string \"Third: x=${var.x} z=${var.z}\" Third") - + self.runCmd( + "type summary add --summary-string \"AllUseIt: x=${var.x} {y=${var.y}} {z=${var.z}}\" --name AllUseIt") + self.runCmd( + "type summary add --summary-string \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First") + self.runCmd( + "type summary add --summary-string \"Second: x=${var.x} y=${var.y%hex}\" Second") + self.runCmd( + "type summary add --summary-string \"Third: x=${var.x} z=${var.z}\" Third") + self.expect('type summary list', substrs=['AllUseIt']) - + self.expect("frame variable first", - substrs = ['First: x=12']) + substrs=['First: x=12']) self.expect("frame variable first --summary AllUseIt", - substrs = ['AllUseIt: x=12']) - + substrs=['AllUseIt: x=12']) + # We *DO NOT* remember the summary choice anymore self.expect("frame variable first", matching=False, - substrs = ['AllUseIt: x=12']) + substrs=['AllUseIt: x=12']) self.expect("frame variable first", - substrs = ['First: x=12']) + substrs=['First: x=12']) + + self.runCmd("thread step-over") # 2 - self.runCmd("thread step-over") # 2 - self.expect("frame variable first", - substrs = ['First: x=12']) - + substrs=['First: x=12']) + self.expect("frame variable first --summary AllUseIt", - substrs = ['AllUseIt: x=12', - 'y=34']) + substrs=['AllUseIt: x=12', + 'y=34']) self.expect("frame variable second --summary AllUseIt", - substrs = ['AllUseIt: x=65', - 'y=43.25']) + substrs=['AllUseIt: x=65', + 'y=43.25']) self.expect("frame variable third --summary AllUseIt", - substrs = ['AllUseIt: x=96', - 'z=', - 'E']) + substrs=['AllUseIt: x=96', + 'z=', + 'E']) + + self.runCmd("thread step-over") # 3 - self.runCmd("thread step-over") # 3 - self.expect("frame variable second", - substrs = ['Second: x=65', - 'y=0x']) - + substrs=['Second: x=65', + 'y=0x']) + # <rdar://problem/11576143> decided that invalid summaries will raise an error # instead of just defaulting to the base summary - self.expect("frame variable second --summary NoSuchSummary",error=True, - substrs = ['must specify a valid named summary']) - + self.expect( + "frame variable second --summary NoSuchSummary", + error=True, + substrs=['must specify a valid named summary']) + self.runCmd("thread step-over") - - self.runCmd("type summary add --summary-string \"FirstAndFriends: x=${var.x} {y=${var.y}} {z=${var.z}}\" First --name FirstAndFriends") - + + self.runCmd( + "type summary add --summary-string \"FirstAndFriends: x=${var.x} {y=${var.y}} {z=${var.z}}\" First --name FirstAndFriends") + self.expect("frame variable first", - substrs = ['FirstAndFriends: x=12', - 'y=34']) + substrs=['FirstAndFriends: x=12', + 'y=34']) self.runCmd("type summary delete First") - + self.expect("frame variable first --summary FirstAndFriends", - substrs = ['FirstAndFriends: x=12', - 'y=34']) - + substrs=['FirstAndFriends: x=12', + 'y=34']) + self.expect("frame variable first", matching=True, - substrs = ['x = 12', - 'y = 34']) - + substrs=['x = 12', + 'y = 34']) + self.runCmd("type summary delete FirstAndFriends") self.expect("type summary delete NoSuchSummary", error=True) self.runCmd("type summary delete AllUseIt") - + self.expect("frame variable first", matching=False, - substrs = ['FirstAndFriends']) + substrs=['FirstAndFriends']) - self.runCmd("thread step-over") # 4 + self.runCmd("thread step-over") # 4 - self.expect("frame variable first",matching=False, - substrs = ['FirstAndFriends: x=12', - 'y=34']) + self.expect("frame variable first", matching=False, + substrs=['FirstAndFriends: x=12', + 'y=34']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py index 4392cead5a1..6d38578dae7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py @@ -6,14 +6,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,7 +25,7 @@ class ObjCDataFormatterTestCase(TestBase): self.build() self.plain_data_formatter_commands() - def appkit_tester_impl(self,commands): + def appkit_tester_impl(self, commands): self.build() self.appkit_common_data_formatters_command() commands() @@ -49,25 +50,21 @@ class ObjCDataFormatterTestCase(TestBase): """Test formatters for NSURL.""" self.appkit_tester_impl(self.nsurl_data_formatter_commands) - @skipUnlessDarwin def test_nserror_with_run_command(self): """Test formatters for NSError.""" self.appkit_tester_impl(self.nserror_data_formatter_commands) - @skipUnlessDarwin def test_nsbundle_with_run_command(self): """Test formatters for NSBundle.""" self.appkit_tester_impl(self.nsbundle_data_formatter_commands) - @skipUnlessDarwin def test_nsexception_with_run_command(self): """Test formatters for NSException.""" self.appkit_tester_impl(self.nsexception_data_formatter_commands) - @skipUnlessDarwin def test_nsdate_with_run_command(self): """Test formatters for NSDate.""" @@ -101,14 +98,15 @@ class ObjCDataFormatterTestCase(TestBase): """Test basic ObjC formatting behavior.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -123,57 +121,58 @@ class ObjCDataFormatterTestCase(TestBase): self.runCmd("type summary add --summary-string \"${var%@}\" MyClass") self.expect("frame variable object2", - substrs = ['MyOtherClass']); - + substrs=['MyOtherClass']) + self.expect("frame variable *object2", - substrs = ['MyOtherClass']); + substrs=['MyOtherClass']) # Now let's delete the 'MyClass' custom summary. self.runCmd("type summary delete MyClass") # The type format list should not show 'MyClass' at this point. self.expect("type summary list", matching=False, - substrs = ['MyClass']) + substrs=['MyClass']) self.runCmd("type summary add --summary-string \"a test\" MyClass") - + self.expect("frame variable *object2", - substrs = ['*object2 =', - 'MyClass = a test', - 'backup = ']); - + substrs=['*object2 =', + 'MyClass = a test', + 'backup = ']) + self.expect("frame variable object2", matching=False, - substrs = ['a test']); - + substrs=['a test']) + self.expect("frame variable object", - substrs = ['a test']); - + substrs=['a test']) + self.expect("frame variable *object", - substrs = ['a test']); + substrs=['a test']) self.expect('frame variable myclass', - substrs = ['(Class) myclass = NSValue']) + substrs=['(Class) myclass = NSValue']) self.expect('frame variable myclass2', - substrs = ['(Class) myclass2 = ','NS','String']) + substrs=['(Class) myclass2 = ', 'NS', 'String']) self.expect('frame variable myclass3', - substrs = ['(Class) myclass3 = Molecule']) + substrs=['(Class) myclass3 = Molecule']) self.expect('frame variable myclass4', - substrs = ['(Class) myclass4 = NSMutableArray']) + substrs=['(Class) myclass4 = NSMutableArray']) self.expect('frame variable myclass5', - substrs = ['(Class) myclass5 = nil']) + substrs=['(Class) myclass5 = nil']) def appkit_common_data_formatters_command(self): """Test formatters for AppKit classes.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -184,132 +183,183 @@ class ObjCDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + def nsnumber_data_formatter_commands(self): # Now enable AppKit and check we are displaying Cocoa classes correctly self.expect('frame variable num1 num2 num3 num4 num5 num6 num7 num9', - substrs = ['(NSNumber *) num1 = ',' (int)5', - '(NSNumber *) num2 = ',' (float)3.1', - '(NSNumber *) num3 = ',' (double)3.14', - '(NSNumber *) num4 = ',' (long)-2', - '(NSNumber *) num5 = ',' (char)65', - '(NSNumber *) num6 = ',' (long)255', - '(NSNumber *) num7 = ','2000000', - '(NSNumber *) num9 = ',' (short)-31616']) + substrs=['(NSNumber *) num1 = ', ' (int)5', + '(NSNumber *) num2 = ', ' (float)3.1', + '(NSNumber *) num3 = ', ' (double)3.14', + '(NSNumber *) num4 = ', ' (long)-2', + '(NSNumber *) num5 = ', ' (char)65', + '(NSNumber *) num6 = ', ' (long)255', + '(NSNumber *) num7 = ', '2000000', + '(NSNumber *) num9 = ', ' (short)-31616']) self.expect('frame variable num_at1 num_at2 num_at3 num_at4', - substrs = ['(NSNumber *) num_at1 = ',' (int)12', - '(NSNumber *) num_at2 = ',' (int)-12', - '(NSNumber *) num_at3 = ',' (double)12.5', - '(NSNumber *) num_at4 = ',' (double)-12.5']) + substrs=['(NSNumber *) num_at1 = ', ' (int)12', + '(NSNumber *) num_at2 = ', ' (int)-12', + '(NSNumber *) num_at3 = ', ' (double)12.5', + '(NSNumber *) num_at4 = ', ' (double)-12.5']) def nscontainers_data_formatter_commands(self): - self.expect('frame variable newArray newDictionary newMutableDictionary cfarray_ref mutable_array_ref', - substrs = ['(NSArray *) newArray = ','@"50 elements"', - '(NSDictionary *) newDictionary = ',' 12 key/value pairs', - '(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs', - '(CFArrayRef) cfarray_ref = ','@"3 elements"', - '(CFMutableArrayRef) mutable_array_ref = ','@"11 elements"']) + self.expect( + 'frame variable newArray newDictionary newMutableDictionary cfarray_ref mutable_array_ref', + substrs=[ + '(NSArray *) newArray = ', + '@"50 elements"', + '(NSDictionary *) newDictionary = ', + ' 12 key/value pairs', + '(NSDictionary *) newMutableDictionary = ', + ' 21 key/value pairs', + '(CFArrayRef) cfarray_ref = ', + '@"3 elements"', + '(CFMutableArrayRef) mutable_array_ref = ', + '@"11 elements"']) self.expect('frame variable iset1 iset2 imset', - substrs = ['4 indexes','512 indexes','10 indexes']) + substrs=['4 indexes', '512 indexes', '10 indexes']) - self.expect('frame variable binheap_ref', - substrs = ['(CFBinaryHeapRef) binheap_ref = ','@"21 items"']) + self.expect( + 'frame variable binheap_ref', + substrs=[ + '(CFBinaryHeapRef) binheap_ref = ', + '@"21 items"']) - self.expect('expression -d run -- [NSArray new]', substrs=['@"0 elements"']) + self.expect( + 'expression -d run -- [NSArray new]', + substrs=['@"0 elements"']) def nsdata_data_formatter_commands(self): - self.expect('frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref', - substrs = ['(NSData *) immutableData = ',' 4 bytes', - '(NSData *) mutableData = ',' 14 bytes', - '(CFDataRef) data_ref = ','@"5 bytes"', - '(CFMutableDataRef) mutable_data_ref = ','@"5 bytes"', - '(CFMutableStringRef) mutable_string_ref = ',' @"Wish ya knew"']) + self.expect( + 'frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref', + substrs=[ + '(NSData *) immutableData = ', + ' 4 bytes', + '(NSData *) mutableData = ', + ' 14 bytes', + '(CFDataRef) data_ref = ', + '@"5 bytes"', + '(CFMutableDataRef) mutable_data_ref = ', + '@"5 bytes"', + '(CFMutableStringRef) mutable_string_ref = ', + ' @"Wish ya knew"']) def nsurl_data_formatter_commands(self): - self.expect('frame variable cfurl_ref cfchildurl_ref cfgchildurl_ref', - substrs = ['(CFURLRef) cfurl_ref = ','@"http://www.foo.bar', - 'cfchildurl_ref = ','@"page.html -- http://www.foo.bar', - '(CFURLRef) cfgchildurl_ref = ','@"?whatever -- http://www.foo.bar/page.html"']) - - self.expect('frame variable nsurl nsurl2 nsurl3', - substrs = ['(NSURL *) nsurl = ','@"http://www.foo.bar', - '(NSURL *) nsurl2 =','@"page.html -- http://www.foo.bar', - '(NSURL *) nsurl3 = ','@"?whatever -- http://www.foo.bar/page.html"']) + self.expect( + 'frame variable cfurl_ref cfchildurl_ref cfgchildurl_ref', + substrs=[ + '(CFURLRef) cfurl_ref = ', + '@"http://www.foo.bar', + 'cfchildurl_ref = ', + '@"page.html -- http://www.foo.bar', + '(CFURLRef) cfgchildurl_ref = ', + '@"?whatever -- http://www.foo.bar/page.html"']) + + self.expect( + 'frame variable nsurl nsurl2 nsurl3', + substrs=[ + '(NSURL *) nsurl = ', + '@"http://www.foo.bar', + '(NSURL *) nsurl2 =', + '@"page.html -- http://www.foo.bar', + '(NSURL *) nsurl3 = ', + '@"?whatever -- http://www.foo.bar/page.html"']) def nserror_data_formatter_commands(self): self.expect('frame variable nserror', - substrs = ['domain: @"Foobar" - code: 12']) + substrs=['domain: @"Foobar" - code: 12']) self.expect('frame variable nserrorptr', - substrs = ['domain: @"Foobar" - code: 12']) + substrs=['domain: @"Foobar" - code: 12']) self.expect('frame variable nserror->_userInfo', - substrs = ['2 key/value pairs']) + substrs=['2 key/value pairs']) - self.expect('frame variable nserror->_userInfo --ptr-depth 1 -d run-target', - substrs = ['@"a"','@"b"',"1","2"]) + self.expect( + 'frame variable nserror->_userInfo --ptr-depth 1 -d run-target', + substrs=[ + '@"a"', + '@"b"', + "1", + "2"]) def nsbundle_data_formatter_commands(self): - self.expect('frame variable bundle_string bundle_url main_bundle', - substrs = ['(NSBundle *) bundle_string = ',' @"/System/Library/Frameworks/Accelerate.framework"', - '(NSBundle *) bundle_url = ',' @"/System/Library/Frameworks/Foundation.framework"', - '(NSBundle *) main_bundle = ','data-formatter-objc']) + self.expect( + 'frame variable bundle_string bundle_url main_bundle', + substrs=[ + '(NSBundle *) bundle_string = ', + ' @"/System/Library/Frameworks/Accelerate.framework"', + '(NSBundle *) bundle_url = ', + ' @"/System/Library/Frameworks/Foundation.framework"', + '(NSBundle *) main_bundle = ', + 'data-formatter-objc']) def nsexception_data_formatter_commands(self): - self.expect('frame variable except0 except1 except2 except3', - substrs = ['(NSException *) except0 = ','name: @"TheGuyWhoHasNoName" - reason: @"cuz it\'s funny"', - '(NSException *) except1 = ','name: @"TheGuyWhoHasNoName~1" - reason: @"cuz it\'s funny"', - '(NSException *) except2 = ','name: @"TheGuyWhoHasNoName`2" - reason: @"cuz it\'s funny"', - '(NSException *) except3 = ','name: @"TheGuyWhoHasNoName/3" - reason: @"cuz it\'s funny"']) + self.expect( + 'frame variable except0 except1 except2 except3', + substrs=[ + '(NSException *) except0 = ', + 'name: @"TheGuyWhoHasNoName" - reason: @"cuz it\'s funny"', + '(NSException *) except1 = ', + 'name: @"TheGuyWhoHasNoName~1" - reason: @"cuz it\'s funny"', + '(NSException *) except2 = ', + 'name: @"TheGuyWhoHasNoName`2" - reason: @"cuz it\'s funny"', + '(NSException *) except3 = ', + 'name: @"TheGuyWhoHasNoName/3" - reason: @"cuz it\'s funny"']) def nsdate_data_formatter_commands(self): - self.expect('frame variable date1 date2', - patterns = ['(1985-04-10|1985-04-11)','(2011-01-01|2010-12-31)']) + self.expect( + 'frame variable date1 date2', + patterns=[ + '(1985-04-10|1985-04-11)', + '(2011-01-01|2010-12-31)']) # this test might fail if we hit the breakpoint late on December 31st of some given year # and midnight comes between hitting the breakpoint and running this line of code # hopefully the output will be revealing enough in that case :-) now_year = '%s-' % str(datetime.datetime.now().year) - self.expect('frame variable date3', substrs = [now_year]) - self.expect('frame variable date4', substrs = ['1970']) - self.expect('frame variable date5', substrs = [now_year]) + self.expect('frame variable date3', substrs=[now_year]) + self.expect('frame variable date4', substrs=['1970']) + self.expect('frame variable date5', substrs=[now_year]) self.expect('frame variable date1_abs date2_abs', - substrs = ['1985-04','2011-01']) + substrs=['1985-04', '2011-01']) - self.expect('frame variable date3_abs', substrs = [now_year]) - self.expect('frame variable date4_abs', substrs = ['1970']) - self.expect('frame variable date5_abs', substrs = [now_year]) + self.expect('frame variable date3_abs', substrs=[now_year]) + self.expect('frame variable date4_abs', substrs=['1970']) + self.expect('frame variable date5_abs', substrs=[now_year]) self.expect('frame variable cupertino home europe', - substrs = ['@"America/Los_Angeles"', - '@"Europe/Rome"', - '@"Europe/Paris"']) + substrs=['@"America/Los_Angeles"', + '@"Europe/Rome"', + '@"Europe/Paris"']) self.expect('frame variable cupertino_ns home_ns europe_ns', - substrs = ['@"America/Los_Angeles"', - '@"Europe/Rome"', - '@"Europe/Paris"']) - - self.expect('frame variable mut_bv', - substrs = ['(CFMutableBitVectorRef) mut_bv = ', '1110 0110 1011 0000 1101 1010 1000 1111 0011 0101 1101 0001 00']) + substrs=['@"America/Los_Angeles"', + '@"Europe/Rome"', + '@"Europe/Paris"']) + self.expect( + 'frame variable mut_bv', + substrs=[ + '(CFMutableBitVectorRef) mut_bv = ', + '1110 0110 1011 0000 1101 1010 1000 1111 0011 0101 1101 0001 00']) def expr_objc_data_formatter_commands(self): """Test common cases of expression parser <--> formatters interaction.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -323,36 +373,41 @@ class ObjCDataFormatterTestCase(TestBase): # check that the formatters are able to deal safely and correctly # with ValueObjects that the expression parser returns - self.expect('expression ((id)@"Hello for long enough to avoid short string types")', matching=False, - substrs = ['Hello for long enough to avoid short string types']) + self.expect( + 'expression ((id)@"Hello for long enough to avoid short string types")', + matching=False, + substrs=['Hello for long enough to avoid short string types']) - self.expect('expression -d run -- ((id)@"Hello for long enough to avoid short string types")', - substrs = ['Hello for long enough to avoid short string types']) + self.expect( + 'expression -d run -- ((id)@"Hello for long enough to avoid short string types")', + substrs=['Hello for long enough to avoid short string types']) self.expect('expr -d run -- label1', - substrs = ['Process Name']) - - self.expect('expr -d run -- @"Hello for long enough to avoid short string types"', - substrs = ['Hello for long enough to avoid short string types']) + substrs=['Process Name']) - self.expect('expr -d run --object-description -- @"Hello for long enough to avoid short string types"', - substrs = ['Hello for long enough to avoid short string types']) - self.expect('expr -d run --object-description -- @"Hello"', matching=False, - substrs = ['@"Hello" Hello']) + self.expect( + 'expr -d run -- @"Hello for long enough to avoid short string types"', + substrs=['Hello for long enough to avoid short string types']) + self.expect( + 'expr -d run --object-description -- @"Hello for long enough to avoid short string types"', + substrs=['Hello for long enough to avoid short string types']) + self.expect('expr -d run --object-description -- @"Hello"', + matching=False, substrs=['@"Hello" Hello']) def cf_data_formatter_commands(self): """Test formatters for Core OSX frameworks.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -361,50 +416,53 @@ class ObjCDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type synth clear', check=False) - # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # check formatters for common Objective-C types - expect_strings = ['(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds', - '(CFRange) cf_range = location=4 length=4', - '(NSPoint) ns_point = (x = 4, y = 4)', - '(NSRange) ns_range = location=4, length=4', - '(NSRect) ns_rect = (origin = (x = 1, y = 1), size = (width = 5, height = 5))', - '(NSRectArray) ns_rect_arr = ((x = 1, y = 1), (width = 5, height = 5)), ...', - '(NSSize) ns_size = (width = 5, height = 7)', - '(CGSize) cg_size = (width = 1, height = 6)', - '(CGPoint) cg_point = (x = 2, y = 7)', - '(CGRect) cg_rect = (origin = (x = 1, y = 2), size = (width = 7, height = 7))', - '(Rect) rect = (t=4, l=8, b=4, r=7)', - '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)', - '(Point) point = (v=7, h=12)', - '(Point *) point_ptr = (v=7, h=12)', - '1985', - 'foo_selector_impl']; - + expect_strings = [ + '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds', + '(CFRange) cf_range = location=4 length=4', + '(NSPoint) ns_point = (x = 4, y = 4)', + '(NSRange) ns_range = location=4, length=4', + '(NSRect) ns_rect = (origin = (x = 1, y = 1), size = (width = 5, height = 5))', + '(NSRectArray) ns_rect_arr = ((x = 1, y = 1), (width = 5, height = 5)), ...', + '(NSSize) ns_size = (width = 5, height = 7)', + '(CGSize) cg_size = (width = 1, height = 6)', + '(CGPoint) cg_point = (x = 2, y = 7)', + '(CGRect) cg_rect = (origin = (x = 1, y = 2), size = (width = 7, height = 7))', + '(Rect) rect = (t=4, l=8, b=4, r=7)', + '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)', + '(Point) point = (v=7, h=12)', + '(Point *) point_ptr = (v=7, h=12)', + '1985', + 'foo_selector_impl'] + if self.getArchitecture() in ['i386', 'x86_64']: expect_strings.append('(HIPoint) hi_point = (x=7, y=12)') - expect_strings.append('(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)') - expect_strings.append('(RGBColor) rgb_color = red=3 green=56 blue=35') - expect_strings.append('(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35') - - self.expect("frame variable", - substrs = expect_strings) + expect_strings.append( + '(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)') + expect_strings.append( + '(RGBColor) rgb_color = red=3 green=56 blue=35') + expect_strings.append( + '(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35') + self.expect("frame variable", + substrs=expect_strings) def kvo_data_formatter_commands(self): """Test the behavior of formatters when KVO is in use.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -420,18 +478,23 @@ class ObjCDataFormatterTestCase(TestBase): # we should be able to dynamically figure out that the KVO implementor class # is a subclass of Molecule, and use the appropriate summary for it self.runCmd("type summary add -s JustAMoleculeHere Molecule") - self.expect('frame variable molecule', substrs = ['JustAMoleculeHere']) + self.expect('frame variable molecule', substrs=['JustAMoleculeHere']) self.runCmd("next") self.expect("thread list", - substrs = ['stopped', - 'step over']) - self.expect('frame variable molecule', substrs = ['JustAMoleculeHere']) + substrs=['stopped', + 'step over']) + self.expect('frame variable molecule', substrs=['JustAMoleculeHere']) self.runCmd("next") - # check that NSMutableDictionary's formatter is not confused when dealing with a KVO'd dictionary - self.expect('frame variable newMutableDictionary', substrs = ['(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs']) + # check that NSMutableDictionary's formatter is not confused when + # dealing with a KVO'd dictionary + self.expect( + 'frame variable newMutableDictionary', + substrs=[ + '(NSDictionary *) newMutableDictionary = ', + ' 21 key/value pairs']) - lldbutil.run_break_set_by_regexp (self, 'setAtoms') + lldbutil.run_break_set_by_regexp(self, 'setAtoms') self.runCmd("continue") - self.expect("frame variable _cmd",substrs = ['setAtoms:']) + self.expect("frame variable _cmd", substrs=['setAtoms:']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py index 89145553d35..5ef84b019df 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py @@ -6,30 +6,32 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import datetime import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class NSIndexPathDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def appkit_tester_impl(self,commands): + def appkit_tester_impl(self, commands): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -38,7 +40,6 @@ class NSIndexPathDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type synth clear', check=False) - # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) commands() @@ -56,15 +57,58 @@ class NSIndexPathDataFormatterTestCase(TestBase): def nsindexpath_data_formatter_commands(self): # check 'frame variable' - self.expect('frame variable --ptr-depth=1 -d run -- indexPath1', substrs = ['[0] = 1']) - self.expect('frame variable --ptr-depth=1 -d run -- indexPath2', substrs = ['[0] = 1', '[1] = 2']) - self.expect('frame variable --ptr-depth=1 -d run -- indexPath3', substrs = ['[0] = 1', '[1] = 2', '[2] = 3']) - self.expect('frame variable --ptr-depth=1 -d run -- indexPath4', substrs = ['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4']) - self.expect('frame variable --ptr-depth=1 -d run -- indexPath5', substrs = ['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4', '[4] = 5']) - + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath1', + substrs=['[0] = 1']) + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath2', + substrs=[ + '[0] = 1', + '[1] = 2']) + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath3', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3']) + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath4', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3', + '[3] = 4']) + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath5', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3', + '[3] = 4', + '[4] = 5']) + # and 'expression' - self.expect('expression --ptr-depth=1 -d run -- indexPath1', substrs = ['[0] = 1']) - self.expect('expression --ptr-depth=1 -d run -- indexPath2', substrs = ['[0] = 1', '[1] = 2']) - self.expect('expression --ptr-depth=1 -d run -- indexPath3', substrs = ['[0] = 1', '[1] = 2', '[2] = 3']) - self.expect('expression --ptr-depth=1 -d run -- indexPath4', substrs = ['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4']) - self.expect('expression --ptr-depth=1 -d run -- indexPath5', substrs = ['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4', '[4] = 5']) + self.expect( + 'expression --ptr-depth=1 -d run -- indexPath1', + substrs=['[0] = 1']) + self.expect( + 'expression --ptr-depth=1 -d run -- indexPath2', + substrs=[ + '[0] = 1', + '[1] = 2']) + self.expect( + 'expression --ptr-depth=1 -d run -- indexPath3', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3']) + self.expect('expression --ptr-depth=1 -d run -- indexPath4', + substrs=['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4']) + self.expect( + 'expression --ptr-depth=1 -d run -- indexPath5', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3', + '[3] = 4', + '[4] = 5']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py index f5c79259377..12e62f62ee9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py @@ -6,30 +6,32 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import datetime import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class NSStringDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def appkit_tester_impl(self,commands): + def appkit_tester_impl(self, commands): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -38,7 +40,6 @@ class NSStringDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type synth clear', check=False) - # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) commands() @@ -58,7 +59,6 @@ class NSStringDataFormatterTestCase(TestBase): """Test formatters for NSString.""" self.appkit_tester_impl(self.nsstring_withNULs_commands) - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -67,42 +67,55 @@ class NSStringDataFormatterTestCase(TestBase): def rdar11106605_commands(self): """Check that Unicode characters come out of CFString summary correctly.""" - self.expect('frame variable italian', substrs = ['L\'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.']) - self.expect('frame variable french', substrs = ['Que veut cette horde d\'esclaves, De traîtres, de rois conjurés?']) - self.expect('frame variable german', substrs = ['Über-Ich und aus den Ansprüchen der sozialen Umwelt']) - self.expect('frame variable japanese', substrs = ['色は匂へど散りぬるを']) - self.expect('frame variable hebrew', substrs = ['לילה טוב']) + self.expect('frame variable italian', substrs=[ + 'L\'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.']) + self.expect('frame variable french', substrs=[ + 'Que veut cette horde d\'esclaves, De traîtres, de rois conjurés?']) + self.expect('frame variable german', substrs=[ + 'Über-Ich und aus den Ansprüchen der sozialen Umwelt']) + self.expect('frame variable japanese', substrs=['色は匂へど散りぬるを']) + self.expect('frame variable hebrew', substrs=['לילה טוב']) def nsstring_data_formatter_commands(self): self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12', - substrs = ['(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"', - # '(NSString *) str0 = ',' @"255"', - '(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"', - '(NSString *) str2 = ',' @"A rather short UTF8 NSString object is here"', - '(NSString *) str3 = ',' @"A string made with the at sign is here"', - '(NSString *) str4 = ',' @"This is string number 4 right here"', - '(NSString *) str5 = ',' @"{{1, 1}, {5, 5}}"', - '(NSString *) str6 = ',' @"1ST"', - '(NSString *) str8 = ',' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime', - '(NSString *) str9 = ',' @"a very much boring task to write a string this way!!', - '(NSString *) str10 = ',' @"This is a Unicode string σ number 4 right here"', - '(NSString *) str11 = ',' @"__NSCFString"', - '(NSString *) label1 = ',' @"Process Name: "', - '(NSString *) label2 = ',' @"Process Id: "', - '(NSString *) str12 = ',' @"Process Name: a.out Process Id:']) - self.expect('frame variable attrString mutableAttrString mutableGetConst', - substrs = ['(NSAttributedString *) attrString = ',' @"hello world from foo"', - '(NSAttributedString *) mutableAttrString = ',' @"hello world from foo"', - '(NSString *) mutableGetConst = ',' @"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear foo"']) - - self.expect('expr -d run-target -- path',substrs = ['usr/blah/stuff']) - self.expect('frame variable path',substrs = ['usr/blah/stuff']) + substrs=['(NSString *) str1 = ', ' @"A rather short ASCII NSString object is here"', + # '(NSString *) str0 = ',' @"255"', + '(NSString *) str1 = ', ' @"A rather short ASCII NSString object is here"', + '(NSString *) str2 = ', ' @"A rather short UTF8 NSString object is here"', + '(NSString *) str3 = ', ' @"A string made with the at sign is here"', + '(NSString *) str4 = ', ' @"This is string number 4 right here"', + '(NSString *) str5 = ', ' @"{{1, 1}, {5, 5}}"', + '(NSString *) str6 = ', ' @"1ST"', + '(NSString *) str8 = ', ' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime', + '(NSString *) str9 = ', ' @"a very much boring task to write a string this way!!', + '(NSString *) str10 = ', ' @"This is a Unicode string σ number 4 right here"', + '(NSString *) str11 = ', ' @"__NSCFString"', + '(NSString *) label1 = ', ' @"Process Name: "', + '(NSString *) label2 = ', ' @"Process Id: "', + '(NSString *) str12 = ', ' @"Process Name: a.out Process Id:']) + self.expect( + 'frame variable attrString mutableAttrString mutableGetConst', + substrs=[ + '(NSAttributedString *) attrString = ', + ' @"hello world from foo"', + '(NSAttributedString *) mutableAttrString = ', + ' @"hello world from foo"', + '(NSString *) mutableGetConst = ', + ' @"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear foo"']) + + self.expect('expr -d run-target -- path', substrs=['usr/blah/stuff']) + self.expect('frame variable path', substrs=['usr/blah/stuff']) def nsstring_withNULs_commands(self): """Check that the NSString formatter supports embedded NULs in the text""" - self.expect('po strwithNULs', substrs=['a very much boring task to write']) + self.expect( + 'po strwithNULs', + substrs=['a very much boring task to write']) self.expect('expr [strwithNULs length]', substrs=['54']) - self.expect('frame variable strwithNULs', substrs=['@"a very much boring task to write\\0a string this way!!']) - self.expect('po strwithNULs2', substrs=['a very much boring task to write']) + self.expect('frame variable strwithNULs', substrs=[ + '@"a very much boring task to write\\0a string this way!!']) + self.expect('po strwithNULs2', substrs=[ + 'a very much boring task to write']) self.expect('expr [strwithNULs2 length]', substrs=['52']) - self.expect('frame variable strwithNULs2', substrs=['@"a very much boring task to write\\0a string this way!!']) + self.expect('frame variable strwithNULs2', substrs=[ + '@"a very much boring task to write\\0a string this way!!']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py index 3c9be04a2f6..bf600219bce 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class DataFormatterOneIsSingularTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,14 +34,15 @@ class DataFormatterOneIsSingularTestCase(TestBase): """Test that 1 item is not as reported as 1 items.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -54,26 +56,26 @@ class DataFormatterOneIsSingularTestCase(TestBase): # Now check that we are displaying Cocoa classes correctly self.expect('frame variable key', - substrs = ['@"1 element"']) + substrs=['@"1 element"']) self.expect('frame variable key', matching=False, - substrs = ['1 elements']) + substrs=['1 elements']) self.expect('frame variable value', - substrs = ['@"1 element"']) + substrs=['@"1 element"']) self.expect('frame variable value', matching=False, - substrs = ['1 elements']) + substrs=['1 elements']) self.expect('frame variable dict', - substrs = ['1 key/value pair']) + substrs=['1 key/value pair']) self.expect('frame variable dict', matching=False, - substrs = ['1 key/value pairs']) + substrs=['1 key/value pairs']) self.expect('frame variable imset', - substrs = ['1 index']) + substrs=['1 index']) self.expect('frame variable imset', matching=False, - substrs = ['1 indexes']) + substrs=['1 indexes']) self.expect('frame variable binheap_ref', - substrs = ['@"1 item"']) + substrs=['@"1 item"']) self.expect('frame variable binheap_ref', matching=False, - substrs = ['1 items']) + substrs=['1 items']) self.expect('frame variable immutableData', - substrs = ['1 byte']) + substrs=['1 byte']) self.expect('frame variable immutableData', matching=False, - substrs = ['1 bytes']) + substrs=['1 bytes']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py index 86cd3c42728..ebabe307661 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class PtrToArrayDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,14 +31,15 @@ class PtrToArrayDataFormatterTestCase(TestBase): """Test that LLDB handles the clang typeclass Paren correctly.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -49,9 +51,9 @@ class PtrToArrayDataFormatterTestCase(TestBase): self.addTearDownHook(cleanup) self.expect('p *(int (*)[3])foo', - substrs = ['(int [3]) $','[0] = 1','[1] = 2','[2] = 3']) + substrs=['(int [3]) $', '[0] = 1', '[1] = 2', '[2] = 3']) self.expect('p *(int (*)[3])foo', matching=False, - substrs = ['01 00 00 00 02 00 00 00 03 00 00 00']) + substrs=['01 00 00 00 02 00 00 00 03 00 00 00']) self.expect('p *(int (*)[3])foo', matching=False, - substrs = ['0x000000030000000200000001']) + substrs=['0x000000030000000200000001']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py index c7ff28874c5..75d1853f6a7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py @@ -5,18 +5,19 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class PythonSynthDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser + @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser def test_with_run_command(self): """Test data formatter commands.""" self.build() @@ -27,20 +28,22 @@ class PythonSynthDataFormatterTestCase(TestBase): self.build() self.rdar10960550_formatter_commands() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - self.line2 = line_number('main.cpp', '// Set cast break point at this line.') - self.line3 = line_number('main.cpp', '// Set second cast break point at this line.') + self.line2 = line_number('main.cpp', + '// Set cast break point at this line.') + self.line3 = line_number( + 'main.cpp', '// Set second cast break point at this line.') def data_formatter_commands(self): """Test using Python synthetic children provider.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -48,8 +51,8 @@ class PythonSynthDataFormatterTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -64,9 +67,9 @@ class PythonSynthDataFormatterTestCase(TestBase): # print the f00_1 variable without a synth self.expect("frame variable f00_1", - substrs = ['a = 1', - 'b = 2', - 'r = 34']); + substrs=['a = 1', + 'b = 2', + 'r = 34']) # now set up the synth self.runCmd("script from fooSynthProvider import *") @@ -81,30 +84,32 @@ class PythonSynthDataFormatterTestCase(TestBase): # check that we get the two real vars and the fake_a variables self.expect("frame variable f00_1", - substrs = ['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 1']); + substrs=['r = 34', + 'fake_a = %d' % fake_a_val, + 'a = 1']) # check that we do not get the extra vars self.expect("frame variable f00_1", matching=False, - substrs = ['b = 2']); - + substrs=['b = 2']) + # check access to members by name self.expect('frame variable f00_1.fake_a', - substrs = ['%d' % fake_a_val]) - + substrs=['%d' % fake_a_val]) + # check access to members by index self.expect('frame variable f00_1[1]', - substrs = ['%d' % fake_a_val]) - + substrs=['%d' % fake_a_val]) + # put synthetic children in summary in several combinations - self.runCmd("type summary add --summary-string \"fake_a=${svar.fake_a}\" foo") + self.runCmd( + "type summary add --summary-string \"fake_a=${svar.fake_a}\" foo") self.expect('frame variable f00_1', - substrs = ['fake_a=%d' % fake_a_val]) - self.runCmd("type summary add --summary-string \"fake_a=${svar[1]}\" foo") + substrs=['fake_a=%d' % fake_a_val]) + self.runCmd( + "type summary add --summary-string \"fake_a=${svar[1]}\" foo") self.expect('frame variable f00_1', - substrs = ['fake_a=%d' % fake_a_val]) - + substrs=['fake_a=%d' % fake_a_val]) + # clear the summary self.runCmd("type summary delete foo") @@ -117,9 +122,9 @@ class PythonSynthDataFormatterTestCase(TestBase): fake_a_val = 0x00000200 self.expect("frame variable f00_1", - substrs = ['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 2']); + substrs=['r = 34', + 'fake_a = %d' % fake_a_val, + 'a = 2']) # check that altering the object also alters fake_a self.runCmd("expr f00_1.a = 280") @@ -130,9 +135,9 @@ class PythonSynthDataFormatterTestCase(TestBase): fake_a_val = 0x00011800 self.expect("frame variable f00_1", - substrs = ['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 280']); + substrs=['r = 34', + 'fake_a = %d' % fake_a_val, + 'a = 280']) # check that expanding a pointer does the right thing if process.GetByteOrder() == lldb.eByteOrderLittle: @@ -141,94 +146,97 @@ class PythonSynthDataFormatterTestCase(TestBase): fake_a_val = 0x00000c00 self.expect("frame variable --ptr-depth 1 f00_ptr", - substrs = ['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) - + substrs=['r = 45', + 'fake_a = %d' % fake_a_val, + 'a = 12']) + # now add a filter.. it should fail self.expect("type filter add foo --child b --child j", error=True, - substrs = ['cannot add']) - + substrs=['cannot add']) + # we get the synth again.. self.expect('frame variable f00_1', matching=False, - substrs = ['b = 1', - 'j = 17']) + substrs=['b = 1', + 'j = 17']) self.expect("frame variable --ptr-depth 1 f00_ptr", - substrs = ['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) - + substrs=['r = 45', + 'fake_a = %d' % fake_a_val, + 'a = 12']) + # now delete the synth and add the filter self.runCmd("type synth delete foo") self.runCmd("type filter add foo --child b --child j") - + self.expect('frame variable f00_1', - substrs = ['b = 2', - 'j = 18']) + substrs=['b = 2', + 'j = 18']) self.expect("frame variable --ptr-depth 1 f00_ptr", matching=False, - substrs = ['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) - + substrs=['r = 45', + 'fake_a = %d' % fake_a_val, + 'a = 12']) + # now add the synth and it should fail self.expect("type synth add -l fooSynthProvider foo", error=True, - substrs = ['cannot add']) - + substrs=['cannot add']) + # check the listing self.expect('type synth list', matching=False, - substrs = ['foo', - 'Python class fooSynthProvider']) - self.expect('type filter list', - substrs = ['foo', - '.b', - '.j']) - + substrs=['foo', + 'Python class fooSynthProvider']) + self.expect('type filter list', + substrs=['foo', + '.b', + '.j']) + # delete the filter, add the synth self.runCmd("type filter delete foo") self.runCmd("type synth add -l fooSynthProvider foo") - + self.expect('frame variable f00_1', matching=False, - substrs = ['b = 2', - 'j = 18']) - self.expect("frame variable --ptr-depth 1 f00_ptr", - substrs = ['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) + substrs=['b = 2', + 'j = 18']) + self.expect("frame variable --ptr-depth 1 f00_ptr", + substrs=['r = 45', + 'fake_a = %d' % fake_a_val, + 'a = 12']) # check the listing self.expect('type synth list', - substrs = ['foo', - 'Python class fooSynthProvider']) + substrs=['foo', + 'Python class fooSynthProvider']) self.expect('type filter list', matching=False, - substrs = ['foo', - '.b', - '.j']) - + substrs=['foo', + '.b', + '.j']) + # delete the synth and check that we get good output self.runCmd("type synth delete foo") - + self.expect("frame variable f00_1", - substrs = ['a = 280', - 'b = 2', - 'j = 18']); + substrs=['a = 280', + 'b = 2', + 'j = 18']) self.expect("frame variable f00_1", matching=False, - substrs = ['fake_a = ']) + substrs=['fake_a = ']) def rdar10960550_formatter_commands(self): """Test that synthetic children persist stoppoints.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - # The second breakpoint is on a multi-line expression, so the comment can't be on the right line... - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line2, num_expected_locations=1, loc_exact=False) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line3, num_expected_locations=1, loc_exact=True) + # The second breakpoint is on a multi-line expression, so the comment + # can't be on the right line... + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line2, num_expected_locations=1, loc_exact=False) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line3, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -248,25 +256,28 @@ class PythonSynthDataFormatterTestCase(TestBase): # but their values change correctly across stop-points - in order to do this, self.runCmd("next") # does not work because it forces a wipe of the stack frame - this is why we are using this more contrived # mechanism to achieve our goal of preserving test_cast as a VO - test_cast = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('test_cast') + test_cast = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable('test_cast') str_cast = str(test_cast) if self.TraceOn(): - print(str_cast) + print(str_cast) self.assertTrue(str_cast.find('A') != -1, 'could not find A in output') self.assertTrue(str_cast.find('B') != -1, 'could not find B in output') self.assertTrue(str_cast.find('C') != -1, 'could not find C in output') self.assertTrue(str_cast.find('D') != -1, 'could not find D in output') - self.assertTrue(str_cast.find("4 = '\\0'") != -1, 'could not find item 4 == 0') + self.assertTrue( + str_cast.find("4 = '\\0'") != -1, + 'could not find item 4 == 0') self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().StepOver() str_cast = str(test_cast) if self.TraceOn(): - print(str_cast) + print(str_cast) # we detect that all the values of the child objects have changed - but the counter-generated item # is still fixed at 0 because it is cached - this would fail if update(self): in ftsp returned False @@ -275,4 +286,6 @@ class PythonSynthDataFormatterTestCase(TestBase): self.assertTrue(str_cast.find('X') != -1, 'could not find X in output') self.assertTrue(str_cast.find('T') != -1, 'could not find T in output') self.assertTrue(str_cast.find('F') != -1, 'could not find F in output') - self.assertTrue(str_cast.find("4 = '\\0'") != -1, 'could not find item 4 == 0') + self.assertTrue( + str_cast.find("4 = '\\0'") != -1, + 'could not find item 4 == 0') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py index 0dc2c233e2a..45fb00468e0 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py @@ -1,23 +1,30 @@ import lldb + + class fooSynthProvider: - def __init__(self, valobj, dict): - self.valobj = valobj; - self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) - def num_children(self): - return 3; - def get_child_at_index(self, index): - if index == 0: - child = self.valobj.GetChildMemberWithName('a'); - if index == 1: - child = self.valobj.CreateChildAtOffset ('fake_a', 1, self.int_type); - if index == 2: - child = self.valobj.GetChildMemberWithName('r'); - return child; - def get_child_index(self, name): - if name == 'a': - return 0; - if name == 'fake_a': - return 1; - return 2; - def update(self): - return True
\ No newline at end of file + + def __init__(self, valobj, dict): + self.valobj = valobj + self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) + + def num_children(self): + return 3 + + def get_child_at_index(self, index): + if index == 0: + child = self.valobj.GetChildMemberWithName('a') + if index == 1: + child = self.valobj.CreateChildAtOffset('fake_a', 1, self.int_type) + if index == 2: + child = self.valobj.GetChildMemberWithName('r') + return child + + def get_child_index(self, name): + if name == 'a': + return 0 + if name == 'fake_a': + return 1 + return 2 + + def update(self): + return True diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py index d162b00db32..b96dbac6f50 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py @@ -2,31 +2,39 @@ import lldb counter = 0 + class ftsp: - def __init__(self, valobj, dict): - self.valobj = valobj; - def num_children(self): - if self.char.IsValid(): - return 5; - return 0; - def get_child_index(self,name): - return 0; - def get_child_at_index(self,index): - if index == 0: - return self.x.Cast(self.char) - if index == 4: - return self.valobj.CreateValueFromExpression(str(index),'(char)('+str(self.count)+')') - return self.x.CreateChildAtOffset(str(index), - index, - self.char); - def update(self): - self.x = self.valobj.GetChildMemberWithName('x'); - self.char = self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar) - global counter - self.count = counter - counter = counter + 1 - return True # important: if we return False here, or fail to return, the test will fail + + def __init__(self, valobj, dict): + self.valobj = valobj + + def num_children(self): + if self.char.IsValid(): + return 5 + return 0 + + def get_child_index(self, name): + return 0 + + def get_child_at_index(self, index): + if index == 0: + return self.x.Cast(self.char) + if index == 4: + return self.valobj.CreateValueFromExpression( + str(index), '(char)(' + str(self.count) + ')') + return self.x.CreateChildAtOffset(str(index), + index, + self.char) + + def update(self): + self.x = self.valobj.GetChildMemberWithName('x') + self.char = self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar) + global counter + self.count = counter + counter = counter + 1 + return True # important: if we return False here, or fail to return, the test will fail + def __lldb_init_module(debugger, dict): - global counter - counter = 0
\ No newline at end of file + global counter + counter = 0 diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py index 7ebc1c14ce1..3355ca16305 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class ScriptDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,14 +31,15 @@ class ScriptDataFormatterTestCase(TestBase): """Test that that file and class static variables display correctly.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -51,121 +53,133 @@ class ScriptDataFormatterTestCase(TestBase): # Set the script here to ease the formatting script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'Hello from Python, \' + a_val + \' time\'; return str + (\'!\' if a_val == \'1\' else \'s!\');' - self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script) + self.runCmd( + "type summary add i_am_cool --python-script \"%s\"" % + script) self.expect('type summary list i_am_cool', substrs=[script]) self.expect("frame variable one", - substrs = ['Hello from Python', - '1 time!']) + substrs=['Hello from Python', + '1 time!']) self.expect("frame variable two", - substrs = ['Hello from Python', - '4 times!']) - - self.runCmd("n"); # skip ahead to make values change + substrs=['Hello from Python', + '4 times!']) + + self.runCmd("n") # skip ahead to make values change self.expect("frame variable three", - substrs = ['Hello from Python, 10 times!', - 'Hello from Python, 4 times!']) + substrs=['Hello from Python, 10 times!', + 'Hello from Python, 4 times!']) + + self.runCmd("n") # skip ahead to make values change - self.runCmd("n"); # skip ahead to make values change - self.expect("frame variable two", - substrs = ['Hello from Python', - '1 time!']) + substrs=['Hello from Python', + '1 time!']) script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'int says \' + a_val; return str;' # Check that changes in the script are immediately reflected - self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script) + self.runCmd( + "type summary add i_am_cool --python-script \"%s\"" % + script) self.expect("frame variable two", - substrs = ['int says 1']) - + substrs=['int says 1']) + self.expect("frame variable twoptr", - substrs = ['int says 1']) + substrs=['int says 1']) # Change the summary - self.runCmd("type summary add --summary-string \"int says ${var.integer}, and float says ${var.floating}\" i_am_cool") + self.runCmd( + "type summary add --summary-string \"int says ${var.integer}, and float says ${var.floating}\" i_am_cool") self.expect("frame variable two", - substrs = ['int says 1', - 'and float says 2.71']) + substrs=['int says 1', + 'and float says 2.71']) # Try it for pointers self.expect("frame variable twoptr", - substrs = ['int says 1', - 'and float says 2.71']) + substrs=['int says 1', + 'and float says 2.71']) # Force a failure for pointers - self.runCmd("type summary add i_am_cool -p --python-script \"%s\"" % script) + self.runCmd( + "type summary add i_am_cool -p --python-script \"%s\"" % + script) self.expect("frame variable twoptr", matching=False, - substrs = ['and float says 2.71']) + substrs=['and float says 2.71']) - script = 'return \'Python summary\''; + script = 'return \'Python summary\'' - self.runCmd("type summary add --name test_summary --python-script \"%s\"" % script) + self.runCmd( + "type summary add --name test_summary --python-script \"%s\"" % + script) # attach the Python named summary to someone self.expect("frame variable one --summary test_summary", - substrs = ['Python summary']) + substrs=['Python summary']) # should not bind to the type self.expect("frame variable two", matching=False, - substrs = ['Python summary']) + substrs=['Python summary']) # and should not stick to the variable - self.expect("frame variable one",matching=False, - substrs = ['Python summary']) + self.expect("frame variable one", matching=False, + substrs=['Python summary']) - self.runCmd("type summary add i_am_cool --summary-string \"Text summary\"") + self.runCmd( + "type summary add i_am_cool --summary-string \"Text summary\"") # should be temporary only - self.expect("frame variable one",matching=False, - substrs = ['Python summary']) + self.expect("frame variable one", matching=False, + substrs=['Python summary']) # use the type summary self.expect("frame variable two", - substrs = ['Text summary']) + substrs=['Text summary']) - self.runCmd("n"); # skip ahead to make values change + self.runCmd("n") # skip ahead to make values change # both should use the type summary now self.expect("frame variable one", - substrs = ['Text summary']) - + substrs=['Text summary']) + self.expect("frame variable two", - substrs = ['Text summary']) + substrs=['Text summary']) # disable type summary for pointers, and make a Python regex summary - self.runCmd("type summary add i_am_cool -p --summary-string \"Text summary\"") + self.runCmd( + "type summary add i_am_cool -p --summary-string \"Text summary\"") self.runCmd("type summary add -x cool --python-script \"%s\"" % script) # variables should stick to the type summary self.expect("frame variable one", - substrs = ['Text summary']) + substrs=['Text summary']) self.expect("frame variable two", - substrs = ['Text summary']) + substrs=['Text summary']) # array and pointer should match the Python one self.expect("frame variable twoptr", - substrs = ['Python summary']) - + substrs=['Python summary']) + self.expect("frame variable array", - substrs = ['Python summary']) + substrs=['Python summary']) # return pointers to the type summary - self.runCmd("type summary add i_am_cool --summary-string \"Text summary\"") + self.runCmd( + "type summary add i_am_cool --summary-string \"Text summary\"") self.expect("frame variable one", - substrs = ['Text summary']) - + substrs=['Text summary']) + self.expect("frame variable two", - substrs = ['Text summary']) - + substrs=['Text summary']) + self.expect("frame variable twoptr", - substrs = ['Text summary']) - + substrs=['Text summary']) + self.expect("frame variable array", - substrs = ['Python summary']) + substrs=['Python summary']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py index c186f1465cf..5b52277e8b7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py @@ -5,19 +5,24 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class SkipSummaryDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr20548 fails to build on lab.llvm.org buildbot") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") + @expectedFailureAll( + oslist=['freebsd'], + bugnumber="llvm.org/pr20548 fails to build on lab.llvm.org buildbot") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Test data formatter commands.""" self.build() @@ -34,15 +39,15 @@ class SkipSummaryDataFormatterTestCase(TestBase): self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) #import lldbsuite.test.lldbutil as lldbutil - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) - + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -55,122 +60,146 @@ class SkipSummaryDataFormatterTestCase(TestBase): # Setup the summaries for this scenario #self.runCmd("type summary add --summary-string \"${var._M_dataplus._M_p}\" std::string") - self.runCmd("type summary add --summary-string \"Level 1\" \"DeepData_1\"") - self.runCmd("type summary add --summary-string \"Level 2\" \"DeepData_2\" -e") - self.runCmd("type summary add --summary-string \"Level 3\" \"DeepData_3\"") - self.runCmd("type summary add --summary-string \"Level 4\" \"DeepData_4\"") - self.runCmd("type summary add --summary-string \"Level 5\" \"DeepData_5\"") - + self.runCmd( + "type summary add --summary-string \"Level 1\" \"DeepData_1\"") + self.runCmd( + "type summary add --summary-string \"Level 2\" \"DeepData_2\" -e") + self.runCmd( + "type summary add --summary-string \"Level 3\" \"DeepData_3\"") + self.runCmd( + "type summary add --summary-string \"Level 4\" \"DeepData_4\"") + self.runCmd( + "type summary add --summary-string \"Level 5\" \"DeepData_5\"") + # Default case, just print out summaries self.expect('frame variable', - substrs = ['(DeepData_1) data1 = Level 1', - '(DeepData_2) data2 = Level 2 {', - 'm_child1 = Level 3', - 'm_child2 = Level 3', - 'm_child3 = Level 3', - 'm_child4 = Level 3', - '}']) + substrs=['(DeepData_1) data1 = Level 1', + '(DeepData_2) data2 = Level 2 {', + 'm_child1 = Level 3', + 'm_child2 = Level 3', + 'm_child3 = Level 3', + 'm_child4 = Level 3', + '}']) # Skip the default (should be 1) levels of summaries self.expect('frame variable --no-summary-depth', - substrs = ['(DeepData_1) data1 = {', - 'm_child1 = 0x', - '}', - '(DeepData_2) data2 = {', - 'm_child1 = Level 3', - 'm_child2 = Level 3', - 'm_child3 = Level 3', - 'm_child4 = Level 3', - '}']) + substrs=['(DeepData_1) data1 = {', + 'm_child1 = 0x', + '}', + '(DeepData_2) data2 = {', + 'm_child1 = Level 3', + 'm_child2 = Level 3', + 'm_child3 = Level 3', + 'm_child4 = Level 3', + '}']) # Now skip 2 levels of summaries self.expect('frame variable --no-summary-depth=2', - substrs = ['(DeepData_1) data1 = {', - 'm_child1 = 0x', - '}', - '(DeepData_2) data2 = {', - 'm_child1 = {', - 'm_child1 = 0x', - 'Level 4', - 'm_child2 = {', - 'm_child3 = {', - '}']) + substrs=['(DeepData_1) data1 = {', + 'm_child1 = 0x', + '}', + '(DeepData_2) data2 = {', + 'm_child1 = {', + 'm_child1 = 0x', + 'Level 4', + 'm_child2 = {', + 'm_child3 = {', + '}']) # Check that no "Level 3" comes out - self.expect('frame variable data1.m_child1 --no-summary-depth=2', matching=False, - substrs = ['Level 3']) + self.expect( + 'frame variable data1.m_child1 --no-summary-depth=2', + matching=False, + substrs=['Level 3']) # Now expand a pointer with 2 level of skipped summaries self.expect('frame variable data1.m_child1 --no-summary-depth=2', - substrs = ['(DeepData_2 *) data1.m_child1 = 0x']) + substrs=['(DeepData_2 *) data1.m_child1 = 0x']) # Deref and expand said pointer self.expect('frame variable *data1.m_child1 --no-summary-depth=2', - substrs = ['(DeepData_2) *data1.m_child1 = {', - 'm_child2 = {', - 'm_child1 = 0x', - 'Level 4', - '}']) + substrs=['(DeepData_2) *data1.m_child1 = {', + 'm_child2 = {', + 'm_child1 = 0x', + 'Level 4', + '}']) # Expand an expression, skipping 2 layers of summaries - self.expect('frame variable data1.m_child1->m_child2 --no-summary-depth=2', - substrs = ['(DeepData_3) data1.m_child1->m_child2 = {', - 'm_child2 = {', - 'm_child1 = Level 5', - 'm_child2 = Level 5', - 'm_child3 = Level 5', - '}']) + self.expect( + 'frame variable data1.m_child1->m_child2 --no-summary-depth=2', + substrs=[ + '(DeepData_3) data1.m_child1->m_child2 = {', + 'm_child2 = {', + 'm_child1 = Level 5', + 'm_child2 = Level 5', + 'm_child3 = Level 5', + '}']) # Expand same expression, skipping only 1 layer of summaries - self.expect('frame variable data1.m_child1->m_child2 --no-summary-depth=1', - substrs = ['(DeepData_3) data1.m_child1->m_child2 = {', - 'm_child1 = 0x', - 'Level 4', - 'm_child2 = Level 4', - '}']) + self.expect( + 'frame variable data1.m_child1->m_child2 --no-summary-depth=1', + substrs=[ + '(DeepData_3) data1.m_child1->m_child2 = {', + 'm_child1 = 0x', + 'Level 4', + 'm_child2 = Level 4', + '}']) # Bad debugging info on SnowLeopard gcc (Apple Inc. build 5666). # Skip the following tests if the condition is met. if self.getCompiler().endswith('gcc') and not self.getCompiler().endswith('llvm-gcc'): - import re - gcc_version_output = system([[lldbutil.which(self.getCompiler()), "-v"]])[1] - #print("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) - if m: - gcc_build = int(m.group(1)) - #print("gcc build:", gcc_build) - if gcc_build >= 5666: - # rdar://problem/9804600" - self.skipTest("rdar://problem/9804600 wrong namespace for std::string in debug info") + import re + gcc_version_output = system( + [[lldbutil.which(self.getCompiler()), "-v"]])[1] + #print("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) + if m: + gcc_build = int(m.group(1)) + #print("gcc build:", gcc_build) + if gcc_build >= 5666: + # rdar://problem/9804600" + self.skipTest( + "rdar://problem/9804600 wrong namespace for std::string in debug info") # Expand same expression, skipping 3 layers of summaries - self.expect('frame variable data1.m_child1->m_child2 --show-types --no-summary-depth=3', - substrs = ['(DeepData_3) data1.m_child1->m_child2 = {', - 'm_some_text = "Just a test"', - 'm_child2 = {', - 'm_some_text = "Just a test"']) - - # Expand within a standard string (might depend on the implementation of the C++ stdlib you use) - self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=2', - substrs = ['(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', - 'm_some_text = {', - '_M_dataplus = (_M_p = "Just a test")']) + self.expect( + 'frame variable data1.m_child1->m_child2 --show-types --no-summary-depth=3', + substrs=[ + '(DeepData_3) data1.m_child1->m_child2 = {', + 'm_some_text = "Just a test"', + 'm_child2 = {', + 'm_some_text = "Just a test"']) + + # Expand within a standard string (might depend on the implementation + # of the C++ stdlib you use) + self.expect( + 'frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=2', + substrs=[ + '(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', + 'm_some_text = {', + '_M_dataplus = (_M_p = "Just a test")']) # Repeat the above, but only skip 1 level of summaries - self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=1', - substrs = ['(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', - 'm_some_text = "Just a test"', - '}']) - - # Change summary and expand, first without --no-summary-depth then with --no-summary-depth - self.runCmd("type summary add --summary-string \"${var.m_some_text}\" DeepData_5") - - self.expect('fr var data2.m_child4.m_child2.m_child2', - substrs = ['(DeepData_5) data2.m_child4.m_child2.m_child2 = "Just a test"']) - - self.expect('fr var data2.m_child4.m_child2.m_child2 --no-summary-depth', - substrs = ['(DeepData_5) data2.m_child4.m_child2.m_child2 = {', - 'm_some_text = "Just a test"', - '}']) + self.expect( + 'frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=1', + substrs=[ + '(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', + 'm_some_text = "Just a test"', + '}']) + + # Change summary and expand, first without --no-summary-depth then with + # --no-summary-depth + self.runCmd( + "type summary add --summary-string \"${var.m_some_text}\" DeepData_5") + + self.expect('fr var data2.m_child4.m_child2.m_child2', substrs=[ + '(DeepData_5) data2.m_child4.m_child2.m_child2 = "Just a test"']) + + self.expect( + 'fr var data2.m_child4.m_child2.m_child2 --no-summary-depth', + substrs=[ + '(DeepData_5) data2.m_child4.m_child2.m_child2 = {', + 'm_some_text = "Just a test"', + '}']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py index b3f8ba7d048..9e82f11ff36 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py @@ -5,18 +5,21 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class SmartArrayDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Test data formatter commands.""" self.build() @@ -32,7 +35,8 @@ class SmartArrayDataFormatterTestCase(TestBase): """Test that that file and class static variables display correctly.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -40,9 +44,9 @@ class SmartArrayDataFormatterTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - + substrs=['stopped', + 'stop reason = breakpoint']) + # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): @@ -56,338 +60,400 @@ class SmartArrayDataFormatterTestCase(TestBase): self.runCmd("type summary add --summary-string \"${var%V}\" SomeData") self.expect("frame variable data", - substrs = ['SomeData @ 0x']) + substrs=['SomeData @ 0x']) # ${var%s} - self.runCmd("type summary add --summary-string \"ptr = ${var%s}\" \"char *\"") + self.runCmd( + "type summary add --summary-string \"ptr = ${var%s}\" \"char *\"") self.expect("frame variable strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("frame variable other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) - - self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\"") - + substrs=['ptr = \"', + 'Nested Hello world!']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\"") + self.expect("frame variable strarr", - substrs = ['arr = \"', - 'Hello world!']) - + substrs=['arr = \"', + 'Hello world!']) + self.expect("frame variable other.strarr", - substrs = ['arr = \"', - 'Nested Hello world!']) + substrs=['arr = \"', + 'Nested Hello world!']) self.expect("p strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("p other.strarr", - substrs = ['arr = \"', - 'Nested Hello world!']) + substrs=['arr = \"', + 'Nested Hello world!']) # ${var%c} - self.runCmd("type summary add --summary-string \"ptr = ${var%c}\" \"char *\"") - + self.runCmd( + "type summary add --summary-string \"ptr = ${var%c}\" \"char *\"") + self.expect("frame variable strptr", - substrs = ['ptr = \"', - 'Hello world!']) - + substrs=['ptr = \"', + 'Hello world!']) + self.expect("frame variable other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) self.expect("p strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("p other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) - self.runCmd("type summary add --summary-string \"arr = ${var%c}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%c}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("frame variable other.strarr", - substrs = ['arr = \"', - 'Nested Hello world!']) - + substrs=['arr = \"', + 'Nested Hello world!']) + self.expect("p strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("p other.strarr", - substrs = ['arr = \"', - 'Nested Hello world!']) + substrs=['arr = \"', + 'Nested Hello world!']) # ${var%char[]} - self.runCmd("type summary add --summary-string \"arr = ${var%char[]}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%char[]}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("frame variable other.strarr", - substrs = ['arr = ', - 'Nested Hello world!']) + substrs=['arr = ', + 'Nested Hello world!']) self.expect("p strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("p other.strarr", - substrs = ['arr = ', - 'Nested Hello world!']) + substrs=['arr = ', + 'Nested Hello world!']) - self.runCmd("type summary add --summary-string \"ptr = ${var%char[]}\" \"char *\"") + self.runCmd( + "type summary add --summary-string \"ptr = ${var%char[]}\" \"char *\"") self.expect("frame variable strptr", - substrs = ['ptr = \"', - 'Hello world!']) - + substrs=['ptr = \"', + 'Hello world!']) + self.expect("frame variable other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) self.expect("p strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("p other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) # ${var%a} - self.runCmd("type summary add --summary-string \"arr = ${var%a}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%a}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("frame variable other.strarr", - substrs = ['arr = ', - 'Nested Hello world!']) + substrs=['arr = ', + 'Nested Hello world!']) self.expect("p strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("p other.strarr", - substrs = ['arr = ', - 'Nested Hello world!']) + substrs=['arr = ', + 'Nested Hello world!']) - self.runCmd("type summary add --summary-string \"ptr = ${var%a}\" \"char *\"") + self.runCmd( + "type summary add --summary-string \"ptr = ${var%a}\" \"char *\"") self.expect("frame variable strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("frame variable other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) self.expect("p strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("p other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) + + self.runCmd( + "type summary add --summary-string \"ptr = ${var[]%char[]}\" \"char *\"") - self.runCmd("type summary add --summary-string \"ptr = ${var[]%char[]}\" \"char *\"") - # I do not know the size of the data, but you are asking for a full array slice.. # use the ${var%char[]} to obtain a string as result self.expect("frame variable strptr", matching=False, - substrs = ['ptr = \"', - 'Hello world!']) - + substrs=['ptr = \"', + 'Hello world!']) + self.expect("frame variable other.strptr", matching=False, - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) self.expect("p strptr", matching=False, - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("p other.strptr", matching=False, - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) # You asked an array-style printout... - self.runCmd("type summary add --summary-string \"ptr = ${var[0-1]%char[]}\" \"char *\"") - + self.runCmd( + "type summary add --summary-string \"ptr = ${var[0-1]%char[]}\" \"char *\"") + self.expect("frame variable strptr", - substrs = ['ptr = ', - '[{H},{e}]']) - + substrs=['ptr = ', + '[{H},{e}]']) + self.expect("frame variable other.strptr", - substrs = ['ptr = ', - '[{N},{e}]']) + substrs=['ptr = ', + '[{N},{e}]']) self.expect("p strptr", - substrs = ['ptr = ', - '[{H},{e}]']) + substrs=['ptr = ', + '[{H},{e}]']) self.expect("p other.strptr", - substrs = ['ptr = ', - '[{N},{e}]']) + substrs=['ptr = ', + '[{N},{e}]']) # using [] is required here - self.runCmd("type summary add --summary-string \"arr = ${var%x}\" \"int [5]\"") - - self.expect("frame variable intarr",matching=False, - substrs = ['0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) - - self.expect("frame variable other.intarr", matching=False, - substrs = ['0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) - - self.runCmd("type summary add --summary-string \"arr = ${var[]%x}\" \"int [5]\"") - - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) - - self.expect("frame variable other.intarr", - substrs = ['intarr = arr =', - '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) + self.runCmd( + "type summary add --summary-string \"arr = ${var%x}\" \"int [5]\"") + + self.expect("frame variable intarr", matching=False, substrs=[ + '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) + + self.expect("frame variable other.intarr", matching=False, substrs=[ + '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var[]%x}\" \"int [5]\"") + + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) + + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr =', + '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) # printing each array item as an array - self.runCmd("type summary add --summary-string \"arr = ${var[]%uint32_t[]}\" \"int [5]\"") - - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '{0x00000001},{0x00000001},{0x00000002},{0x00000003},{0x00000005}']) - - self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '{0x00000009},{0x00000008},{0x00000007},{0x00000006},{0x00000005}']) + self.runCmd( + "type summary add --summary-string \"arr = ${var[]%uint32_t[]}\" \"int [5]\"") + + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '{0x00000001},{0x00000001},{0x00000002},{0x00000003},{0x00000005}']) + + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr = ', + '{0x00000009},{0x00000008},{0x00000007},{0x00000006},{0x00000005}']) # printing full array as an array - self.runCmd("type summary add --summary-string \"arr = ${var%uint32_t[]}\" \"int [5]\"") - - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) + self.runCmd( + "type summary add --summary-string \"arr = ${var%uint32_t[]}\" \"int [5]\"") - self.expect("frame variable other.intarr", - substrs = ['intarr = arr =', - '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) + + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr =', + '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) # printing each array item as an array - self.runCmd("type summary add --summary-string \"arr = ${var[]%float32[]}\" \"float [7]\"") - - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '{78.5},{77.25},{78},{76.125},{76.75},{76.875},{77}']) - - self.expect("frame variable other.flarr", - substrs = ['flarr = arr = ', - '{25.5},{25.25},{25.125},{26.75},{27.375},{27.5},{26.125}']) - + self.runCmd( + "type summary add --summary-string \"arr = ${var[]%float32[]}\" \"float [7]\"") + + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '{78.5},{77.25},{78},{76.125},{76.75},{76.875},{77}']) + + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr = ', + '{25.5},{25.25},{25.125},{26.75},{27.375},{27.5},{26.125}']) + # printing full array as an array - self.runCmd("type summary add --summary-string \"arr = ${var%float32[]}\" \"float [7]\"") - + self.runCmd( + "type summary add --summary-string \"arr = ${var%float32[]}\" \"float [7]\"") + self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '78.5,77.25,78,76.125,76.75,76.875,77']) - + substrs=['flarr = arr =', + '78.5,77.25,78,76.125,76.75,76.875,77']) + self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '25.5,25.25,25.125,26.75,27.375,27.5,26.125']) + substrs=['flarr = arr =', + '25.5,25.25,25.125,26.75,27.375,27.5,26.125']) # using array smart summary strings for pointers should make no sense - self.runCmd("type summary add --summary-string \"arr = ${var%float32[]}\" \"float *\"") - self.runCmd("type summary add --summary-string \"arr = ${var%int32_t[]}\" \"int *\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%float32[]}\" \"float *\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%int32_t[]}\" \"int *\"") self.expect("frame variable flptr", matching=False, - substrs = ['78.5,77.25,78,76.125,76.75,76.875,77']) - + substrs=['78.5,77.25,78,76.125,76.75,76.875,77']) + self.expect("frame variable intptr", matching=False, - substrs = ['1,1,2,3,5']) + substrs=['1,1,2,3,5']) # use y and Y - self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"float [7]\"") - self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"int [5]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%y}\" \"float [7]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%y}\" \"int [5]\"") if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '00 00 9d 42,00 80 9a 42,00 00 9c 42,00 40 98 42,00 80 99 42,00 c0 99 42,00 00 9a 42']) + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '00 00 9d 42,00 80 9a 42,00 00 9c 42,00 40 98 42,00 80 99 42,00 c0 99 42,00 00 9a 42']) else: - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '42 9d 00 00,42 9a 80 00,42 9c 00 00,42 98 40 00,42 99 80 00,42 99 c0 00,42 9a 00 00']) + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '42 9d 00 00,42 9a 80 00,42 9c 00 00,42 98 40 00,42 99 80 00,42 99 c0 00,42 9a 00 00']) if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '00 00 cc 41,00 00 ca 41,00 00 c9 41,00 00 d6 41,00 00 db 41,00 00 dc 41,00 00 d1 41']) + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr =', + '00 00 cc 41,00 00 ca 41,00 00 c9 41,00 00 d6 41,00 00 db 41,00 00 dc 41,00 00 d1 41']) else: - self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '41 cc 00 00,41 ca 00 00,41 c9 00 00,41 d6 00 00,41 db 00 00,41 dc 00 00,41 d1 00 00']) + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr =', + '41 cc 00 00,41 ca 00 00,41 c9 00 00,41 d6 00 00,41 db 00 00,41 dc 00 00,41 d1 00 00']) if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '01 00 00 00,01 00 00 00,02 00 00 00,03 00 00 00,05 00 00 00']) + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '01 00 00 00,01 00 00 00,02 00 00 00,03 00 00 00,05 00 00 00']) else: - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '00 00 00 01,00 00 00 01,00 00 00 02,00 00 00 03,00 00 00 05']) + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '00 00 00 01,00 00 00 01,00 00 00 02,00 00 00 03,00 00 00 05']) if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '09 00 00 00,08 00 00 00,07 00 00 00,06 00 00 00,05 00 00 00']) + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr = ', + '09 00 00 00,08 00 00 00,07 00 00 00,06 00 00 00,05 00 00 00']) else: - self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '00 00 00 09,00 00 00 08,00 00 00 07,00 00 00 06,00 00 00 05']) - - self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"float [7]\"") - self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"int [5]\"") - + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr = ', + '00 00 00 09,00 00 00 08,00 00 00 07,00 00 00 06,00 00 00 05']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var%Y}\" \"float [7]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%Y}\" \"int [5]\"") + if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '00 00 9d 42 ...B,00 80 9a 42 ...B,00 00 9c 42 ...B,00 40 98 42 .@.B,00 80 99 42 ...B,00 c0 99 42 ...B,00 00 9a 42 ...B']) + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '00 00 9d 42 ...B,00 80 9a 42 ...B,00 00 9c 42 ...B,00 40 98 42 .@.B,00 80 99 42 ...B,00 c0 99 42 ...B,00 00 9a 42 ...B']) else: - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '42 9d 00 00 B...,42 9a 80 00 B...,42 9c 00 00 B...,42 98 40 00 B.@.,42 99 80 00 B...,42 99 c0 00 B...,42 9a 00 00 B...']) + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '42 9d 00 00 B...,42 9a 80 00 B...,42 9c 00 00 B...,42 98 40 00 B.@.,42 99 80 00 B...,42 99 c0 00 B...,42 9a 00 00 B...']) if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '00 00 cc 41 ...A,00 00 ca 41 ...A,00 00 c9 41 ...A,00 00 d6 41 ...A,00 00 db 41 ...A,00 00 dc 41 ...A,00 00 d1 41 ...A']) + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr =', + '00 00 cc 41 ...A,00 00 ca 41 ...A,00 00 c9 41 ...A,00 00 d6 41 ...A,00 00 db 41 ...A,00 00 dc 41 ...A,00 00 d1 41 ...A']) else: - self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '41 cc 00 00 A...,41 ca 00 00 A...,41 c9 00 00 A...,41 d6 00 00 A...,41 db 00 00 A...,41 dc 00 00 A...,41 d1 00 00 A...']) + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr =', + '41 cc 00 00 A...,41 ca 00 00 A...,41 c9 00 00 A...,41 d6 00 00 A...,41 db 00 00 A...,41 dc 00 00 A...,41 d1 00 00 A...']) if process.GetByteOrder() == lldb.eByteOrderLittle: self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '....,01 00 00 00', - '....,05 00 00 00']) + substrs=['intarr = arr =', + '....,01 00 00 00', + '....,05 00 00 00']) else: self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '....,00 00 00 01', - '....,00 00 00 05']) + substrs=['intarr = arr =', + '....,00 00 00 01', + '....,00 00 00 05']) if process.GetByteOrder() == lldb.eByteOrderLittle: self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '09 00 00 00', - '....,07 00 00 00']) + substrs=['intarr = arr = ', + '09 00 00 00', + '....,07 00 00 00']) else: self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '00 00 00 09', - '....,00 00 00 07']) + substrs=['intarr = arr = ', + '00 00 00 09', + '....,00 00 00 07']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py index 083f713c259..2b63dbb1c83 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibCxxAtomicTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,30 +24,39 @@ class LibCxxAtomicTestCase(TestBase): return var @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test(self): """Test that std::atomic as defined by libc++ is correctly printed by LLDB""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - + substrs=['stopped', + 'stop reason = breakpoint']) + s = self.get_variable('s') i = self.get_variable('i') - - if self.TraceOn(): print(s) - if self.TraceOn(): print(i) - + + if self.TraceOn(): + print(s) + if self.TraceOn(): + print(i) + self.assertTrue(i.GetValueAsUnsigned(0) == 5, "i == 5") self.assertTrue(s.GetNumChildren() == 2, "s has two children") - self.assertTrue(s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1, "s.x == 1") - self.assertTrue(s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2, "s.y == 2") + self.assertTrue( + s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1, + "s.x == 1") + self.assertTrue( + s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2, + "s.y == 2") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py index a5eec8a0362..6a832e02990 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibCxxFunctionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,28 +24,33 @@ class LibCxxFunctionTestCase(TestBase): return var @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test(self): """Test that std::function as defined by libc++ is correctly printed by LLDB""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - + substrs=['stopped', + 'stop reason = breakpoint']) + f1 = self.get_variable('f1') f2 = self.get_variable('f2') - - if self.TraceOn(): print(f1) - if self.TraceOn(): print(f2) - + + if self.TraceOn(): + print(f1) + if self.TraceOn(): + print(f2) + self.assertTrue(f1.GetValueAsUnsigned(0) != 0, 'f1 has a valid value') self.assertTrue(f2.GetValueAsUnsigned(0) != 0, 'f2 has a valid value') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py index d452c1be69b..f0857f420fc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py @@ -5,37 +5,44 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class InitializerListTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @skipIf(compiler="gcc") - @expectedFailureAll(oslist=["linux"], bugnumber="fails on clang 3.5 and tot") + @expectedFailureAll( + oslist=["linux"], + bugnumber="fails on clang 3.5 and tot") def test(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) - self.expect("frame variable ili", substrs = ['[1] = 2','[4] = 5']) - self.expect("frame variable ils", substrs = ['[4] = "surprise it is a long string!! yay!!"']) + self.expect("frame variable ili", substrs=['[1] = 2', '[4] = 5']) + self.expect("frame variable ils", substrs=[ + '[4] = "surprise it is a long string!! yay!!"']) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py index 23f6956cf3f..cbcdc2ce739 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxIteratorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,22 +24,24 @@ class LibcxxIteratorDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that libc++ iterators format properly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,21 +50,31 @@ class LibcxxIteratorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) - self.expect('frame variable ivI', substrs = ['item = 3']) - self.expect('expr ivI', substrs = ['item = 3']) + self.expect('frame variable ivI', substrs=['item = 3']) + self.expect('expr ivI', substrs=['item = 3']) - self.expect('frame variable iimI', substrs = ['first = 0','second = 12']) - self.expect('expr iimI', substrs = ['first = 0','second = 12']) + self.expect( + 'frame variable iimI', + substrs=[ + 'first = 0', + 'second = 12']) + self.expect('expr iimI', substrs=['first = 0', 'second = 12']) - self.expect('frame variable simI', substrs = ['first = "world"','second = 42']) - self.expect('expr simI', substrs = ['first = "world"','second = 42']) + self.expect( + 'frame variable simI', + substrs=[ + 'first = "world"', + 'second = 42']) + self.expect('expr simI', substrs=['first = "world"', 'second = 42']) - self.expect('frame variable svI', substrs = ['item = "hello"']) - self.expect('expr svI', substrs = ['item = "hello"']) + self.expect('frame variable svI', substrs=['item = "hello"']) + self.expect('expr svI', substrs=['item = "hello"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py index 6fcdc37465d..61101411f65 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py @@ -5,13 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time, re +import os +import time +import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,31 +23,39 @@ class LibcxxListDataFormatterTestCase(TestBase): TestBase.setUp(self) # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - self.line2 = line_number('main.cpp', '// Set second break point at this line.') - self.line3 = line_number('main.cpp', '// Set third break point at this line.') - self.line4 = line_number('main.cpp', '// Set fourth break point at this line.') + self.line2 = line_number('main.cpp', + '// Set second break point at this line.') + self.line3 = line_number('main.cpp', + '// Set third break point at this line.') + self.line4 = line_number('main.cpp', + '// Set fourth break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @expectedFailureAll(oslist=["macosx"], bugnumber="rdar://25499635") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line2, num_expected_locations=-1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line3, num_expected_locations=-1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line4, num_expected_locations=-1) + + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line2, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line3, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line4, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -54,135 +64,154 @@ class LibcxxListDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) self.runCmd("frame variable numbers_list --show-types") - self.runCmd("type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e") + self.runCmd( + "type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e") self.runCmd("type format add -f hex int") self.expect("frame variable numbers_list --raw", matching=False, - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) self.expect("frame variable numbers_list", - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) self.expect("p numbers_list", - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['list has 1 items', - '[0] = ', - '0x12345678']) + substrs=['list has 1 items', + '[0] = ', + '0x12345678']) - self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['list has 4 items', - '[0] = ', - '0x12345678', - '[1] =', - '0x11223344', - '[2] =', - '0xbeeffeed', - '[3] =', - '0x00abba00']) - - self.runCmd("n");self.runCmd("n"); + substrs=['list has 4 items', + '[0] = ', + '0x12345678', + '[1] =', + '0x11223344', + '[2] =', + '0xbeeffeed', + '[3] =', + '0x00abba00']) + + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['list has 6 items', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['list has 6 items', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) self.expect("p numbers_list", - substrs = ['list has 6 items', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['list has 6 items', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) # check access-by-index self.expect("frame variable numbers_list[0]", - substrs = ['0x12345678']); + substrs=['0x12345678']) self.expect("frame variable numbers_list[1]", - substrs = ['0x11223344']); + substrs=['0x11223344']) self.runCmd("n") - + self.expect("frame variable numbers_list", - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) + + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); - self.expect("frame variable numbers_list", - substrs = ['list has 4 items', - '[0] = ', '1', - '[1] = ', '2', - '[2] = ', '3', - '[3] = ', '4']) + substrs=['list has 4 items', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("numbers_list").MightHaveChildren(), + "numbers_list.MightHaveChildren() says False for non empty!") self.runCmd("type format delete int") self.runCmd("c") self.expect("frame variable text_list", - substrs = ['list has 3 items', - '[0]', 'goofy', - '[1]', 'is', - '[2]', 'smart']) + substrs=['list has 3 items', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("text_list").MightHaveChildren(), + "text_list.MightHaveChildren() says False for non empty!") self.expect("p text_list", - substrs = ['list has 3 items', - '\"goofy\"', - '\"is\"', - '\"smart\"']) - + substrs=['list has 3 items', + '\"goofy\"', + '\"is\"', + '\"smart\"']) + self.runCmd("n") # check access-by-index self.expect("frame variable text_list[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable text_list[3]", - substrs = ['!!!']); - + substrs=['!!!']) + self.runCmd("continue") - + # check that the list provider correctly updates if elements move countingList = self.frame().FindVariable("countingList") countingList.SetPreferDynamicValue(True) countingList.SetPreferSyntheticValue(True) - - self.assertTrue(countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, "list[0] == 3141") - self.assertTrue(countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3141, "list[1] == 3141") - + + self.assertTrue(countingList.GetChildAtIndex( + 0).GetValueAsUnsigned(0) == 3141, "list[0] == 3141") + self.assertTrue(countingList.GetChildAtIndex( + 1).GetValueAsUnsigned(0) == 3141, "list[1] == 3141") + self.runCmd("continue") - self.assertTrue(countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, "uniqued list[0] == 3141") - self.assertTrue(countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3142, "uniqued list[1] == 3142") + self.assertTrue( + countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, + "uniqued list[0] == 3141") + self.assertTrue( + countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3142, + "uniqued list[1] == 3142") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py index 9e68e1dbc00..e2e082c795f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py @@ -6,19 +6,21 @@ corruption). from __future__ import print_function - -import os, time, re +import os +import time +import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @add_test_categories(["pyapi"]) @skipIfDarwin # rdar://25499635 def test_with_run_command(self): @@ -27,29 +29,47 @@ class LibcxxListDataFormatterTestCase(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target and target.IsValid(), "Target is valid") - file_spec = lldb.SBFileSpec ("main.cpp", False) - breakpoint1 = target.BreakpointCreateBySourceRegex('// Set break point at this line.', file_spec) + file_spec = lldb.SBFileSpec("main.cpp", False) + breakpoint1 = target.BreakpointCreateBySourceRegex( + '// Set break point at this line.', file_spec) self.assertTrue(breakpoint1 and breakpoint1.IsValid()) - breakpoint2 = target.BreakpointCreateBySourceRegex('// Set second break point at this line.', file_spec) + breakpoint2 = target.BreakpointCreateBySourceRegex( + '// Set second break point at this line.', file_spec) self.assertTrue(breakpoint2 and breakpoint2.IsValid()) # Run the program, it should stop at breakpoint 1. - process = target.LaunchSimple(None, None, self.get_process_working_directory()) - lldbutil.skip_if_library_missing(self, target, lldbutil.PrintableRegex("libc\+\+")) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) + lldbutil.skip_if_library_missing( + self, target, lldbutil.PrintableRegex("libc\+\+")) self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) - self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1) + self.assertEqual( + len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1) # verify our list is displayed correctly - self.expect("frame variable *numbers_list", substrs=['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4', '[5] = 6']) + self.expect( + "frame variable *numbers_list", + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3', + '[3] = 4', + '[5] = 6']) # Continue to breakpoint 2. process.Continue() self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) - self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)), 1) + self.assertEqual( + len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)), 1) # The list is now inconsistent. However, we should be able to get the first three # elements at least (and most importantly, not crash). - self.expect("frame variable *numbers_list", substrs=['[0] = 1', '[1] = 2', '[2] = 3']) + self.expect( + "frame variable *numbers_list", + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3']) # Run to completion. process.Continue() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py index cecc3178b31..7433a0b0da2 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py @@ -5,34 +5,38 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,259 +45,269 @@ class LibcxxMapDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) - + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=2', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + substrs=['size=2', + '[0] = ', + 'first = 0', + 'second = 0', + '[1] = ', + 'first = 1', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=4', - '[2] = ', - 'first = 2', - 'second = 0', - '[3] = ', - 'first = 3', - 'second = 1']) + substrs=['size=4', + '[2] = ', + 'first = 2', + 'second = 0', + '[3] = ', + 'first = 3', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) self.expect("p ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) # check access-by-index self.expect("frame variable ii[0]", - substrs = ['first = 0', - 'second = 0']); + substrs=['first = 0', + 'second = 0']) self.expect("frame variable ii[3]", - substrs = ['first =', - 'second =']); + substrs=['first =', + 'second =']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ii").MightHaveChildren(), + "ii.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ii[8]", matching=False, error=True, + # self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) - self.runCmd("continue"); - + self.runCmd("continue") + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) - self.runCmd("continue"); + self.runCmd("continue") self.expect('frame variable si', - substrs = ['size=1', - '[0] = ', - 'first = \"zero\"', - 'second = 0']) + substrs=['size=1', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) self.expect("p si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("si").MightHaveChildren(), + "si.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'one', - 'second = 1']); - + substrs=['first = ', 'one', + 'second = 1']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression si[0]", matching=False, error=True, + # self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + self.expect("p is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("is").MightHaveChildren(), + "is.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable is[0]", - substrs = ['first = ', - 'second =']); - + substrs=['first = ', + 'second =']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression is[0]", matching=False, error=True, + # self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) - + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) + self.expect("p ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ss").MightHaveChildren(), + "ss.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable ss[2]", - substrs = ['gatto', 'cat']); - + substrs=['gatto', 'cat']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ss[3]", matching=False, error=True, + # self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py index eb74818c91f..66091e6e113 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py @@ -5,35 +5,39 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxMultiMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @skipIf(compiler="gcc") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -42,259 +46,269 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) - + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=2', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + substrs=['size=2', + '[0] = ', + 'first = 0', + 'second = 0', + '[1] = ', + 'first = 1', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=4', - '[2] = ', - 'first = 2', - 'second = 0', - '[3] = ', - 'first = 3', - 'second = 1']) + substrs=['size=4', + '[2] = ', + 'first = 2', + 'second = 0', + '[3] = ', + 'first = 3', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) self.expect("p ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) # check access-by-index self.expect("frame variable ii[0]", - substrs = ['first = 0', - 'second = 0']); + substrs=['first = 0', + 'second = 0']) self.expect("frame variable ii[3]", - substrs = ['first =', - 'second =']); + substrs=['first =', + 'second =']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ii").MightHaveChildren(), + "ii.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ii[8]", matching=False, error=True, + # self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable si', - substrs = ['size=1', - '[0] = ', - 'first = \"zero\"', - 'second = 0']) + substrs=['size=1', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) self.expect("p si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("si").MightHaveChildren(), + "si.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'one', - 'second = 1']); - + substrs=['first = ', 'one', + 'second = 1']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression si[0]", matching=False, error=True, + # self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + self.expect("p is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("is").MightHaveChildren(), + "is.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable is[0]", - substrs = ['first = ', - 'second =']); - + substrs=['first = ', + 'second =']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression is[0]", matching=False, error=True, + # self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) - + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) + self.expect("p ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ss").MightHaveChildren(), + "ss.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable ss[2]", - substrs = ['gatto', 'cat']); - + substrs=['gatto', 'cat']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ss[3]", matching=False, error=True, + # self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py index cfdfd07ddec..d40bce83e0a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py @@ -5,34 +5,38 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxMultiSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,30 +45,78 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) - self.expect("frame variable ii",substrs = ["size=0","{}"]) + self.expect("frame variable ii", substrs=["size=0", "{}"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=6","[0] = 0","[1] = 1", "[2] = 2", "[3] = 3", "[4] = 4", "[5] = 5"]) + self.expect( + "frame variable ii", + substrs=[ + "size=6", + "[0] = 0", + "[1] = 1", + "[2] = 2", + "[3] = 3", + "[4] = 4", + "[5] = 5"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"]) - self.expect("p ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"]) - self.expect("frame variable ii[2]",substrs = [" = 2"]) + self.expect( + "frame variable ii", + substrs=[ + "size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + self.expect( + "p ii", + substrs=[ + "size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + self.expect("frame variable ii[2]", substrs=[" = 2"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=0","{}"]) + self.expect("frame variable ii", substrs=["size=0", "{}"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=0","{}"]) - self.expect("frame variable ss",substrs = ["size=0","{}"]) + self.expect("frame variable ii", substrs=["size=0", "{}"]) + self.expect("frame variable ss", substrs=["size=0", "{}"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss",substrs = ["size=2",'[0] = "a"','[1] = "a very long string is right here"']) + self.expect( + "frame variable ss", + substrs=[ + "size=2", + '[0] = "a"', + '[1] = "a very long string is right here"']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) - self.expect("p ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) - self.expect("frame variable ss[2]",substrs = [' = "b"']) + self.expect( + "frame variable ss", + substrs=[ + "size=4", + '[2] = "b"', + '[3] = "c"', + '[0] = "a"', + '[1] = "a very long string is right here"']) + self.expect( + "p ss", + substrs=[ + "size=4", + '[2] = "b"', + '[3] = "c"', + '[0] = "a"', + '[1] = "a very long string is right here"']) + self.expect("frame variable ss[2]", substrs=[' = "b"']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss",substrs = ["size=3",'[0] = "a"','[1] = "a very long string is right here"','[2] = "c"']) + self.expect( + "frame variable ss", + substrs=[ + "size=3", + '[0] = "a"', + '[1] = "a very long string is right here"', + '[2] = "c"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py index 00c1e548cf6..be1547ea5d8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py @@ -5,24 +5,25 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - + # bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py index 76eedb8c891..b0e84121dde 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py @@ -1,4 +1,4 @@ -#coding=utf8 +# coding=utf8 """ Test lldb data formatter subsystem. """ @@ -6,13 +6,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxStringDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,22 +25,24 @@ class LibcxxStringDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,40 +51,51 @@ class LibcxxStringDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect("frame variable", - substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"', - '(std::__1::wstring) S = L"!!!!"', - '(const wchar_t *) mazeltov = 0x','L"מזל טוב"', - '(std::__1::string) q = "hello world"', - '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', - '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', - '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) + self.expect( + "frame variable", + substrs=[ + '(std::__1::wstring) s = L"hello world! מזל טוב!"', + '(std::__1::wstring) S = L"!!!!"', + '(const wchar_t *) mazeltov = 0x', + 'L"מזל טוב"', + '(std::__1::string) q = "hello world"', + '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', + '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', + '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) self.runCmd("n") - TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne"); + TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne") summaryOptions = lldb.SBTypeSummaryOptions() summaryOptions.SetCapping(lldb.eTypeSummaryUncapped) uncappedSummaryStream = lldb.SBStream() - TheVeryLongOne.GetSummary(uncappedSummaryStream,summaryOptions) + TheVeryLongOne.GetSummary(uncappedSummaryStream, summaryOptions) uncappedSummary = uncappedSummaryStream.GetData() - self.assertTrue(uncappedSummary.find("someText") > 0, "uncappedSummary does not include the full string") + self.assertTrue(uncappedSummary.find("someText") > 0, + "uncappedSummary does not include the full string") summaryOptions.SetCapping(lldb.eTypeSummaryCapped) cappedSummaryStream = lldb.SBStream() - TheVeryLongOne.GetSummary(cappedSummaryStream,summaryOptions) + TheVeryLongOne.GetSummary(cappedSummaryStream, summaryOptions) cappedSummary = cappedSummaryStream.GetData() - self.assertTrue(cappedSummary.find("someText") <= 0, "cappedSummary includes the full string") - - self.expect("frame variable", - substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"', - '(std::__1::wstring) S = L"!!!!!"', - '(const wchar_t *) mazeltov = 0x','L"מזל טוב"', - '(std::__1::string) q = "hello world"', - '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', - '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', - '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) + self.assertTrue( + cappedSummary.find("someText") <= 0, + "cappedSummary includes the full string") + + self.expect( + "frame variable", + substrs=[ + '(std::__1::wstring) s = L"hello world! מזל טוב!"', + '(std::__1::wstring) S = L"!!!!!"', + '(const wchar_t *) mazeltov = 0x', + 'L"מזל טוב"', + '(std::__1::string) q = "hello world"', + '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', + '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', + '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py index 4765cd70f67..8a08d38975c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py @@ -5,34 +5,37 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxUnorderedDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @skipIf(compiler="gcc") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,12 +44,14 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) self.look_for_content_and_continue( "map", ['size=5 {', 'hello', 'world', 'this', 'is', 'me']) @@ -72,6 +77,6 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase): '(\[\d\] = "world"(\\n|.)+){2}']) def look_for_content_and_continue(self, var_name, patterns): - self.expect( ("frame variable %s" % var_name), patterns=patterns) - self.expect( ("frame variable %s" % var_name), patterns=patterns) + self.expect(("frame variable %s" % var_name), patterns=patterns) + self.expect(("frame variable %s" % var_name), patterns=patterns) self.runCmd("continue") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py index fe3b6c115e3..43d5ad4f103 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxVBoolDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,22 +24,24 @@ class LibcxxVBoolDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows. + @skipIfWindows # libc++ not ported to Windows. def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,13 +50,33 @@ class LibcxxVBoolDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect("frame variable vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) - - self.expect("expr vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) + self.expect( + "frame variable vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) + + self.expect( + "expr vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py index 9a145fba73e..719ed730050 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py @@ -5,34 +5,38 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxVectorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "break here")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "break here")) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,51 +45,54 @@ class LibcxxVectorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # empty vectors (and storage pointers SHOULD BOTH BE NULL..) self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 1', - '}']) + substrs=['numbers = size=1', + '[0] = 1', + '}']) # add some more data lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect("frame variable numbers", - substrs = ['numbers = size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) + substrs=['numbers = size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) self.expect("p numbers", - substrs = ['$', 'size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) - - + substrs=['$', 'size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) + # check access to synthetic children - self.runCmd("type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") + self.runCmd( + "type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', - substrs = ['item 0 is 1']); - - self.runCmd("type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") + substrs=['item 0 is 1']) + + self.runCmd( + "type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', - substrs = ['item 0 is 1']); + substrs=['item 0 is 1']) # move on with synths self.runCmd("type summary delete std::int_vect") self.runCmd("type summary delete int_vect") @@ -94,88 +101,89 @@ class LibcxxVectorDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable numbers", - substrs = ['numbers = size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) - + substrs=['numbers = size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) + self.expect("p numbers", - substrs = ['$', 'size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) + substrs=['$', 'size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) # check access-by-index self.expect("frame variable numbers[0]", - substrs = ['1']); + substrs=['1']) self.expect("frame variable numbers[1]", - substrs = ['12']); + substrs=['12']) self.expect("frame variable numbers[2]", - substrs = ['123']); + substrs=['123']) self.expect("frame variable numbers[3]", - substrs = ['1234']); + substrs=['1234']) # clear out the vector and see that we do the right thing once again lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 7', - '}']) + substrs=['numbers = size=1', + '[0] = 7', + '}']) # check if we can display strings self.expect("frame variable strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) # test summaries based on synthetic children - self.runCmd("type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") + self.runCmd( + "type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") self.expect("frame variable strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable strings", - substrs = ['vector has 4 items']) - + substrs=['vector has 4 items']) + # check access-by-index self.expect("frame variable strings[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable strings[1]", - substrs = ['is']); + substrs=['is']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable strings", - substrs = ['vector has 0 items']) + substrs=['vector has 0 items']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py index dbaa37daa2d..53ab11bcc8c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdIteratorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,21 +23,24 @@ class StdIteratorDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") + @skipIfWindows # libstdcpp not ported to Windows + @expectedFailureAll( + compiler="icc", + bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") def test_with_run_command(self): """Test that libstdcpp iterators format properly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,19 +49,29 @@ class StdIteratorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('frame variable ivI', substrs = ['item = 3']) - self.expect('expr ivI', substrs = ['item = 3']) - - self.expect('frame variable iimI', substrs = ['first = 0','second = 12']) - self.expect('expr iimI', substrs = ['first = 0','second = 12']) - - self.expect('frame variable simI', substrs = ['first = "world"','second = 42']) - self.expect('expr simI', substrs = ['first = "world"','second = 42']) - - self.expect('frame variable svI', substrs = ['item = "hello"']) - self.expect('expr svI', substrs = ['item = "hello"']) + self.expect('frame variable ivI', substrs=['item = 3']) + self.expect('expr ivI', substrs=['item = 3']) + + self.expect( + 'frame variable iimI', + substrs=[ + 'first = 0', + 'second = 12']) + self.expect('expr iimI', substrs=['first = 0', 'second = 12']) + + self.expect( + 'frame variable simI', + substrs=[ + 'first = "world"', + 'second = 42']) + self.expect('expr simI', substrs=['first = "world"', 'second = 42']) + + self.expect('frame variable svI', substrs=['item = "hello"']) + self.expect('expr svI', substrs=['item = "hello"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py index 55658af1f2a..a7f8c4b1e17 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,23 +22,26 @@ class StdListDataFormatterTestCase(TestBase): TestBase.setUp(self) # Find the line numbers to break at for the different tests. self.line = line_number('main.cpp', '// Set break point at this line.') - self.optional_line = line_number('main.cpp', '// Optional break point at this line.') - self.final_line = line_number('main.cpp', '// Set final break point at this line.') + self.optional_line = line_number( + 'main.cpp', '// Optional break point at this line.') + self.final_line = line_number( + 'main.cpp', '// Set final break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,7 +50,9 @@ class StdListDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -56,134 +62,148 @@ class StdListDataFormatterTestCase(TestBase): self.runCmd("type format add -f hex int") self.expect("frame variable numbers_list --raw", matching=False, - substrs = ['size=0', - '{}']) - self.expect("frame variable &numbers_list._M_impl._M_node --raw", matching=False, - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) + self.expect( + "frame variable &numbers_list._M_impl._M_node --raw", + matching=False, + substrs=[ + 'size=0', + '{}']) self.expect("frame variable numbers_list", - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.expect("p numbers_list", - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['size=1', - '[0] = ', - '0x12345678']) + substrs=['size=1', + '[0] = ', + '0x12345678']) - self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['size=4', - '[0] = ', - '0x12345678', - '[1] =', - '0x11223344', - '[2] =', - '0xbeeffeed', - '[3] =', - '0x00abba00']) - - self.runCmd("n");self.runCmd("n"); + substrs=['size=4', + '[0] = ', + '0x12345678', + '[1] =', + '0x11223344', + '[2] =', + '0xbeeffeed', + '[3] =', + '0x00abba00']) + + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['size=6', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['size=6', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) self.expect("p numbers_list", - substrs = ['size=6', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['size=6', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) # check access-by-index self.expect("frame variable numbers_list[0]", - substrs = ['0x12345678']); + substrs=['0x12345678']) self.expect("frame variable numbers_list[1]", - substrs = ['0x11223344']); - + substrs=['0x11223344']) + # but check that expression does not rely on us self.expect("expression numbers_list[0]", matching=False, error=True, - substrs = ['0x12345678']) + substrs=['0x12345678']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("numbers_list").MightHaveChildren(), + "numbers_list.MightHaveChildren() says False for non empty!") self.runCmd("n") - + self.expect("frame variable numbers_list", - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) + + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); - self.expect("frame variable numbers_list", - substrs = ['size=4', - '[0] = ', '1', - '[1] = ', '2', - '[2] = ', '3', - '[3] = ', '4']) + substrs=['size=4', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) self.runCmd("type format delete int") self.runCmd("n") - + self.expect("frame variable text_list", - substrs = ['size=0', - '{}']) - - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.final_line, num_expected_locations=-1) + substrs=['size=0', + '{}']) + + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.final_line, num_expected_locations=-1) self.runCmd("c", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) self.expect("frame variable text_list", - substrs = ['size=4', - '[0]', 'goofy', - '[1]', 'is', - '[2]', 'smart', - '[3]', '!!!']) + substrs=['size=4', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart', + '[3]', '!!!']) self.expect("p text_list", - substrs = ['size=4', - '\"goofy\"', - '\"is\"', - '\"smart\"', - '\"!!!\"']) - + substrs=['size=4', + '\"goofy\"', + '\"is\"', + '\"smart\"', + '\"!!!\"']) + # check access-by-index self.expect("frame variable text_list[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable text_list[3]", - substrs = ['!!!']); - + substrs=['!!!']) + # but check that expression does not rely on us self.expect("expression text_list[0]", matching=False, error=True, - substrs = ['goofy']) + substrs=['goofy']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("text_list").MightHaveChildren(), + "text_list.MightHaveChildren() says False for non empty!") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py index ff99255aec0..f5dbadb6958 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,22 +23,25 @@ class StdMapDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") - @skipIfWindows # libstdcpp not ported to Windows + @expectedFailureAll( + compiler="icc", + bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") + @skipIfWindows # libstdcpp not ported to Windows @skipIfFreeBSD def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,278 +50,289 @@ class StdMapDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) self.runCmd("frame variable ii --show-types") - - self.runCmd("type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e") - + + self.runCmd( + "type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e") + self.expect('frame variable ii', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) - self.runCmd("c"); + self.runCmd("c") self.expect('frame variable ii', - substrs = ['map has 2 items', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + substrs=['map has 2 items', + '[0] = ', + 'first = 0', + 'second = 0', + '[1] = ', + 'first = 1', + 'second = 1']) - self.runCmd("c"); + self.runCmd("c") self.expect('frame variable ii', - substrs = ['map has 4 items', - '[2] = ', - 'first = 2', - 'second = 0', - '[3] = ', - 'first = 3', - 'second = 1']) + substrs=['map has 4 items', + '[2] = ', + 'first = 2', + 'second = 0', + '[3] = ', + 'first = 3', + 'second = 1']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable ii", - substrs = ['map has 9 items', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) - + substrs=['map has 9 items', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) + self.expect("p ii", - substrs = ['map has 9 items', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['map has 9 items', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) # check access-by-index self.expect("frame variable ii[0]", - substrs = ['first = 0', - 'second = 0']); + substrs=['first = 0', + 'second = 0']) self.expect("frame variable ii[3]", - substrs = ['first =', - 'second =']); - + substrs=['first =', + 'second =']) + self.expect("frame variable ii[8]", matching=True, - substrs = ['1234567']) + substrs=['1234567']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ii").MightHaveChildren(), + "ii.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ii[8]", matching=False, error=True, + # self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) self.runCmd("c") - + self.expect('frame variable ii', - substrs = ['map has 0 items', - '{}']) - + substrs=['map has 0 items', + '{}']) + self.runCmd("frame variable si --show-types") self.expect('frame variable si', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) self.runCmd("c") self.expect('frame variable si', - substrs = ['map has 1 items', - '[0] = ', - 'first = \"zero\"', - 'second = 0']) + substrs=['map has 1 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable si", - substrs = ['map has 5 items', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3', - '[4] = ', - 'first = \"four\"', - 'second = 4']) + substrs=['map has 5 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3', + '[4] = ', + 'first = \"four\"', + 'second = 4']) self.expect("p si", - substrs = ['map has 5 items', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3', - '[4] = ', - 'first = \"four\"', - 'second = 4']) + substrs=['map has 5 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3', + '[4] = ', + 'first = \"four\"', + 'second = 4']) # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'four', - 'second = 4']); + substrs=['first = ', 'four', + 'second = 4']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("si").MightHaveChildren(), + "si.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression si[0]", matching=False, error=True, + # self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) self.runCmd("c") - + self.expect('frame variable si', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) self.runCmd("frame variable is --show-types") - + self.expect('frame variable is', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable is", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - + substrs=['map has 4 items', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + self.expect("p is", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + substrs=['map has 4 items', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) # check access-by-index self.expect("frame variable is[0]", - substrs = ['first = ', - 'second =']); + substrs=['first = ', + 'second =']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("is").MightHaveChildren(), + "is.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression is[0]", matching=False, error=True, + # self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) self.runCmd("c") - + self.expect('frame variable is', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) self.runCmd("frame variable ss --show-types") - + self.expect('frame variable ss', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable ss", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"', - '[3] = ', - 'second = \"..is always a Mac!\"', - 'first = \"a Mac..\"']) - + substrs=['map has 4 items', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"', + '[3] = ', + 'second = \"..is always a Mac!\"', + 'first = \"a Mac..\"']) + self.expect("p ss", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"', - '[3] = ', - 'second = \"..is always a Mac!\"', - 'first = \"a Mac..\"']) + substrs=['map has 4 items', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"', + '[3] = ', + 'second = \"..is always a Mac!\"', + 'first = \"a Mac..\"']) # check access-by-index self.expect("frame variable ss[3]", - substrs = ['gatto', 'cat']); + substrs=['gatto', 'cat']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!") - + self.assertTrue( + self.frame().FindVariable("ss").MightHaveChildren(), + "ss.MightHaveChildren() says False for non empty!") + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ss[3]", matching=False, error=True, + # self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) self.runCmd("c") - + self.expect('frame variable ss', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py index 20b1a3d2115..8d940c2686a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py @@ -4,43 +4,46 @@ Test lldb data formatter subsystem. from __future__ import print_function -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdSmartPtrDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIfFreeBSD - @skipIfWindows # libstdcpp not ported to Windows - @skipIfDarwin # doesn't compile on Darwin + @skipIfWindows # libstdcpp not ported to Windows + @skipIfDarwin # doesn't compile on Darwin def test_with_run_command(self): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', 'stop reason = breakpoint']) + substrs=['stopped', 'stop reason = breakpoint']) + + self.expect("frame variable nsp", substrs=['nsp = nullptr']) + self.expect("frame variable isp", substrs=['isp = 123']) + self.expect("frame variable ssp", substrs=['ssp = "foobar"']) - self.expect("frame variable nsp", substrs = ['nsp = nullptr']) - self.expect("frame variable isp", substrs = ['isp = 123']) - self.expect("frame variable ssp", substrs = ['ssp = "foobar"']) + self.expect("frame variable nwp", substrs=['nwp = nullptr']) + self.expect("frame variable iwp", substrs=['iwp = 123']) + self.expect("frame variable swp", substrs=['swp = "foobar"']) - self.expect("frame variable nwp", substrs = ['nwp = nullptr']) - self.expect("frame variable iwp", substrs = ['iwp = 123']) - self.expect("frame variable swp", substrs = ['swp = "foobar"']) - self.runCmd("continue") - self.expect("frame variable nsp", substrs = ['nsp = nullptr']) - self.expect("frame variable isp", substrs = ['isp = nullptr']) - self.expect("frame variable ssp", substrs = ['ssp = nullptr']) + self.expect("frame variable nsp", substrs=['nsp = nullptr']) + self.expect("frame variable isp", substrs=['isp = nullptr']) + self.expect("frame variable ssp", substrs=['ssp = nullptr']) - self.expect("frame variable nwp", substrs = ['nwp = nullptr']) - self.expect("frame variable iwp", substrs = ['iwp = nullptr']) - self.expect("frame variable swp", substrs = ['swp = nullptr']) + self.expect("frame variable nwp", substrs=['nwp = nullptr']) + self.expect("frame variable iwp", substrs=['iwp = nullptr']) + self.expect("frame variable swp", substrs=['swp = nullptr']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py index fde2f791183..67823c95f13 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py @@ -1,4 +1,4 @@ -#coding=utf8 +# coding=utf8 """ Test lldb data formatter subsystem. """ @@ -6,13 +6,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdStringDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,20 +24,21 @@ class StdStringDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,7 +47,9 @@ class StdStringDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -56,12 +60,22 @@ class StdStringDataFormatterTestCase(TestBase): var_q = self.frame().FindVariable('q') var_Q = self.frame().FindVariable('Q') - self.assertTrue(var_s.GetSummary() == 'L"hello world! מזל טוב!"', "s summary wrong") + self.assertTrue( + var_s.GetSummary() == 'L"hello world! מזל טוב!"', + "s summary wrong") self.assertTrue(var_S.GetSummary() == 'L"!!!!"', "S summary wrong") - self.assertTrue(var_mazeltov.GetSummary() == 'L"מזל טוב"', "mazeltov summary wrong") - self.assertTrue(var_q.GetSummary() == '"hello world"', "q summary wrong") - self.assertTrue(var_Q.GetSummary() == '"quite a long std::strin with lots of info inside it"', "Q summary wrong") + self.assertTrue( + var_mazeltov.GetSummary() == 'L"מזל טוב"', + "mazeltov summary wrong") + self.assertTrue( + var_q.GetSummary() == '"hello world"', + "q summary wrong") + self.assertTrue( + var_Q.GetSummary() == '"quite a long std::strin with lots of info inside it"', + "Q summary wrong") self.runCmd("next") - self.assertTrue(var_S.GetSummary() == 'L"!!!!!"', "new S summary wrong") + self.assertTrue( + var_S.GetSummary() == 'L"!!!!!"', + "new S summary wrong") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py index f5cf7c04c3a..eff5feedd42 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdVBoolDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,23 +23,28 @@ class StdVBoolDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr20548 fails to build on lab.llvm.org buildbot') - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") - @skipIfWindows # libstdcpp not ported to Windows. + @expectedFailureAll( + oslist=['freebsd'], + bugnumber='llvm.org/pr20548 fails to build on lab.llvm.org buildbot') + @expectedFailureAll( + compiler="icc", + bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") + @skipIfWindows # libstdcpp not ported to Windows. @skipIfDarwin def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,13 +53,33 @@ class StdVBoolDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect("frame variable vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) + self.expect( + "frame variable vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) - self.expect("expr vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) + self.expect( + "expr vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py index 4a352ef41c1..5de64f636cc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdVectorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,21 +24,24 @@ class StdVectorDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIfFreeBSD - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") - @skipIfWindows # libstdcpp not ported to Windows + @expectedFailureAll( + compiler="icc", + bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,163 +50,171 @@ class StdVectorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # empty vectors (and storage pointers SHOULD BOTH BE NULL..) self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) self.runCmd("c") - + # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 1', - '}']) + substrs=['numbers = size=1', + '[0] = 1', + '}']) # add some more data - self.runCmd("c"); - + self.runCmd("c") + self.expect("frame variable numbers", - substrs = ['numbers = size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) + substrs=['numbers = size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) self.expect("p numbers", - substrs = ['$', 'size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) - - + substrs=['$', 'size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) + # check access to synthetic children - self.runCmd("type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") + self.runCmd( + "type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', - substrs = ['item 0 is 1']); - - self.runCmd("type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") + substrs=['item 0 is 1']) + + self.runCmd( + "type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") #import time - #time.sleep(19) + # time.sleep(19) self.expect('frame variable numbers', - substrs = ['item 0 is 1']); + substrs=['item 0 is 1']) # move on with synths self.runCmd("type summary delete std::int_vect") self.runCmd("type summary delete int_vect") # add some more data - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable numbers", - substrs = ['numbers = size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) - + substrs=['numbers = size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) + self.expect("p numbers", - substrs = ['$', 'size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) + substrs=['$', 'size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) # check access-by-index self.expect("frame variable numbers[0]", - substrs = ['1']); + substrs=['1']) self.expect("frame variable numbers[1]", - substrs = ['12']); + substrs=['12']) self.expect("frame variable numbers[2]", - substrs = ['123']); + substrs=['123']) self.expect("frame variable numbers[3]", - substrs = ['1234']); - + substrs=['1234']) + # but check that expression does not rely on us # (when expression gets to call into STL code correctly, we will have to find # another way to check this) self.expect("expression numbers[6]", matching=False, error=True, - substrs = ['1234567']) + substrs=['1234567']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("numbers").MightHaveChildren(), "numbers.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("numbers").MightHaveChildren(), + "numbers.MightHaveChildren() says False for non empty!") # clear out the vector and see that we do the right thing once again self.runCmd("c") self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) self.runCmd("c") # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 7', - '}']) + substrs=['numbers = size=1', + '[0] = 7', + '}']) # check if we can display strings self.runCmd("c") self.expect("frame variable strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) # test summaries based on synthetic children - self.runCmd("type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") + self.runCmd( + "type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") self.expect("frame variable strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable strings", - substrs = ['vector has 4 items']) - + substrs=['vector has 4 items']) + # check access-by-index self.expect("frame variable strings[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable strings[1]", - substrs = ['is']); - + substrs=['is']) + # but check that expression does not rely on us # (when expression gets to call into STL code correctly, we will have to find # another way to check this) self.expect("expression strings[0]", matching=False, error=True, - substrs = ['goofy']) + substrs=['goofy']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("strings").MightHaveChildren(), "strings.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("strings").MightHaveChildren(), + "strings.MightHaveChildren() says False for non empty!") self.runCmd("c") self.expect("frame variable strings", - substrs = ['vector has 0 items']) + substrs=['vector has 0 items']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py index 8cebf20ddd2..8fff07d89dc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class SynthDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,14 +27,15 @@ class SynthDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,158 +50,171 @@ class SynthDataFormatterTestCase(TestBase): # Pick some values and check that the basics work self.runCmd("type filter add BagOfInts --child x --child z") self.expect("frame variable int_bag", - substrs = ['x = 6', - 'z = 8']) + substrs=['x = 6', + 'z = 8']) # Check we can still access the missing child by summary - self.runCmd("type summary add BagOfInts --summary-string \"y=${var.y}\"") + self.runCmd( + "type summary add BagOfInts --summary-string \"y=${var.y}\"") self.expect('frame variable int_bag', - substrs = ['y=7']) - - # Even if we have synth children, the summary prevails + substrs=['y=7']) + + # Even if we have synth children, the summary prevails self.expect("frame variable int_bag", matching=False, - substrs = ['x = 6', - 'z = 8']) - + substrs=['x = 6', + 'z = 8']) + # if we skip synth and summary show y - self.expect("frame variable int_bag --synthetic-type false --no-summary-depth=1", - substrs = ['x = 6', - 'y = 7', - 'z = 8']) - + self.expect( + "frame variable int_bag --synthetic-type false --no-summary-depth=1", + substrs=[ + 'x = 6', + 'y = 7', + 'z = 8']) + # if we ask for raw output same happens self.expect("frame variable int_bag --raw-output", - substrs = ['x = 6', - 'y = 7', - 'z = 8']) - + substrs=['x = 6', + 'y = 7', + 'z = 8']) + # Summary+Synth must work together - self.runCmd("type summary add BagOfInts --summary-string \"x=${var.x}\" -e") + self.runCmd( + "type summary add BagOfInts --summary-string \"x=${var.x}\" -e") self.expect('frame variable int_bag', - substrs = ['x=6', - 'x = 6', - 'z = 8']) - + substrs=['x=6', + 'x = 6', + 'z = 8']) + # Same output, but using Python - self.runCmd("type summary add BagOfInts --python-script \"return 'x=%s' % valobj.GetChildMemberWithName('x').GetValue()\" -e") + self.runCmd( + "type summary add BagOfInts --python-script \"return 'x=%s' % valobj.GetChildMemberWithName('x').GetValue()\" -e") self.expect('frame variable int_bag', - substrs = ['x=6', - 'x = 6', - 'z = 8']) + substrs=['x=6', + 'x = 6', + 'z = 8']) # If I skip summaries, still give me the artificial children self.expect("frame variable int_bag --no-summary-depth=1", - substrs = ['x = 6', - 'z = 8']) + substrs=['x = 6', + 'z = 8']) # Delete synth and check that the view reflects it immediately self.runCmd("type filter delete BagOfInts") self.expect("frame variable int_bag", - substrs = ['x = 6', - 'y = 7', - 'z = 8']) + substrs=['x = 6', + 'y = 7', + 'z = 8']) - # Add the synth again and check that it's honored deeper in the hierarchy + # Add the synth again and check that it's honored deeper in the + # hierarchy self.runCmd("type filter add BagOfInts --child x --child z") self.expect('frame variable bag_bag', - substrs = ['x = x=69 {', - 'x = 69', - 'z = 71', - 'y = x=66 {', - 'x = 66', - 'z = 68']) + substrs=['x = x=69 {', + 'x = 69', + 'z = 71', + 'y = x=66 {', + 'x = 66', + 'z = 68']) self.expect('frame variable bag_bag', matching=False, - substrs = ['y = 70', - 'y = 67']) + substrs=['y = 70', + 'y = 67']) # Check that a synth can expand nested stuff self.runCmd("type filter add BagOfBags --child x.y --child y.z") self.expect('frame variable bag_bag', - substrs = ['x.y = 70', - 'y.z = 68']) + substrs=['x.y = 70', + 'y.z = 68']) # ...even if we get -> and . wrong self.runCmd("type filter add BagOfBags --child x.y --child \"y->z\"") self.expect('frame variable bag_bag', - substrs = ['x.y = 70', - 'y->z = 68']) + substrs=['x.y = 70', + 'y->z = 68']) # ...even bitfields - self.runCmd("type filter add BagOfBags --child x.y --child \"y->z[1-2]\"") + self.runCmd( + "type filter add BagOfBags --child x.y --child \"y->z[1-2]\"") self.expect('frame variable bag_bag --show-types', - substrs = ['x.y = 70', - '(int:2) y->z[1-2] = 2']) + substrs=['x.y = 70', + '(int:2) y->z[1-2] = 2']) # ...even if we format the bitfields - self.runCmd("type filter add BagOfBags --child x.y --child \"y->y[0-0]\"") + self.runCmd( + "type filter add BagOfBags --child x.y --child \"y->y[0-0]\"") self.runCmd("type format add \"int:1\" -f bool") self.expect('frame variable bag_bag --show-types', - substrs = ['x.y = 70', - '(int:1) y->y[0-0] = true']) - + substrs=['x.y = 70', + '(int:1) y->y[0-0] = true']) + # ...even if we use one-liner summaries self.runCmd("type summary add -c BagOfBags") - self.expect('frame variable bag_bag', - substrs = ['(BagOfBags) bag_bag = (x.y = 70, y->y[0-0] = true)']) - + self.expect('frame variable bag_bag', substrs=[ + '(BagOfBags) bag_bag = (x.y = 70, y->y[0-0] = true)']) + self.runCmd("type summary delete BagOfBags") # now check we are dynamic (and arrays work) - self.runCmd("type filter add Plenty --child bitfield --child array[0] --child array[2]") + self.runCmd( + "type filter add Plenty --child bitfield --child array[0] --child array[2]") self.expect('frame variable plenty_of_stuff', - substrs = ['bitfield = 1', - 'array[0] = 5', - 'array[2] = 3']) - + substrs=['bitfield = 1', + 'array[0] = 5', + 'array[2] = 3']) + self.runCmd("n") self.expect('frame variable plenty_of_stuff', - substrs = ['bitfield = 17', - 'array[0] = 5', - 'array[2] = 3']) - + substrs=['bitfield = 17', + 'array[0] = 5', + 'array[2] = 3']) + # skip synthetic children self.expect('frame variable plenty_of_stuff --synthetic-type no', - substrs = ['some_values = 0x', - 'array = 0x', - 'array_size = 5']) + substrs=['some_values = 0x', + 'array = 0x', + 'array_size = 5']) - # check flat printing with synthetic children self.expect('frame variable plenty_of_stuff --flat', - substrs = ['plenty_of_stuff.bitfield = 17', - '*(plenty_of_stuff.array) = 5', - '*(plenty_of_stuff.array) = 3']) - + substrs=['plenty_of_stuff.bitfield = 17', + '*(plenty_of_stuff.array) = 5', + '*(plenty_of_stuff.array) = 3']) + # check that we do not lose location information for our children self.expect('frame variable plenty_of_stuff --location', - substrs = ['0x', - ': bitfield = 17']) + substrs=['0x', + ': bitfield = 17']) # check we work across pointer boundaries self.expect('frame variable plenty_of_stuff.some_values --ptr-depth=1', - substrs = ['(BagOfInts *) plenty_of_stuff.some_values', - 'x = 5', - 'z = 7']) + substrs=['(BagOfInts *) plenty_of_stuff.some_values', + 'x = 5', + 'z = 7']) # but not if we don't want to self.runCmd("type filter add BagOfInts --child x --child z -p") self.expect('frame variable plenty_of_stuff.some_values --ptr-depth=1', - substrs = ['(BagOfInts *) plenty_of_stuff.some_values', - 'x = 5', - 'y = 6', - 'z = 7']) + substrs=['(BagOfInts *) plenty_of_stuff.some_values', + 'x = 5', + 'y = 6', + 'z = 7']) # check we're dynamic even if nested self.runCmd("type filter add BagOfBags --child x.z") self.expect('frame variable bag_bag', - substrs = ['x.z = 71']) + substrs=['x.z = 71']) self.runCmd("n") self.expect('frame variable bag_bag', - substrs = ['x.z = 12']) + substrs=['x.z = 12']) - self.runCmd('type summary add -e -s "I am always empty but have" EmptyStruct') - self.expect('frame variable es', substrs = ["I am always empty but have {}"]) + self.runCmd( + 'type summary add -e -s "I am always empty but have" EmptyStruct') + self.expect('frame variable es', substrs=[ + "I am always empty but have {}"]) self.runCmd('type summary add -e -h -s "I am really empty" EmptyStruct') - self.expect('frame variable es', substrs = ["I am really empty"]) - self.expect('frame variable es', substrs = ["I am really empty {}"], matching=False) + self.expect('frame variable es', substrs=["I am really empty"]) + self.expect( + 'frame variable es', + substrs=["I am really empty {}"], + matching=False) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py index 6a03456e5c3..75d3b4e5f5c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class DataFormatterSynthTypeTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,20 +23,21 @@ class DataFormatterSynthTypeTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', 'break here') - @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser + @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser def test_with_run_command(self): """Test using Python synthetic children provider to provide a typename.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py index 42737140b11..fa47ca2cfe6 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py @@ -1,22 +1,30 @@ class myIntSynthProvider(object): - def __init__(self, valobj, dict): - self.valobj = valobj; - self.val = self.valobj.GetChildMemberWithName("theValue") - def num_children(self): - return 0; - def get_child_at_index(self, index): - return None - def get_child_index(self, name): - return None - def update(self): - return False - def has_children(self): - return False - def get_type_name(self): - return "ThisTestPasses" + + def __init__(self, valobj, dict): + self.valobj = valobj + self.val = self.valobj.GetChildMemberWithName("theValue") + + def num_children(self): + return 0 + + def get_child_at_index(self, index): + return None + + def get_child_index(self, name): + return None + + def update(self): + return False + + def has_children(self): + return False + + def get_type_name(self): + return "ThisTestPasses" class myArraySynthProvider(object): + def __init__(self, valobj, dict): self.valobj = valobj self.array = self.valobj.GetChildMemberWithName("array") @@ -27,10 +35,10 @@ class myArraySynthProvider(object): return max_count def get_child_at_index(self, index): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def get_child_index(self, name): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def has_children(self): return True diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py index 5d796f9bf99..6e7ac2c13f3 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class DataFormatterSynthValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,21 +23,24 @@ class DataFormatterSynthValueTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', 'break here') - @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") + @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Test using Python synthetic children provider to provide a value.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,7 +52,7 @@ class DataFormatterSynthValueTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + x = self.frame().FindVariable("x") x.SetPreferSyntheticValue(True) y = self.frame().FindVariable("y") @@ -62,9 +66,11 @@ class DataFormatterSynthValueTestCase(TestBase): y_val = y.GetValueAsUnsigned z_val = z.GetValueAsUnsigned q_val = q.GetValueAsUnsigned - + if self.TraceOn(): - print("x_val = %s; y_val = %s; z_val = %s; q_val = %s" % (x_val(),y_val(),z_val(),q_val())) + print( + "x_val = %s; y_val = %s; z_val = %s; q_val = %s" % + (x_val(), y_val(), z_val(), q_val())) self.assertFalse(x_val() == 3, "x == 3 before synthetics") self.assertFalse(y_val() == 4, "y == 4 before synthetics") @@ -76,23 +82,34 @@ class DataFormatterSynthValueTestCase(TestBase): self.runCmd("type synth add -l myIntSynthProvider myInt") self.runCmd("type synth add -l myArraySynthProvider myArray") self.runCmd("type synth add -l myIntSynthProvider myIntAndStuff") - + if self.TraceOn(): - print("x_val = %s; y_val = %s; z_val = %s; q_val = %s" % (x_val(),y_val(),z_val(),q_val())) - + print( + "x_val = %s; y_val = %s; z_val = %s; q_val = %s" % + (x_val(), y_val(), z_val(), q_val())) + self.assertTrue(x_val() == 3, "x != 3 after synthetics") self.assertTrue(y_val() == 4, "y != 4 after synthetics") self.assertTrue(z_val() == 7, "z != 7 after synthetics") self.assertTrue(q_val() == 8, "q != 8 after synthetics") - + self.expect("frame variable x", substrs=['3']) - self.expect("frame variable x", substrs=['theValue = 3'], matching=False) + self.expect( + "frame variable x", + substrs=['theValue = 3'], + matching=False) self.expect("frame variable q", substrs=['8']) - self.expect("frame variable q", substrs=['theValue = 8'], matching=False) - - # check that an aptly defined synthetic provider does not affect one-lining - self.expect("expression struct S { myInt theInt{12}; }; S()", substrs = ['(theInt = 12)']) - + self.expect( + "frame variable q", + substrs=['theValue = 8'], + matching=False) + + # check that an aptly defined synthetic provider does not affect + # one-lining + self.expect( + "expression struct S { myInt theInt{12}; }; S()", + substrs=['(theInt = 12)']) + # check that we can use a synthetic value in a summary self.runCmd("type summary add hasAnInt -s ${var.theInt}") hi = self.frame().FindVariable("hi") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py index c8517a44293..82da6f9da92 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py @@ -1,22 +1,30 @@ class myIntSynthProvider(object): - def __init__(self, valobj, dict): - self.valobj = valobj; - self.val = self.valobj.GetChildMemberWithName("theValue") - def num_children(self): - return 0; - def get_child_at_index(self, index): - return None - def get_child_index(self, name): - return None - def update(self): - return False - def has_children(self): - return False - def get_value(self): - return self.val + + def __init__(self, valobj, dict): + self.valobj = valobj + self.val = self.valobj.GetChildMemberWithName("theValue") + + def num_children(self): + return 0 + + def get_child_at_index(self, index): + return None + + def get_child_index(self, name): + return None + + def update(self): + return False + + def has_children(self): + return False + + def get_value(self): + return self.val class myArraySynthProvider(object): + def __init__(self, valobj, dict): self.valobj = valobj self.array = self.valobj.GetChildMemberWithName("array") @@ -27,10 +35,10 @@ class myArraySynthProvider(object): return max_count def get_child_at_index(self, index): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def get_child_index(self, name): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def has_children(self): return True diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py index 886d09fda45..734e711fb7f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py @@ -2,4 +2,7 @@ from __future__ import absolute_import from lldbsuite.test import lldbinline -lldbinline.MakeInlineTest(__file__, globals(), [lldbinline.expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")]) +lldbinline.MakeInlineTest( + __file__, globals(), [ + lldbinline.expectedFailureAll( + oslist=["windows"], bugnumber="llvm.org/pr24663")]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py index 5cb7c82c9e0..0c15c793e1f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py @@ -5,12 +5,13 @@ Check if changing Format on an SBValue correctly propagates that new format to c from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class FormatPropagationTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,14 +28,15 @@ class FormatPropagationTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,18 +49,24 @@ class FormatPropagationTestCase(TestBase): # extract the parent and the children frame = self.frame() parent = self.frame().FindVariable("f") - self.assertTrue(parent != None and parent.IsValid(),"could not find f") + self.assertTrue( + parent is not None and parent.IsValid(), + "could not find f") X = parent.GetChildMemberWithName("X") - self.assertTrue(X != None and X.IsValid(),"could not find X") + self.assertTrue(X is not None and X.IsValid(), "could not find X") Y = parent.GetChildMemberWithName("Y") - self.assertTrue(Y != None and Y.IsValid(),"could not find Y") + self.assertTrue(Y is not None and Y.IsValid(), "could not find Y") # check their values now self.assertTrue(X.GetValue() == "1", "X has an invalid value") self.assertTrue(Y.GetValue() == "2", "Y has an invalid value") # set the format on the parent parent.SetFormat(lldb.eFormatHex) - self.assertTrue(X.GetValue() == "0x00000001", "X has not changed format") - self.assertTrue(Y.GetValue() == "0x00000002", "Y has not changed format") + self.assertTrue( + X.GetValue() == "0x00000001", + "X has not changed format") + self.assertTrue( + Y.GetValue() == "0x00000002", + "Y has not changed format") # Step and check if the values make sense still self.runCmd("next") self.assertTrue(X.GetValue() == "0x00000004", "X has not become 4") @@ -71,5 +79,7 @@ class FormatPropagationTestCase(TestBase): parent.SetFormat(lldb.eFormatDefault) X.SetFormat(lldb.eFormatHex) Y.SetFormat(lldb.eFormatDefault) - self.assertTrue(X.GetValue() == "0x00000004", "X is not hex as it asked") + self.assertTrue( + X.GetValue() == "0x00000004", + "X is not hex as it asked") self.assertTrue(Y.GetValue() == "2", "Y is not defaulted") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py index 555351998c2..d6303fe8b73 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py @@ -5,12 +5,13 @@ Test that the user can input a format but it will not prevail over summary forma from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class FrameFormatSmallStructTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,13 +27,14 @@ class FrameFormatSmallStructTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) - self.expect("thread list", substrs = ['addPair(p=(x = 3, y = -3))']) + self.expect("thread list", substrs=['addPair(p=(x = 3, y = -3))']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py index 3c28b68056f..32fbf48dcc6 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class DataFormatterHexCapsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,14 +27,15 @@ class DataFormatterHexCapsTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,38 +47,43 @@ class DataFormatterHexCapsTestCase(TestBase): self.addTearDownHook(cleanup) self.runCmd("type format add -f uppercase int") - + self.expect('frame variable mine', - substrs = ['mine = ', - 'first = 0x001122AA', 'second = 0x1122BB44']) + substrs=['mine = ', + 'first = 0x001122AA', 'second = 0x1122BB44']) self.runCmd("type format add -f hex int") self.expect('frame variable mine', - substrs = ['mine = ', - 'first = 0x001122aa', 'second = 0x1122bb44']) + substrs=['mine = ', + 'first = 0x001122aa', 'second = 0x1122bb44']) self.runCmd("type format delete int") - self.runCmd("type summary add -s \"${var.first%X} and ${var.second%x}\" foo") + self.runCmd( + "type summary add -s \"${var.first%X} and ${var.second%x}\" foo") self.expect('frame variable mine', - substrs = ['(foo) mine = 0x001122AA and 0x1122bb44']) + substrs=['(foo) mine = 0x001122AA and 0x1122bb44']) - self.runCmd("type summary add -s \"${var.first%X} and ${var.second%X}\" foo") + self.runCmd( + "type summary add -s \"${var.first%X} and ${var.second%X}\" foo") self.runCmd("next") self.runCmd("next") self.expect('frame variable mine', - substrs = ['(foo) mine = 0xAABBCCDD and 0x1122BB44']) + substrs=['(foo) mine = 0xAABBCCDD and 0x1122BB44']) - self.runCmd("type summary add -s \"${var.first%x} and ${var.second%X}\" foo") + self.runCmd( + "type summary add -s \"${var.first%x} and ${var.second%X}\" foo") self.expect('frame variable mine', - substrs = ['(foo) mine = 0xaabbccdd and 0x1122BB44']) + substrs=['(foo) mine = 0xaabbccdd and 0x1122BB44']) self.runCmd("next") self.runCmd("next") - self.runCmd("type summary add -s \"${var.first%x} and ${var.second%x}\" foo") + self.runCmd( + "type summary add -s \"${var.first%x} and ${var.second%x}\" foo") self.expect('frame variable mine', - substrs = ['(foo) mine = 0xaabbccdd and 0xff00ff00']) - self.runCmd("type summary add -s \"${var.first%X} and ${var.second%X}\" foo") + substrs=['(foo) mine = 0xaabbccdd and 0xff00ff00']) + self.runCmd( + "type summary add -s \"${var.first%X} and ${var.second%X}\" foo") self.expect('frame variable mine', - substrs = ['(foo) mine = 0xAABBCCDD and 0xFF00FF00']) + substrs=['(foo) mine = 0xAABBCCDD and 0xFF00FF00']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py index f30733d2d81..b7f60cfac41 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class LanguageCategoryUpdatesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,7 +27,11 @@ class LanguageCategoryUpdatesTestCase(TestBase): # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): - if hasattr(self, 'type_category') and hasattr(self, 'type_specifier'): + if hasattr( + self, + 'type_category') and hasattr( + self, + 'type_specifier'): self.type_category.DeleteTypeSummary(self.type_specifier) # Execute the cleanup function during test case tear down. @@ -35,25 +40,47 @@ class LanguageCategoryUpdatesTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - - self.expect("frame variable", substrs = ['(S)', 'object', '123', '456'], matching=True) - - self.type_category = self.dbg.GetCategory(lldb.eLanguageTypeC_plus_plus) - type_summary = lldb.SBTypeSummary.CreateWithSummaryString("this is an object of type S") + substrs=['stopped', + 'stop reason = breakpoint']) + + self.expect( + "frame variable", + substrs=[ + '(S)', + 'object', + '123', + '456'], + matching=True) + + self.type_category = self.dbg.GetCategory( + lldb.eLanguageTypeC_plus_plus) + type_summary = lldb.SBTypeSummary.CreateWithSummaryString( + "this is an object of type S") self.type_specifier = lldb.SBTypeNameSpecifier('S') self.type_category.AddTypeSummary(self.type_specifier, type_summary) - self.expect("frame variable", substrs = ['this is an object of type S'], matching=True) - - self.type_category.DeleteTypeSummary(self.type_specifier) - self.expect("frame variable", substrs = ['this is an object of type S'], matching=False) - self.expect("frame variable", substrs = ['(S)', 'object', '123', '456'], matching=True) + self.expect( + "frame variable", + substrs=['this is an object of type S'], + matching=True) + self.type_category.DeleteTypeSummary(self.type_specifier) + self.expect( + "frame variable", + substrs=['this is an object of type S'], + matching=False) + self.expect( + "frame variable", + substrs=[ + '(S)', + 'object', + '123', + '456'], + matching=True) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py index 871cc19373a..87fc2d1802b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class NSArraySyntheticTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class NSArraySyntheticTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,19 +52,59 @@ class NSArraySyntheticTestCase(TestBase): # Now check that we are displaying Cocoa classes correctly self.expect('frame variable arr', - substrs = ['@"6 elements"']) + substrs=['@"6 elements"']) self.expect('frame variable other_arr', - substrs = ['@"4 elements"']) - self.expect('frame variable arr --ptr-depth 1', - substrs = ['@"6 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x','[4] = 0x','[5] = 0x']) - self.expect('frame variable other_arr --ptr-depth 1', - substrs = ['@"4 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x']) - self.expect('frame variable arr --ptr-depth 1 -d no-run-target', - substrs = ['@"6 elements"','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com']) - self.expect('frame variable other_arr --ptr-depth 1 -d no-run-target', - substrs = ['@"4 elements"','(int)5','@"a string"','@"6 elements"']) - self.expect('frame variable other_arr --ptr-depth 2 -d no-run-target', - substrs = ['@"4 elements"','@"6 elements" {','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com']) + substrs=['@"4 elements"']) + self.expect( + 'frame variable arr --ptr-depth 1', + substrs=[ + '@"6 elements"', + '[0] = 0x', + '[1] = 0x', + '[2] = 0x', + '[3] = 0x', + '[4] = 0x', + '[5] = 0x']) + self.expect( + 'frame variable other_arr --ptr-depth 1', + substrs=[ + '@"4 elements"', + '[0] = 0x', + '[1] = 0x', + '[2] = 0x', + '[3] = 0x']) + self.expect( + 'frame variable arr --ptr-depth 1 -d no-run-target', + substrs=[ + '@"6 elements"', + '@"hello"', + '@"world"', + '@"this"', + '@"is"', + '@"me"', + '@"http://www.apple.com']) + self.expect( + 'frame variable other_arr --ptr-depth 1 -d no-run-target', + substrs=[ + '@"4 elements"', + '(int)5', + '@"a string"', + '@"6 elements"']) + self.expect( + 'frame variable other_arr --ptr-depth 2 -d no-run-target', + substrs=[ + '@"4 elements"', + '@"6 elements" {', + '@"hello"', + '@"world"', + '@"this"', + '@"is"', + '@"me"', + '@"http://www.apple.com']) - self.assertTrue(self.frame().FindVariable("arr").MightHaveChildren(), "arr says it does not have children!") - self.assertTrue(self.frame().FindVariable("other_arr").MightHaveChildren(), "arr says it does not have children!") + self.assertTrue( + self.frame().FindVariable("arr").MightHaveChildren(), + "arr says it does not have children!") + self.assertTrue( + self.frame().FindVariable("other_arr").MightHaveChildren(), + "arr says it does not have children!") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py index 5ee54c3a295..85675d21123 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class NSDictionarySyntheticTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class NSDictionarySyntheticTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,21 +52,73 @@ class NSDictionarySyntheticTestCase(TestBase): # Now check that we are displaying Cocoa classes correctly self.expect('frame variable dictionary', - substrs = ['3 key/value pairs']) + substrs=['3 key/value pairs']) self.expect('frame variable mutabledict', - substrs = ['4 key/value pairs']) - self.expect('frame variable dictionary --ptr-depth 1', - substrs = ['3 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = ']) - self.expect('frame variable mutabledict --ptr-depth 1', - substrs = ['4 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = ','[3] = ']) - self.expect('frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target', - substrs = ['3 key/value pairs','@"bar"','@"2 elements"','@"baz"','2 key/value pairs']) - self.expect('frame variable mutabledict --ptr-depth 1 --dynamic-type no-run-target', - substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs']) - self.expect('frame variable mutabledict --ptr-depth 2 --dynamic-type no-run-target', - substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"']) - self.expect('frame variable mutabledict --ptr-depth 3 --dynamic-type no-run-target', - substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"','(int)1','@"two"']) + substrs=['4 key/value pairs']) + self.expect( + 'frame variable dictionary --ptr-depth 1', + substrs=[ + '3 key/value pairs', + '[0] = ', + 'key = 0x', + 'value = 0x', + '[1] = ', + '[2] = ']) + self.expect( + 'frame variable mutabledict --ptr-depth 1', + substrs=[ + '4 key/value pairs', + '[0] = ', + 'key = 0x', + 'value = 0x', + '[1] = ', + '[2] = ', + '[3] = ']) + self.expect( + 'frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target', + substrs=[ + '3 key/value pairs', + '@"bar"', + '@"2 elements"', + '@"baz"', + '2 key/value pairs']) + self.expect( + 'frame variable mutabledict --ptr-depth 1 --dynamic-type no-run-target', + substrs=[ + '4 key/value pairs', + '(int)23', + '@"123"', + '@"http://www.apple.com"', + '@"sourceofstuff"', + '3 key/value pairs']) + self.expect( + 'frame variable mutabledict --ptr-depth 2 --dynamic-type no-run-target', + substrs=[ + '4 key/value pairs', + '(int)23', + '@"123"', + '@"http://www.apple.com"', + '@"sourceofstuff"', + '3 key/value pairs', + '@"bar"', + '@"2 elements"']) + self.expect( + 'frame variable mutabledict --ptr-depth 3 --dynamic-type no-run-target', + substrs=[ + '4 key/value pairs', + '(int)23', + '@"123"', + '@"http://www.apple.com"', + '@"sourceofstuff"', + '3 key/value pairs', + '@"bar"', + '@"2 elements"', + '(int)1', + '@"two"']) - self.assertTrue(self.frame().FindVariable("dictionary").MightHaveChildren(), "dictionary says it does not have children!") - self.assertTrue(self.frame().FindVariable("mutabledict").MightHaveChildren(), "mutable says it does not have children!") + self.assertTrue( + self.frame().FindVariable("dictionary").MightHaveChildren(), + "dictionary says it does not have children!") + self.assertTrue( + self.frame().FindVariable("mutabledict").MightHaveChildren(), + "mutable says it does not have children!") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py index d1680434d3b..6affc5a71fa 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class NSSetSyntheticTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class NSSetSyntheticTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,26 +52,64 @@ class NSSetSyntheticTestCase(TestBase): # Now check that we are displaying Cocoa classes correctly self.expect('frame variable set', - substrs = ['4 elements']) + substrs=['4 elements']) self.expect('frame variable mutable', - substrs = ['9 elements']) - self.expect('frame variable set --ptr-depth 1 -d run -T', - substrs = ['4 elements','[0]','[1]','[2]','[3]','hello','world','(int)1','(int)2']) - self.expect('frame variable mutable --ptr-depth 1 -d run -T', - substrs = ['9 elements','(int)5','@"3 elements"','@"www.apple.com"','(int)3','@"world"','(int)4']) + substrs=['9 elements']) + self.expect( + 'frame variable set --ptr-depth 1 -d run -T', + substrs=[ + '4 elements', + '[0]', + '[1]', + '[2]', + '[3]', + 'hello', + 'world', + '(int)1', + '(int)2']) + self.expect( + 'frame variable mutable --ptr-depth 1 -d run -T', + substrs=[ + '9 elements', + '(int)5', + '@"3 elements"', + '@"www.apple.com"', + '(int)3', + '@"world"', + '(int)4']) self.runCmd("next") self.expect('frame variable mutable', - substrs = ['0 elements']) + substrs=['0 elements']) self.runCmd("next") self.expect('frame variable mutable', - substrs = ['4 elements']) - self.expect('frame variable mutable --ptr-depth 1 -d run -T', - substrs = ['4 elements','[0]','[1]','[2]','[3]','hello','world','(int)1','(int)2']) + substrs=['4 elements']) + self.expect( + 'frame variable mutable --ptr-depth 1 -d run -T', + substrs=[ + '4 elements', + '[0]', + '[1]', + '[2]', + '[3]', + 'hello', + 'world', + '(int)1', + '(int)2']) self.runCmd("next") self.expect('frame variable mutable', - substrs = ['4 elements']) - self.expect('frame variable mutable --ptr-depth 1 -d run -T', - substrs = ['4 elements','[0]','[1]','[2]','[3]','hello','world','(int)1','(int)2']) + substrs=['4 elements']) + self.expect( + 'frame variable mutable --ptr-depth 1 -d run -T', + substrs=[ + '4 elements', + '[0]', + '[1]', + '[2]', + '[3]', + 'hello', + 'world', + '(int)1', + '(int)2']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py index 4158ec8a661..7ffddc5ec67 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class DataFormatterOSTypeTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class DataFormatterOSTypeTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,4 +52,4 @@ class DataFormatterOSTypeTestCase(TestBase): # Now check that we use the right summary for OSType self.expect('frame variable', - substrs = ["'test'","'best'"]) + substrs=["'test'", "'best'"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py index 700b7418118..49cda4ae6cc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class PrintArrayTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -32,14 +33,15 @@ class PrintArrayTestCase(TestBase): """Test that expr -Z works""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,21 +52,85 @@ class PrintArrayTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - - self.expect('expr --element-count 3 -- data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) + + self.expect( + 'expr --element-count 3 -- data', + substrs=[ + '[0] = 1', + '[1] = 3', + '[2] = 5']) self.expect('expr data', substrs=['int *', '$', '0x']) - self.expect('expr -f binary --element-count 0 -- data', substrs=['int *', '$', '0b']) - self.expect('expr -f hex --element-count 3 -- data', substrs=['[0] = 0x', '1', '[1] = 0x', '3', '[2] = 0x', '5']) - self.expect('expr -f binary --element-count 2 -- data', substrs=['int *', '$', '0x', '[0] = 0b', '1', '[1] = 0b', '11']) + self.expect( + 'expr -f binary --element-count 0 -- data', + substrs=[ + 'int *', + '$', + '0b']) + self.expect( + 'expr -f hex --element-count 3 -- data', + substrs=[ + '[0] = 0x', + '1', + '[1] = 0x', + '3', + '[2] = 0x', + '5']) + self.expect( + 'expr -f binary --element-count 2 -- data', + substrs=[ + 'int *', + '$', + '0x', + '[0] = 0b', + '1', + '[1] = 0b', + '11']) self.expect('parray 3 data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) - self.expect('parray `1 + 1 + 1` data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) - self.expect('parray `data[1]` data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) - self.expect('parray/x 3 data', substrs=['[0] = 0x', '1', '[1] = 0x', '3', '[2] = 0x', '5']) - self.expect('parray/x `data[1]` data', substrs=['[0] = 0x', '1', '[1] = 0x', '3', '[2] = 0x', '5']) + self.expect( + 'parray `1 + 1 + 1` data', + substrs=[ + '[0] = 1', + '[1] = 3', + '[2] = 5']) + self.expect( + 'parray `data[1]` data', + substrs=[ + '[0] = 1', + '[1] = 3', + '[2] = 5']) + self.expect( + 'parray/x 3 data', + substrs=[ + '[0] = 0x', + '1', + '[1] = 0x', + '3', + '[2] = 0x', + '5']) + self.expect( + 'parray/x `data[1]` data', + substrs=[ + '[0] = 0x', + '1', + '[1] = 0x', + '3', + '[2] = 0x', + '5']) # check error conditions - self.expect('expr --element-count 10 -- 123', error=True, substrs=['expression cannot be used with --element-count as it does not refer to a pointer']) - self.expect('expr --element-count 10 -- (void*)123', error=True, substrs=['expression cannot be used with --element-count as it refers to a pointer to void']) - self.expect('parray data', error=True, substrs=["invalid element count 'data'"]) - self.expect('parray data data', error=True, substrs=["invalid element count 'data'"]) - self.expect('parray', error=True, substrs=['Not enough arguments provided']) + self.expect( + 'expr --element-count 10 -- 123', + error=True, + substrs=['expression cannot be used with --element-count as it does not refer to a pointer']) + self.expect( + 'expr --element-count 10 -- (void*)123', + error=True, + substrs=['expression cannot be used with --element-count as it refers to a pointer to void']) + self.expect('parray data', error=True, substrs=[ + "invalid element count 'data'"]) + self.expect( + 'parray data data', + error=True, + substrs=["invalid element count 'data'"]) + self.expect('parray', error=True, substrs=[ + 'Not enough arguments provided']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py index 7eb26a56986..83408e7b456 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class PrintObjectArrayTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,14 +34,15 @@ class PrintObjectArrayTestCase(TestBase): """Test that expr -O -Z works""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -52,9 +54,59 @@ class PrintObjectArrayTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('expr --element-count 3 --object-description -- objects', substrs=['3735928559', '4276993775', '3203398366', 'Hello', 'World', 'Two =', '1 =']) - self.expect('poarray 3 objects', substrs=['3735928559', '4276993775', '3203398366', 'Hello', 'World', 'Two =', '1 =']) - self.expect('expr --element-count 3 --object-description --description-verbosity=full -- objects', substrs=['[0] =', '3735928559', '4276993775', '3203398366', '[1] =', 'Hello', 'World', '[2] =', 'Two =', '1 =']) - self.expect('parray 3 objects', substrs=['[0] = 0x', '[1] = 0x', '[2] = 0x']) - self.expect('expr --element-count 3 -d run -- objects', substrs=['3 elements', '2 elements', '2 key/value pairs']) - self.expect('expr --element-count 3 -d run --ptr-depth=1 -- objects', substrs=['3 elements', '2 elements', '2 key/value pairs', '3735928559', '4276993775', '3203398366', '"Hello"', '"World"']) + self.expect( + 'expr --element-count 3 --object-description -- objects', + substrs=[ + '3735928559', + '4276993775', + '3203398366', + 'Hello', + 'World', + 'Two =', + '1 =']) + self.expect( + 'poarray 3 objects', + substrs=[ + '3735928559', + '4276993775', + '3203398366', + 'Hello', + 'World', + 'Two =', + '1 =']) + self.expect( + 'expr --element-count 3 --object-description --description-verbosity=full -- objects', + substrs=[ + '[0] =', + '3735928559', + '4276993775', + '3203398366', + '[1] =', + 'Hello', + 'World', + '[2] =', + 'Two =', + '1 =']) + self.expect( + 'parray 3 objects', + substrs=[ + '[0] = 0x', + '[1] = 0x', + '[2] = 0x']) + self.expect( + 'expr --element-count 3 -d run -- objects', + substrs=[ + '3 elements', + '2 elements', + '2 key/value pairs']) + self.expect( + 'expr --element-count 3 -d run --ptr-depth=1 -- objects', + substrs=[ + '3 elements', + '2 elements', + '2 key/value pairs', + '3735928559', + '4276993775', + '3203398366', + '"Hello"', + '"World"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py index bf98559cd0c..69b9dd04887 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class PtrRef2TypedefTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -20,20 +21,21 @@ class PtrRef2TypedefTestCase(TestBase): TestBase.setUp(self) # Find the line number to break at. self.line = line_number('main.cpp', '// Set breakpoint here') - + def test_with_run_command(self): """Test that a pointer/reference to a typedef is formatted as we want.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,10 +50,18 @@ class PtrRef2TypedefTestCase(TestBase): self.runCmd('type summary add --cascade true -s "IntLRef" "int &"') self.runCmd('type summary add --cascade true -s "IntRRef" "int &&"') - self.expect("frame variable x", substrs = ['(Foo *) x = 0x','IntPointer']) + self.expect( + "frame variable x", + substrs=[ + '(Foo *) x = 0x', + 'IntPointer']) # note: Ubuntu 12.04 x86_64 build with gcc 4.8.2 is getting a # const after the ref that isn't showing up on FreeBSD. This # tweak changes the behavior so that the const is not part of # the match. - self.expect("frame variable y", substrs = ['(Foo &', ') y = 0x','IntLRef']) - self.expect("frame variable z", substrs = ['(Foo &&', ') z = 0x','IntRRef']) + self.expect( + "frame variable y", substrs=[ + '(Foo &', ') y = 0x', 'IntLRef']) + self.expect( + "frame variable z", substrs=[ + '(Foo &&', ') z = 0x', 'IntRRef']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py index db2d5806e09..2ff27ae2047 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class PyObjectSynthProviderTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,14 +34,15 @@ class PyObjectSynthProviderTestCase(TestBase): """Test that the PythonObjectSyntheticChildProvider helper class works""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -51,9 +53,20 @@ class PyObjectSynthProviderTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + self.runCmd('command script import provider.py') - self.runCmd('type synthetic add Foo --python-class provider.SyntheticChildrenProvider') + self.runCmd( + 'type synthetic add Foo --python-class provider.SyntheticChildrenProvider') self.expect('frame variable f.Name', substrs=['"Enrico"']) - self.expect('frame variable f', substrs=['ID = 123456', 'Name = "Enrico"', 'Rate = 1.25']) - self.expect('expression f', substrs=['ID = 123456', 'Name = "Enrico"', 'Rate = 1.25']) + self.expect( + 'frame variable f', + substrs=[ + 'ID = 123456', + 'Name = "Enrico"', + 'Rate = 1.25']) + self.expect( + 'expression f', + substrs=[ + 'ID = 123456', + 'Name = "Enrico"', + 'Rate = 1.25']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/provider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/provider.py index 134ae83aa1c..c263190c102 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/provider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/provider.py @@ -2,12 +2,15 @@ import lldb import lldb.formatters import lldb.formatters.synth -class SyntheticChildrenProvider(lldb.formatters.synth.PythonObjectSyntheticChildProvider): + +class SyntheticChildrenProvider( + lldb.formatters.synth.PythonObjectSyntheticChildProvider): + def __init__(self, value, internal_dict): - lldb.formatters.synth.PythonObjectSyntheticChildProvider.__init__(self, value, internal_dict) + lldb.formatters.synth.PythonObjectSyntheticChildProvider.__init__( + self, value, internal_dict) def make_children(self): - return [("ID", 123456), - ("Name", "Enrico"), - ("Rate", 1.25)] - + return [("ID", 123456), + ("Name", "Enrico"), + ("Rate", 1.25)] diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py index 13b84e9f74c..0a039107d84 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py @@ -5,12 +5,13 @@ Test that ValueObjectPrinter does not cause an infinite loop when a reference to from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class DataFormatterRefPtrRecursionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,16 +27,17 @@ class DataFormatterRefPtrRecursionTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) - self.expect("frame variable foo", substrs = []); - self.expect("frame variable foo --ptr-depth=1", substrs = ['ID = 1']); - self.expect("frame variable foo --ptr-depth=2", substrs = ['ID = 1']); - self.expect("frame variable foo --ptr-depth=3", substrs = ['ID = 1']); + self.expect("frame variable foo", substrs=[]) + self.expect("frame variable foo --ptr-depth=1", substrs=['ID = 1']) + self.expect("frame variable foo --ptr-depth=2", substrs=['ID = 1']) + self.expect("frame variable foo --ptr-depth=3", substrs=['ID = 1']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py index 791ce27dad0..804905106df 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py @@ -1,4 +1,6 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows]) +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.skipIfFreeBSD, decorators.skipIfLinux, decorators.skipIfWindows]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py index e26344f2711..c76b421a1ea 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py @@ -1,4 +1,7 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [decorators.expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772")]) +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.expectedFailureAll( + oslist=["windows"], bugnumber="llvm.org/pr24772")]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py index 2873e35368f..d7862d2327c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class Radar9974002DataFormatterTestCase(TestBase): # test for rdar://problem/9974002 () @@ -26,18 +27,20 @@ class Radar9974002DataFormatterTestCase(TestBase): """Test that that file and class static variables display correctly.""" self.build() if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion(): - self.skipTest("llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef") + self.skipTest( + "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef") self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,87 +50,98 @@ class Radar9974002DataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") - + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") + self.expect('frame variable mine', - substrs = ['mine = ', - '1', '<parent is NULL>']) + substrs=['mine = ', + '1', '<parent is NULL>']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) self.runCmd("type summary add -s foo contained") self.expect('frame variable mine', - substrs = ['mine = ', - '1', 'foo']) + substrs=['mine = ', + '1', 'foo']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', 'foo']) + substrs=['mine = ', + '1', 'foo']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '<parent is NULL>']) + substrs=['mine = ', + '1', '<parent is NULL>']) self.runCmd("type summary delete contained") self.runCmd("n") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '<parent is NULL>']) + substrs=['mine = ', + '1', '<parent is NULL>']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) self.runCmd("type summary add -s foo contained") self.expect('frame variable mine', - substrs = ['mine = ', - '1', 'foo']) + substrs=['mine = ', + '1', 'foo']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', 'foo']) + substrs=['mine = ', + '1', 'foo']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '<parent is NULL>']) + substrs=['mine = ', + '1', '<parent is NULL>']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py index e8b6c1ad95f..6d519761b7b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py @@ -5,13 +5,14 @@ Check for an issue where capping does not work because the Target pointer appear from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class SyntheticCappingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,7 +28,8 @@ class SyntheticCappingTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -35,8 +37,8 @@ class SyntheticCappingTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,7 +47,9 @@ class SyntheticCappingTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -60,25 +64,25 @@ class SyntheticCappingTestCase(TestBase): else: fake_a_val = 0x00000100 - # check that the synthetic children work, so we know we are doing the right thing + # check that the synthetic children work, so we know we are doing the + # right thing self.expect("frame variable f00_1", - substrs = ['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 1']); + substrs=['r = 34', + 'fake_a = %d' % fake_a_val, + 'a = 1']) # check that capping works self.runCmd("settings set target.max-children-count 2", check=False) - + self.expect("frame variable f00_1", - substrs = ['...', - 'fake_a = %d' % fake_a_val, - 'a = 1']); - + substrs=['...', + 'fake_a = %d' % fake_a_val, + 'a = 1']) + self.expect("frame variable f00_1", matching=False, - substrs = ['r = 34']); + substrs=['r = 34']) - self.runCmd("settings set target.max-children-count 256", check=False) self.expect("frame variable f00_1", matching=True, - substrs = ['r = 34']); + substrs=['r = 34']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py index 1a7e5679c0b..124eb5d31ba 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py @@ -1,21 +1,27 @@ import lldb + + class fooSynthProvider: + def __init__(self, valobj, dict): - self.valobj = valobj; + self.valobj = valobj self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) + def num_children(self): - return 3; + return 3 + def get_child_at_index(self, index): if index == 0: - child = self.valobj.GetChildMemberWithName('a'); + child = self.valobj.GetChildMemberWithName('a') if index == 1: - child = self.valobj.CreateChildAtOffset ('fake_a', 1, self.int_type); + child = self.valobj.CreateChildAtOffset('fake_a', 1, self.int_type) if index == 2: - child = self.valobj.GetChildMemberWithName('r'); - return child; + child = self.valobj.GetChildMemberWithName('r') + return child + def get_child_index(self, name): if name == 'a': - return 0; + return 0 if name == 'fake_a': - return 1; - return 2; + return 1 + return 2 diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py index 23a31da685d..29c1214564d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class SyntheticFilterRecomputingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class SyntheticFilterRecomputingTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -49,27 +51,37 @@ class SyntheticFilterRecomputingTestCase(TestBase): self.addTearDownHook(cleanup) # Now run the bulk of the test - id_x = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable("x") + id_x = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable("x") id_x.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) id_x.SetPreferSyntheticValue(True) - + if self.TraceOn(): self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x") - self.assertTrue(id_x.GetSummary() == '@"5 elements"', "array does not get correct summary") + self.assertTrue( + id_x.GetSummary() == '@"5 elements"', + "array does not get correct summary") self.runCmd("next") self.runCmd("frame select 0") - id_x = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable("x") + id_x = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable("x") id_x.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) id_x.SetPreferSyntheticValue(True) if self.TraceOn(): self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x") - self.assertTrue(id_x.GetNumChildren() == 7, "dictionary does not have 7 children") + self.assertTrue( + id_x.GetNumChildren() == 7, + "dictionary does not have 7 children") id_x.SetPreferSyntheticValue(False) - self.assertFalse(id_x.GetNumChildren() == 7, "dictionary still looks synthetic") + self.assertFalse( + id_x.GetNumChildren() == 7, + "dictionary still looks synthetic") id_x.SetPreferSyntheticValue(True) - self.assertTrue(id_x.GetSummary() == "7 key/value pairs", "dictionary does not get correct summary") + self.assertTrue( + id_x.GetSummary() == "7 key/value pairs", + "dictionary does not get correct summary") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py index 6568056f761..1cc2a0e431a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TypeSummaryListArgumentTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,9 +24,28 @@ class TypeSummaryListArgumentTestCase(TestBase): @no_debug_info_test def test_type_summary_list_with_arg(self): """Test that the 'type summary list' command handles command line arguments properly""" - self.expect('type summary list Foo', substrs=['Category: default', 'Category: system']) - self.expect('type summary list char', substrs=['char *', 'unsigned char']) - - self.expect('type summary list -w default', substrs=['system'], matching=False) - self.expect('type summary list -w system unsigned', substrs=['default', '0-9'], matching=False) - self.expect('type summary list -w system char', substrs=['unsigned char *'], matching=True) + self.expect( + 'type summary list Foo', + substrs=[ + 'Category: default', + 'Category: system']) + self.expect( + 'type summary list char', + substrs=[ + 'char *', + 'unsigned char']) + + self.expect( + 'type summary list -w default', + substrs=['system'], + matching=False) + self.expect( + 'type summary list -w system unsigned', + substrs=[ + 'default', + '0-9'], + matching=False) + self.expect( + 'type summary list -w system char', + substrs=['unsigned char *'], + matching=True) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py index 63a4a3a4ba8..2e66b800b15 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TypeSummaryListScriptTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -31,14 +32,15 @@ class TypeSummaryListScriptTestCase(TestBase): """Test printing out Python summary formatters.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -53,9 +55,11 @@ class TypeSummaryListScriptTestCase(TestBase): self.runCmd("command script import tslsformatters.py") - self.expect("frame variable myStruct", substrs=['A data formatter at work']) - - self.expect('type summary list', substrs=['Struct_SummaryFormatter']) - self.expect('type summary list Struct', substrs=['Struct_SummaryFormatter']) - + self.expect( + "frame variable myStruct", + substrs=['A data formatter at work']) + self.expect('type summary list', substrs=['Struct_SummaryFormatter']) + self.expect( + 'type summary list Struct', + substrs=['Struct_SummaryFormatter']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py index d1ce8b7db17..03fe17bfe76 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py @@ -1,10 +1,12 @@ import lldb + def Struct_SummaryFormatter(valobj, internal_dict): return 'A data formatter at work' category = lldb.debugger.CreateCategory("TSLSFormatters") category.SetEnabled(True) -summary = lldb.SBTypeSummary.CreateWithFunctionName("tslsformatters.Struct_SummaryFormatter", lldb.eTypeOptionCascade) +summary = lldb.SBTypeSummary.CreateWithFunctionName( + "tslsformatters.Struct_SummaryFormatter", lldb.eTypeOptionCascade) spec = lldb.SBTypeNameSpecifier("Struct", False) category.AddTypeSummary(spec, summary) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py index 41b8c3499cc..7e67f73b709 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py @@ -1,4 +1,7 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [decorators.expectedFailureAll(compiler="gcc")]) +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.expectedFailureAll( + compiler="gcc")]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py index dba2816d264..d970d11a2ba 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py @@ -5,12 +5,13 @@ Test that the user can input a format but it will not prevail over summary forma from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class UserFormatVSSummaryTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,16 +27,18 @@ class UserFormatVSSummaryTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) - self.expect("frame variable p1", substrs = ['(Pair) p1 = (x = 3, y = -3)']); + self.expect("frame variable p1", substrs=[ + '(Pair) p1 = (x = 3, y = -3)']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,12 +51,24 @@ class UserFormatVSSummaryTestCase(TestBase): self.runCmd('type summary add Pair -s "x=${var.x%d},y=${var.y%u}"') - self.expect("frame variable p1", substrs = ['(Pair) p1 = x=3,y=4294967293']); - self.expect("frame variable -f x p1", substrs = ['(Pair) p1 = x=0x00000003,y=0xfffffffd'], matching=False); - self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3'], matching=False); - self.expect("frame variable p1", substrs = ['(Pair) p1 = x=3,y=4294967293']); + self.expect("frame variable p1", substrs=[ + '(Pair) p1 = x=3,y=4294967293']) + self.expect( + "frame variable -f x p1", + substrs=['(Pair) p1 = x=0x00000003,y=0xfffffffd'], + matching=False) + self.expect( + "frame variable -f d p1", + substrs=['(Pair) p1 = x=3,y=-3'], + matching=False) + self.expect("frame variable p1", substrs=[ + '(Pair) p1 = x=3,y=4294967293']) self.runCmd('type summary add Pair -s "x=${var.x%x},y=${var.y%u}"') - self.expect("frame variable p1", substrs = ['(Pair) p1 = x=0x00000003,y=4294967293']); - self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3'],matching=False); + self.expect("frame variable p1", substrs=[ + '(Pair) p1 = x=0x00000003,y=4294967293']) + self.expect( + "frame variable -f d p1", + substrs=['(Pair) p1 = x=3,y=-3'], + matching=False) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py index 5899469651d..53073f6d910 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class VarInAggregateMisuseTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,14 +27,15 @@ class VarInAggregateMisuseTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -43,32 +45,36 @@ class VarInAggregateMisuseTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var}\" Summarize") - + self.runCmd( + "type summary add --summary-string \"SUMMARY SUCCESS ${var}\" Summarize") + self.expect('frame variable mine_ptr', - substrs = ['SUMMARY SUCCESS summarize_ptr_t @ ']) + substrs=['SUMMARY SUCCESS summarize_ptr_t @ ']) self.expect('frame variable *mine_ptr', - substrs = ['SUMMARY SUCCESS summarize_t @']) + substrs=['SUMMARY SUCCESS summarize_t @']) - self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") + self.runCmd( + "type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") self.expect('frame variable mine_ptr', - substrs = ['SUMMARY SUCCESS 10']) + substrs=['SUMMARY SUCCESS 10']) self.expect('frame variable *mine_ptr', - substrs = ['SUMMARY SUCCESS 10']) + substrs=['SUMMARY SUCCESS 10']) self.runCmd("type summary add --summary-string \"${var}\" Summarize") - self.runCmd("type summary add --summary-string \"${var}\" -e TwoSummarizes") - + self.runCmd( + "type summary add --summary-string \"${var}\" -e TwoSummarizes") + self.expect('frame variable', - substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ', - 'first = summarize_t @ ', - 'second = summarize_t @ ']) - - self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") + substrs=['(TwoSummarizes) twos = TwoSummarizes @ ', + 'first = summarize_t @ ', + 'second = summarize_t @ ']) + + self.runCmd( + "type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") self.expect('frame variable', - substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ', - 'first = SUMMARY SUCCESS 1', - 'second = SUMMARY SUCCESS 3']) + substrs=['(TwoSummarizes) twos = TwoSummarizes @ ', + 'first = SUMMARY SUCCESS 1', + 'second = SUMMARY SUCCESS 3']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py index f3eced62589..cde0ef40962 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import os.path import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class PythonSynthDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,20 +24,21 @@ class PythonSynthDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', ' // Set breakpoint here.') - @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser + @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser def test_with_run_command(self): """Test using Python synthetic children provider.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,10 +50,11 @@ class PythonSynthDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + self.runCmd("command script import helperfunc.py") - self.runCmd('type summary add -x "^something<.*>$" -s "T is a ${script.var:helperfunc.f}"') + self.runCmd( + 'type summary add -x "^something<.*>$" -s "T is a ${script.var:helperfunc.f}"') + + self.expect("frame variable x", substrs=['T is a non-pointer type']) - self.expect("frame variable x", substrs = ['T is a non-pointer type']); - - self.expect("frame variable y", substrs = ['T is a pointer type']); + self.expect("frame variable y", substrs=['T is a pointer type']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py index 01562c5baa8..75654e4b4ed 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py @@ -1,5 +1,6 @@ import lldb -def f(value,d): - return "pointer type" if value.GetType().GetTemplateArgumentType(0).IsPointerType() else "non-pointer type" +def f(value, d): + return "pointer type" if value.GetType().GetTemplateArgumentType( + 0).IsPointerType() else "non-pointer type" diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py index 365ddff3c7e..2d4cd5782fd 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py @@ -5,13 +5,14 @@ Check that vector types format properly from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class VectorTypesFormattingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,20 +24,21 @@ class VectorTypesFormattingTestCase(TestBase): self.line = line_number('main.cpp', '// break here') # rdar://problem/14035604 - @skipIf(compiler='gcc') # gcc don't have ext_vector_type extension + @skipIf(compiler='gcc') # gcc don't have ext_vector_type extension def test_with_run_command(self): """Check that vector types format properly""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,29 +48,43 @@ class VectorTypesFormattingTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - pass # my code never fails - + pass # my code never fails + v = self.frame().FindVariable("v") v.SetPreferSyntheticValue(True) v.SetFormat(lldb.eFormatVectorOfFloat32) - - if self.TraceOn(): print(v) - - self.assertTrue(v.GetNumChildren() == 4, "v as float32[] has 4 children") - self.assertTrue(v.GetChildAtIndex(0).GetData().float[0] == 1.25, "child 0 == 1.25") - self.assertTrue(v.GetChildAtIndex(1).GetData().float[0] == 1.25, "child 1 == 1.25") - self.assertTrue(v.GetChildAtIndex(2).GetData().float[0] == 2.50, "child 2 == 2.50") - self.assertTrue(v.GetChildAtIndex(3).GetData().float[0] == 2.50, "child 3 == 2.50") - - self.expect("expr -f int16_t[] -- v", substrs=['(0, 16288, 0, 16288, 0, 16416, 0, 16416)']) - self.expect("expr -f uint128_t[] -- v", substrs=['(85236745249553456609335044694184296448)']) - self.expect("expr -f float32[] -- v", substrs=['(1.25, 1.25, 2.5, 2.5)']) - + + if self.TraceOn(): + print(v) + + self.assertTrue( + v.GetNumChildren() == 4, + "v as float32[] has 4 children") + self.assertTrue(v.GetChildAtIndex(0).GetData().float[ + 0] == 1.25, "child 0 == 1.25") + self.assertTrue(v.GetChildAtIndex(1).GetData().float[ + 0] == 1.25, "child 1 == 1.25") + self.assertTrue(v.GetChildAtIndex(2).GetData().float[ + 0] == 2.50, "child 2 == 2.50") + self.assertTrue(v.GetChildAtIndex(3).GetData().float[ + 0] == 2.50, "child 3 == 2.50") + + self.expect("expr -f int16_t[] -- v", + substrs=['(0, 16288, 0, 16288, 0, 16416, 0, 16416)']) + self.expect("expr -f uint128_t[] -- v", + substrs=['(85236745249553456609335044694184296448)']) + self.expect( + "expr -f float32[] -- v", + substrs=['(1.25, 1.25, 2.5, 2.5)']) + oldValue = v.GetChildAtIndex(0).GetValue() v.SetFormat(lldb.eFormatHex) newValue = v.GetChildAtIndex(0).GetValue() - self.assertFalse(oldValue == newValue, "values did not change along with format") - + self.assertFalse(oldValue == newValue, + "values did not change along with format") + v.SetFormat(lldb.eFormatVectorOfFloat32) oldValueAgain = v.GetChildAtIndex(0).GetValue() - self.assertTrue(oldValue == oldValueAgain, "same format but different values") + self.assertTrue( + oldValue == oldValueAgain, + "same format but different values") |