From 6f8832c9475c1805e856487da88b4a6a11f2b398 Mon Sep 17 00:00:00 2001 From: jichuan Date: Mon, 15 Apr 2024 20:28:04 +0800 Subject: [PATCH 01/14] =?UTF-8?q?fix:=20=E5=90=8C=E6=AD=A5hiperf=E5=92=8Cf?= =?UTF-8?q?aultloggerd=E6=9C=80=E6=96=B0=E4=BB=A3=E7=A0=81=EF=BC=8C=20?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=AF=B9hilog=E7=9A=84=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- ide/src/trace/component/chart/SpClockChart.ts | 22 ++++++++++-------- ide/src/trace/database/sql/Clock.sql.ts | 1 + ....test.ts => TabPaneGpufreqDataCut.test.ts} | 0 ...ge.test.ts => TabPaneGpufreqUsage.test.ts} | 0 trace_streamer/.gn | 0 trace_streamer/mac_depend.sh | 0 trace_streamer/pare_third_party.sh | 15 ++---------- .../prebuilts/patch_hiperf/BUILD.gn | 1 + .../prebuilts/patch_hiperf/hiviewdfx_BUILD.gn | 8 +++---- .../parser/hiperf_parser/perf_data_parser.cpp | 8 +++---- .../pbreader_parser/pbreader_parser.cpp | 2 +- .../native_hook/native_hook_result.proto | 0 trace_streamer/test/resource/Mmap.htrace | Bin trace_streamer/test/resource/ebpf_bio.htrace | Bin .../resource/hiprofiler_data_ability.htrace | Bin .../test/resource/hiprofiler_data_perf.htrace | Bin .../htrace_perf_no_profiler_header.bin | Bin .../test/resource/perfCompressed.data | Bin 18 files changed, 25 insertions(+), 32 deletions(-) rename ide/test/trace/component/trace/sheet/gpufreq/{tabPaneGpufreqDataCut.test.ts => TabPaneGpufreqDataCut.test.ts} (100%) rename ide/test/trace/component/trace/sheet/gpufreq/{tabPaneGpufreqUsage.test.ts => TabPaneGpufreqUsage.test.ts} (100%) mode change 100644 => 100755 trace_streamer/.gn mode change 100644 => 100755 trace_streamer/mac_depend.sh mode change 100755 => 100644 trace_streamer/src/protos/types/plugins/native_hook/native_hook_result.proto mode change 100644 => 100755 trace_streamer/test/resource/Mmap.htrace mode change 100644 => 100755 trace_streamer/test/resource/ebpf_bio.htrace mode change 100644 => 100755 trace_streamer/test/resource/hiprofiler_data_ability.htrace mode change 100644 => 100755 trace_streamer/test/resource/hiprofiler_data_perf.htrace mode change 100644 => 100755 trace_streamer/test/resource/htrace_perf_no_profiler_header.bin mode change 100644 => 100755 trace_streamer/test/resource/perfCompressed.data diff --git a/ide/src/trace/component/chart/SpClockChart.ts b/ide/src/trace/component/chart/SpClockChart.ts index 70dd584f2..845ba7299 100644 --- a/ide/src/trace/component/chart/SpClockChart.ts +++ b/ide/src/trace/component/chart/SpClockChart.ts @@ -42,10 +42,10 @@ export class SpClockChart { name: string; num: number; srcname: string; + maxValue?: number; }, isState: boolean, - isScreenState: boolean, - maxValue: number + isScreenState: boolean ): void { traceRow.supplierFrame = (): Promise => { let promiseData = null; @@ -62,8 +62,8 @@ export class SpClockChart { return promiseData.then((resultClock: Array) => { for (let j = 0; j < resultClock.length; j++) { resultClock[j].type = 'measure'; - if ((resultClock[j].value || 0) > maxValue) { - maxValue = resultClock[j].value || 0; + if ((resultClock[j].value || 0) > it.maxValue!) { + it.maxValue = resultClock[j].value || 0; } if (j > 0) { resultClock[j].delta = (resultClock[j].value || 0) - (resultClock[j - 1].value || 0); @@ -83,10 +83,10 @@ export class SpClockChart { name: string; num: number; srcname: string; + maxValue?: number; }, isState: boolean, isScreenState: boolean, - maxValue: number, clockId: number ): void { traceRow.onThreadHandler = (useCache): void => { @@ -102,10 +102,12 @@ export class SpClockChart { context: context, useCache: useCache, type: it.name, - maxValue: maxValue === 0 ? 1 : maxValue, + maxValue: it.maxValue === 0 ? 1 : it.maxValue!, index: clockId, maxName: - isState || isScreenState ? maxValue.toString() : Utils.getFrequencyWithUnit(maxValue / 1000).maxFreqName, + isState || isScreenState + ? it.maxValue!.toString() + : Utils.getFrequencyWithUnit(it.maxValue! / 1000).maxFreqName, }, traceRow ); @@ -124,7 +126,7 @@ export class SpClockChart { ClockStruct.maxValue = clockList.map((item) => item.num).reduce((a, b) => Math.max(a, b)); for (let i = 0; i < clockList.length; i++) { const it = clockList[i]; - let maxValue = 0; + it.maxValue = 0; let traceRow = TraceRow.skeleton(); let isState = it.name.endsWith(' State'); let isScreenState = it.name.endsWith('ScreenState'); @@ -137,7 +139,7 @@ export class SpClockChart { traceRow.setAttribute('children', ''); traceRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; traceRow.selectChangeHandler = this.trace.selectChangeHandler; - this.clockSupplierFrame(traceRow, it, isState, isScreenState, maxValue); + this.clockSupplierFrame(traceRow, it, isState, isScreenState); traceRow.getCacheData = (args: any): Promise> | undefined => { if (it.name.endsWith(' Frequency')) { return clockDataSender(it.srcname, 'clockFrequency', traceRow, args); @@ -157,7 +159,7 @@ export class SpClockChart { traceRow.findHoverStruct = (): void => { ClockStruct.hoverClockStruct = traceRow.getHoverStruct(); }; - this.clockThreadHandler(traceRow, it, isState, isScreenState, maxValue, i); + this.clockThreadHandler(traceRow, it, isState, isScreenState, i); folder.addChildTraceRow(traceRow); } let durTime = new Date().getTime() - clockStartTime; diff --git a/ide/src/trace/database/sql/Clock.sql.ts b/ide/src/trace/database/sql/Clock.sql.ts index e9f4b77c2..97b43ae50 100644 --- a/ide/src/trace/database/sql/Clock.sql.ts +++ b/ide/src/trace/database/sql/Clock.sql.ts @@ -20,6 +20,7 @@ export const queryClockData = (): Promise< name: string; num: number; srcname: string; + maxValue?: number }> > => query( diff --git a/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqDataCut.test.ts b/ide/test/trace/component/trace/sheet/gpufreq/TabPaneGpufreqDataCut.test.ts similarity index 100% rename from ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqDataCut.test.ts rename to ide/test/trace/component/trace/sheet/gpufreq/TabPaneGpufreqDataCut.test.ts diff --git a/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqUsage.test.ts b/ide/test/trace/component/trace/sheet/gpufreq/TabPaneGpufreqUsage.test.ts similarity index 100% rename from ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqUsage.test.ts rename to ide/test/trace/component/trace/sheet/gpufreq/TabPaneGpufreqUsage.test.ts diff --git a/trace_streamer/.gn b/trace_streamer/.gn old mode 100644 new mode 100755 diff --git a/trace_streamer/mac_depend.sh b/trace_streamer/mac_depend.sh old mode 100644 new mode 100755 diff --git a/trace_streamer/pare_third_party.sh b/trace_streamer/pare_third_party.sh index 9fcc027b7..b9610d13b 100755 --- a/trace_streamer/pare_third_party.sh +++ b/trace_streamer/pare_third_party.sh @@ -84,20 +84,12 @@ if [ ! -f "perf_include/libbpf/linux/perf_event.h" ];then $patch -p0 perf_include/libbpf/linux/perf_event.h ../prebuilts/patch_perf_event/perf_event.h.patch fi -if [ ! -d "perf_include/hiviewdfx/hilog" ];then - rm -rf hiviewdfx_hilog perf_include/hiviewdfx/hilog - mkdir -p perf_include/hiviewdfx/hilog - git clone --depth=1 https://gitee.com/openharmony/hiviewdfx_hilog.git - mv hiviewdfx_hilog/interfaces/native/innerkits/include/ perf_include/hiviewdfx/hilog - rm -rf hiviewdfx_hilog -fi - if [ ! -d "perf_include/hiviewdfx/faultloggerd" ];then rm -rf hiviewdfx_faultloggerd perf_include/hiviewdfx/faultloggerd mkdir -p perf_include/hiviewdfx/faultloggerd/interfaces/innerkits git clone git@gitee.com:openharmony/hiviewdfx_faultloggerd.git cd hiviewdfx_faultloggerd - git reset --hard b7e7ae4340a39db64d2cdf5f8fdb96cdb368f6a7 + git reset --hard 7bd128c8fa91b79606c1bb21f20123879b351a4f cd .. mv hiviewdfx_faultloggerd/common/ perf_include/hiviewdfx/faultloggerd mv hiviewdfx_faultloggerd/interfaces/common/ perf_include/hiviewdfx/faultloggerd/interfaces @@ -109,14 +101,11 @@ if [ ! -d "perf_include/hiviewdfx/faultloggerd" ];then rm -rf perf_include/hiviewdfx/common/build rm -rf perf_include/hiviewdfx/common/cutil rm perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_regs_x86_64.cpp - $sed -i '/HiLogPrint/s/^/\/\/ /' perf_include/hiviewdfx/faultloggerd/common/dfxlog/dfx_log.cpp $sed -i '/TRAP_BRANCH/s/^/\/\/ /' perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_signal.cpp $sed -i '/TRAP_HWBKPT/s/^/\/\/ /' perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_signal.cpp $sed -i '/is_ohos/s/is_ohos/true/g' perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_mmap.cpp $sed -i '/is_ohos/s/is_ohos/true/g' perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/include/dfx_regs.h $sed -i '/#include /a #include "debug_logger.h"' perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/include/unwinder.h - $sed -i '/VerifyFilePath/s/const std::vector/std::vector\/g' perf_include/hiviewdfx/faultloggerd/common/dfxutil/dfx_util.h - $sed -i '/VerifyFilePath/s/const std::vector/std::vector\/g' perf_include/hiviewdfx/faultloggerd/common/dfxutil/dfx_util.cpp $sed -i '/getpid() == gettid()/s/getpid() == gettid()/false/g' perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/unwinder.cpp $sed -i '/!realpath(path, realPath)/s/!realpath(path, realPath)/false/g' perf_include/hiviewdfx/faultloggerd/common/dfxutil/dfx_util.cpp $sed -i '/#include "dfx_util.h"/a #include "utilities.h"' perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_mmap.cpp @@ -137,7 +126,7 @@ if [ ! -f "hiperf/BUILD.gn" ];then rm -rf hiperf developtools_hiperf git clone git@gitee.com:openharmony/developtools_hiperf.git cd developtools_hiperf - git reset --hard 9d9322fcd0a83ab409f26b3c6dfaea2bb8d42628 + git reset --hard 59eecf523796401740d02894f64b4d23f7d370a9 cd .. if [ -d "developtools_hiperf" ];then mv developtools_hiperf hiperf diff --git a/trace_streamer/prebuilts/patch_hiperf/BUILD.gn b/trace_streamer/prebuilts/patch_hiperf/BUILD.gn index e319db0a1..4fbceafea 100644 --- a/trace_streamer/prebuilts/patch_hiperf/BUILD.gn +++ b/trace_streamer/prebuilts/patch_hiperf/BUILD.gn @@ -53,6 +53,7 @@ ohos_source_set("hiperf_src") { "./src/report.cpp", "./src/subcommand.cpp", "./src/symbols_file.cpp", + "./src/unique_stack_table.cpp", "./src/virtual_runtime.cpp", "./src/virtual_thread.cpp", "include/symbols_file.h", diff --git a/trace_streamer/prebuilts/patch_hiperf/hiviewdfx_BUILD.gn b/trace_streamer/prebuilts/patch_hiperf/hiviewdfx_BUILD.gn index 52103e903..ca28797f0 100644 --- a/trace_streamer/prebuilts/patch_hiperf/hiviewdfx_BUILD.gn +++ b/trace_streamer/prebuilts/patch_hiperf/hiviewdfx_BUILD.gn @@ -18,6 +18,8 @@ ohos_source_set("hiviewdfx_source") { subsystem_name = "developtools" part_name = "smartperf_host" cflags = [ "-D ALWAYSTRUE" ] + cflags += [ "-D DFX_NO_PRINT_LOG" ] + cflags += [ "-D is_host" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } @@ -28,10 +30,7 @@ ohos_source_set("hiviewdfx_source") { "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxutil", "${THIRD_PARTY}/perf_include/hiviewdfx/hilog/include", ] - sources = [ - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxlog/dfx_log.cpp", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxutil/dfx_util.cpp", - ] + sources = [ "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxutil/dfx_util.cpp" ] include_dirs += [ "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/common", "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/nonlinux", @@ -55,6 +54,7 @@ ohos_source_set("hiviewdfx_source") { "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_memory.cpp", "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_mmap.cpp", "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_symbols.cpp", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/unwinder_config.cpp", ] } diff --git a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp index ec50366d2..08425bb1e 100644 --- a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp +++ b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp @@ -612,7 +612,7 @@ uint32_t PerfDataParser::UpdateCallChainUnCompressed(const std::unique_ptrcallFrames_) { - stackStr += "+" + base::number(callFrame.ip_, base::INTEGER_RADIX_TYPE_HEX); + stackStr += "+" + base::number(callFrame.pc, base::INTEGER_RADIX_TYPE_HEX); } auto stackHash = hashFun_(stackStr); auto pid = sample->data_.pid; @@ -625,12 +625,12 @@ uint32_t PerfDataParser::UpdateCallChainUnCompressed(const std::unique_ptrcallFrames_.rbegin(); frame != sample->callFrames_.rend(); ++frame) { uint64_t fileId = INVALID_UINT64; - auto fileDataIndex = traceDataCache_->dataDict_.GetStringIndex(frame->filePath_); + auto fileDataIndex = traceDataCache_->dataDict_.GetStringIndex(frame->mapName); if (fileDataDictIdToFileId_.count(fileDataIndex) != 0) { fileId = fileDataDictIdToFileId_.at(fileDataIndex); } - streamFilters_->perfDataFilter_->AppendPerfCallChain(callChainId, depth++, frame->ip_, frame->vaddrInFile_, - fileId, frame->symbolIndex_); + streamFilters_->perfDataFilter_->AppendPerfCallChain(callChainId, depth++, frame->pc, frame->funcOffset, fileId, + frame->index); } return callChainId; } diff --git a/trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp b/trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp index f3c797b4c..8416591d3 100644 --- a/trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp @@ -172,7 +172,7 @@ void PbreaderParser::ParserFileSO(std::string& directory, const std::vectorsetSymbolsFilePath(directory); - symbolsFile->LoadSymbols(absoluteFilePath); + symbolsFile->LoadSymbols(nullptr, absoluteFilePath); symbolsFiles_.emplace_back(std::move(symbolsFile)); } } diff --git a/trace_streamer/src/protos/types/plugins/native_hook/native_hook_result.proto b/trace_streamer/src/protos/types/plugins/native_hook/native_hook_result.proto old mode 100755 new mode 100644 diff --git a/trace_streamer/test/resource/Mmap.htrace b/trace_streamer/test/resource/Mmap.htrace old mode 100644 new mode 100755 diff --git a/trace_streamer/test/resource/ebpf_bio.htrace b/trace_streamer/test/resource/ebpf_bio.htrace old mode 100644 new mode 100755 diff --git a/trace_streamer/test/resource/hiprofiler_data_ability.htrace b/trace_streamer/test/resource/hiprofiler_data_ability.htrace old mode 100644 new mode 100755 diff --git a/trace_streamer/test/resource/hiprofiler_data_perf.htrace b/trace_streamer/test/resource/hiprofiler_data_perf.htrace old mode 100644 new mode 100755 diff --git a/trace_streamer/test/resource/htrace_perf_no_profiler_header.bin b/trace_streamer/test/resource/htrace_perf_no_profiler_header.bin old mode 100644 new mode 100755 diff --git a/trace_streamer/test/resource/perfCompressed.data b/trace_streamer/test/resource/perfCompressed.data old mode 100644 new mode 100755 -- Gitee From df971c56ce0546bef7dd9a830866d202e36eba48 Mon Sep 17 00:00:00 2001 From: jichuan Date: Mon, 15 Apr 2024 20:33:53 +0800 Subject: [PATCH 02/14] =?UTF-8?q?fix:=201.=20gn=E6=96=87=E4=BB=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=202.=20=E6=B8=85=E7=90=86=E6=97=A0=E6=95=88=E5=A4=B4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=8C=85=E5=90=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- trace_streamer/build/sync_base.sh | 47 ++++++ .../sdk/demo_sdk/sdk/sdk_data_parser.cpp | 1 - .../sdk/demo_sdk/trace_data/trace_stdtype.h | 1 - trace_streamer/src/BUILD.gn | 135 ++++-------------- trace_streamer/src/base/clock_filter.cpp | 1 - trace_streamer/src/base/sqlite_ext/BUILD.gn | 8 +- .../src/base/sqlite_ext/sqlite_ext_funcs.cpp | 2 +- trace_streamer/src/base/ts_common.h | 1 + .../src/cfg/trace_streamer_config.cpp | 10 +- .../src/cfg/trace_streamer_config.h | 4 +- trace_streamer/src/filter/BUILD.gn | 21 +-- trace_streamer/src/filter/args_filter.cpp | 1 - trace_streamer/src/filter/frame_filter.cpp | 1 - .../hi_sysevent_measure_filter.cpp | 1 - trace_streamer/src/filter/measure_filter.cpp | 1 - trace_streamer/src/filter/slice_filter.cpp | 1 - trace_streamer/src/filter/stat_filter.cpp | 1 - .../filter/system_event_measure_filter.cpp | 1 - trace_streamer/src/main.cpp | 74 +++++++--- trace_streamer/src/metrics/BUILD.gn | 24 ++-- trace_streamer/src/metrics/metrics.h | 1 - trace_streamer/src/parser/BUILD.gn | 28 ++-- .../src/parser/ebpf_parser/BUILD.gn | 5 +- .../src/parser/ebpf_parser/ebpf_data_parser.h | 2 +- .../src/parser/ebpf_parser/ebpf_data_reader.h | 2 +- .../src/parser/ebpf_parser/ebpf_splitter.h | 2 +- .../src/parser/hiperf_parser/BUILD.gn | 7 +- .../parser/hiperf_parser/perf_data_parser.cpp | 2 +- .../parser/hiperf_parser/perf_data_parser.h | 3 +- .../src/parser/pbreader_parser/BUILD.gn | 18 ++- .../src/parser/pbreader_parser/arkts/BUILD.gn | 11 +- .../pbreader_parser/cpu_data_parser/BUILD.gn | 9 +- .../pbreader_cpu_data_parser.h | 2 +- .../pbreader_parser/disk_io_parser/BUILD.gn | 9 +- .../pbreader_parser/hidump_parser/BUILD.gn | 9 +- .../hidump_parser/pbreader_hidump_parser.h | 2 +- .../hilog_parser/pbreader_hilog_parser.cpp | 1 - .../hilog_parser/pbreader_hilog_parser.h | 2 +- .../pbreader_hisysevent_parser.h | 4 +- .../pbreader_parser/htrace_parser/BUILD.gn | 1 - .../htrace_cpu_detail_parser.cpp | 1 - .../htrace_parser/htrace_cpu_detail_parser.h | 3 +- .../htrace_parser/htrace_event_parser.cpp | 3 +- .../htrace_parser/htrace_event_parser.h | 5 +- .../htrace_symbols_detail_parser.cpp | 1 - .../htrace_symbols_detail_parser.h | 4 +- .../pbreader_parser/mem_parser/BUILD.gn | 9 +- .../mem_parser/pbreader_mem_parser.h | 2 +- .../native_hook_parser/BUILD.gn | 6 +- .../pbreader_native_hook_parser.h | 5 +- .../pbreader_parser/network_parser/BUILD.gn | 9 +- ...r.cpp => pbreader_clock_detail_parser.cpp} | 12 +- ...arser.h => pbreader_clock_detail_parser.h} | 8 +- .../pbreader_parser/pbreader_parser.cpp | 23 ++- .../parser/pbreader_parser/pbreader_parser.h | 29 ++-- .../pbreader_parser/process_parser/BUILD.gn | 9 +- .../src/parser/print_event_parser.h | 8 +- .../ptreader_parser/bytrace_parser/BUILD.gn | 11 +- .../bytrace_parser/bytrace_event_parser.cpp | 7 +- .../hilog_parser/ptreader_hilog_parser.cpp | 2 +- .../hisysevent_parser/BUILD.gn | 2 +- .../ptreader_hisysevent_parser.h | 1 - .../ptreader_parser/ptreader_parser.cpp | 2 +- .../parser/ptreader_parser/ptreader_parser.h | 9 +- .../src/parser/rawtrace_parser/BUILD.gn | 4 +- .../ftrace_event_processor.cpp | 1 - .../kernel_symbols_processor.cpp | 1 - .../printk_formats_processor.cpp | 1 - .../rawtrace_parser/rawtrace_parser.cpp | 3 +- .../src/protos/services/common_types.proto | 24 ++-- trace_streamer/src/rpc/ffrt_converter.h | 2 - trace_streamer/src/rpc/rpc_server.cpp | 5 +- trace_streamer/src/table/base/BUILD.gn | 39 ++--- trace_streamer/src/table/base/table_base.cpp | 2 - trace_streamer/src/table/ebpf/BUILD.gn | 25 +--- trace_streamer/src/table/ftrace/BUILD.gn | 24 +--- .../table/ftrace/cpu_measure_filter_table.cpp | 2 - trace_streamer/src/table/hi_sysevent/BUILD.gn | 24 +--- trace_streamer/src/table/hiperf/BUILD.gn | 25 +--- trace_streamer/src/table/js_memory/BUILD.gn | 24 +--- trace_streamer/src/table/monitor/BUILD.gn | 24 +--- trace_streamer/src/table/native_hook/BUILD.gn | 25 +--- trace_streamer/src/trace_data/BUILD.gn | 11 +- .../src/trace_data/trace_data_cache.cpp | 2 +- .../trace_data/trace_data_cache_reader.cpp | 1 - .../trace_data/trace_data_cache_writer.cpp | 1 - .../src/trace_data/trace_data_db.cpp | 3 +- .../trace_data/trace_stdtype/base_stdtype.h | 1 - .../trace_data/trace_stdtype/common_stdtype.h | 2 +- .../trace_streamer/trace_streamer_filters.cpp | 4 +- .../trace_streamer_selector.cpp | 10 +- .../trace_streamer/trace_streamer_selector.h | 2 +- trace_streamer/test/BUILD.gn | 3 +- .../ebpf/paged_memory_parser_test.cpp | 2 +- .../unittest/filter/app_start_filter_test.cpp | 2 +- .../test/unittest/filter/cpu_filter_test.cpp | 6 +- .../htrace_binder_event_test.cpp | 1 - .../htrace_cpu_detail_parser_test.cpp | 1 - .../pbreader_parser/htrace_irq_event_test.cpp | 1 - 99 files changed, 401 insertions(+), 534 deletions(-) create mode 100644 trace_streamer/build/sync_base.sh rename trace_streamer/src/parser/pbreader_parser/{htrace_parser/htrace_clock_detail_parser.cpp => pbreader_clock_detail_parser.cpp} (90%) rename trace_streamer/src/parser/pbreader_parser/{htrace_parser/htrace_clock_detail_parser.h => pbreader_clock_detail_parser.h} (86%) diff --git a/trace_streamer/build/sync_base.sh b/trace_streamer/build/sync_base.sh new file mode 100644 index 000000000..371dcef82 --- /dev/null +++ b/trace_streamer/build/sync_base.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -e +TARGET_PATH="" +PROJ_PATH="" +echo $SCRIPT_PATH +function help { + echo "Usage: $1 [-p ]" + echo " -p , set the sync target path." + echo " -h Show the help info." + exit +} +function parser_param { + while [[ $# -gt 0 ]]; do + case "$1" in + -p) + TARGET_PATH="$2" + shift 2;; + -h) + help $0 + shift;; + *) + shift;; + esac + done +} +function check_target_path { + if [ -z "$TARGET_PATH" ]; then + echo "target path is empty!" + help $0 + exit + fi +} +function set_cur_proj_path { + PROJ_PATH=$(dirname "$(readlink -f "$0")") +} \ No newline at end of file diff --git a/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.cpp b/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.cpp index c37b62b26..b1e8a6acc 100644 --- a/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.cpp +++ b/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.cpp @@ -22,7 +22,6 @@ #include "gpu_counter_object_table.h" #include "gpu_counter_table.h" #include "json.hpp" -#include "log.h" #include "demo_meta_table.h" #include "sdk_plugin_data_parser.h" #include "slice_object_table.h" diff --git a/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.h b/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.h index af7c994d1..02a84b293 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.h +++ b/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.h @@ -27,7 +27,6 @@ #include #include #include -#include "log.h" #include "ts_common.h" namespace SysTuning { diff --git a/trace_streamer/src/BUILD.gn b/trace_streamer/src/BUILD.gn index 76eb68b14..455d78792 100644 --- a/trace_streamer/src/BUILD.gn +++ b/trace_streamer/src/BUILD.gn @@ -55,89 +55,8 @@ ohos_source_set("ts_sqlite") { } } -trace_streamer_include = [ - "base", - "..", - "trace_streamer", - "filter", - "table", - "trace_data", - "metrics", - "include", - "rpc", - "./", - "parser", - "cfg", - "proto_reader/include", - "parser/ptreader_parser", - "parser/ebpf_parser", - "parser/pbreader_parser", - "parser/pbreader_parser/htrace_parser", - "parser/pbreader_parser/htrace_parser", - "parser/rawtrace_parser", - "parser/hiperf_parser", - "${THIRD_PARTY}/bounds_checking_function/include", - "${THIRD_PARTY}/sqlite/include", - "${THIRD_PARTY}/json/single_include/nlohmann", - "${THIRD_PARTY}/protobuf/src", - "${PERF_DIR}/hiperf/include", - "${PERF_DIR}/hiperf/include/nonlinux", - "${PERF_DIR}/hiperf/include/nonlinux/linux", - "${THIRD_PARTY}/libunwind/include", - "${THIRD_PARTY}/libunwind/src", - "${THIRD_PARTY}/perf_include/libbpf", - "${THIRD_PARTY}/googletest/googletest/include", - "${COMMON_LIBRARY}/c_utils/base/include", - "${THIRD_PARTY}/sqlite", - "${THIRD_PARTY}/protogen/types/plugins/js_memory", - "${PERF_DIR}/profiler/device/plugins/ftrace_plugin/include", -] - -ohos_source_set("trace_streamer_source") { - subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" - part_name = "${OHOS_PROFILER_PART_NAME}" - sources = [ - "cfg/trace_streamer_config.cpp", - "rpc/ffrt_converter.cpp", - "rpc/rpc_server.cpp", - "trace_streamer/trace_streamer_filters.cpp", - "trace_streamer/trace_streamer_selector.cpp", - "version.cpp", - ] - if (!is_test && !is_fuzz) { - sources += [ "main.cpp" ] - } - if (use_wasm) { - sources += [ - "rpc/wasm_func.cpp", - "rpc/wasm_func.h", - ] - } - - include_dirs = trace_streamer_include - include_dirs += [ - "${THIRD_PARTY}/perf_include/hiviewdfx/hilog/include", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/cutil", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxlog", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxutil", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/common", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/nonlinux", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/include", - ] - include_dirs += [ - "${SRC}/trace_data/trace_stdtype", - "${SRC}/trace_data/trace_stdtype/ftrace", - "${SRC}/trace_data/trace_stdtype/ftrace/template", - "${SRC}/trace_data/trace_stdtype/hilog", - "${SRC}/trace_data/trace_stdtype/hiperf", - "${SRC}/trace_data/trace_stdtype/hisysevent", - "${SRC}/trace_data/trace_stdtype/htrace", - "${SRC}/trace_data/trace_stdtype/measure", - ] - - if (!is_independent_compile) { - configs = [ "${TS_DIR}/gn:ts_config" ] - } +config("trace_streamer_cfg") { + include_dirs = [ "." ] if (enable_ts_utest && !use_wasm) { cflags = [ "-fprofile-arcs", @@ -152,6 +71,9 @@ ohos_source_set("trace_streamer_source") { cflags += [ "-D IS_UT" ] } } + if (!is_independent_compile) { + configs = [ "${TS_DIR}/gn:ts_config" ] + } if (is_mingw || is_mac) { include_dirs += [ "${THIRD_PARTY}/libbpf/include/uapi", @@ -161,24 +83,25 @@ ohos_source_set("trace_streamer_source") { if (is_mingw) { cflags = [ "-includeMingW64Fix.h" ] } +} - public_deps = [ - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp_standard", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:cpu_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ftrace_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hisysevent_data:hisysevent_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/js_memory:ts_js_memory_data_cpp", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader", +ohos_source_set("trace_streamer_source") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ + "cfg/trace_streamer_config.cpp", + "rpc/ffrt_converter.cpp", + "rpc/rpc_server.cpp", + "trace_streamer/trace_streamer_filters.cpp", + "trace_streamer/trace_streamer_selector.cpp", + "version.cpp", ] - if (!use_wasm && !is_test && !is_fuzz) { - public_deps += [ - "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})", - "proto_reader/protoc_plugin:protoreader_plugin(${host_toolchain})", - ] + if (!is_test && !is_fuzz) { + sources += [ "main.cpp" ] + } + if (use_wasm) { + sources += [ "rpc/wasm_func.cpp" ] } - deps = [ ":ts_sqlite", "base:base", @@ -191,14 +114,13 @@ ohos_source_set("trace_streamer_source") { "//third_party/bounds_checking_function:libsec_static", "//third_party/perf_include/hiviewdfx:hiviewdfx", ] - - public_configs = [] - if (enable_hiperf) { - public_configs += [ "parser/hiperf_parser:hiperf_parser_cfg" ] - } - if (enable_stream_extend) { - public_configs += - [ "${EXTEND_SRC}/parser/pbreader_stream_parser:pbreader_stream_cfg" ] + public_configs = [ ":trace_streamer_cfg" ] + public_deps = [] + if (!use_wasm && !is_test && !is_fuzz) { + public_deps += [ + "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})", + "proto_reader/protoc_plugin:protoreader_plugin(${host_toolchain})", + ] } } @@ -221,7 +143,6 @@ if (use_wasm) { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [] - include_dirs = trace_streamer_include deps = [ ":trace_streamer_source" ] } } diff --git a/trace_streamer/src/base/clock_filter.cpp b/trace_streamer/src/base/clock_filter.cpp index ccf97abb3..cab954168 100644 --- a/trace_streamer/src/base/clock_filter.cpp +++ b/trace_streamer/src/base/clock_filter.cpp @@ -17,7 +17,6 @@ #include #include #include -#include "log.h" #include "string_help.h" #include "ts_common.h" diff --git a/trace_streamer/src/base/sqlite_ext/BUILD.gn b/trace_streamer/src/base/sqlite_ext/BUILD.gn index 206301b1b..28fc04b0b 100644 --- a/trace_streamer/src/base/sqlite_ext/BUILD.gn +++ b/trace_streamer/src/base/sqlite_ext/BUILD.gn @@ -13,13 +13,17 @@ import("//build/ohos.gni") import("../../../build/ts.gni") -ohos_source_set("sqliteext") { - sources = [ "sqlite_ext_funcs.cpp" ] +config("sqlite_ext_cfg") { include_dirs = [ "${THIRD_PARTY}/sqlite/include", "${THIRD_PARTY}/bounds_checking_function/include", "..", + ".", ] +} +ohos_source_set("sqliteext") { + sources = [ "sqlite_ext_funcs.cpp" ] + public_configs = [ ":sqlite_ext_cfg" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } diff --git a/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.cpp b/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.cpp index 28c01897d..fcf6672ff 100644 --- a/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.cpp +++ b/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.cpp @@ -18,7 +18,7 @@ #include #include "log.h" #include "sqlite3.h" -#include "../base/string_help.h" +#include "string_help.h" namespace SysTuning { namespace base { /* diff --git a/trace_streamer/src/base/ts_common.h b/trace_streamer/src/base/ts_common.h index a3e02f0f5..0ed29f71a 100644 --- a/trace_streamer/src/base/ts_common.h +++ b/trace_streamer/src/base/ts_common.h @@ -21,6 +21,7 @@ #include #include #include +#include "log.h" using ClockId = uint32_t; constexpr size_t G_CHUNK_SIZE = 1024 * 1024; constexpr size_t FLUSH_CHUNK_THRESHOLD = G_CHUNK_SIZE - 10000; diff --git a/trace_streamer/src/cfg/trace_streamer_config.cpp b/trace_streamer/src/cfg/trace_streamer_config.cpp index bcd499444..4ae38a463 100644 --- a/trace_streamer/src/cfg/trace_streamer_config.cpp +++ b/trace_streamer/src/cfg/trace_streamer_config.cpp @@ -14,12 +14,14 @@ */ #include "trace_streamer_config.h" +#ifdef ENABLE_MEMORY #include "memory_plugin_common.pbreader.h" -#include "memory_plugin_result.pbreader.h" -#include "log.h" +#endif namespace SysTuning { namespace TraceCfg { +#ifdef ENABLE_MEMORY using namespace ProtoReader; +#endif TraceStreamerConfig::TraceStreamerConfig() { InitEventNameMap(); @@ -46,8 +48,10 @@ TraceStreamerConfig::TraceStreamerConfig() {MEM_GL_PSS, MEM_INFO_GL_PSS_DESC}, {MEM_GRAPH_PSS, MEM_INFO_GRAPH_PSS_DESC}, }; +#ifdef ENABLE_MEMORY InitSysMemMap(); InitSysVmemMap(); +#endif InitSecurityMap(); if (eventNameMap_.size() != TRACE_EVENT_MAX) { TS_LOGF("eventNameMap_.size() max be %d, logic error", TRACE_EVENT_MAX); @@ -233,6 +237,7 @@ void TraceStreamerConfig::InitEventNameMap() InitEbpfEventNameMap(); InitHookEventNameMap(); } +#ifdef ENABLE_MEMORY void TraceStreamerConfig::InitSysMemMap() { sysMemNameMap_ = {{SysMeminfoType::PMEM_UNSPECIFIED, SYS_MEMINFO_UNSPECIFIED_DESC}, @@ -484,6 +489,7 @@ void TraceStreamerConfig::InitSysVmemMap() InitPgEventSysVmemMap(); InitOtherEventSysVmemMap(); } +#endif inline void TraceStreamerConfig::InitBinderEventSecurityMap() { eventParserStatSeverityDescMap_.emplace(TRACE_EVENT_BINDER_TRANSACTION, statSeverityDescMap_); diff --git a/trace_streamer/src/cfg/trace_streamer_config.h b/trace_streamer/src/cfg/trace_streamer_config.h index 056732c45..4865fe8cd 100644 --- a/trace_streamer/src/cfg/trace_streamer_config.h +++ b/trace_streamer/src/cfg/trace_streamer_config.h @@ -207,9 +207,8 @@ private: void InitOtherEventNameMap(); void InitEbpfEventNameMap(); void InitHookEventNameMap(); - +#ifdef ENABLE_MEMORY void InitSysMemMap(); - void InitSysVmemMap(); void InitNrZoneEventSysVmemMap(); void InitNrDirtierEventSysVmemMap(); @@ -222,6 +221,7 @@ private: void InitWorkingSetEventSysVmemMap(); void InitPgEventSysVmemMap(); void InitOtherEventSysVmemMap(); +#endif void InitSecurityMap(); void InitBinderEventSecurityMap(); diff --git a/trace_streamer/src/filter/BUILD.gn b/trace_streamer/src/filter/BUILD.gn index f12bad783..6d0cb3ba1 100644 --- a/trace_streamer/src/filter/BUILD.gn +++ b/trace_streamer/src/filter/BUILD.gn @@ -77,52 +77,37 @@ ohos_source_set("filter") { part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "animation_filter.cpp", - "animation_filter.h", "app_start_filter.cpp", - "app_start_filter.h", "args_filter.cpp", - "args_filter.h", "binder_filter.cpp", - "binder_filter.h", "clock_filter_ex.cpp", "cpu_filter.cpp", "filter_base.cpp", - "filter_base.h", "filter_filter.cpp", - "filter_filter.h", "frame_filter.cpp", - "frame_filter.h", "irq_filter.cpp", - "irq_filter.h", "measure_filter.cpp", - "measure_filter.h", "process_filter.cpp", - "process_filter.h", "slice_filter.cpp", - "slice_filter.h", "stat_filter.cpp", - "stat_filter.h", "system_event_measure_filter.cpp", - "system_event_measure_filter.h", "task_pool_filter.cpp", - "task_pool_filter.h", ] public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp" ] - deps = [] if (enable_hiperf) { - deps += [ "perf_filter:hiperf_filter" ] + public_deps += [ "perf_filter:hiperf_filter" ] } if (enable_native_hook) { - deps += [ "hook_filter:native_hook_filter" ] + public_deps += [ "hook_filter:native_hook_filter" ] public_deps += [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:native_hook_data_reader", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:ts_native_hook_cpp", ] } if (enable_hisysevent) { - deps += [ "hi_sysevent_filter:hi_sysevent_filter" ] + public_deps += [ "hi_sysevent_filter:hi_sysevent_filter" ] } public_configs = [ ":filter_cfg" ] } diff --git a/trace_streamer/src/filter/args_filter.cpp b/trace_streamer/src/filter/args_filter.cpp index 1c1e456d7..2c919775a 100644 --- a/trace_streamer/src/filter/args_filter.cpp +++ b/trace_streamer/src/filter/args_filter.cpp @@ -15,7 +15,6 @@ #include "args_filter.h" #include "filter_filter.h" -#include "log.h" #include "ts_common.h" namespace SysTuning { diff --git a/trace_streamer/src/filter/frame_filter.cpp b/trace_streamer/src/filter/frame_filter.cpp index 2a153875a..f67fb0bf3 100644 --- a/trace_streamer/src/filter/frame_filter.cpp +++ b/trace_streamer/src/filter/frame_filter.cpp @@ -15,7 +15,6 @@ #include "frame_filter.h" #include #include -#include "log.h" namespace SysTuning { namespace TraceStreamer { diff --git a/trace_streamer/src/filter/hi_sysevent_filter/hi_sysevent_measure_filter.cpp b/trace_streamer/src/filter/hi_sysevent_filter/hi_sysevent_measure_filter.cpp index b581b8285..8dd56f90d 100644 --- a/trace_streamer/src/filter/hi_sysevent_filter/hi_sysevent_measure_filter.cpp +++ b/trace_streamer/src/filter/hi_sysevent_filter/hi_sysevent_measure_filter.cpp @@ -16,7 +16,6 @@ #include "hi_sysevent_measure_filter.h" #include "clock_filter_ex.h" #include "filter_filter.h" -#include "log.h" #include "stat_filter.h" #include "system_event_measure_filter.h" #include "ts_common.h" diff --git a/trace_streamer/src/filter/measure_filter.cpp b/trace_streamer/src/filter/measure_filter.cpp index 1136f0f6f..d52cd2bed 100644 --- a/trace_streamer/src/filter/measure_filter.cpp +++ b/trace_streamer/src/filter/measure_filter.cpp @@ -15,7 +15,6 @@ #include "measure_filter.h" #include "filter_filter.h" -#include "log.h" #include "ts_common.h" namespace SysTuning { diff --git a/trace_streamer/src/filter/slice_filter.cpp b/trace_streamer/src/filter/slice_filter.cpp index c3798e88b..ea05ce4d6 100644 --- a/trace_streamer/src/filter/slice_filter.cpp +++ b/trace_streamer/src/filter/slice_filter.cpp @@ -19,7 +19,6 @@ #include #include "args_filter.h" -#include "log.h" #include "measure_filter.h" #include "process_filter.h" #include "stat_filter.h" diff --git a/trace_streamer/src/filter/stat_filter.cpp b/trace_streamer/src/filter/stat_filter.cpp index 5e72ed0da..fb59d83bb 100644 --- a/trace_streamer/src/filter/stat_filter.cpp +++ b/trace_streamer/src/filter/stat_filter.cpp @@ -15,7 +15,6 @@ #include "stat_filter.h" #include "filter_filter.h" -#include "log.h" #include "ts_common.h" namespace SysTuning { diff --git a/trace_streamer/src/filter/system_event_measure_filter.cpp b/trace_streamer/src/filter/system_event_measure_filter.cpp index 3721d223e..adc0c6030 100644 --- a/trace_streamer/src/filter/system_event_measure_filter.cpp +++ b/trace_streamer/src/filter/system_event_measure_filter.cpp @@ -15,7 +15,6 @@ #include "system_event_measure_filter.h" #include "filter_filter.h" -#include "log.h" #include "ts_common.h" namespace SysTuning { diff --git a/trace_streamer/src/main.cpp b/trace_streamer/src/main.cpp index 30a8ee24e..6449ed7e9 100644 --- a/trace_streamer/src/main.cpp +++ b/trace_streamer/src/main.cpp @@ -12,35 +12,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include #include #include #include #include #include #include -#include #include -#include #include #include "codec_cov.h" #include "file.h" -#include "filter/cpu_filter.h" -#include "filter/frame_filter.h" -#include "filter/slice_filter.h" -#include "log.h" -#include "metrics.h" -#include "parser/ptreader_parser/bytrace_parser/bytrace_event_parser.h" -#include "parser/ptreader_parser/ptreader_parser.h" -#include "parting_string.h" -#include "rpc_server.h" +#include "cpu_filter.h" +#include "frame_filter.h" +#include "slice_filter.h" #include "string_help.h" -#include "thread_state_flag.h" -#include "trace_streamer/trace_streamer_selector.h" -#include "trace_streamer_filters.h" +#include "trace_streamer_selector.h" #include "version.h" using namespace SysTuning::TraceStreamer; using namespace SysTuning; @@ -119,65 +107,107 @@ void PrintVersion() { (void)fprintf(stderr, "version %s\n", g_traceStreamerVersion.c_str()); } -void PrintDefaultAbilityInfo(std::string& disableInfo) +void SetFtracePluginsAbilityInfo(std::string& disableInfo, std::string& enableInfo) { #ifndef ENABLE_BYTRACE disableInfo.append("\n\tbytrace"); +#else + enableInfo.append("\n\tbytrace"); #endif #ifndef ENABLE_RAWTRACE disableInfo.append("\n\trawtrace"); +#else + enableInfo.append("\n\trawtrace"); #endif #ifndef ENABLE_HTRACE disableInfo.append("\n\thtrace"); +#else + enableInfo.append("\n\thtrace"); #endif +} +void PrintDefaultAbilityInfo(std::string& disableInfo, std::string& enableInfo) +{ + SetFtracePluginsAbilityInfo(disableInfo, enableInfo); #ifndef ENABLE_MEMORY disableInfo.append("\n\tmemory"); +#else + enableInfo.append("\n\tmemory"); #endif #ifndef ENABLE_HTDUMP disableInfo.append("\n\thidump"); +#else + enableInfo.append("\n\thidump"); #endif #ifndef ENABLE_CPUDATA disableInfo.append("\n\tcpudata"); +#else + enableInfo.append("\n\tcpudata"); #endif #ifndef ENABLE_NETWORK disableInfo.append("\n\tnetwork"); +#else + enableInfo.append("\n\tnetwork"); #endif #ifndef ENABLE_DISKIO disableInfo.append("\n\tdiskio"); +#else + enableInfo.append("\n\tdiskio"); #endif #ifndef ENABLE_PROCESS disableInfo.append("\n\tprocess"); +#else + enableInfo.append("\n\tprocess"); #endif printf( "the default support ability list:\n\thiperf,ebpf,native_hook,hilog,hisysevent,arkts\n\t" "bytrace,rawtrace,htrace,memory,hidump,cpudata,network,diskio,process\n"); } +void PrintExtendAbilityInfo(std::string& disableInfo, std::string& enableInfo) +{ +#ifndef ENABLE_STREAM_EXTEND + disableInfo.append("\n\tstream_extend"); +#else + enableInfo.append("\n\tstream_extend"); +#endif + printf("the extend support ability list:\n\tstream_extend\n"); +} void PrintAbilityInfo() { std::string disableInfo; + std::string enableInfo; #ifndef ENABLE_HIPERF disableInfo.append("\n\thiperf"); +#else + enableInfo.append("\n\thiperf"); #endif #ifndef ENABLE_EBPF disableInfo.append("\n\tebpf"); +#else + enableInfo.append("\n\tebpf"); #endif #ifndef ENABLE_NATIVE_HOOK disableInfo.append("\n\tnative_hook"); +#else + enableInfo.append("\n\tnative_hook"); #endif #ifndef ENABLE_HILOG disableInfo.append("\n\thilog"); +#else + enableInfo.append("\n\thilog"); #endif #ifndef ENABLE_HISYSEVENT disableInfo.append("\n\thisysevent"); +#else + enableInfo.append("\n\thisysevent"); #endif #ifndef ENABLE_ARKTS disableInfo.append("\n\tarkts"); +#else + enableInfo.append("\n\tarkts"); #endif - PrintDefaultAbilityInfo(disableInfo); -#ifndef ENABLE_STREAM_EXTEND - disableInfo.append("\n\tstream_extend"); -#endif - printf("the extend support ability list:\n\tstream_extend\n"); + PrintDefaultAbilityInfo(disableInfo, enableInfo); + PrintExtendAbilityInfo(disableInfo, enableInfo); + printf("the enable ability list:%s\n", enableInfo.empty() ? "\n\tnull" : enableInfo.c_str()); printf("the disable ability list:%s\n", disableInfo.empty() ? "\n\tnull" : disableInfo.c_str()); } bool ReadAndParser(SysTuning::TraceStreamer::TraceStreamerSelector& ta, int fd) diff --git a/trace_streamer/src/metrics/BUILD.gn b/trace_streamer/src/metrics/BUILD.gn index 98bbd78d2..0baf4bfac 100644 --- a/trace_streamer/src/metrics/BUILD.gn +++ b/trace_streamer/src/metrics/BUILD.gn @@ -14,25 +14,21 @@ import("//build/ohos.gni") import("../../build/ts.gni") -ohos_source_set("metrics_parser") { - subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" - part_name = "${OHOS_PROFILER_PART_NAME}" - sources = [ - "memAggStrategy.h", - "memDataStrategy.h", - "memStrategy.h", - "metrics.cpp", - "metrics.h", - "sysCallStrategy.h", - "traceStateStrategy.h", - "traceTaskStrategy.h", - ] - deps = [] +config("metrics_cfg") { include_dirs = [ + ".", "${SRC}/base", "${THIRD_PARTY}/bounds_checking_function/include", "${THIRD_PARTY}/json/single_include/nlohmann", ] +} + +ohos_source_set("metrics_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "metrics.cpp" ] + deps = [] + public_configs = [ ":metrics_cfg" ] if (enable_ts_utest && !use_wasm) { cflags = [ "-fprofile-arcs", diff --git a/trace_streamer/src/metrics/metrics.h b/trace_streamer/src/metrics/metrics.h index e295b5930..adec7c17e 100644 --- a/trace_streamer/src/metrics/metrics.h +++ b/trace_streamer/src/metrics/metrics.h @@ -20,7 +20,6 @@ #include #include #include "json.hpp" -#include "log.h" #include "memAggStrategy.h" #include "memStrategy.h" #include "metaDataStrategy.h" diff --git a/trace_streamer/src/parser/BUILD.gn b/trace_streamer/src/parser/BUILD.gn index 8baf280a2..421a22a3d 100644 --- a/trace_streamer/src/parser/BUILD.gn +++ b/trace_streamer/src/parser/BUILD.gn @@ -24,14 +24,20 @@ config("parser_base_cfg") { "${SRC}/trace_data", "${SRC}/include", "${SRC}/filter", + "${SRC}/filter/hi_sysevent_filter", + "${SRC}/filter/hook_filter", + "${SRC}/filter/perf_filter", "${SRC}", ".", + "ptreader_parser", "pbreader_parser", "pbreader_parser/htrace_parser", "rawtrace_parser", + "ebpf_parser", "../proto_reader/include", "${THIRD_PARTY}/bounds_checking_function/include", "${THIRD_PARTY}/json/single_include/nlohmann", + "${THIRD_PARTY}/profiler/device/plugins/ftrace_plugin/include", ] include_dirs += [ "${PERF_DIR}/hiperf/include/nonlinux/linux", @@ -89,6 +95,7 @@ config("hisysevent_parser_cfg") { "pbreader_parser", "pbreader_parser/hisysevent_parser", "ptreader_parser/hisysevent_parser", + "${SRC}/filter/hi_sysevent_filter", ] } @@ -101,25 +108,14 @@ ohos_source_set("parser") { "thread_state_flag.cpp", ] - deps = [ - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:cpu_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/diskio_data:diskio_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hidump_data:hidump_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/js_memory:js_memory_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/network_data:network_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/process_data:process_data_reader", - ] - deps += [ "pbreader_parser:pbreader_parser" ] - deps += [ "ptreader_parser:ptreader_parser_src" ] + public_deps = [] + public_deps += [ "pbreader_parser:pbreader_parser_src" ] + public_deps += [ "ptreader_parser:ptreader_parser_src" ] if (enable_rawtrace) { - deps += [ "rawtrace_parser:rawtrace_parser" ] + public_deps += [ "rawtrace_parser:rawtrace_parser" ] } - - # for hook,perf,ebpf - deps += [ "${PERF_DIR}/hiperf:hiperf_platform_common" ] if (enable_ebpf) { - deps += [ "ebpf_parser:ebpf_parser" ] + public_deps += [ "ebpf_parser:ebpf_parser" ] } public_configs = [ ":parser_base_cfg" ] } diff --git a/trace_streamer/src/parser/ebpf_parser/BUILD.gn b/trace_streamer/src/parser/ebpf_parser/BUILD.gn index ab1c92cae..9a1512a2a 100644 --- a/trace_streamer/src/parser/ebpf_parser/BUILD.gn +++ b/trace_streamer/src/parser/ebpf_parser/BUILD.gn @@ -85,7 +85,10 @@ ohos_static_library("ebpf_parser") { "paged_memory_data_parser.cpp", ] public_configs = [ ":ebpf_parser_cfg" ] - public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader" ] + public_deps = [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader", + "${PERF_DIR}/hiperf:hiperf_platform_common", + ] deps = [ "${THIRD_PARTY}/protobuf:protobuf_lite_static", "${THIRD_PARTY}/protobuf:protobuf_static", diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.h b/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.h index f1d9572fd..ec3ed16e8 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.h +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.h @@ -20,7 +20,7 @@ #include "ebpf_data_structure.h" #include "file_system_data_parser.h" #include "paged_memory_data_parser.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_filters.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.h b/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.h index 258049629..f207e8120 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.h +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.h @@ -26,7 +26,7 @@ #include "process_filter.h" #include "quatra_map.h" #include "string_help.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_filters.h" #include "unordered_map" diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.h b/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.h index 7944ce7bb..f52b25777 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.h +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.h @@ -26,7 +26,7 @@ #include "process_filter.h" #include "quatra_map.h" #include "string_help.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_filters.h" #include "unordered_map" #include "pbreader_file_header.h" diff --git a/trace_streamer/src/parser/hiperf_parser/BUILD.gn b/trace_streamer/src/parser/hiperf_parser/BUILD.gn index 06047b5c6..48697bff5 100644 --- a/trace_streamer/src/parser/hiperf_parser/BUILD.gn +++ b/trace_streamer/src/parser/hiperf_parser/BUILD.gn @@ -97,8 +97,11 @@ ohos_static_library("hiperf_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "perf_data_parser.cpp" ] - public_configs = [ ":hiperf_parser_cfg" ] - deps = [ + public_configs = [ + ":hiperf_parser_cfg", + "../../filter/perf_filter:hiperf_filter_cfg", + ] + public_deps = [ "${PERF_DIR}/hiperf:hiperf_platform_common", "${THIRD_PARTY}/protobuf:protobuf_lite_static", "${THIRD_PARTY}/protobuf:protobuf_static", diff --git a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp index 08425bb1e..2c4068c59 100644 --- a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp +++ b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp @@ -15,7 +15,7 @@ #include "perf_data_parser.h" #include "clock_filter_ex.h" #include "file.h" -#include "perf_filter/perf_data_filter.h" +#include "perf_data_filter.h" #include "stat_filter.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.h b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.h index 2709ac8b0..6ea2d2341 100644 --- a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.h +++ b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.h @@ -23,7 +23,6 @@ #include "event_parser_base.h" #include "pbreader_file_header.h" #include "htrace_plugin_time_parser.h" -#include "log.h" #if is_mingw #define unw_word_t uint64_t #endif @@ -33,7 +32,7 @@ #include "perf_file_reader.h" #include "quatra_map.h" #include "report.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_filters.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/pbreader_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/BUILD.gn index 660b5b309..5bac80a03 100644 --- a/trace_streamer/src/parser/pbreader_parser/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/BUILD.gn @@ -17,6 +17,7 @@ ohos_source_set("pbreader_parser_src") { part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "../parser_base.cpp", + "pbreader_clock_detail_parser.cpp", "pbreader_parser.cpp", ] include_dirs = [ @@ -36,6 +37,7 @@ ohos_source_set("pbreader_parser_src") { "${THIRD_PARTY}/json/single_include/nlohmann", "../../filter", "../../base", + "../../rpc", "../ebpf_parser", ] include_dirs += [ @@ -76,7 +78,7 @@ ohos_source_set("pbreader_parser_src") { cflags = [ "-includeMingW64Fix.h" ] } public_configs = [ "../ebpf_parser:ebpf_parser_cfg" ] - public_deps = [] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ftrace_data_reader" ] if (enable_hiperf) { public_deps += [ "../hiperf_parser:hiperf_parser" ] } @@ -117,25 +119,21 @@ ohos_source_set("pbreader_parser_src") { public_deps += [ "${EXTEND_SRC}/parser/pbreader_stream_parser:stream_extend_parser" ] } - deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp_standard" ] -} -group("pbreader_parser") { - deps = [ - ":pbreader_parser_src", + public_deps += [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp_standard", "${THIRD_PARTY}/protobuf:protobuf_lite_static", "${THIRD_PARTY}/protobuf:protobuf_static", "//third_party/perf_include/hiviewdfx:hiviewdfx", ] - if (!use_wasm && !is_win && !is_mingw && !is_mac && !is_test) { if (!is_independent_compile) { if (target_cpu == "arm64") { - deps += [ "//third_party/libunwind:unwind_source_arm64_opt" ] + public_deps += [ "//third_party/libunwind:unwind_source_arm64_opt" ] } else { - deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ] + public_deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ] } } else { - deps += [ "${THIRD_PARTY}/libunwind:libunwind" ] + public_deps += [ "${THIRD_PARTY}/libunwind:libunwind" ] } } } diff --git a/trace_streamer/src/parser/pbreader_parser/arkts/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/arkts/BUILD.gn index 3b4ab4e7a..fc7f12436 100644 --- a/trace_streamer/src/parser/pbreader_parser/arkts/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/arkts/BUILD.gn @@ -13,6 +13,10 @@ import("//build/ohos.gni") import("../../../../build/ts.gni") +config("arkts_parser_cfg") { + include_dirs = [ "." ] +} + ohos_static_library("pbreader_arkts_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" @@ -20,10 +24,13 @@ ohos_static_library("pbreader_arkts_parser") { "pbreader_js_cpu_profiler_parser.cpp", "pbreader_js_memory_parser.cpp", ] - include_dirs = [ "." ] public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/js_memory:js_memory_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/js_memory:ts_js_memory_data_cpp", + ] + public_configs = [ + ":arkts_parser_cfg", + "../../:parser_base_cfg", ] - public_configs = [ "../../:parser_base_cfg" ] } diff --git a/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/BUILD.gn index d838f439b..baf735b7f 100644 --- a/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/BUILD.gn @@ -13,11 +13,18 @@ import("//build/ohos.gni") import("../../../../build/ts.gni") +config("cpu_data_parser_cfg") { + include_dirs = [ "." ] +} + ohos_static_library("cpu_data_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "pbreader_cpu_data_parser.cpp" ] include_dirs = [ "." ] public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:cpu_data_reader" ] - public_configs = [ "../../:parser_base_cfg" ] + public_configs = [ + ":cpu_data_parser_cfg", + "../../:parser_base_cfg", + ] } diff --git a/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_cpu_data_parser.h b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_cpu_data_parser.h index 3abac2716..e981ed0a9 100644 --- a/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_cpu_data_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_cpu_data_parser.h @@ -20,7 +20,7 @@ #include "cpu_plugin_result.pbreader.h" #include "event_parser_base.h" #include "htrace_plugin_time_parser.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_config.h" #include "trace_streamer_filters.h" diff --git a/trace_streamer/src/parser/pbreader_parser/disk_io_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/disk_io_parser/BUILD.gn index 60fbc0ae3..b09644889 100644 --- a/trace_streamer/src/parser/pbreader_parser/disk_io_parser/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/disk_io_parser/BUILD.gn @@ -13,11 +13,18 @@ import("//build/ohos.gni") import("../../../../build/ts.gni") +config("disk_io_parser_cfg") { + include_dirs = [ "." ] +} + ohos_static_library("disk_io_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "pbreader_disk_io_parser.cpp" ] include_dirs = [ "." ] public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/diskio_data:diskio_data_reader" ] - public_configs = [ "../../:parser_base_cfg" ] + public_configs = [ + ":disk_io_parser_cfg", + "../../:parser_base_cfg", + ] } diff --git a/trace_streamer/src/parser/pbreader_parser/hidump_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/hidump_parser/BUILD.gn index 2dfd3f05f..3d2ce6718 100644 --- a/trace_streamer/src/parser/pbreader_parser/hidump_parser/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/hidump_parser/BUILD.gn @@ -13,11 +13,18 @@ import("//build/ohos.gni") import("../../../../build/ts.gni") +config("hidump_parser_cfg") { + include_dirs = [ "." ] +} + ohos_static_library("pbreader_hidump_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "pbreader_hidump_parser.cpp" ] include_dirs = [ "." ] public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hidump_data:hidump_data_reader" ] - public_configs = [ "../../:parser_base_cfg" ] + public_configs = [ + ":hidump_parser_cfg", + "../../:parser_base_cfg", + ] } diff --git a/trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_hidump_parser.h b/trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_hidump_parser.h index c4ee0d92e..fd9a6bfc2 100644 --- a/trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_hidump_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_hidump_parser.h @@ -20,7 +20,7 @@ #include "common_types.h" #include "event_parser_base.h" #include "htrace_plugin_time_parser.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_config.h" #include "trace_streamer_filters.h" diff --git a/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.cpp b/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.cpp index a844dfaa5..b165a6750 100644 --- a/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.cpp @@ -16,7 +16,6 @@ #include "clock_filter_ex.h" #include "event_parser_base.h" #include "hilog_plugin_result.pbreader.h" -#include "htrace_event_parser.h" #include "process_filter.h" #include "stat_filter.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.h b/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.h index 3ad5a8090..e7c521e61 100644 --- a/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.h @@ -19,7 +19,7 @@ #include #include "common_types.h" #include "event_parser_base.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "hilog_plugin_result.pb.h" #include "htrace_plugin_time_parser.h" #include "trace_streamer_config.h" diff --git a/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_hisysevent_parser.h b/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_hisysevent_parser.h index 35d52c9cd..7a21d114f 100644 --- a/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_hisysevent_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_hisysevent_parser.h @@ -19,11 +19,11 @@ #include "clock_filter_ex.h" #include "event_parser_base.h" -#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" +#include "hi_sysevent_measure_filter.h" #include "hisysevent_plugin_config.pbreader.h" #include "hisysevent_plugin_result.pbreader.h" #include "htrace_plugin_time_parser.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_filters.h" #include "ts_common.h" diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/htrace_parser/BUILD.gn index 368e79f27..fe206f4be 100644 --- a/trace_streamer/src/parser/pbreader_parser/htrace_parser/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/htrace_parser/BUILD.gn @@ -21,7 +21,6 @@ ohos_static_library("pbreader_htrace_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ - "htrace_clock_detail_parser.cpp", "htrace_cpu_detail_parser.cpp", "htrace_event_parser.cpp", "htrace_symbols_detail_parser.cpp", diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.cpp b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.cpp index 51856ead8..62da51021 100644 --- a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ #include "htrace_cpu_detail_parser.h" -#include "htrace_event_parser.h" #include "stat_filter.h" #include "trace_plugin_result.pbreader.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.h b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.h index 6adddb2c3..1de2ae8a5 100644 --- a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.h @@ -21,10 +21,9 @@ #include #include "event_parser_base.h" #include "htrace_event_parser.h" -#include "log.h" #include "parser_base.h" #include "proto_reader_help.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_plugin_result.pbreader.h" #include "trace_streamer_filters.h" diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.cpp b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.cpp index 2f766e160..a36c3c075 100644 --- a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.cpp @@ -27,7 +27,6 @@ #include "ipi.pbreader.h" #include "irq_filter.h" #include "irq.pbreader.h" -#include "log.h" #include "measure_filter.h" #include "oom.pbreader.h" #include "power.pbreader.h" @@ -447,7 +446,7 @@ bool HtraceEventParser::BinderTractionAllocBufEvent(const EventInfo& event) cons uint64_t dataSize = msg.data_size(); uint64_t offsetsSize = msg.offsets_size(); streamFilters_->binderFilter_->TransactionAllocBuf(event.timeStamp_, event.pid_, dataSize, offsetsSize); - TS_LOGD("dataSize:%lu, offsetSize:%lu", dataSize, offsetsSize); + TS_LOGD("dataSize:%" PRIu64 ", offsetSize:%" PRIu64 "", dataSize, offsetsSize); return true; } bool HtraceEventParser::BinderTractionEvent(const EventInfo& event) const diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.h b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.h index b7186fa21..3f9d93f20 100644 --- a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.h @@ -25,10 +25,8 @@ #include "event_parser_base.h" #include "ftrace_event.pbreader.h" -#include "google/protobuf/message_lite.h" -#include "log.h" #include "print_event_parser.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_plugin_result.pbreader.h" #include "trace_streamer_config.h" #include "trace_streamer_filters.h" @@ -36,7 +34,6 @@ namespace SysTuning { namespace TraceStreamer { -using namespace google::protobuf; class HtraceEventParser : private EventParserBase { public: HtraceEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filter); diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.cpp b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.cpp index 7b9fe21c9..bcca74c22 100644 --- a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ #include "htrace_symbols_detail_parser.h" -#include "htrace_event_parser.h" namespace SysTuning { namespace TraceStreamer { HtraceSymbolsDetailParser::HtraceSymbolsDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.h b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.h index 39a79e0ef..f4a67862f 100644 --- a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.h @@ -20,8 +20,8 @@ #include #include #include -#include "proto_reader/include/data_area.h" -#include "trace_data/trace_data_cache.h" +#include "data_area.h" +#include "trace_data_cache.h" #include "trace_plugin_result.pbreader.h" #include "trace_streamer_filters.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/pbreader_parser/mem_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/mem_parser/BUILD.gn index 04583776d..b1e09e06d 100644 --- a/trace_streamer/src/parser/pbreader_parser/mem_parser/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/mem_parser/BUILD.gn @@ -13,11 +13,18 @@ import("//build/ohos.gni") import("../../../../build/ts.gni") +config("mem_parser_cfg") { + include_dirs = [ "." ] +} + ohos_static_library("pbreader_mem_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "pbreader_mem_parser.cpp" ] include_dirs = [ "." ] public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader" ] - public_configs = [ "../../:parser_base_cfg" ] + public_configs = [ + ":mem_parser_cfg", + "../../:parser_base_cfg", + ] } diff --git a/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.h b/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.h index 27785f9ab..015511e58 100644 --- a/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.h @@ -25,7 +25,7 @@ #include "htrace_plugin_time_parser.h" #include "memory_plugin_result.pbreader.h" #include "string_help.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_config.h" #include "trace_streamer_filters.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/pbreader_parser/native_hook_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/BUILD.gn index 2c059ea25..a9f2279d0 100644 --- a/trace_streamer/src/parser/pbreader_parser/native_hook_parser/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/BUILD.gn @@ -13,10 +13,11 @@ import("//build/ohos.gni") import("../../../../build/ts.gni") -config("native_hook_cfg") { +config("native_hook_parser_cfg") { include_dirs = [ ".", "//third_party/hiperf/include", + "${SRC}/filter/hook_filter", ] } @@ -28,9 +29,10 @@ ohos_static_library("native_hook_parser") { "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ftrace_data_reader", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:native_hook_data_reader", + "${PERF_DIR}/hiperf:hiperf_platform_common", ] public_configs = [ - ":native_hook_cfg", + ":native_hook_parser_cfg", "../../:parser_base_cfg", ] } diff --git a/trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_native_hook_parser.h b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_native_hook_parser.h index 62dae9f5f..1f09f773f 100644 --- a/trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_native_hook_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_native_hook_parser.h @@ -20,10 +20,9 @@ #include #include "common_types.h" #include "event_parser_base.h" -#include "htrace_event_parser.h" #include "htrace_plugin_time_parser.h" -#include "hook_filter/native_hook_filter.h" -#include "hook_filter/offline_symbolization_filter.h" +#include "native_hook_filter.h" +#include "offline_symbolization_filter.h" #include "trace_streamer_config.h" #include "trace_streamer_filters.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/pbreader_parser/network_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/network_parser/BUILD.gn index a7e6cfaca..52c8f726c 100644 --- a/trace_streamer/src/parser/pbreader_parser/network_parser/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/network_parser/BUILD.gn @@ -13,11 +13,18 @@ import("//build/ohos.gni") import("../../../../build/ts.gni") +config("network_parser_cfg") { + include_dirs = [ "." ] +} + ohos_static_library("network_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "pbreader_network_parser.cpp" ] include_dirs = [ "." ] public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/network_data:network_data_reader" ] - public_configs = [ "../../:parser_base_cfg" ] + public_configs = [ + ":network_parser_cfg", + "../../:parser_base_cfg", + ] } diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_clock_detail_parser.cpp b/trace_streamer/src/parser/pbreader_parser/pbreader_clock_detail_parser.cpp similarity index 90% rename from trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_clock_detail_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/pbreader_clock_detail_parser.cpp index 30cfa09b1..fe264f7d4 100644 --- a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_clock_detail_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/pbreader_clock_detail_parser.cpp @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_clock_detail_parser.h" +#include "pbreader_clock_detail_parser.h" #include "clock_filter_ex.h" -#include "htrace_event_parser.h" +#include "trace_plugin_result.pbreader.h" #include "measure_filter.h" #include "process_filter.h" #include "stat_filter.h" @@ -22,7 +22,7 @@ namespace SysTuning { namespace TraceStreamer { -HtraceClockDetailParser::HtraceClockDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters) +PbreaderClockDetailParser::PbreaderClockDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters) : EventParserBase(dataCache, filters) { for (auto i = 0; i < MEM_MAX; i++) { @@ -32,8 +32,8 @@ HtraceClockDetailParser::HtraceClockDetailParser(TraceDataCache* dataCache, cons } } -HtraceClockDetailParser::~HtraceClockDetailParser() = default; -void HtraceClockDetailParser::Parse(const ProtoReader::BytesView& tracePacket) const +PbreaderClockDetailParser::~PbreaderClockDetailParser() = default; +void PbreaderClockDetailParser::Parse(const ProtoReader::BytesView& tracePacket) const { if (traceDataCache_->isSplitFile_) { return; @@ -62,7 +62,7 @@ void HtraceClockDetailParser::Parse(const ProtoReader::BytesView& tracePacket) c streamFilters_->statFilter_->IncreaseStat(TRACE_EVENT_CLOCK_SYNC, STAT_EVENT_RECEIVED); } -void HtraceClockDetailParser::Parse(const ProfilerTraceFileHeader* profilerTraceFileHeader) const +void PbreaderClockDetailParser::Parse(const ProfilerTraceFileHeader* profilerTraceFileHeader) const { if (streamFilters_->clockFilter_->HasInitSnapShot()) { TS_LOGW("already has clock snapshot!!!"); diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_clock_detail_parser.h b/trace_streamer/src/parser/pbreader_parser/pbreader_clock_detail_parser.h similarity index 86% rename from trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_clock_detail_parser.h rename to trace_streamer/src/parser/pbreader_parser/pbreader_clock_detail_parser.h index 9ea4c0dbb..e5415868b 100644 --- a/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_clock_detail_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/pbreader_clock_detail_parser.h @@ -23,16 +23,16 @@ #include "file.h" #include "proto_reader_help.h" #include "pbreader_file_header.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_config.h" #include "trace_streamer_filters.h" namespace SysTuning { namespace TraceStreamer { -class HtraceClockDetailParser : public EventParserBase { +class PbreaderClockDetailParser : public EventParserBase { public: - HtraceClockDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters); - ~HtraceClockDetailParser(); + PbreaderClockDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters); + ~PbreaderClockDetailParser(); void Parse(const ProtoReader::BytesView& tracePacket) const; void Parse(const ProfilerTraceFileHeader* profilerTraceFileHeader) const; diff --git a/trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp b/trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp index 8416591d3..68cefa87f 100644 --- a/trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp @@ -24,22 +24,21 @@ #include "ftrace_event.pbreader.h" #include "trace_plugin_result.pbreader.h" #endif -#include "log.h" #ifdef ENABLE_MEMORY #include "memory_plugin_result.pbreader.h" #endif #include "stat_filter.h" #if IS_WASM -#include "../rpc/wasm_func.h" +#include "wasm_func.h" #endif namespace SysTuning { namespace TraceStreamer { PbreaderParser::PbreaderParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters) : ParserBase(filters), + pbreaderClockDetailParser_(std::make_unique(dataCache, filters)), #ifdef ENABLE_HTRACE htraceCpuDetailParser_(std::make_unique(dataCache, filters)), htraceSymbolsDetailParser_(std::make_unique(dataCache, filters)), - htraceClockDetailParser_(std::make_unique(dataCache, filters)), #endif #ifdef ENABLE_MEMORY pbreaderMemParser_(std::make_unique(dataCache, filters)), @@ -165,6 +164,7 @@ void PbreaderParser::InitPluginNameIndex() #endif } +#if defined(ENABLE_HIPERF) || defined(ENABLE_NATIVE_HOOK) || defined(ENABLE_EBPF) void PbreaderParser::ParserFileSO(std::string& directory, const std::vector& relativeFilePaths) { for (const auto& filePath : relativeFilePaths) { @@ -176,6 +176,7 @@ void PbreaderParser::ParserFileSO(std::string& directory, const std::vectorPerfReloadSymbolFiles(dirs); #endif +#if defined(ENABLE_HIPERF) || defined(ENABLE_NATIVE_HOOK) || defined(ENABLE_EBPF) ParserFileSO(symbolsPath, symbolsPaths); +#endif #ifdef ENABLE_NATIVE_HOOK if (traceDataCache_->GetNativeHookFrameData()->Size() > 0) { pbreaderNativeHookParser_->NativeHookReloadElfSymbolTable(symbolsFiles_); @@ -630,10 +633,6 @@ void PbreaderParser::ParseMemory(const ProtoReader::ProfilerPluginData_Reader& p PbreaderDataSegment& dataSeg) { BuiltinClocks clockId = TS_CLOCK_REALTIME; - auto clockIdTemp = pluginDataZero.clock_id(); - if (clockIdTemp == ProtoReader::ProfilerPluginData_ClockId_CLOCKID_REALTIME) { - clockId = TS_CLOCK_REALTIME; - } dataSourceTypeMemClockid_ = clockId; dataSeg.dataType = DATA_SOURCE_TYPE_MEM; dataSeg.clockId = clockId; @@ -686,8 +685,8 @@ void PbreaderParser::ParseFtrace(PbreaderDataSegment& dataSeg) ProtoReader::FtraceCpuStatsMsg_Reader ftraceCpuStatsMsg(cpuStats.data_, cpuStats.size_); auto s = *ftraceCpuStatsMsg.per_cpu_stats(); ProtoReader::PerCpuStatsMsg_Reader perCpuStatsMsg(s.data_, s.size_); - TS_LOGD("s.overrun():%lu", perCpuStatsMsg.overrun()); - TS_LOGD("s.dropped_events():%lu", perCpuStatsMsg.dropped_events()); + TS_LOGD("s.overrun():%" PRIu64 "", perCpuStatsMsg.overrun()); + TS_LOGD("s.dropped_events():%" PRIu64 "", perCpuStatsMsg.dropped_events()); auto clock = ftraceCpuStatsMsg.trace_clock().ToStdString(); if (clock == "boot") { clock_ = TS_CLOCK_BOOTTIME; @@ -713,7 +712,7 @@ void PbreaderParser::ParseFtrace(PbreaderDataSegment& dataSeg) haveSplitSeg = true; } if (tracePluginResult.has_clocks_detail()) { - htraceClockDetailParser_->Parse(dataSeg.protoData); // has Event + pbreaderClockDetailParser_->Parse(dataSeg.protoData); // has Event haveSplitSeg = true; } if (traceDataCache_->isSplitFile_ && haveSplitSeg) { @@ -1091,9 +1090,7 @@ bool PbreaderParser::InitProfilerTraceFileHeader() const int32_t DATA_TYPE_CLOCK = 100; TraceStreamer_Plugin_Out_SendData(reinterpret_cast(buffer), packetHeaderLength_, DATA_TYPE_CLOCK); #endif -#ifdef ENABLE_HTRACE - htraceClockDetailParser_->Parse(pHeader); -#endif + pbreaderClockDetailParser_->Parse(pHeader); return true; } } // namespace TraceStreamer diff --git a/trace_streamer/src/parser/pbreader_parser/pbreader_parser.h b/trace_streamer/src/parser/pbreader_parser/pbreader_parser.h index f0be66e21..670852347 100644 --- a/trace_streamer/src/parser/pbreader_parser/pbreader_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/pbreader_parser.h @@ -28,43 +28,42 @@ #include "ebpf_data_parser.h" #endif #include "file.h" +#include "pbreader_clock_detail_parser.h" #ifdef ENABLE_HTRACE -#include "htrace_clock_detail_parser.h" #include "htrace_cpu_detail_parser.h" #include "htrace_symbols_detail_parser.h" #endif #include "htrace_plugin_time_parser.h" #ifdef ENABLE_CPUDATA -#include "cpu_data_parser/pbreader_cpu_data_parser.h" +#include "pbreader_cpu_data_parser.h" #endif #ifdef ENABLE_DISKIO -#include "disk_io_parser/pbreader_disk_io_parser.h" +#include "pbreader_disk_io_parser.h" #endif #ifdef ENABLE_HTDUMP -#include "hidump_parser/pbreader_hidump_parser.h" +#include "pbreader_hidump_parser.h" #endif #ifdef ENABLE_HILOG -#include "hilog_parser/pbreader_hilog_parser.h" +#include "pbreader_hilog_parser.h" #endif #ifdef ENABLE_HISYSEVENT -#include "hisysevent_parser/pbreader_hisysevent_parser.h" +#include "pbreader_hisysevent_parser.h" #endif #ifdef ENABLE_ARKTS -#include "arkts/pbreader_js_memory_parser.h" +#include "pbreader_js_memory_parser.h" #endif #ifdef ENABLE_MEMORY -#include "mem_parser/pbreader_mem_parser.h" +#include "pbreader_mem_parser.h" #endif #ifdef ENABLE_NATIVE_HOOK -#include "native_hook_parser/pbreader_native_hook_parser.h" +#include "pbreader_native_hook_parser.h" #endif #ifdef ENABLE_NETWORK -#include "network_parser/pbreader_network_parser.h" +#include "pbreader_network_parser.h" #endif #ifdef ENABLE_PROCESS -#include "process_parser/pbreader_process_parser.h" +#include "pbreader_process_parser.h" #endif -#include "log.h" #include "parser_base.h" #include "pbreader_file_header.h" #ifdef ENABLE_HIPERF @@ -73,7 +72,7 @@ #include "proto_reader_help.h" #include "string_help.h" #include "symbols_file.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_filters.h" #include "ts_common.h" #ifdef ENABLE_STREAM_EXTEND @@ -94,7 +93,9 @@ public: #ifdef ENABLE_ARKTS void EnableFileSeparate(bool enabled); #endif +#if defined(ENABLE_HIPERF) || defined(ENABLE_NATIVE_HOOK) || defined(ENABLE_EBPF) void ParserFileSO(std::string& directory, const std::vector& relativeFilePaths); +#endif #ifdef ENABLE_HIPERF void TraceDataSegmentEnd(bool isSplitFile); void StoreTraceDataSegment(std::unique_ptr bufferStr, size_t size, int32_t isFinish); @@ -250,10 +251,10 @@ private: const size_t packetSegLength_ = 4; const size_t packetHeaderLength_ = 1024; TraceDataCache* traceDataCache_; + std::unique_ptr pbreaderClockDetailParser_; #ifdef ENABLE_HTRACE std::unique_ptr htraceCpuDetailParser_; std::unique_ptr htraceSymbolsDetailParser_; - std::unique_ptr htraceClockDetailParser_; ClockId dataSourceTypeTraceClockid_ = TS_CLOCK_UNKNOW; bool onlyParseFtrace_ = false; #endif diff --git a/trace_streamer/src/parser/pbreader_parser/process_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/process_parser/BUILD.gn index 0b93f72c1..31d571e38 100644 --- a/trace_streamer/src/parser/pbreader_parser/process_parser/BUILD.gn +++ b/trace_streamer/src/parser/pbreader_parser/process_parser/BUILD.gn @@ -13,6 +13,10 @@ import("//build/ohos.gni") import("../../../../build/ts.gni") +config("process_parser_cfg") { + include_dirs = [ "." ] +} + ohos_static_library("process_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" @@ -22,5 +26,8 @@ ohos_static_library("process_parser") { "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp_standard", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/process_data:process_data_reader", ] - public_configs = [ "../../:parser_base_cfg" ] + public_configs = [ + ":process_parser_cfg", + "../../:parser_base_cfg", + ] } diff --git a/trace_streamer/src/parser/print_event_parser.h b/trace_streamer/src/parser/print_event_parser.h index 9326c39ac..bee64b767 100644 --- a/trace_streamer/src/parser/print_event_parser.h +++ b/trace_streamer/src/parser/print_event_parser.h @@ -19,10 +19,10 @@ #include #include "common_types.h" #include "event_parser_base.h" -#include "filter/measure_filter.h" -#include "filter/process_filter.h" -#include "filter/slice_filter.h" -#include "filter/task_pool_filter.h" +#include "measure_filter.h" +#include "process_filter.h" +#include "slice_filter.h" +#include "task_pool_filter.h" #include "string_to_numerical.h" #include "trace_streamer_config.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/ptreader_parser/bytrace_parser/BUILD.gn b/trace_streamer/src/parser/ptreader_parser/bytrace_parser/BUILD.gn index bd432943d..c73f750a7 100644 --- a/trace_streamer/src/parser/ptreader_parser/bytrace_parser/BUILD.gn +++ b/trace_streamer/src/parser/ptreader_parser/bytrace_parser/BUILD.gn @@ -13,11 +13,16 @@ import("//build/ohos.gni") import("../../../../build/ts.gni") +config("bytrace_parser_cfg") { + include_dirs = [ "." ] +} + ohos_static_library("ptreader_bytrace_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "bytrace_event_parser.cpp" ] - include_dirs = [ "." ] - public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_reader" ] - public_configs = [ "../../:parser_base_cfg" ] + public_configs = [ + ":bytrace_parser_cfg", + "../../:parser_base_cfg", + ] } diff --git a/trace_streamer/src/parser/ptreader_parser/bytrace_parser/bytrace_event_parser.cpp b/trace_streamer/src/parser/ptreader_parser/bytrace_parser/bytrace_event_parser.cpp index eb81c8c89..b4f07b3b2 100644 --- a/trace_streamer/src/parser/ptreader_parser/bytrace_parser/bytrace_event_parser.cpp +++ b/trace_streamer/src/parser/ptreader_parser/bytrace_parser/bytrace_event_parser.cpp @@ -660,7 +660,8 @@ bool BytraceEventParser::BinderTransaction(const ArgsMap& args, const BytraceLin auto isReply = base::StrToInt(args.at("reply")); auto flags = base::StrToInt(args.at("flags"), base::INTEGER_RADIX_TYPE_HEX); auto codeStr = base::StrToInt(args.at("code"), base::INTEGER_RADIX_TYPE_HEX); - TS_LOGD("ts:%lu, pid:%u, destNode:%u, destTgid:%u, destTid:%u, transactionId:%lu, isReply:%u flags:%u, code:%u", + TS_LOGD("ts:%" PRIu64 ", pid:%u, destNode:%u, destTgid:%u, destTid:%u, transactionId:%" PRIu64 + ", isReply:%u flags:%u, code:%u", line.ts, line.pid, destNode.value(), destProc.value(), destThread.value(), transactionId.value(), isReply.value(), flags.value(), codeStr.value()); streamFilters_->binderFilter_->SendTraction(line.ts, line.pid, transactionId.value(), destNode.value(), @@ -687,7 +688,7 @@ bool BytraceEventParser::BinderTransactionReceived(const ArgsMap& args, const By streamFilters_->cpuFilter_->InsertRunnableBinderRecvEvent( transactionId.value(), streamFilters_->processFilter_->GetInternalTid(line.pid)); } - TS_LOGD("ts:%lu, pid:%u, transactionId:%lu", line.ts, line.pid, transactionId.value()); + TS_LOGD("ts:%" PRIu64 ", pid:%u, transactionId:%" PRIu64 "", line.ts, line.pid, transactionId.value()); return true; } bool BytraceEventParser::BinderTransactionAllocBufEvent(const ArgsMap& args, const BytraceLine& line) const @@ -701,7 +702,7 @@ bool BytraceEventParser::BinderTransactionAllocBufEvent(const ArgsMap& args, con auto dataSize = base::StrToInt(args.at("data_size")); auto offsetsSize = base::StrToInt(args.at("offsets_size")); streamFilters_->binderFilter_->TransactionAllocBuf(line.ts, line.pid, dataSize.value(), offsetsSize.value()); - TS_LOGD("dataSize:%lu, offsetSize:%lu", dataSize.value(), offsetsSize.value()); + TS_LOGD("dataSize:%" PRIu64 ", offsetSize:%" PRIu64 "", dataSize.value(), offsetsSize.value()); return true; } void BytraceEventParser::ParseDataItem(const BytraceLine& line) diff --git a/trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_hilog_parser.cpp b/trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_hilog_parser.cpp index 39b61ca6c..3c4d93a96 100644 --- a/trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_hilog_parser.cpp +++ b/trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_hilog_parser.cpp @@ -35,7 +35,7 @@ bool PtreaderHilogParser::HilogTimeStrToTimestamp(std::string& timeStr, uint64_t if (std::regex_search(timeStr, matcheLine, std::regex(R"(^\d+\.(\d+)$)"))) { size_t index = 0; usecStr = matcheLine[++index].str(); - sscanf_s(timeStr.c_str(), "%lu.%lu", &sec, &nsec); + sscanf_s(timeStr.c_str(), "%" PRIu64 ".%" PRIu64 "", &sec, &nsec); } else if (std::regex_search(timeStr, matcheLine, std::regex(R"(^(\d{4})?\-?(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})\.(\d+)$)"))) { size_t index = 0; diff --git a/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/BUILD.gn b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/BUILD.gn index 9ad0f3f4a..0d833f2f6 100644 --- a/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/BUILD.gn +++ b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/BUILD.gn @@ -17,7 +17,7 @@ ohos_static_library("ptreader_hisysevent_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "ptreader_hisysevent_parser.cpp" ] - public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_reader" ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hisysevent_data:hisysevent_data_reader" ] public_configs = [ "../../:hisysevent_parser_cfg", "../../:parser_base_cfg", diff --git a/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_hisysevent_parser.h b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_hisysevent_parser.h index 5cdda88ab..f27dcfd16 100644 --- a/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_hisysevent_parser.h +++ b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_hisysevent_parser.h @@ -17,7 +17,6 @@ #include "common_types.h" #include "string_help.h" -#include "log.h" #include "string_to_numerical.h" #include "parser_base.h" #include "event_parser_base.h" diff --git a/trace_streamer/src/parser/ptreader_parser/ptreader_parser.cpp b/trace_streamer/src/parser/ptreader_parser/ptreader_parser.cpp index b1adc4d0c..7f1a765ee 100644 --- a/trace_streamer/src/parser/ptreader_parser/ptreader_parser.cpp +++ b/trace_streamer/src/parser/ptreader_parser/ptreader_parser.cpp @@ -21,7 +21,7 @@ #include "binder_filter.h" #include "cpu_filter.h" #ifdef ENABLE_HISYSEVENT -#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" +#include "hi_sysevent_measure_filter.h" #endif #include "parting_string.h" #include "stat_filter.h" diff --git a/trace_streamer/src/parser/ptreader_parser/ptreader_parser.h b/trace_streamer/src/parser/ptreader_parser/ptreader_parser.h index 502bd8a21..e1480e98a 100644 --- a/trace_streamer/src/parser/ptreader_parser/ptreader_parser.h +++ b/trace_streamer/src/parser/ptreader_parser/ptreader_parser.h @@ -22,19 +22,18 @@ #include #ifdef ENABLE_BYTRACE -#include "bytrace_parser/bytrace_event_parser.h" +#include "bytrace_event_parser.h" #endif #include "common_types.h" #ifdef ENABLE_HILOG -#include "hilog_parser/ptreader_hilog_parser.h" +#include "ptreader_hilog_parser.h" #endif #ifdef ENABLE_HISYSEVENT -#include "hisysevent_parser/ptreader_hisysevent_parser.h" +#include "ptreader_hisysevent_parser.h" #endif -#include "log.h" #include "parser_base.h" #include "string_to_numerical.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_filters.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/rawtrace_parser/BUILD.gn b/trace_streamer/src/parser/rawtrace_parser/BUILD.gn index 65d4389b1..35e990dd6 100755 --- a/trace_streamer/src/parser/rawtrace_parser/BUILD.gn +++ b/trace_streamer/src/parser/rawtrace_parser/BUILD.gn @@ -19,6 +19,7 @@ config("rawtrace_parser_comm") { "${SRC}/base", "${SRC}/cfg", "${SRC}/parser", + "${SRC}/rpc", "${SRC}/trace_streamer", "${SRC}/proto_reader/include", "${SRC}/trace_data", @@ -81,8 +82,7 @@ ohos_static_library("rawtrace_parser") { cflags = [ "-includeMingW64Fix.h" ] } - public_deps = [] - deps = [ + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp_standard", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ts_ftrace_data_cpp", "${THIRD_PARTY}/protobuf:protobuf_lite_static", diff --git a/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp b/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp index 7c660f750..26a82827c 100644 --- a/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ #include "ftrace_event_processor.h" -#include "log.h" namespace SysTuning { namespace TraceStreamer { diff --git a/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.cpp b/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.cpp index f945f228e..7e0e24933 100644 --- a/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.cpp @@ -14,7 +14,6 @@ */ #include "kernel_symbols_processor.h" -#include "log.h" #include "string_help.h" #include "string_to_numerical.h" diff --git a/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.cpp b/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.cpp index c59be8a26..abca16a6d 100644 --- a/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.cpp @@ -15,7 +15,6 @@ #include "printk_formats_processor.h" #include -#include "log.h" #include "string_help.h" #include "string_to_numerical.h" diff --git a/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp b/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp index 248b888ff..764659a31 100644 --- a/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp @@ -16,9 +16,8 @@ #include "rawtrace_parser.h" #include #if IS_WASM -#include "../rpc/wasm_func.h" +#include "wasm_func.h" #endif -#include "log.h" #include "string_help.h" namespace SysTuning { namespace TraceStreamer { diff --git a/trace_streamer/src/protos/services/common_types.proto b/trace_streamer/src/protos/services/common_types.proto index d92416e11..77a9cc167 100755 --- a/trace_streamer/src/protos/services/common_types.proto +++ b/trace_streamer/src/protos/services/common_types.proto @@ -20,8 +20,9 @@ message ProfilerPluginConfig { string name = 1; string plugin_sha256 = 2; uint32 sample_interval = 3; // Polling plugin collection interval(ms) - bytes config_data = 4; - bool protobuf_serialize = 5; // data encoding method, true is protobuf, false is protoencoder + bytes config_data = 4; + string clock = 5; + bool is_protobuf_serialize = 6; // data encoding method, true is protobuf, false is protoencoder } message ProfilerPluginState { @@ -42,16 +43,17 @@ message ProfilerPluginData { bytes data = 3; enum ClockId { CLOCKID_REALTIME = 0; - CLOCKID_REALTIME_ALARM = 1; // since Linux 3.0; Linux-specific - CLOCKID_REALTIME_COARSE = 2; // since Linux 2.6.32; Linux-specific - CLOCKID_TAI = 3; // since Linux 3.10; Linux-specific - CLOCKID_MONOTONIC = 4; - CLOCKID_MONOTONIC_COARSE = 5; // since Linux 2.6.32; Linux-specific - CLOCKID_MONOTONIC_RAW = 6; // since Linux 2.6.28; Linux-specific + CLOCKID_MONOTONIC = 1; + CLOCKID_PROCESS_CPUTIME_ID = 2; // since Linux 2.6.12 + CLOCKID_THREAD_CPUTIME_ID = 3; // since Linux 2.6.12 + CLOCKID_MONOTONIC_RAW = 4; // since Linux 2.6.28; Linux-specific + CLOCKID_REALTIME_COARSE = 5; // since Linux 2.6.32; Linux-specific + CLOCKID_MONOTONIC_COARSE = 6; // since Linux 2.6.32; Linux-specific CLOCKID_BOOTTIME = 7; // since Linux 2.6.39; Linux-specific - CLOCKID_BOOTTIME_ALARM = 8; // since Linux 3.0; Linux-specific - CLOCKID_PROCESS_CPUTIME_ID = 9; // since Linux 2.6.12 - CLOCKID_THREAD_CPUTIME_ID = 10; // since Linux 2.6.12 + CLOCKID_REALTIME_ALARM = 8; // since Linux 3.0; Linux-specific + CLOCKID_BOOTTIME_ALARM = 9; // since Linux 3.0; Linux-specific + CLOCKID_SGI_CYCLE = 10; + CLOCKID_TAI = 11; // since Linux 3.10; Linux-specific }; ClockId clock_id = 4; uint64 tv_sec = 5; diff --git a/trace_streamer/src/rpc/ffrt_converter.h b/trace_streamer/src/rpc/ffrt_converter.h index 7519f40ed..8b7bf4e66 100644 --- a/trace_streamer/src/rpc/ffrt_converter.h +++ b/trace_streamer/src/rpc/ffrt_converter.h @@ -24,9 +24,7 @@ #include #include #include -#include #include -#include "log.h" #include "ts_common.h" namespace SysTuning { namespace TraceStreamer { diff --git a/trace_streamer/src/rpc/rpc_server.cpp b/trace_streamer/src/rpc/rpc_server.cpp index f302af013..83bc0be78 100644 --- a/trace_streamer/src/rpc/rpc_server.cpp +++ b/trace_streamer/src/rpc/rpc_server.cpp @@ -26,8 +26,9 @@ #include "ptreader_parser.h" #include "pbreader_parser.h" #include "json.hpp" -#include "log.h" +#ifdef ENABLE_RAWTRACE #include "rawtrace_parser.h" +#endif #include "string_help.h" #include "trace_streamer_selector.h" #include "ts_common.h" @@ -319,7 +320,7 @@ bool RpcServer::SendRawtraceSplitFileData(SplitFileCallBack splitFileCallBack, i result += "]}\r\n"; splitFileCallBack(result, (int32_t)SplitDataDataType::SPLIT_FILE_JSON, isFinish); } - TS_LOGI("mTraceRawCpuData.size()= %lu, mTraceRawCommData.size()=%lu\n result=%s\n", mTraceRawCpuData.size(), + TS_LOGI("mTraceRawCpuData.size()= %zu, mTraceRawCommData.size()=%zu\n result=%s\n", mTraceRawCpuData.size(), mTraceRawCommData.size(), result.data()); return true; } diff --git a/trace_streamer/src/table/base/BUILD.gn b/trace_streamer/src/table/base/BUILD.gn index 61ab92001..ac46aacc8 100644 --- a/trace_streamer/src/table/base/BUILD.gn +++ b/trace_streamer/src/table/base/BUILD.gn @@ -12,25 +12,8 @@ # limitations under the License. import("//build/ohos.gni") - import("../../../build/ts.gni") -ohos_source_set("base_tables") { - subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" - part_name = "${OHOS_PROFILER_PART_NAME}" - sources = [ - "args_table.cpp", - "data_dict_table.cpp", - "data_type_table.cpp", - "datasource_clockid_table.cpp", - "device_info_table.cpp", - "meta_table.cpp", - "range_table.cpp", - "span_join.cpp", - "stat_table.cpp", - "symbols_table.cpp", - "table_base.cpp", - "trace_config_table.cpp", - ] +config("base_tables_cfg") { include_dirs = [ "include", "${THIRD_PARTY}/sqlite/include", @@ -39,6 +22,7 @@ ohos_source_set("base_tables") { "${SRC}/trace_data", "${SRC}/include", "${SRC}", + "${SRC}/cfg", "${THIRD_PARTY}/protobuf/src", "${THIRD_PARTY}/bounds_checking_function/include", ] @@ -52,6 +36,25 @@ ohos_source_set("base_tables") { "${SRC}/trace_data/trace_stdtype/htrace", "${SRC}/trace_data/trace_stdtype/measure", ] +} +ohos_source_set("base_tables") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ + "args_table.cpp", + "data_dict_table.cpp", + "data_type_table.cpp", + "datasource_clockid_table.cpp", + "device_info_table.cpp", + "meta_table.cpp", + "range_table.cpp", + "span_join.cpp", + "stat_table.cpp", + "symbols_table.cpp", + "table_base.cpp", + "trace_config_table.cpp", + ] + public_configs = [ ":base_tables_cfg" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } diff --git a/trace_streamer/src/table/base/table_base.cpp b/trace_streamer/src/table/base/table_base.cpp index 8cb6f3dbc..5c18ce65e 100644 --- a/trace_streamer/src/table/base/table_base.cpp +++ b/trace_streamer/src/table/base/table_base.cpp @@ -19,8 +19,6 @@ #include #include -#include "log.h" - namespace SysTuning { namespace TraceStreamer { namespace { diff --git a/trace_streamer/src/table/ebpf/BUILD.gn b/trace_streamer/src/table/ebpf/BUILD.gn index bdc78b11f..b33714fbe 100644 --- a/trace_streamer/src/table/ebpf/BUILD.gn +++ b/trace_streamer/src/table/ebpf/BUILD.gn @@ -22,29 +22,8 @@ ohos_source_set("ebpf_tables") { "ebpf_callstack_table.cpp", "file_system_sample_table.cpp", ] - include_dirs = [ - "include", - "../base/include", - "${THIRD_PARTY}/sqlite/include", - "${SRC}/base", - "../../parser", - "${SRC}/trace_data", - "${SRC}/include", - "${SRC}", - "${THIRD_PARTY}/protobuf/src", - "${THIRD_PARTY}/bounds_checking_function/include", - "${THIRD_PARTY}/json/single_include/nlohmann", - ] - include_dirs += [ - "${SRC}/trace_data/trace_stdtype", - "${SRC}/trace_data/trace_stdtype/ftrace", - "${SRC}/trace_data/trace_stdtype/ftrace/template", - "${SRC}/trace_data/trace_stdtype/hilog", - "${SRC}/trace_data/trace_stdtype/hiperf", - "${SRC}/trace_data/trace_stdtype/hisysevent", - "${SRC}/trace_data/trace_stdtype/htrace", - "${SRC}/trace_data/trace_stdtype/measure", - ] + include_dirs = [ "include" ] + public_configs = [ "${SRC}/table/base:base_tables_cfg" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } diff --git a/trace_streamer/src/table/ftrace/BUILD.gn b/trace_streamer/src/table/ftrace/BUILD.gn index 83a40dff5..d43e07038 100644 --- a/trace_streamer/src/table/ftrace/BUILD.gn +++ b/trace_streamer/src/table/ftrace/BUILD.gn @@ -45,28 +45,8 @@ ohos_source_set("ftrace_tables") { "thread_table.cpp", ] - include_dirs = [ - "../base/include", - "include", - "${THIRD_PARTY}/sqlite/include", - "${SRC}/base", - "../../parser", - "${SRC}/trace_data", - "${SRC}/include", - "${SRC}", - "${THIRD_PARTY}/protobuf/src", - "${THIRD_PARTY}/bounds_checking_function/include", - ] - include_dirs += [ - "${SRC}/trace_data/trace_stdtype", - "${SRC}/trace_data/trace_stdtype/ftrace", - "${SRC}/trace_data/trace_stdtype/ftrace/template", - "${SRC}/trace_data/trace_stdtype/hilog", - "${SRC}/trace_data/trace_stdtype/hiperf", - "${SRC}/trace_data/trace_stdtype/hisysevent", - "${SRC}/trace_data/trace_stdtype/htrace", - "${SRC}/trace_data/trace_stdtype/measure", - ] + include_dirs = [ "include" ] + public_configs = [ "${SRC}/table/base:base_tables_cfg" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] diff --git a/trace_streamer/src/table/ftrace/cpu_measure_filter_table.cpp b/trace_streamer/src/table/ftrace/cpu_measure_filter_table.cpp index fbc39fd74..10b2b8d45 100644 --- a/trace_streamer/src/table/ftrace/cpu_measure_filter_table.cpp +++ b/trace_streamer/src/table/ftrace/cpu_measure_filter_table.cpp @@ -17,8 +17,6 @@ #include -#include "log.h" - namespace SysTuning { namespace TraceStreamer { enum class Index : int32_t { ID = 0, NAME, CPU }; diff --git a/trace_streamer/src/table/hi_sysevent/BUILD.gn b/trace_streamer/src/table/hi_sysevent/BUILD.gn index b140ec36c..ad284c4b1 100644 --- a/trace_streamer/src/table/hi_sysevent/BUILD.gn +++ b/trace_streamer/src/table/hi_sysevent/BUILD.gn @@ -23,28 +23,8 @@ ohos_source_set("hi_sysevent_tables") { "sysevent_measure_table.cpp", "sysevent_subkey_table.cpp", ] - include_dirs = [ - "include", - "../base/include", - "${THIRD_PARTY}/sqlite/include", - "${SRC}/base", - "../../parser", - "${SRC}/trace_data", - "${SRC}/include", - "${SRC}", - "${THIRD_PARTY}/protobuf/src", - "${THIRD_PARTY}/bounds_checking_function/include", - ] - include_dirs += [ - "${SRC}/trace_data/trace_stdtype", - "${SRC}/trace_data/trace_stdtype/ftrace", - "${SRC}/trace_data/trace_stdtype/ftrace/template", - "${SRC}/trace_data/trace_stdtype/hilog", - "${SRC}/trace_data/trace_stdtype/hiperf", - "${SRC}/trace_data/trace_stdtype/hisysevent", - "${SRC}/trace_data/trace_stdtype/htrace", - "${SRC}/trace_data/trace_stdtype/measure", - ] + include_dirs = [ "include" ] + public_configs = [ "${SRC}/table/base:base_tables_cfg" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } diff --git a/trace_streamer/src/table/hiperf/BUILD.gn b/trace_streamer/src/table/hiperf/BUILD.gn index 4ec34ec7b..56791a2b0 100644 --- a/trace_streamer/src/table/hiperf/BUILD.gn +++ b/trace_streamer/src/table/hiperf/BUILD.gn @@ -24,29 +24,8 @@ ohos_source_set("hiperf_tables") { "perf_sample_table.cpp", "perf_thread_table.cpp", ] - - include_dirs = [ - "include", - "../base/include", - "${THIRD_PARTY}/sqlite/include", - "${SRC}/base", - "../../parser", - "${SRC}/trace_data", - "${SRC}/include", - "${SRC}", - "${THIRD_PARTY}/protobuf/src", - "${THIRD_PARTY}/bounds_checking_function/include", - ] - include_dirs += [ - "${SRC}/trace_data/trace_stdtype", - "${SRC}/trace_data/trace_stdtype/ftrace", - "${SRC}/trace_data/trace_stdtype/ftrace/template", - "${SRC}/trace_data/trace_stdtype/hilog", - "${SRC}/trace_data/trace_stdtype/hiperf", - "${SRC}/trace_data/trace_stdtype/hisysevent", - "${SRC}/trace_data/trace_stdtype/htrace", - "${SRC}/trace_data/trace_stdtype/measure", - ] + include_dirs = [ "include" ] + public_configs = [ "${SRC}/table/base:base_tables_cfg" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } diff --git a/trace_streamer/src/table/js_memory/BUILD.gn b/trace_streamer/src/table/js_memory/BUILD.gn index 639440500..c383b1abd 100644 --- a/trace_streamer/src/table/js_memory/BUILD.gn +++ b/trace_streamer/src/table/js_memory/BUILD.gn @@ -31,28 +31,8 @@ ohos_source_set("js_memory_tables") { "js_heap_trace_function_info_table.cpp", "js_heap_trace_node_table.cpp", ] - include_dirs = [ - "include", - "../base/include", - "${THIRD_PARTY}/sqlite/include", - "${SRC}/base", - "../../parser", - "${SRC}/trace_data", - "${SRC}/include", - "${SRC}", - "${THIRD_PARTY}/protobuf/src", - "${THIRD_PARTY}/bounds_checking_function/include", - ] - include_dirs += [ - "${SRC}/trace_data/trace_stdtype", - "${SRC}/trace_data/trace_stdtype/ftrace", - "${SRC}/trace_data/trace_stdtype/ftrace/template", - "${SRC}/trace_data/trace_stdtype/hilog", - "${SRC}/trace_data/trace_stdtype/hiperf", - "${SRC}/trace_data/trace_stdtype/hisysevent", - "${SRC}/trace_data/trace_stdtype/htrace", - "${SRC}/trace_data/trace_stdtype/measure", - ] + include_dirs = [ "include" ] + public_configs = [ "${SRC}/table/base:base_tables_cfg" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } diff --git a/trace_streamer/src/table/monitor/BUILD.gn b/trace_streamer/src/table/monitor/BUILD.gn index 1c5f0bbba..7a7c2afcd 100644 --- a/trace_streamer/src/table/monitor/BUILD.gn +++ b/trace_streamer/src/table/monitor/BUILD.gn @@ -34,28 +34,8 @@ ohos_source_set("monitor_tables") { "paged_memory_sample_table.cpp", "smaps_table.cpp", ] - include_dirs = [ - "include", - "../base/include", - "${THIRD_PARTY}/sqlite/include", - "${SRC}/base", - "../../parser", - "${SRC}/trace_data", - "${SRC}/include", - "${SRC}", - "${THIRD_PARTY}/protobuf/src", - "${THIRD_PARTY}/bounds_checking_function/include", - ] - include_dirs += [ - "${SRC}/trace_data/trace_stdtype", - "${SRC}/trace_data/trace_stdtype/ftrace", - "${SRC}/trace_data/trace_stdtype/ftrace/template", - "${SRC}/trace_data/trace_stdtype/hilog", - "${SRC}/trace_data/trace_stdtype/hiperf", - "${SRC}/trace_data/trace_stdtype/hisysevent", - "${SRC}/trace_data/trace_stdtype/htrace", - "${SRC}/trace_data/trace_stdtype/measure", - ] + include_dirs = [ "include" ] + public_configs = [ "${SRC}/table/base:base_tables_cfg" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } diff --git a/trace_streamer/src/table/native_hook/BUILD.gn b/trace_streamer/src/table/native_hook/BUILD.gn index 7818dc229..2cd0416a2 100644 --- a/trace_streamer/src/table/native_hook/BUILD.gn +++ b/trace_streamer/src/table/native_hook/BUILD.gn @@ -22,29 +22,8 @@ ohos_source_set("native_hook_tables") { "native_hook_statistic_table.cpp", "native_hook_table.cpp", ] - - include_dirs = [ - "include", - "../base/include", - "${THIRD_PARTY}/sqlite/include", - "${SRC}/base", - "../../parser", - "${SRC}/trace_data", - "${SRC}/include", - "${SRC}", - "${THIRD_PARTY}/protobuf/src", - "${THIRD_PARTY}/bounds_checking_function/include", - ] - include_dirs += [ - "${SRC}/trace_data/trace_stdtype", - "${SRC}/trace_data/trace_stdtype/ftrace", - "${SRC}/trace_data/trace_stdtype/ftrace/template", - "${SRC}/trace_data/trace_stdtype/hilog", - "${SRC}/trace_data/trace_stdtype/hiperf", - "${SRC}/trace_data/trace_stdtype/hisysevent", - "${SRC}/trace_data/trace_stdtype/htrace", - "${SRC}/trace_data/trace_stdtype/measure", - ] + include_dirs = [ "include" ] + public_configs = [ "${SRC}/table/base:base_tables_cfg" ] if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } diff --git a/trace_streamer/src/trace_data/BUILD.gn b/trace_streamer/src/trace_data/BUILD.gn index a5b029f93..5489b73ef 100644 --- a/trace_streamer/src/trace_data/BUILD.gn +++ b/trace_streamer/src/trace_data/BUILD.gn @@ -19,17 +19,11 @@ ohos_source_set("trace_data") { part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "sqllite_prepar_cache_data.cpp", - "sqllite_prepar_cache_data.h", "trace_data_cache.cpp", - "trace_data_cache.h", "trace_data_cache_base.cpp", - "trace_data_cache_base.h", "trace_data_cache_reader.cpp", - "trace_data_cache_reader.h", "trace_data_cache_writer.cpp", - "trace_data_cache_writer.h", "trace_data_db.cpp", - "trace_data_db.h", "trace_stdtype/base_stdtype.cpp", "trace_stdtype/common_stdtype.cpp", "trace_stdtype/ftrace/callstack_stdtype.cpp", @@ -98,4 +92,9 @@ ohos_source_set("trace_data") { deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/smartperf_host:ts_all_sph_cpp", ] + + public_configs = [ + "${SRC}/parser/ebpf_parser:ebpf_parser_cfg", + "${SRC}/base/sqlite_ext:sqlite_ext_cfg", + ] } diff --git a/trace_streamer/src/trace_data/trace_data_cache.cpp b/trace_streamer/src/trace_data/trace_data_cache.cpp index df387b436..5ff17c878 100644 --- a/trace_streamer/src/trace_data/trace_data_cache.cpp +++ b/trace_streamer/src/trace_data/trace_data_cache.cpp @@ -77,7 +77,7 @@ #include "native_hook_statistic_table.h" #include "network_table.h" #include "paged_memory_sample_table.h" -#include "parser/ebpf_parser/ebpf_data_structure.h" +#include "ebpf_data_structure.h" #include "perf_call_chain_table.h" #include "perf_files_table.h" #include "perf_report_table.h" diff --git a/trace_streamer/src/trace_data/trace_data_cache_reader.cpp b/trace_streamer/src/trace_data/trace_data_cache_reader.cpp index d81a43e3e..7ffc1cc2f 100644 --- a/trace_streamer/src/trace_data/trace_data_cache_reader.cpp +++ b/trace_streamer/src/trace_data/trace_data_cache_reader.cpp @@ -14,7 +14,6 @@ */ #include "trace_data_cache_reader.h" -#include "log.h" namespace SysTuning { namespace TraceStreamer { using namespace TraceStdtype; diff --git a/trace_streamer/src/trace_data/trace_data_cache_writer.cpp b/trace_streamer/src/trace_data/trace_data_cache_writer.cpp index f93d8eaae..b6fd64d5b 100644 --- a/trace_streamer/src/trace_data/trace_data_cache_writer.cpp +++ b/trace_streamer/src/trace_data/trace_data_cache_writer.cpp @@ -14,7 +14,6 @@ */ #include "trace_data_cache_writer.h" -#include "log.h" namespace SysTuning { namespace TraceStreamer { using namespace TraceStdtype; diff --git a/trace_streamer/src/trace_data/trace_data_db.cpp b/trace_streamer/src/trace_data/trace_data_db.cpp index 085158bd0..024031a93 100644 --- a/trace_streamer/src/trace_data/trace_data_db.cpp +++ b/trace_streamer/src/trace_data/trace_data_db.cpp @@ -26,10 +26,9 @@ #include "codec_cov.h" #include "file.h" -#include "log.h" #include "sph_data.pb.h" #include "sqlite3.h" -#include "sqlite_ext/sqlite_ext_funcs.h" +#include "sqlite_ext_funcs.h" #include "string_help.h" #include "ts_common.h" diff --git a/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.h index 2fa126ea7..15b11d8d3 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.h @@ -17,7 +17,6 @@ #define BASE_STDTYPE_H #include -#include "log.h" #include "ts_common.h" namespace SysTuning { diff --git a/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.h index 9c0a8d482..4e5607129 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.h @@ -20,7 +20,7 @@ #include #include #include "base_stdtype.h" -#include "cfg/trace_streamer_config.h" +#include "trace_streamer_config.h" namespace SysTuning { namespace TraceStdtype { diff --git a/trace_streamer/src/trace_streamer/trace_streamer_filters.cpp b/trace_streamer/src/trace_streamer/trace_streamer_filters.cpp index 61aa8b3fc..31707d323 100644 --- a/trace_streamer/src/trace_streamer/trace_streamer_filters.cpp +++ b/trace_streamer/src/trace_streamer/trace_streamer_filters.cpp @@ -23,11 +23,11 @@ #include "filter_filter.h" #include "frame_filter.h" #ifdef ENABLE_HISYSEVENT -#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" +#include "hi_sysevent_measure_filter.h" #endif #include "irq_filter.h" #include "measure_filter.h" -#include "perf_filter/perf_data_filter.h" +#include "perf_data_filter.h" #include "process_filter.h" #include "slice_filter.h" #include "stat_filter.h" diff --git a/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp b/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp index cacb61b8e..0d3b3727b 100644 --- a/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp +++ b/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp @@ -29,18 +29,18 @@ #include "filter_filter.h" #include "frame_filter.h" #ifdef ENABLE_HISYSEVENT -#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" +#include "hi_sysevent_measure_filter.h" #endif #include "irq_filter.h" #include "measure_filter.h" #include "task_pool_filter.h" -#include "parser/ptreader_parser/ptreader_parser.h" -#include "parser/pbreader_parser/pbreader_parser.h" +#include "ptreader_parser.h" +#include "pbreader_parser.h" #ifdef ENABLE_RAWTRACE -#include "parser/rawtrace_parser/rawtrace_parser.h" +#include "rawtrace_parser.h" #endif #ifdef ENABLE_HIPERF -#include "perf_filter/perf_data_filter.h" +#include "perf_data_filter.h" #endif #include "process_filter.h" #include "slice_filter.h" diff --git a/trace_streamer/src/trace_streamer/trace_streamer_selector.h b/trace_streamer/src/trace_streamer/trace_streamer_selector.h index 00cbd00a6..20788bf36 100644 --- a/trace_streamer/src/trace_streamer/trace_streamer_selector.h +++ b/trace_streamer/src/trace_streamer/trace_streamer_selector.h @@ -18,7 +18,7 @@ #include #include #include "metrics.h" -#include "trace_data/trace_data_cache.h" +#include "trace_data_cache.h" #include "trace_streamer_filters.h" namespace SysTuning { diff --git a/trace_streamer/test/BUILD.gn b/trace_streamer/test/BUILD.gn index f80591b75..917347abe 100644 --- a/trace_streamer/test/BUILD.gn +++ b/trace_streamer/test/BUILD.gn @@ -92,7 +92,7 @@ if (is_test) { "${THIRD_PARTY}/protobuf:protobuf_lite_static", "${THIRD_PARTY}/protobuf:protobuf_static", "../src:trace_streamer_source", - "../src/parser/pbreader_parser:pbreader_parser", + "../src/parser/pbreader_parser:pbreader_parser_src", "../src/proto_reader:proto_reader", ] public_configs = [] @@ -117,6 +117,7 @@ if (is_test) { "../src/include", "../src/trace_streamer", "../src/parser/ptreader_parser", + "../src/parser/ptreader_parser/bytrace_parser", "../src/parser", "../src/cfg", "../src/metrics", diff --git a/trace_streamer/test/unittest/ebpf/paged_memory_parser_test.cpp b/trace_streamer/test/unittest/ebpf/paged_memory_parser_test.cpp index 103a9612a..4f04a708f 100644 --- a/trace_streamer/test/unittest/ebpf/paged_memory_parser_test.cpp +++ b/trace_streamer/test/unittest/ebpf/paged_memory_parser_test.cpp @@ -121,7 +121,7 @@ HWTEST_F(EbpfPagedMemoryParserTest, EbpfPagedMemoryParserwrongWithoutCallback, T ebpfDataParser->Finish(); EXPECT_TRUE(ebpfDataParser->reader_->ebpfDataHeader_->header.clock == EBPF_CLOCK_BOOTTIME); auto sampleData = stream_.traceDataCache_->GetConstPagedMemorySampleData(); - EXPECT_FALSE(sampleData.CallChainIds()[0] == INVALID_UINT64); + EXPECT_FALSE(sampleData.CallChainIds()[0] == INVALID_UINT32); EXPECT_FALSE(sampleData.Types()[0] == 2); auto startTs = sampleData.StartTs()[0]; auto endTs = sampleData.EndTs()[0]; diff --git a/trace_streamer/test/unittest/filter/app_start_filter_test.cpp b/trace_streamer/test/unittest/filter/app_start_filter_test.cpp index a5f3e2d94..af317a9e6 100644 --- a/trace_streamer/test/unittest/filter/app_start_filter_test.cpp +++ b/trace_streamer/test/unittest/filter/app_start_filter_test.cpp @@ -17,7 +17,7 @@ #include #include "app_start_filter.h" -#include "parser/ptreader_parser/ptreader_parser.h" +#include "ptreader_parser.h" #include "slice_filter.h" #include "trace_streamer_selector.h" diff --git a/trace_streamer/test/unittest/filter/cpu_filter_test.cpp b/trace_streamer/test/unittest/filter/cpu_filter_test.cpp index 69a97b62e..427fc7301 100644 --- a/trace_streamer/test/unittest/filter/cpu_filter_test.cpp +++ b/trace_streamer/test/unittest/filter/cpu_filter_test.cpp @@ -74,7 +74,7 @@ HWTEST_F(CpuFilterTest, CpufilterInsertSwitchTest, TestSize.Level1) streamFilters_.cpuFilter_->InsertSwitchEvent(ts1, cpu, itidPre, prePior, TASK_INTERRUPTIBLE, itidNext, nextPior, INVALID_DATAINDEX); // 1st switch - printf("state of pre itid: %llu\n", streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidPre)); + printf("state of pre itid: %" PRIu64 "\n", streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidPre)); EXPECT_TRUE(streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidPre) == TASK_INTERRUPTIBLE); EXPECT_TRUE(streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidNext) == TASK_RUNNING); @@ -99,7 +99,7 @@ HWTEST_F(CpuFilterTest, CpufilterInsertSwitchFromZeroThread, TestSize.Level1) streamFilters_.cpuFilter_->InsertSwitchEvent(ts1, cpu, itidPre, prePior, TASK_INTERRUPTIBLE, itidNext, nextPior, INVALID_DATAINDEX); // 1st switch - printf("state of pre itid: %llu\n", streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidPre)); + printf("state of pre itid: %" PRIu64 "\n", streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidPre)); EXPECT_TRUE(streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidPre) == TASK_INVALID); EXPECT_TRUE(streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidNext) == TASK_RUNNING); @@ -124,7 +124,7 @@ HWTEST_F(CpuFilterTest, CpufilterInsertSwitchToZeroThread, TestSize.Level1) streamFilters_.cpuFilter_->InsertSwitchEvent(ts1, cpu, itidPre, prePior, TASK_INTERRUPTIBLE, itidNext, nextPior, INVALID_DATAINDEX); // 1st switch - printf("state of pre itid: %llu\n", streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidPre)); + printf("state of pre itid: %" PRIu64 "\n", streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidPre)); EXPECT_TRUE(streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidPre) == TASK_INTERRUPTIBLE); EXPECT_TRUE(streamFilters_.cpuFilter_->StateOfInternalTidInStateTable(itidNext) == TASK_INVALID); diff --git a/trace_streamer/test/unittest/pbreader_parser/htrace_binder_event_test.cpp b/trace_streamer/test/unittest/pbreader_parser/htrace_binder_event_test.cpp index 32d13b1ab..9f9675153 100644 --- a/trace_streamer/test/unittest/pbreader_parser/htrace_binder_event_test.cpp +++ b/trace_streamer/test/unittest/pbreader_parser/htrace_binder_event_test.cpp @@ -18,7 +18,6 @@ #include "binder_filter.h" #include "htrace_cpu_detail_parser.h" -#include "htrace_event_parser.h" #include "trace_plugin_result.pb.h" #include "trace_plugin_result.pbreader.h" #include "trace_streamer_selector.h" diff --git a/trace_streamer/test/unittest/pbreader_parser/htrace_cpu_detail_parser_test.cpp b/trace_streamer/test/unittest/pbreader_parser/htrace_cpu_detail_parser_test.cpp index accc118a9..2115fd663 100644 --- a/trace_streamer/test/unittest/pbreader_parser/htrace_cpu_detail_parser_test.cpp +++ b/trace_streamer/test/unittest/pbreader_parser/htrace_cpu_detail_parser_test.cpp @@ -17,7 +17,6 @@ #include #include "htrace_cpu_detail_parser.h" -#include "htrace_event_parser.h" #include "power.pb.h" #include "stat_filter.h" #include "trace_streamer_selector.h" diff --git a/trace_streamer/test/unittest/pbreader_parser/htrace_irq_event_test.cpp b/trace_streamer/test/unittest/pbreader_parser/htrace_irq_event_test.cpp index a99758ffb..14fec633f 100644 --- a/trace_streamer/test/unittest/pbreader_parser/htrace_irq_event_test.cpp +++ b/trace_streamer/test/unittest/pbreader_parser/htrace_irq_event_test.cpp @@ -17,7 +17,6 @@ #include #include "htrace_cpu_detail_parser.h" -#include "htrace_event_parser.h" #include "irq_filter.h" #include "trace_plugin_result.pb.h" #include "trace_plugin_result.pbreader.h" -- Gitee From 639afce4f7d373449673a4aa22d02554f1521fb2 Mon Sep 17 00:00:00 2001 From: jichuan Date: Mon, 15 Apr 2024 20:34:40 +0800 Subject: [PATCH 03/14] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3falutloggerd?= =?UTF-8?q?=E5=9F=BA=E4=BA=8Emac=E5=B9=B3=E5=8F=B0=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- trace_streamer/gn/BUILD.gn | 3 + trace_streamer/pare_third_party.sh | 1 + .../prebuilts/patch_hiperf/string_view_util.h | 126 ++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 trace_streamer/prebuilts/patch_hiperf/string_view_util.h diff --git a/trace_streamer/gn/BUILD.gn b/trace_streamer/gn/BUILD.gn index fc3911312..32c8ca84d 100644 --- a/trace_streamer/gn/BUILD.gn +++ b/trace_streamer/gn/BUILD.gn @@ -190,6 +190,9 @@ config("default") { if (is_linux) { cflags += [ "-D is_linux" ] } + if (is_mac) { + cflags += [ "-D is_mac"] + } } config("symbols") { diff --git a/trace_streamer/pare_third_party.sh b/trace_streamer/pare_third_party.sh index b9610d13b..4fa45c3c1 100755 --- a/trace_streamer/pare_third_party.sh +++ b/trace_streamer/pare_third_party.sh @@ -121,6 +121,7 @@ if [ ! -d "perf_include/hiviewdfx/faultloggerd" ];then $sed -i '/#define DFX_NONLINUX_DEFINE_H/a #ifndef is_linux' perf_include/hiviewdfx/faultloggerd/interfaces/nonlinux/dfx_nonlinux_define.h $sed -i '/#if is_mingw/s/#if is_mingw/#ifndef is_linux/g' perf_include/hiviewdfx/faultloggerd/interfaces/common/byte_order.h $sed -i '$a #endif' perf_include/hiviewdfx/faultloggerd/interfaces/nonlinux/dfx_nonlinux_define.h + $cp ../prebuilts/patch_hiperf/string_view_util.h ../third_party/perf_include/hiviewdfx/faultloggerd/common/dfxutil/string_view_util.h fi if [ ! -f "hiperf/BUILD.gn" ];then rm -rf hiperf developtools_hiperf diff --git a/trace_streamer/prebuilts/patch_hiperf/string_view_util.h b/trace_streamer/prebuilts/patch_hiperf/string_view_util.h new file mode 100644 index 000000000..a8d538a81 --- /dev/null +++ b/trace_streamer/prebuilts/patch_hiperf/string_view_util.h @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef STRING_VIEW_UTIL_H +#define STRING_VIEW_UTIL_H + +#include +#include +#include +#include +#include +#include "cpp_define.h" + +namespace OHOS { +namespace HiviewDFX { +#ifdef is_mac +class SpinLock { +public: + void lock() + { + while (locked_.test_and_set(std::memory_order_acquire)); + } + void unlock() + { + locked_.clear(std::memory_order_release); + } + +private: + std::atomic_flag locked_ = ATOMIC_FLAG_INIT; +}; +#endif +class StringViewHold { +public: + static StringViewHold &Get() + { + static StringViewHold instance; + return instance; + } + + const char* Hold(STRING_VIEW view) + { +#ifndef is_mac + pthread_spin_lock(&spin_lock_); +#else + std::lock_guard lockGurand(spinlock_); +#endif + if (view.size() == 0) { +#ifndef is_mac + pthread_spin_unlock(&spin_lock_); +#endif + return ""; + } + + char *p = new (std::nothrow) char[view.size() + 1]; + if (p == nullptr) { +#ifndef is_mac + pthread_spin_unlock(&spin_lock_); +#endif + return ""; + } + if (memset_s(p, view.size() + 1, '\0', view.size() + 1) != 0) { +#ifndef is_mac + pthread_spin_unlock(&spin_lock_); +#endif + return ""; + } + std::copy(view.data(), view.data() + view.size(), p); + views_.emplace_back(p); +#ifndef is_mac + pthread_spin_unlock(&spin_lock_); +#endif + return p; + } + + // only use in UT + void Clean() + { +#ifndef is_mac + pthread_spin_lock(&spin_lock_); +#else + std::lock_guard lockGurand(spinlock_); +#endif + for (auto &p : views_) { + delete[] p; + } + views_.clear(); +#ifndef is_mac + pthread_spin_unlock(&spin_lock_); +#endif + } +private: +#ifndef is_mac + StringViewHold() + { + pthread_spin_init(&spin_lock_, PTHREAD_PROCESS_PRIVATE); + } +#endif + ~StringViewHold() + { + Clean(); +#ifndef is_mac + pthread_spin_destroy(&spin_lock_); +#endif + } + + std::vector views_; +#ifndef is_mac + pthread_spinlock_t spin_lock_; +#else + SpinLock spinlock_; +#endif +}; +} // namespace HiviewDFX +} // namespace OHOS +#endif \ No newline at end of file -- Gitee From 073a4a81c9aac4678d1eded7584fae2eb0458f9d Mon Sep 17 00:00:00 2001 From: jichuan Date: Mon, 15 Apr 2024 20:35:22 +0800 Subject: [PATCH 04/14] =?UTF-8?q?fix=201.=E4=BC=98=E5=8C=96process=20sql?= =?UTF-8?q?=E4=BB=8E=E8=80=8C=E6=8F=90=E9=AB=98=E5=AF=BC=E5=85=A5=E6=95=88?= =?UTF-8?q?=E7=8E=87=20=20=20=20=202.=E7=81=AB=E7=84=B0=E5=9B=BE=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E8=B0=83=E5=A4=A7=20=20=20=20=203.=E6=90=9C=E7=B4=A2O?= =?UTF-8?q?S,=E8=BE=93=E5=85=A5=E6=95=B0=E5=AD=97=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=90=8Etrace=E9=A1=B5=E9=9D=A2=E6=97=A0=E6=B3=95=E6=A1=86?= =?UTF-8?q?=E9=80=89=20=20=20=20=204.=E5=A4=9A=E4=B8=AA=E6=97=97=E5=AD=90?= =?UTF-8?q?=E8=B7=9F=E5=8D=A1=E5=B0=BA=E4=BD=BF=E7=94=A8ctrl+[]/<>?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=90=8E,=E5=88=A0=E9=99=A4=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E4=B8=80=E4=B8=AA=E6=8A=A5=E9=94=99=20=20=20=20=205.?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=97=AA=E5=8A=A8=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=20=20=20=206.=E6=B3=B3=E9=81=93=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=BC=98=E5=8C=96=20=20=20=20=207.=E5=AF=BC?= =?UTF-8?q?=E5=85=A5so=E7=A6=BB=E7=BA=BF=E7=AC=A6=E5=8F=B7=E5=8C=96?= =?UTF-8?q?=E5=86=85=E5=AD=98=E6=BA=A2=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- ide/src/trace/SpApplication.ts | 1 + .../trace/component/SpSystemTrace.event.ts | 4 - ide/src/trace/component/SpSystemTrace.init.ts | 12 +- ide/src/trace/component/chart/FrameChart.ts | 4 +- .../trace/component/chart/SpChartManager.ts | 7 +- .../trace/component/chart/SpProcessChart.ts | 338 +++++++++++------- .../component/trace/TimerShaftElement.ts | 6 +- .../component/trace/timer-shaft/RangeRuler.ts | 3 - ide/src/trace/database/TraceWorker.ts | 238 +++++++++--- .../database/data-trafic/utils/DataFilter.ts | 92 +++-- ide/src/trace/database/sql/Func.sql.ts | 97 ++--- .../ui-worker/ProcedureWorkerCommon.ts | 85 +++-- 12 files changed, 571 insertions(+), 316 deletions(-) diff --git a/ide/src/trace/SpApplication.ts b/ide/src/trace/SpApplication.ts index d623c5160..5464cb5d5 100644 --- a/ide/src/trace/SpApplication.ts +++ b/ide/src/trace/SpApplication.ts @@ -1748,6 +1748,7 @@ export class SpApplication extends BaseElement { private initSearchChangeEvents(): void { let timer: any = null; this.litSearch!.valueChangeHandler = (value: string) => { + this.litSearch!.list = []; if (timer) clearTimeout(timer); timer = setTimeout(() => { this.litSearch!.isClearValue = false; diff --git a/ide/src/trace/component/SpSystemTrace.event.ts b/ide/src/trace/component/SpSystemTrace.event.ts index 1b275f6d2..eb0e0bb1e 100644 --- a/ide/src/trace/component/SpSystemTrace.event.ts +++ b/ide/src/trace/component/SpSystemTrace.event.ts @@ -417,10 +417,6 @@ export function spSystemTraceDocumentOnMouseMove(sp: SpSystemTrace, ev: MouseEve } let isMouseInTimeShaft = handleMouseInTimeShaft(sp, ev); let rows = sp.visibleRows; - if (sp.timerShaftEL?.isScaling()) { - return; - } - sp.timerShaftEL?.documentOnMouseMove(ev, sp); if (isMouseInTimeShaft) { diff --git a/ide/src/trace/component/SpSystemTrace.init.ts b/ide/src/trace/component/SpSystemTrace.init.ts index 84368f9db..a7356ff01 100644 --- a/ide/src/trace/component/SpSystemTrace.init.ts +++ b/ide/src/trace/component/SpSystemTrace.init.ts @@ -184,9 +184,9 @@ function flagChangeHandler(sp: SpSystemTrace): (event: any) => void { if (event.detail.hidden) { sp.selectFlag = undefined; if (sp._flagList.length <= 0) { - if (TraceRow.rangeSelectObject) { - let showTab = sp.getShowTab(); - showTab = showTab.filter((it) => it !== 'box-flag'); + let showTab = sp.getShowTab(); + showTab = showTab.filter((it) => it !== 'box-flag'); + if (TraceRow.rangeSelectObject && showTab.length > 0) { sp.traceSheetEL?.displayTab(...showTab); } else { sp.traceSheetEL?.setMode('hidden'); @@ -202,9 +202,9 @@ function slicesChangeHandler(sp: SpSystemTrace): (event: any) => void { if (event.detail.hidden) { sp.slicestime = null; if (sp._slicesList.length <= 0) { - if (TraceRow.rangeSelectObject) { - let showTab = sp.getShowTab(); - showTab = showTab.filter((it) => it !== 'tabpane-current'); + let showTab = sp.getShowTab(); + showTab = showTab.filter((it) => it !== 'tabpane-current'); + if (TraceRow.rangeSelectObject && showTab.length > 0) { sp.traceSheetEL?.displayTab(...showTab); } else { sp.traceSheetEL?.setMode('hidden'); diff --git a/ide/src/trace/component/chart/FrameChart.ts b/ide/src/trace/component/chart/FrameChart.ts index cba83946a..098e4d862 100644 --- a/ide/src/trace/component/chart/FrameChart.ts +++ b/ide/src/trace/component/chart/FrameChart.ts @@ -26,6 +26,7 @@ const textMaxWidth = 50; const scaleRatio = 0.2; // 缩放比例 const ms10 = 10_000_000; const jsStackPath = ['.ts', '.ets', '.js']; +const textStyle = '12px bold'; class NodeValue { size: number; @@ -346,6 +347,7 @@ export class FrameChart extends BaseElement { public async calculateChartData(): Promise { this.clearCanvas(); this.canvasContext?.beginPath(); + this.canvasContext.font = textStyle; // 绘制刻度线 this.drawCalibrationTails(); // 绘制root节点 @@ -990,7 +992,7 @@ export class FrameChart extends BaseElement { background-color: white; border: 1px solid #f9f9f9; width: auto; - font-size: 8px; + font-size: 12px; color: #50809e; padding: 2px 10px; display: none; diff --git a/ide/src/trace/component/chart/SpChartManager.ts b/ide/src/trace/component/chart/SpChartManager.ts index 6c7ef0c58..f0f4f3dda 100644 --- a/ide/src/trace/component/chart/SpChartManager.ts +++ b/ide/src/trace/component/chart/SpChartManager.ts @@ -48,7 +48,7 @@ import { queryDataDICT, queryThreadAndProcessName, } from '../../database/sql/ProcessThread.sql'; -import { queryTaskPoolCallStack, queryTotalTime } from '../../database/sql/SqlLite.sql'; +import { queryTaskPoolCallStack, queryTotalTime, queryTraceRange } from '../../database/sql/SqlLite.sql'; import { getCpuUtilizationRate } from '../../database/sql/Cpu.sql'; import { queryMemoryConfig } from '../../database/sql/Memory.sql'; import { SpLtpoChart } from './SpLTPO'; @@ -81,6 +81,7 @@ export class SpChartManager { private spHiSysEvent: SpHiSysEventChart; private spSegmentationChart: SpSegmentationChart; private spBpftraceChart: SpBpftraceChart; + private tranceRange = { startTs: 0, endTs: 0 }; constructor(trace: SpSystemTrace) { this.trace = trace; @@ -127,6 +128,8 @@ export class SpChartManager { let ptArr = await queryThreadAndProcessName(); this.handleProcessThread(ptArr); info('initData timerShaftEL Data initialized'); + const range = await queryTraceRange(); + this.tranceRange = range[0]; } async initCpu(progress: Function): Promise { @@ -187,7 +190,7 @@ export class SpChartManager { await this.SpLtpoChart.init(); await this.frameTimeChart.init(); progress('process', 92); - await this.process.initAsyncFuncData(); + await this.process.initAsyncFuncData(this.tranceRange); await this.process.initDeliverInputEvent(); await this.process.init(); progress('display', 95); diff --git a/ide/src/trace/component/chart/SpProcessChart.ts b/ide/src/trace/component/chart/SpProcessChart.ts index 4224bd749..86bc6f2af 100644 --- a/ide/src/trace/component/chart/SpProcessChart.ts +++ b/ide/src/trace/component/chart/SpProcessChart.ts @@ -21,9 +21,9 @@ import { ProcessRender, ProcessStruct } from '../../database/ui-worker/Procedure import { ThreadRender, ThreadStruct } from '../../database/ui-worker/ProcedureWorkerThread'; import { FuncRender, FuncStruct } from '../../database/ui-worker/ProcedureWorkerFunc'; import { MemRender, ProcessMemStruct } from '../../database/ui-worker/ProcedureWorkerMem'; -import {folderSupplier, folderThreadHandler, getRowContext, rowThreadHandler, SpChartManager} from './SpChartManager'; +import { folderSupplier, folderThreadHandler, getRowContext, rowThreadHandler, SpChartManager } from './SpChartManager'; import { JankRender, JankStruct } from '../../database/ui-worker/ProcedureWorkerJank'; -import {isFrameContainPoint, ns2xByTimeShaft, PairPoint} from '../../database/ui-worker/ProcedureWorkerCommon'; +import { isFrameContainPoint, ns2xByTimeShaft, PairPoint } from '../../database/ui-worker/ProcedureWorkerCommon'; import { AppStartupRender, AppStartupStruct } from '../../database/ui-worker/ProcedureWorkerAppStartup'; import { SoRender, SoStruct } from '../../database/ui-worker/ProcedureWorkerSoInit'; import { FlagsConfig } from '../SpFlags'; @@ -78,8 +78,16 @@ export class SpProcessChart { this.trace = trace; } - initAsyncFuncData = async (): Promise => { - let asyncFuncList: any[] = await queryProcessAsyncFunc(); + initAsyncFuncData = async (traceRange: { startTs: number; endTs: number }): Promise => { + const funcNamesArray = await queryAllFuncNames(); + funcNamesArray.forEach((it) => { + this.funcNameMap.set(it.id, it.name); + }); + let asyncFuncList: any[] = await queryProcessAsyncFunc(traceRange); + for (const func of asyncFuncList) { + func.funName = this.funcNameMap.get(func.id); + func.threadName = Utils.THREAD_MAP.get(func.tid); + } info('AsyncFuncData Count is: ', asyncFuncList!.length); this.processAsyncFuncArray = asyncFuncList; this.processAsyncFuncMap = Utils.groupBy(asyncFuncList, 'pid'); @@ -113,7 +121,11 @@ export class SpProcessChart { }); }; - private createDeliverInputEventRow(parentRow: TraceRow, key: number,asyncFuncGroups: Array): TraceRow { + private createDeliverInputEventRow( + parentRow: TraceRow, + key: number, + asyncFuncGroups: Array + ): TraceRow { let funcRow = TraceRow.skeleton(); funcRow.rowId = `${asyncFuncGroups[0].funName}-${key}`; funcRow.asyncFuncName = asyncFuncGroups[0].funName; @@ -125,20 +137,25 @@ export class SpProcessChart { funcRow.style.width = '100%'; funcRow.name = `${asyncFuncGroups[0].funName} ${key}`; funcRow.setAttribute('children', ''); - funcRow.supplierFrame = () => { - return processDeliverInputEventDataSender(key, funcRow!).then((res: Array) => { - this.deliverInputEventSendCallback(res, funcRow, asyncFuncGroups); - return res; - }); + funcRow.supplierFrame = async (): Promise => { + const res = await processDeliverInputEventDataSender(key, funcRow!); + this.deliverInputEventSendCallback(res, funcRow, asyncFuncGroups); + return res; }; funcRow.findHoverStruct = (): void => { FuncStruct.hoverFuncStruct = funcRow.getHoverStruct(); - } + }; funcRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; funcRow.selectChangeHandler = this.trace.selectChangeHandler; - funcRow.onThreadHandler = rowThreadHandler('func', 'context', { - type: `func-${asyncFuncGroups[0].funName}-${key}`, - }, funcRow, this.trace); + funcRow.onThreadHandler = rowThreadHandler( + 'func', + 'context', + { + type: `func-${asyncFuncGroups[0].funName}-${key}`, + }, + funcRow, + this.trace + ); return funcRow; } private deliverInputEventSendCallback(res: Array, funcRow: TraceRow, asyncFuncGroups: Array): void { @@ -147,7 +164,7 @@ export class SpProcessChart { left.dur + right.dur; let depths: any = []; let createDepth = (currentDepth: number, index: number): void => { - if (depths[currentDepth] == undefined || !isIntersect(depths[currentDepth], res[index])) { + if (depths[currentDepth] === undefined || !isIntersect(depths[currentDepth], res[index])) { res[index].depth = currentDepth; depths[currentDepth] = res[index]; } else { @@ -157,7 +174,7 @@ export class SpProcessChart { res.forEach((it, i) => { res[i].funName = this.funcNameMap.get(res[i].id!); res[i].threadName = Utils.THREAD_MAP.get(res[i].tid!); - if (it.dur == -1 || it.dur === null || it.dur === undefined) { + if (it.dur === -1 || it.dur === null || it.dur === undefined) { it.dur = (TraceRow.range?.endNS || 0) - it.startTs; it.flag = 'Did not end'; } @@ -171,14 +188,12 @@ export class SpProcessChart { } } - - async init(): Promise { await this.prepareData(); if ( - this.eventCountMap['print'] == 0 && - this.eventCountMap['tracing_mark_write'] == 0 && - this.eventCountMap['sched_switch'] == 0 + this.eventCountMap['print'] === 0 && + this.eventCountMap['tracing_mark_write'] === 0 && + this.eventCountMap['sched_switch'] === 0 ) { return; } @@ -209,10 +224,7 @@ export class SpProcessChart { maxValues.forEach((it) => { this.filterIdMaxValue.set(it.filterId, it.maxValue); }); - let funcNamesArray = await queryAllFuncNames(); - funcNamesArray.forEach((it) => { - this.funcNameMap.set(it.id, it.name); - }); + let soInitNamesArray = await queryAllSoInitNames(); soInitNamesArray.forEach((it) => { this.soInitNameMap.set(it.id, it.name); @@ -254,14 +266,19 @@ export class SpProcessChart { info('The amount of initialized process threads data is : ', this.processThreads!.length); } - private async initProcessRow(pArr: Array, allTaskPoolPid: Array<{ pid: number }>, jankArr: Array, rsProcess: Array) { + private async initProcessRow( + pArr: Array, + allTaskPoolPid: Array<{ pid: number }>, + jankArr: Array, + rsProcess: Array + ): Promise { for (let i = 0; i < pArr.length; i++) { const it = pArr[i]; if ( - (this.processThreadDataCountMap.get(it.pid) || 0) == 0 && - (this.processThreadCountMap.get(it.pid) || 0) == 0 && - (this.processFuncDataCountMap.get(it.pid) || 0) == 0 && - (this.processMemDataCountMap.get(it.pid) || 0) == 0 + (this.processThreadDataCountMap.get(it.pid) || 0) === 0 && + (this.processThreadCountMap.get(it.pid) || 0) === 0 && + (this.processFuncDataCountMap.get(it.pid) || 0) === 0 && + (this.processMemDataCountMap.get(it.pid) || 0) === 0 ) { continue; } @@ -301,7 +318,11 @@ export class SpProcessChart { } } - private createProcessRow(index: number, process: any, allTaskPoolPid: Array<{ pid: number }>) { + private createProcessRow( + index: number, + process: any, + allTaskPoolPid: Array<{ pid: number }> + ): TraceRow { let processRow = TraceRow.skeleton(); processRow.rowId = `${process.pid}`; processRow.index = index; @@ -324,14 +345,20 @@ export class SpProcessChart { }; processRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; processRow.selectChangeHandler = this.trace.selectChangeHandler; - processRow.onThreadHandler = rowThreadHandler('process', 'context', { - pid: process.pid, - type: `process ${processRow.index} ${process.processName}` - }, processRow, this.trace); + processRow.onThreadHandler = rowThreadHandler( + 'process', + 'context', + { + pid: process.pid, + type: `process ${processRow.index} ${process.processName}`, + }, + processRow, + this.trace + ); return processRow; } - addProcessRowListener(processRow: TraceRow, actualRow: TraceRow | null) { + addProcessRowListener(processRow: TraceRow, actualRow: TraceRow | null): void { let offsetYTimeOut: any = undefined; processRow.addEventListener('expansion-change', (e: any) => { JankStruct.delJankLineFlag = false; @@ -375,9 +402,9 @@ export class SpProcessChart { }); } - handler1(e: any, linkItem: PairPoint[], actualRow: TraceRow | null) { + handler1(e: any, linkItem: PairPoint[], actualRow: TraceRow | null): void { JankStruct.selectJankStructList?.forEach((selectProcessStruct: any) => { - if (e.detail.rowId == selectProcessStruct.pid) { + if (e.detail.rowId === selectProcessStruct.pid) { JankStruct.selectJankStruct = selectProcessStruct; JankStruct.hoverJankStruct = selectProcessStruct; } @@ -387,12 +414,12 @@ export class SpProcessChart { this.updatePairPointTranslateY(linkItem[1]); linkItem[1].y = linkItem[1].rowEL!.translateY! + linkItem[1].offsetY; if (actualRow) { - if (linkItem[0].rowEL.rowId == e.detail.rowId) { + if (linkItem[0].rowEL.rowId === e.detail.rowId) { linkItem[0].x = ns2xByTimeShaft(linkItem[0].ns, this.trace.timerShaftEL!); linkItem[0].y = actualRow!.translateY! + linkItem[0].offsetY * 2; linkItem[0].offsetY = linkItem[0].offsetY * 2; linkItem[0].rowEL = actualRow!; - } else if (linkItem[1].rowEL.rowId == e.detail.rowId) { + } else if (linkItem[1].rowEL.rowId === e.detail.rowId) { linkItem[1].x = ns2xByTimeShaft(linkItem[1].ns, this.trace.timerShaftEL!); linkItem[1].y = actualRow!.translateY! + linkItem[1].offsetY * 2; linkItem[1].offsetY = linkItem[1].offsetY * 2; @@ -401,21 +428,21 @@ export class SpProcessChart { } } - handler2(e: any, linkItem: PairPoint[], processRow: TraceRow) { + handler2(e: any, linkItem: PairPoint[], processRow: TraceRow): void { this.updatePairPointTranslateY(linkItem[0]); linkItem[0].y = linkItem[0].rowEL!.translateY! + linkItem[0].offsetY; this.updatePairPointTranslateY(linkItem[1]); linkItem[1].y = linkItem[1].rowEL!.translateY! + linkItem[1].offsetY; - if (linkItem[0].rowEL.rowParentId == e.detail.rowId) { + if (linkItem[0].rowEL.rowParentId === e.detail.rowId) { this.updatePairPoint(linkItem[0], processRow); - } else if (linkItem[1].rowEL.rowParentId == e.detail.rowId) { + } else if (linkItem[1].rowEL.rowParentId === e.detail.rowId) { this.updatePairPoint(linkItem[1], processRow); } } - handler3(e: any, linkItem: PairPoint[]) { + handler3(e: any, linkItem: PairPoint[]): void { ThreadStruct.selectThreadStructList?.forEach((selectProcessStruct: any) => { - if (e.detail.rowId == selectProcessStruct.pid) { + if (e.detail.rowId === selectProcessStruct.pid) { ThreadStruct.selectThreadStruct = selectProcessStruct; ThreadStruct.hoverThreadStruct = selectProcessStruct; } @@ -436,20 +463,20 @@ export class SpProcessChart { } } - handler4(e: any, linkItem: PairPoint[], processRow: TraceRow) { + handler4(e: any, linkItem: PairPoint[], processRow: TraceRow): void { this.updatePairPointTranslateY(linkItem[0]); linkItem[0].y = processRow!.translateY + linkItem[0].offsetY; this.updatePairPointTranslateY(linkItem[1]); linkItem[1].y = linkItem[1].rowEL!.translateY + linkItem[1].offsetY; - if (linkItem[0].rowEL.rowParentId == e.detail.rowId) { + if (linkItem[0].rowEL.rowParentId === e.detail.rowId) { this.updatePairPoint(linkItem[0], processRow); } - if (linkItem[1].rowEL.rowParentId == e.detail.rowId) { + if (linkItem[1].rowEL.rowParentId === e.detail.rowId) { this.updatePairPoint(linkItem[1], processRow); } } - updatePairPointTranslateY(pair: PairPoint) { + updatePairPointTranslateY(pair: PairPoint): void { if (pair.rowEL.collect) { pair.rowEL.translateY = pair.rowEL.getBoundingClientRect().top - 195; } else { @@ -457,7 +484,7 @@ export class SpProcessChart { } } - updatePairPoint(pair: PairPoint, processRow: TraceRow) { + updatePairPoint(pair: PairPoint, processRow: TraceRow): void { if (!pair.rowEL.collect) { pair.x = ns2xByTimeShaft(pair.ns, this.trace.timerShaftEL!); pair.y = processRow!.translateY! + pair.offsetY / 2; @@ -477,16 +504,22 @@ export class SpProcessChart { expectedRow.name = 'Expected Timeline'; expectedRow.addTemplateTypes('FrameTimeline'); expectedRow.setAttribute('children', ''); - expectedRow.supplierFrame = async () => { + expectedRow.supplierFrame = async (): Promise => { let res = await processExpectedDataSender(process.pid, expectedRow!); this.jankSenderCallback(res, 'expected', process, expectedRow, renderServiceProcess); return res; }; expectedRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; expectedRow.selectChangeHandler = this.trace.selectChangeHandler; - expectedRow.onThreadHandler = rowThreadHandler('jank', 'context', { - type: 'expected_frame_timeline_slice', - }, expectedRow, this.trace); + expectedRow.onThreadHandler = rowThreadHandler( + 'jank', + 'context', + { + type: 'expected_frame_timeline_slice', + }, + expectedRow, + this.trace + ); processRow.addChildTraceRow(expectedRow); return expectedRow; } @@ -500,21 +533,33 @@ export class SpProcessChart { actualRow.name = 'Actual Timeline'; actualRow.addTemplateTypes('FrameTimeline'); actualRow.setAttribute('children', ''); - actualRow.supplierFrame = async () => { + actualRow.supplierFrame = async (): Promise => { let res = await processActualDataSender(process.pid, actualRow!); this.jankSenderCallback(res, 'actual', process, actualRow, renderServiceProcess); return res; }; actualRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; actualRow.selectChangeHandler = this.trace.selectChangeHandler; - actualRow.onThreadHandler = rowThreadHandler('jank', 'context', { - type: 'actual_frame_timeline_slice', - }, actualRow, this.trace); + actualRow.onThreadHandler = rowThreadHandler( + 'jank', + 'context', + { + type: 'actual_frame_timeline_slice', + }, + actualRow, + this.trace + ); processRow.addChildTraceRow(actualRow); return actualRow; } - jankSenderCallback(res: JankStruct[], type: string, process: any, row: TraceRow, renderServiceProcess: Array) { + jankSenderCallback( + res: JankStruct[], + type: string, + process: any, + row: TraceRow, + renderServiceProcess: Array + ): void { let maxDepth: number = 1; let unitHeight: number = 20; for (let j = 0; j < res.length; j++) { @@ -557,11 +602,11 @@ export class SpProcessChart { startupRow.rowHidden = !processRow.expansion; startupRow.index = 0; startupRow.style.height = '30px'; - startupRow.style.width = `100%`; - startupRow.name = `App Startups`; + startupRow.style.width = '100%'; + startupRow.name = 'App Startups'; startupRow.findHoverStruct = (): void => { AppStartupStruct.hoverStartupStruct = startupRow.getHoverStruct(); - } + }; startupRow.setAttribute('children', ''); startupRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; startupRow.selectChangeHandler = this.trace.selectChangeHandler; @@ -577,9 +622,15 @@ export class SpProcessChart { } return res; }); - startupRow.onThreadHandler = rowThreadHandler('app-start-up', 'appStartupContext', { - type: `app-startup ${processRow.rowId}`, - }, startupRow, this.trace); + startupRow.onThreadHandler = rowThreadHandler( + 'app-start-up', + 'appStartupContext', + { + type: `app-startup ${processRow.rowId}`, + }, + startupRow, + this.trace + ); processRow.addChildTraceRow(startupRow); return startupRow; } @@ -594,14 +645,14 @@ export class SpProcessChart { soRow.rowHidden = !processRow.expansion; soRow.index = 0; soRow.style.height = `${maxHeight}px`; - soRow.style.width = `100%`; - soRow.name = `Static Initialization`; + soRow.style.width = '100%'; + soRow.name = 'Static Initialization'; soRow.setAttribute('children', ''); soRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; soRow.selectChangeHandler = this.trace.selectChangeHandler; soRow.findHoverStruct = (): void => { SoStruct.hoverSoStruct = soRow.getHoverStruct(); - } + }; soRow.supplierFrame = (): Promise> => processSoInitDataSender(parseInt(processRow.rowId!), soRow).then((res) => { if (res.length <= 0) { @@ -615,16 +666,22 @@ export class SpProcessChart { }); return res; }); - soRow.onThreadHandler = rowThreadHandler('app-so-init', 'context', { - type: `static-init ${processRow.rowId}`, - }, soRow, this.trace); + soRow.onThreadHandler = rowThreadHandler( + 'app-so-init', + 'context', + { + type: `static-init ${processRow.rowId}`, + }, + soRow, + this.trace + ); processRow.addChildTraceRow(soRow); return soRow; } insertAfter(newEl: HTMLElement, targetEl: HTMLElement): void { let parentEl = targetEl.parentNode; - if (parentEl!.lastChild == targetEl) { + if (parentEl!.lastChild === targetEl) { parentEl!.appendChild(newEl); } else { parentEl!.insertBefore(newEl, targetEl.nextSibling); @@ -634,63 +691,69 @@ export class SpProcessChart { //add thread list addThreadList( it: { pid: number | null; processName: string | null }, - processRow: TraceRow, + pRow: TraceRow, expectedRow: TraceRow | null, actualRow: TraceRow | null, soRow: TraceRow | undefined, - startupRow: TraceRow | undefined, - ) { - let threads = this.processThreads.filter((thread) => thread.pid === it.pid && thread.tid != 0); - let threadRowArr: Array> = []; + startupRow: TraceRow | undefined + ): void { + let threads = this.processThreads.filter((thread) => thread.pid === it.pid && thread.tid !== 0); + let tRowArr: Array> = []; for (let j = 0; j < threads.length; j++) { let thread = threads[j]; - let threadRow = TraceRow.skeleton(); - threadRow.rowId = `${thread.tid}`; - threadRow.rowType = TraceRow.ROW_TYPE_THREAD; - threadRow.rowParentId = `${it.pid}`; - threadRow.rowHidden = !processRow.expansion; - threadRow.index = j; - threadRow.style.height = '18px'; - threadRow.style.width = '100%'; - threadRow.name = `${thread.threadName || 'Thread'} ${thread.tid}`; - threadRow.namePrefix = `${thread.threadName || 'Thread'}`; - threadRow.setAttribute('children', ''); - threadRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; - threadRow.selectChangeHandler = this.trace.selectChangeHandler; - threadRow.findHoverStruct = (): void => this.threadRowFindHoverStruct(threadRow); - threadRow.supplierFrame = async (): Promise> => { - const res = await threadDataSender(thread.tid || 0, it.pid || 0, threadRow); + let tRow = TraceRow.skeleton(); + tRow.rowId = `${thread.tid}`; + tRow.rowType = TraceRow.ROW_TYPE_THREAD; + tRow.rowParentId = `${it.pid}`; + tRow.rowHidden = !pRow.expansion; + tRow.index = j; + tRow.style.height = '18px'; + tRow.style.width = '100%'; + tRow.name = `${thread.threadName || 'Thread'} ${thread.tid}`; + tRow.namePrefix = `${thread.threadName || 'Thread'}`; + tRow.setAttribute('children', ''); + tRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; + tRow.selectChangeHandler = this.trace.selectChangeHandler; + tRow.findHoverStruct = (): void => this.threadRowFindHoverStruct(tRow); + tRow.supplierFrame = async (): Promise> => { + const res = await threadDataSender(thread.tid || 0, it.pid || 0, tRow); if (res === true) { return []; } else { let rs = res as ThreadStruct[]; - if (rs.length <= 0 && !threadRow.isComplete) { + if (rs.length <= 0 && !tRow.isComplete) { this.trace.refreshCanvas(true); } return rs; } }; - threadRow.onThreadHandler = rowThreadHandler('thread', 'context', { - type: `thread ${thread.tid} ${thread.threadName}`, - translateY: threadRow.translateY, - }, threadRow, this.trace); - this.insertThreadRowToDocument(it, j, thread, processRow, threadRow, threads, threadRowArr, actualRow, expectedRow, startupRow, soRow); - this.addFuncStackRow(it, thread, j, threads, threadRowArr, threadRow, processRow); + tRow.onThreadHandler = rowThreadHandler( + 'thread', + 'context', + { + type: `thread ${thread.tid} ${thread.threadName}`, + translateY: tRow.translateY, + }, + tRow, + this.trace + ); + this.insertRowToDoc(it, j, thread, pRow, tRow, threads, tRowArr, actualRow, expectedRow, startupRow, soRow); + this.addFuncStackRow(it, thread, j, threads, tRowArr, tRow, pRow); if ((thread.switchCount || 0) === 0) { - threadRow.rowDiscard = true; + tRow.rowDiscard = true; } } } - threadRowFindHoverStruct(threadRow: TraceRow) { + threadRowFindHoverStruct(threadRow: TraceRow): void { let arr = threadRow.dataListCache.filter( (re) => re.frame && isFrameContainPoint(re.frame, threadRow.hoverX, threadRow.hoverY, true, false) ); - let runItem = arr.find(it => it.state === 'Running'); + let runItem = arr.find((it) => it.state === 'Running'); if (runItem) { ThreadStruct.hoverThreadStruct = runItem; } else { - let otherItem = arr.find(it => it.state !== 'S'); + let otherItem = arr.find((it) => it.state !== 'S'); if (otherItem) { ThreadStruct.hoverThreadStruct = otherItem; } else { @@ -699,7 +762,7 @@ export class SpProcessChart { } } - insertThreadRowToDocument( + insertRowToDoc( it: any, index: number, thread: ThreadStruct, @@ -711,7 +774,7 @@ export class SpProcessChart { expectedRow: TraceRow | null, startupRow: TraceRow | null | undefined, soRow: TraceRow | null | undefined - ) { + ): void { if (it.processName === 'render_service') { if (threadRow.name === `${it.processName} ${it.pid}`) { this.renderRow = threadRow; @@ -745,8 +808,8 @@ export class SpProcessChart { threadRowArr: Array, threadRow: TraceRow, processRow: TraceRow - ) { - if (this.threadFuncMaxDepthMap.get(`${thread.upid}-${thread.tid}`) != undefined) { + ): void { + if (this.threadFuncMaxDepthMap.get(`${thread.upid}-${thread.tid}`) !== undefined) { let max = this.threadFuncMaxDepthMap.get(`${thread.upid}-${thread.tid}`) || 1; let maxHeight = max * 18 + 6; let funcRow = TraceRow.skeleton(); @@ -769,10 +832,16 @@ export class SpProcessChart { funcRow.selectChangeHandler = this.trace.selectChangeHandler; funcRow.findHoverStruct = (): void => { FuncStruct.hoverFuncStruct = funcRow.getHoverStruct(); - } - funcRow.onThreadHandler = rowThreadHandler('func', 'context', { - type: `func${thread.tid}${thread.threadName}`, - }, funcRow, this.trace); + }; + funcRow.onThreadHandler = rowThreadHandler( + 'func', + 'context', + { + type: `func${thread.tid}${thread.threadName}`, + }, + funcRow, + this.trace + ); if (process.processName === 'render_service') { let flag = threads.length === index + 1; processRow.sortRenderServiceData(funcRow, threadRow, threadRowArr, flag); @@ -808,7 +877,7 @@ export class SpProcessChart { } //进程内存信息 - addProcessMemInfo(it: { pid: number | null; processName: string | null }, processRow: TraceRow) { + addProcessMemInfo(it: { pid: number | null; processName: string | null }, processRow: TraceRow): void { let processMem = this.processMem.filter((mem) => mem.pid === it.pid); processMem.forEach((mem) => { let row = TraceRow.skeleton(); @@ -823,7 +892,11 @@ export class SpProcessChart { row.favoriteChangeHandler = this.trace.favoriteChangeHandler; row.selectChangeHandler = this.trace.selectChangeHandler; row.focusHandler = (): void => { - this.trace.displayTip(row, ProcessMemStruct.hoverProcessMemStruct, `${ProcessMemStruct.hoverProcessMemStruct?.value || '0'}`); + this.trace.displayTip( + row, + ProcessMemStruct.hoverProcessMemStruct, + `${ProcessMemStruct.hoverProcessMemStruct?.value || '0'}` + ); }; row.findHoverStruct = (): void => { ProcessMemStruct.hoverProcessMemStruct = row.getHoverStruct(false); @@ -846,9 +919,15 @@ export class SpProcessChart { } return resultProcess; }); - row.onThreadHandler = rowThreadHandler('mem', 'context', { - type: `mem ${mem.trackId} ${mem.trackName}`, - }, row, this.trace); + row.onThreadHandler = rowThreadHandler( + 'mem', + 'context', + { + type: `mem ${mem.trackId} ${mem.trackName}`, + }, + row, + this.trace + ); if (this.renderRow && row.name === 'H:PreferredFrameRate') { processRow.addChildTraceRowBefore(row, this.renderRow); } else { @@ -856,7 +935,7 @@ export class SpProcessChart { } }); } - private calMaxHeight(asyncFunctions: any[]) : number{ + private calMaxHeight(asyncFunctions: any[]): number { let max = 0; asyncFunctions.forEach((it) => { const depth = it.depth || 0; @@ -865,11 +944,11 @@ export class SpProcessChart { } }); max += 1; - return max * 18 + 6;; + return max * 18 + 6; } //Async Function - addAsyncFunction(it: { pid: number; processName: string | null }, processRow: TraceRow) { + addAsyncFunction(it: { pid: number; processName: string | null }, processRow: TraceRow): void { let asyncFuncList = this.processAsyncFuncMap[it.pid] || []; let asyncFuncGroup = Utils.groupBy(asyncFuncList, 'funName'); Reflect.ownKeys(asyncFuncGroup).map((key: any) => { @@ -885,7 +964,10 @@ export class SpProcessChart { } let currentDepth = 0; let index = i; - while (depthArray[currentDepth] !== undefined && isIntersect(depthArray[currentDepth], asyncFunctions[index])) { + while ( + depthArray[currentDepth] !== undefined && + isIntersect(depthArray[currentDepth], asyncFunctions[index]) + ) { currentDepth++; } asyncFunctions[index].depth = currentDepth; @@ -907,13 +989,19 @@ export class SpProcessChart { funcRow.setAttribute('children', ''); funcRow.findHoverStruct = (): void => { FuncStruct.hoverFuncStruct = funcRow.getHoverStruct(); - } + }; funcRow.supplier = (): Promise => new Promise((resolve) => resolve(asyncFunctions)); funcRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; funcRow.selectChangeHandler = this.trace.selectChangeHandler; - funcRow.onThreadHandler = rowThreadHandler('func', 'context', { - type: `func-${asyncFunctions[0].funName}-${it.pid}`, - }, funcRow, this.trace); + funcRow.onThreadHandler = rowThreadHandler( + 'func', + 'context', + { + type: `func-${asyncFunctions[0].funName}-${it.pid}`, + }, + funcRow, + this.trace + ); processRow.addChildTraceRow(funcRow); } }); diff --git a/ide/src/trace/component/trace/TimerShaftElement.ts b/ide/src/trace/component/trace/TimerShaftElement.ts index 25868890c..41abbaa0d 100644 --- a/ide/src/trace/component/trace/TimerShaftElement.ts +++ b/ide/src/trace/component/trace/TimerShaftElement.ts @@ -212,12 +212,8 @@ export class TimerShaftElement extends BaseElement { this._endNS = value; } - isScaling(): boolean { - return this._rangeRuler?.isPress || false; - } - reset(): void { - this.loadComplete = false; + this.loadComplete = false; this.totalNS = 10_000_000_000; this.startNS = 0; this.endNS = 10_000_000_000; diff --git a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts index 0e81c05d9..e2a9b80ba 100644 --- a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts +++ b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts @@ -98,7 +98,6 @@ export class RangeRuler extends Graph { isNewRange: boolean = false; markAX: number = 0; markBX: number = 0; - isPress: boolean = false; pressFrameIdF: number = -1; pressFrameIdW: number = -1; pressFrameIdS: number = -1; @@ -558,7 +557,6 @@ export class RangeRuler extends Graph { this.animaStartTime = new Date().getTime(); //记录按下的时间 this.keyboardKeyPressMap[this.pressedKeys[this.pressedKeys.length - 1]]?.bind(this)(); } - this.isPress = true; } keyPressF(): void { @@ -723,7 +721,6 @@ export class RangeRuler extends Graph { this.pressedKeys.splice(number, 1); } } - this.isPress = false; } keyUpW(): void { diff --git a/ide/src/trace/database/TraceWorker.ts b/ide/src/trace/database/TraceWorker.ts index a140f583c..e93b1decd 100644 --- a/ide/src/trace/database/TraceWorker.ts +++ b/ide/src/trace/database/TraceWorker.ts @@ -40,7 +40,6 @@ const CONTENT_TYPE_HEADER_PAGE = 30; const CONTENT_TYPE_PRINTK_FORMATS = 31; const CONTENT_TYPE_KALLSYMS = 32; - let arkTsData: Array = []; let arkTsDataSize: number = 0; @@ -342,19 +341,23 @@ function parseThirdWasmByOpenAction(e: MessageEvent): void { } function isCommonData(dataType: number): boolean { - return dataType === CONTENT_TYPE_CMDLINES || dataType === CONTENT_TYPE_TGIDS || - dataType === CONTENT_TYPE_HEADER_PAGE || dataType === CONTENT_TYPE_PRINTK_FORMATS || + return ( + dataType === CONTENT_TYPE_CMDLINES || + dataType === CONTENT_TYPE_TGIDS || + dataType === CONTENT_TYPE_HEADER_PAGE || + dataType === CONTENT_TYPE_PRINTK_FORMATS || dataType === CONTENT_TYPE_KALLSYMS + ); } function parseRawTraceByOpenAction(e: MessageEvent, wrSize: number, r2: number, uint8Array: Uint8Array): number { - let commonDataOffsetList: Array<{ startOffset: number; endOffset: number}> = []; // common Data + let commonDataOffsetList: Array<{ startOffset: number; endOffset: number }> = []; // common Data let offset = 12; let tlvTypeLength = 4; let headArray = uint8Array.slice(0, offset); let commonTotalLength = 0; while (offset < uint8Array.length) { - let commonDataOffset = {startOffset: offset, endOffset: offset}; + let commonDataOffset = { startOffset: offset, endOffset: offset }; let dataTypeData = e.data.buffer.slice(offset, offset + tlvTypeLength); offset += tlvTypeLength; let dataType = Array.from(new Uint32Array(dataTypeData)); @@ -602,8 +605,9 @@ function onmessageByDownloadDBAction(e: MessageEvent): void { function onmessageByUploadSoAction(e: MessageEvent): void { uploadSoActionId = e.data.id; - let fileList = e.data.params as Array; + const fileList = e.data.params as Array; if (fileList) { + fileList.sort((a, b) => b.size - a.size); soFileList = fileList; uploadFileIndex = 0; if (!uploadSoCallbackFn) { @@ -620,7 +624,7 @@ async function saveDataToIndexDB( timStamp: number, pageNum: number, saveIndex: number, - saveStartOffset: number, + saveStartOffset: number ): Promise { let freeArray = currentChunk.slice(0, currentChunkOffset); await addDataToIndexeddb(indexDB, { @@ -641,7 +645,13 @@ function cutLongTraceCallBackHandle( heapPtr: number, size: number, dataType: number, - newCutFilePageInfo: Map; dataTypes: string }] }> + newCutFilePageInfo: Map< + string, + { + traceFileType: string; + dataArray: [{ data: Uint8Array | Array<{ offset: number; size: number }>; dataTypes: string }]; + } + > ) { let key = `${traceFileType}_${currentPageNum}`; let out: Uint8Array = Module.HEAPU8.slice(heapPtr, heapPtr + size); @@ -652,11 +662,11 @@ function cutLongTraceCallBackHandle( } else { if (newCutFilePageInfo.has(key)) { let newVar = newCutFilePageInfo.get(key); - newVar?.dataArray.push({data: out, dataTypes: 'data'}); + newVar?.dataArray.push({ data: out, dataTypes: 'data' }); } else { newCutFilePageInfo.set(key, { traceFileType: traceFileType, - dataArray: [{data: out, dataTypes: 'data'}], + dataArray: [{ data: out, dataTypes: 'data' }], }); } } @@ -666,12 +676,15 @@ function cutLongTraceCallBackHandle( let jsonStr: string = dec.decode(out); let jsonObj = JSON.parse(jsonStr); let valueArray: Array<{ offset: number; size: number }> = jsonObj.value; - cutFilePageInfo.dataArray.push({data: valueArray, dataTypes: 'json'}); + cutFilePageInfo.dataArray.push({ data: valueArray, dataTypes: 'json' }); } } } -function initSplitLongTraceModuleAndFun(headArray: Uint8Array, cutFileCallBack: (heapPtr: number, size: number, dataType: number, isEnd: number) => void): number { +function initSplitLongTraceModuleAndFun( + headArray: Uint8Array, + cutFileCallBack: (heapPtr: number, size: number, dataType: number, isEnd: number) => void +): number { splitReqBufferAddr = Module._InitializeSplitFile(Module.addFunction(cutFileCallBack, 'viiii'), REQ_BUF_SIZE); Module.HEAPU8.set(headArray, splitReqBufferAddr); Module._TraceStreamerGetLongTraceTimeSnapEx(headArray.length); @@ -717,10 +730,24 @@ async function handleDataTypeBySplitLongTrace( return [currentChunkOffset, saveIndex, saveStartOffset, currentChunk]; } -async function saveAllDataByLongTrace(range: IDBKeyRange, nowCutInfoList: Array, - searchDataInfo: { fileType: string; index: number; pageNum: number; startOffsetSize: number; endOffsetSize: number }[], - currentChunkOffset: number, currentChunk: Uint8Array, fileType: string, timStamp: number, pageNum: number, - saveIndex: number, saveStartOffset: number): Promise<[number, number, number, Uint8Array]> { +async function saveAllDataByLongTrace( + range: IDBKeyRange, + nowCutInfoList: Array, + searchDataInfo: { + fileType: string; + index: number; + pageNum: number; + startOffsetSize: number; + endOffsetSize: number; + }[], + currentChunkOffset: number, + currentChunk: Uint8Array, + fileType: string, + timStamp: number, + pageNum: number, + saveIndex: number, + saveStartOffset: number +): Promise<[number, number, number, Uint8Array]> { let transaction = indexDB.transaction(STORE_NAME, 'readonly'); let store = transaction.objectStore(STORE_NAME); let index = store.index('QueryCompleteFile'); @@ -751,9 +778,16 @@ async function saveAllDataByLongTrace(range: IDBKeyRange, nowCutInfoList: Array< currentChunk.set(saveArray, currentChunkOffset); currentChunkOffset += saveArray.length; } else { - await addDataToIndexeddb(indexDB, { buf: saveArray, id: `${fileType}_new_${timStamp}_${pageNum}_${saveIndex}`, - fileType: `${fileType}_new`, pageNum: pageNum, startOffset: saveStartOffset, - endOffset: saveStartOffset + maxSize, index: saveIndex, timStamp: timStamp}); + await addDataToIndexeddb(indexDB, { + buf: saveArray, + id: `${fileType}_new_${timStamp}_${pageNum}_${saveIndex}`, + fileType: `${fileType}_new`, + pageNum: pageNum, + startOffset: saveStartOffset, + endOffset: saveStartOffset + maxSize, + index: saveIndex, + timStamp: timStamp, + }); saveStartOffset += maxSize; saveIndex++; } @@ -768,7 +802,13 @@ async function saveAllDataByLongTrace(range: IDBKeyRange, nowCutInfoList: Array< async function handleJsonTypeBySplitLongTrace( receiveData: { data: Uint8Array | Array<{ offset: number; size: number }>; dataTypes: string }, - allIndexDataList: Array<{ fileType: string; index: number; pageNum: number; startOffsetSize: number; endOffsetSize: number }>, + allIndexDataList: Array<{ + fileType: string; + index: number; + pageNum: number; + startOffsetSize: number; + endOffsetSize: number; + }>, fileType: string, timStamp: number, currentChunkOffset: number, @@ -793,16 +833,40 @@ async function handleJsonTypeBySplitLongTrace( let nowStartCutOffset = nowCutInfoList[0].offset; let nowEndCutOffset = cutInfo.offset + cutInfo.size; let searchDataInfo = allIndexDataList.filter( - (value: { fileType: string; index: number; pageNum: number; startOffsetSize: number; endOffsetSize: number;}) => { - return ( value.fileType === fileType && value.startOffsetSize <= nowEndCutOffset && - value.endOffsetSize >= nowStartCutOffset);}); + (value: { + fileType: string; + index: number; + pageNum: number; + startOffsetSize: number; + endOffsetSize: number; + }) => { + return ( + value.fileType === fileType && + value.startOffsetSize <= nowEndCutOffset && + value.endOffsetSize >= nowStartCutOffset + ); + } + ); let startIndex = searchDataInfo[0].index; let endIndex = searchDataInfo[searchDataInfo.length - 1].index; - let range = IDBKeyRange.bound([timStamp, fileType, 0, startIndex], - [timStamp, fileType, 0, endIndex],false,false); - [currentChunkOffset, saveIndex, saveStartOffset, currentChunk] = - await saveAllDataByLongTrace(range, nowCutInfoList, searchDataInfo, currentChunkOffset, currentChunk, fileType, - timStamp, pageNum, saveIndex, saveStartOffset); + let range = IDBKeyRange.bound( + [timStamp, fileType, 0, startIndex], + [timStamp, fileType, 0, endIndex], + false, + false + ); + [currentChunkOffset, saveIndex, saveStartOffset, currentChunk] = await saveAllDataByLongTrace( + range, + nowCutInfoList, + searchDataInfo, + currentChunkOffset, + currentChunk, + fileType, + timStamp, + pageNum, + saveIndex, + saveStartOffset + ); isBeforeCutFinish = true; } else { nowCutInfoList.push(cutInfo); @@ -812,18 +876,26 @@ async function handleJsonTypeBySplitLongTrace( } async function handleAllTypeDataByLongTrace( - newCutFilePageInfo: Map; - dataTypes: string }] }>, + newCutFilePageInfo: Map< + string, + { + traceFileType: string; + dataArray: [ + { + data: Uint8Array | Array<{ offset: number; size: number }>; + dataTypes: string; + } + ]; + } + >, timStamp: number, allIndexDataList: Array<{ fileType: string; index: number; pageNum: number; startOffsetSize: number; - endOffsetSize: number}> + endOffsetSize: number; + }> ): Promise { for (const [fileTypePageNum, fileMessage] of newCutFilePageInfo) { let fileTypePageNumArr = fileTypePageNum.split('_'); @@ -837,19 +909,42 @@ async function handleAllTypeDataByLongTrace( for (let fileDataIndex = 0; fileDataIndex < dataArray.length; fileDataIndex++) { let receiveData = dataArray[fileDataIndex]; if (receiveData.dataTypes === 'data') { - [currentChunkOffset, saveIndex, saveStartOffset, currentChunk] = - await handleDataTypeBySplitLongTrace(receiveData, currentChunkOffset, currentChunk, fileType, - timStamp, pageNum, saveIndex, saveStartOffset); + [currentChunkOffset, saveIndex, saveStartOffset, currentChunk] = await handleDataTypeBySplitLongTrace( + receiveData, + currentChunkOffset, + currentChunk, + fileType, + timStamp, + pageNum, + saveIndex, + saveStartOffset + ); } else { if (receiveData.data.length > 0) { - [currentChunkOffset, saveIndex, saveStartOffset, currentChunk] = - await handleJsonTypeBySplitLongTrace(receiveData, allIndexDataList, fileType, timStamp, - currentChunkOffset, currentChunk, pageNum, saveIndex, saveStartOffset); + [currentChunkOffset, saveIndex, saveStartOffset, currentChunk] = await handleJsonTypeBySplitLongTrace( + receiveData, + allIndexDataList, + fileType, + timStamp, + currentChunkOffset, + currentChunk, + pageNum, + saveIndex, + saveStartOffset + ); } } } if (currentChunkOffset !== 0) { - await saveDataToIndexDB(currentChunk, currentChunkOffset, fileType, timStamp, pageNum, saveIndex, saveStartOffset); + await saveDataToIndexDB( + currentChunk, + currentChunkOffset, + fileType, + timStamp, + pageNum, + saveIndex, + saveStartOffset + ); saveStartOffset += maxSize; saveIndex++; } @@ -863,7 +958,11 @@ async function onmessageByLongTraceAction(e: MessageEvent): Promise { let timStamp = e.data.params.timeStamp; let allIndexDataList = e.data.params.splitDataList; let splitFileInfos = e.data.params.splitFileInfo as Array<{ - fileType: string; startIndex: number; endIndex: number; size: number}>; + fileType: string; + startIndex: number; + endIndex: number; + size: number; + }>; let maxPageNum = headArray.length / 1024; let currentPageNum = 0; let splitReqBufferAddr: number; @@ -872,8 +971,13 @@ async function onmessageByLongTraceAction(e: MessageEvent): Promise { if (splitFileInfo && splitFileInfo.length > 0) { let traceFileType: string = ''; indexDB = await openDB(); - let newCutFilePageInfo: Map; dataTypes: string }]}> = new Map(); + let newCutFilePageInfo: Map< + string, + { + traceFileType: string; + dataArray: [{ data: Uint8Array | Array<{ offset: number; size: number }>; dataTypes: string }]; + } + > = new Map(); let cutFileCallBack = (heapPtr: number, size: number, dataType: number, isEnd: number) => { cutLongTraceCallBackHandle(traceFileType, currentPageNum, heapPtr, size, dataType, newCutFilePageInfo); }; @@ -989,7 +1093,12 @@ async function splitFileAndSaveArkTs( } } -const splitFileAndSave = async (timStamp: number, fileInfo: any, pageNum: number, splitReqBufferAddr?: any): Promise => { +const splitFileAndSave = async ( + timStamp: number, + fileInfo: any, + pageNum: number, + splitReqBufferAddr?: any +): Promise => { let fileType = fileInfo.fileType; let fileSize = fileInfo.size; let startIndex = fileInfo.startIndex; @@ -1014,9 +1123,24 @@ const splitFileAndSave = async (timStamp: number, fileInfo: any, pageNum: number let uint8Array = new Uint8Array(arrayBuffer.buf); let cutFileSize = 0; while (cutFileSize < uint8Array.length) { - [cutFileSize, resultFileSize] = execLongTraceSplitFileByModule(pageNum, fileSize, resultFileSize, cutFileSize, uint8Array, splitReqBufferAddr); + [cutFileSize, resultFileSize] = execLongTraceSplitFileByModule( + pageNum, + fileSize, + resultFileSize, + cutFileSize, + uint8Array, + splitReqBufferAddr + ); if (arkTsDataSize > 0 && fileType === 'arkts') { - splitFileAndSaveArkTs(currentChunkOffset, currentChunk, fileType, pageNum, saveStartOffset, saveIndex, timStamp); + splitFileAndSaveArkTs( + currentChunkOffset, + currentChunk, + fileType, + pageNum, + saveStartOffset, + saveIndex, + timStamp + ); } } } @@ -1037,7 +1161,7 @@ async function getIndexedDBQueryData(db: IDBDatabase, range: IDBKeyRange): Promi const store = transaction.objectStore(STORE_NAME); const index = store.index('QueryCompleteFile'); const getRequest = index.openCursor(range); - return await queryDataFromIndexeddb(getRequest) + return await queryDataFromIndexeddb(getRequest); } function execLongTraceSplitFileByModule( @@ -1112,10 +1236,9 @@ const uploadSoFile = async (file: File | null): Promise => { let buffer: ArrayBuffer | null = await blob.arrayBuffer(); let data: Uint8Array | null = new Uint8Array(buffer); let size = file.size; - let lastFile = uploadFileIndex === soFileList.length - 1 ? 1 : 0; Module.HEAPU8.set(data, reqBufferAddr); writeSize += sliceLen; - upRes = Module._TraceStreamerDownloadELFEx(size, fileNameLength, sliceLen, lastFile); + upRes = Module._TraceStreamerDownloadELFEx(size, fileNameLength, sliceLen, 1); data = null; buffer = null; blob = null; @@ -1126,22 +1249,29 @@ const uploadSoFile = async (file: File | null): Promise => { } }; +const failedArray: string[] = []; + const uploadSoCallBack = (heapPtr: number, size: number, isFinish: number): void => { let out: Uint8Array | null = Module.HEAPU8.slice(heapPtr, heapPtr + size); if (out) { let res = dec.decode(out); out = null; - if (res.includes('file send over')) { + if (res.includes('ok') || res.includes('failed')) { + if (res.includes('failed')) { + failedArray.push(soFileList[uploadFileIndex]!.name); + } if (uploadFileIndex < soFileList.length - 1) { uploadFileIndex = uploadFileIndex + 1; uploadSoFile(soFileList[uploadFileIndex]).then(); } - } else { + } + if (uploadFileIndex === soFileList.length - 1) { soFileList.length = 0; self.postMessage({ id: uploadSoActionId, action: 'upload-so', - results: res.includes('ok') ? 'ok' : 'failed', + results: 'ok', + failedArray: failedArray, }); } } @@ -1167,7 +1297,7 @@ function cutFileBufferByOffSet(out: Uint8Array, uint8Array: Uint8Array): Uint8Ar if (isRawTrace(uint8Array)) { let commDataSize = 0; let otherDataSize = 0; - valueArray.forEach(item => { + valueArray.forEach((item) => { const type = item.type; if (type === 0) { commDataSize += item.size; diff --git a/ide/src/trace/database/data-trafic/utils/DataFilter.ts b/ide/src/trace/database/data-trafic/utils/DataFilter.ts index 8eceab248..92ac82a7c 100644 --- a/ide/src/trace/database/data-trafic/utils/DataFilter.ts +++ b/ide/src/trace/database/data-trafic/utils/DataFilter.ts @@ -21,7 +21,7 @@ export function filterData( width: number ): any[] { let pns = (endNS - startNS) / width; //每个像素多少ns - let slice = findRange(list, {startKey, durKey, startNS, endNS}); + let slice = findRange(list, { startKey, durKey, startNS, endNS }); let sum = 0; for (let i = 0; i < slice.length; i++) { if (i === slice.length - 1) { @@ -61,7 +61,7 @@ export function filterDataByLayer( width: number ): any[] { let pns = (endNS - startNS) / width; //每个像素多少ns - let sliceArray = findRange(list, {startKey, durKey, startNS, endNS}); + let sliceArray = findRange(list, { startKey, durKey, startNS, endNS }); let groups = groupBy(sliceArray, layerKey); let res: any[] = []; Reflect.ownKeys(groups).map((key: any) => { @@ -107,30 +107,64 @@ export function filterDataByGroup( endNS: number, width: number, valueKey?: string, - filter?: (a: any) => boolean): any[] { - let arr = findRange(list, {startKey, durKey, startNS, endNS}) - arr = arr.map((it) => { - it.px = Math.floor(it[startKey] / ((endNS - startNS) / width)); - return it; - }); - let group = groupBy(arr, 'px'); - let res: Set = new Set(); - Reflect.ownKeys(group).map((key: any): void => { - let arr = group[key] as any[]; - if (arr.length > 0) { - res.add(arr.reduce((p, c) => (p[durKey] > c[durKey]) ? p : c)); - if (valueKey) { - res.add(arr.reduce((p, c) => (p[valueKey] > c[valueKey]) ? p : c)); - } - if (filter) { - let filterArr = arr.filter(a => filter(a)); - if (filterArr && filterArr.length > 0) { - res.add(filterArr.reduce((p, c) => (p[durKey] > c[durKey]) ? p : c)); + filter?: (a: any) => boolean +): any[] { + if (valueKey && filter) { + let arr = findRange(list, { startKey, durKey, startNS, endNS }); + arr = arr.map((it) => { + it.px = Math.floor(it[startKey] / ((endNS - startNS) / width)); + return it; + }); + let group = groupBy(arr, 'px'); + let res: Set = new Set(); + Reflect.ownKeys(group).map((key: any): void => { + let arr = group[key] as any[]; + if (arr.length > 0) { + res.add(arr.reduce((p, c) => (p[durKey] > c[durKey] ? p : c))); + if (valueKey) { + res.add(arr.reduce((p, c) => (p[valueKey] > c[valueKey] ? p : c))); + } + if (filter) { + let filterArr = arr.filter((a) => filter(a)); + if (filterArr && filterArr.length > 0) { + res.add(filterArr.reduce((p, c) => (p[durKey] > c[durKey] ? p : c))); + } } } + }); + return [...res]; + } else { + return filterDataByGroupWithoutValue(list, startKey, durKey, startNS, endNS, width); + } +} + +function filterDataByGroupWithoutValue( + list: any[], + startKey: string, + durKey: string, + startNS: number, + endNS: number, + width: number +) { + let arr: any[] = []; + // 标志位,判定何时进行新一轮数据统计处理 + let flag: number = -1; + for (let i = 0; i < list.length; i++) { + // 筛选符合判断条件的数据,作进一步处理 + if (list[i][startKey] + list[i][durKey] >= startNS && list[i][startKey] <= endNS) { + // 获取当前数据的像素值 + const px: number = Math.floor(list[i][startKey] / ((endNS - startNS) / width)); + list[i].px = px; + if (flag === px && list[i][durKey] > arr[arr.length - 1][durKey]) { + arr[arr.length - 1] = list[i]; + } + if (flag !== px) { + flag = px; + arr.push(list[i]); + } } - }); - return [...res]; + } + return arr; } export function filterDataByGroupLayer( @@ -142,17 +176,18 @@ export function filterDataByGroupLayer( endNS: number, width: number ): any[] { - let arr = findRange(list, {startKey, durKey, startNS, endNS}); + let arr = findRange(list, { startKey, durKey, startNS, endNS }); arr = arr.map((it) => { it.px = Math.floor(it[startKey] / ((endNS - startNS) / width) + it[layerKey] * width); //设置临时变量durTmp 用于参与计算,分组后有dur为-1的数据按最长宽度显示 - it.durTmp = (it[durKey] === -1 || it[durKey] === null || it[durKey] === undefined) ? (endNS - it[startKey]) : it[durKey]; + it.durTmp = + it[durKey] === -1 || it[durKey] === null || it[durKey] === undefined ? endNS - it[startKey] : it[durKey]; return it; }); let group = groupBy(arr, 'px'); let res: any[] = []; Reflect.ownKeys(group).map((key: any) => { - let childArray = (group[key] as any[]).reduce((p, c) => (p.durTmp > c.durTmp) ? p : c); + let childArray = (group[key] as any[]).reduce((p, c) => (p.durTmp > c.durTmp ? p : c)); res.push(childArray); }); return res; @@ -174,5 +209,8 @@ function findRange( endNS: number; } ): Array { - return fullData.filter(it => it[condition.startKey] + it[condition.durKey] >= condition.startNS && it[condition.startKey] <= condition.endNS); + return fullData.filter( + (it) => + it[condition.startKey] + it[condition.durKey] >= condition.startNS && it[condition.startKey] <= condition.endNS + ); } diff --git a/ide/src/trace/database/sql/Func.sql.ts b/ide/src/trace/database/sql/Func.sql.ts index 4218cd9d3..d004dd119 100644 --- a/ide/src/trace/database/sql/Func.sql.ts +++ b/ide/src/trace/database/sql/Func.sql.ts @@ -115,62 +115,46 @@ export const queryAllFuncNames = (): Promise> => { ); }; -export const queryProcessAsyncFunc = (_funName?: string): Promise> => +export const queryProcessAsyncFunc = (traceRange: { startTs: number; endTs: number }): Promise> => query( 'queryProcessAsyncFunc', - ` -select tid, - P.pid, - A.name as threadName, - is_main_thread, - c.callid as track_id, - c.ts-D.start_ts as startTs, - c.dur, - c.name as funName, - c.parent_id, - c.id, - c.cookie, - c.depth, - c.argsetid -from thread A,trace_range D -left join callstack C on A.id = C.callid -left join process P on P.id = A.ipid -where startTs not null and cookie not null ${_funName ? 'funName=$funName' : ''};`, - { - funName: _funName, - } - ); - -export const getFunDataByTid = (tid: number, ipid: number): Promise> => - query( - 'getFunDataByTid', - ` - select - c.ts-D.start_ts as startTs, - c.dur, - c.name as funName, - c.argsetid, - c.depth, - c.id as id, - A.itid as itid, - A.ipid as ipid -from thread A,trace_range D -left join callstack C on A.id = C.callid -where startTs not null and c.cookie is null and tid = $tid and A.ipid = $ipid`, - { $tid: tid, $ipid: ipid } + `select tid, + P.pid, + c.ts-${traceRange.startTs} as startTs, + c.dur, + c.id, + c.depth + from thread A + left join callstack C on A.id = C.callid + left join process P on P.id = A.ipid + where startTs not null and cookie not null;`, + {} ); export const getMaxDepthByTid = (): Promise> => query( 'getMaxDepthByTid', - ` - select -tid, -ipid, - MAX(c.depth + 1) as maxDepth -from thread A -left join callstack C on A.id = C.callid -where c.ts not null and c.cookie is null group by tid,ipid`, + `SELECT + tid, + ipid, + maxDepth + FROM + thread T + LEFT JOIN ( + SELECT + callid, + MAX( c.depth + 1 ) AS maxDepth + FROM + callstack C + WHERE + c.ts IS NOT NULL + AND c.cookie IS NULL + GROUP BY + callid + ) C ON T.id = C.callid + WHERE + maxDepth NOT NULL +`, {} ); @@ -233,13 +217,10 @@ export const queryFuncRowData = (funcName: string, tIds: number): Promise> => - query( - 'fuzzyQueryFuncRowData', - `select +export const fuzzyQueryFuncRowData = (funcName: string, tIds: number): Promise> => + query( + 'fuzzyQueryFuncRowData', + `select c.name as funName, c.ts - r.start_ts as startTime, c.ts - r.start_ts + c.dur as endTime, @@ -261,8 +242,8 @@ export const queryFuncRowData = (funcName: string, tIds: number): Promise, diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerCommon.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerCommon.ts index 3f4166258..054057632 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerCommon.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerCommon.ts @@ -18,7 +18,6 @@ import { TraceRow } from '../../component/trace/base/TraceRow'; import { TimerShaftElement } from '../../component/trace/TimerShaftElement'; import { Flag } from '../../component/trace/timer-shaft/Flag'; import { drawVSync } from '../../component/chart/VSync'; -import { draw } from '../../bean/FrameChartStruct'; export abstract class Render { abstract renderMainThread(req: any, row: TraceRow): void; @@ -50,10 +49,10 @@ export class RequestMessage { totalNS: any; slicesTime: | { - startTime: number | null; - endTime: number | null; - color: string | null; - } + startTime: number | null; + endTime: number | null; + color: string | null; + } | undefined; range: any; scale: any; @@ -66,9 +65,9 @@ export class RequestMessage { id: any; postMessage: | { - (message: any, targetOrigin: string, transfer?: Transferable[]): void; - (message: any, options?: WindowPostMessageOptions): void; - } + (message: any, targetOrigin: string, transfer?: Transferable[]): void; + (message: any, options?: WindowPostMessageOptions): void; + } | undefined; } @@ -101,8 +100,8 @@ export function ns2Timestamp(ns: number): string { return `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}:${second .toString() .padStart(2, '0')}:${millisecond.toString().padStart(3, '0')}:${microsecond - .toString() - .padStart(3, '0')}:${nanosecond.toString().padStart(3, '0')}`; + .toString() + .padStart(3, '0')}:${nanosecond.toString().padStart(3, '0')}`; } const offsetX = 5; @@ -560,10 +559,10 @@ export function drawFlagLine( frame: any, slicesTime: | { - startTime: number | null | undefined; - endTime: number | null | undefined; - color: string | null | undefined; - } + startTime: number | null | undefined; + endTime: number | null | undefined; + color: string | null | undefined; + } | undefined ) { if (commonCtx) { @@ -868,7 +867,7 @@ function changeFrameRatePoint(arrList: Array, selectParams: TraceRow, selectParams: TraceRow, selectParams: TraceRow, textWidth: number) { const TEXT_WIDTH_HALF = 2; - let textX = Math.floor(ns2x( - (arrList[0]! + arrList[arrList.length - 1]!) / 2, - TraceRow.range?.startNS ?? 0, - TraceRow.range?.endNS ?? 0, - TraceRow.range?.totalNS ?? 0, - selectParams.frame - )); //根据帧率范围的中间值转换文本的起始x坐标 + let textX = Math.floor( + ns2x( + (arrList[0]! + arrList[arrList.length - 1]!) / 2, + TraceRow.range?.startNS ?? 0, + TraceRow.range?.endNS ?? 0, + TraceRow.range?.totalNS ?? 0, + selectParams.frame + ) + ); //根据帧率范围的中间值转换文本的起始x坐标 textX = textX <= textWidth / TEXT_WIDTH_HALF ? textX : textX - textWidth / TEXT_WIDTH_HALF; let textY = selectParams.frame.y + 11; if (selectParams.avgRateTxt?.includes('HitchTime')) { @@ -951,7 +952,12 @@ export function drawAvgFrameRate(arrList: Array, ctx: any, selectParams: const TEXT_RECT_PADDING = 2; ctx.fillStyle = 'red'; - ctx.fillRect(textX - padding, textY - textHeight / TEXT_RECT_PADDING + padding, textWidth + padding * TEXT_RECT_PADDING, textHeight - padding * TEXT_RECT_PADDING); + ctx.fillRect( + textX - padding, + textY - textHeight / TEXT_RECT_PADDING + padding, + textWidth + padding * TEXT_RECT_PADDING, + textHeight - padding * TEXT_RECT_PADDING + ); ctx.fillStyle = 'white'; ctx.fillText(selectParams.avgRateTxt, textX, textY + 4); @@ -1370,8 +1376,7 @@ export function drawLoading( frame: any, left: number, right: number -) { -} +) {} let loadingText = 'Loading...'; let loadingTextWidth = 0; @@ -1409,23 +1414,36 @@ export function drawLoadingFrame( ctx.closePath(); } -export function drawString(ctx: CanvasRenderingContext2D, str: string, textPadding: number, frame: Rect, data: any) { +export function drawString( + ctx: CanvasRenderingContext2D, + str: string, + textPadding: number, + frame: Rect, + data: any, +) { if (data.textMetricsWidth === undefined) { data.textMetricsWidth = ctx.measureText(str).width; } + const yPos = 1.5; let charWidth = Math.round(data.textMetricsWidth / str.length); let fillTextWidth = frame.width - textPadding * 2; if (data.textMetricsWidth < fillTextWidth) { let x2 = Math.floor(frame.width / 2 - data.textMetricsWidth / 2 + frame.x + textPadding); - ctx.fillText(str, x2, Math.floor(frame.y + frame.height / 2), fillTextWidth); + ctx.fillText(str, x2, Math.floor(frame.y + frame.height / yPos), fillTextWidth); } else { if (fillTextWidth >= charWidth) { let chatNum = fillTextWidth / charWidth; let x1 = frame.x + textPadding; + if (chatNum < 2) { - ctx.fillText(str.substring(0, 1), x1, Math.floor(frame.y + frame.height / 2), fillTextWidth); + ctx.fillText(str.substring(0, 1), x1, Math.floor(frame.y + frame.height / yPos), fillTextWidth); } else { - ctx.fillText(str.substring(0, chatNum - 1) + '...', x1, Math.floor(frame.y + frame.height / 2), fillTextWidth); + ctx.fillText( + str.substring(0, chatNum - 1) + '...', + x1, + Math.floor(frame.y + frame.height / yPos), + fillTextWidth + ); } } } @@ -1447,7 +1465,12 @@ export function drawFunString(ctx: CanvasRenderingContext2D, str: string, textPa if (chatNum < 2) { ctx.fillText(str.substring(0, 1), x1, Math.floor(data.frame.height * (data.depth! + 0.5) + 3), fillTextWidth); } else { - ctx.fillText(str.substring(0, chatNum - 1) + '...', x1, Math.floor(data.frame.height * (data.depth! + 0.5) + 3), fillTextWidth); + ctx.fillText( + str.substring(0, chatNum - 1) + '...', + x1, + Math.floor(data.frame.height * (data.depth! + 0.5) + 3), + fillTextWidth + ); } } } -- Gitee From 94b06b0271b37ac2110d4c09ed00d7f37c09768e Mon Sep 17 00:00:00 2001 From: jichuan Date: Mon, 15 Apr 2024 20:36:42 +0800 Subject: [PATCH 05/14] =?UTF-8?q?fix:=E7=81=AB=E7=84=B0=E5=9B=BE=E5=86=85?= =?UTF-8?q?=E5=AD=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- ...ickstart_smartperflinux_compile_guide.html | 2 +- ide/src/trace/bean/FrameChartStruct.ts | 7 +++++ ide/src/trace/bean/NativeHook.ts | 3 -- ide/src/trace/component/chart/FrameChart.ts | 13 +++++++++ .../sheet/file-system/TabPaneCallTree.html.ts | 4 +-- .../sheet/file-system/TabPaneCallTree.ts | 10 +++---- .../TabPaneFileSystemCalltree.html.ts | 4 +-- .../file-system/TabPaneFileSystemCalltree.ts | 10 +++---- .../native-memory/TabPaneNMCallTree.html.ts | 4 +-- .../sheet/native-memory/TabPaneNMCallTree.ts | 10 +++---- .../native-memory/TabPaneNMSampleList.ts | 2 +- .../sheet/native-memory/TabPaneNMemory.ts | 2 +- .../ProcedureLogicWorkerCommon.ts | 22 ++++++--------- .../ProcedureLogicWorkerFileSystem.ts | 17 ++++++----- .../ProcedureLogicWorkerNativeNemory.ts | 28 ++++++++----------- 15 files changed, 73 insertions(+), 65 deletions(-) diff --git a/ide/src/doc/quickstart_smartperflinux_compile_guide.html b/ide/src/doc/quickstart_smartperflinux_compile_guide.html index e905a41bf..1d45dff5d 100644 --- a/ide/src/doc/quickstart_smartperflinux_compile_guide.html +++ b/ide/src/doc/quickstart_smartperflinux_compile_guide.html @@ -878,7 +878,7 @@