bool IsValid() const;
+ /// Return whether a built-in command with the passed in
+ /// name or command path exists.
+ ///
+ /// \param[in] cmd
+ /// The command or command path to search for.
+ ///
+ /// \return
+ /// \b true if the command exists, \b false otherwise.
bool CommandExists(const char *cmd);
+ /// Return whether a user defined command with the passed in
+ /// name or command path exists.
+ ///
+ /// \param[in] cmd
+ /// The command or command path to search for.
+ ///
+ /// \return
+ /// \b true if the command exists, \b false otherwise.
+ bool UserCommandExists(const char *cmd);
+
+ /// Return whether the passed in name or command path
+ /// exists and is an alias to some other command.
+ ///
+ /// \param[in] cmd
+ /// The command or command path to search for.
+ ///
+ /// \return
+ /// \b true if the command exists, \b false otherwise.
bool AliasExists(const char *cmd);
lldb::SBBroadcaster GetBroadcaster();
: false);
}
+bool SBCommandInterpreter::UserCommandExists(const char *cmd) {
+ LLDB_INSTRUMENT_VA(this, cmd);
+
+ return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->UserCommandExists(cmd)
+ : false);
+}
+
bool SBCommandInterpreter::AliasExists(const char *cmd) {
LLDB_INSTRUMENT_VA(this, cmd);
def pycmd_tests(self):
self.runCmd("command source py_import")
+ # Test that we did indeed add these commands as user commands:
+ interp = self.dbg.GetCommandInterpreter()
+ self.expectTrue(interp.UserCommandExists("foobar"), "foobar exists")
+ self.expectFalse(interp.CommandExists("foobar"), "It is not a builtin.")
+
# Test a bunch of different kinds of python callables with
# both 4 and 5 positional arguments.
self.expect("foobar", substrs=["All good"])