Skip to content

Commit 4bb4a65

Browse files
committed
[lldb] Unify default/hijack listener between Process{Attach,Launch}Info (NFC)
This patch is a simple refactor that unifies the default and hijack listener methods and attributes between ProcessAttachInfo and ProcessLaunchInfo. These 2 classes are both derived from the ProcessInfo base class so this patch moves the listeners attributes and getter/setter methods to the base class. Differential Revision: https://reviews.llvm.org/D148395 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent f7ebc7b commit 4bb4a65

File tree

5 files changed

+21
-36
lines changed

5 files changed

+21
-36
lines changed

lldb/include/lldb/Host/ProcessLaunchInfo.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,6 @@ class ProcessLaunchInfo : public ProcessInfo {
120120

121121
PseudoTerminal &GetPTY() { return *m_pty; }
122122

123-
// Get and set the actual listener that will be used for the process events
124-
lldb::ListenerSP GetListener() const { return m_listener_sp; }
125-
126-
void SetListener(const lldb::ListenerSP &listener_sp) {
127-
m_listener_sp = listener_sp;
128-
}
129-
130-
lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
131-
132-
void SetHijackListener(const lldb::ListenerSP &listener_sp) {
133-
m_hijack_listener_sp = listener_sp;
134-
}
135-
136123
void SetLaunchEventData(const char *data) { m_event_data.assign(data); }
137124

138125
const char *GetLaunchEventData() const { return m_event_data.c_str(); }
@@ -154,8 +141,6 @@ class ProcessLaunchInfo : public ProcessInfo {
154141
Host::MonitorChildProcessCallback m_monitor_callback;
155142
std::string m_event_data; // A string passed to the plugin launch, having no
156143
// meaning to the upper levels of lldb.
157-
lldb::ListenerSP m_listener_sp;
158-
lldb::ListenerSP m_hijack_listener_sp;
159144
};
160145
}
161146

lldb/include/lldb/Target/Process.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ class ProcessAttachInfo : public ProcessInstanceInfo {
125125
ProcessInfo::operator=(launch_info);
126126
SetProcessPluginName(launch_info.GetProcessPluginName());
127127
SetResumeCount(launch_info.GetResumeCount());
128-
SetListener(launch_info.GetListener());
129-
SetHijackListener(launch_info.GetHijackListener());
130128
m_detach_on_error = launch_info.GetDetachOnError();
131129
}
132130

@@ -177,28 +175,13 @@ class ProcessAttachInfo : public ProcessInstanceInfo {
177175
return false;
178176
}
179177

180-
lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
181-
182-
void SetHijackListener(const lldb::ListenerSP &listener_sp) {
183-
m_hijack_listener_sp = listener_sp;
184-
}
185-
186178
bool GetDetachOnError() const { return m_detach_on_error; }
187179

188180
void SetDetachOnError(bool enable) { m_detach_on_error = enable; }
189181

190-
// Get and set the actual listener that will be used for the process events
191-
lldb::ListenerSP GetListener() const { return m_listener_sp; }
192-
193-
void SetListener(const lldb::ListenerSP &listener_sp) {
194-
m_listener_sp = listener_sp;
195-
}
196-
197182
lldb::ListenerSP GetListenerForProcess(Debugger &debugger);
198183

199184
protected:
200-
lldb::ListenerSP m_listener_sp;
201-
lldb::ListenerSP m_hijack_listener_sp;
202185
std::string m_plugin_name;
203186
uint32_t m_resume_count = 0; // How many times do we resume after launching
204187
bool m_wait_for_launch = false;

lldb/include/lldb/Utility/ProcessInfo.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ class ProcessInfo {
9797
m_scripted_metadata_sp = metadata_sp;
9898
}
9999

100+
// Get and set the actual listener that will be used for the process events
101+
lldb::ListenerSP GetListener() const { return m_listener_sp; }
102+
103+
void SetListener(const lldb::ListenerSP &listener_sp) {
104+
m_listener_sp = listener_sp;
105+
}
106+
107+
lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
108+
109+
void SetHijackListener(const lldb::ListenerSP &listener_sp) {
110+
m_hijack_listener_sp = listener_sp;
111+
}
112+
100113
protected:
101114
FileSpec m_executable;
102115
std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.
@@ -109,6 +122,8 @@ class ProcessInfo {
109122
ArchSpec m_arch;
110123
lldb::pid_t m_pid = LLDB_INVALID_PROCESS_ID;
111124
lldb::ScriptedMetadataSP m_scripted_metadata_sp = nullptr;
125+
lldb::ListenerSP m_listener_sp = nullptr;
126+
lldb::ListenerSP m_hijack_listener_sp = nullptr;
112127
};
113128

114129
// ProcessInstanceInfo

lldb/source/Host/common/ProcessLaunchInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ using namespace lldb_private;
3131

3232
ProcessLaunchInfo::ProcessLaunchInfo()
3333
: ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0),
34-
m_file_actions(), m_pty(new PseudoTerminal), m_monitor_callback(nullptr),
35-
m_listener_sp(), m_hijack_listener_sp() {}
34+
m_file_actions(), m_pty(new PseudoTerminal), m_monitor_callback(nullptr) {
35+
}
3636

3737
ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec,
3838
const FileSpec &stdout_file_spec,

lldb/source/Utility/ProcessInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ using namespace lldb;
2121
using namespace lldb_private;
2222

2323
ProcessInfo::ProcessInfo()
24-
: m_executable(), m_arguments(), m_environment(), m_arch() {}
24+
: m_executable(), m_arguments(), m_environment(), m_arch(), m_listener_sp(),
25+
m_hijack_listener_sp(), m_passthrough_listener_sp() {}
2526

2627
ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch,
2728
lldb::pid_t pid)
2829
: m_executable(name), m_arguments(), m_environment(), m_arch(arch),
29-
m_pid(pid) {}
30+
m_pid(pid), m_listener_sp(), m_hijack_listener_sp(),
31+
m_passthrough_listener_sp() {}
3032

3133
void ProcessInfo::Clear() {
3234
m_executable.Clear();

0 commit comments

Comments
 (0)