Add support for custom commands to set flags on themselves

This works for Python commands defined via a class (implement get_flags on your class) and C++ plugin commands (which can call SBCommand::GetFlags()/SetFlags())

Flags allow features such as not letting the command run if there's no target, or if the process is not stopped, ...
Commands could always check for these things themselves, but having these accessible via flags makes custom commands more consistent with built-in ones

llvm-svn: 238286
This commit is contained in:
Enrico Granata
2015-05-27 05:04:35 +00:00
parent 3273930d9a
commit e87764f247
26 changed files with 360 additions and 246 deletions

View File

@@ -23,11 +23,17 @@ class CmdPythonTestCase(TestBase):
self.pycmd_tests ()
def pycmd_tests (self):
self.runCmd("command source py_import")
self.expect('targetname',
substrs = ['a.out'], matching=False, error=True)
exe = os.path.join (os.getcwd(), "a.out")
self.expect("file " + exe,
patterns = [ "Current executable set to .*a.out" ])
self.runCmd("command source py_import")
self.expect('targetname',
substrs = ['a.out'], matching=True, error=False)
# This is the function to remove the custom commands in order to have a
# clean slate for the next test case.
@@ -75,9 +81,6 @@ class CmdPythonTestCase(TestBase):
self.expect('welcome Enrico', matching=False, error=True,
substrs = ['Hello Enrico, welcome to LLDB']);
self.expect('targetname',
substrs = ['a.out'])
self.expect('targetname fail', error=True,
substrs = ['a test for error in command'])
@@ -122,7 +125,7 @@ class CmdPythonTestCase(TestBase):
self.runCmd('command script add my_command --class welcome.WelcomeCommand')
self.expect('my_command Blah', substrs = ['Hello Blah, welcome to LLDB'])
self.runCmd('command script add my_command --function welcome.target_name_impl')
self.runCmd('command script add my_command --class welcome.TargetnameCommand')
self.expect('my_command', substrs = ['a.out'])
self.runCmd("command script clear")