1 //===-- ProcessLaunchInfo.h -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ProcessLaunch_Info_h
11 #define liblldb_ProcessLaunch_Info_h
17 #include "lldb/Core/Flags.h"
18 #include "lldb/Host/FileSpec.h"
19 #include "lldb/Host/Host.h"
20 #include "lldb/Target/FileAction.h"
21 #include "lldb/Target/ProcessInfo.h"
22 #include "lldb/Utility/PseudoTerminal.h"
24 namespace lldb_private
27 //----------------------------------------------------------------------
30 // Describes any information that is required to launch a process.
31 //----------------------------------------------------------------------
33 class ProcessLaunchInfo : public ProcessInfo
39 ProcessLaunchInfo(const FileSpec &stdin_file_spec,
40 const FileSpec &stdout_file_spec,
41 const FileSpec &stderr_file_spec,
42 const FileSpec &working_dir,
43 uint32_t launch_flags);
46 AppendFileAction (const FileAction &info)
48 m_file_actions.push_back(info);
52 AppendCloseFileAction (int fd);
55 AppendDuplicateFileAction (int fd, int dup_fd);
58 AppendOpenFileAction(int fd, const FileSpec &file_spec,
59 bool read, bool write);
62 AppendSuppressFileAction (int fd, bool read, bool write);
65 FinalizeFileActions (Target *target,
66 bool default_to_use_pty);
69 GetNumFileActions () const
71 return m_file_actions.size();
75 GetFileActionAtIndex (size_t idx) const;
78 GetFileActionForFD (int fd) const;
93 GetWorkingDirectory() const;
96 SetWorkingDirectory(const FileSpec &working_dir);
99 GetProcessPluginName () const;
102 SetProcessPluginName (const char *plugin);
108 SetShell (const FileSpec &shell);
111 GetResumeCount () const
113 return m_resume_count;
117 SetResumeCount (uint32_t c)
123 GetLaunchInSeparateProcessGroup() const
125 return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
129 SetLaunchInSeparateProcessGroup (bool separate);
132 GetShellExpandArguments () const
134 return m_flags.Test(lldb::eLaunchFlagShellExpandArguments);
138 SetShellExpandArguments (bool expand);
144 ConvertArgumentsForLaunchingInShell (Error &error,
147 bool first_arg_is_full_shell_command,
148 int32_t num_resumes);
151 SetMonitorProcessCallback (Host::MonitorChildProcessCallback callback,
153 bool monitor_signals);
155 Host::MonitorChildProcessCallback
156 GetMonitorProcessCallback() const
158 return m_monitor_callback;
162 GetMonitorProcessBaton() const
164 return m_monitor_callback_baton;
168 GetMonitorSignals() const
170 return m_monitor_signals;
173 // If the LaunchInfo has a monitor callback, then arrange to monitor the process.
174 // Return true if the LaunchInfo has taken care of monitoring the process, and false if the
175 // caller might want to monitor the process themselves.
178 MonitorProcess () const;
180 lldb_utility::PseudoTerminal &
186 // Get and set the actual listener that will be used for the process events
190 return m_listener_sp;
194 SetListener (const lldb::ListenerSP &listener_sp)
196 m_listener_sp = listener_sp;
200 GetListenerForProcess (Debugger &debugger);
203 GetHijackListener () const
205 return m_hijack_listener_sp;
209 SetHijackListener (const lldb::ListenerSP &listener_sp)
211 m_hijack_listener_sp = listener_sp;
215 SetLaunchEventData (const char *data)
217 m_event_data.assign (data);
221 GetLaunchEventData () const
223 return m_event_data.c_str();
227 SetDetachOnError (bool enable);
230 GetDetachOnError () const
232 return m_flags.Test(lldb::eLaunchFlagDetachOnError);
236 FileSpec m_working_dir;
237 std::string m_plugin_name;
239 Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags
240 std::vector<FileAction> m_file_actions; // File actions for any other files
241 std::shared_ptr<lldb_utility::PseudoTerminal> m_pty;
242 uint32_t m_resume_count; // How many times do we resume after launching
243 Host::MonitorChildProcessCallback m_monitor_callback;
244 void *m_monitor_callback_baton;
245 bool m_monitor_signals;
246 std::string m_event_data; // A string passed to the plugin launch, having no meaning to the upper levels of lldb.
247 lldb::ListenerSP m_listener_sp;
248 lldb::ListenerSP m_hijack_listener_sp;
252 #endif // liblldb_ProcessLaunch_Info_h