diff --git a/PerformanceAnalysisKit/HiDebugTool/AppScope/app.json5 b/PerformanceAnalysisKit/HiDebugTool/AppScope/app.json5 new file mode 100755 index 0000000000000000000000000000000000000000..d6773b4dd4e6fc7c8d8763b5c57b4f2723685603 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "app": { + "bundleName": "com.samples.hidebugtool", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/element/string.json b/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..c1cda1fb0fed8483e3a1bdb7f680d7c0a2fcfe2a --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "HiDebugTool" + } + ] +} diff --git a/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/media/background.png b/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/media/background.png new file mode 100755 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/media/background.png differ diff --git a/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/media/foreground.png b/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/media/foreground.png new file mode 100755 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/media/foreground.png differ diff --git a/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/media/layered_image.json b/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/media/layered_image.json new file mode 100755 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/README_zh.md b/PerformanceAnalysisKit/HiDebugTool/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..790d1c3cdb390b30c6b2e45ff3cda55c53766eac --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/README_zh.md @@ -0,0 +1,94 @@ +# 性能分析工具 + +### 介绍 + +本示例主要展示了HiDebug对外提供接口的使用。 + + +该工程中的展示的代码详细描述可查如下链接: + +- [使用HiDebug获取调试信息(ArkTS)](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/hidebug-guidelines-arkts) + +- [使用HiDebug获取调试信息(C/C++)](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/hidebug-guidelines-ndk) + + +### 效果预览 + +| 主页 | +| :----------------------------------------------------------: | +| z | + +#### 使用说明 + +1.在主界面,点击切换到“Log”窗口,日志过滤选择“No filters”,搜索内容设置为“testTag”。 + +2.依次点击按钮,即可在“Log”窗口看到以下日志输出。 + +按钮“testHiDebugArk”: + +``` text +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I getSystemCpuUsage: 0.2878989952876323 +``` +按钮“testGetThreadCpuUsage”: +``` text +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000104 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000000 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000040 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000010 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000001 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000038 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000000 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000007 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000004 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000007 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000006 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000001 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000004 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000002 +**-** **:**:**.*** *****-***** A00000/com.sam...gtool/testTag com.sampl...ebugtool I GetAppThreadCpuUsage: threadId *****, cpuUsage: 0.000001 +``` +按钮“testHiDebugBackTrace”(该功能仅支持arm64设备): +```text +... +**-** **:**:**.*** *****-***** A0FF00/com.sam...gtool/testTag com.sampl...ebugtool I native stack frame info for pc: ************ is relativePc: ****** funcOffset: 0x38 mapName: /data/storage/el1/bundle/libs/arm64/libentry.so functionName: TestNativeFrames(int) buildId: b6d3429f6e2e594b1c696e13049dae7e51694099 reserved: (null). +**-** **:**:**.*** *****-***** A0FF00/com.sam...gtool/testTag com.sampl...ebugtool I native stack frame info for pc: ************ is relativePc: ****** funcOffset: 0x30 mapName: /data/storage/el1/bundle/libs/arm64/libentry.so functionName: TestNativeFrames(int) buildId: b6d3429f6e2e594b1c696e13049dae7e51694099 reserved: (null). +**-** **:**:**.*** *****-***** A0FF00/com.sam...gtool/testTag com.sampl...ebugtool I native stack frame info for pc: ************ is relativePc: ****** funcOffset: 0x1c mapName: /data/storage/el1/bundle/libs/arm64/libentry.so functionName: TestBackTrace(napi_env__*, napi_callback_info__*) buildId: b6d3429f6e2e594b1c696e13049dae7e51694099 reserved: (null). +... +**-** **:**:**.*** *****-***** A0FF00/com.sam...gtool/testTag com.sampl...ebugtool I js stack frame info for pc: ************ is relativePc: ****** line: 27 column: 21 mapName: /data/storage/el1/bundle/entry.hap functionName: testBackTraceJsFrame url: entry|entry|1.0.0|src/main/ets/pages/Index.ts packageName: . +**-** **:**:**.*** *****-***** A0FF00/com.sam...gtool/testTag com.sampl...ebugtool I js stack frame info for pc: ************ is relativePc: ****** line: 25 column: 16 mapName: /data/storage/el1/bundle/entry.hap functionName: testBackTraceJsFrame url: entry|entry|1.0.0|src/main/ets/pages/Index.ts packageName: . +**-** **:**:**.*** *****-***** A0FF00/com.sam...gtool/testTag com.sampl...ebugtool I js stack frame info for pc: ************ is relativePc: ****** line: 25 column: 16 mapName: /data/storage/el1/bundle/entry.hap functionName: testBackTraceJsFrame url: entry|entry|1.0.0|src/main/ets/pages/Index.ts packageName: . +**-** **:**:**.*** *****-***** A0FF00/com.sam...gtool/testTag com.sampl...ebugtool I js stack frame info for pc: ************ is relativePc: ****** line: 25 column: 16 mapName: /data/storage/el1/bundle/entry.hap functionName: testBackTraceJsFrame url: entry|entry|1.0.0|src/main/ets/pages/Index.ts packageName: . +... +``` + +### 具体实现 + +1. ArkTS项目可以在"@kit.PerformanceAnalysisKit"中导入对应模块即可在各种场景下调用对应函数,如在index.ets中直接调用,或者在EntryAbility.ets函数中在应用的各个生命周期内添加功能函数以实现应用自动在“启动”或“结束”时进行性能分析。 +1. C++项目可以在CMakeLists.txt里的target_link_libraries中添加对应功能的包,在napi_init.cpp中添加注册自定义C++功能函数(还需在index.d.ts中声明)后,即可在各种场景下通过"libentry.so"库自定义一个对象来调用注册声明的测试函数即可。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行; +2. 本示例已适配API20版本SDK,版本号:6.0.0.47,镜像版本号:OpenHarmony 6.0.0.47; +3. 本示例建议使用DevEco Studio(6.0.0.858)及以上版本编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/PerformanceAnalysisKit/HiDebugTool/ > .git/info/sparse-checkout +git remote add origin https://gitcode.com/openharmony/applications_app_samples.git +git pull origin master +``` + diff --git a/PerformanceAnalysisKit/HiDebugTool/build-profile.json5 b/PerformanceAnalysisKit/HiDebugTool/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fb528438ef5809443f8d9d90e5d6c9e6e83a038e --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/build-profile.json5 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.0(20)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/build-profile.json5 b/PerformanceAnalysisKit/HiDebugTool/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1e2ece10194943f2a5059c7bf3f7771b1b2c3d4e --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/build-profile.json5 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["arm64-v8a", "x86_64"] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/hvigorfile.ts b/PerformanceAnalysisKit/HiDebugTool/entry/hvigorfile.ts new file mode 100755 index 0000000000000000000000000000000000000000..cfa8a00f74f409d9647f55cdf270ab6aec69fe41 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/obfuscation-rules.txt b/PerformanceAnalysisKit/HiDebugTool/entry/obfuscation-rules.txt new file mode 100755 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/oh-package.json5 b/PerformanceAnalysisKit/HiDebugTool/entry/oh-package.json5 new file mode 100755 index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/oh-package.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/CMakeLists.txt b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..2316445c80dc7d36986ada78fe626d0a682fe634 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,16 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(CPP2) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +# 新增动态库依赖libohhidebug.so和libhilog_ndk.z.so(日志输出) +add_library(entry SHARED napi_init.cpp test_backtrace.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so libohhidebug.so) \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/napi_init.cpp b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/napi_init.cpp new file mode 100755 index 0000000000000000000000000000000000000000..2d0967c5b29053be5430e00d9ad7fb82c0d46543 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2025 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 "napi/native_api.h" + +// [Start TestHidebugNdk_Function] +#include +#include "hidebug/hidebug.h" +#include "hilog/log.h" +#include "test_backtrace.h" + +#undef LOG_TAG +#define LOG_TAG "testTag" + +__attribute((noinline)) __attribute((optnone)) void TestNativeFrames(int i) +{ + if (i > 0) { + TestNativeFrames(i - 1); + return; + } + BacktraceCurrentThread(); +} + +__attribute((noinline)) __attribute((optnone)) napi_value TestBackTrace(napi_env env, napi_callback_info info) +{ + TestNativeFrames(1); + return nullptr; +} + +napi_value TestGetThreadCpuUsage(napi_env env, napi_callback_info info) +{ + HiDebug_ThreadCpuUsagePtr cpuUsage = OH_HiDebug_GetAppThreadCpuUsage(); + while (cpuUsage != nullptr) { + OH_LOG_INFO(LogType::LOG_APP, + "GetAppThreadCpuUsage: threadId %{public}d, cpuUsage: %{public}f", cpuUsage->threadId, cpuUsage->cpuUsage); + cpuUsage = cpuUsage->next; // 获取下一个线程的cpu使用率对象指针。 + } + OH_HiDebug_FreeThreadCpuUsage(&cpuUsage); // 释放内存,防止内存泄露。 + return nullptr; +} +// [End TestHidebugNdk_Function] + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + // [Start TestHidebugNdk_Define] + napi_property_descriptor desc[] = { + { "testGetThreadCpuUsage", nullptr, TestGetThreadCpuUsage, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "testBackTrace", nullptr, TestBackTrace, nullptr, nullptr, nullptr, napi_default, nullptr }, + }; + // [End TestHidebugNdk_Define] + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/test_backtrace.cpp b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/test_backtrace.cpp new file mode 100755 index 0000000000000000000000000000000000000000..1176a12fe4017a96068a992cd1cf89409b186be0 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/test_backtrace.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2025 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. + */ + +// [Start TestHidebugNdk_Backtrace] +#include "test_backtrace.h" +#include +#include +#include +#include +#include "hidebug/hidebug.h" +#include "hilog/log.h" + +#define MAX_FRAME_SIZE 256 // 最大栈回溯深度,应根据业务场景调整该值。 + +namespace { + constexpr auto LOG_PRINT_DOMAIN = 0xFF00; +} + +class BackTraceObject { // 封装了抓栈过程中需要使用的资源,在使用过程中请注意线程安全和异步信号安全。 +public: + static BackTraceObject& GetInstance(); + BackTraceObject(const BackTraceObject&) = delete; + BackTraceObject& operator=(const BackTraceObject&) = delete; + BackTraceObject(BackTraceObject&&) = delete; + BackTraceObject& operator=(BackTraceObject&&) = delete; + bool Init(uint32_t size); + void Release(); + int BackTraceFromFp(void* startFp, int size); // 该函数异步信号安全。 + void SymbolicAddress(int index); // 该函数耗费性能,请避免频繁调用。 + void PrintStackFrame(void* pc, const HiDebug_StackFrame& frame); +private: + BackTraceObject() = default; + ~BackTraceObject() = default; + HiDebug_Backtrace_Object backtraceObject_ = nullptr; + void** pcs_ = nullptr; +}; + +BackTraceObject& BackTraceObject::GetInstance() // 单例模式,用于信号处理和请求抓栈线程的数据交互。注意该类非异步信号安全,业务逻辑应确保同一时刻仅单个线程访问。 +{ + static BackTraceObject instance; + return instance; +} + +bool BackTraceObject::Init(uint32_t size) // 初始化资源。 +{ + backtraceObject_ = OH_HiDebug_CreateBacktraceObject(); + if (backtraceObject_ == nullptr || size > MAX_FRAME_SIZE) { + return false; + } + pcs_ = new (std::nothrow) void* [size]{nullptr}; + if (pcs_ == nullptr) { + return false; + } + return true; +} + +void BackTraceObject::Release() // 释放资源。 +{ + OH_HiDebug_DestroyBacktraceObject(backtraceObject_); + backtraceObject_ = nullptr; + delete[] pcs_; + pcs_ = nullptr; +} + +int BackTraceObject::BackTraceFromFp(void* startFp, int size) // 栈回溯获取pc地址。 +{ + if (size <= MAX_FRAME_SIZE) { + return OH_HiDebug_BacktraceFromFp(backtraceObject_, startFp, pcs_, size); // OH_HiDebug_BacktraceFromFp接口调用示例。 + } + return 0; +} + +void BackTraceObject::PrintStackFrame(void* pc, const HiDebug_StackFrame& frame) // 输出栈内容。 +{ + if (frame.type == HIDEBUG_STACK_FRAME_TYPE_JS) { // 根据栈帧的类型,区分不同的栈帧输出方式。 + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "testTag", + "js stack frame info for pc: %{public}p is " + "relativePc: %{public}p " + "line: %{public}d " + "column: %{public}d " + "mapName: %{public}s " + "functionName: %{public}s " + "url: %{public}s " + "packageName: %{public}s.", + pc, + reinterpret_cast(frame.frame.js.relativePc), + frame.frame.js.line, + frame.frame.js.column, + frame.frame.js.mapName, + frame.frame.js.functionName, + frame.frame.js.url, + frame.frame.js.packageName); + } else { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "testTag", + "native stack frame info for pc: %{public}p is " + "relativePc: %{public}p " + "funcOffset: %{public}p " + "mapName: %{public}s " + "functionName: %{public}s " + "buildId: %{public}s " + "reserved: %{public}s.", + pc, + reinterpret_cast(frame.frame.native.relativePc), + reinterpret_cast(frame.frame.native.funcOffset), + frame.frame.native.mapName, + frame.frame.native.functionName, + frame.frame.native.buildId, + frame.frame.native.reserved); + } +} + +void BackTraceObject::SymbolicAddress(int index) // 栈解析接口。 +{ + if (index < 0 || index >= MAX_FRAME_SIZE) { + return; + } + OH_HiDebug_SymbolicAddress(backtraceObject_, pcs_[index], this, + [] (void* pc, void* arg, const HiDebug_StackFrame* frame) { + reinterpret_cast(arg)->PrintStackFrame(pc, *frame); + }); // 调用OH_HiDebug_SymbolicAddress接口解析栈。 +} + +void BacktraceCurrentThread() // 该接口非线程安全,同一时刻只能由一个线程使用。 +{ + if (!BackTraceObject::GetInstance().Init(MAX_FRAME_SIZE)) { // 注意:在调用栈回溯函数之前,需申请资源,且不可重复初始化。 + BackTraceObject::GetInstance().Release(); + OH_LOG_Print(LOG_APP, LOG_WARN, LOG_PRINT_DOMAIN, "testTag", "failed init backtrace object."); + return; + } + int pcSize = BackTraceObject::GetInstance().BackTraceFromFp(__builtin_frame_address(0), MAX_FRAME_SIZE); + for (int i = 0; i < pcSize; i++) { + BackTraceObject::GetInstance().SymbolicAddress(i); // 主线程获取pc后,对pc值进行栈解析。 + } + BackTraceObject::GetInstance().Release(); // 栈回溯并且解析结束后,及时释放资源。 +} +// [End TestHidebugNdk_Backtrace] \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/test_backtrace.h b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/test_backtrace.h new file mode 100755 index 0000000000000000000000000000000000000000..4623816515198dc950e0b90f52a269c9a4d862f4 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/test_backtrace.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 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. + */ + +// [Start TestHidebugNdk_Backtrace] +#ifndef MYAPPLICATION_TESTBACKTRACE_H +#define MYAPPLICATION_TESTBACKTRACE_H + +void BacktraceCurrentThread(); + +#endif // MYAPPLICATION_TESTBACKTRACE_H +// [End TestHidebugNdk_Backtrace] \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/types/libentry/Index.d.ts b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..52b84b6bbc67e0d1f7fab1981370257cc95c59bb --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 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. + */ + +// [Start TestHidebugNdk] +export const testGetThreadCpuUsage: () => void; +export const testBackTrace: () => void; +// [End TestHidebugNdk] \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/types/libentry/oh-package.json5 b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100755 index 0000000000000000000000000000000000000000..6abf3b7c20f22c62aaac6a995a25cae672f73f35 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100755 index 0000000000000000000000000000000000000000..c8a68f5689033b7e06d6991d63a50ce742e80bb5 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100755 index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/ets/pages/Index.ets b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/ets/pages/Index.ets new file mode 100755 index 0000000000000000000000000000000000000000..5d619eef0269e5b363ecbeec5169c585bb5cd3f4 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025 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. + */ + +// [Start TestHidebugArk_Import] +import { BusinessError } from '@kit.BasicServicesKit'; +import { hidebug, hilog } from '@kit.PerformanceAnalysisKit'; +// [End TestHidebugArk_Import] + +// [Start TestHidebugNdk_Import] +import testNapi from 'libentry.so'; +// [End TestHidebugNdk_Import] + +// [Start TestHidebugArk_Function] +function testHiDebugArk() { // 按照需要调用的接口实现 + try { + hilog.info(0x0000, 'testTag', `getSystemCpuUsage: ${hidebug.getSystemCpuUsage()}`); + } catch (error) { + hilog.info(0x0000, 'testTag', `error code: ${(error as BusinessError).code}, + error msg: ${(error as BusinessError).message}`); + } +} +// [End TestHidebugArk_Function] + +// [Start TestHidebugNdk_Function] +function testBackTraceJsFrame(i : number) : void { + if (i > 0) { + return testBackTraceJsFrame(i-1); + } + return testNapi.testBackTrace(); +} + +function testBackTrace() : void { + testBackTraceJsFrame(3); +} + +function testGetThreadCpuUsage() : void { + testNapi.testGetThreadCpuUsage(); +} +// [End TestHidebugNdk_Function] + +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + // [Start TestHidebugArk_Button] + Button('testHiDebugArk') + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('60%') + .height('5%') + // 添加点击事件 + .onClick(testHiDebugArk); + // [End TestHidebugArk_Button] + + // [Start TestHidebugNdk_Buttons] + Button('testGetThreadCpuUsage') + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('60%') + .height('5%') + // 添加点击事件 + .onClick(testGetThreadCpuUsage); + + Button('testHiDebugBackTrace') + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('60%') + .height('5%') + // 添加点击事件 + .onClick(testBackTrace); + // [End TestHidebugNdk_Buttons] + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/module.json5 b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/module.json5 new file mode 100755 index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/element/color.json b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/element/color.json new file mode 100755 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/element/float.json b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/element/float.json new file mode 100755 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/element/string.json b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d628fc47440d210e8f27344b50782e647277bdd4 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "HiDebugTool" + } + ] +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/background.png b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/background.png new file mode 100755 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/background.png differ diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/foreground.png b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/foreground.png new file mode 100755 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/foreground.png differ diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/layered_image.json b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/layered_image.json new file mode 100755 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/startIcon.png b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/startIcon.png new file mode 100755 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/media/startIcon.png differ diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/profile/backup_config.json b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/profile/backup_config.json new file mode 100755 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/profile/main_pages.json b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/dark/element/color.json b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/dark/element/color.json new file mode 100755 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/en_US/element/string.json b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/en_US/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d628fc47440d210e8f27344b50782e647277bdd4 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "HiDebugTool" + } + ] +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/zh_CN/element/string.json b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/zh_CN/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0bfce12d941c55746ebe01265862d118020f4b93 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "HiDebug示例" + } + ] +} \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/hvigor/hvigor-config.json5 b/PerformanceAnalysisKit/HiDebugTool/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/PerformanceAnalysisKit/HiDebugTool/hvigorfile.ts b/PerformanceAnalysisKit/HiDebugTool/hvigorfile.ts new file mode 100755 index 0000000000000000000000000000000000000000..4cfc811670f43a9427793854a1ff54dc587007c8 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceAnalysisKit/HiDebugTool/oh-package.json5 b/PerformanceAnalysisKit/HiDebugTool/oh-package.json5 new file mode 100755 index 0000000000000000000000000000000000000000..952ab183532e81c9c50e5de1e64393704e1e48fe --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.18", + "@ohos/hamock": "1.0.0" + } +} diff --git a/PerformanceAnalysisKit/HiDebugTool/ohosTest.md b/PerformanceAnalysisKit/HiDebugTool/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..ceb8bc593156530ee1566d31ac1b16c3b1e68cf0 --- /dev/null +++ b/PerformanceAnalysisKit/HiDebugTool/ohosTest.md @@ -0,0 +1,8 @@ +# 性能分析工具测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------ | ------------ | ------------------------------ | ------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 否 | Pass | +| 主页按钮点击 | 位于主页 | 按readme的使用说明依次点击按钮 | 输出预期日志 | 否 | Pass | \ No newline at end of file diff --git a/PerformanceAnalysisKit/HiDebugTool/screenshots/screenShot_20251022_154442.jpeg b/PerformanceAnalysisKit/HiDebugTool/screenshots/screenShot_20251022_154442.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..238baec0281bcccbb2339c80f9f755a00bafb590 Binary files /dev/null and b/PerformanceAnalysisKit/HiDebugTool/screenshots/screenShot_20251022_154442.jpeg differ