1 //===-- SBAttachInfo.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 LLDB_SBAttachInfo_h_
11 #define LLDB_SBAttachInfo_h_
12 
13 #include "lldb/API/SBDefines.h"
14 
15 namespace lldb {
16 
17 class SBTarget;
18 
19 class LLDB_API SBAttachInfo {
20 public:
21   SBAttachInfo();
22 
23   SBAttachInfo(lldb::pid_t pid);
24 
25   //------------------------------------------------------------------
26   /// Attach to a process by name.
27   ///
28   /// This function implies that a future call to SBTarget::Attach(...)
29   /// will be synchronous.
30   ///
31   /// @param[in] path
32   ///     A full or partial name for the process to attach to.
33   ///
34   /// @param[in] wait_for
35   ///     If \b false, attach to an existing process whose name matches.
36   ///     If \b true, then wait for the next process whose name matches.
37   //------------------------------------------------------------------
38   SBAttachInfo(const char *path, bool wait_for);
39 
40   //------------------------------------------------------------------
41   /// Attach to a process by name.
42   ///
43   /// Future calls to SBTarget::Attach(...) will be synchronous or
44   /// asynchronous depending on the \a async argument.
45   ///
46   /// @param[in] path
47   ///     A full or partial name for the process to attach to.
48   ///
49   /// @param[in] wait_for
50   ///     If \b false, attach to an existing process whose name matches.
51   ///     If \b true, then wait for the next process whose name matches.
52   ///
53   /// @param[in] async
54   ///     If \b false, then the SBTarget::Attach(...) call will be a
55   ///     synchronous call with no way to cancel the attach in
56   ///     progress.
57   ///     If \b true, then the SBTarget::Attach(...) function will
58   ///     return immediately and clients are expected to wait for a
59   ///     process eStateStopped event if a suitable process is
60   ///     eventually found. If the client wants to cancel the event,
61   ///     SBProcess::Stop() can be called and an eStateExited process
62   ///     event will be delivered.
63   //------------------------------------------------------------------
64   SBAttachInfo(const char *path, bool wait_for, bool async);
65 
66   SBAttachInfo(const SBAttachInfo &rhs);
67 
68   ~SBAttachInfo();
69 
70   SBAttachInfo &operator=(const SBAttachInfo &rhs);
71 
72   lldb::pid_t GetProcessID();
73 
74   void SetProcessID(lldb::pid_t pid);
75 
76   void SetExecutable(const char *path);
77 
78   void SetExecutable(lldb::SBFileSpec exe_file);
79 
80   bool GetWaitForLaunch();
81 
82   //------------------------------------------------------------------
83   /// Set attach by process name settings.
84   ///
85   /// Designed to be used after a call to SBAttachInfo::SetExecutable().
86   /// This function implies that a call to SBTarget::Attach(...) will
87   /// be synchronous.
88   ///
89   /// @param[in] b
90   ///     If \b false, attach to an existing process whose name matches.
91   ///     If \b true, then wait for the next process whose name matches.
92   //------------------------------------------------------------------
93   void SetWaitForLaunch(bool b);
94 
95   //------------------------------------------------------------------
96   /// Set attach by process name settings.
97   ///
98   /// Designed to be used after a call to SBAttachInfo::SetExecutable().
99   /// Future calls to SBTarget::Attach(...) will be synchronous or
100   /// asynchronous depending on the \a async argument.
101   ///
102   /// @param[in] b
103   ///     If \b false, attach to an existing process whose name matches.
104   ///     If \b true, then wait for the next process whose name matches.
105   ///
106   /// @param[in] async
107   ///     If \b false, then the SBTarget::Attach(...) call will be a
108   ///     synchronous call with no way to cancel the attach in
109   ///     progress.
110   ///     If \b true, then the SBTarget::Attach(...) function will
111   ///     return immediately and clients are expected to wait for a
112   ///     process eStateStopped event if a suitable process is
113   ///     eventually found. If the client wants to cancel the event,
114   ///     SBProcess::Stop() can be called and an eStateExited process
115   ///     event will be delivered.
116   //------------------------------------------------------------------
117   void SetWaitForLaunch(bool b, bool async);
118 
119   bool GetIgnoreExisting();
120 
121   void SetIgnoreExisting(bool b);
122 
123   uint32_t GetResumeCount();
124 
125   void SetResumeCount(uint32_t c);
126 
127   const char *GetProcessPluginName();
128 
129   void SetProcessPluginName(const char *plugin_name);
130 
131   uint32_t GetUserID();
132 
133   uint32_t GetGroupID();
134 
135   bool UserIDIsValid();
136 
137   bool GroupIDIsValid();
138 
139   void SetUserID(uint32_t uid);
140 
141   void SetGroupID(uint32_t gid);
142 
143   uint32_t GetEffectiveUserID();
144 
145   uint32_t GetEffectiveGroupID();
146 
147   bool EffectiveUserIDIsValid();
148 
149   bool EffectiveGroupIDIsValid();
150 
151   void SetEffectiveUserID(uint32_t uid);
152 
153   void SetEffectiveGroupID(uint32_t gid);
154 
155   lldb::pid_t GetParentProcessID();
156 
157   void SetParentProcessID(lldb::pid_t pid);
158 
159   bool ParentProcessIDIsValid();
160 
161   //----------------------------------------------------------------------
162   /// Get the listener that will be used to receive process events.
163   ///
164   /// If no listener has been set via a call to
165   /// SBAttachInfo::SetListener(), then an invalid SBListener will be
166   /// returned (SBListener::IsValid() will return false). If a listener
167   /// has been set, then the valid listener object will be returned.
168   //----------------------------------------------------------------------
169   SBListener GetListener();
170 
171   //----------------------------------------------------------------------
172   /// Set the listener that will be used to receive process events.
173   ///
174   /// By default the SBDebugger, which has a listener, that the SBTarget
175   /// belongs to will listen for the process events. Calling this function
176   /// allows a different listener to be used to listen for process events.
177   //----------------------------------------------------------------------
178   void SetListener(SBListener &listener);
179 
180 protected:
181   friend class SBTarget;
182 
183   lldb_private::ProcessAttachInfo &ref();
184 
185   ProcessAttachInfoSP m_opaque_sp;
186 };
187 
188 } // namespace lldb
189 
190 #endif // LLDB_SBAttachInfo_h_
191