From b7f406a1c15a8b5b337af40e1caf8f0c8a90dc6c Mon Sep 17 00:00:00 2001 From: yaofeng wang Date: Sat, 24 Sep 2022 15:07:41 +0800 Subject: [PATCH] fix longtime waiting while attach to remote process Signed-off-by: yaofeng wang --- lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp index d28a73e3ec0d..68f22d232744 100644 --- a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp +++ b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp @@ -30,6 +30,7 @@ using namespace std::chrono; static uint32_t g_initialize_count = 0; static const unsigned int g_ohos_default_cache_size = 2048; // Fits inside 4k adb packet. +static constexpr uint32_t INVALID_SDK_VERSION = 0xFFFFFFFF; LLDB_PLUGIN_DEFINE(PlatformOHOS) @@ -242,7 +243,7 @@ uint32_t PlatformOHOS::GetSdkVersion() { std::string version_string; HdcClient hdc(m_device_id); Status error = - hdc.Shell("getprop ro.build.version.sdk", seconds(5), &version_string); + hdc.Shell("param get const.ohos.apiversion", seconds(5), &version_string); version_string = llvm::StringRef(version_string).trim().str(); if (error.Fail() || version_string.empty()) { @@ -250,10 +251,15 @@ uint32_t PlatformOHOS::GetSdkVersion() { if (log) log->Printf("Get SDK version failed. (error: %s, output: %s)", error.AsCString(), version_string.c_str()); + m_sdk_version = INVALID_SDK_VERSION; + return 0; + } + + m_sdk_version = StringConvert::ToUInt32(version_string.c_str(), INVALID_SDK_VERSION); + if (m_sdk_version == INVALID_SDK_VERSION) { return 0; } - m_sdk_version = StringConvert::ToUInt32(version_string.c_str()); return m_sdk_version; } -- Gitee