]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - scripts/interface/SBCommandInterpreter.i
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / scripts / interface / SBCommandInterpreter.i
1 //===-- 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
10 namespace lldb {
11
12 %feature("docstring",
13 "SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed.
14 A 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;
24 class SBCommandInterpreterRunOptions
25 {
26 friend class SBDebugger;
27 public:
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);
66 private:
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",
78 "SBCommandInterpreter handles/interprets commands for lldb.  You get the
79 command interpreter from the SBDebugger instance. For example (from test/
80 python_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
117 The HandleCommand() instance method takes two args: the command string and
118 an SBCommandReturnObject instance which encapsulates the result of command
119 execution.
120 ") SBCommandInterpreter;
121 class SBCommandInterpreter
122 {
123 public:
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     static bool
144     EventIsCommandInterpreterEvent (const lldb::SBEvent &event);
145
146     bool
147     IsValid() const;
148
149     const char *
150     GetIOHandlerControlSequence(char ch);
151
152     bool
153     GetPromptOnQuit();
154
155     void
156     SetPromptOnQuit(bool b);
157
158     void
159     ResolveCommand(const char *command_line, SBCommandReturnObject &result);
160
161     bool
162     CommandExists (const char *cmd);
163
164     bool
165     AliasExists (const char *cmd);
166
167     lldb::SBBroadcaster
168     GetBroadcaster ();
169
170     static const char *
171     GetBroadcasterClass ();
172
173     bool
174     HasCommands ();
175
176     bool
177     HasAliases ();
178
179     bool
180     HasAliasOptions ();
181
182     lldb::SBProcess
183     GetProcess ();
184     
185     lldb::SBDebugger
186     GetDebugger ();
187
188     void
189     SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
190
191     void
192     SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
193
194     lldb::ReturnStatus
195     HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
196
197     lldb::ReturnStatus
198     HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false);
199
200     void
201     HandleCommandsFromFile (lldb::SBFileSpec &file,
202                             lldb::SBExecutionContext &override_context,
203                             lldb::SBCommandInterpreterRunOptions &options,
204                             lldb::SBCommandReturnObject result);
205
206     int
207     HandleCompletion (const char *current_line,
208                       uint32_t cursor_pos,
209                       int match_start_point,
210                       int max_return_elements,
211                       lldb::SBStringList &matches);
212     
213     bool
214     IsActive ();
215
216 };
217
218 } // namespace lldb