SBProcess.h revision e49ec18f1868168c8927ae30a379db176ca8cce3
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    ~SBProcess();
41
42    void
43    Clear ();
44
45    bool
46    IsValid() const;
47
48    lldb::SBTarget
49    GetTarget() const;
50
51    size_t
52    PutSTDIN (const char *src, size_t src_len);
53
54    size_t
55    GetSTDOUT (char *dst, size_t dst_len) const;
56
57    size_t
58    GetSTDERR (char *dst, size_t dst_len) const;
59
60    void
61    ReportEventState (const lldb::SBEvent &event, FILE *out) const;
62
63    void
64    AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
65
66    //------------------------------------------------------------------
67    // Thread related functions
68    //------------------------------------------------------------------
69    uint32_t
70    GetNumThreads ();
71
72    lldb::SBThread
73    GetThreadAtIndex (size_t index);
74
75    lldb::SBThread
76    GetThreadByID (lldb::tid_t sb_thread_id);
77
78    lldb::SBThread
79    GetSelectedThread () const;
80
81    bool
82    SetSelectedThread (const lldb::SBThread &thread);
83
84    bool
85    SetSelectedThreadByID (uint32_t tid);
86
87    //------------------------------------------------------------------
88    // Stepping related functions
89    //------------------------------------------------------------------
90
91    lldb::StateType
92    GetState ();
93
94    int
95    GetExitStatus ();
96
97    const char *
98    GetExitDescription ();
99
100    lldb::pid_t
101    GetProcessID ();
102
103    uint32_t
104    GetAddressByteSize() const;
105
106    SBError
107    Destroy ();
108
109    bool
110    WaitUntilProcessHasStopped (lldb::SBCommandReturnObject &result);
111
112    lldb::pid_t
113    AttachByPID (lldb::pid_t pid);  // DEPRECATED: will be removed in a few builds in favor of SBError AttachByPID(pid_t)
114
115    SBError
116    Attach (lldb::pid_t pid);
117
118    SBError
119    AttachByName (const char *name, bool wait_for_launch);
120
121    SBError
122    Continue ();
123
124    SBError
125    Stop ();
126
127    SBError
128    Kill ();
129
130    SBError
131    Detach ();
132
133    SBError
134    Signal (int signal);
135
136    size_t
137    ReadMemory (addr_t addr, void *buf, size_t size, SBError &error);
138
139    size_t
140    WriteMemory (addr_t addr, const void *buf, size_t size, SBError &error);
141
142    // Events
143    static lldb::StateType
144    GetStateFromEvent (const lldb::SBEvent &event);
145
146    static bool
147    GetRestartedFromEvent (const lldb::SBEvent &event);
148
149    static lldb::SBProcess
150    GetProcessFromEvent (const lldb::SBEvent &event);
151
152    lldb::SBBroadcaster
153    GetBroadcaster () const;
154
155    bool
156    GetDescription (lldb::SBStream &description);
157
158protected:
159    friend class SBAddress;
160    friend class SBBreakpoint;
161    friend class SBBreakpointLocation;
162    friend class SBCommandInterpreter;
163    friend class SBDebugger;
164    friend class SBTarget;
165    friend class SBThread;
166    friend class SBValue;
167
168#ifndef SWIG
169
170    lldb_private::Process *
171    operator->() const;
172
173    // Mimic shared pointer...
174    lldb_private::Process *
175    get() const;
176
177#endif
178
179
180    SBProcess (const lldb::ProcessSP &process_sp);
181
182    void
183    SetProcess (const lldb::ProcessSP &process_sp);
184
185    lldb::ProcessSP m_opaque_sp;
186};
187
188}  // namespace lldb
189
190#endif  // LLDB_SBProcess_h_
191