File indexing completed on 2026-05-10 08:42:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_HOST_PROCESSLAUNCHINFO_H
0010 #define LLDB_HOST_PROCESSLAUNCHINFO_H
0011
0012
0013 #include <string>
0014
0015
0016 #include "lldb/Utility/Flags.h"
0017
0018 #include "lldb/Host/FileAction.h"
0019 #include "lldb/Host/Host.h"
0020 #include "lldb/Host/PseudoTerminal.h"
0021 #include "lldb/Utility/FileSpec.h"
0022 #include "lldb/Utility/ProcessInfo.h"
0023
0024 namespace lldb_private {
0025
0026
0027
0028
0029
0030 class ProcessLaunchInfo : public ProcessInfo {
0031 public:
0032 ProcessLaunchInfo();
0033
0034 ProcessLaunchInfo(const FileSpec &stdin_file_spec,
0035 const FileSpec &stdout_file_spec,
0036 const FileSpec &stderr_file_spec,
0037 const FileSpec &working_dir, uint32_t launch_flags);
0038
0039 void AppendFileAction(const FileAction &info) {
0040 m_file_actions.push_back(info);
0041 }
0042
0043 bool AppendCloseFileAction(int fd);
0044
0045 bool AppendDuplicateFileAction(int fd, int dup_fd);
0046
0047 bool AppendOpenFileAction(int fd, const FileSpec &file_spec, bool read,
0048 bool write);
0049
0050 bool AppendSuppressFileAction(int fd, bool read, bool write);
0051
0052
0053
0054
0055 llvm::Error SetUpPtyRedirection();
0056
0057 size_t GetNumFileActions() const { return m_file_actions.size(); }
0058
0059 const FileAction *GetFileActionAtIndex(size_t idx) const;
0060
0061 const FileAction *GetFileActionForFD(int fd) const;
0062
0063 Flags &GetFlags() { return m_flags; }
0064
0065 const Flags &GetFlags() const { return m_flags; }
0066
0067 const FileSpec &GetWorkingDirectory() const;
0068
0069 void SetWorkingDirectory(const FileSpec &working_dir);
0070
0071 llvm::StringRef GetProcessPluginName() const;
0072
0073 void SetProcessPluginName(llvm::StringRef plugin);
0074
0075 const FileSpec &GetShell() const;
0076
0077 void SetShell(const FileSpec &shell);
0078
0079 uint32_t GetResumeCount() const { return m_resume_count; }
0080
0081 void SetResumeCount(uint32_t c) { m_resume_count = c; }
0082
0083 bool GetLaunchInSeparateProcessGroup() const {
0084 return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
0085 }
0086
0087 void SetLaunchInSeparateProcessGroup(bool separate);
0088
0089 bool GetShellExpandArguments() const {
0090 return m_flags.Test(lldb::eLaunchFlagShellExpandArguments);
0091 }
0092
0093 void SetShellExpandArguments(bool expand);
0094
0095 void Clear();
0096
0097 bool ConvertArgumentsForLaunchingInShell(Status &error, bool will_debug,
0098 bool first_arg_is_full_shell_command,
0099 uint32_t num_resumes);
0100
0101 void SetMonitorProcessCallback(Host::MonitorChildProcessCallback callback) {
0102 m_monitor_callback = std::move(callback);
0103 }
0104
0105 const Host::MonitorChildProcessCallback &GetMonitorProcessCallback() const {
0106 return m_monitor_callback;
0107 }
0108
0109
0110
0111
0112 static void NoOpMonitorCallback(lldb::pid_t pid, int signal, int status);
0113
0114
0115
0116
0117
0118
0119 bool MonitorProcess() const;
0120
0121 PseudoTerminal &GetPTY() { return *m_pty; }
0122
0123 void SetLaunchEventData(const char *data) { m_event_data.assign(data); }
0124
0125 const char *GetLaunchEventData() const { return m_event_data.c_str(); }
0126
0127 void SetDetachOnError(bool enable);
0128
0129 bool GetDetachOnError() const {
0130 return m_flags.Test(lldb::eLaunchFlagDetachOnError);
0131 }
0132
0133 protected:
0134 FileSpec m_working_dir;
0135 std::string m_plugin_name;
0136 FileSpec m_shell;
0137 Flags m_flags;
0138 std::vector<FileAction> m_file_actions;
0139 std::shared_ptr<PseudoTerminal> m_pty;
0140 uint32_t m_resume_count = 0;
0141 Host::MonitorChildProcessCallback m_monitor_callback;
0142 std::string m_event_data;
0143
0144 };
0145 }
0146
0147 #endif