63 lines · python
1import lldb2from lldbsuite.test.lldbtest import *3from lldbsuite.test.decorators import *4import lldbsuite.test.lldbutil as lldbutil5 6 7class TestCase(TestBase):8 @skipUnlessDarwin9 def test(self):10 self.build()11 _, _, thread, _ = lldbutil.run_to_source_breakpoint(12 self, "break here", lldb.SBFileSpec("lib.cpp")13 )14 15 frame = thread.selected_frame16 self.assertEqual(frame.GuessLanguage(), lldb.eLanguageTypeC_plus_plus_11)17 self.assertEqual(frame.name, "f()")18 19 # Test `help`.20 self.expect(21 "help demangle",22 substrs=[23 "Demangle a C++ mangled name.",24 "Syntax: language cplusplus demangle [<mangled-name> ...]",25 ],26 )27 28 # Run a `language cplusplus` command.29 self.expect("demangle _Z1fv", startstr="_Z1fv ---> f()")30 # Test prefix matching.31 self.expect("dem _Z1fv", startstr="_Z1fv ---> f()")32 33 # Select the objc caller.34 self.runCmd("up")35 frame = thread.selected_frame36 self.assertEqual(frame.GuessLanguage(), lldb.eLanguageTypeObjC_plus_plus)37 self.assertEqual(frame.name, "main")38 39 # Ensure `demangle` doesn't resolve from the objc frame.40 self.expect("help demangle", error=True)41 42 # Run a `language objc` command.43 self.expect(44 "tagged-pointer",45 substrs=[46 "Commands for operating on Objective-C tagged pointers.",47 "Syntax: tagged-pointer <subcommand> [<subcommand-options>]",48 "The following subcommands are supported:",49 "info -- Dump information on a tagged pointer.",50 ],51 )52 53 # To ensure compatability with existing scripts, a language specific54 # command must not be invoked if another command (such as a python55 # command) has the language specific command name as its prefix.56 #57 # For example, this test loads a `tagged-pointer-collision` command. A58 # script could exist that invokes this command using its prefix59 # `tagged-pointer`, under the assumption that "tagged-pointer" uniquely60 # identifies the python command `tagged-pointer-collision`.61 self.runCmd("command script import commands.py")62 self.expect("tagged-pointer", startstr="ran tagged-pointer-collision")63