SBProcess.h revision 191343e7213d3d717327319352d086f981fa8e58
1//===-- SBProcess.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_SBProcess_h_
11#define LLDB_SBProcess_h_
12
13#include "lldb/API/SBDefines.h"
14#include "lldb/API/SBError.h"
15#include "lldb/API/SBTarget.h"
16#include <stdio.h>
17
18namespace lldb {
19
20class SBEvent;
21
22class SBProcess
23{
24public:
25    //------------------------------------------------------------------
26    /// Broadcaster event bits definitions.
27    //------------------------------------------------------------------
28    enum
29    {
30        eBroadcastBitStateChanged   = (1 << 0),
31        eBroadcastBitInterrupt      = (1 << 1),
32        eBroadcastBitSTDOUT         = (1 << 2),
33        eBroadcastBitSTDERR         = (1 << 3)
34    };
35
36    SBProcess ();
37
38    SBProcess (const lldb::SBProcess& rhs);
39
40    const lldb::SBProcess&
41    operator = (const lldb::SBProcess& rhs);
42
43    ~SBProcess();
44
45    static const char *
46    GetBroadcasterClassName ();
47
48    void
49    Clear ();
50
51    bool
52    IsValid() const;
53
54    lldb::SBTarget
55    GetTarget() const;
56
57    lldb::ByteOrder
58    GetByteOrder() const;
59
60    size_t
61    PutSTDIN (const char *src, size_t src_len);
62
63    size_t
64    GetSTDOUT (char *dst, size_t dst_len) const;
65
66    size_t
67    GetSTDERR (char *dst, size_t dst_len) const;
68
69    void
70    ReportEventState (const lldb::SBEvent &event, FILE *out) const;
71
72    void
73    AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
74
75    //------------------------------------------------------------------
76    /// Remote connection related functions. These will fail if the
77    /// process is not in eStateConnected. They are intended for use
78    /// when connecting to an externally managed debugserver instance.
79    //------------------------------------------------------------------
80    bool
81    RemoteAttachToProcessWithID (lldb::pid_t pid,
82                                 lldb::SBError& error);
83
84    bool
85    RemoteLaunch (char const **argv,
86                  char const **envp,
87                  const char *stdin_path,
88                  const char *stdout_path,
89                  const char *stderr_path,
90                  const char *working_directory,
91                  uint32_t launch_flags,
92                  bool stop_at_entry,
93                  lldb::SBError& error);
94
95    //------------------------------------------------------------------
96    // Thread related functions
97    //------------------------------------------------------------------
98    uint32_t
99    GetNumThreads ();
100
101    lldb::SBThread
102    GetThreadAtIndex (size_t index);
103
104    lldb::SBThread
105    GetThreadByID (lldb::tid_t sb_thread_id);
106
107    lldb::SBThread
108    GetSelectedThread () const;
109
110    bool
111    SetSelectedThread (const lldb::SBThread &thread);
112
113    bool
114    SetSelectedThreadByID (uint32_t tid);
115
116    //------------------------------------------------------------------
117    // Stepping related functions
118    //------------------------------------------------------------------
119
120    lldb::StateType
121    GetState ();
122
123    int
124    GetExitStatus ();
125
126    const char *
127    GetExitDescription ();
128
129    lldb::pid_t
130    GetProcessID ();
131
132    uint32_t
133    GetAddressByteSize() const;
134
135    lldb::SBError
136    Destroy ();
137
138    lldb::SBError
139    Continue ();
140
141    lldb::SBError
142    Stop ();
143
144    lldb::SBError
145    Kill ();
146
147    lldb::SBError
148    Detach ();
149
150    lldb::SBError
151    Signal (int signal);
152
153    size_t
154    ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
155
156    size_t
157    WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
158
159    size_t
160    ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
161
162    uint64_t
163    ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);
164
165    lldb::addr_t
166    ReadPointerFromMemory (addr_t addr, lldb::SBError &error);
167
168    // Events
169    static lldb::StateType
170    GetStateFromEvent (const lldb::SBEvent &event);
171
172    static bool
173    GetRestartedFromEvent (const lldb::SBEvent &event);
174
175    static lldb::SBProcess
176    GetProcessFromEvent (const lldb::SBEvent &event);
177
178    static bool
179    EventIsProcessEvent (const lldb::SBEvent &event);
180
181    lldb::SBBroadcaster
182    GetBroadcaster () const;
183
184    static const char *
185    GetBroadcasterClass ();
186
187    bool
188    GetDescription (lldb::SBStream &description);
189
190    uint32_t
191    GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
192
193    uint32_t
194    LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
195
196    lldb::SBError
197    UnloadImage (uint32_t image_token);
198
199protected:
200    friend class SBAddress;
201    friend class SBBreakpoint;
202    friend class SBBreakpointLocation;
203    friend class SBCommandInterpreter;
204    friend class SBDebugger;
205    friend class SBFunction;
206    friend class SBModule;
207    friend class SBTarget;
208    friend class SBThread;
209    friend class SBValue;
210
211    SBProcess (const lldb::ProcessSP &process_sp);
212
213    lldb::ProcessSP
214    GetSP() const;
215
216    void
217    SetSP (const lldb::ProcessSP &process_sp);
218
219    lldb::ProcessSP m_opaque_sp;
220};
221
222}  // namespace lldb
223
224#endif  // LLDB_SBProcess_h_
225