SBTarget.h revision c5f728c81b4896cfbbc87ed1daedf42ba2c0ee63
1//===-- SBTarget.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_SBTarget_h_
11#define LLDB_SBTarget_h_
12
13#include "lldb/API/SBDefines.h"
14#include "lldb/API/SBBroadcaster.h"
15#include "lldb/API/SBFileSpec.h"
16
17namespace lldb {
18
19class SBBreakpoint;
20
21class SBTarget
22{
23public:
24    //------------------------------------------------------------------
25    // Broadcaster bits.
26    //------------------------------------------------------------------
27    enum
28    {
29        eBroadcastBitBreakpointChanged  = (1 << 0),
30        eBroadcastBitModulesLoaded      = (1 << 1),
31        eBroadcastBitModulesUnloaded    = (1 << 2)
32    };
33
34    //------------------------------------------------------------------
35    // Constructors and Destructors
36    //------------------------------------------------------------------
37    SBTarget (const lldb::SBTarget& rhs);
38
39    SBTarget ();  // Required for SWIG.
40
41    //------------------------------------------------------------------
42    // Destructor
43    //------------------------------------------------------------------
44    ~SBTarget();
45
46    const lldb::SBTarget&
47    Assign (const lldb::SBTarget& rhs);
48
49    bool
50    IsValid() const;
51
52    lldb::SBProcess
53    CreateProcess (); // DEPRECATED
54
55    lldb::SBProcess
56    GetProcess ();
57
58    // DEPRECATED in favor of the function below that contains an SBError as the
59    // last parameter.
60    lldb::SBProcess
61    LaunchProcess (char const **argv,
62                   char const **envp,
63                   const char *tty,
64                   uint32_t launch_flags,   // See lldb::LaunchFlags
65                   bool stop_at_entry);
66
67    lldb::SBProcess
68    LaunchProcess (char const **argv,
69                   char const **envp,
70                   const char *tty,
71                   uint32_t launch_flags,   // See lldb::LaunchFlags
72                   bool stop_at_entry,
73                   SBError& error);
74
75    lldb::SBProcess
76    AttachToProcess (lldb::pid_t pid, // The process ID to attach to
77                     SBError& error); // An error explaining what went wrong if attach fails
78
79    lldb::SBProcess
80    AttachToProcess (const char *name,  // basename of process to attach to
81                     bool wait_for,     // if true wait for a new instance of "name" to be launched
82                     SBError& error);   // An error explaining what went wrong if attach fails
83
84    lldb::SBFileSpec
85    GetExecutable ();
86
87    uint32_t
88    GetNumModules () const;
89
90    lldb::SBModule
91    GetModuleAtIndex (uint32_t idx);
92
93    lldb::SBDebugger
94    GetDebugger() const;
95
96    lldb::SBModule
97    FindModule (const lldb::SBFileSpec &file_spec);
98
99    void
100    Clear ();
101
102    bool
103    DeleteTargetFromList (lldb_private::TargetList *list);
104
105    lldb::SBBreakpoint
106    BreakpointCreateByLocation (const char *file, uint32_t line);
107
108    lldb::SBBreakpoint
109    BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
110
111    lldb::SBBreakpoint
112    BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
113
114    lldb::SBBreakpoint
115    BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
116
117    lldb::SBBreakpoint
118    BreakpointCreateByAddress (addr_t address);
119
120    uint32_t
121    GetNumBreakpoints () const;
122
123    lldb::SBBreakpoint
124    GetBreakpointAtIndex (uint32_t idx) const;
125
126    bool
127    BreakpointDelete (break_id_t break_id);
128
129    lldb::SBBreakpoint
130    FindBreakpointByID (break_id_t break_id);
131
132    bool
133    EnableAllBreakpoints ();
134
135    bool
136    DisableAllBreakpoints ();
137
138    bool
139    DeleteAllBreakpoints ();
140
141    lldb::SBBroadcaster
142    GetBroadcaster () const;
143
144    //void
145    //Disassemble ();
146
147    void
148    Disassemble (lldb::addr_t start_address,
149                 lldb::addr_t end_address = LLDB_INVALID_ADDRESS,
150                 const char *module_name = NULL);
151
152    void
153    Disassemble (const char *function_name, const char *module_name = NULL);
154
155#ifndef SWIG
156    bool
157    operator == (const lldb::SBTarget &rhs) const;
158
159    bool
160    operator != (const lldb::SBTarget &rhs) const;
161
162#endif
163
164    bool
165    GetDescription (lldb::SBStream &description);
166
167protected:
168    friend class SBAddress;
169    friend class SBDebugger;
170    friend class SBFunction;
171    friend class SBProcess;
172    friend class SBSymbol;
173
174    //------------------------------------------------------------------
175    // Constructors are private, use static Target::Create function to
176    // create an instance of this class.
177    //------------------------------------------------------------------
178
179    SBTarget (const lldb::TargetSP& target_sp);
180
181    void
182    reset (const lldb::TargetSP& target_sp);
183
184    lldb_private::Target *
185    operator ->() const;
186
187    lldb_private::Target *
188    get() const;
189
190private:
191    //------------------------------------------------------------------
192    // For Target only
193    //------------------------------------------------------------------
194
195    lldb::TargetSP m_opaque_sp;
196};
197
198} // namespace lldb
199
200#endif  // LLDB_SBTarget_h_
201