File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
test/API/commands/command/script Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,34 @@ class SBCommandInterpreter {
45
45
46
46
bool IsValid () const ;
47
47
48
+ // / Return whether a built-in command with the passed in
49
+ // / name or command path exists.
50
+ // /
51
+ // / \param[in] cmd
52
+ // / The command or command path to search for.
53
+ // /
54
+ // / \return
55
+ // / \b true if the command exists, \b false otherwise.
48
56
bool CommandExists (const char *cmd);
49
57
58
+ // / Return whether a user defined command with the passed in
59
+ // / name or command path exists.
60
+ // /
61
+ // / \param[in] cmd
62
+ // / The command or command path to search for.
63
+ // /
64
+ // / \return
65
+ // / \b true if the command exists, \b false otherwise.
66
+ bool UserCommandExists (const char *cmd);
67
+
68
+ // / Return whether the passed in name or command path
69
+ // / exists and is an alias to some other command.
70
+ // /
71
+ // / \param[in] cmd
72
+ // / The command or command path to search for.
73
+ // /
74
+ // / \return
75
+ // / \b true if the command exists, \b false otherwise.
50
76
bool AliasExists (const char *cmd);
51
77
52
78
lldb::SBBroadcaster GetBroadcaster ();
Original file line number Diff line number Diff line change @@ -117,6 +117,13 @@ bool SBCommandInterpreter::CommandExists(const char *cmd) {
117
117
: false );
118
118
}
119
119
120
+ bool SBCommandInterpreter::UserCommandExists (const char *cmd) {
121
+ LLDB_INSTRUMENT_VA (this , cmd);
122
+
123
+ return (((cmd != nullptr ) && IsValid ()) ? m_opaque_ptr->UserCommandExists (cmd)
124
+ : false );
125
+ }
126
+
120
127
bool SBCommandInterpreter::AliasExists (const char *cmd) {
121
128
LLDB_INSTRUMENT_VA (this , cmd);
122
129
Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ def test(self):
19
19
def pycmd_tests (self ):
20
20
self .runCmd ("command source py_import" )
21
21
22
+ # Test that we did indeed add these commands as user commands:
23
+ interp = self .dbg .GetCommandInterpreter ()
24
+ self .expectTrue (interp .UserCommandExists ("foobar" ), "foobar exists" )
25
+ self .expectFalse (interp .CommandExists ("foobar" ), "It is not a builtin." )
26
+
22
27
# Test a bunch of different kinds of python callables with
23
28
# both 4 and 5 positional arguments.
24
29
self .expect ("foobar" , substrs = ["All good" ])
You can’t perform that action at this time.
0 commit comments