]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/ProcessLaunchInfo.h
MFV 331710:
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / ProcessLaunchInfo.h
1 //===-- ProcessLaunchInfo.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 liblldb_ProcessLaunch_Info_h
11 #define liblldb_ProcessLaunch_Info_h
12
13 // C++ Headers
14 #include <string>
15
16 // LLDB Headers
17 #include "lldb/Utility/Flags.h"
18
19 #include "lldb/Host/Host.h"
20 #include "lldb/Host/PseudoTerminal.h"
21 #include "lldb/Target/FileAction.h"
22 #include "lldb/Target/ProcessInfo.h"
23 #include "lldb/Utility/FileSpec.h"
24
25 namespace lldb_private {
26
27 //----------------------------------------------------------------------
28 // ProcessLaunchInfo
29 //
30 // Describes any information that is required to launch a process.
31 //----------------------------------------------------------------------
32
33 class ProcessLaunchInfo : public ProcessInfo {
34 public:
35   ProcessLaunchInfo();
36
37   ProcessLaunchInfo(const FileSpec &stdin_file_spec,
38                     const FileSpec &stdout_file_spec,
39                     const FileSpec &stderr_file_spec,
40                     const FileSpec &working_dir, uint32_t launch_flags);
41
42   void AppendFileAction(const FileAction &info) {
43     m_file_actions.push_back(info);
44   }
45
46   bool AppendCloseFileAction(int fd);
47
48   bool AppendDuplicateFileAction(int fd, int dup_fd);
49
50   bool AppendOpenFileAction(int fd, const FileSpec &file_spec, bool read,
51                             bool write);
52
53   bool AppendSuppressFileAction(int fd, bool read, bool write);
54
55   void FinalizeFileActions(Target *target, bool default_to_use_pty);
56
57   size_t GetNumFileActions() const { return m_file_actions.size(); }
58
59   const FileAction *GetFileActionAtIndex(size_t idx) const;
60
61   const FileAction *GetFileActionForFD(int fd) const;
62
63   Flags &GetFlags() { return m_flags; }
64
65   const Flags &GetFlags() const { return m_flags; }
66
67   const FileSpec &GetWorkingDirectory() const;
68
69   void SetWorkingDirectory(const FileSpec &working_dir);
70
71   const char *GetProcessPluginName() const;
72
73   void SetProcessPluginName(llvm::StringRef plugin);
74
75   const FileSpec &GetShell() const;
76
77   void SetShell(const FileSpec &shell);
78
79   uint32_t GetResumeCount() const { return m_resume_count; }
80
81   void SetResumeCount(uint32_t c) { m_resume_count = c; }
82
83   bool GetLaunchInSeparateProcessGroup() const {
84     return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
85   }
86
87   void SetLaunchInSeparateProcessGroup(bool separate);
88
89   bool GetShellExpandArguments() const {
90     return m_flags.Test(lldb::eLaunchFlagShellExpandArguments);
91   }
92
93   void SetShellExpandArguments(bool expand);
94
95   void Clear();
96
97   bool ConvertArgumentsForLaunchingInShell(Status &error, bool localhost,
98                                            bool will_debug,
99                                            bool first_arg_is_full_shell_command,
100                                            int32_t num_resumes);
101
102   void
103   SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback,
104                             bool monitor_signals);
105
106   Host::MonitorChildProcessCallback GetMonitorProcessCallback() const {
107     return m_monitor_callback;
108   }
109
110   bool GetMonitorSignals() const { return m_monitor_signals; }
111
112   // If the LaunchInfo has a monitor callback, then arrange to monitor the
113   // process.
114   // Return true if the LaunchInfo has taken care of monitoring the process, and
115   // false if the
116   // caller might want to monitor the process themselves.
117
118   bool MonitorProcess() const;
119
120   PseudoTerminal &GetPTY() { return *m_pty; }
121
122   // Get and set the actual listener that will be used for the process events
123   lldb::ListenerSP GetListener() const { return m_listener_sp; }
124
125   void SetListener(const lldb::ListenerSP &listener_sp) {
126     m_listener_sp = listener_sp;
127   }
128
129   lldb::ListenerSP GetListenerForProcess(Debugger &debugger);
130
131   lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
132
133   void SetHijackListener(const lldb::ListenerSP &listener_sp) {
134     m_hijack_listener_sp = listener_sp;
135   }
136
137   void SetLaunchEventData(const char *data) { m_event_data.assign(data); }
138
139   const char *GetLaunchEventData() const { return m_event_data.c_str(); }
140
141   void SetDetachOnError(bool enable);
142
143   bool GetDetachOnError() const {
144     return m_flags.Test(lldb::eLaunchFlagDetachOnError);
145   }
146
147 protected:
148   FileSpec m_working_dir;
149   std::string m_plugin_name;
150   FileSpec m_shell;
151   Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags
152   std::vector<FileAction> m_file_actions; // File actions for any other files
153   std::shared_ptr<PseudoTerminal> m_pty;
154   uint32_t m_resume_count; // How many times do we resume after launching
155   Host::MonitorChildProcessCallback m_monitor_callback;
156   void *m_monitor_callback_baton;
157   bool m_monitor_signals;
158   std::string m_event_data; // A string passed to the plugin launch, having no
159                             // meaning to the upper levels of lldb.
160   lldb::ListenerSP m_listener_sp;
161   lldb::ListenerSP m_hijack_listener_sp;
162 };
163 }
164
165 #endif // liblldb_ProcessLaunch_Info_h