Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:42

0001 //===-- SBLaunchInfo.h ------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_API_SBLAUNCHINFO_H
0010 #define LLDB_API_SBLAUNCHINFO_H
0011 
0012 #include "lldb/API/SBDefines.h"
0013 
0014 namespace lldb_private {
0015 class SBLaunchInfoImpl;
0016 class ScriptInterpreter;
0017 }
0018 
0019 namespace lldb {
0020 
0021 class SBPlatform;
0022 class SBTarget;
0023 
0024 class LLDB_API SBLaunchInfo {
0025 public:
0026   SBLaunchInfo(const char **argv);
0027 
0028   ~SBLaunchInfo();
0029 
0030 #ifndef SWIG
0031   // The copy constructor for SBLaunchInfo presents some problems on some
0032   // supported versions of swig (e.g. 3.0.2). When trying to create an
0033   // SBLaunchInfo from python with the argument `None`, swig will try to call
0034   // the copy constructor instead of SBLaunchInfo(const char **). For that
0035   // reason, we avoid exposing the copy constructor to python.
0036   SBLaunchInfo(const SBLaunchInfo &rhs);
0037 #endif
0038 
0039   SBLaunchInfo &operator=(const SBLaunchInfo &rhs);
0040 
0041   lldb::pid_t GetProcessID();
0042 
0043   uint32_t GetUserID();
0044 
0045   uint32_t GetGroupID();
0046 
0047   bool UserIDIsValid();
0048 
0049   bool GroupIDIsValid();
0050 
0051   void SetUserID(uint32_t uid);
0052 
0053   void SetGroupID(uint32_t gid);
0054 
0055   SBFileSpec GetExecutableFile();
0056 
0057   /// Set the executable file that will be used to launch the process and
0058   /// optionally set it as the first argument in the argument vector.
0059   ///
0060   /// This only needs to be specified if clients wish to carefully control
0061   /// the exact path will be used to launch a binary. If you create a
0062   /// target with a symlink, that symlink will get resolved in the target
0063   /// and the resolved path will get used to launch the process. Calling
0064   /// this function can help you still launch your process using the
0065   /// path of your choice.
0066   ///
0067   /// If this function is not called prior to launching with
0068   /// SBTarget::Launch(...), the target will use the resolved executable
0069   /// path that was used to create the target.
0070   ///
0071   /// \param[in] exe_file
0072   ///     The override path to use when launching the executable.
0073   ///
0074   /// \param[in] add_as_first_arg
0075   ///     If true, then the path will be inserted into the argument vector
0076   ///     prior to launching. Otherwise the argument vector will be left
0077   ///     alone.
0078   void SetExecutableFile(SBFileSpec exe_file, bool add_as_first_arg);
0079 
0080   /// Get the listener that will be used to receive process events.
0081   ///
0082   /// If no listener has been set via a call to
0083   /// SBLaunchInfo::SetListener(), then an invalid SBListener will be
0084   /// returned (SBListener::IsValid() will return false). If a listener
0085   /// has been set, then the valid listener object will be returned.
0086   SBListener GetListener();
0087 
0088   /// Set the listener that will be used to receive process events.
0089   ///
0090   /// By default the SBDebugger, which has a listener, that the SBTarget
0091   /// belongs to will listen for the process events. Calling this function
0092   /// allows a different listener to be used to listen for process events.
0093   void SetListener(SBListener &listener);
0094 
0095   /// Get the shadow listener that receive public process events,
0096   /// additionally to the default process event listener.
0097   ///
0098   /// If no listener has been set via a call to
0099   /// SBLaunchInfo::SetShadowListener(), then an invalid SBListener will
0100   /// be returned (SBListener::IsValid() will return false). If a listener
0101   /// has been set, then the valid listener object will be returned.
0102   SBListener GetShadowListener();
0103 
0104   /// Set the shadow listener that will receive public process events,
0105   /// additionally to the default process event listener.
0106   ///
0107   /// By default a process have no shadow event listener.
0108   /// Calling this function allows public process events to be broadcasted to an
0109   /// additional listener on top of the default process event listener.
0110   /// If the `listener` argument is invalid (SBListener::IsValid() will
0111   /// return false), this will clear the shadow listener.
0112   void SetShadowListener(SBListener &listener);
0113 
0114   uint32_t GetNumArguments();
0115 
0116   const char *GetArgumentAtIndex(uint32_t idx);
0117 
0118   void SetArguments(const char **argv, bool append);
0119 
0120   uint32_t GetNumEnvironmentEntries();
0121 
0122   const char *GetEnvironmentEntryAtIndex(uint32_t idx);
0123 
0124   /// Update this object with the given environment variables.
0125   ///
0126   /// If append is false, the provided environment will replace the existing
0127   /// environment. Otherwise, existing values will be updated of left untouched
0128   /// accordingly.
0129   ///
0130   /// \param [in] envp
0131   ///     The new environment variables as a list of strings with the following
0132   ///     format
0133   ///         name=value
0134   ///
0135   /// \param [in] append
0136   ///     Flag that controls whether to replace the existing environment.
0137   void SetEnvironmentEntries(const char **envp, bool append);
0138 
0139   /// Update this object with the given environment variables.
0140   ///
0141   /// If append is false, the provided environment will replace the existing
0142   /// environment. Otherwise, existing values will be updated of left untouched
0143   /// accordingly.
0144   ///
0145   /// \param [in] env
0146   ///     The new environment variables.
0147   ///
0148   /// \param [in] append
0149   ///     Flag that controls whether to replace the existing environment.
0150   void SetEnvironment(const SBEnvironment &env, bool append);
0151 
0152   /// Return the environment variables of this object.
0153   ///
0154   /// \return
0155   ///     An lldb::SBEnvironment object which is a copy of the SBLaunchInfo's
0156   ///     environment.
0157   SBEnvironment GetEnvironment();
0158 
0159   void Clear();
0160 
0161   const char *GetWorkingDirectory() const;
0162 
0163   void SetWorkingDirectory(const char *working_dir);
0164 
0165   uint32_t GetLaunchFlags();
0166 
0167   void SetLaunchFlags(uint32_t flags);
0168 
0169   const char *GetProcessPluginName();
0170 
0171   void SetProcessPluginName(const char *plugin_name);
0172 
0173   const char *GetShell();
0174 
0175   void SetShell(const char *path);
0176 
0177   bool GetShellExpandArguments();
0178 
0179   void SetShellExpandArguments(bool expand);
0180 
0181   uint32_t GetResumeCount();
0182 
0183   void SetResumeCount(uint32_t c);
0184 
0185   bool AddCloseFileAction(int fd);
0186 
0187   bool AddDuplicateFileAction(int fd, int dup_fd);
0188 
0189   bool AddOpenFileAction(int fd, const char *path, bool read, bool write);
0190 
0191   bool AddSuppressFileAction(int fd, bool read, bool write);
0192 
0193   void SetLaunchEventData(const char *data);
0194 
0195   const char *GetLaunchEventData() const;
0196 
0197   bool GetDetachOnError() const;
0198 
0199   void SetDetachOnError(bool enable);
0200 
0201   const char *GetScriptedProcessClassName() const;
0202 
0203   void SetScriptedProcessClassName(const char *class_name);
0204 
0205   lldb::SBStructuredData GetScriptedProcessDictionary() const;
0206 
0207   void SetScriptedProcessDictionary(lldb::SBStructuredData dict);
0208 
0209 protected:
0210   friend class SBPlatform;
0211   friend class SBTarget;
0212 
0213   friend class lldb_private::ScriptInterpreter;
0214 
0215   const lldb_private::ProcessLaunchInfo &ref() const;
0216   void set_ref(const lldb_private::ProcessLaunchInfo &info);
0217 
0218   std::shared_ptr<lldb_private::SBLaunchInfoImpl> m_opaque_sp;
0219 };
0220 
0221 } // namespace lldb
0222 
0223 #endif // LLDB_API_SBLAUNCHINFO_H