]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/bindings/interface/SBCommandInterpreter.i
MFV r361322:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / bindings / interface / SBCommandInterpreter.i
1 //===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 namespace lldb {
10
11 %feature("docstring",
12 "SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed.
13 A default SBCommandInterpreterRunOptions object has:
14     StopOnContinue: false
15     StopOnError:    false
16     StopOnCrash:    false
17     EchoCommands:   true
18     PrintResults:   true
19     AddToHistory:   true
20
21 ") SBCommandInterpreterRunOptions;
22 class SBCommandInterpreterRunOptions
23 {
24 friend class SBDebugger;
25 public:
26     SBCommandInterpreterRunOptions();
27     ~SBCommandInterpreterRunOptions();
28
29     bool
30     GetStopOnContinue () const;
31
32     void
33     SetStopOnContinue (bool);
34
35     bool
36     GetStopOnError () const;
37
38     void
39     SetStopOnError (bool);
40
41     bool
42     GetStopOnCrash () const;
43
44     void
45     SetStopOnCrash (bool);
46
47     bool
48     GetEchoCommands () const;
49
50     void
51     SetEchoCommands (bool);
52
53     bool
54     GetPrintResults () const;
55
56     void
57     SetPrintResults (bool);
58
59     bool
60     GetAddToHistory () const;
61
62     void
63     SetAddToHistory (bool);
64 private:
65     lldb_private::CommandInterpreterRunOptions *
66     get () const;
67
68     lldb_private::CommandInterpreterRunOptions &
69     ref () const;
70
71     // This is set in the constructor and will always be valid.
72     mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> m_opaque_up;
73 };
74
75 %feature("docstring",
76 "SBCommandInterpreter handles/interprets commands for lldb.  You get the
77 command interpreter from the SBDebugger instance. For example (from test/
78 python_api/interpreter/TestCommandInterpreterAPI.py),
79
80     def command_interpreter_api(self):
81         '''Test the SBCommandInterpreter APIs.'''
82         exe = os.path.join(os.getcwd(), 'a.out')
83
84         # Create a target by the debugger.
85         target = self.dbg.CreateTarget(exe)
86         self.assertTrue(target, VALID_TARGET)
87
88         # Retrieve the associated command interpreter from our debugger.
89         ci = self.dbg.GetCommandInterpreter()
90         self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
91
92         # Exercise some APIs....
93
94         self.assertTrue(ci.HasCommands())
95         self.assertTrue(ci.HasAliases())
96         self.assertTrue(ci.HasAliasOptions())
97         self.assertTrue(ci.CommandExists('breakpoint'))
98         self.assertTrue(ci.CommandExists('target'))
99         self.assertTrue(ci.CommandExists('platform'))
100         self.assertTrue(ci.AliasExists('file'))
101         self.assertTrue(ci.AliasExists('run'))
102         self.assertTrue(ci.AliasExists('bt'))
103
104         res = lldb.SBCommandReturnObject()
105         ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res)
106         self.assertTrue(res.Succeeded())
107         ci.HandleCommand('process launch', res)
108         self.assertTrue(res.Succeeded())
109
110         process = ci.GetProcess()
111         self.assertTrue(process)
112
113         ...
114
115 The HandleCommand() instance method takes two args: the command string and
116 an SBCommandReturnObject instance which encapsulates the result of command
117 execution.") SBCommandInterpreter;
118 class SBCommandInterpreter
119 {
120 public:
121     enum
122     {
123         eBroadcastBitThreadShouldExit       = (1 << 0),
124         eBroadcastBitResetPrompt            = (1 << 1),
125         eBroadcastBitQuitCommandReceived    = (1 << 2),           // User entered quit
126         eBroadcastBitAsynchronousOutputData = (1 << 3),
127         eBroadcastBitAsynchronousErrorData  = (1 << 4)
128     };
129
130     SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
131
132     ~SBCommandInterpreter ();
133
134     static const char *
135     GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
136
137     static const char *
138     GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
139
140     static bool
141     EventIsCommandInterpreterEvent (const lldb::SBEvent &event);
142
143     bool
144     IsValid() const;
145
146     explicit operator bool() const;
147
148     const char *
149     GetIOHandlerControlSequence(char ch);
150
151     bool
152     GetPromptOnQuit();
153
154     void
155     SetPromptOnQuit(bool b);
156
157     void
158     AllowExitCodeOnQuit(bool b);
159
160     bool
161     HasCustomQuitExitCode();
162
163     int
164     GetQuitStatus();
165
166     void
167     ResolveCommand(const char *command_line, SBCommandReturnObject &result);
168
169     bool
170     CommandExists (const char *cmd);
171
172     bool
173     AliasExists (const char *cmd);
174
175     lldb::SBBroadcaster
176     GetBroadcaster ();
177
178     static const char *
179     GetBroadcasterClass ();
180
181     bool
182     HasCommands ();
183
184     bool
185     HasAliases ();
186
187     bool
188     HasAliasOptions ();
189
190     lldb::SBProcess
191     GetProcess ();
192
193     lldb::SBDebugger
194     GetDebugger ();
195
196     void
197     SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
198
199     void
200     SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
201
202     lldb::ReturnStatus
203     HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
204
205     lldb::ReturnStatus
206     HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false);
207
208     void
209     HandleCommandsFromFile (lldb::SBFileSpec &file,
210                             lldb::SBExecutionContext &override_context,
211                             lldb::SBCommandInterpreterRunOptions &options,
212                             lldb::SBCommandReturnObject result);
213
214     int
215     HandleCompletion (const char *current_line,
216                       uint32_t cursor_pos,
217                       int match_start_point,
218                       int max_return_elements,
219                       lldb::SBStringList &matches);
220
221     int
222     HandleCompletionWithDescriptions (const char *current_line,
223                                       uint32_t cursor_pos,
224                                       int match_start_point,
225                                       int max_return_elements,
226                                       lldb::SBStringList &matches,
227                                       lldb::SBStringList &descriptions);
228     bool
229     IsActive ();
230
231     bool
232     WasInterrupted () const;
233 };
234
235 } // namespace lldb