diff --git a/lldb/source/Plugins/Platform/OHOS/CMakeLists.txt b/lldb/source/Plugins/Platform/OHOS/CMakeLists.txt index cc71762efe2ea58aafadcf05184ebe6fc3bd4078..184f014276893b861248c93589db8e5979d6e27b 100644 --- a/lldb/source/Plugins/Platform/OHOS/CMakeLists.txt +++ b/lldb/source/Plugins/Platform/OHOS/CMakeLists.txt @@ -1,3 +1,11 @@ +lldb_tablegen(PlatformOHOSProperties.inc -gen-lldb-property-defs + SOURCE PlatformOHOSProperties.td + TARGET LLDBPluginPlatformOHOSPropertiesGen) + +lldb_tablegen(PlatformOHOSPropertiesEnum.inc -gen-lldb-property-enum-defs + SOURCE PlatformOHOSProperties.td + TARGET LLDBPluginPlatformOHOSPropertiesEnumGen) + add_lldb_library(lldbPluginPlatformOHOS PLUGIN HdcClient.cpp PlatformOHOS.cpp @@ -11,3 +19,7 @@ add_lldb_library(lldbPluginPlatformOHOS PLUGIN LINK_COMPONENTS Support ) + +add_dependencies(lldbPluginPlatformOHOS + LLDBPluginPlatformOHOSPropertiesGen + LLDBPluginPlatformOHOSPropertiesEnumGen) diff --git a/lldb/source/Plugins/Platform/OHOS/HdcClient.cpp b/lldb/source/Plugins/Platform/OHOS/HdcClient.cpp index 26742b8c80eb7d521e0ab6af40e2f6a1653a8e31..3a9679f5fdc9fed35228fae44008d142a5127d5b 100644 --- a/lldb/source/Plugins/Platform/OHOS/HdcClient.cpp +++ b/lldb/source/Plugins/Platform/OHOS/HdcClient.cpp @@ -18,15 +18,16 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/PosixApi.h" -#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataEncoder.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timeout.h" #include "lldb/Utility/Timer.h" // OHOS_LOCAL +#include "lldb/Utility/UriParser.h" #if defined(_WIN32) #include @@ -128,9 +129,36 @@ Status HdcClient::CreateByDeviceID(const std::string &device_id, return error; } -HdcClient::HdcClient(const std::string &connect_addr, +HdcClient HdcClient::Create(const PlatformOHOSProperties &global_props, + std::string &connect_addr, uint16_t &connect_port, + std::string &device_id, Status &error) { + std::string parsed_connect_addr = "localhost"; + uint16_t parsed_connect_port = 0; + llvm::StringRef remote_hdc_server = global_props.GetRemoteHDCServer(); + if (!remote_hdc_server.empty()) { + auto uri = ("connect://" + remote_hdc_server).str(); + llvm::Optional parsed = URI::Parse(uri); + if (parsed) { + parsed_connect_addr = parsed->hostname.str(); + parsed_connect_port = parsed->port.value_or(0); + } + } + + HdcClient hdc(parsed_connect_addr, parsed_connect_port); + error = HdcClient::CreateByDeviceID(device_id, hdc); + if (error.Fail()) + return hdc; + + connect_addr = hdc.GetConnectAddr(); + connect_port = hdc.GetConnectPort(); + device_id = hdc.GetDeviceID(); + return hdc; +} + +HdcClient::HdcClient(const std::string &connect_addr, uint16_t connect_port, const std::string &device_id) - : m_connect_addr(connect_addr), m_device_id(device_id) {} + : m_connect_addr(connect_addr), m_connect_port(connect_port), + m_device_id(device_id) {} HdcClient::HdcClient(HdcClient &&) = default; @@ -141,6 +169,8 @@ void HdcClient::SetDeviceID(const std::string &device_id) { } const std::string &HdcClient::GetDeviceID() const { return m_device_id; } +const std::string &HdcClient::GetConnectAddr() const { return m_connect_addr; } +uint16_t HdcClient::GetConnectPort() const { return m_connect_port; } bool HdcClient::IsServerLocal() { return m_connect_addr == "localhost" || m_connect_addr == "127.0.0.1"; @@ -165,16 +195,21 @@ Status HdcClient::Connect() { return Status("Device id is too long: %s", m_device_id.c_str()); m_conn.reset(new ConnectionFileDescriptor); std::string port = "8710"; - - const char *env_port = std::getenv("OHOS_HDC_SERVER_PORT"); - if (env_port != NULL) { - int iEnv_port = atoi(env_port); - if ((iEnv_port > 0) && (iEnv_port <= 65535)) { - port = env_port; - } - else { - return Status("invalid port specification: %s. $OHOS_HDC_SERVER_PORT must be a positive number in (0,65535]", env_port); + + if (m_connect_port == 0) { + const char *env_port = std::getenv("OHOS_HDC_SERVER_PORT"); + if (env_port != NULL) { + int iEnv_port = atoi(env_port); + if ((iEnv_port > 0) && (iEnv_port <= 65535)) { + port = env_port; + } else { + return Status("invalid port specification: %s. $OHOS_HDC_SERVER_PORT " + "must be a positive number in (0,65535]", + env_port); + } } + } else { + port = std::to_string(m_connect_port); } // Support remote HDC server by providing connection address explicitly diff --git a/lldb/source/Plugins/Platform/OHOS/HdcClient.h b/lldb/source/Plugins/Platform/OHOS/HdcClient.h index 5e17b0d8f8ef465a494022eda3bb498057298560..c1428cd086aca58861899f375cf328395f241b28 100644 --- a/lldb/source/Plugins/Platform/OHOS/HdcClient.h +++ b/lldb/source/Plugins/Platform/OHOS/HdcClient.h @@ -9,6 +9,7 @@ #ifndef liblldb_HdcClient_h_ #define liblldb_HdcClient_h_ +#include "lldb/Core/UserSettingsController.h" #include "lldb/Utility/Status.h" #include #include @@ -23,6 +24,16 @@ class FileSpec; namespace platform_ohos { +class HdcClient; + +class PlatformOHOSProperties : public Properties { +public: + static ConstString &GetSettingName(); + PlatformOHOSProperties(); + ~PlatformOHOSProperties() override = default; + llvm::StringRef GetRemoteHDCServer() const; +}; + class HdcClient { public: enum UnixSocketNamespace { @@ -33,8 +44,10 @@ public: using DeviceIDList = std::list; static Status CreateByDeviceID(const std::string &device_id, HdcClient &hdc); - - explicit HdcClient(const std::string &connect_addr, + static HdcClient Create(const PlatformOHOSProperties &global_props, + std::string &connect_addr, uint16_t &connect_port, + std::string &device_id, Status &error); + explicit HdcClient(const std::string &connect_addr, uint16_t connect_port = 0, const std::string &device_id = ""); HdcClient(HdcClient &&); @@ -42,6 +55,8 @@ public: ~HdcClient(); const std::string &GetDeviceID() const; + const std::string &GetConnectAddr() const; + uint16_t GetConnectPort() const; Status GetDevices(DeviceIDList &device_list); @@ -105,7 +120,8 @@ private: Status ReadAllBytes(void *buffer, size_t size); std::string m_connect_addr; - std::string m_device_id; + uint16_t m_connect_port; + std::string m_device_id{}; std::unique_ptr m_conn; }; diff --git a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp index d7ea2897f377a0b7a78441508fc3088807e1dbe6..cd15e2ba3976e390d4278cfb963c00c445a8f8ad 100644 --- a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp +++ b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp @@ -11,6 +11,7 @@ #include "lldb/Core/Section.h" #include "lldb/Core/ValueObject.h" #include "lldb/Host/HostInfo.h" +#include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Scalar.h" #include "lldb/Utility/UriParser.h" @@ -62,7 +63,7 @@ void PlatformOHOS::Initialize() { PluginManager::RegisterPlugin( PlatformOHOS::GetPluginNameStatic(false), PlatformOHOS::GetPluginDescriptionStatic(false), - PlatformOHOS::CreateInstance); + PlatformOHOS::CreateInstance, PlatformOHOS::DebuggerInitialize); } } @@ -146,13 +147,54 @@ llvm::StringRef PlatformOHOS::GetPluginName() { return GetPluginNameStatic(IsHost()); } +#define LLDB_PROPERTIES_platformohos +#include "PlatformOHOSProperties.inc" + +#define LLDB_PROPERTIES_platformohos +enum { +#include "PlatformOHOSPropertiesEnum.inc" +}; + +ConstString &PlatformOHOSProperties::GetSettingName() { + static ConstString g_setting_name("ohos"); + return g_setting_name; +} + +PlatformOHOSProperties::PlatformOHOSProperties() : Properties() { + m_collection_sp = std::make_shared(GetSettingName()); + m_collection_sp->Initialize(g_platformohos_properties); +} + +llvm::StringRef PlatformOHOSProperties::GetRemoteHDCServer() const { + const uint32_t idx = ePropertyRemoteHDCServer; + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, + llvm::StringRef()); +} + +static PlatformOHOSProperties &GetGlobalProperties() { + static PlatformOHOSProperties g_settings; + return g_settings; +} + HdcClient PlatformOHOS::CreateHdcClient() { - return HdcClient(m_connect_addr, m_device_id); + return HdcClient(m_connect_addr, m_connect_port, m_device_id); +} + +void PlatformOHOS::DebuggerInitialize(lldb_private::Debugger &debugger) { + if (!PluginManager::GetSettingForPlatformPlugin( + debugger, PlatformOHOSProperties::GetSettingName())) { + const bool is_global_setting = false; + PluginManager::CreateSettingForPlatformPlugin( + debugger, GetGlobalProperties().GetValueProperties(), + ConstString("Properties for the OHOS platform plug-in."), + is_global_setting); + } } Status PlatformOHOS::ConnectRemote(Args &args) { m_device_id.clear(); m_connect_addr = "localhost"; + m_connect_port = 0; if (IsHost()) { return Status("can't connect to the host platform '%s', always connected", @@ -160,7 +202,8 @@ Status PlatformOHOS::ConnectRemote(Args &args) { } if (!m_remote_platform_sp) - m_remote_platform_sp = PlatformSP(new PlatformOHOSRemoteGDBServer()); + m_remote_platform_sp = + PlatformSP(new PlatformOHOSRemoteGDBServer(GetGlobalProperties())); const char *url = args.GetArgumentAtIndex(0); if (!url) @@ -170,25 +213,17 @@ Status PlatformOHOS::ConnectRemote(Args &args) { return Status("Invalid URL: %s", url); Log *log = GetLog(LLDBLog::Platform); - if (PlatformOHOSRemoteGDBServer::IsHostnameDeviceID( - uri->hostname)) { // accepts no (empty) hostname too + if (uri->hostname != "localhost") { m_device_id = uri->hostname.str(); LLDB_LOG(log, "Treating hostname as device id: \"{0}\"", m_device_id); - } else { - m_connect_addr = uri->hostname.str(); - LLDB_LOG(log, "Treating hostname as remote HDC server address: \"{0}\"", - m_connect_addr); } auto error = PlatformLinux::ConnectRemote(args); - if (error.Success()) { - HdcClient hdc(m_connect_addr); - error = HdcClient::CreateByDeviceID(m_device_id, hdc); - if (error.Fail()) - return error; + if (error.Fail()) + return error; - m_device_id = hdc.GetDeviceID(); - } + HdcClient::Create(GetGlobalProperties(), m_connect_addr, m_connect_port, + m_device_id, error); return error; } diff --git a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.h b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.h index 4ad5c4c23894b1560dc5c023915b5a844ea8fa76..0803336988d54b1c3a93f252f6f66fdf134c0739 100644 --- a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.h +++ b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.h @@ -25,6 +25,8 @@ public: ~PlatformOHOS() override; + static void DebuggerInitialize(lldb_private::Debugger &debugger); + static void Initialize(); static void Terminate(); @@ -75,6 +77,7 @@ protected: private: std::string m_connect_addr; + uint16_t m_connect_port; std::string m_device_id; uint32_t m_sdk_version; diff --git a/lldb/source/Plugins/Platform/OHOS/PlatformOHOSProperties.td b/lldb/source/Plugins/Platform/OHOS/PlatformOHOSProperties.td new file mode 100644 index 0000000000000000000000000000000000000000..a5b9678c2b3793c55d38278672964bfb5c77b088 --- /dev/null +++ b/lldb/source/Plugins/Platform/OHOS/PlatformOHOSProperties.td @@ -0,0 +1,7 @@ +include "../../../../include/lldb/Core/PropertiesBase.td" + +let Definition = "platformohos" in { + def RemoteHDCServer: Property<"remote-hdc-server", "String">, + DefaultStringValue<"">, + Desc<"Set remote HDC server address to connect to instead of localhost.">; +} diff --git a/lldb/source/Plugins/Platform/OHOS/PlatformOHOSRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/OHOS/PlatformOHOSRemoteGDBServer.cpp index becc789af80ce72e08d9f79e60627842a2b188b0..d0654e5d7a3857e3abc3a5afb02e1fb3f60f2576 100644 --- a/lldb/source/Plugins/Platform/OHOS/PlatformOHOSRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/OHOS/PlatformOHOSRemoteGDBServer.cpp @@ -27,20 +27,11 @@ static const lldb::pid_t g_remote_platform_pid = static uint16_t g_hdc_forward_port_offset = 0; static Status ForwardPortWithHdc( - const std::string &connect_addr, const uint16_t local_port, - const uint16_t remote_port, llvm::StringRef remote_socket_name, - const llvm::Optional &socket_namespace, - std::string &device_id) { + HdcClient &hdc, const uint16_t local_port, const uint16_t remote_port, + llvm::StringRef remote_socket_name, + const llvm::Optional &socket_namespace) { Log *log = GetLog(LLDBLog::Platform); - HdcClient hdc(connect_addr); - auto error = HdcClient::CreateByDeviceID(device_id, hdc); - if (error.Fail()) - return error; - - device_id = hdc.GetDeviceID(); - LLDB_LOGF(log, "Connected to OHOS device \"%s\"", device_id.c_str()); - if (socket_namespace) { LLDB_LOGF(log, "Forwarding remote socket \"%s\" to local TCP port %d", remote_socket_name.str().c_str(), local_port); @@ -57,32 +48,24 @@ static Status ForwardPortWithHdc( return hdc.SetPortForwarding(local_port, remote_port); } -static Status DeleteForwardPortWithHdc(const std::string &connect_addr, - std::pair ports, - const std::string &device_id) { +static Status DeleteForwardPortWithHdc(HdcClient &hdc, + std::pair ports) { Log *log = GetLog(LLDBLog::Platform); LLDB_LOGF(log, "Delete port forwarding %d -> %d, device=%s", ports.first, - ports.second, device_id.c_str()); - - HdcClient hdc(connect_addr, device_id); + ports.second, hdc.GetDeviceID().c_str()); return hdc.DeletePortForwarding(ports); } static Status DeleteForwardPortWithHdc( - const std::string &connect_addr, - std::pair remote_socket, - const llvm::Optional &socket_namespace, - const std::string &device_id) { - + HdcClient &hdc, std::pair remote_socket, + const llvm::Optional &socket_namespace) { Log *log = GetLog(LLDBLog::Platform); uint16_t local_port = remote_socket.first; std::string remote_socket_name = remote_socket.second; LLDB_LOGF(log, "Delete port forwarding %d -> %s, device=%s", local_port, - remote_socket_name.c_str(), device_id.c_str()); + remote_socket_name.c_str(), hdc.GetDeviceID().c_str()); if (!socket_namespace) return Status("Invalid socket namespace"); - - HdcClient hdc(connect_addr, device_id); return hdc.DeletePortForwarding(local_port, remote_socket_name, *socket_namespace); } @@ -106,15 +89,16 @@ static Status FindUnusedPort(uint16_t &port) { return error; } -PlatformOHOSRemoteGDBServer::PlatformOHOSRemoteGDBServer() = default; +PlatformOHOSRemoteGDBServer::PlatformOHOSRemoteGDBServer( + const PlatformOHOSProperties &global_props) + : m_global_props(global_props) {} PlatformOHOSRemoteGDBServer::~PlatformOHOSRemoteGDBServer() { - for (const auto &it : m_port_forwards) { - DeleteForwardPortWithHdc(m_connect_addr, it.second, m_device_id); - } - for (const auto &it_socket : m_remote_socket_name) { - DeleteForwardPortWithHdc(m_connect_addr, it_socket.second, m_socket_namespace, m_device_id); - } + HdcClient hdc(m_connect_addr, m_connect_port, m_device_id); + for (const auto &it : m_port_forwards) + DeleteForwardPortWithHdc(hdc, it.second); + for (const auto &it_socket : m_remote_socket_name) + DeleteForwardPortWithHdc(hdc, it_socket.second, m_socket_namespace); } bool PlatformOHOSRemoteGDBServer::LaunchGDBServer(lldb::pid_t &pid, @@ -126,8 +110,9 @@ bool PlatformOHOSRemoteGDBServer::LaunchGDBServer(lldb::pid_t &pid, Log *log = GetLog(LLDBLog::Platform); + HdcClient hdc(m_connect_addr, m_connect_port, m_device_id); auto error = - MakeConnectURL(pid, remote_port, socket_name.c_str(), connect_url); + MakeConnectURL(hdc, pid, remote_port, socket_name.c_str(), connect_url); if (error.Success()) LLDB_LOGF(log, "gdbserver connect URL: %s", connect_url.c_str()); @@ -139,23 +124,6 @@ bool PlatformOHOSRemoteGDBServer::KillSpawnedProcess(lldb::pid_t pid) { return m_gdb_client_up->KillSpawnedProcess(pid); } -bool IsValidIPv4(llvm::StringRef ip) { - std::string pattern = "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; - llvm::Regex regex(pattern); - return regex.match(ip); -} - -bool IsValidIPv6(llvm::StringRef ip) { - std::string pattern = "^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$"; - llvm::Regex regex(pattern); - return regex.match(ip); -} - -bool PlatformOHOSRemoteGDBServer::IsHostnameDeviceID(llvm::StringRef hostname) { - return hostname != "localhost" && !IsValidIPv4(hostname) && - !IsValidIPv6(hostname); -} - Status PlatformOHOSRemoteGDBServer::ConnectRemote(Args &args) { m_device_id.clear(); m_connect_addr = "localhost"; @@ -173,13 +141,9 @@ Status PlatformOHOSRemoteGDBServer::ConnectRemote(Args &args) { return Status("Invalid URL: %s", url); Log *log = GetLog(LLDBLog::Platform); - if (IsHostnameDeviceID(uri->hostname)) { // accepts no (empty) hostname too + if (uri->hostname != "localhost") { m_device_id = uri->hostname.str(); LLDB_LOG(log, "Treating hostname as device id: \"{0}\"", m_device_id); - } else { - m_connect_addr = uri->hostname.str(); - LLDB_LOG(log, "Treating hostname as remote HDC server address: \"{0}\"", - m_connect_addr); } m_socket_namespace.reset(); @@ -188,10 +152,17 @@ Status PlatformOHOSRemoteGDBServer::ConnectRemote(Args &args) { else if (uri->scheme == "unix-abstract-connect") m_socket_namespace = HdcClient::UnixSocketNamespaceAbstract; + Status error; + auto hdc = HdcClient::Create(m_global_props, m_connect_addr, m_connect_port, + m_device_id, error); + if (error.Fail()) + return error; + + LLDB_LOGF(log, "Connected to OHOS device \"%s\"", m_device_id.c_str()); + std::string connect_url; - auto error = - MakeConnectURL(g_remote_platform_pid, uri->port ? (*uri->port) : 0, - uri->path, connect_url); + error = MakeConnectURL(hdc, g_remote_platform_pid, + uri->port ? (*uri->port) : 0, uri->path, connect_url); if (error.Fail()) return error; @@ -214,36 +185,37 @@ Status PlatformOHOSRemoteGDBServer::DisconnectRemote() { void PlatformOHOSRemoteGDBServer::DeleteForwardPort(lldb::pid_t pid) { Log *log = GetLog(LLDBLog::Platform); + HdcClient hdc(m_connect_addr, m_connect_port, m_device_id); auto it = m_port_forwards.find(pid); auto it_socket = m_remote_socket_name.find(pid); if (it != m_port_forwards.end() && it->second.second != 0) { - const auto error = - DeleteForwardPortWithHdc(m_connect_addr, it->second, m_device_id); + const auto error = DeleteForwardPortWithHdc(hdc, it->second); if (error.Fail()) { - LLDB_LOGF(log, "Failed to delete port forwarding (pid=%" PRIu64 + LLDB_LOGF(log, + "Failed to delete port forwarding (pid=%" PRIu64 ", fwd=(%d -> %d), device=%s): %s", pid, it->second.first, it->second.second, m_device_id.c_str(), error.AsCString()); } m_port_forwards.erase(it); } - - if(it_socket != m_remote_socket_name.end()) { - const auto error_Socket = DeleteForwardPortWithHdc( - m_connect_addr, it_socket->second, m_socket_namespace, m_device_id); + + if (it_socket != m_remote_socket_name.end()) { + const auto error_Socket = + DeleteForwardPortWithHdc(hdc, it_socket->second, m_socket_namespace); if (error_Socket.Fail()) { LLDB_LOGF(log, "Failed to delete port forwarding (pid=%" PRIu64 ", fwd=(%d->%s)device=%s): %s", pid, it_socket->second.first, it_socket->second.second.c_str(), m_device_id.c_str(),error_Socket.AsCString()); } m_remote_socket_name.erase(it_socket); } - + return; } Status PlatformOHOSRemoteGDBServer::MakeConnectURL( - const lldb::pid_t pid, const uint16_t remote_port, + HdcClient &hdc, const lldb::pid_t pid, const uint16_t remote_port, llvm::StringRef remote_socket_name, std::string &connect_url) { static const int kAttempsNum = 5; @@ -257,9 +229,8 @@ Status PlatformOHOSRemoteGDBServer::MakeConnectURL( if (error.Fail()) return error; - error = - ForwardPortWithHdc(m_connect_addr, local_port, remote_port, - remote_socket_name, m_socket_namespace, m_device_id); + error = ForwardPortWithHdc(hdc, local_port, remote_port, remote_socket_name, + m_socket_namespace); if (error.Success()) { if (!m_socket_namespace){ m_port_forwards[pid] = {local_port, remote_port}; @@ -298,8 +269,12 @@ lldb::ProcessSP PlatformOHOSRemoteGDBServer::ConnectProcess( // If m_connect_addr is remote, this connects to a remote HDC server, assuming // that all of the needed ports are open + HdcClient hdc(m_connect_addr, m_connect_port); + error = HdcClient::CreateByDeviceID(m_device_id, hdc); + if (error.Fail()) + return nullptr; std::string new_connect_url; - error = MakeConnectURL(s_remote_gdbserver_fake_pid--, + error = MakeConnectURL(hdc, s_remote_gdbserver_fake_pid--, (*uri->port) ? (*uri->port) : 0, uri->path, new_connect_url); if (error.Fail()) diff --git a/lldb/source/Plugins/Platform/OHOS/PlatformOHOSRemoteGDBServer.h b/lldb/source/Plugins/Platform/OHOS/PlatformOHOSRemoteGDBServer.h index a4ba2e16d3ed6b764d3359fd91e7d75d487d4645..a28618fee09ada4deb0cb32bdab3dba7741de003 100644 --- a/lldb/source/Plugins/Platform/OHOS/PlatformOHOSRemoteGDBServer.h +++ b/lldb/source/Plugins/Platform/OHOS/PlatformOHOSRemoteGDBServer.h @@ -24,7 +24,7 @@ namespace platform_ohos { class PlatformOHOSRemoteGDBServer : public platform_gdb_server::PlatformRemoteGDBServer { public: - PlatformOHOSRemoteGDBServer(); + PlatformOHOSRemoteGDBServer(const PlatformOHOSProperties &global_props); ~PlatformOHOSRemoteGDBServer() override; @@ -44,10 +44,12 @@ public: protected: std::string m_connect_addr; + uint16_t m_connect_port; std::string m_device_id; std::map> m_port_forwards; std::map> m_remote_socket_name; llvm::Optional m_socket_namespace; + const PlatformOHOSProperties &m_global_props; bool LaunchGDBServer(lldb::pid_t &pid, std::string &connect_url) override; @@ -55,7 +57,8 @@ protected: void DeleteForwardPort(lldb::pid_t pid); - Status MakeConnectURL(const lldb::pid_t pid, const uint16_t remote_port, + Status MakeConnectURL(HdcClient &hdc, const lldb::pid_t pid, + const uint16_t remote_port, llvm::StringRef remote_socket_name, std::string &connect_url);