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..a6bafb4390e83d306fb6bd9027669e058f65ec2e --- /dev/null +++ b/config/hiperf.cfg @@ -0,0 +1,9 @@ +{ + "jobs" : [{ + "name" : "post-init", + "cmds" : [ + "mkdir /data/local/tmp/hiperf -m 755" + ] + } + ] +} diff --git a/include/debug_logger.h b/include/debug_logger.h index b10c3556bce46c1d6b2f647ec7eb18b0e189366f..44ec165a682ca3143f08a9351f813a00d362c00c 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/local/tmp/hiperf"; +const std::string DEFAULT_LOG_PATH = "/data/local/tmp/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 82d5eb8f611ef6bd2253103d6b4737cbdfa8fa42..44dbdbdc909160d7ac11f30300a6713c1726fd05 100644 --- a/include/subcommand_record.h +++ b/include/subcommand_record.h @@ -57,7 +57,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/local/tmp/hiperf/perf.data.\n" " -a\n" " Collect system-wide information.\n" " for measures all processes/threads\n" @@ -140,7 +140,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/local/tmp/hiperf/perf.data.\n" " -z\n" " Compress record data.\n" " --verbose\n" @@ -182,7 +182,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/local/tmp/hiperf/perf.data"; std::string appPackage_ = {}; std::string clockId_ = {}; std::string strLimit_ = {}; diff --git a/interfaces/innerkits/native/include/hiperf_client.h b/interfaces/innerkits/native/include/hiperf_client.h index 52158a91e599598b5ba3739001c6de50b985f69d..a879263a808c49e200695a017fa0266e6a278d84 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/local/tmp/hiperf/"; static const std::string CurrentPath = "./"; static const std::string PerfDataName = "perf.data"; diff --git a/script/hiperf_utils.py b/script/hiperf_utils.py index ed624f1aec231d03f2d7649965ffca32f70a8833..bd7b4ea5705e9dbb0481029ff4f4e0abef565c1a 100644 --- a/script/hiperf_utils.py +++ b/script/hiperf_utils.py @@ -25,7 +25,7 @@ from ctypes import cdll IS_DEBUG = False HDC_NAME = "hdc_std" -SYMBOL_FILES_DIR = '/data/local/tmp/local_libs/' +SYMBOL_FILES_DIR = '/data/local/tmp/hiperf/local_libs/' BUILD_ID_FILE = "build_id_list" EXPECTED_TOOLS = { HDC_NAME: { @@ -396,8 +396,8 @@ class PerformanceProfile: def download_hiperf(self): hiperf_binary = get_hiperf_binary_path(self.device_arch, 'hiperf') - self.hdc.check_run(['file send', hiperf_binary, '/data/local/tmp']) - self.hdc.check_run(['shell', 'chmod', 'a+x', '/data/local/tmp/hiperf']) + self.hdc.check_run(['file send', hiperf_binary, '/data/local/tmp/hiperf']) + self.hdc.check_run(['shell', 'chmod', 'a+x', '/data/local/tmp/hiperf/hiperf']) def download_libs(self): executor = LocalLibDownload(self.device_arch, self.hdc) @@ -471,12 +471,12 @@ class PerformanceProfile: record_options = self.args.record_options.split(' ') record_options = [cmd.replace("'", "") for cmd in record_options] if self.is_control: - args = ['/data/local/tmp/hiperf', 'record', + args = ['/data/local/tmp/hiperf/hiperf', 'record', '--control', self.control_mode, '-o', - '/data/local/tmp/perf.data'] + record_options + '/data/local/tmp/hiperf/perf.data'] + record_options else: - args = ['/data/local/tmp/hiperf', 'record', '-o', - '/data/local/tmp/perf.data'] + record_options + args = ['/data/local/tmp/hiperf/hiperf', 'record', '-o', + '/data/local/tmp/hiperf/hiperf/perf.data'] + record_options if self.args.local_lib_dir and self.hdc.run_hdc_cmd( ['shell', 'ls', SYMBOL_FILES_DIR]): args += ['--symbol-dir', SYMBOL_FILES_DIR] @@ -521,14 +521,14 @@ class PerformanceProfile: def get_profiling_data(self): current_path = os.getcwd() full_path = os.path.join(current_path, self.args.output_perf_data) - self.hdc.check_run(['file recv', '/data/local/tmp/perf.data', + self.hdc.check_run(['file recv', '/data/local/tmp/hiperf/perf.data', full_path]) self.hdc.run_hdc_cmd(['shell', 'rm', - '/data/local/tmp/perf.data']) + '/data/local/tmp/hiperf/perf.data']) def exec_control(self): hdc_args = [self.hdc.hdc_path, 'shell', - '/data/local/tmp/hiperf', 'record', + '/data/local/tmp/hiperf/hiperf', 'record', '--control', self.control_mode] print('run hdc cmd: %s' % hdc_args) self.record_subproc = subprocess.Popen(hdc_args) @@ -537,7 +537,7 @@ class PerformanceProfile: last_size = 0 while True: (result, out) = self.hdc.run_hdc_cmd( - ['shell', 'du', 'data/local/tmp/perf.data']) + ['shell', 'du', 'data/local/tmp/hiperf/perf.data']) if "du" not in out: current_size = out.split(" ")[0] if current_size == last_size: diff --git a/script/recv_binary_cache.py b/script/recv_binary_cache.py index b1876631ffbfc40b1dd6414f7b210682296d4759..5aa1b3861d7078d66440ff5ea48e97d7cbf881fc 100644 --- a/script/recv_binary_cache.py +++ b/script/recv_binary_cache.py @@ -164,15 +164,15 @@ class GetLibFiles(object): if self.hdc.run_hdc_cmd(['file recv', device_path, host_path]): return True # In non-root device, we can't pull /data/app/XXX/base.odex directly. - # Instead, we can first copy the file to /data/local/tmp, then pull it. + # Instead, we can first copy the file to /data/local/tmp/hiperf, then pull it. filename = device_path[device_path.rfind('/') + 1:] if (self.hdc.run_hdc_cmd(['shell', 'cp', device_path, - '/data/local/tmp']) and + '/data/local/tmp/hiperf']) and self.hdc.run_hdc_cmd(['file recv', - '/data/local/tmp/' + filename, + '/data/local/tmp/hiperf/' + filename, host_path])): self.hdc.run_hdc_cmd(['shell', 'rm', - '/data/local/tmp/' + filename]) + '/data/local/tmp/hiperf/' + filename]) return True print('failed to pull %s from device' % device_path) return False diff --git a/src/subcommand_record.cpp b/src/subcommand_record.cpp index 14ccf7ad7706cc05c665394509e75152dd35d790..45aa14d72091ba9cd692569825ee7c47dce62971 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/local/tmp/hiperf/.hiperf_record_control_c2s"; +const std::string CONTROL_FIFO_FILE_S2C = "/data/local/tmp/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..b0ea4154a9359f599c271327208d8922b6788ffe 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/local/tmp/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..bf7f0fdb32a7ca900ace1764d3a8a7a01f859a51 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/local/tmp/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/local/tmp/hiperf/"); TestCaseOption(opt); } diff --git a/test/unittest/common/native/hiperf_libreport_test.cpp b/test/unittest/common/native/hiperf_libreport_test.cpp index 42ee290252e34cbe48259c59a1d6c6cba2ef4ece..d941340f5e0ffaa88e2e432c7e51f47f547e4380 100644 --- a/test/unittest/common/native/hiperf_libreport_test.cpp +++ b/test/unittest/common/native/hiperf_libreport_test.cpp @@ -86,7 +86,7 @@ void HiperfLibReportTest::DefaultSymbolsBuildIdContentCheck(const std::string &c "libace.z.so,b8d9d3bb0184ba917e8d05d471e8387a],[/system/lib/" "libeventhandler.z.so,b1e08a8a6eabe33363f721b14393b06b],[/system/bin/" "hilogd,b11a9f3700884ded33879f81914e3aa2],[/system/bin/" - "wifi_hal_service,6beba486dcdf5debb5c9248bc5cdf5f0],[/data/local/tmp/" + "wifi_hal_service,6beba486dcdf5debb5c9248bc5cdf5f0],[/data/local/tmp/hiperf/" "hiperf,32aa1e9c5f35d49e16fa1b6e86db130c],[/system/bin/" "hiview,419493d9ccef1df5dedfa4a144249e49],[/system/lib/" "libhiviewbase.z.so,349d82d4f1d2dc21c039156afbe470ad],[/system/lib/" diff --git a/test/unittest/common/native/include/callstack_test.h b/test/unittest/common/native/include/callstack_test.h index 01414c380837465cf0675f5823398eadaffbf70c..b991b730d09461b335ba3f37f0094cf0c72f9d77 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/local/tmp/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/local/tmp/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/local/tmp/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/local/tmp/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/local/tmp/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/local/tmp/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/local/tmp/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 0930cbacf01c1c208786845fa146f32176753433..6c074b521b86774f27f0c107414d491af4d1de10 100644 --- a/test/unittest/common/native/subcommand_record_test.cpp +++ b/test/unittest/common/native/subcommand_record_test.cpp @@ -649,7 +649,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/local/tmp/hiperf/output.perf.data "); } HWTEST_F(SubCommandRecordTest, OutputFileNameErr, TestSize.Level1)