From ac846e9e73fbe64901704bb4da8dcc5788192833 Mon Sep 17 00:00:00 2001 From: yuyanqinghw Date: Thu, 14 Aug 2025 10:07:57 +0800 Subject: [PATCH 1/8] adapt sandbox output path Signed-off-by: yuyanqinghw --- BUILD.gn | 16 +++--- bundle.json | 3 ++ etc/hiperf.cfg | 2 +- hiperf.gni | 1 + include/subcommand_record.h | 8 +++ include/subcommand_stat.h | 4 ++ include/utilities.h | 2 + src/subcommand_record.cpp | 25 ++++++++- src/subcommand_stat.cpp | 6 ++- src/utilities.cpp | 53 +++++++++++++++++++ test/BUILD.gn | 4 ++ .../common/native/subcommand_record_test.cpp | 7 +++ .../common/native/subcommand_stat_test.cpp | 9 +++- 13 files changed, 129 insertions(+), 11 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 677648e..5232e1d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -135,9 +135,7 @@ sources_platform_with_ts_common = [ ] if (hiperf_debug) { - sources_platform_with_ts_common += [ - "./src/debug_logger.cpp", - ] + sources_platform_with_ts_common += [ "./src/debug_logger.cpp" ] } sources_platform_common = [ @@ -157,9 +155,7 @@ if (is_ohos) { } if (hiperf_debug) { - sources_platform_common += [ - "./src/option_debug.cpp", - ] + sources_platform_common += [ "./src/option_debug.cpp" ] } sources_platform_linux = [ @@ -226,6 +222,9 @@ ohos_source_set("hiperf_platform_common") { "samgr:samgr_proxy", ] defines += [ "CONFIG_HAS_CCM" ] + if (hiperf_sandbox_log_patch_mapping) { + defines += [ "is_sandbox_mapping=${hiperf_sandbox_log_patch_mapping}" ] + } if (bundle_framework_enable) { external_deps += [ "bundle_framework:appexecfwk_base", @@ -273,6 +272,9 @@ ohos_source_set("hiperf_platform_linux") { "init:libbegetutil", ] defines = [ "CONFIG_HAS_CCM" ] + if (hiperf_sandbox_log_patch_mapping) { + defines += [ "is_sandbox_mapping=${hiperf_sandbox_log_patch_mapping}" ] + } } else { external_deps = [ "faultloggerd:unwinder_host" ] } @@ -463,7 +465,7 @@ ohos_executable("hiperf") { ohos_executable("hiperf_host") { sources = [ "./src/main.cpp" ] - + deps = [ ":hiperf_platform_common" ] external_deps = [ diff --git a/bundle.json b/bundle.json index 6443937..9d12e2a 100644 --- a/bundle.json +++ b/bundle.json @@ -12,6 +12,9 @@ "component": { "name": "hiperf", "subsystem": "developtools", + "features": [ + "hiperf_sandbox_log_patch_mapping" + ], "adapted_system_type": [ "standard" ], diff --git a/etc/hiperf.cfg b/etc/hiperf.cfg index a87ab47..cdd12e5 100644 --- a/etc/hiperf.cfg +++ b/etc/hiperf.cfg @@ -2,7 +2,7 @@ "jobs": [{ "name": "post-fs-data", "cmds": [ - "mkdir /data/log/hiperflog 0770 shell shell", + "mkdir /data/log/hiperflog 0777 shell shell", "restorecon /data/log/hiperflog", "chmod 0666 /dev/lperf" ] diff --git a/hiperf.gni b/hiperf.gni index 8123bff..5d5ae80 100644 --- a/hiperf.gni +++ b/hiperf.gni @@ -34,6 +34,7 @@ declare_args() { hiperf_independent_compilation = true bundle_framework_enable = false ability_base_enable = false + hiperf_sandbox_log_patch_mapping = false if (defined(global_parts_info) && defined(global_parts_info.bundlemanager_bundle_framework)) { bundle_framework_enable = true diff --git a/include/subcommand_record.h b/include/subcommand_record.h index 14eea9b..2480223 100644 --- a/include/subcommand_record.h +++ b/include/subcommand_record.h @@ -169,7 +169,11 @@ public: " --data-limit \n" " Stop recording after SIZE bytes of records. Default is unlimited.\n" " -o \n" +#if defined(is_sandbox_mapping) && is_sandbox_mapping + " Set output file name, default is $TMPDIR/perf.data.\n" +#else " Set output file name, default is /data/local/tmp/perf.data.\n" +#endif " -z\n" " Compress record data.\n" " --restart\n" @@ -248,7 +252,11 @@ private: int cmdlinesSize_ = DEFAULT_SAVED_CMDLINES_SIZE; int oldCmdlinesSize_ = 0; std::vector symbolDir_ = {}; +#if defined(is_sandbox_mapping) && is_sandbox_mapping + std::string outputFilename_ = GetDefaultPathByEnv("perf.data"); +#else std::string outputFilename_ = "/data/local/tmp/perf.data"; +#endif std::string appPackage_ = {}; int checkAppMs_ = DEFAULT_CHECK_APP_MS; std::string clockId_ = {}; diff --git a/include/subcommand_stat.h b/include/subcommand_stat.h index 6adfc88..2958f6e 100644 --- a/include/subcommand_stat.h +++ b/include/subcommand_stat.h @@ -90,7 +90,11 @@ public: " start: start counting\n" " stop: stop counting\n" " -o \n" +#if defined(is_sandbox_mapping) && is_sandbox_mapping + " Set output file name, default is $TMPDIR/perf_stat.txt.\n" +#else " Set output file name, default is /data/local/tmp/perf_stat.txt.\n" +#endif " Only restrain using with --control prepare.\n" // clang-format on ), diff --git a/include/utilities.h b/include/utilities.h index 8dca5e7..ab96ec2 100644 --- a/include/utilities.h +++ b/include/utilities.h @@ -418,6 +418,8 @@ cJSON* ParseJson(const std::string &filePath); bool GetJsonNum(cJSON* tag, const char* key, size_t &value); bool GetCfgValue(const char* cfgPath, const char* cfgKey, size_t &value); #endif + +std::string GetDefaultPathByEnv(const std::string fileType); } // namespace HiPerf } // namespace Developtools } // namespace OHOS diff --git a/src/subcommand_record.cpp b/src/subcommand_record.cpp index b1f53e4..373ae1c 100644 --- a/src/subcommand_record.cpp +++ b/src/subcommand_record.cpp @@ -1676,9 +1676,14 @@ HiperfError SubCommandRecord::OnSubCommand(std::vector& args) ChildResponseToMain(false); CloseClientThread(); } +#if defined(is_sandbox_mapping) && is_sandbox_mapping + HLOGE("Fail to create record file"); + HIPERF_HILOGE(MODULE_DEFAULT, "[OnSubCommand] Fail to create record file"); +#else HLOGE("Fail to create record file %s", outputFilename_.c_str()); HIPERF_HILOGE(MODULE_DEFAULT, "[OnSubCommand] Fail to create record file %{public}s", outputFilename_.c_str()); +#endif return HiperfError::CREATE_OUTPUT_FILE_FAIL; } HIPERF_HILOGI(MODULE_DEFAULT, "[OnSubCommand] CreateInitRecordFile finished"); @@ -1725,8 +1730,13 @@ HiperfError SubCommandRecord::OnSubCommand(std::vector& args) startSaveFileTimes_ = steady_clock::now(); if (!backtrack_) { if (!FinishWriteRecordFile()) { +#if defined(is_sandbox_mapping) && is_sandbox_mapping + HLOGE("Fail to finish record file"); + HIPERF_HILOGE(MODULE_DEFAULT, "Fail to finish record file"); +#else HLOGE("Fail to finish record file %s", outputFilename_.c_str()); HIPERF_HILOGE(MODULE_DEFAULT, "Fail to finish record file %{public}s", outputFilename_.c_str()); +#endif return HiperfError::FINISH_WRITE_RECORD_FILE_FAIL; } else if (!PostProcessRecordFile()) { HLOGE("Fail to post process record file"); @@ -2079,8 +2089,11 @@ bool SubCommandRecord::CreateInitRecordFile(bool compressData) CHECK_TRUE(fileWriter_->WriteAttrAndId(perfEvents_.GetAttrWithId(), isSpe_), false, 0, ""); CHECK_TRUE(AddFeatureRecordFile(), false, 0, ""); - +#if defined(is_sandbox_mapping) && is_sandbox_mapping + HLOGD("create new record file"); +#else HLOGD("create new record file %s", outputFilename_.c_str()); +#endif return true; } @@ -2102,14 +2115,22 @@ bool SubCommandRecord::PostProcessRecordFile() fileWriter_.reset(); if (!CreateInitRecordFile(compressData_)) { // create again +#if defined(is_sandbox_mapping) && is_sandbox_mapping + HLOGEP("Fail to open data file"); +#else HLOGEP("Fail to open data file %s ", outputFilename_.c_str()); +#endif return false; } // read temp file auto fileReader = PerfFileReader::Instance(tempFileName); if (fileReader == nullptr) { +#if defined(is_sandbox_mapping) && is_sandbox_mapping + HLOGEP("Fail to open data file"); +#else HLOGEP("Fail to open data file %s ", tempFileName.c_str()); +#endif return false; } @@ -2412,7 +2433,9 @@ bool SubCommandRecord::OnlineReportData() } std::unique_ptr reporter = std::make_unique(); +#ifndef is_sandbox_mapping HLOGD("report the file %s to report file %s \n", tempFileName.c_str(), outputFilename_.c_str()); +#endif std::vector args; args.emplace_back("-i"); args.emplace_back(tempFileName); diff --git a/src/subcommand_stat.cpp b/src/subcommand_stat.cpp index 41db0ee..4f64612 100644 --- a/src/subcommand_stat.cpp +++ b/src/subcommand_stat.cpp @@ -37,7 +37,11 @@ const uint16_t THOUSANDS_SEPARATOR = 3; namespace OHOS { namespace Developtools { namespace HiPerf { +#if defined(is_sandbox_mapping) && is_sandbox_mapping +const std::string DEFAULT_STAT_FILE = GetDefaultPathByEnv("perf_stat.txt"); +#else const std::string DEFAULT_STAT_FILE = "/data/local/tmp/perf_stat.txt"; +#endif // when there are many events, start record will take more time. const std::chrono::milliseconds CONTROL_WAITREPY_TIMEOUT = 2000ms; static std::map thread_map_; @@ -911,7 +915,7 @@ HiperfError SubCommandStat::CheckStatOption() if (!CheckRestartOption(appPackage_, targetSystemWide_, restart_, selectPids_)) { return HiperfError::CHECK_RESTART_OPTION_FAIL; } - + // check option if (!CheckSelectCpuPidOption()) { return HiperfError::CHECK_SELECT_CPU_PID_FAIL; diff --git a/src/utilities.cpp b/src/utilities.cpp index 696b783..98327d7 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -1074,6 +1074,59 @@ void AgeHiperflogFiles() } #endif } + +bool IsHiShellLabel() +{ +#if defined(is_sandbox_mapping) && is_sandbox_mapping + pid_t ppid = syscall(SYS_getppid); + char buf[DEFAULT_STRING_BUF_SIZE] = ""; + if (snprintf_s(buf, sizeof(buf), sizeof(buf) - 1, "/proc/%d/attr/current", ppid) < 0) { + HLOGE("get buf failed, pid is %d", ppid); + return false; + } + + const char* attrName = "security.selinux"; + ssize_t attrSize = getxattr(buf, attrName, nullptr, 0); + if (attrSize == 0 || attrSize == - 1) { + return false; + } + char* attrValue = new(std::nothrow) char[attrSize]; + if (attrValue == nullptr) { + return false; + } + if (getxattr(buf, attrName, attrValue, attrSize) == -1) { + delete []attrValue; + return false; + } + string label(attrValue, attrSize - 1); + delete []attrValue; + return label == "u:r:hishell_hap:s0"; +#else + return false; +#endif +} + +std::string GetDefaultPathByEnv(const std::string fileType) +{ + std::string outputFilename = "/data/local/tmp/" + fileType; +#if defined(is_sandbox_mapping) && is_sandbox_mapping + if (IsHiShellLabel()) { + char* outputPathEnv = std::getenv("TMPDIR"); + if (outputPathEnv != nullptr && strlen(outputPathEnv) > 0) { + std::string tmpFilename = outputPathEnv; + std::string fileName = StringEndsWith(outputFilename, "/") ? fileType : "/" + fileType; + tmpFilename += fileName; + outputFilename = CanonicalizeSpecPath(tmpFilename); + HIPERF_HILOGI(MODULE_DEFAULT, "get TMPDIR env success"); + } else { + HIPERF_HILOGE(MODULE_DEFAULT, "get TMPDIR env failed"); + } + } + return outputFilename; +#else + return outputFilename; +#endif +} } // namespace HiPerf } // namespace Developtools } // namespace OHOS diff --git a/test/BUILD.gn b/test/BUILD.gn index aabe9d0..f50ed4e 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -113,6 +113,10 @@ ohos_unittest("hiperf_unittest") { "CONFIG_HAS_CCM", ] + if (hiperf_sandbox_log_patch_mapping) { + defines += [ "is_sandbox_mapping=${hiperf_sandbox_log_patch_mapping}" ] + } + public_deps = [] external_deps = [ "abseil-cpp:absl_container", diff --git a/test/unittest/common/native/subcommand_record_test.cpp b/test/unittest/common/native/subcommand_record_test.cpp index 32f6c87..b4eb1e3 100644 --- a/test/unittest/common/native/subcommand_record_test.cpp +++ b/test/unittest/common/native/subcommand_record_test.cpp @@ -2544,6 +2544,13 @@ HWTEST_F(SubCommandRecordTest, UpdateDevHostMaps4, TestSize.Level1) cmd.UpdateDevHostMaps(recordIn); EXPECT_EQ(recordIn.data_.addr, addr); } + +HWTEST_F(SubCommandRecordTest, CheckPcRecordPath, TestSize.Level1) +{ + SubCommandRecord cmd; + string defaultName = "/data/local/tmp/perf.data"; + EXPECT_EQ(cmd.outputFilename_, defaultName); +} } // namespace HiPerf } // namespace Developtools } // namespace OHOS diff --git a/test/unittest/common/native/subcommand_stat_test.cpp b/test/unittest/common/native/subcommand_stat_test.cpp index c87c083..8faced5 100644 --- a/test/unittest/common/native/subcommand_stat_test.cpp +++ b/test/unittest/common/native/subcommand_stat_test.cpp @@ -2451,7 +2451,7 @@ HWTEST_F(SubCommandStatTest, TestOnSubCommand_control05, TestSize.Level1) const std::string expectedStr = "was not stopped within 30 seconds"; std::string tempOutputFile = "/data/local/tmp/stat_test_output.tmp"; std::string cmdWithOutput = testCmd + " > " + tempOutputFile + " 2>&1"; - + int ret = system((cmdWithOutput + " &").c_str()); ASSERT_EQ(ret, 0); @@ -2518,6 +2518,13 @@ HWTEST_F(SubCommandStatTest, OutPutFileName02, TestSize.Level1) EXPECT_EQ(CheckTraceCommandOutput("hiperf stat --control prepare -a -o /data/log/hiperflog/stat.txt", {"Invalid output file path, permission denied"}), true); } + +HWTEST_F(SubCommandStatTest, CheckPcStatPath, TestSize.Level1) +{ + std::string defaultName = "/data/local/tmp/perf_stat.txt"; + std::string outputPath = GetDefaultPathByEnv("perf_stat.txt"); + EXPECT_EQ(defaultName, outputPath); +} } // namespace HiPerf } // namespace Developtools } // namespace OHOS -- Gitee From 9d6c1547ca63c7b0d8f2b06d847dff0635ff6865 Mon Sep 17 00:00:00 2001 From: yuyanqinghw Date: Thu, 14 Aug 2025 19:42:01 +0800 Subject: [PATCH 2/8] adapt sandbox output path Signed-off-by: yuyanqinghw --- src/utilities.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utilities.cpp b/src/utilities.cpp index 98327d7..f6e5f24 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -25,6 +25,10 @@ #include #endif +#if defined(is_ohos) && is_ohos +#include +#endif + #ifdef CONFIG_HAS_CCM #include "config_policy_utils.h" #endif @@ -1098,7 +1102,7 @@ bool IsHiShellLabel() delete []attrValue; return false; } - string label(attrValue, attrSize - 1); + std::string label(attrValue, attrSize - 1); delete []attrValue; return label == "u:r:hishell_hap:s0"; #else @@ -1116,7 +1120,7 @@ std::string GetDefaultPathByEnv(const std::string fileType) std::string tmpFilename = outputPathEnv; std::string fileName = StringEndsWith(outputFilename, "/") ? fileType : "/" + fileType; tmpFilename += fileName; - outputFilename = CanonicalizeSpecPath(tmpFilename); + outputFilename = CanonicalizeSpecPath(tmpFilename.c_str()); HIPERF_HILOGI(MODULE_DEFAULT, "get TMPDIR env success"); } else { HIPERF_HILOGE(MODULE_DEFAULT, "get TMPDIR env failed"); -- Gitee From 28eec44628fa317866b614cf8e5e2b19500a65ce Mon Sep 17 00:00:00 2001 From: yuyanqinghw Date: Thu, 14 Aug 2025 21:13:56 +0800 Subject: [PATCH 3/8] adapt sandbox output path Signed-off-by: yuyanqinghw --- include/subcommand_record.h | 2 +- include/subcommand_stat.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/subcommand_record.h b/include/subcommand_record.h index 2480223..11081b1 100644 --- a/include/subcommand_record.h +++ b/include/subcommand_record.h @@ -170,7 +170,7 @@ public: " Stop recording after SIZE bytes of records. Default is unlimited.\n" " -o \n" #if defined(is_sandbox_mapping) && is_sandbox_mapping - " Set output file name, default is $TMPDIR/perf.data.\n" + " Set output file name, default is " + GetDefaultPathByEnv("perf.data") + ".\n" #else " Set output file name, default is /data/local/tmp/perf.data.\n" #endif diff --git a/include/subcommand_stat.h b/include/subcommand_stat.h index 2958f6e..5800231 100644 --- a/include/subcommand_stat.h +++ b/include/subcommand_stat.h @@ -91,7 +91,7 @@ public: " stop: stop counting\n" " -o \n" #if defined(is_sandbox_mapping) && is_sandbox_mapping - " Set output file name, default is $TMPDIR/perf_stat.txt.\n" + " Set output file name, default is " + GetDefaultPathByEnv("perf_stat.txt") + ".\n" #else " Set output file name, default is /data/local/tmp/perf_stat.txt.\n" #endif -- Gitee From 44620f6ae1356e76fe1053e804564de29ffeb0d1 Mon Sep 17 00:00:00 2001 From: yuyanqinghw Date: Tue, 19 Aug 2025 09:59:58 +0800 Subject: [PATCH 4/8] adapt sandbox output path Signed-off-by: yuyanqinghw --- src/utilities.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utilities.cpp b/src/utilities.cpp index f6e5f24..eff0e60 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -1123,13 +1123,12 @@ std::string GetDefaultPathByEnv(const std::string fileType) outputFilename = CanonicalizeSpecPath(tmpFilename.c_str()); HIPERF_HILOGI(MODULE_DEFAULT, "get TMPDIR env success"); } else { + outputFilename = "/storage/Users/currentUser/" + fileType; HIPERF_HILOGE(MODULE_DEFAULT, "get TMPDIR env failed"); } } - return outputFilename; -#else - return outputFilename; #endif + return outputFilename; } } // namespace HiPerf } // namespace Developtools -- Gitee From c5240ed9c994bf7a7d27d7a078a2a72e06edcd63 Mon Sep 17 00:00:00 2001 From: yuyanqinghw Date: Tue, 19 Aug 2025 14:55:52 +0800 Subject: [PATCH 5/8] adapt sandbox output path Signed-off-by: yuyanqinghw --- src/subcommand_record.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/subcommand_record.cpp b/src/subcommand_record.cpp index 373ae1c..d857445 100644 --- a/src/subcommand_record.cpp +++ b/src/subcommand_record.cpp @@ -1676,14 +1676,9 @@ HiperfError SubCommandRecord::OnSubCommand(std::vector& args) ChildResponseToMain(false); CloseClientThread(); } -#if defined(is_sandbox_mapping) && is_sandbox_mapping - HLOGE("Fail to create record file"); - HIPERF_HILOGE(MODULE_DEFAULT, "[OnSubCommand] Fail to create record file"); -#else HLOGE("Fail to create record file %s", outputFilename_.c_str()); HIPERF_HILOGE(MODULE_DEFAULT, "[OnSubCommand] Fail to create record file %{public}s", outputFilename_.c_str()); -#endif return HiperfError::CREATE_OUTPUT_FILE_FAIL; } HIPERF_HILOGI(MODULE_DEFAULT, "[OnSubCommand] CreateInitRecordFile finished"); @@ -1730,13 +1725,8 @@ HiperfError SubCommandRecord::OnSubCommand(std::vector& args) startSaveFileTimes_ = steady_clock::now(); if (!backtrack_) { if (!FinishWriteRecordFile()) { -#if defined(is_sandbox_mapping) && is_sandbox_mapping - HLOGE("Fail to finish record file"); - HIPERF_HILOGE(MODULE_DEFAULT, "Fail to finish record file"); -#else HLOGE("Fail to finish record file %s", outputFilename_.c_str()); HIPERF_HILOGE(MODULE_DEFAULT, "Fail to finish record file %{public}s", outputFilename_.c_str()); -#endif return HiperfError::FINISH_WRITE_RECORD_FILE_FAIL; } else if (!PostProcessRecordFile()) { HLOGE("Fail to post process record file"); -- Gitee From dac5470f43021687f225d31c415bb8e36b23e242 Mon Sep 17 00:00:00 2001 From: yuyanqinghw Date: Wed, 20 Aug 2025 14:35:03 +0800 Subject: [PATCH 6/8] adapt sandbox output path Signed-off-by: yuyanqinghw --- src/debug_logger.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/debug_logger.cpp b/src/debug_logger.cpp index d314945..fb260ac 100644 --- a/src/debug_logger.cpp +++ b/src/debug_logger.cpp @@ -19,12 +19,18 @@ #if defined(is_ohos) && is_ohos #include "hiperf_hilog.h" #endif +#include "utilities.h" namespace OHOS { namespace Developtools { namespace HiPerf { -DebugLogger::DebugLogger() : timeStamp_(std::chrono::steady_clock::now()), logPath_(DEFAULT_LOG_PATH) +DebugLogger::DebugLogger() : timeStamp_(std::chrono::steady_clock::now()) { +#if defined(is_sandbox_mapping) && is_sandbox_mapping + logPath_ = GetDefaultPathByEnv("hiperf_log.txt"); +#else + logPath_ = "/data/local/tmp/hiperf_log.txt"; +#endif OpenLog(); } -- Gitee From 5780a1f225a61e336cf2b0427f0e95c9e53f362d Mon Sep 17 00:00:00 2001 From: yuyanqinghw Date: Wed, 27 Aug 2025 11:43:28 +0800 Subject: [PATCH 7/8] adapt sandbox output path Signed-off-by: yuyanqinghw --- BUILD.gn | 8 ++++---- bundle.json | 2 +- hiperf.gni | 2 +- test/BUILD.gn | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 5232e1d..c016b30 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -222,8 +222,8 @@ ohos_source_set("hiperf_platform_common") { "samgr:samgr_proxy", ] defines += [ "CONFIG_HAS_CCM" ] - if (hiperf_sandbox_log_patch_mapping) { - defines += [ "is_sandbox_mapping=${hiperf_sandbox_log_patch_mapping}" ] + if (hiperf_sandbox_log_path_mapping) { + defines += [ "is_sandbox_mapping=${hiperf_sandbox_log_path_mapping}" ] } if (bundle_framework_enable) { external_deps += [ @@ -272,8 +272,8 @@ ohos_source_set("hiperf_platform_linux") { "init:libbegetutil", ] defines = [ "CONFIG_HAS_CCM" ] - if (hiperf_sandbox_log_patch_mapping) { - defines += [ "is_sandbox_mapping=${hiperf_sandbox_log_patch_mapping}" ] + if (hiperf_sandbox_log_path_mapping) { + defines += [ "is_sandbox_mapping=${hiperf_sandbox_log_path_mapping}" ] } } else { external_deps = [ "faultloggerd:unwinder_host" ] diff --git a/bundle.json b/bundle.json index 9d12e2a..12bbd79 100644 --- a/bundle.json +++ b/bundle.json @@ -13,7 +13,7 @@ "name": "hiperf", "subsystem": "developtools", "features": [ - "hiperf_sandbox_log_patch_mapping" + "hiperf_sandbox_log_path_mapping" ], "adapted_system_type": [ "standard" diff --git a/hiperf.gni b/hiperf.gni index 5d5ae80..6393d17 100644 --- a/hiperf.gni +++ b/hiperf.gni @@ -34,7 +34,7 @@ declare_args() { hiperf_independent_compilation = true bundle_framework_enable = false ability_base_enable = false - hiperf_sandbox_log_patch_mapping = false + hiperf_sandbox_log_path_mapping = false if (defined(global_parts_info) && defined(global_parts_info.bundlemanager_bundle_framework)) { bundle_framework_enable = true diff --git a/test/BUILD.gn b/test/BUILD.gn index f50ed4e..518b0a4 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -113,8 +113,8 @@ ohos_unittest("hiperf_unittest") { "CONFIG_HAS_CCM", ] - if (hiperf_sandbox_log_patch_mapping) { - defines += [ "is_sandbox_mapping=${hiperf_sandbox_log_patch_mapping}" ] + if (hiperf_sandbox_log_path_mapping) { + defines += [ "is_sandbox_mapping=${hiperf_sandbox_log_path_mapping}" ] } public_deps = [] -- Gitee From 826af903fdc684834f45c0de43bbc8275017ec22 Mon Sep 17 00:00:00 2001 From: yuyanqinghw Date: Wed, 27 Aug 2025 15:01:57 +0800 Subject: [PATCH 8/8] adapt sandbox output path Signed-off-by: yuyanqinghw --- src/subcommand_record.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/subcommand_record.cpp b/src/subcommand_record.cpp index d857445..4fefb16 100644 --- a/src/subcommand_record.cpp +++ b/src/subcommand_record.cpp @@ -2079,11 +2079,7 @@ bool SubCommandRecord::CreateInitRecordFile(bool compressData) CHECK_TRUE(fileWriter_->WriteAttrAndId(perfEvents_.GetAttrWithId(), isSpe_), false, 0, ""); CHECK_TRUE(AddFeatureRecordFile(), false, 0, ""); -#if defined(is_sandbox_mapping) && is_sandbox_mapping - HLOGD("create new record file"); -#else HLOGD("create new record file %s", outputFilename_.c_str()); -#endif return true; } @@ -2116,11 +2112,7 @@ bool SubCommandRecord::PostProcessRecordFile() // read temp file auto fileReader = PerfFileReader::Instance(tempFileName); if (fileReader == nullptr) { -#if defined(is_sandbox_mapping) && is_sandbox_mapping - HLOGEP("Fail to open data file"); -#else HLOGEP("Fail to open data file %s ", tempFileName.c_str()); -#endif return false; } @@ -2423,9 +2415,7 @@ bool SubCommandRecord::OnlineReportData() } std::unique_ptr reporter = std::make_unique(); -#ifndef is_sandbox_mapping HLOGD("report the file %s to report file %s \n", tempFileName.c_str(), outputFilename_.c_str()); -#endif std::vector args; args.emplace_back("-i"); args.emplace_back(tempFileName); -- Gitee