diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 18:01:57 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 18:01:57 +0000 |
| commit | 88c643b6fec27eec436c8d138fee6346e92337d6 (patch) | |
| tree | 82cd13b2f3cde1c9e5f79689ba4e6ba67694843f /packages/Python/lldbsuite/test/lang/objc/foundation | |
| parent | 94994d372d014ce4c8758b9605d63fae651bd8aa (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/objc/foundation')
12 files changed, 0 insertions, 1159 deletions
diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/Makefile b/packages/Python/lldbsuite/test/lang/objc/foundation/Makefile deleted file mode 100644 index ce2ccd28321d..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -LEVEL = ../../../make - -OBJC_SOURCES := main.m my-base.m -#OBJC_SOURCES := const-strings.m - -include $(LEVEL)/Makefile.rules - -LDFLAGS += -framework Foundation diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py deleted file mode 100644 index 95c5575385c5..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py +++ /dev/null @@ -1,60 +0,0 @@ -""" -Test that objective-c constant strings are generated correctly by the expression -parser. -""" - -from __future__ import print_function - - -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__) - d = {'OBJC_SOURCES': 'const-strings.m'} - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break inside main(). - self.main_source = "const-strings.m" - self.line = line_number(self.main_source, '// Set breakpoint here.') - - @skipUnlessDarwin - def test_break(self): - """Test constant string generation amd comparison by the expression parser.""" - self.build(dictionary=self.d) - self.setTearDownCleanup(self.d) - - exe = self.getBuildArtifact("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) - - 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"]) - - self.expect('expression (int)[str compare:@"hello"]', - startstr="(int) $0 = 0") - self.expect('expression (int)[str compare:@"world"]', - startstr="(int) $1 = -1") - - # Test empty strings, too. - self.expect('expression (int)[@"" length]', - startstr="(int) $2 = 0") - - self.expect('expression (int)[@"123" length]', - startstr="(int) $3 = 3") diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py deleted file mode 100644 index 345e41b2b04e..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py +++ /dev/null @@ -1,162 +0,0 @@ -""" -Test the lldb disassemble command on foundation framework. -""" - -from __future__ import print_function - - -import unittest2 -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): - - mydir = TestBase.compute_mydir(__file__) - - # rdar://problem/8504895 - # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" - @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(self.getBuildArtifact("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()) - self.assertTrue(process, PROCESS_IS_VALID) - - foundation_framework = None - for module in target.modules: - print(module) - if module.file.basename == "Foundation": - foundation_framework = module.file.fullpath - break - - 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: - # 'disassemble -n func'. - # - # The symbol name is on the last column and trails the flag column which - # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits. - codeRE = re.compile(r""" - \ Code\ {9} # ' Code' followed by 9 SPCs, - .* # the wildcard chars, - 0x[0-9a-f]{8} # the flag column, and - \ (.+)$ # finally the function symbol. - """, re.VERBOSE) - for line in raw_output.split(os.linesep): - match = codeRE.search(line) - if match: - func = match.group(1) - #print("line:", line) - #print("func:", func) - self.runCmd('disassemble -n "%s"' % func) - - def test_simple_disasm(self): - """Test the lldb 'disassemble' command""" - self.build() - - # Create a target by the debugger. - target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) - self.assertTrue(target, VALID_TARGET) - - print(target) - for module in target.modules: - print(module) - - # 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) - - # Stop at -[MyString initWithNSString:]. - 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') - - # 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) - - self.runCmd("run", RUN_SUCCEEDED) - - # First stop is +[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") - - self.runCmd("process continue") - # Skip another breakpoint for +[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:]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble -f") - - self.runCmd("process continue") - - # Followed by -[MyString description]. - self.expect("thread backtrace", "Stop at -[MyString description]", - substrs=["a.out`-[MyString description]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble -f") - - self.runCmd("process continue") - # Skip another breakpoint for -[MyString description]. - self.runCmd("process continue") - - # Followed by -[NSAutoreleasePool release]. - self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", - substrs=["Foundation`-[NSAutoreleasePool release]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble -f") diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py deleted file mode 100644 index 42535ca44af0..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py +++ /dev/null @@ -1,327 +0,0 @@ -""" -Set breakpoints on objective-c class and instance methods in foundation. -Also lookup objective-c data types and evaluate expressions. -""" - -from __future__ import print_function - - -import os -import os.path -import time -import lldb -import string -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - -file_index = 0 - - -@skipUnlessDarwin -class FoundationTestCase(TestBase): - - mydir = TestBase.compute_mydir(__file__) - - def setUp(self): - # Call super's setUp(). - 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.') - - def test_break(self): - """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" - self.build() - exe = self.getBuildArtifact("a.out") - 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) - - # Stop at -[MyString initWithNSString:]. - 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') - - # 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) - - self.runCmd("run", RUN_SUCCEEDED) - - # First stop is +[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.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.runCmd("process continue") - - # Followed by -[MyString description]. - self.expect("thread backtrace", "Stop at -[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]"]) - - self.runCmd("process continue") - - # Followed by -[NSAutoreleasePool release]. - self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", - substrs=["Foundation`-[NSAutoreleasePool release]"]) - - # rdar://problem/8542091 - # rdar://problem/8492646 - def test_data_type_and_expr(self): - """Lookup objective-c data types and evaluate expressions.""" - self.build() - exe = self.getBuildArtifact("a.out") - 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) -# self.expect("breakpoint set -n '-[MyString description]", BREAKPOINT_CREATED, -# 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]"]) - - # 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']) - - 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)"]) - - # rdar://problem/8651752 - # don't crash trying to ask clang how many children an empty record has - self.runCmd("frame variable *_cmd") - - # 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") - - # 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") - - # 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"]) - - # isa should be accessible. - self.expect("expression self->isa", VARIABLES_DISPLAYED_CORRECTLY, - 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'") - - # Use expression parser. - self.runCmd("expression self->str") - self.runCmd("expression self->date") - - # (lldb) expression self->str - # error: instance variable 'str' is protected - # error: 1 errors parsing expression - # - # (lldb) expression self->date - # error: instance variable 'date' is protected - # error: 1 errors parsing expression - # - - 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) - - self.runCmd("process continue") - - # rdar://problem/8542091 - # 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_test_categories(['pyapi']) - 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. - exe = self.getBuildArtifact("a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - break1 = target.BreakpointCreateByLocation(self.main_source, self.line) - 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()) - - self.assertTrue(process, PROCESS_IS_VALID) - - # The stop reason of the thread should be breakpoint. - thread = process.GetThreadAtIndex(0) - if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbsuite.test.lldbutil import stop_reason_to_str - self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - stop_reason_to_str(thread.GetStopReason())) - - # Make sure we stopped at the first breakpoint. - - cur_frame = thread.GetFrameAtIndex(0) - - line_number = cur_frame.GetLineEntry().GetLine() - 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") - - str_var = cur_frame.FindVariable("str") - self.assertTrue(str_var, "Made a variable object for str") - - # Now make sure that the my->str == str: - - my_str_var = my_var.GetChildMemberWithName("str") - self.assertTrue(my_str_var, "Found a str ivar in my") - - str_value = int(str_var.GetValue(), 0) - - my_str_value = int(my_str_var.GetValue(), 0) - - 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).""" - self.build() - exe = self.getBuildArtifact("a.out") - 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) - - self.runCmd("run", RUN_SUCCEEDED) - - global file_index - # Log any DWARF lookups - ++file_index - logfile = os.path.join( - self.getBuildDir(), - "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) - - self.addTearDownHook(cleanup) - - 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:") - num_errors += 1 - print(line, end='') - self.assertTrue(num_errors == 0, "Spurious lookups detected") - f.close() diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py deleted file mode 100644 index 2b967e988856..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py +++ /dev/null @@ -1,205 +0,0 @@ -""" -Test more expression command sequences with objective-c. -""" - -from __future__ import print_function - - -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')) - - def test_more_expr_commands(self): - """More expression commands for objective-c.""" - self.build() - exe = self.getBuildArtifact("a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # 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) - - self.runCmd("run", RUN_SUCCEEDED) - - # Test_Selector: - self.runCmd("thread backtrace") - self.expect("expression (char *)sel_getName(sel)", - substrs=["(char *)", - "length"]) - - self.runCmd("process continue") - - # Test_NSArray: - self.runCmd("thread backtrace") - self.runCmd("process continue") - - # Test_NSString: - self.runCmd("thread backtrace") - self.runCmd("process continue") - - # Test_MyString: - self.runCmd("thread backtrace") - self.expect("expression (char *)sel_getName(_cmd)", - substrs=["(char *)", - "description"]) - - self.runCmd("process continue") - - def test_NSArray_expr_commands(self): - """Test expression commands for NSArray.""" - self.build() - exe = self.getBuildArtifact("a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # 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) - - self.runCmd("run", RUN_SUCCEEDED) - - # Test_NSArray: - self.runCmd("thread backtrace") - self.expect("expression (int)[nil_mutable_array count]", - patterns=["\(int\) \$.* = 0"]) - self.expect("expression (int)[array1 count]", - patterns=["\(int\) \$.* = 3"]) - self.expect("expression (int)[array2 count]", - patterns=["\(int\) \$.* = 3"]) - self.expect("expression (int)array1.count", - patterns=["\(int\) \$.* = 3"]) - self.expect("expression (int)array2.count", - patterns=["\(int\) \$.* = 3"]) - self.runCmd("process continue") - - def test_NSString_expr_commands(self): - """Test expression commands for NSString.""" - self.build() - exe = self.getBuildArtifact("a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # 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) - - self.runCmd("run", RUN_SUCCEEDED) - - # Test_NSString: - self.runCmd("thread backtrace") - self.expect("expression (int)[str length]", - patterns=["\(int\) \$.* ="]) - self.expect("expression (int)[str_id length]", - patterns=["\(int\) \$.* ="]) - self.expect("expression (id)[str description]", - patterns=["\(id\) \$.* = 0x"]) - self.expect("expression (id)[str_id description]", - patterns=["\(id\) \$.* = 0x"]) - self.expect("expression str.length") - self.expect('expression str = @"new"') - self.runCmd("image lookup -t NSString") - self.expect('expression str = (id)[NSString stringWithCString: "new"]') - self.runCmd("process continue") - - @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>") - def test_MyString_dump_with_runtime(self): - """Test dump of a known Objective-C object by dereferencing it.""" - self.build() - exe = self.getBuildArtifact("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) - - self.runCmd("run", RUN_SUCCEEDED) - - self.expect( - "expression --show-types -- *my", - patterns=[ - "\(MyString\) \$.* = ", - "\(MyBase\)"]) - self.runCmd("process continue") - - @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>") - def test_runtime_types(self): - """Test commands that require runtime types""" - self.build() - exe = self.getBuildArtifact("a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Break inside Test_NSString: - line = self.lines[2] - lldbutil.run_break_set_by_source_regexp( - self, "NSString tests") - - self.runCmd("run", RUN_SUCCEEDED) - - # Test_NSString: - self.runCmd("thread backtrace") - self.expect("expression [str length]", - patterns=["\(NSUInteger\) \$.* ="]) - self.expect("expression str.length") - self.expect('expression str = [NSString stringWithCString: "new"]') - self.expect( - 'po [NSError errorWithDomain:@"Hello" code:35 userInfo:@{@"NSDescription" : @"be completed."}]', - substrs=[ - "Error Domain=Hello", - "Code=35", - "be completed."]) - self.runCmd("process continue") - - @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>") - def test_NSError_p(self): - """Test that p of the result of an unknown method does require a cast.""" - self.build() - exe = self.getBuildArtifact("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) - - 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.runCmd("process continue") diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py deleted file mode 100644 index 82e08584702f..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py +++ /dev/null @@ -1,78 +0,0 @@ -""" -Test SBValue.GetObjectDescription() with the value from SBTarget.FindGlobalVariables(). -""" - -from __future__ import print_function - - -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__) - - def setUp(self): - # Call super's setUp(). - 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.') - - # rdar://problem/10857337 - @skipUnlessDarwin - @add_test_categories(['pyapi']) - def test_find_global_variables_then_object_description(self): - """Exercise SBTarget.FindGlobalVariables() API.""" - d = {'EXE': 'b.out'} - self.build(dictionary=d) - self.setTearDownCleanup(dictionary=d) - exe = self.getBuildArtifact('b.out') - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - breakpoint = target.BreakpointCreateByLocation(self.source, self.line) - 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()) - 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 = thread_list[0] - frame0 = thread.GetFrameAtIndex(0) - - # Note my_global_str's object description prints fine here. - value_list1 = frame0.GetVariables(True, True, True, True) - for v in value_list1: - self.DebugSBValue(v) - if self.TraceOn(): - print("val:", v) - print("object description:", v.GetObjectDescription()) - if v.GetName() == 'my_global_str': - self.assertTrue(v.GetObjectDescription() == - 'This is a global string') - - # But not here! - value_list2 = target.FindGlobalVariables('my_global_str', 3) - for v in value_list2: - self.DebugSBValue(v) - if self.TraceOn(): - print("val:", v) - print("object description:", v.GetObjectDescription()) - if v.GetName() == 'my_global_str': - self.assertTrue(v.GetObjectDescription() == - 'This is a global string') diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py deleted file mode 100644 index c52ac8c2e6d0..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py +++ /dev/null @@ -1,62 +0,0 @@ -""" -Test that Objective-C methods from the runtime work correctly. -""" - -from __future__ import print_function - - -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") - def test_break(self): - """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" - if self.getArchitecture() != 'x86_64': - self.skipTest("This only applies to the v2 runtime") - - self.build() - exe = self.getBuildArtifact("a.out") - 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) - - 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]"]) - - # 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\)"]) - - # Static methods on NSString should work. - self.expect( - "expr [NSString stringWithCString:\"foo\" encoding:1]", - VALID_TYPE, - substrs=[ - "(id)", - "$1"]) - - self.expect("po $1", VARIABLES_DISPLAYED_CORRECTLY, - substrs=["foo"]) diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py deleted file mode 100644 index bfb9e0b4479d..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py +++ /dev/null @@ -1,74 +0,0 @@ -""" -Test symbol table access for main.m. -""" - -from __future__ import print_function - - -import os -import time - -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -@skipUnlessDarwin -class FoundationSymtabTestCase(TestBase): - - mydir = TestBase.compute_mydir(__file__) - - symbols_list = ['-[MyString initWithNSString:]', - '-[MyString dealloc]', - '-[MyString description]', - '-[MyString descriptionPauses]', # synthesized property - # synthesized property - '-[MyString setDescriptionPauses:]', - 'Test_Selector', - 'Test_NSString', - 'Test_MyString', - 'Test_NSArray', - 'main' - ] - - @add_test_categories(['pyapi']) - def test_with_python_api(self): - """Test symbol table access with Python APIs.""" - self.build() - exe = self.getBuildArtifact("a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - target = self.dbg.CreateTarget(exe) - 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()) - - # - # Exercise Python APIs to access the symbol table entries. - # - - # Create the filespec by which to locate our a.out module. - filespec = lldb.SBFileSpec(exe, False) - - module = target.FindModule(filespec) - self.assertTrue(module, VALID_MODULE) - - # Create the set of known symbols. As we iterate through the symbol - # table, remove the symbol from the set if it is a known symbol. - expected_symbols = set(self.symbols_list) - for symbol in module: - self.assertTrue(symbol, VALID_SYMBOL) - #print("symbol:", symbol) - name = symbol.GetName() - if name in expected_symbols: - #print("Removing %s from known_symbols %s" % (name, expected_symbols)) - expected_symbols.remove(name) - - # At this point, the known_symbols set should have become an empty set. - # If not, raise an error. - #print("symbols unaccounted for:", expected_symbols) - self.assertTrue(len(expected_symbols) == 0, - "All the known symbols are accounted for") diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/const-strings.m b/packages/Python/lldbsuite/test/lang/objc/foundation/const-strings.m deleted file mode 100644 index 8a43abee7b84..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/const-strings.m +++ /dev/null @@ -1,24 +0,0 @@ -#import <Foundation/Foundation.h> - -// Tests to run: - -// Breakpoint 1 -// -- -// (lldb) expr (int)[str compare:@"hello"] -// (int) $0 = 0 -// (lldb) expr (int)[str compare:@"world"] -// (int) $1 = -1 -// (lldb) expr (int)[@"" length] -// (int) $2 = 0 - -int main () -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - NSString *str = [NSString stringWithCString:"hello" encoding:NSASCIIStringEncoding]; - - NSLog(@"String \"%@\" has length %lu", str, [str length]); // Set breakpoint here. - - [pool drain]; - return 0; -} diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/main.m b/packages/Python/lldbsuite/test/lang/objc/foundation/main.m deleted file mode 100644 index 519bec5a3e6a..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/main.m +++ /dev/null @@ -1,141 +0,0 @@ -#import <Foundation/Foundation.h> -#include <unistd.h> -#import "my-base.h" - -@interface MyString : MyBase { - NSString *str; - NSDate *date; - BOOL _desc_pauses; -} - -@property(retain) NSString * str_property; -@property BOOL descriptionPauses; - -- (id)initWithNSString:(NSString *)string; -@end - -@implementation MyString -@synthesize descriptionPauses = _desc_pauses; -@synthesize str_property = str; - -- (id)initWithNSString:(NSString *)string -{ - if (self = [super init]) - { - str = [NSString stringWithString:string]; - date = [NSDate date]; - } - self.descriptionPauses = NO; - return self; -} - -- (void)dealloc -{ - [date release]; - [str release]; - [super dealloc]; -} - -- (NSString *)description -{ - // Set a breakpoint on '-[MyString description]' and test expressions: - // expression (char *)sel_getName(_cmd) - if (self.descriptionPauses) // Break here for description test - { - printf ("\nAbout to sleep.\n"); - usleep(100000); - } - - return [str stringByAppendingFormat:@" with timestamp: %@", date]; -} -@end - -int -Test_Selector () -{ - SEL sel = @selector(length); - printf("sel = %p\n", sel); - // Expressions to test here for selector: - // expression (char *)sel_getName(sel) - // The expression above should return "sel" as it should be just - // a uniqued C string pointer. We were seeing the result pointer being - // truncated with recent LLDBs. - return 0; // Break here for selector: tests -} - -int -Test_NSString (const char *program) -{ - NSString *str = [NSString stringWithFormat:@"Hello from '%s'", program]; - NSLog(@"NSString instance: %@", str); - printf("str = '%s'\n", [str cStringUsingEncoding: [NSString defaultCStringEncoding]]); - printf("[str length] = %zu\n", (size_t)[str length]); - printf("[str description] = %s\n", [[str description] UTF8String]); - id str_id = str; - // Expressions to test here for NSString: - // expression (char *)sel_getName(sel) - // expression [str length] - // expression [str_id length] - // expression [str description] - // expression [str_id description] - // expression str.length - // expression str.description - // expression str = @"new" - // expression str = [NSString stringWithFormat: @"%cew", 'N'] - return 0; // Break here for NSString tests -} - -NSString *my_global_str = NULL; - -void -Test_MyString (const char *program) -{ - my_global_str = @"This is a global string"; - NSString *str = [NSString stringWithFormat:@"Hello from '%s'", program]; - MyString *my = [[MyString alloc] initWithNSString:str]; - NSLog(@"MyString instance: %@", [my description]); - my.descriptionPauses = YES; // Set break point at this line. Test 'expression -o -- my'. - NSLog(@"MyString instance: %@", [my description]); -} - -int -Test_NSArray () -{ - NSMutableArray *nil_mutable_array = nil; - NSArray *array1 = [NSArray arrayWithObjects: @"array1 object1", @"array1 object2", @"array1 object3", nil]; - NSArray *array2 = [NSArray arrayWithObjects: array1, @"array2 object2", @"array2 object3", nil]; - // Expressions to test here for NSArray: - // expression [nil_mutable_array count] - // expression [array1 count] - // expression array1.count - // expression [array2 count] - // expression array2.count - id obj; - // After each object at index call, use expression and validate object - obj = [array1 objectAtIndex: 0]; // Break here for NSArray tests - obj = [array1 objectAtIndex: 1]; - obj = [array1 objectAtIndex: 2]; - - obj = [array2 objectAtIndex: 0]; - obj = [array2 objectAtIndex: 1]; - obj = [array2 objectAtIndex: 2]; - NSUInteger count = [nil_mutable_array count]; - return 0; -} - - -int main (int argc, char const *argv[]) -{ - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - Test_Selector(); - Test_NSArray (); - Test_NSString (argv[0]); - Test_MyString (argv[0]); - - printf("sizeof(id) = %zu\n", sizeof(id)); - printf("sizeof(Class) = %zu\n", sizeof(Class)); - printf("sizeof(SEL) = %zu\n", sizeof(SEL)); - - [pool release]; - return 0; -} diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.h b/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.h deleted file mode 100644 index 53202aa0de37..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.h +++ /dev/null @@ -1,8 +0,0 @@ -@interface MyBase : NSObject -{ -#if !__OBJC2__ - int maybe_used; // The 1.0 runtime needs to have backed properties... -#endif -} -@property int propertyMovesThings; -@end diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.m b/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.m deleted file mode 100644 index 0c316b244f26..000000000000 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/my-base.m +++ /dev/null @@ -1,10 +0,0 @@ -#import <Foundation/Foundation.h> -#import "my-base.h" -@implementation MyBase -#if __OBJC2__ -@synthesize propertyMovesThings; -#else -@synthesize propertyMovesThings = maybe_used; -#endif -@end - |
