diff --git a/BUILD.gn b/BUILD.gn index 6ccb95b0165d27f106e63165ca864528bd2b8943..0ebb347defaf4d7abe4838ca0f042ea6918aecfc 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -368,6 +368,13 @@ ohos_executable("hiperf_host") { part_name = "hiperf" } +ohos_prebuilt_etc("hiperf.cfg") { + source = "./config/hiperf.cfg" + relative_install_dir = "init" + subsystem_name = "developtools" + part_name = "hiperf" +} + ohos_source_set("hiperf_platform_host") { part_name = "hiperf" sources = [ "./src/hiperf_libreport.cpp" ] diff --git a/bundle.json b/bundle.json index 375e5ebe7653718b058a3f5b4e278a79da2f8380..e99309f843f7edd5114e7d8acd590bc93782e401 100644 --- a/bundle.json +++ b/bundle.json @@ -30,7 +30,8 @@ "build": { "sub_component": [ "//developtools/hiperf:hiperf_target", - "//developtools/hiperf:hiperf_target_all" + "//developtools/hiperf:hiperf_target_all", + "//developtools/hiperf:hiperf.cfg" ], "inner_kits": [ { diff --git a/config/hiperf.cfg b/config/hiperf.cfg new file mode 100644 index 0000000000000000000000000000000000000000..00f846c936e12d71850f89afeef981c75254cd60 --- /dev/null +++ b/config/hiperf.cfg @@ -0,0 +1,10 @@ +{ + "jobs" : [{ + "name" : "post-init", + "cmds" : [ + "mkdir /data/log/ 0775 system log", + "mkdir /data/log/hiperf/ 0755 shell shell" + ] + } + ] +} diff --git a/include/debug_logger.h b/include/debug_logger.h index b10c3556bce46c1d6b2f647ec7eb18b0e189366f..c1f452d600e46b78a6d82922203fbb2a2493198b 100644 --- a/include/debug_logger.h +++ b/include/debug_logger.h @@ -56,8 +56,8 @@ enum DebugLevel { #ifdef HIPERF_DEBUG #if is_ohos || is_double_framework -const std::string DEFAULT_UT_LOG_DIR = "/data/local/tmp/"; -const std::string DEFAULT_LOG_PATH = "/data/local/tmp/hiperf_log.txt"; +const std::string DEFAULT_UT_LOG_DIR = "/data/log/hiperf/"; +const std::string DEFAULT_LOG_PATH = "/data/log/hiperf/hiperf_log.txt"; #elif is_mingw const std::string DEFAULT_LOG_PATH = ".\\hiperf_log.txt"; #elif is_linux diff --git a/include/subcommand_record.h b/include/subcommand_record.h index 2bb2d670ce75ab6acfbc4b57b06b4716d7538798..545220c32ec2f12dcc20316e0e7da261c2038e00 100644 --- a/include/subcommand_record.h +++ b/include/subcommand_record.h @@ -60,7 +60,7 @@ public: "Usage: hiperf record [options] [command [command-args]]\n" " Collect performance sampling information of running [command].\n" " The default options are: -c --cpu-limit 25 -d 10000.0 -e hw-cpu-cycles\n" - " -f 4000 -m 1024 -o /data/local/tmp/perf.data.\n" + " -f 4000 -m 1024 -o /data/log/hiperf/perf.data.\n" " -a\n" " Collect system-wide information.\n" " for measures all processes/threads\n" @@ -146,7 +146,7 @@ public: " --data-limit \n" " Stop recording after SIZE bytes of records. Default is unlimited.\n" " -o \n" - " Set output file name, default is /data/local/tmp/perf.data.\n" + " Set output file name, default is /data/log/hiperf/perf.data.\n" " -z\n" " Compress record data.\n" " --verbose\n" @@ -188,7 +188,7 @@ private: int cpuPercent_ = DEFAULT_CPU_PERCENT; int mmapPages_ = MAX_PERF_MMAP_PAGE; std::vector symbolDir_ = {}; - std::string outputFilename_ = "/data/local/tmp/perf.data"; + std::string outputFilename_ = "/data/log/hiperf/perf.data"; std::string appPackage_ = {}; int checkAppMs_ = DEFAULT_CHECK_APP_MS; std::string clockId_ = {}; diff --git a/interfaces/innerkits/native/include/hiperf_client.h b/interfaces/innerkits/native/include/hiperf_client.h index 52158a91e599598b5ba3739001c6de50b985f69d..ca6e7c7d1cf5da1237637f162f7248ab66680e96 100644 --- a/interfaces/innerkits/native/include/hiperf_client.h +++ b/interfaces/innerkits/native/include/hiperf_client.h @@ -25,7 +25,7 @@ namespace HiPerf { namespace HiperfClient { static const std::string HiperfCommandName = "hiperf"; static const std::string SystemBinPath = "/system/bin/"; -static const std::string TempBinPath = "/data/local/tmp/"; +static const std::string TempBinPath = "/data/log/hiperf/"; static const std::string CurrentPath = "./"; static const std::string PerfDataName = "perf.data"; diff --git a/src/subcommand_record.cpp b/src/subcommand_record.cpp index 71792ee862eda4af7ae1a0a4cf2e51bae1ffc0ae..7f74b93ae979bd0dd3211f6707c21e58db44425c 100644 --- a/src/subcommand_record.cpp +++ b/src/subcommand_record.cpp @@ -44,8 +44,8 @@ const std::string CONTROL_CMD_START = "start"; const std::string CONTROL_CMD_PAUSE = "pause"; const std::string CONTROL_CMD_RESUME = "resume"; const std::string CONTROL_CMD_STOP = "stop"; -const std::string CONTROL_FIFO_FILE_C2S = "/data/local/tmp/.hiperf_record_control_c2s"; -const std::string CONTROL_FIFO_FILE_S2C = "/data/local/tmp/.hiperf_record_control_s2c"; +const std::string CONTROL_FIFO_FILE_C2S = "/data/log/hiperf/.hiperf_record_control_c2s"; +const std::string CONTROL_FIFO_FILE_S2C = "/data/log/hiperf/.hiperf_record_control_s2c"; // when there are many events, start record will take more time. const std::chrono::milliseconds CONTROL_WAITREPY_TOMEOUT = 2000ms; diff --git a/src/virtual_runtime.cpp b/src/virtual_runtime.cpp index 22375139a3fc3c34e005bbf7c18563d4593885c3..62c0d9352fb2b06483cfa8edf5b25a46f8fa7736 100644 --- a/src/virtual_runtime.cpp +++ b/src/virtual_runtime.cpp @@ -686,7 +686,7 @@ void VirtualRuntime::LoadVdso() std::string memory(map.end_ - map.begin_, '\0'); std::copy(reinterpret_cast((map.begin_)), reinterpret_cast((map.end_)), &memory[0]); - std::string tempPath("/data/local/tmp/"); + std::string tempPath("/data/log/hiperf/"); std::string tempFileName = tempPath + MMAP_VDSO_NAME; if (!WriteStringToFile(tempFileName, memory)) { printf("vdso temp file create fail at %s\n", tempFileName.c_str()); diff --git a/test/unittest/common/native/hiperf_client_test.cpp b/test/unittest/common/native/hiperf_client_test.cpp index 22c390e4c4034699ef03f5ac76de0d363ae560d8..2f079c9a93c74742991585c9b382f3ee9837fd9c 100644 --- a/test/unittest/common/native/hiperf_client_test.cpp +++ b/test/unittest/common/native/hiperf_client_test.cpp @@ -81,7 +81,7 @@ HWTEST_F(HiperfClientTest, OutDir, TestSize.Level1) StdoutRecord stdoutRecord; stdoutRecord.Start(); - HiperfClient::Client myHiperf("/data/local/tmp/"); + HiperfClient::Client myHiperf("/data/log/hiperf/"); myHiperf.SetDebugMode(); ASSERT_TRUE(myHiperf.Start()); @@ -321,7 +321,7 @@ HWTEST_F(HiperfClientTest, SetSymbolDir, TestSize.Level1) HiperfClient::RecordOption opt; vector selectPids = {getpid()}; opt.SetSelectPids(selectPids); - opt.SetSymbolDir("/data/local/tmp/"); + opt.SetSymbolDir("/data/log/hiperf/"); TestCaseOption(opt); } diff --git a/test/unittest/common/native/include/callstack_test.h b/test/unittest/common/native/include/callstack_test.h index 01414c380837465cf0675f5823398eadaffbf70c..f3a2db5b713e2635906ea833c3560690dbadd392 100644 --- a/test/unittest/common/native/include/callstack_test.h +++ b/test/unittest/common/native/include/callstack_test.h @@ -54,22 +54,22 @@ static const std::string TEST_DWARF_ELF = "hiperf_example_cmd"; record mmap2: type 10, misc 2, size 107 pid 643, tid 643, addr 0x454000, len 0x3000 pgoff 0x0, maj 179, min 7, ino 4868, ino_generation 6874019636378171493 - prot 1, flags 2, filename /data/local/tmp/hiperf_example_cmd + prot 1, flags 2, filename /data/log/hiperf/hiperf_example_cmd record mmap2: type 10, misc 2, size 107 pid 643, tid 643, addr 0x457000, len 0x5000 pgoff 0x2000, maj 179, min 7, ino 4868, ino_generation 7237954708011182952 - prot 5, flags 2, filename /data/local/tmp/hiperf_example_cmd + prot 5, flags 2, filename /data/log/hiperf/hiperf_example_cmd record mmap2: type 10, misc 2, size 107 pid 643, tid 643, addr 0x45c000, len 0x1000 pgoff 0x6000, maj 179, min 7, ino 4868, ino_generation 7237954708011182952 - prot 1, flags 2, filename /data/local/tmp/hiperf_example_cmd + prot 1, flags 2, filename /data/log/hiperf/hiperf_example_cmd record mmap2: type 10, misc 2, size 107 pid 643, tid 643, addr 0x45d000, len 0x1000 pgoff 0x6000, maj 179, min 7, ino 4868, ino_generation 7237954708011182952 - prot 3, flags 2, filename /data/local/tmp/hiperf_example_cmd + prot 3, flags 2, filename /data/log/hiperf/hiperf_example_cmd */ static const std::vector TEST_DWARF_MMAP = { {"hiperf_example_cmd", 0x454000, 0x3000, 0x0}, @@ -109,17 +109,17 @@ static const std::string TEST_DWARF_ELF = "hiperf_example_cmd_64"; record mmap2: type 10, misc 2, size 110 pid 24925, tid 24925, addr 0x5591ef4000, len 0x3000 pgoff 0x0, maj 179, min 11, ino 2495283, ino_generation 0 - prot 1, flags 2, filename /data/local/tmp/hiperf_example_cmd_64 + prot 1, flags 2, filename /data/log/hiperf/hiperf_example_cmd_64 record mmap2: type 10, misc 2, size 110 pid 24925, tid 24925, addr 0x5591ef7000, len 0x3000 pgoff 0x2000, maj 179, min 11, ino 2495283, ino_generation 0 - prot 5, flags 2, filename /data/local/tmp/hiperf_example_cmd_64 + prot 5, flags 2, filename /data/log/hiperf/hiperf_example_cmd_64 record mmap2: type 10, misc 2, size 110 pid 24925, tid 24925, addr 0x5591efa000, len 0x1000 pgoff 0x4000, maj 179, min 11, ino 2495283, ino_generation 0 - prot 1, flags 2, filename /data/local/tmp/hiperf_example_cmd_64 + prot 1, flags 2, filename /data/log/hiperf/hiperf_example_cmd_64 */ static const std::vector TEST_DWARF_MMAP = { {"hiperf_example_cmd_64", 0x5591ef4000, 0x3000, 0x0}, diff --git a/test/unittest/common/native/subcommand_record_test.cpp b/test/unittest/common/native/subcommand_record_test.cpp index b76267dc356d7299834fe1bf606d2a375f41b0c3..2c24a30f949f6fd3cd82cef4141513ed7d20630b 100644 --- a/test/unittest/common/native/subcommand_record_test.cpp +++ b/test/unittest/common/native/subcommand_record_test.cpp @@ -704,7 +704,7 @@ HWTEST_F(SubCommandRecordTest, MmapPagesInputErr, TestSize.Level1) // output file name HWTEST_F(SubCommandRecordTest, OutputFileName, TestSize.Level1) { - TestRecordCommand("-d 2 -o /data/local/tmp/output.perf.data "); + TestRecordCommand("-d 2 -o /data/log/hiperf/output.perf.data "); } HWTEST_F(SubCommandRecordTest, OutputFileNameErr, TestSize.Level1)