From 2de81e042a9c4a45796be9b25f5e12453cc64861 Mon Sep 17 00:00:00 2001 From: yaofeng wang Date: Fri, 16 Dec 2022 21:49:15 +0800 Subject: [PATCH] Create multiple sync-services for multiple threads avoid crashing while access same connection Issue: I66DKR Test: Build & lldb with attach command & Deveco debug native app Signed-off-by: yaofeng wang --- lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp | 9 +++------ lldb/source/Plugins/Platform/HOS/PlatformHOS.h | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp b/lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp index d5be96da944a..d69bef24f212 100644 --- a/lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp +++ b/lldb/source/Plugins/Platform/HOS/PlatformHOS.cpp @@ -456,11 +456,8 @@ PlatformHOS::GetLibdlFunctionDeclarations(lldb_private::Process *process) { return PlatformPOSIX::GetLibdlFunctionDeclarations(process); } -HdcClient::SyncService *PlatformHOS::GetSyncService(Status &error) { - if (m_adb_sync_svc && m_adb_sync_svc->IsConnected()) - return m_adb_sync_svc.get(); - +std::unique_ptr PlatformHOS::GetSyncService(Status &error) { HdcClient hdc(m_device_id); - m_adb_sync_svc = hdc.GetSyncService(error); - return (error.Success()) ? m_adb_sync_svc.get() : nullptr; + std::unique_ptr adb_sync_svc = hdc.GetSyncService(error); + return (error.Success()) ? std::move(adb_sync_svc) : nullptr; } diff --git a/lldb/source/Plugins/Platform/HOS/PlatformHOS.h b/lldb/source/Plugins/Platform/HOS/PlatformHOS.h index 07057ab83e26..40e291a2d35f 100644 --- a/lldb/source/Plugins/Platform/HOS/PlatformHOS.h +++ b/lldb/source/Plugins/Platform/HOS/PlatformHOS.h @@ -69,9 +69,8 @@ protected: GetLibdlFunctionDeclarations(lldb_private::Process *process) override; private: - HdcClient::SyncService *GetSyncService(Status &error); + std::unique_ptr GetSyncService(Status &error); - std::unique_ptr m_adb_sync_svc; std::string m_device_id; uint32_t m_sdk_version; }; -- Gitee