diff options
| author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
|---|---|---|
| committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
| commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
| tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/packages/Python/lldbsuite/test/lang/objc | |
| parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
| download | bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip | |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/objc')
46 files changed, 1568 insertions, 879 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py b/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py index 01bf241b038..4a3311fb5f6 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py @@ -1,4 +1,12 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows, decorators.expectedFailureAll(bugnumber="rdar://problem/17990991")]) +lldbinline.MakeInlineTest( + __file__, + globals(), + [ + decorators.skipIfFreeBSD, + decorators.skipIfLinux, + decorators.skipIfWindows, + decorators.expectedFailureAll( + bugnumber="rdar://problem/17990991")]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py b/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py index 9fa03071c59..74e4f3bc880 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py @@ -3,13 +3,14 @@ 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 TestObjCIvarsInBlocks(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,7 +25,9 @@ class TestObjCIvarsInBlocks(TestBase): @skipUnlessDarwin @add_test_categories(['pyapi']) - @expectedFailureAll(archs=["i[3-6]86"], bugnumber="This test requires the 2.0 runtime, so it will fail on i386") + @expectedFailureAll( + archs=["i[3-6]86"], + bugnumber="This test requires the 2.0 runtime, so it will fail on i386") def test_with_python_api(self): """Test printing the ivars of the self when captured in blocks""" self.build() @@ -33,72 +36,100 @@ class TestObjCIvarsInBlocks(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - breakpoint = target.BreakpointCreateBySourceRegex ('// Break here inside the block.', self.class_source_file_spec) + breakpoint = target.BreakpointCreateBySourceRegex( + '// Break here inside the block.', self.class_source_file_spec) self.assertTrue(breakpoint, VALID_BREAKPOINT) - breakpoint_two = target.BreakpointCreateBySourceRegex ('// Break here inside the class method block.', self.class_source_file_spec) + breakpoint_two = target.BreakpointCreateBySourceRegex( + '// Break here inside the class method block.', self.class_source_file_spec) self.assertTrue(breakpoint, VALID_BREAKPOINT) - process = target.LaunchSimple (None, None, self.get_process_working_directory()) - self.assertTrue (process, "Created a process.") - self.assertTrue (process.GetState() == lldb.eStateStopped, "Stopped it too.") + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) + self.assertTrue(process, "Created a process.") + self.assertTrue( + process.GetState() == lldb.eStateStopped, + "Stopped it too.") - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue (len(thread_list) == 1) + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint) + self.assertTrue(len(thread_list) == 1) thread = thread_list[0] - + frame = thread.GetFrameAtIndex(0) - self.assertTrue (frame, "frame 0 is valid") - - # First use the FindVariable API to see if we can find the ivar by undecorated name: - direct_blocky = frame.GetValueForVariablePath ("blocky_ivar") + self.assertTrue(frame, "frame 0 is valid") + + # First use the FindVariable API to see if we can find the ivar by + # undecorated name: + direct_blocky = frame.GetValueForVariablePath("blocky_ivar") self.assertTrue(direct_blocky, "Found direct access to blocky_ivar.") - - # Now get it as a member of "self" and make sure the two values are equal: - self_var = frame.GetValueForVariablePath ("self") - self.assertTrue (self_var, "Found self in block.") - indirect_blocky = self_var.GetChildMemberWithName ("blocky_ivar") - self.assertTrue (indirect_blocky, "Found blocky_ivar through self") - + + # Now get it as a member of "self" and make sure the two values are + # equal: + self_var = frame.GetValueForVariablePath("self") + self.assertTrue(self_var, "Found self in block.") + indirect_blocky = self_var.GetChildMemberWithName("blocky_ivar") + self.assertTrue(indirect_blocky, "Found blocky_ivar through self") + error = lldb.SBError() direct_value = direct_blocky.GetValueAsSigned(error) - self.assertTrue (error.Success(), "Got direct value for blocky_ivar") + self.assertTrue(error.Success(), "Got direct value for blocky_ivar") + + indirect_value = indirect_blocky.GetValueAsSigned(error) + self.assertTrue(error.Success(), "Got indirect value for blocky_ivar") - indirect_value = indirect_blocky.GetValueAsSigned (error) - self.assertTrue (error.Success(), "Got indirect value for blocky_ivar") - - self.assertTrue (direct_value == indirect_value, "Direct and indirect values are equal.") + self.assertTrue( + direct_value == indirect_value, + "Direct and indirect values are equal.") # Now make sure that we can get at the captured ivar through the expression parser. - # Doing a little trivial math will force this into the real expression parser: - direct_expr = frame.EvaluateExpression ("blocky_ivar + 10") - self.assertTrue (direct_expr, "Got blocky_ivar through the expression parser") - - # Again, get the value through self directly and make sure they are the same: - indirect_expr = frame.EvaluateExpression ("self->blocky_ivar + 10") - self.assertTrue (indirect_expr, "Got blocky ivar through expression parser using self.") - - direct_value = direct_expr.GetValueAsSigned (error) - self.assertTrue (error.Success(), "Got value from direct use of expression parser") - - indirect_value = indirect_expr.GetValueAsSigned (error) - self.assertTrue (error.Success(), "Got value from indirect access using the expression parser") - - self.assertTrue (direct_value == indirect_value, "Direct ivar access and indirect through expression parser produce same value.") + # Doing a little trivial math will force this into the real expression + # parser: + direct_expr = frame.EvaluateExpression("blocky_ivar + 10") + self.assertTrue( + direct_expr, + "Got blocky_ivar through the expression parser") + + # Again, get the value through self directly and make sure they are the + # same: + indirect_expr = frame.EvaluateExpression("self->blocky_ivar + 10") + self.assertTrue( + indirect_expr, + "Got blocky ivar through expression parser using self.") + + direct_value = direct_expr.GetValueAsSigned(error) + self.assertTrue( + error.Success(), + "Got value from direct use of expression parser") + + indirect_value = indirect_expr.GetValueAsSigned(error) + self.assertTrue( + error.Success(), + "Got value from indirect access using the expression parser") + + self.assertTrue( + direct_value == indirect_value, + "Direct ivar access and indirect through expression parser produce same value.") process.Continue() - self.assertTrue (process.GetState() == lldb.eStateStopped, "Stopped at the second breakpoint.") + self.assertTrue( + process.GetState() == lldb.eStateStopped, + "Stopped at the second breakpoint.") - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint_two) - self.assertTrue (len(thread_list) == 1) + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint_two) + self.assertTrue(len(thread_list) == 1) thread = thread_list[0] - + frame = thread.GetFrameAtIndex(0) - self.assertTrue (frame, "frame 0 is valid") - + self.assertTrue(frame, "frame 0 is valid") + expr = frame.EvaluateExpression("(ret)") - self.assertTrue (expr, "Successfully got a local variable in a block in a class method.") + self.assertTrue( + expr, "Successfully got a local variable in a block in a class method.") - ret_value_signed = expr.GetValueAsSigned (error) + ret_value_signed = expr.GetValueAsSigned(error) # print('ret_value_signed = %i' % (ret_value_signed)) - self.assertTrue (ret_value_signed == 5, "The local variable in the block was what we expected.") + self.assertTrue( + ret_value_signed == 5, + "The local variable in the block was what we expected.") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py b/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py index c153f985660..aa2b659b84b 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py @@ -3,13 +3,14 @@ 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 ForwardDeclTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -25,7 +26,7 @@ class ForwardDeclTestCase(TestBase): @skipUnlessDarwin def test_expr(self): self.build() - + # Create a target by the debugger. target = self.dbg.CreateTarget("a.out") self.assertTrue(target, VALID_TARGET) @@ -33,23 +34,26 @@ class ForwardDeclTestCase(TestBase): # Create the breakpoint inside function 'main'. breakpoint = target.BreakpointCreateByLocation(self.source, self.line) self.assertTrue(breakpoint, VALID_BREAKPOINT) - - # Register our shared libraries for remote targets so they get automatically uploaded - environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names) + + # Register our shared libraries for remote targets so they get + # automatically uploaded + environment = self.registerSharedLibrariesWithTarget( + target, self.shlib_names) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, environment, self.get_process_working_directory()) + process = target.LaunchSimple( + None, environment, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # 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']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) # This should display correctly. self.expect("expression [j getMember]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["= 0x"]) + substrs=["= 0x"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py index 4a62d6240d9..2a81c42eb50 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py @@ -6,13 +6,14 @@ parser. 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 ConstStringTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,25 +31,30 @@ class ConstStringTestCase(TestBase): """Test constant string generation amd comparison by the expression parser.""" self.build(dictionary=self.d) self.setTearDownCleanup(self.d) - + exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, + self.main_source, + self.line, + num_expected_locations=1, + loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, - substrs = [" at %s:%d" % (self.main_source, self.line), - "stop reason = breakpoint"]) + substrs=[" at %s:%d" % (self.main_source, self.line), + "stop reason = breakpoint"]) self.expect('expression (int)[str compare:@"hello"]', - startstr = "(int) $0 = 0") + startstr="(int) $0 = 0") self.expect('expression (int)[str compare:@"world"]', - startstr = "(int) $1 = -1") + startstr="(int) $1 = -1") # Test empty strings, too. self.expect('expression (int)[@"" length]', - startstr = "(int) $2 = 0") + startstr="(int) $2 = 0") self.expect('expression (int)[@"123" length]', - startstr = "(int) $3 = 3") + startstr="(int) $3 = 3") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py index 0867eec62eb..51d9d22bf44 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py @@ -5,14 +5,15 @@ Test the lldb disassemble command on foundation framework. from __future__ import print_function - import unittest2 -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + @skipUnlessDarwin class FoundationDisassembleTestCase(TestBase): @@ -20,20 +21,23 @@ class FoundationDisassembleTestCase(TestBase): # rdar://problem/8504895 # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") + @unittest2.skipIf( + TestBase.skipLongRunningTest(), + "Skip this long running test") def test_foundation_disasm(self): """Do 'disassemble -n func' on each and every 'Code' symbol entry from the Foundation.framework.""" self.build() - + # Enable synchronous mode self.dbg.SetAsync(False) - + # Create a target by the debugger. target = self.dbg.CreateTarget("a.out") self.assertTrue(target, VALID_TARGET) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) foundation_framework = None @@ -43,7 +47,9 @@ class FoundationDisassembleTestCase(TestBase): foundation_framework = module.file.fullpath break - self.assertTrue(foundation_framework != None, "Foundation.framework path located") + self.assertTrue( + foundation_framework is not None, + "Foundation.framework path located") self.runCmd("image dump symtab '%s'" % foundation_framework) raw_output = self.res.GetOutput() # Now, grab every 'Code' symbol and feed it into the command: @@ -64,7 +70,6 @@ class FoundationDisassembleTestCase(TestBase): #print("line:", line) #print("func:", func) self.runCmd('disassemble -n "%s"' % func) - def test_simple_disasm(self): """Test the lldb 'disassemble' command""" @@ -80,25 +85,45 @@ class FoundationDisassembleTestCase(TestBase): # Stop at +[NSString stringWithFormat:]. symbol_name = "+[NSString stringWithFormat:]" - break_results = lldbutil.run_break_set_command (self, "_regexp-break %s"%(symbol_name)) - - lldbutil.check_breakpoint_result (self, break_results, symbol_name=symbol_name, num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "_regexp-break %s" % (symbol_name)) + + lldbutil.check_breakpoint_result( + self, + break_results, + symbol_name=symbol_name, + num_locations=1) # Stop at -[MyString initWithNSString:]. - lldbutil.run_break_set_by_symbol (self, '-[MyString initWithNSString:]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString initWithNSString:]', + num_expected_locations=1, + sym_exact=True) # Stop at the "description" selector. - lldbutil.run_break_set_by_selector (self, 'description', num_expected_locations=1, module_name='a.out') + lldbutil.run_break_set_by_selector( + self, + 'description', + num_expected_locations=1, + module_name='a.out') # Stop at -[NSAutoreleasePool release]. - break_results = lldbutil.run_break_set_command (self, "_regexp-break -[NSAutoreleasePool release]") - lldbutil.check_breakpoint_result (self, break_results, symbol_name='-[NSAutoreleasePool release]', num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "_regexp-break -[NSAutoreleasePool release]") + lldbutil.check_breakpoint_result( + self, + break_results, + symbol_name='-[NSAutoreleasePool release]', + num_locations=1) self.runCmd("run", RUN_SUCCEEDED) # First stop is +[NSString stringWithFormat:]. - self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", - substrs = ["Foundation`+[NSString stringWithFormat:]"]) + self.expect( + "thread backtrace", + "Stop at +[NSString stringWithFormat:]", + substrs=["Foundation`+[NSString stringWithFormat:]"]) # Do the disassemble for the currently stopped function. self.runCmd("disassemble -f") @@ -108,8 +133,10 @@ class FoundationDisassembleTestCase(TestBase): self.runCmd("process continue") # Followed by a.out`-[MyString initWithNSString:]. - self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", - substrs = ["a.out`-[MyString initWithNSString:]"]) + self.expect( + "thread backtrace", + "Stop at a.out`-[MyString initWithNSString:]", + substrs=["a.out`-[MyString initWithNSString:]"]) # Do the disassemble for the currently stopped function. self.runCmd("disassemble -f") @@ -118,7 +145,7 @@ class FoundationDisassembleTestCase(TestBase): # Followed by -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) # Do the disassemble for the currently stopped function. self.runCmd("disassemble -f") @@ -129,7 +156,7 @@ class FoundationDisassembleTestCase(TestBase): # Followed by -[NSAutoreleasePool release]. self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", - substrs = ["Foundation`-[NSAutoreleasePool release]"]) + substrs=["Foundation`-[NSAutoreleasePool release]"]) # Do the disassemble for the currently stopped function. self.runCmd("disassemble -f") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py index 2a8e80f6d76..d636458ce1a 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py @@ -6,8 +6,9 @@ Also lookup objective-c data types and evaluate expressions. from __future__ import print_function - -import os, os.path, time +import os +import os.path +import time import lldb import string from lldbsuite.test.decorators import * @@ -15,6 +16,8 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil file_index = 0 + + @skipUnlessDarwin class FoundationTestCase(TestBase): @@ -25,7 +28,9 @@ class FoundationTestCase(TestBase): TestBase.setUp(self) # Find the line number to break inside main(). self.main_source = "main.m" - self.line = line_number(self.main_source, '// Set break point at this line.') + self.line = line_number( + self.main_source, + '// Set break point at this line.') def test_break(self): """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" @@ -34,54 +39,78 @@ class FoundationTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at +[NSString stringWithFormat:]. - break_results = lldbutil.run_break_set_command(self, "_regexp-break +[NSString stringWithFormat:]") - lldbutil.check_breakpoint_result (self, break_results, symbol_name='+[NSString stringWithFormat:]', num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "_regexp-break +[NSString stringWithFormat:]") + lldbutil.check_breakpoint_result( + self, + break_results, + symbol_name='+[NSString stringWithFormat:]', + num_locations=1) # Stop at -[MyString initWithNSString:]. - lldbutil.run_break_set_by_symbol (self, '-[MyString initWithNSString:]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString initWithNSString:]', + num_expected_locations=1, + sym_exact=True) # Stop at the "description" selector. - lldbutil.run_break_set_by_selector (self, 'description', num_expected_locations=1, module_name='a.out') + lldbutil.run_break_set_by_selector( + self, + 'description', + num_expected_locations=1, + module_name='a.out') # Stop at -[NSAutoreleasePool release]. - break_results = lldbutil.run_break_set_command(self, "_regexp-break -[NSAutoreleasePool release]") - lldbutil.check_breakpoint_result (self, break_results, symbol_name='-[NSAutoreleasePool release]', num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "_regexp-break -[NSAutoreleasePool release]") + lldbutil.check_breakpoint_result( + self, + break_results, + symbol_name='-[NSAutoreleasePool release]', + num_locations=1) self.runCmd("run", RUN_SUCCEEDED) # First stop is +[NSString stringWithFormat:]. - self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", - substrs = ["Foundation`+[NSString stringWithFormat:]"]) + self.expect( + "thread backtrace", + "Stop at +[NSString stringWithFormat:]", + substrs=["Foundation`+[NSString stringWithFormat:]"]) self.runCmd("process continue") # Second stop is still +[NSString stringWithFormat:]. - self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", - substrs = ["Foundation`+[NSString stringWithFormat:]"]) + self.expect( + "thread backtrace", + "Stop at +[NSString stringWithFormat:]", + substrs=["Foundation`+[NSString stringWithFormat:]"]) self.runCmd("process continue") # Followed by a.out`-[MyString initWithNSString:]. - self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", - substrs = ["a.out`-[MyString initWithNSString:]"]) + self.expect( + "thread backtrace", + "Stop at a.out`-[MyString initWithNSString:]", + substrs=["a.out`-[MyString initWithNSString:]"]) self.runCmd("process continue") # Followed by -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) self.runCmd("process continue") # Followed by the same -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) self.runCmd("process continue") # Followed by -[NSAutoreleasePool release]. self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", - substrs = ["Foundation`-[NSAutoreleasePool release]"]) + substrs=["Foundation`-[NSAutoreleasePool release]"]) # rdar://problem/8542091 # rdar://problem/8492646 @@ -92,32 +121,40 @@ class FoundationTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at -[MyString description]. - lldbutil.run_break_set_by_symbol (self, '-[MyString description]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString description]', + num_expected_locations=1, + sym_exact=True) # self.expect("breakpoint set -n '-[MyString description]", BREAKPOINT_CREATED, -# startstr = "Breakpoint created: 1: name = '-[MyString description]', locations = 1") +# startstr = "Breakpoint created: 1: name = '-[MyString description]', +# locations = 1") self.runCmd("run", RUN_SUCCEEDED) # The backtrace should show we stop at -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) # Lookup objc data type MyString and evaluate some expressions. self.expect("image lookup -t NSString", DATA_TYPES_DISPLAYED_CORRECTLY, - substrs = ['name = "NSString"', - 'compiler_type = "@interface NSString']) + substrs=['name = "NSString"', + 'compiler_type = "@interface NSString']) self.expect("image lookup -t MyString", DATA_TYPES_DISPLAYED_CORRECTLY, - substrs = ['name = "MyString"', - 'compiler_type = "@interface MyString', - 'NSString * str;', - 'NSDate * date;']) - - self.expect("frame variable --show-types --scope", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["ARG: (MyString *) self"], - patterns = ["ARG: \(.*\) _cmd", - "(objc_selector *)|(SEL)"]) + substrs=['name = "MyString"', + 'compiler_type = "@interface MyString', + 'NSString * str;', + 'NSDate * date;']) + + self.expect( + "frame variable --show-types --scope", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["ARG: (MyString *) self"], + patterns=[ + "ARG: \(.*\) _cmd", + "(objc_selector *)|(SEL)"]) # rdar://problem/8651752 # don't crash trying to ask clang how many children an empty record has @@ -126,28 +163,37 @@ class FoundationTestCase(TestBase): # rdar://problem/8492646 # test/foundation fails after updating to tot r115023 # self->str displays nothing as output - self.expect("frame variable --show-types self->str", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "(NSString *) self->str") + self.expect( + "frame variable --show-types self->str", + VARIABLES_DISPLAYED_CORRECTLY, + startstr="(NSString *) self->str") # rdar://problem/8447030 # 'frame variable self->date' displays the wrong data member - self.expect("frame variable --show-types self->date", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "(NSDate *) self->date") + self.expect( + "frame variable --show-types self->date", + VARIABLES_DISPLAYED_CORRECTLY, + startstr="(NSDate *) self->date") # This should display the str and date member fields as well. - self.expect("frame variable --show-types *self", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["(MyString) *self", - "(NSString *) str", - "(NSDate *) date"]) - + self.expect( + "frame variable --show-types *self", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "(MyString) *self", + "(NSString *) str", + "(NSDate *) date"]) + # isa should be accessible. self.expect("expression self->isa", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["(Class)"]) + substrs=["(Class)"]) # This should fail expectedly. - self.expect("expression self->non_existent_member", - COMMAND_FAILED_AS_EXPECTED, error=True, - startstr = "error: 'MyString' does not have a member named 'non_existent_member'") + self.expect( + "expression self->non_existent_member", + COMMAND_FAILED_AS_EXPECTED, + error=True, + startstr="error: 'MyString' does not have a member named 'non_existent_member'") # Use expression parser. self.runCmd("expression self->str") @@ -163,7 +209,8 @@ class FoundationTestCase(TestBase): # self.runCmd("breakpoint delete 1") - 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("process continue") @@ -171,12 +218,15 @@ class FoundationTestCase(TestBase): # test/foundation: expr -o -- my not working? # # Test new feature with r115115: - # Add "-o" option to "expression" which prints the object description if available. - self.expect("expression --object-description -- my", "Object description displayed correctly", - patterns = ["Hello from.*a.out.*with timestamp: "]) + # Add "-o" option to "expression" which prints the object description + # if available. + self.expect( + "expression --object-description -- my", + "Object description displayed correctly", + patterns=["Hello from.*a.out.*with timestamp: "]) @add_test_categories(['pyapi']) - def test_print_ivars_correctly (self): + def test_print_ivars_correctly(self): self.build() # See: <rdar://problem/8717050> lldb needs to use the ObjC runtime symbols for ivar offsets # Only fails for the ObjC 2.0 runtime. @@ -189,7 +239,8 @@ class FoundationTestCase(TestBase): self.assertTrue(break1, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) @@ -205,7 +256,7 @@ class FoundationTestCase(TestBase): cur_frame = thread.GetFrameAtIndex(0) line_number = cur_frame.GetLineEntry().GetLine() - self.assertTrue (line_number == self.line, "Hit the first breakpoint.") + self.assertTrue(line_number == self.line, "Hit the first breakpoint.") my_var = cur_frame.FindVariable("my") self.assertTrue(my_var, "Made a variable object for my") @@ -222,7 +273,9 @@ class FoundationTestCase(TestBase): my_str_value = int(my_str_var.GetValue(), 0) - self.assertTrue(str_value == my_str_value, "Got the correct value for my->str") + self.assertTrue( + str_value == my_str_value, + "Got the correct value for my->str") def test_expression_lookups_objc(self): """Test running an expression detect spurious debug info lookups (DWARF).""" @@ -231,32 +284,43 @@ class FoundationTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at -[MyString initWithNSString:]. - lldbutil.run_break_set_by_symbol (self, '-[MyString initWithNSString:]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString initWithNSString:]', + num_expected_locations=1, + sym_exact=True) self.runCmd("run", RUN_SUCCEEDED) global file_index # Log any DWARF lookups ++file_index - logfile = os.path.join(os.getcwd(), "dwarf-lookups-" + self.getArchitecture() + "-" + str(file_index) + ".txt") + logfile = os.path.join( + os.getcwd(), + "dwarf-lookups-" + + self.getArchitecture() + + "-" + + str(file_index) + + ".txt") self.runCmd("log enable -f %s dwarf lookups" % (logfile)) self.runCmd("expr self") self.runCmd("log disable dwarf lookups") - + def cleanup(): - if os.path.exists (logfile): - os.unlink (logfile) - + if os.path.exists(logfile): + os.unlink(logfile) + self.addTearDownHook(cleanup) - - if os.path.exists (logfile): + + if os.path.exists(logfile): f = open(logfile) lines = f.readlines() num_errors = 0 for line in lines: if string.find(line, "$__lldb") != -1: if num_errors == 0: - print("error: found spurious name lookups when evaluating an expression:") + print( + "error: found spurious name lookups when evaluating an expression:") num_errors += 1 print(line, end='') self.assertTrue(num_errors == 0, "Spurious lookups detected") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py index 1ee01f7f35f..8f836a1da73 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py @@ -5,28 +5,44 @@ Test more expression command sequences with objective-c. 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 + @skipUnlessDarwin class FoundationTestCase2(TestBase): mydir = TestBase.compute_mydir(__file__) - + def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line numbers to break at. self.lines = [] - self.lines.append(line_number('main.m', '// Break here for selector: tests')) - self.lines.append(line_number('main.m', '// Break here for NSArray tests')) - self.lines.append(line_number('main.m', '// Break here for NSString tests')) - self.lines.append(line_number('main.m', '// Break here for description test')) - self.lines.append(line_number('main.m', '// Set break point at this line')) + self.lines.append( + line_number( + 'main.m', + '// Break here for selector: tests')) + self.lines.append( + line_number( + 'main.m', + '// Break here for NSArray tests')) + self.lines.append( + line_number( + 'main.m', + '// Break here for NSString tests')) + self.lines.append( + line_number( + 'main.m', + '// Break here for description test')) + self.lines.append( + line_number( + 'main.m', + '// Set break point at this line')) def test_more_expr_commands(self): """More expression commands for objective-c.""" @@ -36,15 +52,16 @@ class FoundationTestCase2(TestBase): # Create a bunch of breakpoints. for line in self.lines: - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # Test_Selector: self.runCmd("thread backtrace") self.expect("expression (char *)sel_getName(sel)", - substrs = ["(char *)", - "length"]) + substrs=["(char *)", + "length"]) self.runCmd("process continue") @@ -59,8 +76,8 @@ class FoundationTestCase2(TestBase): # Test_MyString: self.runCmd("thread backtrace") self.expect("expression (char *)sel_getName(_cmd)", - substrs = ["(char *)", - "description"]) + substrs=["(char *)", + "description"]) self.runCmd("process continue") @@ -72,25 +89,29 @@ class FoundationTestCase2(TestBase): # Break inside Test_NSArray: line = self.lines[1] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # Test_NSArray: self.runCmd("thread backtrace") self.expect("expression (int)[nil_mutable_array count]", - patterns = ["\(int\) \$.* = 0"]) + patterns=["\(int\) \$.* = 0"]) self.expect("expression (int)[array1 count]", - patterns = ["\(int\) \$.* = 3"]) + patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)[array2 count]", - patterns = ["\(int\) \$.* = 3"]) + patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)array1.count", - patterns = ["\(int\) \$.* = 3"]) + patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)array2.count", - patterns = ["\(int\) \$.* = 3"]) + patterns=["\(int\) \$.* = 3"]) self.runCmd("process continue") - @expectedFailureAll(oslist=["macosx"], debug_info="gmodules", bugnumber="llvm.org/pr27861") + @expectedFailureAll( + oslist=["macosx"], + debug_info="gmodules", + bugnumber="llvm.org/pr27861") def test_NSString_expr_commands(self): """Test expression commands for NSString.""" self.build() @@ -99,20 +120,21 @@ class FoundationTestCase2(TestBase): # Break inside Test_NSString: line = self.lines[2] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # Test_NSString: self.runCmd("thread backtrace") self.expect("expression (int)[str length]", - patterns = ["\(int\) \$.* ="]) + patterns=["\(int\) \$.* ="]) self.expect("expression (int)[str_id length]", - patterns = ["\(int\) \$.* ="]) + patterns=["\(int\) \$.* ="]) self.expect("expression [str description]", - patterns = ["\(id\) \$.* = 0x"]) + patterns=["\(id\) \$.* = 0x"]) self.expect("expression (id)[str_id description]", - patterns = ["\(id\) \$.* = 0x"]) + patterns=["\(id\) \$.* = 0x"]) self.expect("expression str.length") self.expect("expression str.description") self.expect('expression str = @"new"') @@ -125,15 +147,21 @@ class FoundationTestCase2(TestBase): self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - + line = self.lines[4] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) - - self.expect("expression --show-types -- *my", - patterns = ["\(MyString\) \$.* = ", "\(MyBase\)", "\(NSObject\)", "\(Class\)"]) + + self.expect( + "expression --show-types -- *my", + patterns=[ + "\(MyString\) \$.* = ", + "\(MyBase\)", + "\(NSObject\)", + "\(Class\)"]) self.runCmd("process continue") @expectedFailureAll(archs=["i[3-6]86"]) @@ -142,30 +170,35 @@ class FoundationTestCase2(TestBase): self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - + line = self.lines[4] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) - self.expect('po [NSError errorWithDomain:@"Hello" code:35 userInfo:@{@"NSDescription" : @"be completed."}]', - substrs = ["Error Domain=Hello", "Code=35", "be completed."]) + self.expect( + 'po [NSError errorWithDomain:@"Hello" code:35 userInfo:@{@"NSDescription" : @"be completed."}]', + substrs=[ + "Error Domain=Hello", + "Code=35", + "be completed."]) self.runCmd("process continue") - + def test_NSError_p(self): """Test that p of the result of an unknown method does require a cast.""" self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - + line = self.lines[4] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) - self.expect("p [NSError thisMethodIsntImplemented:0]", - error = True, - patterns = ["no known method", "cast the message send to the method's return type"]) + self.expect("p [NSError thisMethodIsntImplemented:0]", error=True, patterns=[ + "no known method", "cast the message send to the method's return type"]) self.runCmd("process continue") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py index 13ef44f195b..8ef9f39434e 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py @@ -5,14 +5,15 @@ Test SBValue.GetObjectDescription() with the value from SBTarget.FindGlobalVaria from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjectDescriptionAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,7 +23,8 @@ class ObjectDescriptionAPITestCase(TestBase): TestBase.setUp(self) # Find the line number to break at. self.source = 'main.m' - self.line = line_number(self.source, '// Set break point at this line.') + self.line = line_number( + self.source, '// Set break point at this line.') # rdar://problem/10857337 @skipUnlessDarwin @@ -42,11 +44,13 @@ class ObjectDescriptionAPITestCase(TestBase): self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # Make sure we hit our breakpoint: - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue (len(thread_list) == 1) + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint) + self.assertTrue(len(thread_list) == 1) thread = thread_list[0] frame0 = thread.GetFrameAtIndex(0) @@ -59,7 +63,8 @@ class ObjectDescriptionAPITestCase(TestBase): print("val:", v) print("object description:", v.GetObjectDescription()) if v.GetName() == 'my_global_str': - self.assertTrue(v.GetObjectDescription() == 'This is a global string') + self.assertTrue(v.GetObjectDescription() == + 'This is a global string') # But not here! value_list2 = target.FindGlobalVariables('my_global_str', 3) @@ -69,4 +74,5 @@ class ObjectDescriptionAPITestCase(TestBase): print("val:", v) print("object description:", v.GetObjectDescription()) if v.GetName() == 'my_global_str': - self.assertTrue(v.GetObjectDescription() == 'This is a global string') + self.assertTrue(v.GetObjectDescription() == + 'This is a global string') diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py index 8b37f9309ac..334ebba8e64 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py @@ -5,19 +5,23 @@ Test that Objective-C methods from the runtime work correctly. 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 + @skipUnlessDarwin class RuntimeTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["macosx"], debug_info="gmodules", bugnumber="llvm.org/pr27862") + @expectedFailureAll( + oslist=["macosx"], + debug_info="gmodules", + bugnumber="llvm.org/pr27862") def test_break(self): """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" if self.getArchitecture() != 'x86_64': @@ -28,23 +32,31 @@ class RuntimeTypesTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at -[MyString description]. - lldbutil.run_break_set_by_symbol (self, '-[MyString description]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString description]', + num_expected_locations=1, + sym_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The backtrace should show we stop at -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) # Use runtime information about NSString. # The length property should be usable. self.expect("expression str.length", VARIABLES_DISPLAYED_CORRECTLY, - patterns = [r"(\(unsigned long long\))|\(NSUInteger\)"]) + patterns=[r"(\(unsigned long long\))|\(NSUInteger\)"]) # Static methods on NSString should work. - self.expect("expr [NSString stringWithCString:\"foo\" encoding:1]", VALID_TYPE, - substrs = ["(id)", "$1"]) + self.expect( + "expr [NSString stringWithCString:\"foo\" encoding:1]", + VALID_TYPE, + substrs=[ + "(id)", + "$1"]) self.expect("po $1", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo"]) + substrs=["foo"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py index b75a874c814..6e5bc4d9fb0 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py @@ -5,7 +5,6 @@ Test symbol table access for main.m. from __future__ import print_function - import os import time @@ -14,6 +13,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + @skipUnlessDarwin class FoundationSymtabTestCase(TestBase): @@ -23,7 +23,8 @@ class FoundationSymtabTestCase(TestBase): '-[MyString dealloc]', '-[MyString description]', '-[MyString descriptionPauses]', # synthesized property - '-[MyString setDescriptionPauses:]', # synthesized property + # synthesized property + '-[MyString setDescriptionPauses:]', 'Test_Selector', 'Test_NSString', 'Test_MyString', @@ -42,7 +43,8 @@ class FoundationSymtabTestCase(TestBase): self.assertTrue(target, VALID_TARGET) # Launch the process, and do not stop at the entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) # # Exercise Python APIs to access the symbol table entries. diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py b/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py index 24ae1a8852b..bcd4a41e0df 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py @@ -3,13 +3,14 @@ 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 TestObjCGlobalVar(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,26 +30,31 @@ class TestObjCGlobalVar(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - bkpt = target.BreakpointCreateBySourceRegex ('NSLog', self.main_source) + bkpt = target.BreakpointCreateBySourceRegex('NSLog', self.main_source) self.assertTrue(bkpt, VALID_BREAKPOINT) # Before we launch, make an SBValue for our global object pointer: g_obj_ptr = target.FindFirstGlobalVariable("g_obj_ptr") self.assertTrue(g_obj_ptr.GetError().Success(), "Made the g_obj_ptr") - self.assertTrue(g_obj_ptr.GetValueAsUnsigned(10) == 0, "g_obj_ptr is initially null") + self.assertTrue( + g_obj_ptr.GetValueAsUnsigned(10) == 0, + "g_obj_ptr is initially null") # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - threads = lldbutil.get_threads_stopped_at_breakpoint (process, bkpt) + threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt) if len(threads) != 1: - self.fail ("Failed to stop at breakpoint 1.") + self.fail("Failed to stop at breakpoint 1.") thread = threads[0] dyn_value = g_obj_ptr.GetDynamicValue(lldb.eDynamicCanRunTarget) - self.assertTrue(dyn_value.GetError().Success(), "Dynamic value is valid") + self.assertTrue( + dyn_value.GetError().Success(), + "Dynamic value is valid") self.assertTrue(dyn_value.GetObjectDescription() == "Some NSString") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py b/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py index ee5589cb96c..ee21189ab7c 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py @@ -3,7 +3,6 @@ from __future__ import print_function - import unittest2 import os import subprocess @@ -14,6 +13,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class HiddenIvarsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -25,11 +25,14 @@ class HiddenIvarsTestCase(TestBase): self.source = 'main.m' self.line = line_number(self.source, '// breakpoint1') # The makefile names of the shared libraries as they appear in DYLIB_NAME. - # The names should have no loading "lib" or extension as they will be localized + # The names should have no loading "lib" or extension as they will be + # localized self.shlib_names = ["InternalDefiner"] @skipUnlessDarwin - @skipIf(debug_info=no_match("dsym"), bugnumber="This test requires a stripped binary and a dSYM") + @skipIf( + debug_info=no_match("dsym"), + bugnumber="This test requires a stripped binary and a dSYM") def test_expr_stripped(self): if self.getArchitecture() == 'i386': self.skipTest("requires modern objc runtime") @@ -46,7 +49,9 @@ class HiddenIvarsTestCase(TestBase): self.expr(False) @skipUnlessDarwin - @skipIf(debug_info=no_match("dsym"), bugnumber="This test requires a stripped binary and a dSYM") + @skipIf( + debug_info=no_match("dsym"), + bugnumber="This test requires a stripped binary and a dSYM") def test_frame_variable_stripped(self): if self.getArchitecture() == 'i386': self.skipTest("requires modern objc runtime") @@ -70,14 +75,22 @@ class HiddenIvarsTestCase(TestBase): else: self.build() self.common_setup(False) - self.expect("frame variable k->bar", VARIABLES_DISPLAYED_CORRECTLY, substrs = ["= 3"]) - + self.expect( + "frame variable k->bar", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["= 3"]) + def common_setup(self, strip): - + if strip: - self.assertTrue(subprocess.call(['/usr/bin/strip', '-Sx', 'libInternalDefiner.dylib']) == 0, 'stripping dylib succeeded') - self.assertTrue(subprocess.call(['/bin/rm', '-rf', 'libInternalDefiner.dylib.dSYM']) == 0, 'remove dylib dSYM file succeeded') - self.assertTrue(subprocess.call(['/usr/bin/strip', '-Sx', 'a.out']) == 0, 'stripping a.out succeeded') + self.assertTrue(subprocess.call( + ['/usr/bin/strip', '-Sx', 'libInternalDefiner.dylib']) == 0, 'stripping dylib succeeded') + self.assertTrue(subprocess.call(['/bin/rm', + '-rf', + 'libInternalDefiner.dylib.dSYM']) == 0, + 'remove dylib dSYM file succeeded') + self.assertTrue(subprocess.call( + ['/usr/bin/strip', '-Sx', 'a.out']) == 0, 'stripping a.out succeeded') # Create a target by the debugger. target = self.dbg.CreateTarget("a.out") self.assertTrue(target, VALID_TARGET) @@ -85,91 +98,140 @@ class HiddenIvarsTestCase(TestBase): # Create the breakpoint inside function 'main'. breakpoint = target.BreakpointCreateByLocation(self.source, self.line) self.assertTrue(breakpoint, VALID_BREAKPOINT) - - # Register our shared libraries for remote targets so they get automatically uploaded - environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names) + + # Register our shared libraries for remote targets so they get + # automatically uploaded + environment = self.registerSharedLibrariesWithTarget( + target, self.shlib_names) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, environment, self.get_process_working_directory()) + process = target.LaunchSimple( + None, environment, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - + exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. - 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']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) def expr(self, strip): self.common_setup(strip) # This should display correctly. - self.expect("expression (j->_definer->foo)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["= 4"]) + self.expect( + "expression (j->_definer->foo)", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["= 4"]) - self.expect("expression (j->_definer->bar)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["= 5"]) + self.expect( + "expression (j->_definer->bar)", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["= 5"]) if strip: - self.expect("expression *(j->_definer)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo = 4"]) + self.expect( + "expression *(j->_definer)", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["foo = 4"]) else: - self.expect("expression *(j->_definer)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo = 4", "bar = 5"]) + self.expect( + "expression *(j->_definer)", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "foo = 4", + "bar = 5"]) self.expect("expression (k->foo)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["= 2"]) + substrs=["= 2"]) self.expect("expression (k->bar)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["= 3"]) + substrs=["= 3"]) - self.expect("expression k.filteredDataSource", VARIABLES_DISPLAYED_CORRECTLY, - substrs = [' = 0x', '"2 elements"']) + self.expect( + "expression k.filteredDataSource", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + ' = 0x', + '"2 elements"']) if strip: self.expect("expression *(k)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo = 2", ' = 0x', '"2 elements"']) - else: - self.expect("expression *(k)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo = 2", "bar = 3", '_filteredDataSource = 0x', '"2 elements"']) + substrs=["foo = 2", ' = 0x', '"2 elements"']) + else: + self.expect( + "expression *(k)", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "foo = 2", + "bar = 3", + '_filteredDataSource = 0x', + '"2 elements"']) def frame_var(self, strip): self.common_setup(strip) # This should display correctly. - self.expect("frame variable j->_definer->foo", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["= 4"]) + self.expect( + "frame variable j->_definer->foo", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["= 4"]) if not strip: - self.expect("frame variable j->_definer->bar", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["= 5"]) - + self.expect( + "frame variable j->_definer->bar", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["= 5"]) + if strip: - self.expect("frame variable *j->_definer", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo = 4"]) + self.expect( + "frame variable *j->_definer", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["foo = 4"]) else: - self.expect("frame variable *j->_definer", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo = 4", "bar = 5"]) + self.expect( + "frame variable *j->_definer", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "foo = 4", + "bar = 5"]) self.expect("frame variable k->foo", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["= 2"]) + substrs=["= 2"]) - self.expect("frame variable k->_filteredDataSource", VARIABLES_DISPLAYED_CORRECTLY, - substrs = [' = 0x', '"2 elements"']) + self.expect( + "frame variable k->_filteredDataSource", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + ' = 0x', + '"2 elements"']) if strip: - self.expect("frame variable *k", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo = 2", '_filteredDataSource = 0x', '"2 elements"']) + self.expect( + "frame variable *k", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "foo = 2", + '_filteredDataSource = 0x', + '"2 elements"']) else: - self.expect("frame variable *k", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo = 2", "bar = 3", '_filteredDataSource = 0x', '"2 elements"']) + self.expect( + "frame variable *k", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "foo = 2", + "bar = 3", + '_filteredDataSource = 0x', + '"2 elements"']) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py b/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py index b91725d57c6..94f01e4045b 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py @@ -5,8 +5,8 @@ Test that dynamically discovered ivars of type IMP do not crash LLDB from __future__ import print_function - -import os, time +import os +import time import re import lldb @@ -15,7 +15,8 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -def execute_command (command): + +def execute_command(command): # print('%% %s' % (command)) (exit_status, output) = seven.get_command_status_output(command) # if output: @@ -23,6 +24,7 @@ def execute_command (command): # print('status = %u' % (exit_status)) return exit_status + class ObjCiVarIMPTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -34,8 +36,9 @@ class ObjCiVarIMPTestCase(TestBase): if self.getArchitecture() == 'i386': # rdar://problem/9946499 self.skipTest("Dynamic types for ObjC V1 runtime not implemented") - + execute_command("make repro") + def cleanup(): execute_command("make cleanup") self.addTearDownHook(cleanup) @@ -43,23 +46,25 @@ class ObjCiVarIMPTestCase(TestBase): exe = os.path.join(os.getcwd(), "a.out") # Create a target from the debugger. - target = self.dbg.CreateTarget (exe) + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Set up our breakpoint - bkpt = lldbutil.run_break_set_by_source_regexp (self, "break here") + bkpt = lldbutil.run_break_set_by_source_regexp(self, "break here") # Now launch the process, and do not stop at the entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - self.expect('frame variable --ptr-depth=1 --show-types -d run -- object', substrs=[ - '(MyClass *) object = 0x', - '(void *) myImp = 0x' - ]) - self.expect('disassemble --start-address `((MyClass*)object)->myImp`', substrs=[ - '-[MyClass init]' - ]) + self.expect( + 'frame variable --ptr-depth=1 --show-types -d run -- object', + substrs=[ + '(MyClass *) object = 0x', + '(void *) myImp = 0x']) + self.expect( + 'disassemble --start-address `((MyClass*)object)->myImp`', + substrs=['-[MyClass init]']) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py b/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py index fece47625a8..8af906e0842 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py @@ -3,10 +3,10 @@ from __future__ import print_function - from distutils.version import StrictVersion import unittest2 -import os, time +import os +import time import lldb import platform @@ -14,6 +14,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCModulesAutoImportTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,28 +27,30 @@ class ObjCModulesAutoImportTestCase(TestBase): @skipUnlessDarwin @unittest2.expectedFailure("rdar://problem/19991953") - @expectedFailureDarwin # clang: error: unknown argument: '-gmodules' - @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion('12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") + @expectedFailureDarwin # clang: error: unknown argument: '-gmodules' + @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion( + '12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") def test_expr(self): self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. - 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']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) self.runCmd("settings set target.auto-import-clang-modules true") self.expect("p getpid()", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["pid_t"]) + substrs=["pid_t"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py b/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py index 56fcaa05078..aa8414267db 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py @@ -3,7 +3,6 @@ from __future__ import print_function - import unittest2 import platform from distutils.version import StrictVersion @@ -12,6 +11,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class IncompleteModulesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,7 +24,8 @@ class IncompleteModulesTestCase(TestBase): @skipUnlessDarwin @unittest2.expectedFailure("rdar://20416388") - @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion('12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") + @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion( + '12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") @skipIfDarwin # llvm.org/pr26267 def test_expr(self): self.build() @@ -32,29 +33,37 @@ class IncompleteModulesTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. - 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']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) - self.runCmd("settings set target.clang-module-search-paths \"" + os.getcwd() + "\"") + self.runCmd( + "settings set target.clang-module-search-paths \"" + + os.getcwd() + + "\"") self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["int", "3"]) + substrs=["int", "3"]) - self.expect("expr [myObject privateMethod]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["int", "5"]) + self.expect( + "expr [myObject privateMethod]", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "int", + "5"]) self.expect("expr MIN(2,3)", "#defined macro was found", - substrs = ["int", "2"]) + substrs=["int", "2"]) self.expect("expr MAX(2,3)", "#undefd macro was correcltly not found", - error=True) + error=True) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py b/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py index 6a9d9b518e1..87c75cefe64 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py @@ -3,11 +3,11 @@ from __future__ import print_function - from distutils.version import StrictVersion import unittest2 -import os, time +import os +import time import platform import lldb @@ -15,6 +15,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ModulesInlineFunctionsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,7 +27,8 @@ class ModulesInlineFunctionsTestCase(TestBase): self.line = line_number('main.m', '// Set breakpoint here.') @skipUnlessDarwin - @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion('12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") + @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion( + '12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") @expectedFailureDarwin("llvm.org/pr25743") def test_expr(self): self.build() @@ -34,23 +36,27 @@ class ModulesInlineFunctionsTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. - 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']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) - self.runCmd("settings set target.clang-module-search-paths \"" + os.getcwd() + "\"") + self.runCmd( + "settings set target.clang-module-search-paths \"" + + os.getcwd() + + "\"") self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["int", "3"]) + substrs=["int", "3"]) self.expect("expr isInline(2)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["4"]) + substrs=["4"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py b/lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py index 0efdb305584..d91e2a70c8c 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py @@ -3,9 +3,9 @@ from __future__ import print_function - import unittest2 -import os, time +import os +import time import platform from distutils.version import StrictVersion @@ -14,6 +14,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCModulesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,7 +27,8 @@ class ObjCModulesTestCase(TestBase): @skipUnlessDarwin @unittest2.expectedFailure("rdar://20416388") - @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion('12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") + @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion( + '12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") def test_expr(self): if not self.applies(): return @@ -36,36 +38,48 @@ class ObjCModulesTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. - 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']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) self.expect("expr @import Darwin; 3", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["int", "3"]) + substrs=["int", "3"]) self.expect("expr getpid()", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["pid_t"]) + substrs=["pid_t"]) - self.expect("expr @import Foundation; 4", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["int", "4"]) + self.expect( + "expr @import Foundation; 4", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "int", + "4"]) self.expect("expr string.length", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["NSUInteger", "5"]) + substrs=["NSUInteger", "5"]) self.expect("expr array.count", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["NSUInteger", "3"]) - - self.expect("p *[NSURL URLWithString:@\"http://lldb.llvm.org\"]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["NSURL", "isa", "_urlString"]) - - self.expect("p [NSURL URLWithString:@\"http://lldb.llvm.org\"].scheme", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["http"]) + substrs=["NSUInteger", "3"]) + + self.expect( + "p *[NSURL URLWithString:@\"http://lldb.llvm.org\"]", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "NSURL", + "isa", + "_urlString"]) + + self.expect( + "p [NSURL URLWithString:@\"http://lldb.llvm.org\"].scheme", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["http"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py index c702eafa1f2..5b91f9848a9 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py @@ -5,13 +5,14 @@ Make sure that ivars of Objective-C++ classes are visible in LLDB. 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 ObjCXXTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,9 +27,10 @@ class ObjCXXTestCase(TestBase): exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, 'breakpoint 1', num_expected_locations=1) + lldbutil.run_break_set_by_source_regexp( + self, 'breakpoint 1', num_expected_locations=1) self.runCmd("run", RUN_SUCCEEDED) self.expect("expr f->f", "Found ivar in class", - substrs = ["= 3"]) + substrs=["= 3"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py index fa390cb0ad7..0f82cc68df8 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py @@ -5,20 +5,21 @@ Use lldb Python API to test base class resolution for ObjC classes from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCDynamicValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): - # Call super's setUp(). + # Call super's setUp(). TestBase.setUp(self) self.line = line_number('main.m', '// Set breakpoint here.') @@ -36,13 +37,14 @@ class ObjCDynamicValueTestCase(TestBase): # Create a target from the debugger. - target = self.dbg.CreateTarget (exe) + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Set up our breakpoints: target.BreakpointCreateByLocation('main.m', self.line) - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) @@ -50,10 +52,17 @@ class ObjCDynamicValueTestCase(TestBase): var = self.frame().FindVariable("foo") var_ptr_type = var.GetType() var_pte_type = var_ptr_type.GetPointeeType() - self.assertTrue(var_ptr_type.GetNumberOfDirectBaseClasses() == 1, "Foo * has one base class") - self.assertTrue(var_pte_type.GetNumberOfDirectBaseClasses() == 1, "Foo has one base class") - - self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(0).IsValid(), "Foo * has a valid base class") - self.assertTrue(var_pte_type.GetDirectBaseClassAtIndex(0).IsValid(), "Foo * has a valid base class") - - self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(0).GetName() == var_pte_type.GetDirectBaseClassAtIndex(0).GetName(), "Foo and its pointer type don't agree on their base class") + self.assertTrue( + var_ptr_type.GetNumberOfDirectBaseClasses() == 1, + "Foo * has one base class") + self.assertTrue( + var_pte_type.GetNumberOfDirectBaseClasses() == 1, + "Foo has one base class") + + self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex( + 0).IsValid(), "Foo * has a valid base class") + self.assertTrue(var_pte_type.GetDirectBaseClassAtIndex( + 0).IsValid(), "Foo * has a valid base class") + + self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(0).GetName() == var_pte_type.GetDirectBaseClassAtIndex( + 0).GetName(), "Foo and its pointer type don't agree on their base class") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py index 3ff76d4194d..d92daab8035 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py @@ -3,13 +3,14 @@ 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 TestObjCBuiltinTypes(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,7 +20,8 @@ class TestObjCBuiltinTypes(TestBase): TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "main.cpp" - self.break_line = line_number(self.main_source, '// Set breakpoint here.') + self.break_line = line_number( + self.main_source, '// Set breakpoint here.') @skipUnlessDarwin @add_test_categories(['pyapi']) @@ -32,25 +34,31 @@ class TestObjCBuiltinTypes(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) + bpt = target.BreakpointCreateByLocation( + self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt) + thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt) # Make sure we stopped at the first breakpoint. - self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.") - self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.") - - # Now make sure we can call a function in the class method we've stopped in. + self.assertTrue( + len(thread_list) != 0, + "No thread stopped at our breakpoint.") + self.assertTrue(len(thread_list) == 1, + "More than one thread stopped at our breakpoint.") + + # Now make sure we can call a function in the class method we've + # stopped in. frame = thread_list[0].GetFrameAtIndex(0) - self.assertTrue (frame, "Got a valid frame 0 frame.") + self.assertTrue(frame, "Got a valid frame 0 frame.") - self.expect("expr (foo)", patterns = ["\(ns::id\) \$.* = 0"]) + self.expect("expr (foo)", patterns=["\(ns::id\) \$.* = 0"]) - self.expect("expr id my_id = 0; my_id", patterns = ["\(id\) \$.* = nil"]) + self.expect("expr id my_id = 0; my_id", patterns=["\(id\) \$.* = nil"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py index 901d84fb96d..1bd8f1af230 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py @@ -5,23 +5,24 @@ Use lldb Python API to make sure the dynamic checkers are doing their jobs. from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCCheckerTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): - # Call super's setUp(). + # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break for main.c. + # Find the line number to break for main.c. self.source_name = 'main.m' @skipUnlessDarwin @@ -36,41 +37,43 @@ class ObjCCheckerTestCase(TestBase): # Create a target from the debugger. - target = self.dbg.CreateTarget (exe) + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Set up our breakpoints: - - main_bkpt = target.BreakpointCreateBySourceRegex ("Set a breakpoint here.", lldb.SBFileSpec (self.source_name)) + main_bkpt = target.BreakpointCreateBySourceRegex( + "Set a breakpoint here.", lldb.SBFileSpec(self.source_name)) self.assertTrue(main_bkpt and main_bkpt.GetNumLocations() == 1, VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - threads = lldbutil.get_threads_stopped_at_breakpoint (process, main_bkpt) - self.assertTrue (len(threads) == 1) + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, main_bkpt) + self.assertTrue(len(threads) == 1) thread = threads[0] # - # The class Simple doesn't have a count method. Make sure that we don't + # The class Simple doesn't have a count method. Make sure that we don't # actually try to send count but catch it as an unrecognized selector. frame = thread.GetFrameAtIndex(0) expr_value = frame.EvaluateExpression("(int) [my_simple count]", False) expr_error = expr_value.GetError() - self.assertTrue (expr_error.Fail()) - + self.assertTrue(expr_error.Fail()) + # Make sure the call produced no NSLog stdout. stdout = process.GetSTDOUT(100) - self.assertTrue (stdout is None or (len(stdout) == 0)) - + self.assertTrue(stdout is None or (len(stdout) == 0)) + # Make sure the error is helpful: err_string = expr_error.GetCString() - self.assertTrue ("selector" in err_string) + self.assertTrue("selector" in err_string) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py index a5767562c07..5140f26c4fd 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py @@ -3,13 +3,14 @@ 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 TestObjCClassMethod(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,12 +20,13 @@ class TestObjCClassMethod(TestBase): TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "class.m" - self.break_line = line_number(self.main_source, '// Set breakpoint here.') + self.break_line = line_number( + self.main_source, '// Set breakpoint here.') @skipUnlessDarwin @expectedFailureAll(archs=["i[3-6]86"]) @add_test_categories(['pyapi']) - #rdar://problem/9745789 "expression" can't call functions in class methods + # rdar://problem/9745789 "expression" can't call functions in class methods def test_with_python_api(self): """Test calling functions in class methods.""" self.build() @@ -33,25 +35,32 @@ class TestObjCClassMethod(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) + bpt = target.BreakpointCreateByLocation( + self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt) + thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt) # Make sure we stopped at the first breakpoint. - self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.") - self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.") - - # Now make sure we can call a function in the class method we've stopped in. + self.assertTrue( + len(thread_list) != 0, + "No thread stopped at our breakpoint.") + self.assertTrue(len(thread_list) == 1, + "More than one thread stopped at our breakpoint.") + + # Now make sure we can call a function in the class method we've + # stopped in. frame = thread_list[0].GetFrameAtIndex(0) - self.assertTrue (frame, "Got a valid frame 0 frame.") + self.assertTrue(frame, "Got a valid frame 0 frame.") - cmd_value = frame.EvaluateExpression ("(int)[Foo doSomethingWithString:@\"Hello\"]") - self.assertTrue (cmd_value.IsValid()) - self.assertTrue (cmd_value.GetValueAsUnsigned() == 5) + cmd_value = frame.EvaluateExpression( + "(int)[Foo doSomethingWithString:@\"Hello\"]") + self.assertTrue(cmd_value.IsValid()) + self.assertTrue(cmd_value.GetValueAsUnsigned() == 5) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py index fc8a8129fa3..8b3f444b27a 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py @@ -5,13 +5,14 @@ Test that we are able to properly report a usable dynamic type 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 + @skipUnlessDarwin class ObjCDynamicSBTypeTestCase(TestBase): @@ -36,28 +37,57 @@ class ObjCDynamicSBTypeTestCase(TestBase): exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, + self.main_source, + self.line, + num_expected_locations=1, + loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) - v_object = self.frame().FindVariable("object").GetDynamicValue(lldb.eDynamicCanRunTarget) - v_base = self.frame().FindVariable("base").GetDynamicValue(lldb.eDynamicCanRunTarget) - self.assertTrue(v_object.GetTypeName() == "MyDerivedClass *", "The NSObject is properly type-named") - self.assertTrue(v_base.GetTypeName() == "MyDerivedClass *", "The Base is properly type-named") + v_object = self.frame().FindVariable( + "object").GetDynamicValue(lldb.eDynamicCanRunTarget) + v_base = self.frame().FindVariable( + "base").GetDynamicValue(lldb.eDynamicCanRunTarget) + self.assertTrue( + v_object.GetTypeName() == "MyDerivedClass *", + "The NSObject is properly type-named") + self.assertTrue( + v_base.GetTypeName() == "MyDerivedClass *", + "The Base is properly type-named") object_type = v_object.GetType() base_type = v_base.GetType() - self.assertTrue(object_type.GetName() == "MyDerivedClass *", "The dynamic SBType for NSObject is for the correct type") - self.assertTrue(base_type.GetName() == "MyDerivedClass *", "The dynamic SBType for Base is for the correct type") + self.assertTrue( + object_type.GetName() == "MyDerivedClass *", + "The dynamic SBType for NSObject is for the correct type") + self.assertTrue( + base_type.GetName() == "MyDerivedClass *", + "The dynamic SBType for Base is for the correct type") object_pointee_type = object_type.GetPointeeType() base_pointee_type = base_type.GetPointeeType() - self.assertTrue(object_pointee_type.GetName() == "MyDerivedClass", "The dynamic type for NSObject figures out its pointee type just fine") - self.assertTrue(base_pointee_type.GetName() == "MyDerivedClass", "The dynamic type for Base figures out its pointee type just fine") + self.assertTrue( + object_pointee_type.GetName() == "MyDerivedClass", + "The dynamic type for NSObject figures out its pointee type just fine") + self.assertTrue( + base_pointee_type.GetName() == "MyDerivedClass", + "The dynamic type for Base figures out its pointee type just fine") - self.assertTrue(object_pointee_type.GetDirectBaseClassAtIndex(0).GetName() == "MyBaseClass", "The dynamic type for NSObject can go back to its base class") - self.assertTrue(base_pointee_type.GetDirectBaseClassAtIndex(0).GetName() == "MyBaseClass", "The dynamic type for Base can go back to its base class") + self.assertTrue( + object_pointee_type.GetDirectBaseClassAtIndex(0).GetName() == "MyBaseClass", + "The dynamic type for NSObject can go back to its base class") + self.assertTrue( + base_pointee_type.GetDirectBaseClassAtIndex(0).GetName() == "MyBaseClass", + "The dynamic type for Base can go back to its base class") - self.assertTrue(object_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex(0).GetName() == "NSObject", "The dynamic type for NSObject can go up the hierarchy") - self.assertTrue(base_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex(0).GetName() == "NSObject", "The dynamic type for Base can go up the hierarchy") + self.assertTrue(object_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex( + 0).GetName() == "NSObject", "The dynamic type for NSObject can go up the hierarchy") + self.assertTrue(base_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex( + 0).GetName() == "NSObject", "The dynamic type for Base can go up the hierarchy") - self.assertTrue(object_pointee_type.GetNumberOfFields() == 2, "The dynamic type for NSObject has 2 fields") - self.assertTrue(base_pointee_type.GetNumberOfFields() == 2, "The dynamic type for Base has 2 fields") + self.assertTrue( + object_pointee_type.GetNumberOfFields() == 2, + "The dynamic type for NSObject has 2 fields") + self.assertTrue( + base_pointee_type.GetNumberOfFields() == 2, + "The dynamic type for Base has 2 fields") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py index 8720ede04cb..a115d4f1573 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py @@ -5,30 +5,33 @@ Use lldb Python API to test dynamic values in ObjC from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCDynamicValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): - # Call super's setUp(). + # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break for main.c. + # Find the line number to break for main.c. self.source_name = 'dynamic-value.m' - self.set_property_line = line_number(self.source_name, '// This is the line in setProperty, make sure we step to here.') - self.handle_SourceBase = line_number(self.source_name, - '// Break here to check dynamic values.') - self.main_before_setProperty_line = line_number(self.source_name, - '// Break here to see if we can step into real method.') + self.set_property_line = line_number( + self.source_name, + '// This is the line in setProperty, make sure we step to here.') + self.handle_SourceBase = line_number( + self.source_name, '// Break here to check dynamic values.') + self.main_before_setProperty_line = line_number( + self.source_name, '// Break here to see if we can step into real method.') @skipUnlessDarwin @add_test_categories(['pyapi']) @@ -44,29 +47,33 @@ class ObjCDynamicValueTestCase(TestBase): # Create a target from the debugger. - target = self.dbg.CreateTarget (exe) + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Set up our breakpoints: - handle_SourceBase_bkpt = target.BreakpointCreateByLocation(self.source_name, self.handle_SourceBase) + handle_SourceBase_bkpt = target.BreakpointCreateByLocation( + self.source_name, self.handle_SourceBase) self.assertTrue(handle_SourceBase_bkpt and handle_SourceBase_bkpt.GetNumLocations() == 1, VALID_BREAKPOINT) - main_before_setProperty_bkpt = target.BreakpointCreateByLocation(self.source_name, self.main_before_setProperty_line) + main_before_setProperty_bkpt = target.BreakpointCreateByLocation( + self.source_name, self.main_before_setProperty_line) self.assertTrue(main_before_setProperty_bkpt and main_before_setProperty_bkpt.GetNumLocations() == 1, VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - threads = lldbutil.get_threads_stopped_at_breakpoint (process, main_before_setProperty_bkpt) - self.assertTrue (len(threads) == 1) + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, main_before_setProperty_bkpt) + self.assertTrue(len(threads) == 1) thread = threads[0] # @@ -74,53 +81,73 @@ class ObjCDynamicValueTestCase(TestBase): # make sure we can get that properly: frame = thread.GetFrameAtIndex(0) - myObserver = frame.FindVariable('myObserver', lldb.eDynamicCanRunTarget) - self.assertTrue (myObserver) - myObserver_source = myObserver.GetChildMemberWithName ('_source', lldb.eDynamicCanRunTarget) - self.examine_SourceDerived_ptr (myObserver_source) + myObserver = frame.FindVariable( + 'myObserver', lldb.eDynamicCanRunTarget) + self.assertTrue(myObserver) + myObserver_source = myObserver.GetChildMemberWithName( + '_source', lldb.eDynamicCanRunTarget) + self.examine_SourceDerived_ptr(myObserver_source) # - # Make sure a static value can be correctly turned into a dynamic value. + # Make sure a static value can be correctly turned into a dynamic + # value. frame = thread.GetFrameAtIndex(0) - myObserver_static = frame.FindVariable('myObserver', lldb.eNoDynamicValues) - self.assertTrue (myObserver_static) - myObserver = myObserver_static.GetDynamicValue (lldb.eDynamicCanRunTarget) - myObserver_source = myObserver.GetChildMemberWithName ('_source', lldb.eDynamicCanRunTarget) - self.examine_SourceDerived_ptr (myObserver_source) + myObserver_static = frame.FindVariable( + 'myObserver', lldb.eNoDynamicValues) + self.assertTrue(myObserver_static) + myObserver = myObserver_static.GetDynamicValue( + lldb.eDynamicCanRunTarget) + myObserver_source = myObserver.GetChildMemberWithName( + '_source', lldb.eDynamicCanRunTarget) + self.examine_SourceDerived_ptr(myObserver_source) # The "frame var" code uses another path to get into children, so let's # make sure that works as well: result = lldb.SBCommandReturnObject() - self.expect('frame var -d run-target myObserver->_source', 'frame var finds its way into a child member', - patterns = ['\(SourceDerived \*\)']) - - # check that our ObjC GetISA() does a good job at hiding KVO swizzled classes - - self.expect('frame var -d run-target myObserver->_source -T', 'the KVO-ed class is hidden', - substrs = ['SourceDerived']) + self.expect( + 'frame var -d run-target myObserver->_source', + 'frame var finds its way into a child member', + patterns=['\(SourceDerived \*\)']) + + # check that our ObjC GetISA() does a good job at hiding KVO swizzled + # classes - self.expect('frame var -d run-target myObserver->_source -T', 'the KVO-ed class is hidden', matching = False, - substrs = ['NSKVONotify']) + self.expect( + 'frame var -d run-target myObserver->_source -T', + 'the KVO-ed class is hidden', + substrs=['SourceDerived']) + + self.expect( + 'frame var -d run-target myObserver->_source -T', + 'the KVO-ed class is hidden', + matching=False, + substrs=['NSKVONotify']) # This test is not entirely related to the main thrust of this test case, but since we're here, - # try stepping into setProperty, and make sure we get into the version in Source: + # try stepping into setProperty, and make sure we get into the version + # in Source: thread.StepInto() - threads = lldbutil.get_stopped_threads (process, lldb.eStopReasonPlanComplete) - self.assertTrue (len(threads) == 1) + threads = lldbutil.get_stopped_threads( + process, lldb.eStopReasonPlanComplete) + self.assertTrue(len(threads) == 1) line_entry = threads[0].GetFrameAtIndex(0).GetLineEntry() - self.assertEqual (line_entry.GetLine(), self.set_property_line) - self.assertEqual (line_entry.GetFileSpec().GetFilename(), self.source_name) + self.assertEqual(line_entry.GetLine(), self.set_property_line) + self.assertEqual( + line_entry.GetFileSpec().GetFilename(), + self.source_name) - # Okay, back to the main business. Continue to the handle_SourceBase and make sure we get the correct dynamic value. + # Okay, back to the main business. Continue to the handle_SourceBase + # and make sure we get the correct dynamic value. - threads = lldbutil.continue_to_breakpoint (process, handle_SourceBase_bkpt) - self.assertTrue (len(threads) == 1) + threads = lldbutil.continue_to_breakpoint( + process, handle_SourceBase_bkpt) + self.assertTrue(len(threads) == 1) thread = threads[0] frame = thread.GetFrameAtIndex(0) @@ -130,49 +157,55 @@ class ObjCDynamicValueTestCase(TestBase): noDynamic = lldb.eNoDynamicValues useDynamic = lldb.eDynamicCanRunTarget - object_static = frame.FindVariable ('object', noDynamic) - object_dynamic = frame.FindVariable ('object', useDynamic) + object_static = frame.FindVariable('object', noDynamic) + object_dynamic = frame.FindVariable('object', useDynamic) - # Delete this object to make sure that this doesn't cause havoc with the dynamic object that depends on it. + # Delete this object to make sure that this doesn't cause havoc with + # the dynamic object that depends on it. del (object_static) - self.examine_SourceDerived_ptr (object_dynamic) - + self.examine_SourceDerived_ptr(object_dynamic) + # Get "this" using FindValue, make sure that works too: - object_static = frame.FindValue ('object', lldb.eValueTypeVariableArgument, noDynamic) - object_dynamic = frame.FindValue ('object', lldb.eValueTypeVariableArgument, useDynamic) + object_static = frame.FindValue( + 'object', lldb.eValueTypeVariableArgument, noDynamic) + object_dynamic = frame.FindValue( + 'object', lldb.eValueTypeVariableArgument, useDynamic) del (object_static) - self.examine_SourceDerived_ptr (object_dynamic) + self.examine_SourceDerived_ptr(object_dynamic) # Get "this" using the EvaluateExpression: - object_static = frame.EvaluateExpression ('object', noDynamic) - object_dynamic = frame.EvaluateExpression ('object', useDynamic) + object_static = frame.EvaluateExpression('object', noDynamic) + object_dynamic = frame.EvaluateExpression('object', useDynamic) del (object_static) - self.examine_SourceDerived_ptr (object_dynamic) - + self.examine_SourceDerived_ptr(object_dynamic) + # Continue again to the handle_SourceBase and make sure we get the correct dynamic value. # This one looks exactly the same, but in fact this is an "un-KVO'ed" version of SourceBase, so - # its isa pointer points to SourceBase not NSKVOSourceBase or whatever... + # its isa pointer points to SourceBase not NSKVOSourceBase or + # whatever... - threads = lldbutil.continue_to_breakpoint (process, handle_SourceBase_bkpt) - self.assertTrue (len(threads) == 1) + threads = lldbutil.continue_to_breakpoint( + process, handle_SourceBase_bkpt) + self.assertTrue(len(threads) == 1) thread = threads[0] frame = thread.GetFrameAtIndex(0) # Get "object" using FindVariable: - object_static = frame.FindVariable ('object', noDynamic) - object_dynamic = frame.FindVariable ('object', useDynamic) + object_static = frame.FindVariable('object', noDynamic) + object_dynamic = frame.FindVariable('object', useDynamic) - # Delete this object to make sure that this doesn't cause havoc with the dynamic object that depends on it. + # Delete this object to make sure that this doesn't cause havoc with + # the dynamic object that depends on it. del (object_static) - self.examine_SourceDerived_ptr (object_dynamic) + self.examine_SourceDerived_ptr(object_dynamic) - def examine_SourceDerived_ptr (self, object): - self.assertTrue (object) - self.assertTrue (object.GetTypeName().find ('SourceDerived') != -1) - derivedValue = object.GetChildMemberWithName ('_derivedValue') - self.assertTrue (derivedValue) - self.assertTrue (int (derivedValue.GetValue(), 0) == 30) + def examine_SourceDerived_ptr(self, object): + self.assertTrue(object) + self.assertTrue(object.GetTypeName().find('SourceDerived') != -1) + derivedValue = object.GetChildMemberWithName('_derivedValue') + self.assertTrue(derivedValue) + self.assertTrue(int(derivedValue.GetValue(), 0) == 30) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py index 049b41e08d0..03121e6f956 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py @@ -3,13 +3,14 @@ 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 TestObjCIvarOffsets(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,7 +20,8 @@ class TestObjCIvarOffsets(TestBase): TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "main.m" - self.stop_line = line_number(self.main_source, '// Set breakpoint here.') + self.stop_line = line_number( + self.main_source, '// Set breakpoint here.') @skipUnlessDarwin @add_test_categories(['pyapi']) @@ -31,45 +33,54 @@ class TestObjCIvarOffsets(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - breakpoint = target.BreakpointCreateByLocation(self.main_source, self.stop_line) + breakpoint = target.BreakpointCreateByLocation( + self.main_source, self.stop_line) self.assertTrue(breakpoint, VALID_BREAKPOINT) - process = target.LaunchSimple (None, None, self.get_process_working_directory()) - self.assertTrue (process, "Created a process.") - self.assertTrue (process.GetState() == lldb.eStateStopped, "Stopped it too.") + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) + self.assertTrue(process, "Created a process.") + self.assertTrue( + process.GetState() == lldb.eStateStopped, + "Stopped it too.") - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue (len(thread_list) == 1) + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint) + self.assertTrue(len(thread_list) == 1) thread = thread_list[0] - + frame = thread.GetFrameAtIndex(0) - self.assertTrue (frame, "frame 0 is valid") - + self.assertTrue(frame, "frame 0 is valid") + mine = thread.GetFrameAtIndex(0).FindVariable("mine") self.assertTrue(mine, "Found local variable mine.") - + # Test the value object value for BaseClass->_backed_int error = lldb.SBError() - mine_backed_int = mine.GetChildMemberWithName ("_backed_int") - self.assertTrue(mine_backed_int, "Found mine->backed_int local variable.") - backed_value = mine_backed_int.GetValueAsSigned (error) - self.assertTrue (error.Success()) - self.assertTrue (backed_value == 1111) - + mine_backed_int = mine.GetChildMemberWithName("_backed_int") + self.assertTrue( + mine_backed_int, + "Found mine->backed_int local variable.") + backed_value = mine_backed_int.GetValueAsSigned(error) + self.assertTrue(error.Success()) + self.assertTrue(backed_value == 1111) + # Test the value object value for DerivedClass->_derived_backed_int - mine_derived_backed_int = mine.GetChildMemberWithName ("_derived_backed_int") - self.assertTrue(mine_derived_backed_int, "Found mine->derived_backed_int local variable.") - derived_backed_value = mine_derived_backed_int.GetValueAsSigned (error) - self.assertTrue (error.Success()) - self.assertTrue (derived_backed_value == 3333) + mine_derived_backed_int = mine.GetChildMemberWithName( + "_derived_backed_int") + self.assertTrue(mine_derived_backed_int, + "Found mine->derived_backed_int local variable.") + derived_backed_value = mine_derived_backed_int.GetValueAsSigned(error) + self.assertTrue(error.Success()) + self.assertTrue(derived_backed_value == 3333) # Make sure we also get bit-field offsets correct: - mine_flag2 = mine.GetChildMemberWithName ("flag2") + mine_flag2 = mine.GetChildMemberWithName("flag2") self.assertTrue(mine_flag2, "Found mine->flag2 local variable.") - flag2_value = mine_flag2.GetValueAsUnsigned (error) - self.assertTrue (error.Success()) - self.assertTrue (flag2_value == 7) + flag2_value = mine_flag2.GetValueAsUnsigned(error) + self.assertTrue(error.Success()) + self.assertTrue(flag2_value == 7) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py index 791ce27dad0..804905106df 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.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/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py index d9007c57bfb..dde9ebadba4 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py @@ -3,13 +3,14 @@ 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 TestObjCIvarStripped(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,10 +20,13 @@ class TestObjCIvarStripped(TestBase): TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "main.m" - self.stop_line = line_number(self.main_source, '// Set breakpoint here.') + self.stop_line = line_number( + self.main_source, '// Set breakpoint here.') @skipUnlessDarwin - @skipIf(debug_info=no_match("dsym"), bugnumber="This test requires a stripped binary and a dSYM") + @skipIf( + debug_info=no_match("dsym"), + bugnumber="This test requires a stripped binary and a dSYM") @add_test_categories(['pyapi']) def test_with_python_api(self): """Test that we can find stripped Objective-C ivars in the runtime""" @@ -34,26 +38,33 @@ class TestObjCIvarStripped(TestBase): self.dbg.HandleCommand("add-dsym a.out.dSYM") - breakpoint = target.BreakpointCreateByLocation(self.main_source, self.stop_line) - self.assertTrue(breakpoint.IsValid() and breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT) + breakpoint = target.BreakpointCreateByLocation( + self.main_source, self.stop_line) + self.assertTrue( + breakpoint.IsValid() and breakpoint.GetNumLocations() > 0, + VALID_BREAKPOINT) - process = target.LaunchSimple (None, None, self.get_process_working_directory()) - self.assertTrue (process, "Created a process.") - self.assertTrue (process.GetState() == lldb.eStateStopped, "Stopped it too.") + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) + self.assertTrue(process, "Created a process.") + self.assertTrue( + process.GetState() == lldb.eStateStopped, + "Stopped it too.") - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue (len(thread_list) == 1) + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint) + self.assertTrue(len(thread_list) == 1) thread = thread_list[0] - + frame = thread.GetFrameAtIndex(0) - self.assertTrue (frame, "frame 0 is valid") - + self.assertTrue(frame, "frame 0 is valid") + # Test the expression for mc->_foo error = lldb.SBError() - ivar = frame.EvaluateExpression ("(mc->_foo)") + ivar = frame.EvaluateExpression("(mc->_foo)") self.assertTrue(ivar, "Got result for mc->_foo") - ivar_value = ivar.GetValueAsSigned (error) - self.assertTrue (error.Success()) - self.assertTrue (ivar_value == 3) + ivar_value = ivar.GetValueAsSigned(error) + self.assertTrue(error.Success()) + self.assertTrue(ivar_value == 3) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py index 65139b16229..ba4cfdff6fc 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py @@ -3,9 +3,9 @@ from __future__ import print_function - import unittest2 -import os, time +import os +import time import platform from distutils.version import StrictVersion @@ -15,6 +15,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCNewSyntaxTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,80 +27,131 @@ class ObjCNewSyntaxTestCase(TestBase): self.line = line_number('main.m', '// Set breakpoint 0 here.') @skipUnlessDarwin - @expectedFailureAll(oslist=['macosx'], compiler='clang', compiler_version=['<', '7.0.0']) - @expectedFailureAll(oslist=['macosx'], debug_info=['gmodules'], bugnumber='rdar://27792848') - @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion('12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") + @expectedFailureAll( + oslist=['macosx'], + compiler='clang', + compiler_version=[ + '<', + '7.0.0']) + @expectedFailureAll( + oslist=['macosx'], + debug_info=['gmodules'], + bugnumber='rdar://27792848') + @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion( + '12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") def test_expr(self): self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. - 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']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) - - self.expect("expr --object-description -- immutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo"]) - - self.expect("expr --object-description -- mutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo"]) - - self.expect("expr --object-description -- mutable_array[0] = @\"bar\"", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["bar"]) - - self.expect("expr --object-description -- mutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["bar"]) - - self.expect("expr --object-description -- immutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["value"]) - - self.expect("expr --object-description -- mutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["value"]) - - self.expect("expr --object-description -- mutable_dictionary[@\"key\"] = @\"object\"", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["object"]) - - self.expect("expr --object-description -- mutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["object"]) - - self.expect("expr --object-description -- @[ @\"foo\", @\"bar\" ]", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["NSArray", "foo", "bar"]) - - self.expect("expr --object-description -- @{ @\"key\" : @\"object\" }", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["key", "object"]) - - self.expect("expr --object-description -- @'a'", VARIABLES_DISPLAYED_CORRECTLY, - substrs = [str(ord('a'))]) - - self.expect("expr --object-description -- @1", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["1"]) - - self.expect("expr --object-description -- @1l", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["1"]) - - self.expect("expr --object-description -- @1ul", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["1"]) - - self.expect("expr --object-description -- @1ll", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["1"]) - - self.expect("expr --object-description -- @1ull", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["1"]) + substrs=[' resolved, hit count = 1']) + + self.expect( + "expr --object-description -- immutable_array[0]", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["foo"]) + + self.expect( + "expr --object-description -- mutable_array[0]", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["foo"]) + + self.expect( + "expr --object-description -- mutable_array[0] = @\"bar\"", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["bar"]) + + self.expect( + "expr --object-description -- mutable_array[0]", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["bar"]) + + self.expect( + "expr --object-description -- immutable_dictionary[@\"key\"]", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["value"]) + + self.expect( + "expr --object-description -- mutable_dictionary[@\"key\"]", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["value"]) + + self.expect( + "expr --object-description -- mutable_dictionary[@\"key\"] = @\"object\"", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["object"]) + + self.expect( + "expr --object-description -- mutable_dictionary[@\"key\"]", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["object"]) + + self.expect( + "expr --object-description -- @[ @\"foo\", @\"bar\" ]", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "NSArray", + "foo", + "bar"]) + + self.expect( + "expr --object-description -- @{ @\"key\" : @\"object\" }", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "key", + "object"]) + + self.expect("expr --object-description -- @'a'", + VARIABLES_DISPLAYED_CORRECTLY, substrs=[str(ord('a'))]) + + self.expect( + "expr --object-description -- @1", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["1"]) + + self.expect( + "expr --object-description -- @1l", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["1"]) + + self.expect( + "expr --object-description -- @1ul", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["1"]) + + self.expect( + "expr --object-description -- @1ll", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["1"]) + + self.expect( + "expr --object-description -- @1ull", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["1"]) self.expect("expr -- @123.45", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["NSNumber", "123.45"]) - - self.expect("expr --object-description -- @( 1 + 3 )", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["4"]) - self.expect("expr -- @((char*)\"Hello world\" + 6)", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["NSString", "world"]) + substrs=["NSNumber", "123.45"]) + + self.expect( + "expr --object-description -- @( 1 + 3 )", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["4"]) + self.expect( + "expr -- @((char*)\"Hello world\" + 6)", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "NSString", + "world"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py index 2c3ac27d418..08e9594be69 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py @@ -10,8 +10,8 @@ optimized it into a register. from __future__ import print_function - -import os, time +import os +import time import lldb import re @@ -21,6 +21,8 @@ from lldbsuite.test import lldbutil # rdar://problem/9087739 # test failure: objc_optimized does not work for "-C clang -A i386" + + @skipUnlessDarwin class ObjcOptimizedTestCase(TestBase): @@ -35,15 +37,24 @@ class ObjcOptimizedTestCase(TestBase): exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_symbol (self, self.method_spec, num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + self.method_spec, + num_expected_locations=1, + sym_exact=True) self.runCmd("run", RUN_SUCCEEDED) - self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint"], - patterns = ["frame.*0:.*%s %s" % (self.myclass, self.mymethod)]) + self.expect( + "thread backtrace", + STOPPED_DUE_TO_BREAKPOINT, + substrs=["stop reason = breakpoint"], + patterns=[ + "frame.*0:.*%s %s" % + (self.myclass, + self.mymethod)]) self.expect('expression member', - startstr = "(int) $0 = 5") + startstr="(int) $0 = 5") # <rdar://problem/12693963> interp = self.dbg.GetCommandInterpreter() @@ -59,7 +70,7 @@ class ObjcOptimizedTestCase(TestBase): desired_pointer = mo.group(0) self.expect('expression (self)', - substrs = [("(%s *) $1 = " % self.myclass), desired_pointer]) + substrs=[("(%s *) $1 = " % self.myclass), desired_pointer]) self.expect('expression self->non_member', error=True, - substrs = ["does not have a member named 'non_member'"]) + substrs=["does not have a member named 'non_member'"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py index 22fe3136a51..790bc9c0861 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py @@ -5,23 +5,24 @@ Use lldb Python API to verify that expression evaluation for property references from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCPropertyTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): - # Call super's setUp(). + # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break for main.c. + # Find the line number to break for main.c. self.source_name = 'main.m' @skipUnlessDarwin @@ -36,61 +37,68 @@ class ObjCPropertyTestCase(TestBase): # Create a target from the debugger. - target = self.dbg.CreateTarget (exe) + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Set up our breakpoints: - - main_bkpt = target.BreakpointCreateBySourceRegex ("Set a breakpoint here.", lldb.SBFileSpec (self.source_name)) + + main_bkpt = target.BreakpointCreateBySourceRegex( + "Set a breakpoint here.", lldb.SBFileSpec(self.source_name)) self.assertTrue(main_bkpt and main_bkpt.GetNumLocations() == 1, VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - threads = lldbutil.get_threads_stopped_at_breakpoint (process, main_bkpt) - self.assertTrue (len(threads) == 1) + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, main_bkpt) + self.assertTrue(len(threads) == 1) thread = threads[0] frame = thread.GetFrameAtIndex(0) - mine = frame.FindVariable ("mine") - self.assertTrue (mine.IsValid()) - access_count = mine.GetChildMemberWithName ("_access_count") - self.assertTrue (access_count.IsValid()) - start_access_count = access_count.GetValueAsUnsigned (123456) - self.assertTrue (start_access_count != 123456) + mine = frame.FindVariable("mine") + self.assertTrue(mine.IsValid()) + access_count = mine.GetChildMemberWithName("_access_count") + self.assertTrue(access_count.IsValid()) + start_access_count = access_count.GetValueAsUnsigned(123456) + self.assertTrue(start_access_count != 123456) # # The first set of tests test calling the getter & setter of # a property that actually only has a getter & setter and no # @property. # - nonexistant_value = frame.EvaluateExpression("mine.nonexistantInt", False) + nonexistant_value = frame.EvaluateExpression( + "mine.nonexistantInt", False) nonexistant_error = nonexistant_value.GetError() - self.assertTrue (nonexistant_error.Success()) - nonexistant_int = nonexistant_value.GetValueAsUnsigned (123456) - self.assertTrue (nonexistant_int == 6) - - # Calling the getter function would up the access count, so make sure that happened. - - new_access_count = access_count.GetValueAsUnsigned (123456) - self.assertTrue (new_access_count - start_access_count == 1) + self.assertTrue(nonexistant_error.Success()) + nonexistant_int = nonexistant_value.GetValueAsUnsigned(123456) + self.assertTrue(nonexistant_int == 6) + + # Calling the getter function would up the access count, so make sure + # that happened. + + new_access_count = access_count.GetValueAsUnsigned(123456) + self.assertTrue(new_access_count - start_access_count == 1) start_access_count = new_access_count # # Now call the setter, then make sure that - nonexistant_change = frame.EvaluateExpression("mine.nonexistantInt = 10", False) + nonexistant_change = frame.EvaluateExpression( + "mine.nonexistantInt = 10", False) nonexistant_error = nonexistant_change.GetError() - self.assertTrue (nonexistant_error.Success()) + self.assertTrue(nonexistant_error.Success()) + + # Calling the setter function would up the access count, so make sure + # that happened. - # Calling the setter function would up the access count, so make sure that happened. - - new_access_count = access_count.GetValueAsUnsigned (123456) - self.assertTrue (new_access_count - start_access_count == 1) + new_access_count = access_count.GetValueAsUnsigned(123456) + self.assertTrue(new_access_count - start_access_count == 1) start_access_count = new_access_count # @@ -100,30 +108,32 @@ class ObjCPropertyTestCase(TestBase): backed_value = frame.EvaluateExpression("mine.backedInt", False) backed_error = backed_value.GetError() - self.assertTrue (backed_error.Success()) - backing_value = mine.GetChildMemberWithName ("_backedInt") - self.assertTrue (backing_value.IsValid()) - self.assertTrue (backed_value.GetValueAsUnsigned (12345) == backing_value.GetValueAsUnsigned(23456)) + self.assertTrue(backed_error.Success()) + backing_value = mine.GetChildMemberWithName("_backedInt") + self.assertTrue(backing_value.IsValid()) + self.assertTrue(backed_value.GetValueAsUnsigned(12345) + == backing_value.GetValueAsUnsigned(23456)) unbacked_value = frame.EvaluateExpression("mine.unbackedInt", False) unbacked_error = unbacked_value.GetError() - self.assertTrue (unbacked_error.Success()) + self.assertTrue(unbacked_error.Success()) - idWithProtocol_value = frame.EvaluateExpression("mine.idWithProtocol", False) + idWithProtocol_value = frame.EvaluateExpression( + "mine.idWithProtocol", False) idWithProtocol_error = idWithProtocol_value.GetError() - self.assertTrue (idWithProtocol_error.Success()) - self.assertTrue (idWithProtocol_value.GetTypeName() == "id") + self.assertTrue(idWithProtocol_error.Success()) + self.assertTrue(idWithProtocol_value.GetTypeName() == "id") # Make sure that class property getter works as expected value = frame.EvaluateExpression("BaseClass.classInt", False) - self.assertTrue (value.GetError().Success()) - self.assertTrue (value.GetValueAsUnsigned (11111) == 123) + self.assertTrue(value.GetError().Success()) + self.assertTrue(value.GetValueAsUnsigned(11111) == 123) # Make sure that class property setter works as expected value = frame.EvaluateExpression("BaseClass.classInt = 234", False) - self.assertTrue (value.GetError().Success()) + self.assertTrue(value.GetError().Success()) # Verify that setter above actually worked value = frame.EvaluateExpression("BaseClass.classInt", False) - self.assertTrue (value.GetError().Success()) - self.assertTrue (value.GetValueAsUnsigned (11111) == 234) + self.assertTrue(value.GetError().Success()) + self.assertTrue(value.GetValueAsUnsigned(11111) == 234) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py index 791ce27dad0..804905106df 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.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/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py index 7d88292a051..65dc5ace544 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py @@ -3,13 +3,14 @@ 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 TestObjCStaticMethodStripped(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,11 +20,14 @@ class TestObjCStaticMethodStripped(TestBase): TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "static.m" - self.break_line = line_number(self.main_source, '// Set breakpoint here.') + self.break_line = line_number( + self.main_source, '// Set breakpoint here.') @skipUnlessDarwin @add_test_categories(['pyapi']) - @skipIf(debug_info=no_match("dsym"), bugnumber="This test requires a stripped binary and a dSYM") + @skipIf( + debug_info=no_match("dsym"), + bugnumber="This test requires a stripped binary and a dSYM") #<rdar://problem/12042992> def test_with_python_api(self): """Test calling functions in static methods with a stripped binary.""" @@ -35,31 +39,42 @@ class TestObjCStaticMethodStripped(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) + bpt = target.BreakpointCreateByLocation( + self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt) + thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt) # Make sure we stopped at the first breakpoint. - self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.") - self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.") - - # Now make sure we can call a function in the static method we've stopped in. + self.assertTrue( + len(thread_list) != 0, + "No thread stopped at our breakpoint.") + self.assertTrue(len(thread_list) == 1, + "More than one thread stopped at our breakpoint.") + + # Now make sure we can call a function in the static method we've + # stopped in. frame = thread_list[0].GetFrameAtIndex(0) - self.assertTrue (frame, "Got a valid frame 0 frame.") + self.assertTrue(frame, "Got a valid frame 0 frame.") - cmd_value = frame.EvaluateExpression ("(char *) sel_getName (_cmd)") - self.assertTrue (cmd_value.IsValid()) + cmd_value = frame.EvaluateExpression("(char *) sel_getName (_cmd)") + self.assertTrue(cmd_value.IsValid()) sel_name = cmd_value.GetSummary() - self.assertTrue (sel_name == "\"doSomethingWithString:\"", "Got the right value for the selector as string.") + self.assertTrue( + sel_name == "\"doSomethingWithString:\"", + "Got the right value for the selector as string.") - cmd_value = frame.EvaluateExpression ("[Foo doSomethingElseWithString:string]") - self.assertTrue (cmd_value.IsValid()) + cmd_value = frame.EvaluateExpression( + "[Foo doSomethingElseWithString:string]") + self.assertTrue(cmd_value.IsValid()) string_length = cmd_value.GetValueAsUnsigned() - self.assertTrue (string_length == 27, "Got the right value from another class method on the same class.") + self.assertTrue( + string_length == 27, + "Got the right value from another class method on the same class.") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py index ccba42db4eb..9f74d86d633 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py @@ -3,13 +3,14 @@ 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 TestObjCStaticMethod(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,7 +20,8 @@ class TestObjCStaticMethod(TestBase): TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "static.m" - self.break_line = line_number(self.main_source, '// Set breakpoint here.') + self.break_line = line_number( + self.main_source, '// Set breakpoint here.') @skipUnlessDarwin @add_test_categories(['pyapi']) @@ -32,31 +34,42 @@ class TestObjCStaticMethod(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) + bpt = target.BreakpointCreateByLocation( + self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt) + thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt) # Make sure we stopped at the first breakpoint. - self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.") - self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.") - - # Now make sure we can call a function in the static method we've stopped in. + self.assertTrue( + len(thread_list) != 0, + "No thread stopped at our breakpoint.") + self.assertTrue(len(thread_list) == 1, + "More than one thread stopped at our breakpoint.") + + # Now make sure we can call a function in the static method we've + # stopped in. frame = thread_list[0].GetFrameAtIndex(0) - self.assertTrue (frame, "Got a valid frame 0 frame.") + self.assertTrue(frame, "Got a valid frame 0 frame.") - cmd_value = frame.EvaluateExpression ("(char *) sel_getName (_cmd)") - self.assertTrue (cmd_value.IsValid()) + cmd_value = frame.EvaluateExpression("(char *) sel_getName (_cmd)") + self.assertTrue(cmd_value.IsValid()) sel_name = cmd_value.GetSummary() - self.assertTrue (sel_name == "\"doSomethingWithString:\"", "Got the right value for the selector as string.") + self.assertTrue( + sel_name == "\"doSomethingWithString:\"", + "Got the right value for the selector as string.") - cmd_value = frame.EvaluateExpression ("[self doSomethingElseWithString:string]") - self.assertTrue (cmd_value.IsValid()) + cmd_value = frame.EvaluateExpression( + "[self doSomethingElseWithString:string]") + self.assertTrue(cmd_value.IsValid()) string_length = cmd_value.GetValueAsUnsigned() - self.assertTrue (string_length == 27, "Got the right value from another class method on the same class.") + self.assertTrue( + string_length == 27, + "Got the right value from another class method on the same class.") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py index d035287cfa0..8516ef3281f 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py @@ -3,16 +3,17 @@ 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 TestObjCStepping(TestBase): - def getCategories (self): + def getCategories(self): return ['basic_process'] mydir = TestBase.compute_mydir(__file__) @@ -22,11 +23,16 @@ class TestObjCStepping(TestBase): TestBase.setUp(self) # Find the line numbers that we will step to in main: self.main_source = "stepping-tests.m" - self.source_randomMethod_line = line_number (self.main_source, '// Source randomMethod start line.') - self.sourceBase_randomMethod_line = line_number (self.main_source, '// SourceBase randomMethod start line.') - self.source_returnsStruct_start_line = line_number (self.main_source, '// Source returnsStruct start line.') - self.sourceBase_returnsStruct_start_line = line_number (self.main_source, '// SourceBase returnsStruct start line.') - self.stepped_past_nil_line = line_number (self.main_source, '// Step over nil should stop here.') + self.source_randomMethod_line = line_number( + self.main_source, '// Source randomMethod start line.') + self.sourceBase_randomMethod_line = line_number( + self.main_source, '// SourceBase randomMethod start line.') + self.source_returnsStruct_start_line = line_number( + self.main_source, '// Source returnsStruct start line.') + self.sourceBase_returnsStruct_start_line = line_number( + self.main_source, '// SourceBase returnsStruct start line.') + self.stepped_past_nil_line = line_number( + self.main_source, '// Step over nil should stop here.') @skipUnlessDarwin @add_test_categories(['pyapi']) @@ -38,57 +44,65 @@ class TestObjCStepping(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - self.main_source_spec = lldb.SBFileSpec (self.main_source) + self.main_source_spec = lldb.SBFileSpec(self.main_source) breakpoints_to_disable = [] - break1 = target.BreakpointCreateBySourceRegex ("// Set first breakpoint here.", self.main_source_spec) + break1 = target.BreakpointCreateBySourceRegex( + "// Set first breakpoint here.", self.main_source_spec) self.assertTrue(break1, VALID_BREAKPOINT) - breakpoints_to_disable.append (break1) + breakpoints_to_disable.append(break1) - break2 = target.BreakpointCreateBySourceRegex ("// Set second breakpoint here.", self.main_source_spec) + break2 = target.BreakpointCreateBySourceRegex( + "// Set second breakpoint here.", self.main_source_spec) self.assertTrue(break2, VALID_BREAKPOINT) - breakpoints_to_disable.append (break2) + breakpoints_to_disable.append(break2) - break3 = target.BreakpointCreateBySourceRegex ('// Set third breakpoint here.', self.main_source_spec) + break3 = target.BreakpointCreateBySourceRegex( + '// Set third breakpoint here.', self.main_source_spec) self.assertTrue(break3, VALID_BREAKPOINT) - breakpoints_to_disable.append (break3) + breakpoints_to_disable.append(break3) - break4 = target.BreakpointCreateBySourceRegex ('// Set fourth breakpoint here.', self.main_source_spec) + break4 = target.BreakpointCreateBySourceRegex( + '// Set fourth breakpoint here.', self.main_source_spec) self.assertTrue(break4, VALID_BREAKPOINT) - breakpoints_to_disable.append (break4) + breakpoints_to_disable.append(break4) - break5 = target.BreakpointCreateBySourceRegex ('// Set fifth breakpoint here.', self.main_source_spec) + break5 = target.BreakpointCreateBySourceRegex( + '// Set fifth breakpoint here.', self.main_source_spec) self.assertTrue(break5, VALID_BREAKPOINT) - breakpoints_to_disable.append (break5) + breakpoints_to_disable.append(break5) - break_returnStruct_call_super = target.BreakpointCreateBySourceRegex ('// Source returnsStruct call line.', self.main_source_spec) + break_returnStruct_call_super = target.BreakpointCreateBySourceRegex( + '// Source returnsStruct call line.', self.main_source_spec) self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT) - breakpoints_to_disable.append (break_returnStruct_call_super) + breakpoints_to_disable.append(break_returnStruct_call_super) - break_step_nil = target.BreakpointCreateBySourceRegex ('// Set nil step breakpoint here.', self.main_source_spec) + break_step_nil = target.BreakpointCreateBySourceRegex( + '// Set nil step breakpoint here.', self.main_source_spec) self.assertTrue(break_step_nil, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - threads = lldbutil.get_threads_stopped_at_breakpoint (process, break1) + threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1) if len(threads) != 1: - self.fail ("Failed to stop at breakpoint 1.") + self.fail("Failed to stop at breakpoint 1.") thread = threads[0] mySource = thread.GetFrameAtIndex(0).FindVariable("mySource") self.assertTrue(mySource, "Found mySource local variable.") - mySource_isa = mySource.GetChildMemberWithName ("isa") + mySource_isa = mySource.GetChildMemberWithName("isa") self.assertTrue(mySource_isa, "Found mySource->isa local variable.") - className = mySource_isa.GetSummary () + className = mySource_isa.GetSummary() if self.TraceOn(): - print(mySource_isa) + print(mySource_isa) # Lets delete mySource so we can check that after stepping a child variable # with no parent persists and is useful. @@ -97,77 +111,114 @@ class TestObjCStepping(TestBase): # Now step in, that should leave us in the Source randomMethod: thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.source_randomMethod_line, "Stepped into Source randomMethod.") + self.assertTrue( + line_number == self.source_randomMethod_line, + "Stepped into Source randomMethod.") - # Now step in again, through the super call, and that should leave us in the SourceBase randomMethod: + # Now step in again, through the super call, and that should leave us + # in the SourceBase randomMethod: thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod.") + self.assertTrue( + line_number == self.sourceBase_randomMethod_line, + "Stepped through super into SourceBase randomMethod.") - threads = lldbutil.continue_to_breakpoint (process, break2) - self.assertTrue (len(threads) == 1, "Continued to second breakpoint in main.") + threads = lldbutil.continue_to_breakpoint(process, break2) + self.assertTrue( + len(threads) == 1, + "Continued to second breakpoint in main.") - # Again, step in twice gets us to a stret method and a stret super call: + # Again, step in twice gets us to a stret method and a stret super + # call: thread = threads[0] thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct.") - - threads = lldbutil.continue_to_breakpoint (process, break_returnStruct_call_super) - self.assertTrue (len(threads) == 1, "Stepped to the call super line in Source returnsStruct.") + self.assertTrue( + line_number == self.source_returnsStruct_start_line, + "Stepped into Source returnsStruct.") + + threads = lldbutil.continue_to_breakpoint( + process, break_returnStruct_call_super) + self.assertTrue( + len(threads) == 1, + "Stepped to the call super line in Source returnsStruct.") thread = threads[0] thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.sourceBase_returnsStruct_start_line, "Stepped through super into SourceBase returnsStruct.") + self.assertTrue( + line_number == self.sourceBase_returnsStruct_start_line, + "Stepped through super into SourceBase returnsStruct.") - # Cool now continue to get past the call that initializes the Observer, and then do our steps in again to see that - # we can find our way when we're stepping through a KVO swizzled object. + # Cool now continue to get past the call that initializes the Observer, and then do our steps in again to see that + # we can find our way when we're stepping through a KVO swizzled + # object. - threads = lldbutil.continue_to_breakpoint (process, break3) - self.assertTrue (len(threads) == 1, "Continued to third breakpoint in main, our object should now be swizzled.") + threads = lldbutil.continue_to_breakpoint(process, break3) + self.assertTrue( + len(threads) == 1, + "Continued to third breakpoint in main, our object should now be swizzled.") - newClassName = mySource_isa.GetSummary () + newClassName = mySource_isa.GetSummary() if self.TraceOn(): - print(mySource_isa) + print(mySource_isa) - self.assertTrue (newClassName != className, "The isa did indeed change, swizzled!") + self.assertTrue( + newClassName != className, + "The isa did indeed change, swizzled!") # Now step in, that should leave us in the Source randomMethod: thread = threads[0] thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.source_randomMethod_line, "Stepped into Source randomMethod in swizzled object.") + self.assertTrue( + line_number == self.source_randomMethod_line, + "Stepped into Source randomMethod in swizzled object.") - # Now step in again, through the super call, and that should leave us in the SourceBase randomMethod: + # Now step in again, through the super call, and that should leave us + # in the SourceBase randomMethod: thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod in swizzled object.") - - threads = lldbutil.continue_to_breakpoint (process, break4) - self.assertTrue (len(threads) == 1, "Continued to fourth breakpoint in main.") + self.assertTrue( + line_number == self.sourceBase_randomMethod_line, + "Stepped through super into SourceBase randomMethod in swizzled object.") + + threads = lldbutil.continue_to_breakpoint(process, break4) + self.assertTrue( + len(threads) == 1, + "Continued to fourth breakpoint in main.") thread = threads[0] - # Again, step in twice gets us to a stret method and a stret super call: + # Again, step in twice gets us to a stret method and a stret super + # call: thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct in swizzled object.") - - threads = lldbutil.continue_to_breakpoint(process, break_returnStruct_call_super) - self.assertTrue (len(threads) == 1, "Stepped to the call super line in Source returnsStruct - second time.") + self.assertTrue( + line_number == self.source_returnsStruct_start_line, + "Stepped into Source returnsStruct in swizzled object.") + + threads = lldbutil.continue_to_breakpoint( + process, break_returnStruct_call_super) + self.assertTrue( + len(threads) == 1, + "Stepped to the call super line in Source returnsStruct - second time.") thread = threads[0] thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.sourceBase_returnsStruct_start_line, "Stepped through super into SourceBase returnsStruct in swizzled object.") + self.assertTrue( + line_number == self.sourceBase_returnsStruct_start_line, + "Stepped through super into SourceBase returnsStruct in swizzled object.") for bkpt in breakpoints_to_disable: bkpt.SetEnabled(False) - threads = lldbutil.continue_to_breakpoint (process, break_step_nil) - self.assertTrue (len(threads) == 1, "Continued to step nil breakpoint.") + threads = lldbutil.continue_to_breakpoint(process, break_step_nil) + self.assertTrue(len(threads) == 1, "Continued to step nil breakpoint.") thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.stepped_past_nil_line, "Step in over dispatch to nil stepped over.") + self.assertTrue( + line_number == self.stepped_past_nil_line, + "Step in over dispatch to nil stepped over.") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py index b2f2af76632..75f726340ef 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py @@ -3,13 +3,14 @@ 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 TestObjCStructArgument(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,7 +20,8 @@ class TestObjCStructArgument(TestBase): TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "test.m" - self.break_line = line_number(self.main_source, '// Set breakpoint here.') + self.break_line = line_number( + self.main_source, '// Set breakpoint here.') @skipUnlessDarwin @add_test_categories(['pyapi']) @@ -31,28 +33,36 @@ class TestObjCStructArgument(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) + bpt = target.BreakpointCreateByLocation( + self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt) + thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt) # Make sure we stopped at the first breakpoint. - self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.") - self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.") - + self.assertTrue( + len(thread_list) != 0, + "No thread stopped at our breakpoint.") + self.assertTrue(len(thread_list) == 1, + "More than one thread stopped at our breakpoint.") + frame = thread_list[0].GetFrameAtIndex(0) - self.assertTrue (frame, "Got a valid frame 0 frame.") + self.assertTrue(frame, "Got a valid frame 0 frame.") - self.expect("p [summer sumThings:tts]", substrs = ['9']) + self.expect("p [summer sumThings:tts]", substrs=['9']) - self.expect("po [NSValue valueWithRect:rect]", substrs = ['NSRect: {{0, 0}, {10, 20}}']) + self.expect( + "po [NSValue valueWithRect:rect]", + substrs=['NSRect: {{0, 0}, {10, 20}}']) - # Now make sure we can call a method that returns a struct without crashing. - cmd_value = frame.EvaluateExpression ("[provider getRange]") - self.assertTrue (cmd_value.IsValid()) + # Now make sure we can call a method that returns a struct without + # crashing. + cmd_value = frame.EvaluateExpression("[provider getRange]") + self.assertTrue(cmd_value.IsValid()) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py index 5a8722e71a4..6e56c06e8ae 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py @@ -3,13 +3,14 @@ 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 TestObjCClassMethod(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,7 +20,8 @@ class TestObjCClassMethod(TestBase): TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "test.m" - self.break_line = line_number(self.main_source, '// Set breakpoint here.') + self.break_line = line_number( + self.main_source, '// Set breakpoint here.') @skipUnlessDarwin @add_test_categories(['pyapi']) @@ -31,24 +33,30 @@ class TestObjCClassMethod(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) + bpt = target.BreakpointCreateByLocation( + self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt) + thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt) # Make sure we stopped at the first breakpoint. - self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.") - self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.") - + self.assertTrue( + len(thread_list) != 0, + "No thread stopped at our breakpoint.") + self.assertTrue(len(thread_list) == 1, + "More than one thread stopped at our breakpoint.") + frame = thread_list[0].GetFrameAtIndex(0) - self.assertTrue (frame, "Got a valid frame 0 frame.") + self.assertTrue(frame, "Got a valid frame 0 frame.") - # Now make sure we can call a method that returns a struct without crashing. - cmd_value = frame.EvaluateExpression ("[provider getRange]") - self.assertTrue (cmd_value.IsValid()) + # Now make sure we can call a method that returns a struct without + # crashing. + cmd_value = frame.EvaluateExpression("[provider getRange]") + self.assertTrue(cmd_value.IsValid()) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py index 39a0fb716ab..bf6befb4211 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py @@ -3,13 +3,14 @@ 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 TestObjCSuperMethod(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,7 +20,8 @@ class TestObjCSuperMethod(TestBase): TestBase.setUp(self) # Find the line numbers to break inside main(). self.main_source = "class.m" - self.break_line = line_number(self.main_source, '// Set breakpoint here.') + self.break_line = line_number( + self.main_source, '// Set breakpoint here.') @skipUnlessDarwin @expectedFailureAll(archs=["i[3-6]86"]) @@ -32,29 +34,35 @@ class TestObjCSuperMethod(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) + bpt = target.BreakpointCreateByLocation( + self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt) + thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt) # Make sure we stopped at the first breakpoint. - self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.") - self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.") - - # Now make sure we can call a function in the class method we've stopped in. + self.assertTrue( + len(thread_list) != 0, + "No thread stopped at our breakpoint.") + self.assertTrue(len(thread_list) == 1, + "More than one thread stopped at our breakpoint.") + + # Now make sure we can call a function in the class method we've + # stopped in. frame = thread_list[0].GetFrameAtIndex(0) - self.assertTrue (frame, "Got a valid frame 0 frame.") + self.assertTrue(frame, "Got a valid frame 0 frame.") - cmd_value = frame.EvaluateExpression ("[self get]") - self.assertTrue (cmd_value.IsValid()) - self.assertTrue (cmd_value.GetValueAsUnsigned() == 2) + cmd_value = frame.EvaluateExpression("[self get]") + self.assertTrue(cmd_value.IsValid()) + self.assertTrue(cmd_value.GetValueAsUnsigned() == 2) - cmd_value = frame.EvaluateExpression ("[super get]") - self.assertTrue (cmd_value.IsValid()) - self.assertTrue (cmd_value.GetValueAsUnsigned() == 1) + cmd_value = frame.EvaluateExpression("[super get]") + self.assertTrue(cmd_value.IsValid()) + self.assertTrue(cmd_value.GetValueAsUnsigned() == 1) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py b/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py index 33f7a0519fa..288f912dc79 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py @@ -5,13 +5,14 @@ Test "print object" where another thread blocks the print object from making pro 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 + @skipUnlessDarwin class PrintObjTestCase(TestBase): @@ -47,14 +48,16 @@ class PrintObjTestCase(TestBase): self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.runCmd("thread backtrace all") # Let's get the current stopped thread. We'd like to switch to the # other thread to issue our 'po lock_me' command. import lldbsuite.test.lldbutil as lldbutil - this_thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + this_thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) self.assertTrue(this_thread) # Find the other thread. The iteration protocol of SBProcess and the @@ -65,7 +68,8 @@ class PrintObjTestCase(TestBase): other_thread = t break - # Set the other thread as the selected thread to issue our 'po' command.other + # Set the other thread as the selected thread to issue our 'po' + # command.other self.assertTrue(other_thread) process.SetSelectedThread(other_thread) if self.TraceOn(): @@ -86,4 +90,4 @@ class PrintObjTestCase(TestBase): break self.expect("po lock_me", OBJECT_PRINTED_CORRECTLY, - substrs = ['I am pretty special.']) + substrs=['I am pretty special.']) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py b/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py index 32f2e7c8d6d..fe7d5d48ca7 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py @@ -5,13 +5,14 @@ Test that objective-c method returning BOOL works correctly. 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 + @skipUnlessDarwin class MethodReturningBOOLTestCase(TestBase): @@ -35,12 +36,13 @@ class MethodReturningBOOLTestCase(TestBase): exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, 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) self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, - substrs = [" at %s:%d" % (self.main_source, self.line), - "stop reason = breakpoint"]) + substrs=[" at %s:%d" % (self.main_source, self.line), + "stop reason = breakpoint"]) # rdar://problem/9691614 self.runCmd('p (int)[my isValid]') diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py b/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py index a4654d4bd1b..1375a78f87a 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py @@ -5,13 +5,14 @@ Test that CoreFoundation classes CFGregorianDate and CFRange are not improperly 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 + @skipUnlessDarwin class Rdar10967107TestCase(TestBase): @@ -35,11 +36,38 @@ class Rdar10967107TestCase(TestBase): exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, + self.main_source, + self.line, + num_expected_locations=1, + loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # check that each type is correctly bound to its list of children - self.expect("frame variable cf_greg_date --raw", substrs = ['year','month','day','hour','minute','second']) - self.expect("frame variable cf_range --raw", substrs = ['location','length']) + self.expect( + "frame variable cf_greg_date --raw", + substrs=[ + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second']) + self.expect( + "frame variable cf_range --raw", + substrs=[ + 'location', + 'length']) # check that printing both does not somehow confuse LLDB - self.expect("frame variable --raw", substrs = ['year','month','day','hour','minute','second','location','length']) + self.expect( + "frame variable --raw", + substrs=[ + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'location', + 'length']) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py b/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py index f1d38f8b7d3..26afe71d1de 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py @@ -5,13 +5,14 @@ Test that we do not attempt to make a dynamic type for a 'const char*' 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 + @skipUnlessDarwin class Rdar10967107TestCase(TestBase): @@ -35,32 +36,47 @@ class Rdar10967107TestCase(TestBase): exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, + self.main_source, + self.line, + num_expected_locations=1, + loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) - # check that we correctly see the const char*, even with dynamic types on - self.expect("frame variable my_string", substrs = ['const char *']) - self.expect("frame variable my_string --dynamic-type run-target", substrs = ['const char *']) + # check that we correctly see the const char*, even with dynamic types + # on + self.expect("frame variable my_string", substrs=['const char *']) + self.expect( + "frame variable my_string --dynamic-type run-target", + substrs=['const char *']) # check that expr also gets it right - self.expect("expr my_string", substrs = ['const char *']) - self.expect("expr -d run -- my_string", substrs = ['const char *']) + self.expect("expr my_string", substrs=['const char *']) + self.expect("expr -d run -- my_string", substrs=['const char *']) # but check that we get the real Foolie as such - self.expect("frame variable my_foolie", substrs = ['FoolMeOnce *']) - self.expect("frame variable my_foolie --dynamic-type run-target", substrs = ['FoolMeOnce *']) + self.expect("frame variable my_foolie", substrs=['FoolMeOnce *']) + self.expect( + "frame variable my_foolie --dynamic-type run-target", + substrs=['FoolMeOnce *']) # check that expr also gets it right - self.expect("expr my_foolie", substrs = ['FoolMeOnce *']) - self.expect("expr -d run -- my_foolie", substrs = ['FoolMeOnce *']) + self.expect("expr my_foolie", substrs=['FoolMeOnce *']) + self.expect("expr -d run -- my_foolie", substrs=['FoolMeOnce *']) # now check that assigning a true string does not break anything self.runCmd("next") - # check that we correctly see the const char*, even with dynamic types on - self.expect("frame variable my_string", substrs = ['const char *']) - self.expect("frame variable my_string --dynamic-type run-target", substrs = ['const char *']) + # check that we correctly see the const char*, even with dynamic types + # on + self.expect("frame variable my_string", substrs=['const char *']) + self.expect( + "frame variable my_string --dynamic-type run-target", + substrs=['const char *']) # check that expr also gets it right - self.expect("expr my_string", substrs = ['const char *']) - self.expect("expr -d run -- my_string", substrs = ['const char *']) + self.expect("expr my_string", substrs=['const char *']) + self.expect("expr -d run -- my_string", substrs=['const char *']) # but check that we get the real Foolie as such - self.expect("frame variable my_foolie", substrs = ['FoolMeOnce *']) - self.expect("frame variable my_foolie --dynamic-type run-target", substrs = ['FoolMeOnce *']) + self.expect("frame variable my_foolie", substrs=['FoolMeOnce *']) + self.expect( + "frame variable my_foolie --dynamic-type run-target", + substrs=['FoolMeOnce *']) # check that expr also gets it right - self.expect("expr my_foolie", substrs = ['FoolMeOnce *']) - self.expect("expr -d run -- my_foolie", substrs = ['FoolMeOnce *']) + self.expect("expr my_foolie", substrs=['FoolMeOnce *']) + self.expect("expr -d run -- my_foolie", substrs=['FoolMeOnce *']) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py b/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py index 7bc92595ef3..d431e98ba79 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py @@ -5,13 +5,14 @@ Test that we are able to find out how many children NSWindow has 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 + @skipUnlessDarwin class Rdar12408181TestCase(TestBase): @@ -35,15 +36,29 @@ class Rdar12408181TestCase(TestBase): exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, + self.main_source, + self.line, + num_expected_locations=1, + loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) - if self.frame().EvaluateExpression('(void*)_CGSDefaultConnection()').GetValueAsUnsigned() != 0: + if self.frame().EvaluateExpression( + '(void*)_CGSDefaultConnection()').GetValueAsUnsigned() != 0: window = self.frame().FindVariable("window") window_dynamic = window.GetDynamicValue(lldb.eDynamicCanRunTarget) - self.assertTrue(window.GetNumChildren() > 1, "NSWindow (static) only has 1 child!") - self.assertTrue(window_dynamic.GetNumChildren() > 1, "NSWindow (dynamic) only has 1 child!") - self.assertTrue(window.GetChildAtIndex(0).IsValid(), "NSWindow (static) has an invalid child") - self.assertTrue(window_dynamic.GetChildAtIndex(0).IsValid(), "NSWindow (dynamic) has an invalid child") + self.assertTrue( + window.GetNumChildren() > 1, + "NSWindow (static) only has 1 child!") + self.assertTrue( + window_dynamic.GetNumChildren() > 1, + "NSWindow (dynamic) only has 1 child!") + self.assertTrue( + window.GetChildAtIndex(0).IsValid(), + "NSWindow (static) has an invalid child") + self.assertTrue( + window_dynamic.GetChildAtIndex(0).IsValid(), + "NSWindow (dynamic) has an invalid child") else: self.skipTest('no WindowServer connection') diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py b/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py index c8f9a9c82c6..820ddcd9ec6 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py @@ -3,13 +3,14 @@ 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 TestRealDefinition(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,29 +23,35 @@ class TestRealDefinition(TestBase): self.build() self.common_setup() - line = line_number('Foo.m', '// Set breakpoint where Bar is an interface') - lldbutil.run_break_set_by_file_and_line (self, 'Foo.m', line, num_expected_locations=1, loc_exact=True); + line = line_number( + 'Foo.m', '// Set breakpoint where Bar is an interface') + lldbutil.run_break_set_by_file_and_line( + self, 'Foo.m', 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']) # Run and stop at Foo self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) self.runCmd("continue", RUN_SUCCEEDED) # Run at stop at main self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) - + substrs=[' resolved, hit count = 1']) + # This should display correctly. - self.expect("frame variable foo->_bar->_hidden_ivar", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["(NSString *)", "foo->_bar->_hidden_ivar = 0x"]) + self.expect( + "frame variable foo->_bar->_hidden_ivar", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "(NSString *)", + "foo->_bar->_hidden_ivar = 0x"]) @skipUnlessDarwin def test_frame_var_after_stop_at_implementation(self): @@ -54,29 +61,35 @@ class TestRealDefinition(TestBase): self.build() self.common_setup() - line = line_number('Bar.m', '// Set breakpoint where Bar is an implementation') - lldbutil.run_break_set_by_file_and_line (self, 'Bar.m', line, num_expected_locations=1, loc_exact=True) + line = line_number( + 'Bar.m', '// Set breakpoint where Bar is an implementation') + lldbutil.run_break_set_by_file_and_line( + self, 'Bar.m', 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']) # Run and stop at Foo self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) self.runCmd("continue", RUN_SUCCEEDED) # Run at stop at main self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) # This should display correctly. - self.expect("frame variable foo->_bar->_hidden_ivar", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["(NSString *)", "foo->_bar->_hidden_ivar = 0x"]) + self.expect( + "frame variable foo->_bar->_hidden_ivar", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "(NSString *)", + "foo->_bar->_hidden_ivar = 0x"]) def common_setup(self): exe = os.path.join(os.getcwd(), "a.out") @@ -84,4 +97,5 @@ class TestRealDefinition(TestBase): # Break inside the foo function which takes a bar_ptr argument. line = line_number('main.m', '// Set breakpoint in main') - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py b/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py index 004563c55be..48c4313375c 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py @@ -6,10 +6,11 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCSelfTestCase(TestBase): - + mydir = TestBase.compute_mydir(__file__) - + @skipUnlessDarwin def test_with_run_command(self): """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods""" @@ -22,16 +23,17 @@ class ObjCSelfTestCase(TestBase): self.runCmd("process launch", RUN_SUCCEEDED) self.expect("expression -- m_a = 2", - startstr = "(int) $0 = 2") - + startstr="(int) $0 = 2") + self.runCmd("process continue") - + # This would be disallowed if we enforced const. But we don't. self.expect("expression -- m_a = 2", error=True) - - self.expect("expression -- s_a", - startstr = "(int) $1 = 5") + + self.expect("expression -- s_a", + startstr="(int) $1 = 5") def set_breakpoint(self, line): - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py b/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py index 7c294ef8cc6..97b137818a0 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py @@ -3,9 +3,9 @@ from __future__ import print_function - import unittest2 -import os, time +import os +import time import platform from distutils.version import StrictVersion @@ -15,6 +15,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCSingleEntryDictionaryTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -32,37 +33,46 @@ class ObjCSingleEntryDictionaryTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. - 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']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) d1 = self.frame().FindVariable("d1") d1.SetPreferSyntheticValue(True) d1.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) - - self.assertTrue(d1.GetNumChildren() == 1, "dictionary has != 1 child elements") + + self.assertTrue( + d1.GetNumChildren() == 1, + "dictionary has != 1 child elements") pair = d1.GetChildAtIndex(0) pair.SetPreferSyntheticValue(True) pair.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) - - self.assertTrue(pair.GetNumChildren() == 2, "pair has != 2 child elements") - + + self.assertTrue( + pair.GetNumChildren() == 2, + "pair has != 2 child elements") + key = pair.GetChildMemberWithName("key") value = pair.GetChildMemberWithName("value") - + key.SetPreferSyntheticValue(True) key.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) value.SetPreferSyntheticValue(True) value.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) - - self.assertTrue(key.GetSummary() == '@"key"', "key doesn't contain key") - self.assertTrue(value.GetSummary() == '@"value"', "value doesn't contain value") + + self.assertTrue( + key.GetSummary() == '@"key"', + "key doesn't contain key") + self.assertTrue( + value.GetSummary() == '@"value"', + "value doesn't contain value") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py b/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py index 791ce27dad0..804905106df 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.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]) |

