[lldb] Remove prefer-dynamic-value test override

Remove the test override of `target.prefer-dynamic-value`.

Previously, the lldb default was `no-dynamic-values`. In rG9aa7e8e9ffbe (in
2015), the default was changed to `no-run-target`, but at that time the tests
were changed to be run with `no-dynamic-value`. I don't know the reasons for
not changing the tests, perhaps to avoid determining which tests to change, and
what about them to change.

Because `no-run-target` is the lldb default, I think it makes sense to make it
the test default too. It puts the test config closer to what's used in
practice.

This change removes the `target.prefer-dynamic-value` override, and for those
tests that failed, they have been updated to explicitly use
`no-dynamic-values`. Future changes could update these tests to use dynamic
values too, or they can be left as is to exercise non-dynamic typing.

Differential Revision: https://reviews.llvm.org/D132382
This commit is contained in:
Dave Lee 2022-08-21 21:48:14 -07:00
parent b1f2e2664e
commit c21dfa9e49
21 changed files with 50 additions and 15 deletions

View File

@ -51,8 +51,7 @@ sdkroot = None
dwarf_version = 0
# Any overridden settings.
# Always disable default dynamic types for testing purposes.
settings = [('target.prefer-dynamic-value', 'no-dynamic-values')]
settings = []
# Path to the FileCheck testing tool. Not optional.
filecheck = None

View File

@ -41,6 +41,8 @@ class PoVerbosityTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
self.expect("expr -O -v -- foo",
substrs=['(id) $', ' = 0x', '1 = 2', '2 = 3;'])
self.expect("expr -O -vfull -- foo",

View File

@ -32,6 +32,8 @@ class ObjCTypeQueryTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
# Now do a NSArry type query from the 'main.m' compile uint.
self.expect("expression (NSArray*)array_token",
substrs=['(NSArray *) $0 = 0x'])

View File

@ -27,6 +27,8 @@ class ObjCDataFormatterCF(ObjCDataFormatterTestCase):
STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped', 'stop reason = breakpoint'])
self.runCmd('settings set target.prefer-dynamic-value no-dynamic-values')
# 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',

View File

@ -27,6 +27,8 @@ class ObjCDataFormatterExpr(ObjCDataFormatterTestCase):
STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped', 'stop reason = breakpoint'])
self.runCmd('settings set target.prefer-dynamic-value no-dynamic-values')
# This is the function to remove the custom formats in order to have a
# clean slate for the next test case.
def cleanup():

View File

@ -21,6 +21,8 @@ class ObjCDataFormatterKVO(ObjCDataFormatterTestCase):
self, '// Set break point at this line.',
lldb.SBFileSpec('main.m', False))
self.runCmd('settings set target.prefer-dynamic-value no-dynamic-values')
# The stop reason of the thread should be breakpoint.
self.expect(
"thread list",

View File

@ -19,6 +19,8 @@ class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase):
self.appkit_tester_impl(self.nscontainers_data_formatter_commands, False)
def nscontainers_data_formatter_commands(self):
self.runCmd('settings set target.prefer-dynamic-value no-dynamic-values')
self.expect(
'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary copyDictionary newMutableDictionaryRef cfarray_ref mutable_array_ref',
substrs=[

View File

@ -24,6 +24,8 @@ class ObjCDataFormatterNSData(ObjCDataFormatterTestCase):
self.appkit_tester_impl(self.nsdata_data_formatter_commands, False)
def nsdata_data_formatter_commands(self):
self.runCmd('settings set target.prefer-dynamic-value no-dynamic-values')
self.expect(
'frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref concreteData concreteMutableData',
substrs=[

View File

@ -24,6 +24,8 @@ class ObjCDataFormatterNSNumber(ObjCDataFormatterTestCase):
self.appkit_tester_impl(self.nscontainers_data_formatter_commands, False)
def nscontainers_data_formatter_commands(self):
self.runCmd('settings set target.prefer-dynamic-value no-dynamic-values')
self.expect(
'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary cfarray_ref mutable_array_ref',
substrs=[

View File

@ -22,6 +22,8 @@ class NSStringDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',

View File

@ -74,7 +74,7 @@ class NSArraySyntheticTestCase(TestBase):
substrs=[
'@"0 elements"'])
self.expect(
'frame variable arr --ptr-depth 1 -d no-run-target',
'frame variable arr --ptr-depth 1',
substrs=[
'@"6 elements"',
'@"hello"',
@ -84,14 +84,14 @@ class NSArraySyntheticTestCase(TestBase):
'@"me"',
'@"http://www.apple.com'])
self.expect(
'frame variable other_arr --ptr-depth 1 -d no-run-target',
'frame variable other_arr --ptr-depth 1',
substrs=[
'@"4 elements"',
'(int)5',
'@"a string"',
'@"6 elements"'])
self.expect(
'frame variable other_arr --ptr-depth 2 -d no-run-target',
'frame variable other_arr --ptr-depth 2',
substrs=[
'@"4 elements"',
'@"6 elements" {',

View File

@ -86,7 +86,7 @@ class NSDictionarySyntheticTestCase(TestBase):
'[2] = ',
'[3] = '])
self.expect(
'frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target',
'frame variable dictionary --ptr-depth 1',
substrs=[
'3 key/value pairs',
'@"bar"',
@ -94,7 +94,7 @@ class NSDictionarySyntheticTestCase(TestBase):
'@"baz"',
'2 key/value pairs'])
self.expect(
'frame variable mutabledict --ptr-depth 1 --dynamic-type no-run-target',
'frame variable mutabledict --ptr-depth 1',
substrs=[
'4 key/value pairs',
'(int)23',
@ -103,7 +103,7 @@ class NSDictionarySyntheticTestCase(TestBase):
'@"sourceofstuff"',
'3 key/value pairs'])
self.expect(
'frame variable mutabledict --ptr-depth 2 --dynamic-type no-run-target',
'frame variable mutabledict --ptr-depth 2',
substrs=[
'4 key/value pairs',
'(int)23',
@ -114,7 +114,7 @@ class NSDictionarySyntheticTestCase(TestBase):
'@"bar"',
'@"2 elements"'])
self.expect(
'frame variable mutabledict --ptr-depth 3 --dynamic-type no-run-target',
'frame variable mutabledict --ptr-depth 3',
substrs=[
'4 key/value pairs',
'(int)23',

View File

@ -19,6 +19,8 @@ class TestCase(TestBase):
self.build()
lldbutil.run_to_source_breakpoint(self, "// breakpoint 1", lldb.SBFileSpec("main.cpp"))
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
j1 = self.frame().FindVariable("j1")
j1_Derived1 = j1.GetChildAtIndex(0)
j1_Derived2 = j1.GetChildAtIndex(1)

View File

@ -44,6 +44,8 @@ class TestObjCIvarsInBlocks(TestBase):
process.GetState(), lldb.eStateStopped,
"Stopped it too.")
self.runCmd('settings set target.prefer-dynamic-value no-dynamic-values')
thread_list = lldbutil.get_threads_stopped_at_breakpoint(
process, breakpoint)
self.assertEqual(len(thread_list), 1)

View File

@ -64,7 +64,7 @@ class ObjCExceptionsTestCase(TestBase):
])
self.expect(
'frame variable --dynamic-type no-run-target *e1',
'frame variable *e1',
substrs=[
'(NSException) *e1 = ',
'name = ', '"ExceptionName"',
@ -93,7 +93,7 @@ class ObjCExceptionsTestCase(TestBase):
])
self.expect(
'frame variable --dynamic-type no-run-target *e2',
'frame variable *e2',
substrs=[
'(NSException) *e2 = ',
'name = ', '"ThrownException"',

View File

@ -124,6 +124,8 @@ class FoundationTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
# The backtrace should show we stop at -[MyString description].
self.expect("thread backtrace", "Stop at -[MyString description]",
substrs=["a.out`-[MyString description]"])

View File

@ -19,6 +19,8 @@ class FoundationTestCaseString(TestBase):
self, '// Break here for NSString tests',
lldb.SBFileSpec('main.m', False))
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
# Test_NSString:
self.runCmd("thread backtrace")
self.expect("expression (int)[str length]",

View File

@ -31,6 +31,8 @@ class RuntimeTypesTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
# The backtrace should show we stop at -[MyString description].
self.expect("thread backtrace", "Stop at -[MyString description]",
substrs=["a.out`-[MyString description]"])

View File

@ -54,6 +54,8 @@ class ObjCNewSyntaxTestCaseLiteral(ObjCNewSyntaxTest):
def test_float_literal(self):
self.runToBreakpoint()
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
self.expect("expr -- @123.45", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["NSNumber", "123.45"])
@ -62,6 +64,8 @@ class ObjCNewSyntaxTestCaseLiteral(ObjCNewSyntaxTest):
def test_expressions_in_literals(self):
self.runToBreakpoint()
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
self.expect(
"expr --object-description -- @( 1 + 3 )",
VARIABLES_DISPLAYED_CORRECTLY,

View File

@ -28,6 +28,8 @@ class TestRealDefinition(TestBase):
# Run at stop at main
lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
# This should display correctly.
self.expect(
"frame variable foo->_bar->_hidden_ivar",
@ -53,6 +55,8 @@ class TestRealDefinition(TestBase):
# Run at stop at main
lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
# This should display correctly.
self.expect(
"frame variable foo->_bar->_hidden_ivar",

View File

@ -12,12 +12,12 @@ class SettingSkipSanityTestCase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
@skipIf(setting=('target.prefer-dynamic-value', 'no-dynamic-values'))
@skipIf(py_version=('>=', (3, 0)))
def testSkip(self):
"""This setting is on by default"""
self.assertTrue(False, "This test should not run!")
@skipIf(setting=('target.prefer-dynamic-value', 'run-target'))
@skipIf(py_version=('<', (3, 0)))
def testNoMatch(self):
self.assertTrue(True, "This test should run!")
@ -25,11 +25,11 @@ class SettingSkipSanityTestCase(TestBase):
def testNotExisting(self):
self.assertTrue(True, "This test should run!")
@expectedFailureAll(setting=('target.prefer-dynamic-value', 'no-dynamic-values'))
@expectedFailureAll(py_version=('>=', (3, 0)))
def testXFAIL(self):
self.assertTrue(False, "This test should run and fail!")
@expectedFailureAll(setting=('target.prefer-dynamic-value', 'run-target'))
@expectedFailureAll(py_version=('<', (3, 0)))
def testNotXFAIL(self):
self.assertTrue(True, "This test should run and succeed!")