109 lines · python
1"""2Test the lldb disassemble command on foundation framework.3"""4 5import os6import lldb7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9from lldbsuite.test import lldbutil10 11 12class FoundationDisassembleTestCase(TestBase):13 NO_DEBUG_INFO_TESTCASE = True14 15 @skipIfAsan16 def test_simple_disasm(self):17 """Test the lldb 'disassemble' command"""18 self.build()19 20 # Create a target by the debugger.21 target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))22 self.assertTrue(target, VALID_TARGET)23 24 # Stop at +[NSString stringWithFormat:].25 symbol_name = "+[NSString stringWithFormat:]"26 break_results = lldbutil.run_break_set_command(27 self, "_regexp-break %s" % (symbol_name)28 )29 30 lldbutil.check_breakpoint_result(31 self, break_results, symbol_name=symbol_name, num_locations=132 )33 34 # Stop at -[MyString initWithNSString:].35 lldbutil.run_break_set_by_symbol(36 self,37 "-[MyString initWithNSString:]",38 num_expected_locations=1,39 sym_exact=True,40 )41 42 # Stop at the "description" selector.43 lldbutil.run_break_set_by_selector(44 self, "description", num_expected_locations=1, module_name="a.out"45 )46 47 # Stop at -[NSAutoreleasePool release].48 break_results = lldbutil.run_break_set_command(49 self, "_regexp-break -[NSAutoreleasePool release]"50 )51 lldbutil.check_breakpoint_result(52 self,53 break_results,54 symbol_name="-[NSAutoreleasePool release]",55 num_locations=1,56 )57 58 self.runCmd("run", RUN_SUCCEEDED)59 60 # First stop is +[NSString stringWithFormat:].61 self.expect(62 "thread backtrace",63 "Stop at +[NSString stringWithFormat:]",64 substrs=["Foundation`+[NSString stringWithFormat:]"],65 )66 67 # Do the disassemble for the currently stopped function.68 self.runCmd("disassemble -f")69 70 self.runCmd("process continue")71 # Skip another breakpoint for +[NSString stringWithFormat:].72 self.runCmd("process continue")73 74 # Followed by a.out`-[MyString initWithNSString:].75 self.expect(76 "thread backtrace",77 "Stop at a.out`-[MyString initWithNSString:]",78 substrs=["a.out`-[MyString initWithNSString:]"],79 )80 81 # Do the disassemble for the currently stopped function.82 self.runCmd("disassemble -f")83 84 self.runCmd("process continue")85 86 # Followed by -[MyString description].87 self.expect(88 "thread backtrace",89 "Stop at -[MyString description]",90 substrs=["a.out`-[MyString description]"],91 )92 93 # Do the disassemble for the currently stopped function.94 self.runCmd("disassemble -f")95 96 self.runCmd("process continue")97 # Skip another breakpoint for -[MyString description].98 self.runCmd("process continue")99 100 # Followed by -[NSAutoreleasePool release].101 self.expect(102 "thread backtrace",103 "Stop at -[NSAutoreleasePool release]",104 substrs=["Foundation`-[NSAutoreleasePool release]"],105 )106 107 # Do the disassemble for the currently stopped function.108 self.runCmd("disassemble -f")109