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