From 1964f8c0725a67f2cc86cd015efac8ba9e048bf5 Mon Sep 17 00:00:00 2001 From: yuyanqinghw Date: Mon, 18 Mar 2024 19:20:36 +0800 Subject: [PATCH] code optimization Signed-off-by: yuyanqinghw --- BUILD.gn | 6 +++++- hiperf.gni | 5 +++++ src/symbols_file.cpp | 16 ++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 1a347cf..0f9faee 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -195,7 +195,6 @@ ohos_source_set("hiperf_platform_common") { if (is_ohos) { external_deps = [ - "ability_base:extractortool", "c_utils:utils", "faultloggerd:libunwinder_static", "hilog:libhilog", @@ -210,6 +209,11 @@ ohos_source_set("hiperf_platform_common") { ] defines += [ "BUNDLE_FRAMEWORK_ENABLE" ] } + if (ability_base_enable) { + external_deps += [ + "ability_base:extractortool", + ] + } } else { external_deps = [ "faultloggerd:unwinder_host" ] defines += [ "CONFIG_NO_HILOG" ] diff --git a/hiperf.gni b/hiperf.gni index bee470d..cb7906e 100644 --- a/hiperf.gni +++ b/hiperf.gni @@ -32,10 +32,15 @@ declare_args() { hiperf_code_analyze = false hiperf_use_syspara = true bundle_framework_enable = false + ability_base_enable = false if (defined(global_parts_info) && defined(global_parts_info.bundlemanager_bundle_framework)) { bundle_framework_enable = true } + if (defined(global_parts_info) && + defined(global_parts_info.ability_ability_base)) { + ability_base_enable = true + } } code_check_flag = [] diff --git a/src/symbols_file.cpp b/src/symbols_file.cpp index 11fb565..0bd80ae 100644 --- a/src/symbols_file.cpp +++ b/src/symbols_file.cpp @@ -1248,20 +1248,16 @@ std::unique_ptr SymbolsFile::LoadSymbolsFromSaved( symbolsFile->textExecVaddrFileOffset_ = symbolFileStruct.textExecVaddrFileOffset_; symbolsFile->buildId_ = symbolFileStruct.buildId_; for (auto &symbolStruct : symbolFileStruct.symbolStructs_) { - if (isHapSymbolFile) { - symbolsFile->symbolsMap_.insert(std::make_pair( - symbolStruct.vaddr_, // should use pc. or fileVaddr. - DfxSymbol(symbolStruct.vaddr_, - symbolStruct.len_, - symbolStruct.symbolName_, - symbolFileStruct.filePath_) - )); - symbolsFile->SetBoolValue(true); - } symbolsFile->symbols_.emplace_back(symbolStruct.vaddr_, symbolStruct.len_, symbolStruct.symbolName_, symbolFileStruct.filePath_); } symbolsFile->AdjustSymbols(); // reorder + if (isHapSymbolFile) { + for (const auto& symbol : symbolsFile->symbols_) { + symbolsFile->symbolsMap_.emplace(symbol.funcVaddr_, symbol); + } + symbolsFile->SetBoolValue(true); + } symbolsFile->debugInfoLoadResult_ = true; symbolsFile->symbolsLoaded_ = true; // all ready LoadFrom perf.data HLOGV("load %zu symbol from SymbolFileStruct for file '%s'", symbolsFile->symbols_.size(),