SBDebugger.h revision 98f930f429160f9777f626c3ac6aa609f4e965d2
1//===-- SBDebugger.h --------------------------------------------*- 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#ifndef LLDB_SBDebugger_h_
11#define LLDB_SBDebugger_h_
12
13#include "lldb/API/SBDefines.h"
14#include <stdio.h>
15
16namespace lldb {
17
18class SBDebugger
19{
20public:
21
22    static void
23    Initialize();
24
25    static void
26    Terminate();
27
28    static SBDebugger
29    Create();
30
31    SBDebugger();
32
33    ~SBDebugger();
34
35    bool
36    IsValid() const;
37
38    void
39    Clear ();
40
41    void
42    SetAsync (bool b);
43
44    void
45    SetInputFileHandle (FILE *f, bool transfer_ownership);
46
47    void
48    SetOutputFileHandle (FILE *f, bool transfer_ownership);
49
50    void
51    SetErrorFileHandle (FILE *f, bool transfer_ownership);
52
53    FILE *
54    GetInputFileHandle ();
55
56    FILE *
57    GetOutputFileHandle ();
58
59    FILE *
60    GetErrorFileHandle ();
61
62    lldb::SBCommandInterpreter
63    GetCommandInterpreter ();
64
65    void
66    HandleCommand (const char *command);
67
68    lldb::SBListener
69    GetListener ();
70
71    void
72    HandleProcessEvent (const lldb::SBProcess &process,
73                        const lldb::SBEvent &event,
74                        FILE *out,
75                        FILE *err);
76
77    lldb::SBTarget
78    CreateTargetWithFileAndTargetTriple (const char *filename,
79                                         const char *target_triple);
80
81    lldb::SBTarget
82    CreateTargetWithFileAndArch (const char *filename,
83                                 const char *archname);
84
85    lldb::SBTarget
86    CreateTarget (const char *filename);
87
88    lldb::SBTarget
89    GetTargetAtIndex (uint32_t idx);
90
91    lldb::SBTarget
92    FindTargetWithProcessID (pid_t pid);
93
94    lldb::SBTarget
95    FindTargetWithFileAndArch (const char *filename,
96                               const char *arch);
97
98    uint32_t
99    GetNumTargets ();
100
101    lldb::SBTarget
102    GetSelectedTarget ();
103
104    void
105    UpdateSelectedThread (lldb::SBProcess &process);
106
107    lldb::SBSourceManager &
108    GetSourceManager ();
109
110    // FIXME: Once we get the set show stuff in place, the driver won't need
111    // an interface to the Set/Get UseExternalEditor.
112    bool
113    SetUseExternalEditor (bool input);
114
115    bool
116    UseExternalEditor ();
117
118    bool
119    GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
120
121    bool
122    SetDefaultArchitecture (const char *arch_name);
123
124    lldb::ScriptLanguage
125    GetScriptingLanguage (const char *script_language_name);
126
127    static const char *
128    GetVersionString ();
129
130    static const char *
131    StateAsCString (lldb::StateType state);
132
133    static bool
134    StateIsRunningState (lldb::StateType state);
135
136    static bool
137    StateIsStoppedState (lldb::StateType state);
138
139    void
140    DispatchInput (void *baton, const void *data, size_t data_len);
141
142    void
143    PushInputReader (lldb::SBInputReader &reader);
144
145    const char *
146    GetInstanceName  ();
147
148    static SBDebugger
149    FindDebuggerWithID (int id);
150
151    static lldb::SBError
152    SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name);
153
154    static lldb::SBStringList
155    GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
156
157    bool
158    GetDescription (lldb::SBStream &description);
159
160    // The following function gets called by Python when a user tries to print
161    // an object of this class.  It takes no arguments and returns a
162    // PyObject * representing a char * (and it must be named "__repr__");
163
164    PyObject *
165    __repr__ ();
166
167    uint32_t
168    GetTerminalWidth () const;
169
170    void
171    SetTerminalWidth (uint32_t term_width);
172
173    const char *
174    GetPrompt() const;
175
176    void
177    SetPrompt (const char *prompt);
178
179    lldb::ScriptLanguage
180    GetScriptLanguage() const;
181
182    void
183    SetScriptLanguage (lldb::ScriptLanguage script_lang);
184
185private:
186
187#ifndef SWIG
188
189    friend class SBInputReader;
190    friend class SBProcess;
191    friend class SBTarget;
192
193    lldb::SBTarget
194    FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP);
195
196    void
197    reset (const lldb::DebuggerSP &debugger_sp);
198
199    lldb_private::Debugger *
200    get () const;
201
202    lldb_private::Debugger &
203    ref () const;
204
205#endif
206
207    lldb::DebuggerSP m_opaque_sp;
208
209}; // class SBDebugger
210
211
212} // namespace lldb
213
214#endif // LLDB_SBDebugger_h_
215