LLDB mainline
SBLaunchInfo.h
Go to the documentation of this file.
1//===-- SBLaunchInfo.h ------------------------------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_API_SBLAUNCHINFO_H
10#define LLDB_API_SBLAUNCHINFO_H
11
12#include "lldb/API/SBDefines.h"
13
14namespace lldb_private {
15class SBLaunchInfoImpl;
16class ScriptInterpreter;
17}
18
19namespace lldb {
20
21class SBPlatform;
22class SBTarget;
23
25public:
26 SBLaunchInfo(const char **argv);
27
29
30#ifndef SWIG
31 // The copy constructor for SBLaunchInfo presents some problems on some
32 // supported versions of swig (e.g. 3.0.2). When trying to create an
33 // SBLaunchInfo from python with the argument `None`, swig will try to call
34 // the copy constructor instead of SBLaunchInfo(const char **). For that
35 // reason, we avoid exposing the copy constructor to python.
36 SBLaunchInfo(const SBLaunchInfo &rhs);
37#endif
38
39 SBLaunchInfo &operator=(const SBLaunchInfo &rhs);
40
41 lldb::pid_t GetProcessID();
42
43 uint32_t GetUserID();
44
45 uint32_t GetGroupID();
46
47 bool UserIDIsValid();
48
49 bool GroupIDIsValid();
50
51 void SetUserID(uint32_t uid);
52
53 void SetGroupID(uint32_t gid);
54
55 SBFileSpec GetExecutableFile();
56
57 /// Set the executable file that will be used to launch the process and
58 /// optionally set it as the first argument in the argument vector.
59 ///
60 /// This only needs to be specified if clients wish to carefully control
61 /// the exact path will be used to launch a binary. If you create a
62 /// target with a symlink, that symlink will get resolved in the target
63 /// and the resolved path will get used to launch the process. Calling
64 /// this function can help you still launch your process using the
65 /// path of your choice.
66 ///
67 /// If this function is not called prior to launching with
68 /// SBTarget::Launch(...), the target will use the resolved executable
69 /// path that was used to create the target.
70 ///
71 /// \param[in] exe_file
72 /// The override path to use when launching the executable.
73 ///
74 /// \param[in] add_as_first_arg
75 /// If true, then the path will be inserted into the argument vector
76 /// prior to launching. Otherwise the argument vector will be left
77 /// alone.
78 void SetExecutableFile(SBFileSpec exe_file, bool add_as_first_arg);
79
80 /// Get the listener that will be used to receive process events.
81 ///
82 /// If no listener has been set via a call to
83 /// SBLaunchInfo::SetListener(), then an invalid SBListener will be
84 /// returned (SBListener::IsValid() will return false). If a listener
85 /// has been set, then the valid listener object will be returned.
86 SBListener GetListener();
87
88 /// Set the listener that will be used to receive process events.
89 ///
90 /// By default the SBDebugger, which has a listener, that the SBTarget
91 /// belongs to will listen for the process events. Calling this function
92 /// allows a different listener to be used to listen for process events.
93 void SetListener(SBListener &listener);
94
95 uint32_t GetNumArguments();
96
97 const char *GetArgumentAtIndex(uint32_t idx);
98
99 void SetArguments(const char **argv, bool append);
100
101 uint32_t GetNumEnvironmentEntries();
102
103 const char *GetEnvironmentEntryAtIndex(uint32_t idx);
104
105 /// Update this object with the given environment variables.
106 ///
107 /// If append is false, the provided environment will replace the existing
108 /// environment. Otherwise, existing values will be updated of left untouched
109 /// accordingly.
110 ///
111 /// \param [in] envp
112 /// The new environment variables as a list of strings with the following
113 /// format
114 /// name=value
115 ///
116 /// \param [in] append
117 /// Flag that controls whether to replace the existing environment.
118 void SetEnvironmentEntries(const char **envp, bool append);
119
120 /// Update this object with the given environment variables.
121 ///
122 /// If append is false, the provided environment will replace the existing
123 /// environment. Otherwise, existing values will be updated of left untouched
124 /// accordingly.
125 ///
126 /// \param [in] env
127 /// The new environment variables.
128 ///
129 /// \param [in] append
130 /// Flag that controls whether to replace the existing environment.
131 void SetEnvironment(const SBEnvironment &env, bool append);
132
133 /// Return the environment variables of this object.
134 ///
135 /// \return
136 /// An lldb::SBEnvironment object which is a copy of the SBLaunchInfo's
137 /// environment.
138 SBEnvironment GetEnvironment();
139
140 void Clear();
141
142 const char *GetWorkingDirectory() const;
143
144 void SetWorkingDirectory(const char *working_dir);
145
146 uint32_t GetLaunchFlags();
147
148 void SetLaunchFlags(uint32_t flags);
149
150 const char *GetProcessPluginName();
151
152 void SetProcessPluginName(const char *plugin_name);
153
154 const char *GetShell();
155
156 void SetShell(const char *path);
157
158 bool GetShellExpandArguments();
159
160 void SetShellExpandArguments(bool expand);
161
162 uint32_t GetResumeCount();
163
164 void SetResumeCount(uint32_t c);
165
166 bool AddCloseFileAction(int fd);
167
168 bool AddDuplicateFileAction(int fd, int dup_fd);
169
170 bool AddOpenFileAction(int fd, const char *path, bool read, bool write);
171
172 bool AddSuppressFileAction(int fd, bool read, bool write);
173
174 void SetLaunchEventData(const char *data);
175
176 const char *GetLaunchEventData() const;
177
178 bool GetDetachOnError() const;
179
180 void SetDetachOnError(bool enable);
181
182 const char *GetScriptedProcessClassName() const;
183
184 void SetScriptedProcessClassName(const char *class_name);
185
186 lldb::SBStructuredData GetScriptedProcessDictionary() const;
187
188 void SetScriptedProcessDictionary(lldb::SBStructuredData dict);
189
190protected:
191 friend class SBPlatform;
192 friend class SBTarget;
193
195
196 const lldb_private::ProcessLaunchInfo &ref() const;
197 void set_ref(const lldb_private::ProcessLaunchInfo &info);
198
199 std::shared_ptr<lldb_private::SBLaunchInfoImpl> m_opaque_sp;
200};
201
202} // namespace lldb
203
204#endif // LLDB_API_SBLAUNCHINFO_H
#define LLDB_API
Definition: SBDefines.h:26
std::shared_ptr< lldb_private::SBLaunchInfoImpl > m_opaque_sp
Definition: SBLaunchInfo.h:199
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
class LLDB_API SBTarget
Definition: SBDefines.h:86
uint64_t pid_t
Definition: lldb-types.h:85