1 //===-- SBLaunchInfo.h ------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SBLaunchInfo_h_
10 #define LLDB_SBLaunchInfo_h_
12 #include "lldb/API/SBDefines.h"
14 namespace lldb_private {
15 class SBLaunchInfoImpl;
23 class LLDB_API SBLaunchInfo {
25 SBLaunchInfo(const char **argv);
29 lldb::pid_t GetProcessID();
33 uint32_t GetGroupID();
37 bool GroupIDIsValid();
39 void SetUserID(uint32_t uid);
41 void SetGroupID(uint32_t gid);
43 SBFileSpec GetExecutableFile();
45 /// Set the executable file that will be used to launch the process and
46 /// optionally set it as the first argument in the argument vector.
48 /// This only needs to be specified if clients wish to carefully control
49 /// the exact path will be used to launch a binary. If you create a
50 /// target with a symlink, that symlink will get resolved in the target
51 /// and the resolved path will get used to launch the process. Calling
52 /// this function can help you still launch your process using the
53 /// path of your choice.
55 /// If this function is not called prior to launching with
56 /// SBTarget::Launch(...), the target will use the resolved executable
57 /// path that was used to create the target.
59 /// \param[in] exe_file
60 /// The override path to use when launching the executable.
62 /// \param[in] add_as_first_arg
63 /// If true, then the path will be inserted into the argument vector
64 /// prior to launching. Otherwise the argument vector will be left
66 void SetExecutableFile(SBFileSpec exe_file, bool add_as_first_arg);
68 /// Get the listener that will be used to receive process events.
70 /// If no listener has been set via a call to
71 /// SBLaunchInfo::SetListener(), then an invalid SBListener will be
72 /// returned (SBListener::IsValid() will return false). If a listener
73 /// has been set, then the valid listener object will be returned.
74 SBListener GetListener();
76 /// Set the listener that will be used to receive process events.
78 /// By default the SBDebugger, which has a listener, that the SBTarget
79 /// belongs to will listen for the process events. Calling this function
80 /// allows a different listener to be used to listen for process events.
81 void SetListener(SBListener &listener);
83 uint32_t GetNumArguments();
85 const char *GetArgumentAtIndex(uint32_t idx);
87 void SetArguments(const char **argv, bool append);
89 uint32_t GetNumEnvironmentEntries();
91 const char *GetEnvironmentEntryAtIndex(uint32_t idx);
93 void SetEnvironmentEntries(const char **envp, bool append);
97 const char *GetWorkingDirectory() const;
99 void SetWorkingDirectory(const char *working_dir);
101 uint32_t GetLaunchFlags();
103 void SetLaunchFlags(uint32_t flags);
105 const char *GetProcessPluginName();
107 void SetProcessPluginName(const char *plugin_name);
109 const char *GetShell();
111 void SetShell(const char *path);
113 bool GetShellExpandArguments();
115 void SetShellExpandArguments(bool expand);
117 uint32_t GetResumeCount();
119 void SetResumeCount(uint32_t c);
121 bool AddCloseFileAction(int fd);
123 bool AddDuplicateFileAction(int fd, int dup_fd);
125 bool AddOpenFileAction(int fd, const char *path, bool read, bool write);
127 bool AddSuppressFileAction(int fd, bool read, bool write);
129 void SetLaunchEventData(const char *data);
131 const char *GetLaunchEventData() const;
133 bool GetDetachOnError() const;
135 void SetDetachOnError(bool enable);
138 friend class SBPlatform;
139 friend class SBTarget;
141 const lldb_private::ProcessLaunchInfo &ref() const;
142 void set_ref(const lldb_private::ProcessLaunchInfo &info);
144 std::shared_ptr<lldb_private::SBLaunchInfoImpl> m_opaque_sp;
149 #endif // LLDB_SBLaunchInfo_h_