SBTarget.h revision a66ba46379fe41036d870975c56ccc2319cb6618
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    bool
47    IsValid() const;
48
49    lldb::SBProcess
50    CreateProcess (); // DEPRECATED
51
52    lldb::SBProcess
53    GetProcess ();
54
55    // DEPRECATED in favor of the function below that contains an SBError as the
56    // last parameter.
57    lldb::SBProcess
58    LaunchProcess (char const **argv,
59                   char const **envp,
60                   const char *tty,
61                   uint32_t launch_flags,   // See LaunchFlags
62                   bool stop_at_entry);
63
64    lldb::SBProcess
65    Launch (char const **argv,
66            char const **envp,
67            const char *tty,
68            uint32_t launch_flags,   // See LaunchFlags
69            bool stop_at_entry,
70            lldb::SBError& error);
71
72    lldb::SBProcess
73    AttachToProcessWithID (lldb::pid_t pid, // The process ID to attach to
74                           lldb::SBError& error); // An error explaining what went wrong if attach fails
75
76    lldb::SBProcess
77    AttachToProcessWithName (const char *name,  // basename of process to attach to
78                             bool wait_for,     // if true wait for a new instance of "name" to be launched
79                             lldb::SBError& error);   // An error explaining what went wrong if attach fails
80
81    lldb::SBFileSpec
82    GetExecutable ();
83
84    uint32_t
85    GetNumModules () const;
86
87    lldb::SBModule
88    GetModuleAtIndex (uint32_t idx);
89
90    lldb::SBDebugger
91    GetDebugger() const;
92
93    lldb::SBModule
94    FindModule (const lldb::SBFileSpec &file_spec);
95
96    void
97    Clear ();
98
99    bool
100    DeleteTargetFromList (lldb_private::TargetList *list);
101
102    lldb::SBBreakpoint
103    BreakpointCreateByLocation (const char *file, uint32_t line);
104
105    lldb::SBBreakpoint
106    BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
107
108    lldb::SBBreakpoint
109    BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
110
111    lldb::SBBreakpoint
112    BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
113
114    lldb::SBBreakpoint
115    BreakpointCreateByAddress (addr_t address);
116
117    uint32_t
118    GetNumBreakpoints () const;
119
120    lldb::SBBreakpoint
121    GetBreakpointAtIndex (uint32_t idx) const;
122
123    bool
124    BreakpointDelete (break_id_t break_id);
125
126    lldb::SBBreakpoint
127    FindBreakpointByID (break_id_t break_id);
128
129    bool
130    EnableAllBreakpoints ();
131
132    bool
133    DisableAllBreakpoints ();
134
135    bool
136    DeleteAllBreakpoints ();
137
138    lldb::SBBroadcaster
139    GetBroadcaster () const;
140
141    //void
142    //Disassemble ();
143
144    void
145    Disassemble (lldb::addr_t start_address,
146                 lldb::addr_t end_address = LLDB_INVALID_ADDRESS,
147                 const char *module_name = NULL);
148
149    void
150    Disassemble (const char *function_name, const char *module_name = NULL);
151
152#ifndef SWIG
153    bool
154    operator == (const lldb::SBTarget &rhs) const;
155
156    bool
157    operator != (const lldb::SBTarget &rhs) const;
158
159#endif
160
161    bool
162    GetDescription (lldb::SBStream &description, lldb::DescriptionLevel);
163
164    bool
165    GetDescription (lldb::SBStream &description, lldb::DescriptionLevel) const;
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