[Lldb-commits] [PATCH] D144929: Add SBCommandInterpreter::UserCommandExists
Jim Ingham via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Feb 28 16:00:35 PST 2023
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4eb694e35dd5: Add SBCommandInterpreter::UserCommandExists parallel to CommandExists. (authored by jingham).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144929/new/
https://reviews.llvm.org/D144929
Files:
lldb/include/lldb/API/SBCommandInterpreter.h
lldb/source/API/SBCommandInterpreter.cpp
lldb/test/API/commands/command/script/TestCommandScript.py
Index: lldb/test/API/commands/command/script/TestCommandScript.py
===================================================================
--- lldb/test/API/commands/command/script/TestCommandScript.py
+++ lldb/test/API/commands/command/script/TestCommandScript.py
@@ -19,6 +19,11 @@
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"])
Index: lldb/source/API/SBCommandInterpreter.cpp
===================================================================
--- lldb/source/API/SBCommandInterpreter.cpp
+++ lldb/source/API/SBCommandInterpreter.cpp
@@ -118,6 +118,13 @@
: 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);
Index: lldb/include/lldb/API/SBCommandInterpreter.h
===================================================================
--- lldb/include/lldb/API/SBCommandInterpreter.h
+++ lldb/include/lldb/API/SBCommandInterpreter.h
@@ -45,8 +45,34 @@
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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144929.501326.patch
Type: text/x-patch
Size: 2661 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230301/d163ca06/attachment.bin>
More information about the lldb-commits
mailing list