[Lldb-commits] [lldb] [lldb][NFC] Separated GDBRemoteCommunication::GetDebugserverPath() (PR #107388)
Dmitry Vasilyev via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 6 01:13:14 PDT 2024
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/107388
>From 9f1612513d5feffe7c0b5b5e5b743d932d233934 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Thu, 5 Sep 2024 16:04:44 +0400
Subject: [PATCH 1/2] [lldb][NFC] Separated
GDBRemoteCommunication::GetDebugserverPath()
This is the prerequisite for #104238.
---
.../gdb-remote/GDBRemoteCommunication.cpp | 28 +++++++++++--------
.../gdb-remote/GDBRemoteCommunication.h | 3 ++
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 50fa11e916c5f5..3ac58859cecafb 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -879,19 +879,11 @@ lldb::thread_result_t GDBRemoteCommunication::ListenThread() {
return {};
}
-Status GDBRemoteCommunication::StartDebugserverProcess(
- const char *url, Platform *platform, ProcessLaunchInfo &launch_info,
- uint16_t *port, const Args *inferior_args, int pass_comm_fd) {
+FileSpec GDBRemoteCommunication::GetDebugserverPath(Platform *platform) {
Log *log = GetLog(GDBRLog::Process);
- LLDB_LOGF(log, "GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")",
- __FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
-
- Status error;
// If we locate debugserver, keep that located version around
static FileSpec g_debugserver_file_spec;
-
- char debugserver_path[PATH_MAX];
- FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
+ FileSpec debugserver_file_spec;
Environment host_env = Host::GetEnvironment();
@@ -943,8 +935,20 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
}
}
}
+ return debugserver_file_spec;
+}
- if (debugserver_exists) {
+Status GDBRemoteCommunication::StartDebugserverProcess(
+ const char *url, Platform *platform, ProcessLaunchInfo &launch_info,
+ uint16_t *port, const Args *inferior_args, shared_fd_t pass_comm_fd) {
+ Log *log = GetLog(GDBRLog::Process);
+ LLDB_LOGF(log, "GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")",
+ __FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
+
+ Status error;
+ FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
+ if (debugserver_file_spec = GetDebugserverPath(platform)) {
+ char debugserver_path[PATH_MAX];
debugserver_file_spec.GetPath(debugserver_path, sizeof(debugserver_path));
Args &debugserver_args = launch_info.GetArguments();
@@ -1059,6 +1063,8 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
}
}
}
+
+ Environment host_env = Host::GetEnvironment();
std::string env_debugserver_log_file =
host_env.lookup("LLDB_DEBUGSERVER_LOG_FILE");
if (!env_debugserver_log_file.empty()) {
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
index 4e59bd5ec8be6b..a182291f6c8594 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -146,6 +146,9 @@ class GDBRemoteCommunication : public Communication {
std::chrono::seconds GetPacketTimeout() const { return m_packet_timeout; }
+ // Get the debugserver path and check that it exist.
+ FileSpec GetDebugserverPath(Platform *platform);
+
// Start a debugserver instance on the current host using the
// supplied connection URL.
Status StartDebugserverProcess(
>From a697609659cacdebc36077e158f73450f6c78e46 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Fri, 6 Sep 2024 12:13:00 +0400
Subject: [PATCH 2/2] Updated std::string debugserver_path =
debugserver_file_spec.GetPath()
---
.../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 3ac58859cecafb..d5dcc71e496110 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -948,8 +948,7 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
Status error;
FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
if (debugserver_file_spec = GetDebugserverPath(platform)) {
- char debugserver_path[PATH_MAX];
- debugserver_file_spec.GetPath(debugserver_path, sizeof(debugserver_path));
+ std::string debugserver_path = debugserver_file_spec.GetPath();
Args &debugserver_args = launch_info.GetArguments();
debugserver_args.Clear();
More information about the lldb-commits
mailing list