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