[Lldb-commits] [lldb] 46e93c9 - [lldb] Unify default/hijack listener between Process{Attach, Launch}Info (NFC)
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 25 15:04:20 PDT 2023
Author: Med Ismail Bennani
Date: 2023-04-25T15:02:34-07:00
New Revision: 46e93c9df287bc06854c66e08658f757ff6cf6f1
URL: https://github.com/llvm/llvm-project/commit/46e93c9df287bc06854c66e08658f757ff6cf6f1
DIFF: https://github.com/llvm/llvm-project/commit/46e93c9df287bc06854c66e08658f757ff6cf6f1.diff
LOG: [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 <medismail.bennani at gmail.com>
Added:
Modified:
lldb/include/lldb/Host/ProcessLaunchInfo.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Utility/ProcessInfo.h
lldb/source/Host/common/ProcessLaunchInfo.cpp
lldb/source/Utility/ProcessInfo.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Host/ProcessLaunchInfo.h b/lldb/include/lldb/Host/ProcessLaunchInfo.h
index b9beea4d11b8c..891f46f650c8c 100644
--- a/lldb/include/lldb/Host/ProcessLaunchInfo.h
+++ b/lldb/include/lldb/Host/ProcessLaunchInfo.h
@@ -120,19 +120,6 @@ class ProcessLaunchInfo : public ProcessInfo {
PseudoTerminal &GetPTY() { return *m_pty; }
- // Get and set the actual listener that will be used for the process events
- lldb::ListenerSP GetListener() const { return m_listener_sp; }
-
- void SetListener(const lldb::ListenerSP &listener_sp) {
- m_listener_sp = listener_sp;
- }
-
- lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
-
- void SetHijackListener(const lldb::ListenerSP &listener_sp) {
- m_hijack_listener_sp = listener_sp;
- }
-
void SetLaunchEventData(const char *data) { m_event_data.assign(data); }
const char *GetLaunchEventData() const { return m_event_data.c_str(); }
@@ -154,8 +141,6 @@ class ProcessLaunchInfo : public ProcessInfo {
Host::MonitorChildProcessCallback m_monitor_callback;
std::string m_event_data; // A string passed to the plugin launch, having no
// meaning to the upper levels of lldb.
- lldb::ListenerSP m_listener_sp;
- lldb::ListenerSP m_hijack_listener_sp;
};
}
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index b4b75e52d572a..68581e47184cb 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -122,8 +122,6 @@ class ProcessAttachInfo : public ProcessInstanceInfo {
ProcessInfo::operator=(launch_info);
SetProcessPluginName(launch_info.GetProcessPluginName());
SetResumeCount(launch_info.GetResumeCount());
- SetListener(launch_info.GetListener());
- SetHijackListener(launch_info.GetHijackListener());
m_detach_on_error = launch_info.GetDetachOnError();
}
@@ -174,28 +172,13 @@ class ProcessAttachInfo : public ProcessInstanceInfo {
return false;
}
- lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
-
- void SetHijackListener(const lldb::ListenerSP &listener_sp) {
- m_hijack_listener_sp = listener_sp;
- }
-
bool GetDetachOnError() const { return m_detach_on_error; }
void SetDetachOnError(bool enable) { m_detach_on_error = enable; }
- // Get and set the actual listener that will be used for the process events
- lldb::ListenerSP GetListener() const { return m_listener_sp; }
-
- void SetListener(const lldb::ListenerSP &listener_sp) {
- m_listener_sp = listener_sp;
- }
-
lldb::ListenerSP GetListenerForProcess(Debugger &debugger);
protected:
- lldb::ListenerSP m_listener_sp;
- lldb::ListenerSP m_hijack_listener_sp;
std::string m_plugin_name;
uint32_t m_resume_count = 0; // How many times do we resume after launching
bool m_wait_for_launch = false;
diff --git a/lldb/include/lldb/Utility/ProcessInfo.h b/lldb/include/lldb/Utility/ProcessInfo.h
index 8bddb04b1d474..a48acdddca3ab 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -97,6 +97,19 @@ class ProcessInfo {
m_scripted_metadata_sp = metadata_sp;
}
+ // Get and set the actual listener that will be used for the process events
+ lldb::ListenerSP GetListener() const { return m_listener_sp; }
+
+ void SetListener(const lldb::ListenerSP &listener_sp) {
+ m_listener_sp = listener_sp;
+ }
+
+ lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
+
+ void SetHijackListener(const lldb::ListenerSP &listener_sp) {
+ m_hijack_listener_sp = listener_sp;
+ }
+
protected:
FileSpec m_executable;
std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.
@@ -109,6 +122,8 @@ class ProcessInfo {
ArchSpec m_arch;
lldb::pid_t m_pid = LLDB_INVALID_PROCESS_ID;
lldb::ScriptedMetadataSP m_scripted_metadata_sp = nullptr;
+ lldb::ListenerSP m_listener_sp = nullptr;
+ lldb::ListenerSP m_hijack_listener_sp = nullptr;
};
// ProcessInstanceInfo
diff --git a/lldb/source/Host/common/ProcessLaunchInfo.cpp b/lldb/source/Host/common/ProcessLaunchInfo.cpp
index 8e09601b5715b..e737815750b2c 100644
--- a/lldb/source/Host/common/ProcessLaunchInfo.cpp
+++ b/lldb/source/Host/common/ProcessLaunchInfo.cpp
@@ -31,8 +31,8 @@ using namespace lldb_private;
ProcessLaunchInfo::ProcessLaunchInfo()
: ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0),
- m_file_actions(), m_pty(new PseudoTerminal), m_monitor_callback(nullptr),
- m_listener_sp(), m_hijack_listener_sp() {}
+ m_file_actions(), m_pty(new PseudoTerminal), m_monitor_callback(nullptr) {
+}
ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec,
const FileSpec &stdout_file_spec,
diff --git a/lldb/source/Utility/ProcessInfo.cpp b/lldb/source/Utility/ProcessInfo.cpp
index 595c0b090401a..29a7064438bcc 100644
--- a/lldb/source/Utility/ProcessInfo.cpp
+++ b/lldb/source/Utility/ProcessInfo.cpp
@@ -22,12 +22,14 @@ using namespace lldb;
using namespace lldb_private;
ProcessInfo::ProcessInfo()
- : m_executable(), m_arguments(), m_environment(), m_arch() {}
+ : m_executable(), m_arguments(), m_environment(), m_arch(), m_listener_sp(),
+ m_hijack_listener_sp(), m_passthrough_listener_sp() {}
ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch,
lldb::pid_t pid)
: m_executable(name), m_arguments(), m_environment(), m_arch(arch),
- m_pid(pid) {}
+ m_pid(pid), m_listener_sp(), m_hijack_listener_sp(),
+ m_passthrough_listener_sp() {}
void ProcessInfo::Clear() {
m_executable.Clear();
More information about the lldb-commits
mailing list