From 812dbaa1e680ee71890ffeb7413ca6770ca3c94a Mon Sep 17 00:00:00 2001 From: zhangxiao72 Date: Wed, 20 Apr 2022 17:40:17 +0800 Subject: [PATCH 01/29] =?UTF-8?q?ace=5Fengine=E3=80=81napi=20=E9=83=A8?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E4=BB=93=E5=90=8D=E5=92=8C=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=90=8D=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibd366c5c14f96d263f15641b8b86c4ed079eb56d Signed-off-by: zhangxiao72 --- interfaces/kits/js/napi/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/js/napi/BUILD.gn b/interfaces/kits/js/napi/BUILD.gn index 3ebdcdc..82c2eb4 100644 --- a/interfaces/kits/js/napi/BUILD.gn +++ b/interfaces/kits/js/napi/BUILD.gn @@ -21,7 +21,7 @@ ohos_shared_library("bytrace") { ] deps = [ "${innerkits_path}/native:bytrace_core", - "//foundation/ace/napi:ace_napi", + "//foundation/arkui/napi:ace_napi", ] external_deps = [ "hiviewdfx_hilog_native:libhilog" ] @@ -38,7 +38,7 @@ ohos_shared_library("hitracemeter_napi") { ] deps = [ "${innerkits_path}/native:bytrace_core", - "//foundation/ace/napi:ace_napi", + "//foundation/arkui/napi:ace_napi", ] external_deps = [ "hiviewdfx_hilog_native:libhilog" ] From bc1a1c288d00b86f82c9a5d6eaa2b898281b0ed2 Mon Sep 17 00:00:00 2001 From: anderskov Date: Tue, 26 Apr 2022 20:22:47 +0800 Subject: [PATCH 02/29] fix trace async mode Signed-off-by: anderskov --- bin/src/bytrace_cmd.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 6d9784e..1ce870e 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -80,7 +80,10 @@ bool g_compress = false; string g_traceRootPath; -bool g_traceStart = true; +const unsigned int START_NONE = 0; +const unsigned int START_NORMAL = 1; +const unsigned int START_ASYNC = 2; +unsigned int g_traceStart = START_NORMAL; bool g_traceStop = true; bool g_traceDump = true; @@ -436,15 +439,15 @@ static void ParseLongOpt(const string& cmd, int optionIndex, bool& isTrue) } else if (!strcmp(g_longOptions[optionIndex].name, "overwrite")) { g_overwrite = false; } else if (!strcmp(g_longOptions[optionIndex].name, "trace_begin")) { - g_traceStart = true; + g_traceStart = START_ASYNC; g_traceStop = false; g_traceDump = false; } else if (!strcmp(g_longOptions[optionIndex].name, "trace_finish")) { - g_traceStart = false; + g_traceStart = START_NONE; g_traceStop = true; g_traceDump = true; } else if (!strcmp(g_longOptions[optionIndex].name, "trace_dump")) { - g_traceStart = false; + g_traceStart = START_NONE; g_traceStop = false; g_traceDump = true; } @@ -561,11 +564,15 @@ static bool StartTrace() ClearTrace(); printf("capturing trace...\n"); fflush(stdout); + return true; +} + +static void WaitForTraceDone(void) +{ struct timespec ts = {0, 0}; ts.tv_sec = g_traceDuration; ts.tv_nsec = 0; while ((nanosleep(&ts, &ts) == -1) && (errno == EINTR)) {} - return true; } static bool StopTrace() @@ -895,9 +902,13 @@ int main(int argc, char **argv) } bool isTrue = true; - if (g_traceStart) { + if (g_traceStart != START_NONE) { SetViewStyle(); isTrue = isTrue && StartTrace(); + if (g_traceStart == START_ASYNC) { + return isTrue ? 0 : -1; + } + WaitForTraceDone(); } isTrue = isTrue && MarkOthersClockSync(); From af675ea7a3626815663c41dddaf21e31d09b994a Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Thu, 28 Apr 2022 10:03:01 +0800 Subject: [PATCH 03/29] update bytrace warehouse name Signed-off-by: wenlong12 Signed-off-by: wenlong12 --- README.md | 2 +- README_zh.md | 2 +- bin/BUILD.gn | 45 +--- bin/example/bytrace_example.cpp | 2 +- bin/src/bytrace_cmd.cpp | 2 +- bin/src/bytrace_impl.cpp | 239 ------------------ bin/src/bytrace_osal.cpp | 2 +- bin/test/BUILD.gn | 8 +- .../common/native/bytrace_ndk_test.cpp | 2 +- bundle.json | 25 +- bytrace.gni | 2 +- interfaces/innerkits/BUILD.gn | 18 -- interfaces/innerkits/native/BUILD.gn | 27 -- interfaces/innerkits/native/include/bytrace.h | 128 ---------- interfaces/kits/BUILD.gn | 4 +- interfaces/kits/js/napi/BUILD.gn | 22 +- .../kits/js/napi/bytrace_napi_common.cpp | 2 +- 17 files changed, 46 insertions(+), 486 deletions(-) delete mode 100644 bin/src/bytrace_impl.cpp delete mode 100644 interfaces/innerkits/BUILD.gn delete mode 100644 interfaces/innerkits/native/BUILD.gn delete mode 100644 interfaces/innerkits/native/include/bytrace.h diff --git a/README.md b/README.md index 03b4588..cf7ef53 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ ByTrace is a tool for you to trace processes and monitor performance. It encapsu ## Directory Structure ``` -/developtools/bytrace_standard +/developtools/bytrace ├── bin # ByTrace code │ └── include # Header files │ └── src # Source files diff --git a/README_zh.md b/README_zh.md index f90da15..bc9d2c0 100644 --- a/README_zh.md +++ b/README_zh.md @@ -20,7 +20,7 @@ bytrace是开发人员用于追踪进程轨迹、查看性能的一种工具, ## 目录 ``` -/developtools/bytrace_standard +/developtools/bytrace ├── bin # bytrace组件代码目录 │ └── include # 头文件目录 │ └── src # 源文件目录 diff --git a/bin/BUILD.gn b/bin/BUILD.gn index f43dfb4..52e9cd3 100644 --- a/bin/BUILD.gn +++ b/bin/BUILD.gn @@ -12,34 +12,13 @@ # limitations under the License. import("//build/ohos.gni") -import("//developtools/bytrace_standard/bytrace.gni") - -config("bytrace_lib_inner_config") { - visibility = [ ":*" ] - include_dirs = [ "${innerkits_path}/native/include" ] -} - -ohos_static_library("bytrace_inner") { - sources = [ "./src/bytrace_impl.cpp" ] - public_configs = [ ":bytrace_lib_inner_config" ] - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "startup_l2:syspara", - "startup_l2:syspara_watchagent", - - #"distributedschedule:samgr_standard" - ] - - subsystem_name = "developtools" - part_name = "bytrace_standard" -} +import("//developtools/bytrace/bytrace.gni") config("bytrace_osal_inner_config") { visibility = [ ":*" ] include_dirs = [ "./include", - "${innerkits_path}/native/include", + "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter", ] } @@ -52,7 +31,7 @@ ohos_static_library("bytrace_osal_inner") { ] subsystem_name = "developtools" - part_name = "bytrace_standard" + part_name = "bytrace" } ohos_executable("bytrace") { @@ -61,33 +40,37 @@ ohos_executable("bytrace") { deps = [ ":bytrace_osal_inner", - "${innerkits_path}/native:bytrace_core", "//third_party/zlib:libz", "//utils/native/base:utils", ] + + external_deps = [ "hitrace_native:hitrace_meter" ] + include_dirs = [ "${bytrace_path}/bin/include", - "${innerkits_path}/include", + "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter", "//utils/native/base/include", "//third_party/zlib", ] subsystem_name = "developtools" - part_name = "bytrace_standard" + part_name = "bytrace" } ohos_prebuilt_etc("bytrace.cfg") { source = "./config/bytrace.cfg" relative_install_dir = "init" subsystem_name = "developtools" - part_name = "bytrace_standard" + part_name = "bytrace" } ohos_executable("bytrace_example") { sources = [ "example/bytrace_example.cpp" ] - deps = [ "${innerkits_path}/native:bytrace_core" ] - external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + external_deps = [ + "hitrace_native:hitrace_meter", + "hiviewdfx_hilog_native:libhilog", + ] subsystem_name = "developtools" - part_name = "bytrace_standard" + part_name = "bytrace" } group("bytrace_target") { diff --git a/bin/example/bytrace_example.cpp b/bin/example/bytrace_example.cpp index db75767..77e55b7 100644 --- a/bin/example/bytrace_example.cpp +++ b/bin/example/bytrace_example.cpp @@ -18,7 +18,7 @@ #include #include -#include "bytrace.h" +#include "hitrace_meter.h" using namespace std; namespace { diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 6d9784e..d981a89 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -30,7 +30,7 @@ #include #include #include -#include "bytrace.h" +#include "hitrace_meter.h" #include "bytrace_osal.h" #include "securec.h" diff --git a/bin/src/bytrace_impl.cpp b/bin/src/bytrace_impl.cpp deleted file mode 100644 index 2f68d0d..0000000 --- a/bin/src/bytrace_impl.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (C) 2021 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "bytrace.h" -#include "hilog/log.h" -#include "parameter.h" -#include "parameters.h" - -using namespace std; -using namespace OHOS::HiviewDFX; - -#define EXPECTANTLY(exp) (__builtin_expect(!!(exp), true)) -#define UNEXPECTANTLY(exp) (__builtin_expect(!!(exp), false)) - -namespace { -int g_markerFd = -1; -std::once_flag g_onceFlag; - -std::atomic g_isBytraceInit(false); -std::atomic g_tagsProperty(BYTRACE_TAG_NOT_READY); - -const std::string KEY_TRACE_TAG = "debug.bytrace.tags.enableflags"; -const std::string KEY_APP_NUMBER = "debug.bytrace.app_number"; -const std::string KEY_RO_DEBUGGABLE = "ro.debuggable"; - -constexpr int NAME_MAX_SIZE = 1000; -static std::vector g_markTypes = {"B", "E", "S", "F", "C"}; -enum MarkerType { MARKER_BEGIN, MARKER_END, MARKER_ASYNC_BEGIN, MARKER_ASYNC_END, MARKER_INT, MARKER_MAX }; - -constexpr uint64_t BYTRACE_TAG = 0xd03301; -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, BYTRACE_TAG, "BytraceCore"}; - -static void ParameterChange(const char* key, const char* value, void* context) -{ - HiLog::Info(LABEL, "Trace param %{public}s change notified", key); - UpdateTraceLabel(); -} - -bool IsAppValid() -{ - // Judge if application-level tracing is enabled. - if (OHOS::system::GetBoolParameter(KEY_RO_DEBUGGABLE, 0)) { - std::ifstream fs; - fs.open("/proc/self/cmdline"); - if (!fs.is_open()) { - fprintf(stderr, "IsAppValid, open /proc/self/cmdline failed.\n"); - return false; - } - - std::string lineStr; - std::getline(fs, lineStr); - std::string keyPrefix = "debug.bytrace.app_"; - int nums = OHOS::system::GetIntParameter(KEY_APP_NUMBER, 0); - for (int i = 0; i < nums; i++) { - std::string keyStr = keyPrefix + std::to_string(i); - std::string val = OHOS::system::GetParameter(keyStr, ""); - if (val == "*" || val == lineStr) { - fs.close(); - return true; - } - } - } - return false; -} - -uint64_t GetSysParamTags() -{ - // Get the system parameters of KEY_TRACE_TAG. - uint64_t tags = OHOS::system::GetUintParameter(KEY_TRACE_TAG, 0); - if (tags == 0) { - return 0; - } - - IsAppValid(); - return (tags | BYTRACE_TAG_ALWAYS) & BYTRACE_TAG_VALID_MASK; -} - -// open file "trace_marker". -void OpenTraceMarkerFile() -{ - const std::string debugFile = "/sys/kernel/debug/tracing/trace_marker"; - const std::string traceFile = "/sys/kernel/tracing/trace_marker"; - g_markerFd = open(debugFile.c_str(), O_WRONLY | O_CLOEXEC); - if (g_markerFd == -1) { - g_markerFd = open(traceFile.c_str(), O_WRONLY | O_CLOEXEC); - if (g_markerFd == -1) { - HiLog::Error(LABEL, "open trace file %{public}s failed: %{public}d", traceFile.c_str(), errno); - g_tagsProperty = 0; - return; - } - } - g_tagsProperty = GetSysParamTags(); - if (g_tagsProperty == 0 || (g_tagsProperty & BYTRACE_TAG_VALID_MASK) == BYTRACE_TAG_ALWAYS) { - HiLog::Info(LABEL, "Get trace param value zero firstly"); - } - - if (WatchParameter(KEY_TRACE_TAG.c_str(), ParameterChange, nullptr) != 0) { - HiLog::Error(LABEL, "WatchParameter %{public}s failed", KEY_TRACE_TAG.c_str()); - return; - } - g_isBytraceInit = true; -} -}; // namespace - -void AddBytraceMarker(MarkerType type, uint64_t tag, const std::string& name, const std::string& value) -{ - if (UNEXPECTANTLY(!g_isBytraceInit)) { - std::call_once(g_onceFlag, OpenTraceMarkerFile); - } - if (UNEXPECTANTLY(g_tagsProperty & tag)) { - // record fomart: "type|pid|name value". - std::string record = g_markTypes[type] + "|"; - record += std::to_string(getpid()) + "|"; - record += (name.size() < NAME_MAX_SIZE) ? name : name.substr(0, NAME_MAX_SIZE); - record += " " + value; - if (write(g_markerFd, record.c_str(), record.size()) < 0) { - HiLog::Error(LABEL, "write trace_marker failed, %{public}d", errno); - } - } -} - -void UpdateTraceLabel() -{ - if (!g_isBytraceInit) { - HiLog::Info(LABEL, "trace param notified value delay to acquire"); - return; - } - g_tagsProperty = GetSysParamTags(); - uint64_t val = g_tagsProperty; - if (val == 0 || (val & BYTRACE_TAG_VALID_MASK) == BYTRACE_TAG_ALWAYS) { - HiLog::Info(LABEL, "Get trace param notified value zero"); - } else { - HiLog::Info(LABEL, "Get trace param notified value 0x%{public}" PRIx64, val); - } -} - -void StartTrace(uint64_t label, const string& value, float limit) -{ - string traceName = "H:" + value; - AddBytraceMarker(MARKER_BEGIN, label, traceName, ""); -} - -void StartTraceDebug(uint64_t label, const string& value, float limit) -{ -#if (TRACE_LEVEL >= DEBUG_LEVEL) - string traceName = "H:" + value + GetHiTraceInfo(); - AddBytraceMarker(MARKER_BEGIN, label, traceName, ""); -#endif -} - -void FinishTrace(uint64_t label) -{ - AddBytraceMarker(MARKER_END, label, "", ""); -} - -void FinishTraceDebug(uint64_t label) -{ -#if (TRACE_LEVEL >= DEBUG_LEVEL) - AddBytraceMarker(MARKER_END, label, "", ""); -#endif -} - -void StartAsyncTrace(uint64_t label, const string& value, int32_t taskId, float limit) -{ - string traceName = "H:" + value; - AddBytraceMarker(MARKER_ASYNC_BEGIN, label, traceName, std::to_string(taskId)); -} - -void StartAsyncTraceDebug(uint64_t label, const string& value, int32_t taskId, float limit) -{ -#if (TRACE_LEVEL >= DEBUG_LEVEL) - string traceName = "H:" + value; - AddBytraceMarker(MARKER_ASYNC_BEGIN, label, traceName, std::to_string(taskId)); -#endif -} - -void FinishAsyncTrace(uint64_t label, const string& value, int32_t taskId) -{ - string traceName = "H:" + value; - AddBytraceMarker(MARKER_ASYNC_END, label, traceName, std::to_string(taskId)); -} - -void FinishAsyncTraceDebug(uint64_t label, const string& value, int32_t taskId) -{ -#if (TRACE_LEVEL >= DEBUG_LEVEL) - string traceName = "H:" + value; - AddBytraceMarker(MARKER_ASYNC_END, label, traceName, std::to_string(taskId)); -#endif -} - -void MiddleTrace(uint64_t label, const string& beforeValue, const std::string& afterValue) -{ - string traceName = "H:" + afterValue; - AddBytraceMarker(MARKER_END, label, "", ""); - AddBytraceMarker(MARKER_BEGIN, label, traceName, ""); -} - -void MiddleTraceDebug(uint64_t label, const string& beforeValue, const std::string& afterValue) -{ -#if (TRACE_LEVEL >= DEBUG_LEVEL) - string traceName = "H:" + afterValue + GetTraceInfo(); - AddBytraceMarker(MARKER_END, label, "", ""); - AddBytraceMarker(MARKER_BEGIN, label, traceName, ""); -#endif -} - -void CountTrace(uint64_t label, const string& name, int64_t count) -{ - string traceName = "H:" + name; - AddBytraceMarker(MARKER_INT, label, traceName, std::to_string(count)); -} - -void CountTraceDebug(uint64_t label, const string& name, int64_t count) -{ -#if (TRACE_LEVEL >= DEBUG_LEVEL) - string traceName = "H:" + name; - AddBytraceMarker(MARKER_INT, label, traceName, std::to_string(count)); -#endif -} diff --git a/bin/src/bytrace_osal.cpp b/bin/src/bytrace_osal.cpp index 1789f07..06b2050 100644 --- a/bin/src/bytrace_osal.cpp +++ b/bin/src/bytrace_osal.cpp @@ -14,7 +14,7 @@ */ #include "bytrace_osal.h" -#include "bytrace.h" +#include "hitrace_meter.h" #include "parameters.h" namespace OHOS { diff --git a/bin/test/BUILD.gn b/bin/test/BUILD.gn index 7ceae89..e2e45cd 100644 --- a/bin/test/BUILD.gn +++ b/bin/test/BUILD.gn @@ -9,12 +9,12 @@ # 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. +# limitations under the License. import("//build/test.gni") -import("//developtools/bytrace_standard/bytrace.gni") +import("//developtools/bytrace/bytrace.gni") -module_output_path = "bytrace_standard/bytrace" +module_output_path = "bytrace/bytrace" config("module_private_config") { visibility = [ ":*" ] @@ -25,10 +25,10 @@ ohos_unittest("BytraceNDKTest") { sources = [ "unittest/common/native/bytrace_ndk_test.cpp" ] deps = [ "${bytrace_path}/bin:bytrace_osal_inner", - "${innerkits_path}/native:bytrace_core", "//third_party/googletest:gtest_main", ] external_deps = [ + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "startup_l2:syspara", ] diff --git a/bin/test/unittest/common/native/bytrace_ndk_test.cpp b/bin/test/unittest/common/native/bytrace_ndk_test.cpp index 6e5c519..0e53fd3 100644 --- a/bin/test/unittest/common/native/bytrace_ndk_test.cpp +++ b/bin/test/unittest/common/native/bytrace_ndk_test.cpp @@ -19,7 +19,7 @@ #include #include #include -#include "bytrace.h" +#include "hitrace_meter.h" #include "bytrace_osal.h" #include "parameters.h" diff --git a/bundle.json b/bundle.json index 8f81d8a..a78ba13 100644 --- a/bundle.json +++ b/bundle.json @@ -1,16 +1,16 @@ { - "name": "@ohos/bytrace_standard", + "name": "@ohos/bytrace", "description": "A tool to trace processes and monitor performance", "version": "3.1", "license": "Apache License 2.0", "publishAs": "code-segment", "segment": { - "destPath": "developtools/bytrace_standard" + "destPath": "developtools/bytrace" }, "dirs": {}, "scripts": {}, "component": { - "name": "bytrace_standard", + "name": "bytrace", "subsystem": "developtools", "adapted_system_type": [ "standard" @@ -31,25 +31,14 @@ }, "build": { "sub_component": [ - "//developtools/bytrace_standard/interfaces/innerkits/native:bytrace_core", - "//developtools/bytrace_standard/bin:bytrace_target", - "//developtools/bytrace_standard/bin:bytrace.cfg", - "//developtools/bytrace_standard/interfaces/kits:jsapi_kits_target" + "//developtools/bytrace/bin:bytrace_target", + "//developtools/bytrace/bin:bytrace.cfg", + "//developtools/bytrace/interfaces/kits:jsapi_kits_target" ], "inner_kits": [ - { - "type": "so", - "name": "//developtools/bytrace_standard/interfaces/innerkits/native:bytrace_core", - "header": { - "header_files": [ - "bytrace.h" - ], - "header_base": "//developtools/bytrace_standard/interfaces/innerkits/native/include" - } - } ], "test": [ - "//developtools/bytrace_standard/bin/test:unittest" + "//developtools/bytrace/bin/test:unittest" ] } } diff --git a/bytrace.gni b/bytrace.gni index c91cf8b..ac56d81 100644 --- a/bytrace.gni +++ b/bytrace.gni @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -bytrace_path = "//developtools/bytrace_standard" +bytrace_path = "//developtools/bytrace" innerkits_path = "${bytrace_path}/interfaces/innerkits" diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn deleted file mode 100644 index 53974fe..0000000 --- a/interfaces/innerkits/BUILD.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2021-2022 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. - -import("//build/ohos.gni") - -group("innerkits_target") { - deps = [ "native:bytrace_core" ] -} diff --git a/interfaces/innerkits/native/BUILD.gn b/interfaces/innerkits/native/BUILD.gn deleted file mode 100644 index 943b31e..0000000 --- a/interfaces/innerkits/native/BUILD.gn +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2021-2022 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. - -import("//build/ohos.gni") -import("//developtools/bytrace_standard/bytrace.gni") - -config("bytrace_config") { - visibility = [ ":*" ] - include_dirs = [ "include" ] -} - -ohos_shared_library("bytrace_core") { - public_configs = [ ":bytrace_config" ] - deps = [ "${bytrace_path}/bin:bytrace_inner" ] - subsystem_name = "developtools" - part_name = "bytrace_standard" -} diff --git a/interfaces/innerkits/native/include/bytrace.h b/interfaces/innerkits/native/include/bytrace.h deleted file mode 100644 index 24a028d..0000000 --- a/interfaces/innerkits/native/include/bytrace.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2021-2022 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 INTERFACES_INNERKITS_NATIVE_INCLUDE_BYTRACE_H -#define INTERFACES_INNERKITS_NATIVE_INCLUDE_BYTRACE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -constexpr uint64_t BYTRACE_TAG_NEVER = 0; // This tag is never enabled. -constexpr uint64_t BYTRACE_TAG_ALWAYS = (1ULL << 0); // This tag is always enabled. -constexpr uint64_t BYTRACE_TAG_OHOS = (1ULL << 30); // OHOS generic tag. -constexpr uint64_t BYTRACE_TAG_ABILITY_MANAGER = (1ULL << 31); // Ability Manager tag. -constexpr uint64_t BYTRACE_TAG_ZCAMERA = (1ULL << 32); // Camera module tag. -constexpr uint64_t BYTRACE_TAG_ZMEDIA = (1ULL << 33); // Media module tag. -constexpr uint64_t BYTRACE_TAG_ZIMAGE = (1ULL << 34); // Image module tag. -constexpr uint64_t BYTRACE_TAG_ZAUDIO = (1ULL << 35); // Audio module tag. -constexpr uint64_t BYTRACE_TAG_DISTRIBUTEDDATA = (1ULL << 36); // Distributeddata manager module tag. -constexpr uint64_t BYTRACE_TAG_MDFS = (1ULL << 37); // Mobile distributed file system tag. -constexpr uint64_t BYTRACE_TAG_GRAPHIC_AGP = (1ULL << 38); // Graphic module tag. -constexpr uint64_t BYTRACE_TAG_ACE = (1ULL << 39); // ACE development framework tag. -constexpr uint64_t BYTRACE_TAG_NOTIFICATION = (1ULL << 40); // Notification module tag. -constexpr uint64_t BYTRACE_TAG_MISC = (1ULL << 41); // Notification module tag. -constexpr uint64_t BYTRACE_TAG_MULTIMODALINPUT = (1ULL << 42); // Multi modal module tag. -constexpr uint64_t BYTRACE_TAG_SENSORS = (1ULL << 43); // Sensors mudule tag. -constexpr uint64_t BYTRACE_TAG_MSDP = (1ULL << 44); // Multimodal Sensor Data Platform module tag. -constexpr uint64_t BYTRACE_TAG_DSOFTBUS = (1ULL << 45); // Distributed Softbus tag. -constexpr uint64_t BYTRACE_TAG_RPC = (1ULL << 46); // RPC and IPC tag. -constexpr uint64_t BYTRACE_TAG_ARK = (1ULL << 47); // ARK tag. -constexpr uint64_t BYTRACE_TAG_WINDOW_MANAGER = (1ULL << 48); // window manager tag. -constexpr uint64_t BYTRACE_TAG_APP = (1ULL << 62); // App tag. - -constexpr uint64_t BYTRACE_TAG_LAST = BYTRACE_TAG_APP; -constexpr uint64_t BYTRACE_TAG_NOT_READY = (1ULL << 63); // Reserved for initialization. -constexpr uint64_t BYTRACE_TAG_VALID_MASK = ((BYTRACE_TAG_LAST - 1) | BYTRACE_TAG_LAST); - -#ifndef BYTRACE_TAG -#define BYTRACE_TAG BYTRACE_TAG_NEVER -#elif BYTRACE_TAG > BYTRACE_TAG_VALID_MASK -#error BYTRACE_TAG must be defined to be one of the tags defined in bytrace.h -#elif BYTRACE_TAG < BYTRACE_TAG_OHOS -#error BYTRACE_TAG must be defined to be one of the tags defined in bytrace.h -#endif - -#define RELEASE_LEVEL 0X01 -#define DEBUG_LEVEL 0X02 - -#ifndef TRACE_LEVEL -#define TRACE_LEVEL RELEASE -#endif - -#define TOKENPASTE(x, y) x ## y -#define TOKENPASTE2(x, y) TOKENPASTE(x, y) -#define BYTRACE_NAME(TAG, fmt, ...) ByTraceScoped TOKENPASTE2(tracer, __LINE__)(TAG, fmt, ##__VA_ARGS__) -#define BYTRACE(TAG) BYTRACE_NAME(TAG, __func__) - -/** - * Update trace label when your process has started. - */ -void UpdateTraceLabel(); - -/** - * Track the beginning of a context. - */ -void StartTrace(uint64_t label, const std::string& value, float limit = -1); -void StartTraceDebug(uint64_t label, const std::string& value, float limit = -1); -/** - * Track the end of a context. - */ -void FinishTrace(uint64_t label); -void FinishTraceDebug(uint64_t label); -/** - * Track the beginning of an asynchronous event. - */ -void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); -void StartAsyncTraceDebug(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); - -/** - * Track the end of an asynchronous event. - */ -void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); -void FinishAsyncTraceDebug(uint64_t label, const std::string& value, int32_t taskId); - -/** - * Track the middle of a context. Match the previous function of StartTrace before it. - */ -void MiddleTrace(uint64_t label, const std::string& beforeValue, const std::string& afterValue); -void MiddleTraceDebug(uint64_t label, const std::string& beforeValue, const std::string& afterValue); - -/** - * Track the 64-bit integer counter value. - */ -void CountTrace(uint64_t label, const std::string& name, int64_t count); -void CountTraceDebug(uint64_t label, const std::string& name, int64_t count); - -class ByTraceScoped { -public: - inline ByTraceScoped(uint64_t tag, const std::string &value) : mTag(tag) - { - StartTrace(mTag, value); - } - - inline ~ByTraceScoped() - { - FinishTrace(mTag); - } -private: - uint64_t mTag; -}; -#ifdef __cplusplus -} -#endif -#endif // INTERFACES_INNERKITS_NATIVE_INCLUDE_BYTRACE_H diff --git a/interfaces/kits/BUILD.gn b/interfaces/kits/BUILD.gn index 05d1b57..4200e0f 100644 --- a/interfaces/kits/BUILD.gn +++ b/interfaces/kits/BUILD.gn @@ -16,8 +16,8 @@ import("//build/ohos.gni") group("jsapi_kits_target") { if (support_jsapi) { deps = [ - "//developtools/bytrace_standard/interfaces/kits/js/napi:bytrace", - "//developtools/bytrace_standard/interfaces/kits/js/napi:hitracemeter_napi", + "//developtools/bytrace/interfaces/kits/js/napi:bytrace", + "//developtools/bytrace/interfaces/kits/js/napi:hitracemeter_napi", ] } } diff --git a/interfaces/kits/js/napi/BUILD.gn b/interfaces/kits/js/napi/BUILD.gn index 82c2eb4..2ae7512 100644 --- a/interfaces/kits/js/napi/BUILD.gn +++ b/interfaces/kits/js/napi/BUILD.gn @@ -12,23 +12,23 @@ # limitations under the License. import("//build/ohos.gni") -import("//developtools/bytrace_standard/bytrace.gni") +import("//developtools/bytrace/bytrace.gni") ohos_shared_library("bytrace") { sources = [ "bytrace.cpp", "bytrace_napi_common.cpp", ] - deps = [ - "${innerkits_path}/native:bytrace_core", - "//foundation/arkui/napi:ace_napi", + deps = [ "//foundation/arkui/napi:ace_napi" ] + external_deps = [ + "hitrace_native:hitrace_meter", + "hiviewdfx_hilog_native:libhilog", ] - external_deps = [ "hiviewdfx_hilog_native:libhilog" ] relative_install_dir = "module" subsystem_name = "developtools" - part_name = "bytrace_standard" + part_name = "bytrace" } ohos_shared_library("hitracemeter_napi") { @@ -36,14 +36,14 @@ ohos_shared_library("hitracemeter_napi") { "bytrace_napi_common.cpp", "hitracemeter.cpp", ] - deps = [ - "${innerkits_path}/native:bytrace_core", - "//foundation/arkui/napi:ace_napi", + deps = [ "//foundation/arkui/napi:ace_napi" ] + external_deps = [ + "hitrace_native:hitrace_meter", + "hiviewdfx_hilog_native:libhilog", ] - external_deps = [ "hiviewdfx_hilog_native:libhilog" ] relative_install_dir = "module" subsystem_name = "developtools" - part_name = "bytrace_standard" + part_name = "bytrace" } diff --git a/interfaces/kits/js/napi/bytrace_napi_common.cpp b/interfaces/kits/js/napi/bytrace_napi_common.cpp index 8434e6c..ae24dcc 100644 --- a/interfaces/kits/js/napi/bytrace_napi_common.cpp +++ b/interfaces/kits/js/napi/bytrace_napi_common.cpp @@ -19,7 +19,7 @@ #include #include "napi/native_api.h" #include "napi/native_node_api.h" -#include "bytrace.h" +#include "hitrace_meter.h" #include "bytrace_napi_common.h" using namespace OHOS::HiviewDFX; From cfafae0943a20e8f4007643aee499c0de6bafabf Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Wed, 11 May 2022 15:47:24 +0800 Subject: [PATCH 04/29] replace bytrace key to hitrace_meter Signed-off-by: wenlong12 Signed-off-by: wenlong12 --- bin/example/bytrace_example.cpp | 4 +- bin/src/bytrace_cmd.cpp | 40 +++++++++---------- .../common/native/bytrace_ndk_test.cpp | 6 +-- .../kits/js/napi/bytrace_napi_common.cpp | 8 ++-- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/bin/example/bytrace_example.cpp b/bin/example/bytrace_example.cpp index 77e55b7..ba8d0b4 100644 --- a/bin/example/bytrace_example.cpp +++ b/bin/example/bytrace_example.cpp @@ -26,7 +26,7 @@ constexpr int SLEEP_ONE_SECOND = 1; constexpr int SLEEP_TWO_SECOND = 2; constexpr int CYCLE_TIMES = 5; constexpr int32_t TASK_ID = 111; -constexpr uint64_t LABEL = BYTRACE_TAG_OHOS; +constexpr uint64_t LABEL = HITRACE_TAG_OHOS; void FuncA() { @@ -45,7 +45,7 @@ void FuncC() cout << "funcC" << endl; int num = 0; for (int i = 0; i < CYCLE_TIMES; i++) { - CountTrace(BYTRACE_TAG_OHOS, "count number", ++num); + CountTrace(HITRACE_TAG_OHOS, "count number", ++num); sleep(SLEEP_ONE_SECOND); } } diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 381efb5..2288b88 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -840,28 +840,28 @@ static void InitKernelSupportTags() static void InitAllSupportTags() { // OHOS - g_tagMap["ohos"] = { "ohos", "OpenHarmony", BYTRACE_TAG_OHOS, USER, {}}; - g_tagMap["ability"] = { "ability", "Ability Manager", BYTRACE_TAG_ABILITY_MANAGER, USER, {}}; - g_tagMap["zcamera"] = { "zcamera", "OpenHarmony Camera Module", BYTRACE_TAG_ZCAMERA, USER, {}}; - g_tagMap["zmedia"] = { "zmedia", "OpenHarmony Media Module", BYTRACE_TAG_ZMEDIA, USER, {}}; - g_tagMap["zimage"] = { "zimage", "OpenHarmony Image Module", BYTRACE_TAG_ZIMAGE, USER, {}}; - g_tagMap["zaudio"] = { "zaudio", "OpenHarmony Audio Module", BYTRACE_TAG_ZAUDIO, USER, {}}; + g_tagMap["ohos"] = { "ohos", "OpenHarmony", HITRACE_TAG_OHOS, USER, {}}; + g_tagMap["ability"] = { "ability", "Ability Manager", HITRACE_TAG_ABILITY_MANAGER, USER, {}}; + g_tagMap["zcamera"] = { "zcamera", "OpenHarmony Camera Module", HITRACE_TAG_ZCAMERA, USER, {}}; + g_tagMap["zmedia"] = { "zmedia", "OpenHarmony Media Module", HITRACE_TAG_ZMEDIA, USER, {}}; + g_tagMap["zimage"] = { "zimage", "OpenHarmony Image Module", HITRACE_TAG_ZIMAGE, USER, {}}; + g_tagMap["zaudio"] = { "zaudio", "OpenHarmony Audio Module", HITRACE_TAG_ZAUDIO, USER, {}}; g_tagMap["distributeddatamgr"] = { "distributeddatamgr", "Distributed Data Manager", - BYTRACE_TAG_DISTRIBUTEDDATA, USER, {}}; - g_tagMap["mdfs"] = { "mdfs", "Mobile Distributed File System", BYTRACE_TAG_MDFS, USER, {}}; - g_tagMap["graphic"] = { "graphic", "Graphic Module", BYTRACE_TAG_GRAPHIC_AGP, USER, {}}; - g_tagMap["ace"] = { "ace", "ACE development framework", BYTRACE_TAG_ACE, USER, {}}; - g_tagMap["notification"] = { "notification", "Notification Module", BYTRACE_TAG_NOTIFICATION, USER, {}}; - g_tagMap["misc"] = { "misc", "Misc Module", BYTRACE_TAG_MISC, USER, {}}; + HITRACE_TAG_DISTRIBUTEDDATA, USER, {}}; + g_tagMap["mdfs"] = { "mdfs", "Mobile Distributed File System", HITRACE_TAG_MDFS, USER, {}}; + g_tagMap["graphic"] = { "graphic", "Graphic Module", HITRACE_TAG_GRAPHIC_AGP, USER, {}}; + g_tagMap["ace"] = { "ace", "ACE development framework", HITRACE_TAG_ACE, USER, {}}; + g_tagMap["notification"] = { "notification", "Notification Module", HITRACE_TAG_NOTIFICATION, USER, {}}; + g_tagMap["misc"] = { "misc", "Misc Module", HITRACE_TAG_MISC, USER, {}}; g_tagMap["multimodalinput"] = { "multimodalinput", "Multimodal Input Module", - BYTRACE_TAG_MULTIMODALINPUT, USER, {}}; - g_tagMap["sensors"] = { "sensors", "Sensors Module", BYTRACE_TAG_SENSORS, USER, {}}; - g_tagMap["msdp"] = { "msdp", "Multimodal Sensor Data Platform", BYTRACE_TAG_MSDP, USER, {}}; - g_tagMap["dsoftbus"] = { "dsoftbus", "Distributed Softbus", BYTRACE_TAG_DSOFTBUS, USER, {}}; - g_tagMap["rpc"] = { "rpc", "RPC and IPC", BYTRACE_TAG_RPC, USER, {}}; - g_tagMap["ark"] = { "ark", "ARK Module", BYTRACE_TAG_ARK, USER, {}}; - g_tagMap["window"] = { "window", "Window Manager", BYTRACE_TAG_WINDOW_MANAGER, USER, {}}; - g_tagMap["app"] = { "app", "APP Module", BYTRACE_TAG_APP, USER, {}}; + HITRACE_TAG_MULTIMODALINPUT, USER, {}}; + g_tagMap["sensors"] = { "sensors", "Sensors Module", HITRACE_TAG_SENSORS, USER, {}}; + g_tagMap["msdp"] = { "msdp", "Multimodal Sensor Data Platform", HITRACE_TAG_MSDP, USER, {}}; + g_tagMap["dsoftbus"] = { "dsoftbus", "Distributed Softbus", HITRACE_TAG_DSOFTBUS, USER, {}}; + g_tagMap["rpc"] = { "rpc", "RPC and IPC", HITRACE_TAG_RPC, USER, {}}; + g_tagMap["ark"] = { "ark", "ARK Module", HITRACE_TAG_ARK, USER, {}}; + g_tagMap["window"] = { "window", "Window Manager", HITRACE_TAG_WINDOW_MANAGER, USER, {}}; + g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, }}; diff --git a/bin/test/unittest/common/native/bytrace_ndk_test.cpp b/bin/test/unittest/common/native/bytrace_ndk_test.cpp index 0e53fd3..8c9f1d1 100644 --- a/bin/test/unittest/common/native/bytrace_ndk_test.cpp +++ b/bin/test/unittest/common/native/bytrace_ndk_test.cpp @@ -58,9 +58,9 @@ constexpr uint32_t TRACE_FMA11 = 11; constexpr uint32_t TRACE_FMA12 = 12; constexpr uint64_t TRACE_INVALIDATE_TAG = 0x1000000; -constexpr uint64_t BYTRACE_TAG = 0xd03301; -const constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, BYTRACE_TAG, "BYTRACE_TEST"}; -const uint64_t TAG = BYTRACE_TAG_OHOS; +constexpr uint64_t HITRACE_TAG = 0xd03301; +const constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HITRACE_TAG, "BYTRACE_TEST"}; +const uint64_t TAG = HITRACE_TAG_OHOS; static string g_traceRootPath; bool SetProperty(const string& property, const string& value); diff --git a/interfaces/kits/js/napi/bytrace_napi_common.cpp b/interfaces/kits/js/napi/bytrace_napi_common.cpp index ae24dcc..7ccd738 100644 --- a/interfaces/kits/js/napi/bytrace_napi_common.cpp +++ b/interfaces/kits/js/napi/bytrace_napi_common.cpp @@ -50,13 +50,13 @@ static napi_value JSTraceStart(napi_env env, napi_callback_info info) int taskId = 0; napi_get_value_int32(env, argv[1], &taskId); if (argc == ARGC_NUMBER_TWO) { - StartAsyncTrace(BYTRACE_TAG_APP, name, taskId); + StartAsyncTrace(HITRACE_TAG_APP, name, taskId); } else { NAPI_CALL(env, napi_typeof(env, argv[ARGC_NUMBER_TWO], &valueType)); NAPI_ASSERT(env, valueType == napi_number, "Third arg type error, should is number"); double limit = 0; napi_get_value_double(env, argv[ARGC_NUMBER_TWO], &limit); - StartAsyncTrace(BYTRACE_TAG_APP, name, taskId, limit); + StartAsyncTrace(HITRACE_TAG_APP, name, taskId, limit); } return nullptr; } @@ -81,7 +81,7 @@ static napi_value JSTraceFinish(napi_env env, napi_callback_info info) NAPI_ASSERT(env, valueType == napi_number, "Second arg type error, should is number"); int taskId = 0; napi_get_value_int32(env, argv[1], &taskId); - FinishAsyncTrace(BYTRACE_TAG_APP, name, taskId); + FinishAsyncTrace(HITRACE_TAG_APP, name, taskId); return nullptr; } @@ -105,7 +105,7 @@ static napi_value JSTraceCount(napi_env env, napi_callback_info info) NAPI_ASSERT(env, valueType == napi_number, "Second arg type error, should is number"); int64_t count = 0; napi_get_value_int64(env, argv[1], &count); - CountTrace(BYTRACE_TAG_APP, name, count); + CountTrace(HITRACE_TAG_APP, name, count); return nullptr; } From e08747cba8676419873e8d825e5847dc06c15af4 Mon Sep 17 00:00:00 2001 From: zhangalong Date: Mon, 16 May 2022 14:37:43 +0800 Subject: [PATCH 05/29] add trace tag for account Signed-off-by:zhang_along Signed-off-by: zhangalong --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 2288b88..7613c36 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -861,6 +861,7 @@ static void InitAllSupportTags() g_tagMap["rpc"] = { "rpc", "RPC and IPC", HITRACE_TAG_RPC, USER, {}}; g_tagMap["ark"] = { "ark", "ARK Module", HITRACE_TAG_ARK, USER, {}}; g_tagMap["window"] = { "window", "Window Manager", HITRACE_TAG_WINDOW_MANAGER, USER, {}}; + g_tagMap["account"] = { "account", "Account Manager", HITRACE_TAG_ACCOUNT_MANAGER, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, From 7b61fc6ec0a26ccdcfd754420a91877744954b1b Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Tue, 17 May 2022 14:39:11 +0800 Subject: [PATCH 06/29] add distributed screen tag Signed-off-by: qinlong0101 --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 7613c36..b93e50a 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -862,6 +862,7 @@ static void InitAllSupportTags() g_tagMap["ark"] = { "ark", "ARK Module", HITRACE_TAG_ARK, USER, {}}; g_tagMap["window"] = { "window", "Window Manager", HITRACE_TAG_WINDOW_MANAGER, USER, {}}; g_tagMap["account"] = { "account", "Account Manager", HITRACE_TAG_ACCOUNT_MANAGER, USER, {}}; + g_tagMap["screen"] = { "screen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, From eda00e2b9a0ad1d99e089c608dc95c38a5892068 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Wed, 18 May 2022 10:51:39 +0800 Subject: [PATCH 07/29] add distributed screen tag Signed-off-by: qinlong0101 --- bin/src/bytrace_cmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index b93e50a..3c8acf4 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -862,7 +862,7 @@ static void InitAllSupportTags() g_tagMap["ark"] = { "ark", "ARK Module", HITRACE_TAG_ARK, USER, {}}; g_tagMap["window"] = { "window", "Window Manager", HITRACE_TAG_WINDOW_MANAGER, USER, {}}; g_tagMap["account"] = { "account", "Account Manager", HITRACE_TAG_ACCOUNT_MANAGER, USER, {}}; - g_tagMap["screen"] = { "screen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; + g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, From 615e63e4680aae3427ac1b4d778d10380e4af7cc Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 25 May 2022 19:53:30 +0800 Subject: [PATCH 08/29] add distributed hardware fwk tag Signed-off-by: wanderer-dl122 --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 3c8acf4..eb22691 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -862,6 +862,7 @@ static void InitAllSupportTags() g_tagMap["ark"] = { "ark", "ARK Module", HITRACE_TAG_ARK, USER, {}}; g_tagMap["window"] = { "window", "Window Manager", HITRACE_TAG_WINDOW_MANAGER, USER, {}}; g_tagMap["account"] = { "account", "Account Manager", HITRACE_TAG_ACCOUNT_MANAGER, USER, {}}; + g_tagMap["dhfwk"] = { "dhfwk", "Distributed Hardware FWK", HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK, USER, {}}; g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { From e6f87f9f4ef928a550d9d45ac1f307290880bbf2 Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Fri, 27 May 2022 16:58:04 +0800 Subject: [PATCH 09/29] replace debug.bytrace to debug.hitrace Signed-off-by: wenlong12 Signed-off-by: wenlong12 --- bin/config/bytrace.cfg | 2 +- bin/src/bytrace_cmd.cpp | 2 +- bin/test/unittest/common/native/bytrace_ndk_test.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/config/bytrace.cfg b/bin/config/bytrace.cfg index 3a6675c..662b563 100644 --- a/bin/config/bytrace.cfg +++ b/bin/config/bytrace.cfg @@ -183,7 +183,7 @@ "chmod 0666 /sys/kernel/tracing/per_cpu/cpu13/trace", "chmod 0666 /sys/kernel/tracing/per_cpu/cpu14/trace", "chmod 0666 /sys/kernel/tracing/per_cpu/cpu15/trace", - "setparam debug.bytrace.tags.enableflags 0" + "setparam debug.hitrace.tags.enableflags 0" ] } ] diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 3c8acf4..03ee4ca 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -53,7 +53,7 @@ struct option g_longOptions[] = { const unsigned int CHUNK_SIZE = 65536; const int BLOCK_SIZE = 4096; -const string TRACE_TAG_PROPERTY = "debug.bytrace.tags.enableflags"; +const string TRACE_TAG_PROPERTY = "debug.hitrace.tags.enableflags"; // various operating paths of ftrace const string TRACING_ON_PATH = "tracing_on"; diff --git a/bin/test/unittest/common/native/bytrace_ndk_test.cpp b/bin/test/unittest/common/native/bytrace_ndk_test.cpp index 8c9f1d1..13b57e5 100644 --- a/bin/test/unittest/common/native/bytrace_ndk_test.cpp +++ b/bin/test/unittest/common/native/bytrace_ndk_test.cpp @@ -43,7 +43,7 @@ const string TRACE_FINISH = TRACE_PATTERN + "E\\|"; const string TRACE_ASYNC_START = TRACE_PATTERN + "S\\|(.*?)\\|H:"; const string TRACE_ASYNC_FINISH = TRACE_PATTERN + "F\\|(.*?)\\|H:"; const string TRACE_COUNT = TRACE_PATTERN + "C\\|(.*?)\\|H:"; -const string TRACE_PROPERTY = "debug.bytrace.tags.enableflags"; +const string TRACE_PROPERTY = "debug.hitrace.tags.enableflags"; constexpr uint32_t TASK = 1; constexpr uint32_t TID = 2; constexpr uint32_t TGID = 3; From 2e77b454b5f37b28599e8b0ba12e8031571c1679 Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Fri, 27 May 2022 16:58:04 +0800 Subject: [PATCH 10/29] replace debug.bytrace to debug.hitrace Signed-off-by: wenlong12 Signed-off-by: wenlong12 --- bin/config/bytrace.cfg | 2 +- bin/src/bytrace_cmd.cpp | 2 +- bin/src/bytrace_osal.cpp | 2 +- bin/test/unittest/common/native/bytrace_ndk_test.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/config/bytrace.cfg b/bin/config/bytrace.cfg index 3a6675c..662b563 100644 --- a/bin/config/bytrace.cfg +++ b/bin/config/bytrace.cfg @@ -183,7 +183,7 @@ "chmod 0666 /sys/kernel/tracing/per_cpu/cpu13/trace", "chmod 0666 /sys/kernel/tracing/per_cpu/cpu14/trace", "chmod 0666 /sys/kernel/tracing/per_cpu/cpu15/trace", - "setparam debug.bytrace.tags.enableflags 0" + "setparam debug.hitrace.tags.enableflags 0" ] } ] diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 3c8acf4..03ee4ca 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -53,7 +53,7 @@ struct option g_longOptions[] = { const unsigned int CHUNK_SIZE = 65536; const int BLOCK_SIZE = 4096; -const string TRACE_TAG_PROPERTY = "debug.bytrace.tags.enableflags"; +const string TRACE_TAG_PROPERTY = "debug.hitrace.tags.enableflags"; // various operating paths of ftrace const string TRACING_ON_PATH = "tracing_on"; diff --git a/bin/src/bytrace_osal.cpp b/bin/src/bytrace_osal.cpp index 06b2050..3d02718 100644 --- a/bin/src/bytrace_osal.cpp +++ b/bin/src/bytrace_osal.cpp @@ -24,7 +24,7 @@ bool SetPropertyInner(const std::string& property, const std::string& value) { bool result = OHOS::system::SetParameter(property, value); if (!result) { - fprintf(stderr, "Error: Failed to set %s property.\n", property.c_str()); + fprintf(stderr, "Error: Failed to set %s property.\n", value.c_str()); } return result; } diff --git a/bin/test/unittest/common/native/bytrace_ndk_test.cpp b/bin/test/unittest/common/native/bytrace_ndk_test.cpp index 8c9f1d1..13b57e5 100644 --- a/bin/test/unittest/common/native/bytrace_ndk_test.cpp +++ b/bin/test/unittest/common/native/bytrace_ndk_test.cpp @@ -43,7 +43,7 @@ const string TRACE_FINISH = TRACE_PATTERN + "E\\|"; const string TRACE_ASYNC_START = TRACE_PATTERN + "S\\|(.*?)\\|H:"; const string TRACE_ASYNC_FINISH = TRACE_PATTERN + "F\\|(.*?)\\|H:"; const string TRACE_COUNT = TRACE_PATTERN + "C\\|(.*?)\\|H:"; -const string TRACE_PROPERTY = "debug.bytrace.tags.enableflags"; +const string TRACE_PROPERTY = "debug.hitrace.tags.enableflags"; constexpr uint32_t TASK = 1; constexpr uint32_t TID = 2; constexpr uint32_t TGID = 3; From e33e753b2fb0427f2d58f0ca81ee4a6f30f02e1c Mon Sep 17 00:00:00 2001 From: Goldgom Date: Tue, 7 Jun 2022 12:12:22 +0000 Subject: [PATCH 11/29] =?UTF-8?q?=E4=BC=98=E5=8C=96README=20Signed-off-by:?= =?UTF-8?q?=20Goldgom=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 79 ++++++++++------------------------------------------ README_zh.md | 79 ++++++++++------------------------------------------ 2 files changed, 28 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index cf7ef53..cb05942 100644 --- a/README.md +++ b/README.md @@ -37,70 +37,19 @@ The following table lists the commands supported by ByTrace. ** Table 1** Commands supported by ByTrace - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Option

-

Description

-

-h, --help

-

Views the help Information.

-

-b n, --buffer_size n

-

Sets the size of the buffer (KB) for storing and reading traces. The default buffer size is 2048 KB.

-

-t n, --time n

-

Sets the ByTrace uptime in seconds, which depends on the time required for analysis.

-

--trace_clock clock

-

Sets the type of the clock for adding a timestamp to a trace, which can be boot (default), global, mono, uptime, or perf.

-

--trace_begin

-

Starts trace.

-

--trace_dump

-

Dumps traced data to a specified position (the default position is the console).

-

--trace_finish

-

Stops capturing traces and dumps traced data to a specified position (the default position is the console).

-

-l, --list_categories

-

Lists the ByTrace categories supported by the device.

-

--overwrite

-

Sets the action to take when the buffer is full. If this option is used, the latest traced data is discarded.

-

-o filename, --output filename

-

Outputs traced data to a specified file.

-

-z

-

Compresses traced data.

-
+| Option | Description | +|---------|------------| +| -h, --help | Views the help Information. | +| -b n, --buffer_size n | Sets the size of the buffer (KB) for storing and reading traces. The default buffer size is 2048 KB. | +| -t n, --time n | Sets the ByTrace uptime in seconds, which depends on the time required for analysis. | +| --trace_clock clock | Sets the type of the clock for adding a timestamp to a trace, which can be boot (default), global, mono, uptime, or perf. | +| --trace_begin | Starts trace. | +| --trace_dump | Dumps traced data to a specified position (the default position is the console). | +| --trace_finish | Stops capturing traces and dumps traced data to a specified position (the default position is the console). | +| -l, --list_categories | Lists the ByTrace categories supported by the device. | +| --overwrite | Sets the action to take when the buffer is full. If this option is used, the latest traced data is discarded. | +| -o filename, --output filename | Outputs traced data to a specified file. | +| -z | Compresses traced data. | The following are some example ByTrace commands: @@ -140,6 +89,6 @@ The following are some example ByTrace commands: ## Repositories Involved -Development Tools Subsystem +[Development Tools Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/development-toolchain.md) **developtools\_bytrace\_standard** diff --git a/README_zh.md b/README_zh.md index bc9d2c0..31724bc 100644 --- a/README_zh.md +++ b/README_zh.md @@ -39,70 +39,19 @@ bytrace当前支持如下命令: **表 1** 命令行列表 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Option

-

Description

-

-h,--help

-

查看option帮助

-

-b n,--buffer_size n

-

指定n(KB)内存大小用于存取trace日志,默认2048KB

-

-t n,--time n

-

用来指定trace运行的时间(单位:s),取决于需要分析过程的时间

-

--trace_clock clock

-

trace输出的时钟类型,一般设备支持boot、global、mono、uptime、perf等,默认为boot

-

--trace_begin

-

启动抓trace

-

--trace_dump

-

将数据输出到指定位置(默认控制台)

-

--trace_finish

-

停止抓trace,并将数据输出到指定位置(默认控制台)

-

-l,--list_categories

-

输出手机能支持的trace模块

-

--overwrite

-

当缓冲区满的时候,将丢弃最新的信息。(默认丢弃最老的日志)

-

-o filename,--output filename

-

指定输出的目标文件名称

-

-z

-

抓取trace后进行压缩

-
+| Option | Description | +|--------|------------| +| -h,--help | 查看option帮助 | +| -b n,--buffer_size n | 指定n(KB)内存大小用于存取trace日志,默认2048KB | +| -t n,--time n | 用来指定trace运行的时间(单位:s),取决于需要分析过程的时间 | +| --trace_clock clock | trace输出的时钟类型,一般设备支持boot、global、mono、uptime、perf等,默认为boot | +| --trace_begin | 启动抓trace | +| --trace_dump | 将数据输出到指定位置(默认控制台) | +| --trace_finish | 停止抓trace,并将数据输出到指定位置(默认控制台) | +| -l,--list_categories | 输出手机能支持的trace模块 | +| --overwrite | 当缓冲区满的时候,将丢弃最新的信息。(默认丢弃最老的日志) | +| -o filename,--output filename | 指定输出的目标文件名称 | +| -z | 抓取trace后进行压缩 | 以下是常用bytrace命令示例,供开发者参考: @@ -142,7 +91,7 @@ bytrace当前支持如下命令: ## 相关仓 -研发工具链子系统 +[研发工具链子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E7%A0%94%E5%8F%91%E5%B7%A5%E5%85%B7%E9%93%BE%E5%AD%90%E7%B3%BB%E7%BB%9F.md) **developtools\_bytrace\_standard** From 4c422a56b5466a71026d0103933ac72a9be8f5e4 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Wed, 8 Jun 2022 10:35:59 +0800 Subject: [PATCH 12/29] dcamera add hitrace Signed-off-by: chen0088 --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 03ee4ca..96dbf43 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -863,6 +863,7 @@ static void InitAllSupportTags() g_tagMap["window"] = { "window", "Window Manager", HITRACE_TAG_WINDOW_MANAGER, USER, {}}; g_tagMap["account"] = { "account", "Account Manager", HITRACE_TAG_ACCOUNT_MANAGER, USER, {}}; g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; + g_tagMap["dcamera"] = { "dcamera", "Distributed Camera", HITRACE_TAG_DISTRIBUTED_CAMERA, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, From ce23ecb552189e47310796ece08ede45b98656ce Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Wed, 15 Jun 2022 16:14:38 +0800 Subject: [PATCH 13/29] =?UTF-8?q?=E3=80=90DFX=E3=80=91=E5=88=86=E5=B8=83?= =?UTF-8?q?=E5=BC=8F=E7=A1=AC=E4=BB=B6=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0Hitrace=E6=89=93=E7=82=B9=20Signed-off-by:=20?= =?UTF-8?q?wangyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/src/bytrace_cmd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 96dbf43..22a7a82 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -864,6 +864,8 @@ static void InitAllSupportTags() g_tagMap["account"] = { "account", "Account Manager", HITRACE_TAG_ACCOUNT_MANAGER, USER, {}}; g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["dcamera"] = { "dcamera", "Distributed Camera", HITRACE_TAG_DISTRIBUTED_CAMERA, USER, {}}; + g_tagMap["devicemanager"] = { "devicemanager", "Distributed Hardware DM", HITRACE_TAG_DISTRIBUTED_DEVICEMANAGER, + USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, From e755e93a8282162fdbea082916b68b5be04c8da1 Mon Sep 17 00:00:00 2001 From: huangjie Date: Wed, 15 Jun 2022 15:58:06 +0800 Subject: [PATCH 14/29] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=A8=E7=90=83?= =?UTF-8?q?=E5=8C=96DFX=20trace=20tag=20=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjie --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 96dbf43..383266c 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -868,6 +868,7 @@ static void InitAllSupportTags() g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, }}; + g_tagMap["gresource"] = { "gresource", "Global Resource Manager", HITRACE_TAG_GLOBAL_RESMGR, USER, {}}; // Kernel os InitKernelSupportTags(); From 265f23e1ef0f115fe4cbd66ed0e7578ccb4ae92a Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Wed, 15 Jun 2022 17:34:38 +0800 Subject: [PATCH 15/29] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- bin/src/bytrace_cmd.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 22a7a82..d7e47b7 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -864,8 +864,7 @@ static void InitAllSupportTags() g_tagMap["account"] = { "account", "Account Manager", HITRACE_TAG_ACCOUNT_MANAGER, USER, {}}; g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["dcamera"] = { "dcamera", "Distributed Camera", HITRACE_TAG_DISTRIBUTED_CAMERA, USER, {}}; - g_tagMap["devicemanager"] = { "devicemanager", "Distributed Hardware DM", HITRACE_TAG_DISTRIBUTED_DEVICEMANAGER, - USER, {}}; + g_tagMap["devicemanager"] = { "devicemanager", "Device Manager", HITRACE_TAG_DEVICE_MANAGER, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, From c5fd883b3045907bc7b38cdffa2a9210c8bb6777 Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 20 Jun 2022 13:53:37 +0800 Subject: [PATCH 16/29] add sa trace tag Signed-off-by: chen Change-Id: Ie26879e87ac09c3197599fffddd5d39cecdb163f --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 516ef50..2ce187b 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -866,6 +866,7 @@ static void InitAllSupportTags() g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["dcamera"] = { "dcamera", "Distributed Camera", HITRACE_TAG_DISTRIBUTED_CAMERA, USER, {}}; g_tagMap["devicemanager"] = { "devicemanager", "Device Manager", HITRACE_TAG_DEVICE_MANAGER, USER, {}}; + g_tagMap["samgr"] = { "samgr", "samgr", HITRACE_TAG_SAMGR, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, From f7d5257123610b436091b40dc4cdc3a68183c11c Mon Sep 17 00:00:00 2001 From: wangyang2022 Date: Mon, 20 Jun 2022 13:58:37 +0800 Subject: [PATCH 17/29] add dms trace tag Signed-off-by: wangyang2022 Change-Id: I59dc5ead8d07df242eacd9a0268e7a0285a28ab0 --- bin/src/bytrace_cmd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 516ef50..4b509ef 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -866,6 +866,8 @@ static void InitAllSupportTags() g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["dcamera"] = { "dcamera", "Distributed Camera", HITRACE_TAG_DISTRIBUTED_CAMERA, USER, {}}; g_tagMap["devicemanager"] = { "devicemanager", "Device Manager", HITRACE_TAG_DEVICE_MANAGER, USER, {}}; + g_tagMap["distributedschedule"] = { "distributedschedule", "Distributed Schedule", + HITRACE_TAG_DISTRIBUTED_SCHEDULE, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, From 8d5074973652e68851f4ec5dbcfe85d60d8dc8aa Mon Sep 17 00:00:00 2001 From: m30030488 Date: Mon, 20 Jun 2022 16:20:33 +0800 Subject: [PATCH 18/29] add device profile bytrace Signed-off-by: m30030488 --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 516ef50..c695c0c 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -866,6 +866,7 @@ static void InitAllSupportTags() g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["dcamera"] = { "dcamera", "Distributed Camera", HITRACE_TAG_DISTRIBUTED_CAMERA, USER, {}}; g_tagMap["devicemanager"] = { "devicemanager", "Device Manager", HITRACE_TAG_DEVICE_MANAGER, USER, {}}; + g_tagMap["deviceprofile"] = { "deviceprofile", "Device Profile", HITRACE_TAG_DEVICE_PROFILE, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { { "events/zbinder/enable" }, From 9eb43f457d631c6d3709a245be9972e14c895f59 Mon Sep 17 00:00:00 2001 From: shijie Date: Wed, 22 Jun 2022 14:24:16 +0800 Subject: [PATCH 19/29] feat: add power hitrace Signed-off-by: shijie --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 516ef50..23e5a73 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -871,6 +871,7 @@ static void InitAllSupportTags() { "events/zbinder/enable" }, }}; g_tagMap["gresource"] = { "gresource", "Global Resource Manager", HITRACE_TAG_GLOBAL_RESMGR, USER, {}}; + g_tagMap["power"] = { "power", "Power Manager", HITRACE_TAG_POWER, USER, {}}; // Kernel os InitKernelSupportTags(); From 91a3ce5991339fba71990fc30f3befffcbcaf5a4 Mon Sep 17 00:00:00 2001 From: wangyang2022 Date: Wed, 22 Jun 2022 14:32:56 +0800 Subject: [PATCH 20/29] add dms trace tag Signed-off-by: wangyang2022 Change-Id: Ie858fb7def3629d8cee9a8e2868ab7607b386a30 --- bin/src/bytrace_cmd.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 05485de..523fc41 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -866,8 +866,7 @@ static void InitAllSupportTags() g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["dcamera"] = { "dcamera", "Distributed Camera", HITRACE_TAG_DISTRIBUTED_CAMERA, USER, {}}; g_tagMap["devicemanager"] = { "devicemanager", "Device Manager", HITRACE_TAG_DEVICE_MANAGER, USER, {}}; - g_tagMap["distributedschedule"] = { "distributedschedule", "Distributed Schedule", - HITRACE_TAG_DISTRIBUTED_SCHEDULE, USER, {}}; + g_tagMap["dsched"] = { "dsched", "Distributed Schedule", HITRACE_TAG_DISTRIBUTED_SCHEDULE, USER, {}}; g_tagMap["samgr"] = { "samgr", "samgr", HITRACE_TAG_SAMGR, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, { From 1f8f48c1d5b46eb527069cdd9d8f00987bea6b75 Mon Sep 17 00:00:00 2001 From: wangxuanxuan Date: Wed, 22 Jun 2022 17:29:20 +0800 Subject: [PATCH 21/29] add distributed input tag Signed-off-by: wangxuanxuan --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 2ce187b..7722653 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -865,6 +865,7 @@ static void InitAllSupportTags() g_tagMap["dhfwk"] = { "dhfwk", "Distributed Hardware FWK", HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK, USER, {}}; g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; g_tagMap["dcamera"] = { "dcamera", "Distributed Camera", HITRACE_TAG_DISTRIBUTED_CAMERA, USER, {}}; + g_tagMap["dinput"] = { "dinput", "Distributed Input", HITRACE_TAG_DISTRIBUTED_INPUT, USER, {}}; g_tagMap["devicemanager"] = { "devicemanager", "Device Manager", HITRACE_TAG_DEVICE_MANAGER, USER, {}}; g_tagMap["samgr"] = { "samgr", "samgr", HITRACE_TAG_SAMGR, USER, {}}; g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}}; From ea6d530a662a0d993ee91b5575dc3cad24f31132 Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Thu, 23 Jun 2022 10:52:30 +0800 Subject: [PATCH 22/29] delete bytrace ut test Signed-off-by:wenlong12 Signed-off-by: wenlong12 --- bin/test/BUILD.gn | 41 -- .../common/native/bytrace_ndk_test.cpp | 684 ------------------ bundle.json | 3 - 3 files changed, 728 deletions(-) delete mode 100644 bin/test/BUILD.gn delete mode 100644 bin/test/unittest/common/native/bytrace_ndk_test.cpp diff --git a/bin/test/BUILD.gn b/bin/test/BUILD.gn deleted file mode 100644 index e2e45cd..0000000 --- a/bin/test/BUILD.gn +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2021 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. - -import("//build/test.gni") -import("//developtools/bytrace/bytrace.gni") - -module_output_path = "bytrace/bytrace" - -config("module_private_config") { - visibility = [ ":*" ] -} - -ohos_unittest("BytraceNDKTest") { - module_out_path = module_output_path - sources = [ "unittest/common/native/bytrace_ndk_test.cpp" ] - deps = [ - "${bytrace_path}/bin:bytrace_osal_inner", - "//third_party/googletest:gtest_main", - ] - external_deps = [ - "hitrace_native:hitrace_meter", - "hiviewdfx_hilog_native:libhilog", - "startup_l2:syspara", - ] - include_dirs = [ "${innerkits_path}/bytrace/bytrace_native/include" ] -} - -group("unittest") { - testonly = true - deps = [ ":BytraceNDKTest" ] -} diff --git a/bin/test/unittest/common/native/bytrace_ndk_test.cpp b/bin/test/unittest/common/native/bytrace_ndk_test.cpp deleted file mode 100644 index 13b57e5..0000000 --- a/bin/test/unittest/common/native/bytrace_ndk_test.cpp +++ /dev/null @@ -1,684 +0,0 @@ -/* - * Copyright (C) 2021-2022 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. - */ - -#include -#include -#include -#include -#include -#include -#include "hitrace_meter.h" -#include "bytrace_osal.h" -#include "parameters.h" - -using namespace testing::ext; -using namespace std; -using namespace OHOS::HiviewDFX; -using namespace OHOS::Developtools::BytraceOsal; - -namespace OHOS { -namespace Developtools { -namespace BytraceTest { -const string TRACE_MARKER_PATH = "trace_marker"; -const string TRACING_ON_PATH = "tracing_on"; -const string TRACING_ON = "tracing_on"; -const string TRACE_PATH = "trace"; -const string TRACE_MARK_WRITE = "tracing_mark_write"; -const string TRACE_PATTERN = "\\s*(.*?)-(.*?)\\s+(.*?)\\[(\\d+?)\\]\\s+(.*?)\\s+((\\d+).(\\d+)?):\\s+" - + TRACE_MARK_WRITE + ": "; -const string TRACE_START = TRACE_PATTERN + "B\\|(.*?)\\|H:"; -const string TRACE_FINISH = TRACE_PATTERN + "E\\|"; -const string TRACE_ASYNC_START = TRACE_PATTERN + "S\\|(.*?)\\|H:"; -const string TRACE_ASYNC_FINISH = TRACE_PATTERN + "F\\|(.*?)\\|H:"; -const string TRACE_COUNT = TRACE_PATTERN + "C\\|(.*?)\\|H:"; -const string TRACE_PROPERTY = "debug.hitrace.tags.enableflags"; -constexpr uint32_t TASK = 1; -constexpr uint32_t TID = 2; -constexpr uint32_t TGID = 3; -constexpr uint32_t CPU = 4; -constexpr uint32_t DNH2 = 5; -constexpr uint32_t TIMESTAMP = 6; -constexpr uint32_t PID = 9; -constexpr uint32_t TRACE_NAME = 10; -constexpr uint32_t NUM = 11; - -constexpr uint32_t TRACE_FMA11 = 11; -constexpr uint32_t TRACE_FMA12 = 12; - -constexpr uint64_t TRACE_INVALIDATE_TAG = 0x1000000; -constexpr uint64_t HITRACE_TAG = 0xd03301; -const constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HITRACE_TAG, "BYTRACE_TEST"}; -const uint64_t TAG = HITRACE_TAG_OHOS; -static string g_traceRootPath; - -bool SetProperty(const string& property, const string& value); -string GetProperty(const string& property, const string& value); -bool CleanTrace(); -bool CleanFtrace(); -bool SetFtrace(const string& filename, bool enabled); - -class BytraceNDKTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown() {} -}; - -void BytraceNDKTest::SetUpTestCase() -{ - const string debugfsDir = "/sys/kernel/debug/tracing/"; - const string tracefsDir = "/sys/kernel/tracing/"; - if (access((debugfsDir + TRACE_MARKER_PATH).c_str(), F_OK) != -1) { - g_traceRootPath = debugfsDir; - } else if (access((tracefsDir + TRACE_MARKER_PATH).c_str(), F_OK) != -1) { - g_traceRootPath = tracefsDir; - } else { - HiLog::Error(LABEL, "Error: Finding trace folder failed"); - } - CleanFtrace(); -} - -void BytraceNDKTest::TearDownTestCase() -{ - SetProperty(TRACE_PROPERTY, "0"); - SetFtrace(TRACING_ON, false); - CleanTrace(); -} - -void BytraceNDKTest::SetUp() -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - string value = to_string(TAG); - SetProperty(TRACE_PROPERTY, value); - HiLog::Info(LABEL, "current tag is %{public}s", GetProperty(TRACE_PROPERTY, "0").c_str()); - ASSERT_TRUE(GetProperty(TRACE_PROPERTY, "-123") == value); - UpdateTraceLabel(); -} - -struct Param { - string m_task; - string m_tid; - string m_tgid; - string m_cpu; - string m_dnh2; - string m_timestamp; - string m_pid; - string m_traceName; - string m_num; -}; - -class MyTrace { - Param m_param; - bool m_loaded = false; -public: - MyTrace() : m_loaded(false) - { - m_param.m_task = ""; - m_param.m_tid = ""; - m_param.m_tgid = ""; - m_param.m_cpu = ""; - m_param.m_dnh2 = ""; - m_param.m_timestamp = ""; - m_param.m_pid = ""; - m_param.m_traceName = ""; - m_param.m_num = ""; - } - - ~MyTrace() - { - } - - // task-pid ( tig) [cpu] ...1 timestamp: tracing_mark_write: B|pid|traceName - // task-pid ( tig) [cpu] ...1 timestamp: tracing_mark_write: E|pid - void Load(const Param& param) - { - m_param.m_task = param.m_task; - m_param.m_pid = param.m_pid; - m_param.m_tid = param.m_tid; - m_param.m_tgid = param.m_tgid; - m_param.m_cpu = param.m_cpu; - m_param.m_dnh2 = param.m_dnh2; - m_param.m_timestamp = param.m_timestamp; - m_param.m_traceName = param.m_traceName; - m_param.m_num = param.m_num; - m_loaded = true; - } - - string GetTask() - { - return m_param.m_task; - } - - string GetPid() - { - if (m_loaded) { - return m_param.m_pid; - } - return ""; - } - - string GetTgid() - { - if (m_loaded) { - return m_param.m_tgid; - } - return ""; - } - - string GetCpu() - { - if (m_loaded) { - return m_param.m_cpu; - } - return ""; - } - - string GetDnh2() - { - if (m_loaded) { - return m_param.m_dnh2; - } - return ""; - } - - string GetTimestamp() - { - if (m_loaded) { - return m_param.m_timestamp; - } - return ""; - } - - string GetTraceName() - { - if (m_loaded) { - return m_param.m_traceName; - } - return ""; - } - - string GetNum() - { - if (m_loaded) { - return m_param.m_num; - } - return ""; - } - - string GetTid() - { - if (m_loaded) { - return m_param.m_tid; - } - return ""; - } - - bool IsLoaded() const - { - return m_loaded; - } -}; - -bool SetProperty(const string& property, const string& value) -{ - bool result = false; - result = OHOS::system::SetParameter(property, value); - if (!result) { - HiLog::Error(LABEL, "Error: setting %s failed", property.c_str()); - return false; - } - return true; -} - -string GetProperty(const string& property, const string& value) -{ - return OHOS::system::GetParameter(property, value); -} - -bool GetTimeDuration(int64_t time1, int64_t time2, int64_t diffRange) -{ - int64_t duration = time2 - time1; - return (duration > 0) && (duration <= diffRange ? true : false); -} - -string& Trim(string& s) -{ - if (s.empty()) { - return s; - } - s.erase(0, s.find_first_not_of(" ")); - s.erase(s.find_last_not_of(" ") + 1); - return s; -} - -int64_t GetTimeStamp(string str) -{ - if (str == "") { - return 0; - } - int64_t time; - Trim(str); - time = atol(str.erase(str.find("."), 1).c_str()); - return time; -} - -MyTrace GetTraceResult(const string& checkContent, const vector& list) -{ - MyTrace trace; - if (list.empty() || checkContent == "") { - return trace; - } - regex pattern(checkContent); - smatch match; - Param param {""}; - for (int i = list.size() - 1; i >= 0; i--) { - if (regex_match(list[i], match, pattern)) { - param.m_task = match[TASK]; - param.m_tid = match[TID]; - param.m_tgid = match[TGID]; - param.m_cpu = match[CPU]; - param.m_dnh2 = match[DNH2]; - param.m_timestamp = match[TIMESTAMP]; - param.m_pid = match[PID]; - if (match.size() == TRACE_FMA11) { - param.m_traceName = match[TRACE_NAME], - param.m_num = ""; - } else if (match.size() == TRACE_FMA12) { - param.m_traceName = match[TRACE_NAME], - param.m_num = match[NUM]; - } else { - param.m_traceName = ""; - param.m_num = ""; - } - trace.Load(param); - break; - } - } - return trace; -} - -static bool WriteStringToFile(const string& fileName, const string& str) -{ - if (g_traceRootPath.empty()) { - HiLog::Error(LABEL, "Error: trace path not found."); - return false; - } - ofstream out; - out.open(g_traceRootPath + fileName, ios::out); - out << str; - out.close(); - return true; -} - -bool CleanTrace() -{ - if (g_traceRootPath.empty()) { - HiLog::Error(LABEL, "Error: trace path not found."); - return false; - } - ofstream ofs; - ofs.open(g_traceRootPath + TRACE_PATH, ofstream::out); - if (!ofs.is_open()) { - HiLog::Error(LABEL, "Error: opening trace path failed."); - return false; - } - ofs << ""; - ofs.close(); - return true; -} - -static stringstream ReadFile(const string& filename) -{ - stringstream ss; - char resolvedPath[PATH_MAX] = { 0 }; - if (realpath(filename.c_str(), resolvedPath) == nullptr) { - fprintf(stderr, "Error: _fullpath %s failed", filename.c_str()); - return ss; - } - ifstream fin(resolvedPath); - if (!fin.is_open()) { - fprintf(stderr, "opening file: %s failed!", filename.c_str()); - return ss; - } - ss << fin.rdbuf(); - fin.close(); - return ss; -} - -static bool IsFileExisting(const string& filename) -{ - return access(filename.c_str(), F_OK) != -1; -} - -bool SetFtrace(const string& filename, bool enabled) -{ - return WriteStringToFile(filename, enabled ? "1" : "0"); -} - -bool CleanFtrace() -{ - return WriteStringToFile("set_event", ""); -} - -string GetFinishTraceRegex(MyTrace& trace) -{ - if (!trace.IsLoaded()) { - return ""; - } else { - return "\\s*(.*?)-(" + trace.GetTid() + "?)\\s+(.*?)\\[(\\d+?)\\]\\s+(.*?)\\s+" + "((\\d+).(\\d+)?):\\s+" + - TRACE_MARK_WRITE + ": E\\|(" + trace.GetPid() + ")|(.*)"; - } -} - -vector ReadFile2string(const string& filename) -{ - vector list; - if (IsFileExisting(filename)) { - stringstream ss = ReadFile(filename); - string line; - while (getline(ss, line)) { - list.emplace_back(move(line)); - } - } - return list; -} - -vector ReadTrace() -{ - return ReadFile2string(g_traceRootPath + TRACE_PATH); -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node normal output start tracing and end tracing. - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_001, TestSize.Level0) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartTrace(TAG, "StartTraceTest001"); - FinishTrace(TAG); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - vector list = ReadTrace(); - MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest001) ", list); - ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest001\" from trace."; - MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list); - ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node has no output. - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_002, TestSize.Level0) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartTrace(TAG, "StartTraceTest002"); - FinishTrace(TAG); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - vector list = ReadTrace(); - MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest002) ", list); - ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest002\" from trace."; - MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list); - ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node normal output start trace and end trace. - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_003, TestSize.Level0) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartTrace(TAG, "StartTraceTest003 %s"); - FinishTrace(TAG); - vector list = ReadTrace(); - MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest003 %s) ", list); - ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest003 %s\" from trace."; - MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list); - ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace."; - ASSERT_TRUE(CleanTrace()); - list.clear(); - StartTrace(TAG, "StartTraceTest003 %p"); - FinishTrace(TAG); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - list = ReadTrace(); - MyTrace startTrace2 = GetTraceResult(TRACE_START + "(StartTraceTest003 %p) ", list); - MyTrace finishTrace2 = GetTraceResult(GetFinishTraceRegex(startTrace), list); - ASSERT_TRUE(finishTrace2.IsLoaded()) << "Can't find \"E|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: test Input and output interval 1ms execution, time fluctuation 1ms - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_004, TestSize.Level0) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartTrace(TAG, "StartTraceTest004"); - usleep(1000); - FinishTrace(TAG); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - vector list = ReadTrace(); - MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest004) ", list); - ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest004\" from trace."; - MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list); - ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node normal output start trace and end trace - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_005, TestSize.Level0) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartAsyncTrace(TAG, "asyncTraceTest005", 123); - FinishAsyncTrace(TAG, "asyncTraceTest005", 123); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - vector list = ReadTrace(); - MyTrace startTrace = GetTraceResult(TRACE_ASYNC_START + "(asyncTraceTest005) (.*)", list); - ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"S|pid|asyncTraceTest005\" from trace."; - MyTrace finishTrace = - GetTraceResult(TRACE_ASYNC_FINISH + startTrace.GetTraceName() + " " + startTrace.GetNum(), list); - ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"F|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node normal output start trace and end trace - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_006, TestSize.Level0) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - CountTrace(TAG, "countTraceTest006", 1); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - vector list = ReadTrace(); - MyTrace countTrace = GetTraceResult(TRACE_COUNT + "(countTraceTest006) (.*)", list); - ASSERT_TRUE(countTrace.IsLoaded()) << "Can't find \"C|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node normal output start trace and end trace. - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_007, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartTrace(TRACE_INVALIDATE_TAG, "StartTraceTest007"); - FinishTrace(TRACE_INVALIDATE_TAG); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - vector list = ReadTrace(); - MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest007)", list); - EXPECT_FALSE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest007\" from trace."; - MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list); - EXPECT_FALSE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node normal output start trace and end trace. - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_008, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartTrace(TRACE_INVALIDATE_TAG, "StartTraceTest008 %s"); - FinishTrace(TRACE_INVALIDATE_TAG); - vector list = ReadTrace(); - MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest008 %s)", list); - EXPECT_FALSE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest008 %s\" from trace."; - MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list); - EXPECT_FALSE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace."; - ASSERT_TRUE(CleanTrace()); - list.clear(); - StartTrace(TRACE_INVALIDATE_TAG, "StartTraceTest008 %p"); - FinishTrace(TRACE_INVALIDATE_TAG); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - list = ReadTrace(); - MyTrace startTrace2 = GetTraceResult(TRACE_START + "(StartTraceTest008 %p)", list); - MyTrace finishTrace2 = GetTraceResult(GetFinishTraceRegex(startTrace), list); - EXPECT_FALSE(finishTrace2.IsLoaded()) << "Can't find \"E|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node normal output start trace and end trace - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_009, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartAsyncTrace(TRACE_INVALIDATE_TAG, "asyncTraceTest009", 123); - FinishAsyncTrace(TRACE_INVALIDATE_TAG, "asyncTraceTest009", 123); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - vector list = ReadTrace(); - MyTrace startTrace = GetTraceResult(TRACE_ASYNC_START + "(asyncTraceTest009)\\|(.*)", list); - EXPECT_FALSE(startTrace.IsLoaded()) << "Can't find \"S|pid|asyncTraceTest009\" from trace."; - MyTrace finishTrace = GetTraceResult(TRACE_ASYNC_FINISH + startTrace.GetTraceName() + "\\|" - + startTrace.GetNum(), list); - EXPECT_FALSE(finishTrace.IsLoaded()) << "Can't find \"F|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node normal output start trace and end trace - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_010, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - CountTrace(TRACE_INVALIDATE_TAG, "countTraceTest010", 1); - ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed."; - vector list = ReadTrace(); - MyTrace countTrace = GetTraceResult(TRACE_COUNT + "(countTraceTest010)\\|(.*)", list); - EXPECT_FALSE(countTrace.IsLoaded()) << "Can't find \"C|\" from trace."; -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node general output start and end tracing for debugging. - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_011, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartTraceDebug(TAG, "StartTraceTest011"); - FinishTraceDebug(TAG); -} - -/** - * @tc.name: bytrace - * @tc.desc: tracing_mark_write file node general output start and end tracing for debugging. - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_012, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartTraceDebug(TAG, "StartTraceTest012 %s"); - FinishTraceDebug(TAG); -} - -/** - * @tc.name: bytrace - * @tc.desc: Testing StartAsyncTraceDebug and FinishAsyncTraceDebug functions - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_013, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - StartAsyncTraceDebug(TAG, "asyncTraceTest013", 123); - FinishAsyncTraceDebug(TAG, "asyncTraceTest013", 123); -} - -/** - * @tc.name: bytrace - * @tc.desc: Testing CountTraceDebug function - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_014, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - CountTraceDebug(TAG, "countTraceTest014", 1); -} - -/** - * @tc.name: bytrace - * @tc.desc: Testing MiddleTrace function - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_015, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - MiddleTrace(TAG, "MiddleTraceTest015", "050tseTecarTelddiM"); -} - -/** - * @tc.name: bytrace - * @tc.desc: Testing MiddleTraceDebug function - * @tc.type: FUNC - */ -HWTEST_F(BytraceNDKTest, StartTrace_016, TestSize.Level1) -{ - ASSERT_TRUE(CleanTrace()); - ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed."; - MiddleTraceDebug(TAG, "MiddleTraceTest016", "061tseTecarTelddiM"); -} -} // namespace BytraceTest -} // namespace Developtools -} // namespace OHOS diff --git a/bundle.json b/bundle.json index a78ba13..3eb7d1d 100644 --- a/bundle.json +++ b/bundle.json @@ -36,9 +36,6 @@ "//developtools/bytrace/interfaces/kits:jsapi_kits_target" ], "inner_kits": [ - ], - "test": [ - "//developtools/bytrace/bin/test:unittest" ] } } From 573b62b78c1a70112a1eea3944c05ee0cfe543c2 Mon Sep 17 00:00:00 2001 From: laiguizhong Date: Fri, 24 Jun 2022 02:22:46 -0700 Subject: [PATCH 23/29] =?UTF-8?q?=E9=80=82=E9=85=8Dsysparam=E4=BB=93?= =?UTF-8?q?=E5=BD=92=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laiguizhong Change-Id: I23888822294c9673ab84d94192e776d49f34f774 --- bin/BUILD.gn | 2 +- bundle.json | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/BUILD.gn b/bin/BUILD.gn index 52e9cd3..39024e4 100644 --- a/bin/BUILD.gn +++ b/bin/BUILD.gn @@ -26,8 +26,8 @@ ohos_static_library("bytrace_osal_inner") { sources = [ "./src/bytrace_osal.cpp" ] public_configs = [ ":bytrace_osal_inner_config" ] external_deps = [ + "init:libbegetutil", "ipc:ipc_core", - "startup_l2:syspara", ] subsystem_name = "developtools" diff --git a/bundle.json b/bundle.json index 3eb7d1d..68836a3 100644 --- a/bundle.json +++ b/bundle.json @@ -20,8 +20,7 @@ "deps": { "components": [ "hilog", - "syspara", - "syspara_watchagent", + "init", "ipc", "utils_base" ], From 9383a94e3f577570bedd89d3fecb0f3ebc0bdb18 Mon Sep 17 00:00:00 2001 From: xiahaiqin Date: Wed, 29 Jun 2022 20:13:45 +0800 Subject: [PATCH 24/29] add accessibility trace tag Signed-off-by: xiahaiqin Change-Id: Id035dd3d2f4b6647e2ea02c5b0a7489aa7a1a450 --- bin/src/bytrace_cmd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 27242b3..4770baa 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -861,6 +861,8 @@ static void InitAllSupportTags() g_tagMap["rpc"] = { "rpc", "RPC and IPC", HITRACE_TAG_RPC, USER, {}}; g_tagMap["ark"] = { "ark", "ARK Module", HITRACE_TAG_ARK, USER, {}}; g_tagMap["window"] = { "window", "Window Manager", HITRACE_TAG_WINDOW_MANAGER, USER, {}}; + g_tagMap["accessibility"] = { "accessibility", "Accessibility Manager", + HITRACE_TAG_ACCESSIBILITY_MANAGER, USER, {}}; g_tagMap["account"] = { "account", "Account Manager", HITRACE_TAG_ACCOUNT_MANAGER, USER, {}}; g_tagMap["dhfwk"] = { "dhfwk", "Distributed Hardware FWK", HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK, USER, {}}; g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}}; From b401fa8bb510a2025128bd9ca50cb943f3534ea7 Mon Sep 17 00:00:00 2001 From: jiahaoluo Date: Thu, 30 Jun 2022 11:43:45 +0800 Subject: [PATCH 25/29] add filemanagement tag Signed-off-by: jiahaoluo --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 4770baa..93ad614 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -878,6 +878,7 @@ static void InitAllSupportTags() }}; g_tagMap["gresource"] = { "gresource", "Global Resource Manager", HITRACE_TAG_GLOBAL_RESMGR, USER, {}}; g_tagMap["power"] = { "power", "Power Manager", HITRACE_TAG_POWER, USER, {}}; + g_tagMap["filemanagement"] = { "filemanagement", "filemanagement", HITRACE_TAG_FILEMANAGEMENT, USER, {}}; // Kernel os InitKernelSupportTags(); From 295128e05ae09be3e75bfe7088ccad1a9edeaf5b Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Thu, 7 Jul 2022 11:14:06 +0800 Subject: [PATCH 26/29] fix bytrace_capture.bat failed issue Signed-off-by:wenlong12 Signed-off-by: wenlong12 --- script/bytrace_capture.bat | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/script/bytrace_capture.bat b/script/bytrace_capture.bat index ce59ffe..5027da0 100644 --- a/script/bytrace_capture.bat +++ b/script/bytrace_capture.bat @@ -12,10 +12,10 @@ @rem limitations under the License. @echo off -hdc shell "echo > /sys/kernel/debug/tracing/trace" -hdc shell "echo 4096 > /d/tracing/saved_cmdlines_size" -hdc shell "bytrace -t 10 -b 4096 --overwrite ohos zimage zmedia zcamera zaudio ability distributeddatamgr sched freq irq workq rs idle load disk pagecache memreclaim > /data/mynewtrace.ftrace" -hdc shell "echo > /sys/kernel/debug/tracing/trace" -hdc shell "sed -i '1,2d' /data/mynewtrace.ftrace" -hdc pull /data/mynewtrace.ftrace . +hdc_std shell "echo > /sys/kernel/debug/tracing/trace" +hdc_std shell "echo 4096 > /sys/kernel/debug/tracing/saved_cmdlines_size" +hdc_std shell "bytrace -t 10 -b 204800 --overwrite ohos ace workq idle app ark ability binder disk distributeddatamgr dsoftbus freq graphic irq mdfs memory memreclaim misc mmc msdp multimodalinput notification pagecache regulators rpc sched sync window zaudio zcamera zimage zmedia > /data/mynewtrace.ftrace" +hdc_std shell "echo > /sys/kernel/debug/tracing/trace" +hdc_std shell "sed -i '1,2d' /data/mynewtrace.ftrace" +hdc_std file recv /data/mynewtrace.ftrace . pause From 1498e0a2caa8c3ac8620281d5ce8066c82751864 Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Mon, 18 Jul 2022 17:02:34 +0800 Subject: [PATCH 27/29] update depends for bundle.json Signed-off-by:wenlong12 Signed-off-by: wenlong12 --- bundle.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bundle.json b/bundle.json index 68836a3..bb9f632 100644 --- a/bundle.json +++ b/bundle.json @@ -19,10 +19,11 @@ "ram": "720KB", "deps": { "components": [ - "hilog", + "hitrace_native", + "hiviewdfx_hilog_native", "init", "ipc", - "utils_base" + "napi" ], "third_party": [ "zlib" From 25b93e981de2faa4aef648cef26dbc4489b47edf Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Tue, 19 Jul 2022 18:43:11 +0800 Subject: [PATCH 28/29] fix invalid param crash issue Signed-off-by:wenlong12 Signed-off-by: wenlong12 --- bin/src/bytrace_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/src/bytrace_cmd.cpp b/bin/src/bytrace_cmd.cpp index 93ad614..220908e 100644 --- a/bin/src/bytrace_cmd.cpp +++ b/bin/src/bytrace_cmd.cpp @@ -49,6 +49,7 @@ struct option g_longOptions[] = { { "trace_dump", no_argument, nullptr, 0 }, { "list_categories", no_argument, nullptr, 0 }, { "overwrite", no_argument, nullptr, 0 }, + { nullptr, 0, nullptr, 0 }, }; const unsigned int CHUNK_SIZE = 65536; const int BLOCK_SIZE = 4096; From 910d841caaaa357685746738c843ac02dacf56a3 Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Wed, 20 Jul 2022 11:09:02 +0800 Subject: [PATCH 29/29] update bytrace out path Signed-off-by:wenlong12 Signed-off-by: wenlong12 --- script/bytrace_capture.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/bytrace_capture.bat b/script/bytrace_capture.bat index 5027da0..8f1b6d0 100644 --- a/script/bytrace_capture.bat +++ b/script/bytrace_capture.bat @@ -14,7 +14,7 @@ @echo off hdc_std shell "echo > /sys/kernel/debug/tracing/trace" hdc_std shell "echo 4096 > /sys/kernel/debug/tracing/saved_cmdlines_size" -hdc_std shell "bytrace -t 10 -b 204800 --overwrite ohos ace workq idle app ark ability binder disk distributeddatamgr dsoftbus freq graphic irq mdfs memory memreclaim misc mmc msdp multimodalinput notification pagecache regulators rpc sched sync window zaudio zcamera zimage zmedia > /data/mynewtrace.ftrace" +hdc_std shell "bytrace -t 10 -b 204800 --overwrite filemanagement gresource devicemanager deviceprofile dscreen dinput dhfwk accessibility dsched samgr ohos ace workq idle app ark ability binder disk distributeddatamgr dsoftbus freq graphic irq mdfs memory memreclaim misc mmc msdp multimodalinput notification pagecache regulators rpc sched sync window zaudio zcamera zimage zmedia > /data/local/tmp/data.ftrace" hdc_std shell "echo > /sys/kernel/debug/tracing/trace" hdc_std shell "sed -i '1,2d' /data/mynewtrace.ftrace" hdc_std file recv /data/mynewtrace.ftrace .