1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
//===-- ProcessLaunchInfo.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_ProcessLaunch_Info_h
#define liblldb_ProcessLaunch_Info_h
// C++ Headers
#include <string>
// LLDB Headers
#include "lldb/Core/Flags.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/ProcessInfo.h"
#include "lldb/Utility/PseudoTerminal.h"
namespace lldb_private
{
//----------------------------------------------------------------------
// ProcessLaunchInfo
//
// Describes any information that is required to launch a process.
//----------------------------------------------------------------------
class ProcessLaunchInfo : public ProcessInfo
{
public:
ProcessLaunchInfo ();
ProcessLaunchInfo(const FileSpec &stdin_file_spec,
const FileSpec &stdout_file_spec,
const FileSpec &stderr_file_spec,
const FileSpec &working_dir,
uint32_t launch_flags);
void
AppendFileAction (const FileAction &info)
{
m_file_actions.push_back(info);
}
bool
AppendCloseFileAction (int fd);
bool
AppendDuplicateFileAction (int fd, int dup_fd);
bool
AppendOpenFileAction(int fd, const FileSpec &file_spec,
bool read, bool write);
bool
AppendSuppressFileAction (int fd, bool read, bool write);
void
FinalizeFileActions (Target *target,
bool default_to_use_pty);
size_t
GetNumFileActions () const
{
return m_file_actions.size();
}
const FileAction *
GetFileActionAtIndex (size_t idx) const;
const FileAction *
GetFileActionForFD (int fd) const;
Flags &
GetFlags ()
{
return m_flags;
}
const Flags &
GetFlags () const
{
return m_flags;
}
const FileSpec &
GetWorkingDirectory() const;
void
SetWorkingDirectory(const FileSpec &working_dir);
const char *
GetProcessPluginName () const;
void
SetProcessPluginName (const char *plugin);
const FileSpec &
GetShell () const;
void
SetShell (const FileSpec &shell);
uint32_t
GetResumeCount () const
{
return m_resume_count;
}
void
SetResumeCount (uint32_t c)
{
m_resume_count = c;
}
bool
GetLaunchInSeparateProcessGroup() const
{
return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
}
void
SetLaunchInSeparateProcessGroup (bool separate);
bool
GetShellExpandArguments () const
{
return m_flags.Test(lldb::eLaunchFlagShellExpandArguments);
}
void
SetShellExpandArguments (bool expand);
void
Clear ();
bool
ConvertArgumentsForLaunchingInShell (Error &error,
bool localhost,
bool will_debug,
bool first_arg_is_full_shell_command,
int32_t num_resumes);
void
SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback, bool monitor_signals);
Host::MonitorChildProcessCallback
GetMonitorProcessCallback() const
{
return m_monitor_callback;
}
bool
GetMonitorSignals() const
{
return m_monitor_signals;
}
// If the LaunchInfo has a monitor callback, then arrange to monitor the process.
// Return true if the LaunchInfo has taken care of monitoring the process, and false if the
// caller might want to monitor the process themselves.
bool
MonitorProcess () const;
lldb_utility::PseudoTerminal &
GetPTY ()
{
return *m_pty;
}
// Get and set the actual listener that will be used for the process events
lldb::ListenerSP
GetListener () const
{
return m_listener_sp;
}
void
SetListener (const lldb::ListenerSP &listener_sp)
{
m_listener_sp = listener_sp;
}
lldb::ListenerSP
GetListenerForProcess (Debugger &debugger);
lldb::ListenerSP
GetHijackListener () const
{
return m_hijack_listener_sp;
}
void
SetHijackListener (const lldb::ListenerSP &listener_sp)
{
m_hijack_listener_sp = listener_sp;
}
void
SetLaunchEventData (const char *data)
{
m_event_data.assign (data);
}
const char *
GetLaunchEventData () const
{
return m_event_data.c_str();
}
void
SetDetachOnError (bool enable);
bool
GetDetachOnError () const
{
return m_flags.Test(lldb::eLaunchFlagDetachOnError);
}
protected:
FileSpec m_working_dir;
std::string m_plugin_name;
FileSpec m_shell;
Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags
std::vector<FileAction> m_file_actions; // File actions for any other files
std::shared_ptr<lldb_utility::PseudoTerminal> m_pty;
uint32_t m_resume_count; // How many times do we resume after launching
Host::MonitorChildProcessCallback m_monitor_callback;
void *m_monitor_callback_baton;
bool m_monitor_signals;
std::string m_event_data; // A string passed to the plugin launch, having no meaning to the upper levels of lldb.
lldb::ListenerSP m_listener_sp;
lldb::ListenerSP m_hijack_listener_sp;
};
}
#endif // liblldb_ProcessLaunch_Info_h
|