SBProcess.h revision c5f728c81b4896cfbbc87ed1daedf42ba2c0ee63
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    // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (lldb::pid_t pid, SBError& error)"
116    SBError
117    Attach (lldb::pid_t pid);
118
119    // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (const char *name, bool wait_for_launch, SBError& error)"
120    SBError
121    AttachByName (const char *name, bool wait_for_launch);
122
123    SBError
124    Continue ();
125
126    SBError
127    Stop ();
128
129    SBError
130    Kill ();
131
132    SBError
133    Detach ();
134
135    SBError
136    Signal (int signal);
137
138    size_t
139    ReadMemory (addr_t addr, void *buf, size_t size, SBError &error);
140
141    size_t
142    WriteMemory (addr_t addr, const void *buf, size_t size, SBError &error);
143
144    // Events
145    static lldb::StateType
146    GetStateFromEvent (const lldb::SBEvent &event);
147
148    static bool
149    GetRestartedFromEvent (const lldb::SBEvent &event);
150
151    static lldb::SBProcess
152    GetProcessFromEvent (const lldb::SBEvent &event);
153
154    lldb::SBBroadcaster
155    GetBroadcaster () const;
156
157    bool
158    GetDescription (lldb::SBStream &description);
159
160protected:
161    friend class SBAddress;
162    friend class SBBreakpoint;
163    friend class SBBreakpointLocation;
164    friend class SBCommandInterpreter;
165    friend class SBDebugger;
166    friend class SBFunction;
167    friend class SBTarget;
168    friend class SBThread;
169    friend class SBValue;
170
171#ifndef SWIG
172
173    lldb_private::Process *
174    operator->() const;
175
176    // Mimic shared pointer...
177    lldb_private::Process *
178    get() const;
179
180#endif
181
182
183    SBProcess (const lldb::ProcessSP &process_sp);
184
185    void
186    SetProcess (const lldb::ProcessSP &process_sp);
187
188    lldb::ProcessSP m_opaque_sp;
189};
190
191}  // namespace lldb
192
193#endif  // LLDB_SBProcess_h_
194