blob: 0a795adb038fadbca9843914a52e3ac65495fbf4 [file] [log] [blame]
Johnny Chenfdc4a862011-07-19 22:41:47 +00001//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10namespace lldb {
11
Johnny Chenad4fe1b2011-07-20 22:50:58 +000012%feature("docstring",
Jim Ingham26c7bf92014-10-11 00:38:27 +000013"SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed.
14A default SBCommandInterpreterRunOptions object has:
15 StopOnContinue: false
16 StopOnError: false
17 StopOnCrash: false
18 EchoCommands: true
19 PrintResults: true
20 AddToHistory: true
21
22
23") SBCommandInterpreterRunOptions;
24class SBCommandInterpreterRunOptions
25{
26friend class SBDebugger;
27public:
28 SBCommandInterpreterRunOptions();
29 ~SBCommandInterpreterRunOptions();
30
31 bool
32 GetStopOnContinue () const;
33
34 void
35 SetStopOnContinue (bool);
36
37 bool
38 GetStopOnError () const;
39
40 void
41 SetStopOnError (bool);
42
43 bool
44 GetStopOnCrash () const;
45
46 void
47 SetStopOnCrash (bool);
48
49 bool
50 GetEchoCommands () const;
51
52 void
53 SetEchoCommands (bool);
54
55 bool
56 GetPrintResults () const;
57
58 void
59 SetPrintResults (bool);
60
61 bool
62 GetAddToHistory () const;
63
64 void
65 SetAddToHistory (bool);
66private:
67 lldb_private::CommandInterpreterRunOptions *
68 get () const;
69
70 lldb_private::CommandInterpreterRunOptions &
71 ref () const;
72
73 // This is set in the constructor and will always be valid.
74 mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> m_opaque_up;
75};
76
77%feature("docstring",
Johnny Chenad4fe1b2011-07-20 22:50:58 +000078"SBCommandInterpreter handles/interprets commands for lldb. You get the
79command interpreter from the SBDebugger instance. For example (from test/
80python_api/interpreter/TestCommandInterpreterAPI.py),
81
82 def command_interpreter_api(self):
83 '''Test the SBCommandInterpreter APIs.'''
84 exe = os.path.join(os.getcwd(), 'a.out')
85
86 # Create a target by the debugger.
87 target = self.dbg.CreateTarget(exe)
88 self.assertTrue(target, VALID_TARGET)
89
90 # Retrieve the associated command interpreter from our debugger.
91 ci = self.dbg.GetCommandInterpreter()
92 self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
93
94 # Exercise some APIs....
95
96 self.assertTrue(ci.HasCommands())
97 self.assertTrue(ci.HasAliases())
98 self.assertTrue(ci.HasAliasOptions())
99 self.assertTrue(ci.CommandExists('breakpoint'))
100 self.assertTrue(ci.CommandExists('target'))
101 self.assertTrue(ci.CommandExists('platform'))
102 self.assertTrue(ci.AliasExists('file'))
103 self.assertTrue(ci.AliasExists('run'))
104 self.assertTrue(ci.AliasExists('bt'))
105
106 res = lldb.SBCommandReturnObject()
107 ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res)
108 self.assertTrue(res.Succeeded())
109 ci.HandleCommand('process launch', res)
110 self.assertTrue(res.Succeeded())
111
112 process = ci.GetProcess()
113 self.assertTrue(process)
114
115 ...
116
117The HandleCommand() instance method takes two args: the command string and
118an SBCommandReturnObject instance which encapsulates the result of command
119execution.
120") SBCommandInterpreter;
Johnny Chenfdc4a862011-07-19 22:41:47 +0000121class SBCommandInterpreter
122{
123public:
124 enum
125 {
126 eBroadcastBitThreadShouldExit = (1 << 0),
127 eBroadcastBitResetPrompt = (1 << 1),
128 eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
129 eBroadcastBitAsynchronousOutputData = (1 << 3),
130 eBroadcastBitAsynchronousErrorData = (1 << 4)
131 };
132
133 SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
134
135 ~SBCommandInterpreter ();
136
137 static const char *
138 GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
139
140 static const char *
141 GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
142
143 bool
144 IsValid() const;
145
Greg Clayton44d93782014-01-27 23:43:24 +0000146 const char *
147 GetIOHandlerControlSequence(char ch);
148
Johnny Chenfdc4a862011-07-19 22:41:47 +0000149 bool
150 CommandExists (const char *cmd);
151
152 bool
153 AliasExists (const char *cmd);
154
155 lldb::SBBroadcaster
156 GetBroadcaster ();
157
Jim Ingham4bddaeb2012-02-16 06:50:00 +0000158 static const char *
159 GetBroadcasterClass ();
160
Johnny Chenfdc4a862011-07-19 22:41:47 +0000161 bool
162 HasCommands ();
163
164 bool
165 HasAliases ();
166
167 bool
168 HasAliasOptions ();
169
170 lldb::SBProcess
171 GetProcess ();
Enrico Granata21dfcd92012-09-28 23:57:51 +0000172
173 lldb::SBDebugger
174 GetDebugger ();
Johnny Chenfdc4a862011-07-19 22:41:47 +0000175
Johnny Chenfdc4a862011-07-19 22:41:47 +0000176 void
177 SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
178
179 void
180 SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
181
182 lldb::ReturnStatus
183 HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
184
Jim Inghamffc9f1d2014-10-14 01:20:07 +0000185 lldb::ReturnStatus
186 HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false);
187
188 void
189 HandleCommandsFromFile (lldb::SBFileSpec &file,
190 lldb::SBExecutionContext &override_context,
191 lldb::SBCommandInterpreterRunOptions &options,
192 lldb::SBCommandReturnObject result);
193
Johnny Chenfdc4a862011-07-19 22:41:47 +0000194 int
195 HandleCompletion (const char *current_line,
Jim Ingham969795f2011-09-21 01:17:13 +0000196 uint32_t cursor_pos,
Johnny Chenfdc4a862011-07-19 22:41:47 +0000197 int match_start_point,
198 int max_return_elements,
199 lldb::SBStringList &matches);
Greg Clayton44d93782014-01-27 23:43:24 +0000200
201 bool
202 IsActive ();
203
Johnny Chenfdc4a862011-07-19 22:41:47 +0000204};
205
206} // namespace lldb