mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-22 22:40:48 +00:00
Merge branch 'master' of gitee.com:openharmony/developtools_profiler into master
Signed-off-by: wenlong_12 <wenlong12@huawei.com>
This commit is contained in:
commit
46954a9fb1
@ -72,7 +72,7 @@ ohos_source_set("hiprofiler_base") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
|
@ -438,6 +438,37 @@ bool CheckApplicationPermission(int pid, const std::string& processName)
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* RealPath(std::string &filePath)
|
||||
{
|
||||
if (filePath.size() > 0 && (filePath.back() == '/' || filePath.back() == '.')) {
|
||||
return nullptr;
|
||||
}
|
||||
if (filePath.find('.') == -1) {
|
||||
return filePath.c_str();
|
||||
}
|
||||
std::vector<std::string> paths;
|
||||
SplitString(filePath, "/", paths);
|
||||
std::vector<std::string> validPaths;
|
||||
for (std::string& pathName: paths) {
|
||||
if (pathName == "..") {
|
||||
if (validPaths.size() == 0) {
|
||||
return nullptr;
|
||||
} else {
|
||||
validPaths.pop_back();
|
||||
}
|
||||
} else {
|
||||
validPaths.emplace_back(pathName);
|
||||
}
|
||||
}
|
||||
filePath = "/";
|
||||
for (std::string &pathName : validPaths) {
|
||||
filePath += pathName;
|
||||
filePath += "/";
|
||||
}
|
||||
filePath.pop_back();
|
||||
return filePath.c_str();
|
||||
}
|
||||
|
||||
bool VerifyPath(const std::string& filePath, const std::vector<std::string>& validPaths)
|
||||
{
|
||||
if (validPaths.size() == 0) {
|
||||
@ -454,11 +485,11 @@ bool VerifyPath(const std::string& filePath, const std::vector<std::string>& val
|
||||
|
||||
bool ReadFile(const std::string &filePath, const std::vector<std::string>& validPaths, std::string& fileContent)
|
||||
{
|
||||
char* realFilePath = realpath(filePath.c_str(), nullptr);
|
||||
std::string pathName = filePath;
|
||||
const char* realFilePath = RealPath(pathName);
|
||||
CHECK_NOTNULL(realFilePath, false, "Fail to realPath: %s", filePath.c_str());
|
||||
|
||||
std::string realFilePathStr(realFilePath);
|
||||
free(realFilePath);
|
||||
CHECK_TRUE(VerifyPath(realFilePathStr, validPaths), false, "Fail to VerifyPath: %s", realFilePathStr.c_str());
|
||||
|
||||
std::ifstream fileStream(realFilePathStr, std::ios::in);
|
||||
|
@ -61,7 +61,7 @@ ohos_unittest("hiprofiler_cmd_ut") {
|
||||
]
|
||||
external_deps = [
|
||||
"abseil-cpp:absl_sync",
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"grpc:grpc",
|
||||
"grpc:grpcxx",
|
||||
|
@ -60,7 +60,7 @@ ohos_source_set("plugins_sources") {
|
||||
]
|
||||
if (current_toolchain != host_toolchain) {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"openssl:libcrypto_shared",
|
||||
"protobuf:protobuf",
|
||||
@ -86,7 +86,7 @@ ohos_executable("hiprofiler_plugins") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"openssl:libcrypto_shared",
|
||||
"protobuf:protobuf",
|
||||
|
@ -40,7 +40,7 @@ ohos_source_set("arkts_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines += [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"openssl:libcrypto_shared",
|
||||
]
|
||||
@ -57,7 +57,7 @@ ohos_shared_library("arktsplugin") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"openssl:libcrypto_shared",
|
||||
]
|
||||
|
@ -42,7 +42,7 @@ ohos_unittest("arktsplugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"openssl:libcrypto_shared",
|
||||
|
@ -34,7 +34,7 @@ ohos_shared_library("bytraceplugin") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -48,7 +48,7 @@ ohos_shared_library("cpudataplugin") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
}
|
||||
@ -70,7 +70,7 @@ ohos_executable("cpudataplugintest") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -44,7 +44,7 @@ ohos_unittest("cpudataplugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -29,9 +29,9 @@ ohos_fuzztest("CpuStartPluginFuzzTest") {
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/cpu_data:cpu_data_cpp",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
"protobuf:protobuf_lite",
|
||||
|
@ -51,7 +51,7 @@ ohos_shared_library("diskiodataplugin") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ ohos_unittest("diskiodataplugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -29,9 +29,9 @@ ohos_fuzztest("DiskioStartPluginFuzzTest") {
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/diskio_plugin:diskiodataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/diskio_data:diskio_data_cpp",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
"protobuf:protobuf_lite",
|
||||
|
@ -57,7 +57,7 @@ ohos_shared_library("libffrt_profiler") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
|
||||
|
@ -49,7 +49,7 @@ ohos_source_set("ffrt_profiler_service") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"init:libbegetutil",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -32,7 +32,7 @@ ohos_executable("ffrt_profiler_test_exe") {
|
||||
external_deps = []
|
||||
|
||||
external_deps += [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"ffrt:libffrt",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
|
@ -51,7 +51,7 @@ ohos_source_set("ftrace_plugin_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines += [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"hiview:libucollection_client",
|
||||
"init:libbegetutil",
|
||||
|
@ -61,7 +61,7 @@ bool FtraceFsOps::IsHmKernel()
|
||||
utsname unameBuf;
|
||||
if ((uname(&unameBuf)) == 0) {
|
||||
std::string osRelease = unameBuf.release;
|
||||
isHM = osRelease.find("hmkernel") != std::string::npos;
|
||||
isHM = osRelease.find("HongMeng") != std::string::npos;
|
||||
}
|
||||
return isHM;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ ohos_unittest("ftrace_plugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"hiview:libucollection_client",
|
||||
|
@ -36,7 +36,7 @@ ohos_source_set("gpudataplugin_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -41,7 +41,7 @@ ohos_unittest("gpudataplugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -33,7 +33,7 @@ ohos_source_set("hidumpplugin_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -40,7 +40,7 @@ ohos_unittest("hidumpplugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -31,7 +31,7 @@ ohos_fuzztest("HidumpStartPluginFuzzTest") {
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/hidump_data:hidump_data_cpp",
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"openssl:libcrypto_shared",
|
||||
"protobuf:protobuf",
|
||||
|
@ -39,7 +39,7 @@ ohos_source_set("hiebpfplugin_source") {
|
||||
"LITE_PROTO",
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"openssl:libcrypto_shared",
|
||||
]
|
||||
|
@ -50,7 +50,7 @@ ohos_executable("ebpf_converter") {
|
||||
|
||||
sources = [ "src/ebpf_converter.cpp" ]
|
||||
include_dirs = [ "./include" ]
|
||||
external_deps = [ "bounds_checking_function:libsec_static" ]
|
||||
external_deps = [ "bounds_checking_function:libsec_shared" ]
|
||||
install_enable = false
|
||||
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
|
||||
part_name = "${OHOS_PROFILER_PART_NAME}"
|
||||
|
@ -36,7 +36,7 @@ ohos_source_set("hilogplugin_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -40,7 +40,7 @@ ohos_unittest("hilogplugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -29,9 +29,9 @@ ohos_fuzztest("HilogStartPluginFuzzTest") {
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/hilog_plugin:hilogplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/hilog_data:hilog_data_cpp",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
"protobuf:protobuf_lite",
|
||||
|
@ -45,7 +45,7 @@ ohos_source_set("hiperfplugin_source") {
|
||||
"LITE_PROTO",
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"openssl:libcrypto_shared",
|
||||
"protobuf:protobuf_lite",
|
||||
|
@ -36,7 +36,7 @@ ohos_source_set("hisyseventplugin_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -40,7 +40,7 @@ ohos_unittest("hisyseventplugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -37,7 +37,7 @@ ohos_source_set("memdataplugin_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"c_utils:utils",
|
||||
"drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
|
||||
"graphic_2d:librender_service_client",
|
||||
@ -76,7 +76,7 @@ ohos_executable("memorytest") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ ohos_unittest("memdataplugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"c_utils:utils",
|
||||
"drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
|
||||
"googletest:gtest",
|
||||
@ -77,7 +77,7 @@ ohos_unittest("smaps_stats_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"c_utils:utils",
|
||||
"drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
|
||||
"googletest:gtest",
|
||||
|
@ -30,10 +30,10 @@ ohos_fuzztest("MemoryStartPluginFuzzTest") {
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/memory_plugin:memdataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/memory_data:memory_data_cpp",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
|
@ -125,7 +125,7 @@ ohos_executable("native_daemon") {
|
||||
"ability_base:extractortool",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtoken_setproc",
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"openssl:libcrypto_shared",
|
||||
|
@ -72,6 +72,8 @@ enum {
|
||||
THREAD_NAME_MSG,
|
||||
PR_SET_VMA_MSG,
|
||||
JS_STACK_MSG,
|
||||
NMD_MSG,
|
||||
END_MSG,
|
||||
};
|
||||
|
||||
struct alignas(8) MmapFileRawData { // 8 is 8 bit
|
||||
@ -145,6 +147,8 @@ struct alignas(8) ClientConfig { // 8 is 8 bit
|
||||
memtraceEnable = false;
|
||||
responseLibraryMode = false;
|
||||
freeEventOnlyAddrEnable = false;
|
||||
printNmd = false;
|
||||
nmdType = -1;
|
||||
arktsConfig.jsStackReport = 0;
|
||||
arktsConfig.maxJsStackDepth = 0;
|
||||
arktsConfig.jsFpunwind = false;
|
||||
@ -181,6 +185,8 @@ struct alignas(8) ClientConfig { // 8 is 8 bit
|
||||
bool memtraceEnable = false;
|
||||
bool responseLibraryMode = false;
|
||||
bool freeEventOnlyAddrEnable = false;
|
||||
bool printNmd = false;
|
||||
int nmdType = -1;
|
||||
ArkTsClientConfig arktsConfig = {0};
|
||||
};
|
||||
#endif // HOOK_COMMON_H
|
@ -101,7 +101,7 @@ public:
|
||||
int32_t CreatePluginSession();
|
||||
void RegisterWriter(const std::shared_ptr<Writer> writer);
|
||||
void WriteHookConfig();
|
||||
std::vector<int> GetFds(int32_t pid, const std::string& name);
|
||||
std::pair<int, int> GetFds(int32_t pid, const std::string& name);
|
||||
inline void SetSaServiceConfig(bool saFlag, bool isProtobufSerialize)
|
||||
{
|
||||
isSaService_ = saFlag;
|
||||
@ -112,7 +112,6 @@ public:
|
||||
{
|
||||
return noDataQueue_;
|
||||
}
|
||||
bool PrintStat(uint32_t fd, int type);
|
||||
void SetPid(int pid)
|
||||
{
|
||||
pid_ = pid;
|
||||
@ -149,7 +148,6 @@ private:
|
||||
std::shared_ptr<Writer> writer_{nullptr};
|
||||
constexpr static uint32_t MAX_BUFFER_SIZE = 100 * 1024 * 1024;
|
||||
uint64_t shareMemorySize_{MAX_BUFFER_SIZE};
|
||||
std::shared_ptr<ShareMemoryBlock> shareMemoryNmd_ = nullptr;
|
||||
NmdParam nmdParamInfo_;
|
||||
};
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "native_hook_result.pb.h"
|
||||
#include "native_hook_result.pbencoder.h"
|
||||
#include "safe_map.h"
|
||||
#include "schedule_task_manager.h"
|
||||
|
||||
using WriterStructPtr = std::unique_ptr<WriterStruct>::pointer;
|
||||
class StackPreprocess {
|
||||
@ -59,10 +60,15 @@ public:
|
||||
void FinishTraceFile();
|
||||
bool FlushRecordStatistics();
|
||||
void FlushRecordApplyAndReleaseMatchData();
|
||||
void ForceStop();
|
||||
inline void SetPid(int32_t pid)
|
||||
{
|
||||
pid_ = pid;
|
||||
}
|
||||
inline void InitStatisticsTime()
|
||||
{
|
||||
lastStatisticsTime_ = std::chrono::steady_clock::now();
|
||||
}
|
||||
void SaveMemTag(uint32_t tagId, const std::string& tagName);
|
||||
bool GetMemTag(uint32_t tagId, std::string& tagName);
|
||||
void SaveJsRawStack(uint64_t jsChainId, const char* jsRawStack);
|
||||
@ -70,6 +76,10 @@ public:
|
||||
void ReportBasicData();
|
||||
void WriteHookConfig();
|
||||
void TakeResultsFromShmem(const std::shared_ptr<EventNotifier>&, const std::shared_ptr<ShareMemoryBlock>&);
|
||||
void SetNmdFd(uint32_t fd)
|
||||
{
|
||||
nmdFd_ = fd;
|
||||
}
|
||||
void SetFlushSize(uint64_t size)
|
||||
{
|
||||
double tenth = static_cast<double>(size) / 10.0;
|
||||
@ -173,6 +183,7 @@ private:
|
||||
void FillDwarfErrorStack();
|
||||
void FillNapiStack(std::string& tagName, std::vector<CallFrame>& callFrames, uint64_t napiIndex);
|
||||
private:
|
||||
std::chrono::steady_clock::time_point lastStatisticsTime_ = std::chrono::steady_clock::now();
|
||||
std::shared_ptr<Writer> writer_ = nullptr;
|
||||
StackDataRepeaterPtr dataRepeater_ = nullptr;
|
||||
std::thread thread_ {};
|
||||
@ -228,6 +239,8 @@ private:
|
||||
std::vector<std::string> prctlPeriodTags_; // applyAndReleaseMatchInterval mode used
|
||||
std::vector<std::string> fpJsCallStacks_;
|
||||
std::atomic<uint64_t> napiIndex_{1};
|
||||
ScheduleTaskManager scheduleTaskManager_;
|
||||
uint32_t nmdFd_ = 0;
|
||||
};
|
||||
|
||||
#endif // STACK_PREPROCESS_H
|
@ -164,11 +164,8 @@ int32_t main(int32_t argc, char* argv[])
|
||||
close(fd);
|
||||
} else if (config->printNmd_) {
|
||||
uint32_t fdFirst = TestDumpFile(std::to_string(0));
|
||||
uint32_t fdSecond = TestDumpFile(std::to_string(1));
|
||||
NativeMemoryProfilerSaClientManager::GetMallocStats(fdFirst, config->pid_, 0);
|
||||
NativeMemoryProfilerSaClientManager::GetMallocStats(fdSecond, config->pid_, 1);
|
||||
close(fdFirst);
|
||||
close(fdSecond);
|
||||
} else {
|
||||
NativeMemoryProfilerSaClientManager::Start(config);
|
||||
}
|
||||
|
@ -143,13 +143,6 @@ void NativeMemoryProfilerSaService::StopHook(uint32_t pid, std::string name, boo
|
||||
return;
|
||||
}
|
||||
|
||||
if (config->hookMgr->GetPid() > 0) {
|
||||
std::lock_guard<std::mutex> nmdGuard(nmdMtx_);
|
||||
if (nmdPidType_.find(config->hookMgr->GetPid()) != nmdPidType_.end()) {
|
||||
config->hookMgr->SetNmdInfo(nmdPidType_[config->hookMgr->GetPid()]);
|
||||
}
|
||||
}
|
||||
|
||||
config->hookMgr->StopPluginSession({});
|
||||
config->hookMgr->DestroyPluginSession({});
|
||||
if (timeout) {
|
||||
@ -208,6 +201,12 @@ int32_t NativeMemoryProfilerSaService::StartHook(std::shared_ptr<NativeMemoryPro
|
||||
hook->RegisterWriter(writeFile);
|
||||
hook->SetHookConfig(config);
|
||||
hook->SetSaServiceConfig(true, false);
|
||||
if (config->pid_ > 0) {
|
||||
std::lock_guard<std::mutex> nmdGuard(nmdMtx_);
|
||||
if (nmdPidType_.find(config->pid_) != nmdPidType_.end()) {
|
||||
hook->SetNmdInfo(nmdPidType_[config->pid_]);
|
||||
}
|
||||
}
|
||||
if (hook->CreatePluginSession() != RET_OK) {
|
||||
return RET_ERR;
|
||||
}
|
||||
@ -339,11 +338,8 @@ bool NativeMemoryProfilerSaService::ProtocolProc(SocketContext &context, uint32_
|
||||
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
if (auto iter = pidCtx_.find(peerConfig); iter != pidCtx_.end()) {
|
||||
std::vector<int> vec = iter->second->hookMgr->GetFds(peerConfig, bundleName);
|
||||
auto [eventFd, smbFd] = iter->second->hookMgr->GetFds(peerConfig, bundleName);
|
||||
iter->second->hookMgr->SetPid(peerConfig);
|
||||
auto eventFd = vec[0];
|
||||
auto smbFd = vec[1];
|
||||
auto nmdFd = vec[2];
|
||||
if (eventFd == smbFd) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE,
|
||||
"Get eventFd and smbFd failed!, name: %s, pid: %d", bundleName.c_str(), peerConfig);
|
||||
@ -360,7 +356,6 @@ bool NativeMemoryProfilerSaService::ProtocolProc(SocketContext &context, uint32_
|
||||
context.SendHookConfig(reinterpret_cast<uint8_t *>(&clientConfig), sizeof(clientConfig));
|
||||
context.SendFileDescriptor(smbFd);
|
||||
context.SendFileDescriptor(eventFd);
|
||||
context.SendFileDescriptor(nmdFd);
|
||||
iter->second->hookMgr->ResetStartupParam();
|
||||
} else {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "ProtocolProc: send config failed");
|
||||
|
@ -124,7 +124,7 @@ ohos_unittest("native_memory_profiler_sa_ut") {
|
||||
"ability_base:extractortool",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtoken_setproc",
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"c_utils:utils",
|
||||
"googletest:gtest",
|
||||
"init:libbegetutil",
|
||||
|
@ -47,9 +47,6 @@ constexpr int SIGNAL_STOP_HOOK = 37;
|
||||
const std::string VERSION = "1.02";
|
||||
constexpr int32_t RESPONSE_MAX_PID_COUNT = 8;
|
||||
constexpr int32_t MAX_PID_COUNT = 4;
|
||||
constexpr uint32_t SHARED_MEMORY_SIZE = 307200;
|
||||
constexpr uint32_t WAIT_TIME = 100;
|
||||
constexpr uint32_t MAX_WAIT_TIME = 500;
|
||||
}
|
||||
|
||||
HookManager::~HookManager()
|
||||
@ -234,6 +231,8 @@ void HookManager::GetClientConfig(ClientConfig& clientConfig)
|
||||
clientConfig.sampleInterval = hookConfig_.sample_interval();
|
||||
clientConfig.responseLibraryMode = hookConfig_.response_library_mode();
|
||||
clientConfig.arktsConfig.jsStackReport = hookConfig_.js_stack_report();
|
||||
clientConfig.printNmd = printMallocNmd_;
|
||||
clientConfig.nmdType = nmdParamInfo_.type;
|
||||
// -1 is save '\0'
|
||||
int ret = memcpy_s(clientConfig.arktsConfig.filterNapiName, sizeof(clientConfig.arktsConfig.filterNapiName) - 1,
|
||||
hookConfig_.filter_napi_name().c_str(), hookConfig_.filter_napi_name().size());
|
||||
@ -288,6 +287,7 @@ bool HookManager::HandleHookContext(const std::shared_ptr<HookManagerCtx>& ctx)
|
||||
ctx->stackPreprocess = std::make_shared<StackPreprocess>(nullptr, hookConfig_, pluginDataClockId,
|
||||
fpHookData_, isHookStandalone_, isSaService_, isProtobufSerialize_);
|
||||
ctx->stackPreprocess->SetFlushSize(shareMemorySize_);
|
||||
ctx->stackPreprocess->SetNmdFd(nmdParamInfo_.fd);
|
||||
ctx->eventPoller->AddFileDescriptor(
|
||||
ctx->eventNotifier->GetFd(),
|
||||
std::bind(&StackPreprocess::TakeResultsFromShmem, ctx->stackPreprocess,
|
||||
@ -428,6 +428,16 @@ void HookManager::ReadShareMemory(const std::shared_ptr<HookManagerCtx>& hookCtx
|
||||
"memcpy_s raw data failed!");
|
||||
|
||||
rawStack->stackConext = reinterpret_cast<BaseStackRawData*>(rawStack->baseStackData.get());
|
||||
|
||||
if (rawStack->stackConext->type == NMD_MSG && printMallocNmd_) {
|
||||
rawStack->data = rawStack->baseStackData.get() + sizeof(BaseStackRawData);
|
||||
const char* nmdResult = reinterpret_cast<const char*>(rawStack->data);
|
||||
lseek(nmdParamInfo_.fd, 0, SEEK_END);
|
||||
(void)write(nmdParamInfo_.fd, nmdResult, strlen(nmdResult));
|
||||
return true;
|
||||
} else if (rawStack->stackConext->type == END_MSG) {
|
||||
return true;
|
||||
}
|
||||
rawStack->data = rawStack->baseStackData.get() + sizeof(BaseStackRawData);
|
||||
rawStack->reportFlag = true;
|
||||
if (rawStack->stackConext->type == MEMORY_TAG || rawStack->stackConext->type == THREAD_NAME_MSG ||
|
||||
@ -463,6 +473,16 @@ void HookManager::ReadShareMemory(const std::shared_ptr<HookManagerCtx>& hookCtx
|
||||
hookCtx->stackPreprocess->SaveJsRawStack(rawStack->stackConext->jsChainId,
|
||||
reinterpret_cast<char*>(rawStack->data));
|
||||
continue;
|
||||
} else if (rawStack->stackConext->type == END_MSG) {
|
||||
if (!hookCtx->stackData->PutRawStack(rawStack, hookCtx->isRecordAccurately)) {
|
||||
break;
|
||||
}
|
||||
if (!hookCtx->stackData->PutRawStack(nullptr, false)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
} else if (rawStack->stackConext->type == NMD_MSG) {
|
||||
continue;
|
||||
}
|
||||
if (!hookCtx->stackData->PutRawStack(rawStack, hookCtx->isRecordAccurately)) {
|
||||
break;
|
||||
@ -534,21 +554,6 @@ bool HookManager::StopPluginSession(const std::vector<uint32_t>& pluginIds)
|
||||
}
|
||||
item->stackPreprocess->FinishTraceFile();
|
||||
}
|
||||
|
||||
if (printMallocNmd_) {
|
||||
if (nmdParamInfo_.fd == 0) {
|
||||
return false;
|
||||
}
|
||||
if (nmdParamInfo_.type == 0) {
|
||||
PrintStat(nmdParamInfo_.fd, 0);
|
||||
} else if (nmdParamInfo_.type == 1) {
|
||||
uint32_t waitTime = 0;
|
||||
while ((!PrintStat(nmdParamInfo_.fd, 1)) && waitTime < MAX_WAIT_TIME) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME));
|
||||
waitTime += WAIT_TIME;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -665,6 +670,7 @@ void HookManager::StartPluginSession()
|
||||
if (!noDataQueue_) {
|
||||
item->stackPreprocess->StartTakeResults();
|
||||
}
|
||||
item->stackPreprocess->InitStatisticsTime();
|
||||
if (item->pid > 0) {
|
||||
PROFILER_LOG_INFO(LOG_CORE, "start command : send 36 signal to process %d", item->pid);
|
||||
if (kill(item->pid, SIGNAL_START_HOOK) == -1) {
|
||||
@ -690,35 +696,18 @@ void HookManager::WriteHookConfig()
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> HookManager::GetFds(int32_t pid, const std::string& name)
|
||||
std::pair<int, int> HookManager::GetFds(int32_t pid, const std::string& name)
|
||||
{
|
||||
shareMemoryNmd_ = ShareMemoryAllocator::GetInstance().CreateMemoryBlockLocal("nmd " + std::to_string(pid),
|
||||
SHARED_MEMORY_SIZE);
|
||||
for (const auto& item : hookCtx_) {
|
||||
if (item->pid == pid || item->processName == name) {
|
||||
if (item->pid == -1) {
|
||||
item->pid = pid;
|
||||
}
|
||||
item->stackPreprocess->SetPid(pid);
|
||||
return {item->eventNotifier->GetFd(), item->shareMemoryBlock->GetfileDescriptor(),
|
||||
shareMemoryNmd_->GetfileDescriptor()};
|
||||
return {item->eventNotifier->GetFd(), item->shareMemoryBlock->GetfileDescriptor()};
|
||||
}
|
||||
}
|
||||
return {-1, -1, -1};
|
||||
}
|
||||
|
||||
bool HookManager::PrintStat(uint32_t fd, int type)
|
||||
{
|
||||
CHECK_NOTNULL(shareMemoryNmd_, false, "PrintStat failed, sharedMemoryNmd empty");
|
||||
bool ret = shareMemoryNmd_->TakeData(
|
||||
[&](const int8_t data[], uint32_t size) -> bool {
|
||||
const char* result = reinterpret_cast<const char*>(data);
|
||||
lseek(fd, 0, SEEK_END);
|
||||
(void)write(fd, result, strlen(result));
|
||||
return true;
|
||||
}
|
||||
);
|
||||
return ret;
|
||||
return {-1, -1};
|
||||
}
|
||||
|
||||
void HookManager::SetNmdInfo(std::pair<uint32_t, uint32_t> info)
|
||||
|
@ -88,10 +88,7 @@ bool HookService::ProtocolProc(SocketContext &context, uint32_t pnum, const int8
|
||||
return false;
|
||||
}
|
||||
firstProcess = false;
|
||||
std::vector<int> vec = hookMgr_->GetFds(peerConfig, procName);
|
||||
auto eventFd = vec[0];
|
||||
auto smbFd = vec[1];
|
||||
auto nmdFd = vec[2];
|
||||
auto [eventFd, smbFd] = hookMgr_->GetFds(peerConfig, procName);
|
||||
if (eventFd == smbFd) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "Get eventFd and smbFd failed!, name: %s, pid: %d", procName.c_str(), peerConfig);
|
||||
return false;
|
||||
@ -102,7 +99,6 @@ bool HookService::ProtocolProc(SocketContext &context, uint32_t pnum, const int8
|
||||
context.SendHookConfig(reinterpret_cast<uint8_t *>(&clientConfig_), sizeof(clientConfig_));
|
||||
context.SendFileDescriptor(smbFd);
|
||||
context.SendFileDescriptor(eventFd);
|
||||
context.SendFileDescriptor(nmdFd);
|
||||
hookMgr_->ResetStartupParam();
|
||||
return true;
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ constexpr static uint32_t LG_TINY_MAXCLASS = 3;
|
||||
constexpr static uint32_t MAX_MATCH_CNT = 1000;
|
||||
constexpr static uint32_t MAX_MATCH_INTERVAL = 3600;
|
||||
constexpr static uint32_t LOG_PRINT_TIMES = 10000;
|
||||
constexpr static uint32_t WAIT_STOP_TIME = 5000;
|
||||
constexpr static uint32_t WAIT_TIME_ONCE = 10;
|
||||
constexpr static uint32_t MAX_BATCH_CNT = 20;
|
||||
constexpr static uint32_t RIGHT_MOVE_1 = 1;
|
||||
constexpr static uint32_t RIGHT_MOVE_2 = 2;
|
||||
@ -176,15 +178,21 @@ bool StackPreprocess::StartTakeResults()
|
||||
bool StackPreprocess::StopTakeResults()
|
||||
{
|
||||
PROFILER_LOG_INFO(LOG_CORE, "start StopTakeResults");
|
||||
int32_t timerFd = scheduleTaskManager_.ScheduleTask(
|
||||
std::bind(&StackPreprocess::ForceStop, this), WAIT_STOP_TIME, true, false);
|
||||
if (timerFd == -1) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "StopTakeResults ScheduleTask failed!");
|
||||
return false;
|
||||
}
|
||||
if (!dataRepeater_) {
|
||||
isStopTakeData_ = true;
|
||||
while (!isStopTakeData_) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME_ONCE));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
CHECK_NOTNULL(dataRepeater_, false, "data repeater null");
|
||||
CHECK_TRUE(thread_.get_id() != std::thread::id(), false, "thread invalid");
|
||||
|
||||
isStopTakeData_ = true;
|
||||
dataRepeater_->PutRawStack(nullptr, false);
|
||||
PROFILER_LOG_INFO(LOG_CORE, "StopTakeResults Wait thread join");
|
||||
|
||||
if (thread_.joinable()) {
|
||||
@ -198,11 +206,10 @@ inline void StackPreprocess::IntervalFlushRecordStatistics()
|
||||
{
|
||||
// interval reporting statistics
|
||||
if (hookConfig_.statistics_interval() > 0) {
|
||||
static auto lastStatisticsTime = std::chrono::steady_clock::now();
|
||||
auto currentTime = std::chrono::steady_clock::now();
|
||||
auto elapsedTime = std::chrono::duration_cast<std::chrono::seconds>(currentTime - lastStatisticsTime);
|
||||
auto elapsedTime = std::chrono::duration_cast<std::chrono::seconds>(currentTime - lastStatisticsTime_);
|
||||
if (elapsedTime >= statisticsInterval_) {
|
||||
lastStatisticsTime = currentTime;
|
||||
lastStatisticsTime_ = currentTime;
|
||||
FlushRecordStatistics();
|
||||
}
|
||||
}
|
||||
@ -245,6 +252,14 @@ bool StackPreprocess::HandleNoStackEvent(RawStackPtr& rawData)
|
||||
return true;
|
||||
}
|
||||
|
||||
void StackPreprocess::ForceStop()
|
||||
{
|
||||
isStopTakeData_ = true;
|
||||
if (dataRepeater_ != nullptr) {
|
||||
dataRepeater_->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void StackPreprocess::TakeResultsFromShmem(const std::shared_ptr<EventNotifier>& eventNotifier,
|
||||
const std::shared_ptr<ShareMemoryBlock>& shareMemoryBlock)
|
||||
{
|
||||
@ -291,6 +306,14 @@ void StackPreprocess::TakeResultsFromShmem(const std::shared_ptr<EventNotifier>&
|
||||
} else if (rawData->stackConext->type == MUNMAP_MSG) {
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
runtime_instance->RemoveMaps(reinterpret_cast<uint64_t>(rawData->stackConext->addr));
|
||||
} else if (rawData->stackConext->type == NMD_MSG) {
|
||||
const char* nmdResult = reinterpret_cast<const char*>(rawData->data);
|
||||
lseek(nmdFd_, 0, SEEK_END);
|
||||
(void)write(nmdFd_, nmdResult, strlen(nmdResult));
|
||||
return true;
|
||||
} else if (rawData->stackConext->type == END_MSG) {
|
||||
isStopTakeData_ = true;
|
||||
return true;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mtx_);
|
||||
@ -341,9 +364,12 @@ void StackPreprocess::TakeResults()
|
||||
PROFILER_LOG_INFO(LOG_CORE, "TakeResults thread %d, start!", gettid());
|
||||
while (1) {
|
||||
RawStackPtr batchRawStack[MAX_BATCH_CNT] = {nullptr};
|
||||
if (isStopTakeData_) {
|
||||
break;
|
||||
}
|
||||
auto result = dataRepeater_->TakeRawData(hookConfig_.malloc_free_matching_interval(), hookDataClockId_,
|
||||
MAX_BATCH_CNT, batchRawStack);
|
||||
if (!result || isStopTakeData_) {
|
||||
if (!result) {
|
||||
break;
|
||||
}
|
||||
for (unsigned int i = 0; i < MAX_BATCH_CNT; i++) {
|
||||
@ -351,6 +377,12 @@ void StackPreprocess::TakeResults()
|
||||
if (!rawData || isStopTakeData_) {
|
||||
break;
|
||||
}
|
||||
if (rawData->stackConext->type == NMD_MSG) {
|
||||
continue;
|
||||
} else if (rawData->stackConext->type == END_MSG) {
|
||||
isStopTakeData_ = true;
|
||||
break;
|
||||
}
|
||||
#ifdef PERFORMANCE_DEBUG
|
||||
struct timespec start = {};
|
||||
clock_gettime(CLOCK_REALTIME, &start);
|
||||
@ -578,9 +610,13 @@ inline uint32_t StackPreprocess::GetCallStackId(const RawStackPtr& rawStack, std
|
||||
callStack_.clear();
|
||||
bool isNapi = false;
|
||||
if (rawStack->stackConext->type == MEMORY_USING_MSG && hookConfig_.js_stack_report() == NAPI_CALL_STACK) {
|
||||
callStack_.reserve(callFrames.size() + 1); // 1 : insert a frame
|
||||
callStack_.push_back((DWARF_NAPI_CALLBACK + napiIndex_) | JS_OFFLINE_IP_MASK);
|
||||
isNapi = true;
|
||||
std::string tagName;
|
||||
GetMemTag(rawStack->stackConext->tagId, tagName);
|
||||
if (tagName.find("napi") != std::string::npos) {
|
||||
callStack_.reserve(callFrames.size() + 1); // 1 : insert a frame
|
||||
callStack_.push_back((DWARF_NAPI_CALLBACK + napiIndex_) | JS_OFFLINE_IP_MASK);
|
||||
isNapi = true;
|
||||
}
|
||||
} else {
|
||||
callStack_.reserve(callFrames.size());
|
||||
}
|
||||
@ -701,9 +737,13 @@ void StackPreprocess::SetAllocStatisticsFrame(const RawStackPtr& rawStack, std::
|
||||
callStack_.clear();
|
||||
bool isNapi = false;
|
||||
if (hookConfig_.js_stack_report() == NAPI_CALL_STACK) {
|
||||
callStack_.reserve(callFrames.size() + FRAME_DEPTH);
|
||||
callStack_.push_back((DWARF_NAPI_CALLBACK + napiIndex_) | JS_OFFLINE_IP_MASK);
|
||||
isNapi = true;
|
||||
std::string tagName;
|
||||
GetMemTag(rawStack->stackConext->tagId, tagName);
|
||||
if (tagName.find("napi") != std::string::npos) {
|
||||
callStack_.reserve(callFrames.size() + FRAME_DEPTH); // insert a frame
|
||||
callStack_.push_back((DWARF_NAPI_CALLBACK + napiIndex_) | JS_OFFLINE_IP_MASK);
|
||||
isNapi = true;
|
||||
}
|
||||
} else {
|
||||
callStack_.reserve(callFrames.size() + 1);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ ohos_unittest("native_daemon_ut") {
|
||||
"ability_base:extractortool",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtoken_setproc",
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"faultloggerd:libunwinder_static",
|
||||
"googletest:gtest",
|
||||
"init:libbegetutil",
|
||||
|
@ -183,19 +183,4 @@ HWTEST_F(HookManagerTest, CheckProcess, TestSize.Level1)
|
||||
EXPECT_TRUE(hookManager.CheckProcessName());
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: PrintStat
|
||||
* @tc.desc: test PrintStat with false case.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(HookManagerTest, PrintStat, TestSize.Level1)
|
||||
{
|
||||
HookManager hookManager;
|
||||
NativeHookConfig nativeConfig;
|
||||
nativeConfig.set_process_name("HookManagerTest");
|
||||
nativeConfig.set_startup_mode(true);
|
||||
hookManager.SetHookConfig(nativeConfig);
|
||||
hookManager.GetFds(9, "");
|
||||
EXPECT_TRUE((hookManager.shareMemoryNmd_ && hookManager.shareMemoryNmd_->GetName() == "nmd 9"));
|
||||
}
|
||||
} // namespace
|
@ -64,7 +64,7 @@ ohos_source_set("native_hook_source") {
|
||||
public_deps = [ "//third_party/libunwind:unwind_source_${target_cpu}" ]
|
||||
}
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"ffrt:libffrt",
|
||||
"hitrace:libhitracechain",
|
||||
"init:libbegetutil",
|
||||
@ -116,7 +116,7 @@ ohos_executable("nativetest_c") {
|
||||
"-Wno-error=inline-asm",
|
||||
"-O3",
|
||||
]
|
||||
external_deps += [ "bounds_checking_function:libsec_static" ]
|
||||
external_deps += [ "bounds_checking_function:libsec_shared" ]
|
||||
ldflags = [ "-rdynamic" ]
|
||||
install_enable = false
|
||||
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
|
||||
@ -175,7 +175,7 @@ ohos_executable("malloctest_cpp") {
|
||||
"-Wno-error=inline-asm",
|
||||
"-O3",
|
||||
]
|
||||
external_deps += [ "bounds_checking_function:libsec_static" ]
|
||||
external_deps += [ "bounds_checking_function:libsec_shared" ]
|
||||
ldflags = [ "-rdynamic" ]
|
||||
install_enable = false
|
||||
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
|
||||
@ -212,7 +212,7 @@ ohos_executable("statisticstest_cpp") {
|
||||
"-O3",
|
||||
]
|
||||
ldflags = [ "-rdynamic" ]
|
||||
external_deps += [ "bounds_checking_function:libsec_static" ]
|
||||
external_deps += [ "bounds_checking_function:libsec_shared" ]
|
||||
install_enable = false
|
||||
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
|
||||
part_name = "${OHOS_PROFILER_PART_NAME}"
|
||||
|
@ -44,17 +44,21 @@ public:
|
||||
void DisableHook();
|
||||
bool PeerIsConnected();
|
||||
bool SendNmdInfo();
|
||||
bool SendEndMsg();
|
||||
int GetNmdType()
|
||||
{
|
||||
return nmdType_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<UnixSocketClient> unixSocketClient_;
|
||||
int smbFd_;
|
||||
int eventFd_;
|
||||
int pid_;
|
||||
int nmdFd_{0};
|
||||
int nmdType_ = -1;
|
||||
ClientConfig *config_ = nullptr;
|
||||
Sampling *sampler_ = nullptr;
|
||||
std::shared_ptr<StackWriter> stackWriter_;
|
||||
std::shared_ptr<ShareMemoryBlock> shareMemoryBlockNmd_;
|
||||
void (*disableHookCallback_)(){nullptr};
|
||||
};
|
||||
|
||||
|
@ -303,8 +303,14 @@ bool ohos_malloc_hook_on_end(void)
|
||||
{
|
||||
std::lock_guard<std::recursive_timed_mutex> guard(g_ClientMutex);
|
||||
if (g_hookClient != nullptr) {
|
||||
g_hookClient->SendNmdInfo();
|
||||
if (g_hookClient->GetNmdType() == 1) {
|
||||
PROFILER_LOG_INFO(LOG_CORE, "sending nmd info after hook");
|
||||
g_hookClient->SendNmdInfo();
|
||||
}
|
||||
g_hookClient->SendEndMsg();
|
||||
g_hookClient->Flush();
|
||||
} else {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "ohos_malloc_hook_on_end, g_hookClient is nullptr");
|
||||
}
|
||||
}
|
||||
pthread_t threadEnd;
|
||||
@ -427,7 +433,7 @@ void* hook_malloc(void* (*fn)(size_t), size_t size)
|
||||
void* stackAddr = nullptr;
|
||||
size_t coroutineStackSize = 0;
|
||||
if (ffrt_get_current_coroutine_stack(&stackAddr, &coroutineStackSize)) {
|
||||
stackSize = coroutineStackSize;
|
||||
stackSize = static_cast<int>(coroutineStackSize);
|
||||
} else {
|
||||
stackptr = reinterpret_cast<const char*>(__builtin_frame_address(0));
|
||||
GetRuntimeStackEnd(stackptr, &stackendptr, g_hookPid, GetCurThreadId()); // stack end pointer
|
||||
@ -530,7 +536,7 @@ void* hook_aligned_alloc(void* (*fn)(size_t, size_t), size_t align, size_t len)
|
||||
void* stackAddr = nullptr;
|
||||
size_t coroutineStackSize = 0;
|
||||
if (ffrt_get_current_coroutine_stack(&stackAddr, &coroutineStackSize)) {
|
||||
stackSize = coroutineStackSize;
|
||||
stackSize = static_cast<int>(coroutineStackSize);
|
||||
} else {
|
||||
stackptr = reinterpret_cast<const char*>(__builtin_frame_address(0));
|
||||
GetRuntimeStackEnd(stackptr, &stackendptr, g_hookPid, GetCurThreadId()); // stack end pointer
|
||||
@ -633,7 +639,7 @@ void* hook_calloc(void* (*fn)(size_t, size_t), size_t number, size_t size)
|
||||
void* stackAddr = nullptr;
|
||||
size_t coroutineStackSize = 0;
|
||||
if (ffrt_get_current_coroutine_stack(&stackAddr, &coroutineStackSize)) {
|
||||
stackSize = coroutineStackSize;
|
||||
stackSize = static_cast<int>(coroutineStackSize);
|
||||
} else {
|
||||
stackptr = reinterpret_cast<const char*>(__builtin_frame_address(0));
|
||||
GetRuntimeStackEnd(stackptr, &stackendptr, g_hookPid, GetCurThreadId()); // stack end pointer
|
||||
@ -741,7 +747,7 @@ void* hook_realloc(void* (*fn)(void*, size_t), void* ptr, size_t size)
|
||||
void* stackAddr = nullptr;
|
||||
size_t coroutineStackSize = 0;
|
||||
if (ffrt_get_current_coroutine_stack(&stackAddr, &coroutineStackSize)) {
|
||||
stackSize = coroutineStackSize;
|
||||
stackSize = static_cast<int>(coroutineStackSize);
|
||||
} else {
|
||||
stackptr = reinterpret_cast<const char*>(__builtin_frame_address(0));
|
||||
GetRuntimeStackEnd(stackptr, &stackendptr, g_hookPid, GetCurThreadId()); // stack end pointer
|
||||
@ -824,14 +830,16 @@ size_t hook_malloc_usable_size(size_t (*fn)(void*), void* ptr)
|
||||
|
||||
void hook_free(void (*free_func)(void*), void* p)
|
||||
{
|
||||
if (free_func) {
|
||||
free_func(p);
|
||||
if (!free_func) {
|
||||
return;
|
||||
}
|
||||
if (g_ClientConfig.mallocDisable || IsPidChanged()) {
|
||||
free_func(p);
|
||||
return;
|
||||
}
|
||||
if (g_ClientConfig.sampleInterval >= THRESHOLD) {
|
||||
if (!IsAddrExist(p)) {
|
||||
free_func(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -873,7 +881,7 @@ void hook_free(void (*free_func)(void*), void* p)
|
||||
void* stackAddr = nullptr;
|
||||
size_t coroutineStackSize = 0;
|
||||
if (ffrt_get_current_coroutine_stack(&stackAddr, &coroutineStackSize)) {
|
||||
stackSize = coroutineStackSize;
|
||||
stackSize = static_cast<int>(coroutineStackSize);
|
||||
} else {
|
||||
stackptr = reinterpret_cast<const char*>(__builtin_frame_address(0));
|
||||
GetRuntimeStackEnd(stackptr, &stackendptr, g_hookPid, GetCurThreadId()); // stack end pointer
|
||||
@ -911,6 +919,7 @@ void hook_free(void (*free_func)(void*), void* p)
|
||||
}
|
||||
holder->SendStackWithPayload(&rawdata, realSize, stackptr, stackSize);
|
||||
}
|
||||
free_func(p);
|
||||
#ifdef PERFORMANCE_DEBUG
|
||||
g_mallocTimes++;
|
||||
struct timespec end = {};
|
||||
@ -990,7 +999,7 @@ void* hook_mmap(void*(*fn)(void*, size_t, int, int, int, off_t),
|
||||
void* stackAddr = nullptr;
|
||||
size_t coroutineStackSize = 0;
|
||||
if (ffrt_get_current_coroutine_stack(&stackAddr, &coroutineStackSize)) {
|
||||
stackSize = coroutineStackSize;
|
||||
stackSize = static_cast<int>(coroutineStackSize);
|
||||
} else {
|
||||
stackptr = reinterpret_cast<const char*>(__builtin_frame_address(0));
|
||||
GetRuntimeStackEnd(stackptr, &stackendptr, g_hookPid, GetCurThreadId()); // stack end pointer
|
||||
@ -1067,10 +1076,11 @@ void* hook_mmap(void*(*fn)(void*, size_t, int, int, int, off_t),
|
||||
int hook_munmap(int(*fn)(void*, size_t), void* addr, size_t length)
|
||||
{
|
||||
int ret = -1;
|
||||
if (fn) {
|
||||
ret = fn(addr, length);
|
||||
if (!fn) {
|
||||
return ret;
|
||||
}
|
||||
if (g_ClientConfig.mmapDisable || IsPidChanged()) {
|
||||
ret = fn(addr, length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1092,7 +1102,7 @@ int hook_munmap(int(*fn)(void*, size_t), void* addr, size_t length)
|
||||
void* stackAddr = nullptr;
|
||||
size_t coroutineStackSize = 0;
|
||||
if (ffrt_get_current_coroutine_stack(&stackAddr, &coroutineStackSize)) {
|
||||
stackSize = coroutineStackSize;
|
||||
stackSize = static_cast<int>(coroutineStackSize);
|
||||
} else {
|
||||
stackptr = reinterpret_cast<const char*>(__builtin_frame_address(0));
|
||||
GetRuntimeStackEnd(stackptr, &stackendptr, g_hookPid, GetCurThreadId()); // stack end pointer
|
||||
@ -1130,6 +1140,7 @@ int hook_munmap(int(*fn)(void*, size_t), void* addr, size_t length)
|
||||
}
|
||||
holder->SendStackWithPayload(&rawdata, realSize, stackptr, stackSize);
|
||||
}
|
||||
ret = fn(addr, length);
|
||||
#ifdef PERFORMANCE_DEBUG
|
||||
g_mallocTimes++;
|
||||
struct timespec end = {};
|
||||
@ -1213,7 +1224,7 @@ void hook_memtrace(void* addr, size_t size, const char* tag, bool isUsing)
|
||||
void* stackAddr = nullptr;
|
||||
size_t coroutineStackSize = 0;
|
||||
if (ffrt_get_current_coroutine_stack(&stackAddr, &coroutineStackSize)) {
|
||||
stackSize = coroutineStackSize;
|
||||
stackSize = static_cast<int>(coroutineStackSize);
|
||||
} else {
|
||||
stackptr = reinterpret_cast<const char*>(__builtin_frame_address(0));
|
||||
GetRuntimeStackEnd(stackptr, &stackendptr, g_hookPid, GetCurThreadId()); // stack end pointer
|
||||
|
@ -32,10 +32,8 @@
|
||||
namespace {
|
||||
constexpr int FLUSH_FLAG = 20;
|
||||
std::atomic<uint64_t> g_flushCount = 0;
|
||||
std::atomic<uint64_t> g_memIndex = 0;
|
||||
std::atomic<bool> g_disableHook = false;
|
||||
constexpr uint32_t MEMCHECK_DETAILINFO_MAXSIZE = 102400;
|
||||
constexpr uint32_t SHARED_MEMORY_SIZE = 307200;
|
||||
|
||||
struct OptArg {
|
||||
size_t pos;
|
||||
@ -127,17 +125,16 @@ bool HookSocketClient::ProtocolProc(SocketContext &context, uint32_t pnum, const
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s sample interval %" PRIu64 "", __func__, sampler_->GetSampleInterval());
|
||||
smbFd_ = context.ReceiveFileDiscriptor();
|
||||
eventFd_ = context.ReceiveFileDiscriptor();
|
||||
nmdFd_ = context.ReceiveFileDiscriptor();
|
||||
std::string smbName = "hooknativesmb_" + std::to_string(pid_);
|
||||
stackWriter_ = std::make_shared<StackWriter>(smbName, config_->shareMemorySize,
|
||||
smbFd_, eventFd_, config_->isBlocked);
|
||||
shareMemoryBlockNmd_ =
|
||||
ShareMemoryAllocator::GetInstance().CreateMemoryBlockRemote("nmd" + std::to_string(g_memIndex),
|
||||
SHARED_MEMORY_SIZE, nmdFd_);
|
||||
++g_memIndex;
|
||||
struct mallinfo2 mi = mallinfo2();
|
||||
COMMON::PrintMallinfoLog("stackWriter init(byte) => ", mi);
|
||||
SendNmdInfo();
|
||||
nmdType_ = config_->nmdType;
|
||||
if (nmdType_ == 0) {
|
||||
PROFILER_LOG_INFO(LOG_CORE, "sending nmd info before hook");
|
||||
SendNmdInfo();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -206,13 +203,35 @@ bool HookSocketClient::PeerIsConnected()
|
||||
|
||||
bool HookSocketClient::SendNmdInfo()
|
||||
{
|
||||
CHECK_TRUE(nmdFd_ != -1, false, "HookSocketClient::SendNmdInfo failed, invalid nmdFd_");
|
||||
CHECK_NOTNULL(shareMemoryBlockNmd_, false, "HookSocketClient::SendNmdInfo failed, sharedMemoryBlock error");
|
||||
if (!config_->printNmd) {
|
||||
return false;
|
||||
}
|
||||
void* nmdBuf = malloc(MEMCHECK_DETAILINFO_MAXSIZE);
|
||||
CHECK_NOTNULL(nmdBuf, false, "HookSocketClient::SendNmdInfo failed, nmdBuf malloc failed");
|
||||
struct OptArg opt = {0, reinterpret_cast<char*>(nmdBuf) };
|
||||
malloc_stats_print(NmdWriteStat, &opt, "a");
|
||||
shareMemoryBlockNmd_->PutRawTimeout(reinterpret_cast<int8_t*>(opt.buf), strlen(opt.buf) + 1);
|
||||
free(nmdBuf);
|
||||
StackRawData rawdata = {{{{0}}}};
|
||||
rawdata.type = NMD_MSG;
|
||||
if (stackWriter_) {
|
||||
bool ret = stackWriter_->WriteWithPayloadTimeout(&rawdata, sizeof(BaseStackRawData),
|
||||
reinterpret_cast<int8_t*>(opt.buf), strlen(opt.buf) + 1,
|
||||
std::bind(&HookSocketClient::PeerIsConnected, this));
|
||||
PROFILER_LOG_INFO(LOG_CORE, "SendNmdMsg ret val: %d", ret);
|
||||
} else {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "SendNmdMsg stackWriter_ is nullptr");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HookSocketClient::SendEndMsg()
|
||||
{
|
||||
StackRawData rawdata = {{{{0}}}};
|
||||
rawdata.type = END_MSG;
|
||||
if (stackWriter_) {
|
||||
bool ret = stackWriter_->WriteTimeout(&rawdata, sizeof(BaseStackRawData));
|
||||
PROFILER_LOG_INFO(LOG_CORE, "SendEndMsg ret val: %d", ret);
|
||||
} else {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "SendEndMsg stackWriter_ is nullptr");
|
||||
}
|
||||
return true;
|
||||
}
|
@ -73,7 +73,7 @@ ohos_unittest("nativehook_ut") {
|
||||
"-Dprotected=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"faultloggerd:libunwinder_static",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
|
@ -759,6 +759,7 @@ HWTEST_F(CheckHookDataTest, DFX_DFR_Hiprofiler_0120, Function | MediumTest | Lev
|
||||
uint16_t applyCount = std::atoi(resultVec[1].c_str());
|
||||
std::cout << "applyCount: " << applyCount << std::endl;
|
||||
EXPECT_TRUE(applyCount > 0);
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1028,6 +1029,7 @@ HWTEST_F(CheckHookDataTest, DFX_DFR_Hiprofiler_0180, Function | MediumTest | Lev
|
||||
uint16_t applyCount = std::atoi(resultVec[1].c_str());
|
||||
std::cout << "applyCount: " << applyCount << std::endl;
|
||||
EXPECT_TRUE(applyCount > 0);
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1136,6 +1138,7 @@ HWTEST_F(CheckHookDataTest, DFX_DFR_Hiprofiler_0200, Function | MediumTest | Lev
|
||||
uint16_t applyCount = std::atoi(resultVec[1].c_str());
|
||||
std::cout << "applyCount: " << applyCount << std::endl;
|
||||
EXPECT_TRUE(applyCount > 0);
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,6 @@ HWTEST_F(HookSocketClientTest, SendNmdInfo, TestSize.Level1)
|
||||
if (memcpy_s(buffer.get(), metaSize, &ts, sizeof(ts)) != EOK) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "memcpy_s ts failed");
|
||||
}
|
||||
ASSERT_EQ(hookClient.nmdFd_, -1);
|
||||
ASSERT_FALSE(hookClient.SendNmdInfo());
|
||||
}
|
||||
} // namespace
|
||||
|
@ -37,7 +37,7 @@ ohos_source_set("networkplugin_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -42,7 +42,7 @@ ohos_unittest("networkplugin_ut") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -30,9 +30,9 @@ ohos_fuzztest("NetworkStartPluginFuzzTest") {
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/network_plugin:networkplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/network_data:network_data_cpp",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -57,7 +57,7 @@ ohos_shared_library("libnetwork_profiler") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
|
||||
|
@ -35,7 +35,7 @@ ohos_source_set("processplugin_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -40,7 +40,7 @@ ohos_unittest("processplugin_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -33,7 +33,7 @@ ohos_shared_library("sampleplugin") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -32,7 +32,7 @@ ohos_source_set("streamplugin_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -34,7 +34,7 @@ ohos_shared_library("xpowerplugin") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
@ -65,7 +65,7 @@ ohos_executable("xpowerdecoder") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"cJSON:cjson_static",
|
||||
"hilog:libhilog",
|
||||
"openssl:libcrypto_shared",
|
||||
|
@ -54,7 +54,7 @@ ohos_unittest("xpowerplugin_ut") {
|
||||
"-Dprotected=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -31,7 +31,7 @@ ohos_source_set("ipc") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"init:libbegetutil",
|
||||
"protobuf:protobuf_lite_static",
|
||||
"protobuf:protobuf_static",
|
||||
|
@ -51,7 +51,7 @@ ohos_source_set("profiler_service") {
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_test_config",
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"grpc:grpc",
|
||||
"grpc:grpcxx",
|
||||
"openssl:libcrypto_shared",
|
||||
|
@ -168,7 +168,6 @@ bool ProfilerService::SessionContext::StartPluginSessions()
|
||||
|
||||
bool ProfilerService::SessionContext::StopPluginSessions()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(sessionMutex);
|
||||
if (sessionConfig.session_mode() == ProfilerSessionConfig::OFFLINE) {
|
||||
if (offlineScheduleTaskFd != -1) {
|
||||
stopExpireTask.UnscheduleTaskLockless(offlineScheduleTaskFd);
|
||||
|
@ -35,7 +35,7 @@ ohos_source_set("shared_memory_source") {
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -423,7 +423,6 @@ bool ShareMemoryBlock::PutWithPayloadSync(const int8_t* header, uint32_t headerS
|
||||
return false;
|
||||
}
|
||||
pthread_mutex_unlock(&header_->info.mutex_);
|
||||
PROFILER_LOG_DEBUG(LOG_CORE, "%s:%d block", __FUNCTION__, __LINE__);
|
||||
usleep(WAIT_RELEASE_TIMEOUT_US);
|
||||
pthread_mutex_lock(&header_->info.mutex_);
|
||||
rawMemory = GetFreeMemory(headerSize + payloadSize);
|
||||
|
@ -45,7 +45,7 @@ ohos_unittest("shared_memory_ut") {
|
||||
"-Dprotected=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"googletest:gtest",
|
||||
"hilog:libhilog",
|
||||
"protobuf:protobuf",
|
||||
|
@ -540,7 +540,7 @@ static napi_value GetServiceDump(napi_env env, napi_callback_info info)
|
||||
sptr<IRemoteObject> sa = sam->CheckSystemAbility(serviceAbilityId);
|
||||
if (sa == nullptr) {
|
||||
HILOG_ERROR(LOG_CORE, "no this system ability.");
|
||||
std::string idErrorMessage = "service id is invalid, system ability is not exist.";
|
||||
std::string idErrorMessage = "ServiceId invalid. The system ability does not exist.";
|
||||
napi_throw_error(env, std::to_string(ErrorCode::SYSTEM_ABILITY_NOT_FOUND).c_str(), idErrorMessage.c_str());
|
||||
return CreateUndefined(env);
|
||||
}
|
||||
@ -568,7 +568,7 @@ static napi_value GetSystemCpuUsage(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto cpuUsageOptional = HidebugNativeInterface::CreateInstance()->GetSystemCpuUsage();
|
||||
if (!cpuUsageOptional.has_value()) {
|
||||
std::string paramErrorMessage = "The status of the system cpu usage is abnormal.";
|
||||
std::string paramErrorMessage = "The status of the system CPU usage is abnormal.";
|
||||
napi_throw_error(env, std::to_string(ErrorCode::SYSTEM_STATUS_ABNORMAL).c_str(), paramErrorMessage.c_str());
|
||||
return CreateUndefined(env);
|
||||
}
|
||||
@ -832,14 +832,14 @@ napi_value StartAppTraceCapture(napi_env env, napi_callback_info info)
|
||||
napi_throw_error(env, std::to_string(ErrorCode::PARAMETER_ERROR).c_str(), errorMessage.c_str());
|
||||
}
|
||||
if (ret == HAVA_ALREADY_TRACE) {
|
||||
std::string errorMessage = "Have already capture trace";
|
||||
std::string errorMessage = "Capture trace already enabled.";
|
||||
napi_throw_error(env, std::to_string(ErrorCode::HAVA_ALREADY_TRACE).c_str(), errorMessage.c_str());
|
||||
}
|
||||
if (ret == WITHOUT_WRITE_PERMISSON) {
|
||||
std::string errorMessage = "Without write permission on the file";
|
||||
std::string errorMessage = "No write permission on the file.";
|
||||
napi_throw_error(env, std::to_string(ErrorCode::WITHOUT_WRITE_PERMISSON).c_str(), errorMessage.c_str());
|
||||
}
|
||||
std::string errorMessage = "The status of the trace is abnormal";
|
||||
std::string errorMessage = "Abnormal trace status.";
|
||||
napi_throw_error(env, std::to_string(ErrorCode::SYSTEM_STATUS_ABNORMAL).c_str(), errorMessage.c_str());
|
||||
return CreateUndefined(env);
|
||||
}
|
||||
|
@ -455,4 +455,23 @@ describe("HidebugJsTest", function () {
|
||||
expect(error.message === "Invalid parameter, unknown property.").assertTrue();
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.name: HidebugJsTest_019
|
||||
* @tc.desc: setAppResourceLimit正常测试
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5VY8L
|
||||
*/
|
||||
it('HidebugJsTest_019', 0, function () {
|
||||
console.info("---------------------------HidebugJsTest_019----------------------------------");
|
||||
try {
|
||||
let type = "js_heap";
|
||||
let value = 85;
|
||||
let enabledDebugLog = false;
|
||||
hidebug.setAppResourceLimit(type, value, enabledDebugLog);
|
||||
} catch (error) {
|
||||
console.info(error.code);
|
||||
expect(error.code === "401").assertTrue();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -129,7 +129,7 @@ ohos_source_set("hiebpf_source_common") {
|
||||
":gen_bpf_skeleton",
|
||||
"//third_party/libbpf:libbpf",
|
||||
]
|
||||
external_deps = [ "bounds_checking_function:libsec_static" ]
|
||||
external_deps = [ "bounds_checking_function:libsec_shared" ]
|
||||
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
|
||||
part_name = "${OHOS_PROFILER_PART_NAME}"
|
||||
}
|
||||
|
@ -82,6 +82,9 @@ void Capture::ThreadGetCatch(const std::string &curTime) const
|
||||
|
||||
void Capture::ThreadGetCatchSocket(const std::string &curTime) const
|
||||
{
|
||||
if (curTime.empty()) {
|
||||
return;
|
||||
}
|
||||
auto savePath = "/data/local/tmp/capture/screenCap_" + curTime + ".jpeg";
|
||||
std::string cmdResult;
|
||||
if (!SPUtils::FileAccess("/data/local/tmp/capture")) {
|
||||
@ -89,12 +92,11 @@ void Capture::ThreadGetCatchSocket(const std::string &curTime) const
|
||||
printf("/data/local/tmp/capture created! \n");
|
||||
LOGI("/data/local/tmp/capture created!");
|
||||
};
|
||||
char resolvedPath[PATH_MAX] = {0x00};
|
||||
if (realpath(savePath.c_str(), resolvedPath) == nullptr) {
|
||||
std::cout << "Error: Unable to get resolved path." << std::endl;
|
||||
return;
|
||||
|
||||
if (SPUtils::FileAccess(savePath)) {
|
||||
std::cout << "" << std::endl;
|
||||
}
|
||||
auto fd = open(resolvedPath, O_RDWR | O_CREAT, 0644);
|
||||
auto fd = open(savePath.c_str(), O_RDWR | O_CREAT, 0644);
|
||||
SPUtils::LoadCmd("snapshot_display -f " + savePath, cmdResult);
|
||||
(void)close(fd);
|
||||
}
|
||||
|
@ -13,8 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include "include/sp_utils.h"
|
||||
#include "include/Power.h"
|
||||
#include "include/sp_log.h"
|
||||
@ -24,17 +22,7 @@ std::map<std::string, std::string> Power::ItemData()
|
||||
{
|
||||
std::map<std::string, std::string> result;
|
||||
std::string currentNow;
|
||||
double avgCurrent = 0.0;
|
||||
SPUtils::LoadFile(currentNowPath, curAvgCurrent);
|
||||
const double number = 3.6;
|
||||
if (lastAvgCurrent != "0") {
|
||||
int diffAvgCurrent = std::stoi(curAvgCurrent) - std::stoi(lastAvgCurrent);
|
||||
avgCurrent = diffAvgCurrent * number;
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss << std::fixed << std::setprecision(1) << avgCurrent;
|
||||
currentNow = ss.str();
|
||||
lastAvgCurrent = curAvgCurrent;
|
||||
SPUtils::LoadFile(currentNowPath, currentNow);
|
||||
std::string voltageNow;
|
||||
SPUtils::LoadFile(voltageNowPath, voltageNow);
|
||||
result["currentNow"] = currentNow;
|
||||
|
@ -31,10 +31,8 @@ private:
|
||||
Power() {};
|
||||
Power(const Power &);
|
||||
Power &operator = (const Power &);
|
||||
const std::string currentNowPath = "/sys/class/power_supply/Battery/charge_counter";
|
||||
const std::string currentNowPath = "/sys/class/power_supply/Battery/current_now";
|
||||
const std::string voltageNowPath = "/sys/class/power_supply/Battery/voltage_now";
|
||||
std::string curAvgCurrent;
|
||||
std::string lastAvgCurrent = "0";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
void HelpCommand(CommandHelp type) const;
|
||||
void HandleCommand(std::string argStr, const std::string &argStr1);
|
||||
int GetItemInfo(std::multimap<std::string, std::string, decltype(SPUtils::Cmp) *> &spMap);
|
||||
void printfExecCommand(const std::map<std::string, std::string> data);
|
||||
void PrintfExecCommand(const std::map<std::string, std::string> data) const;
|
||||
// 采集次数
|
||||
int num = 0;
|
||||
// 包名
|
||||
|
@ -183,6 +183,7 @@ void ProfilerFPS::PrintSections(int msCount, long long currTimeLast,
|
||||
}
|
||||
long long timeN = (currTimeLast - currTimeStart) / conversionTime;
|
||||
if (timeN == 0) {
|
||||
printf("sectionsFps:%d|%lld\n", 0, currLastTime);
|
||||
return;
|
||||
}
|
||||
long long fpsSections = (fpsNums * conversionFps) / timeN;
|
||||
@ -237,7 +238,7 @@ void ProfilerFPS::GetSectionsFps(FpsInfoProfiler &fpsInfoResult, int nums) const
|
||||
PrintSections(msCount, currTimeLast, currTimeStart, currLastTime);
|
||||
currTimeLast = currTime;
|
||||
printCount++;
|
||||
GetSectionsPrint(printCount, currLastTime, nums, msJiange);
|
||||
GetSectionsPrint(printCount, currLastTime, nums, harTime);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
@ -211,16 +211,18 @@ std::string SmartPerfCommand::ExecCommand()
|
||||
}
|
||||
if (callGpuCounterResult) {
|
||||
const std::map<std::string, std::string> data = GpuCounter::GetInstance().ItemData();
|
||||
printfExecCommand(data);
|
||||
PrintfExecCommand(data);
|
||||
SPData spdata;
|
||||
spdata.values.insert(data.begin(), data.end());
|
||||
vmap.push_back(spdata);
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(freq));
|
||||
LOGI("SmartPerfCommand::WriteCsv start");
|
||||
SpCsvUtil::WriteCsv(std::string(outPath.c_str()), vmap);
|
||||
LOGI("SmartPerfCommand::WriteCsv finish");
|
||||
return std::string("command exec finished!");
|
||||
}
|
||||
void SmartPerfCommand::printfExecCommand(const std::map<std::string, std::string> data)
|
||||
void SmartPerfCommand::PrintfExecCommand(const std::map<std::string, std::string> data) const
|
||||
{
|
||||
int i = 0;
|
||||
for (auto a = data.cbegin(); a != data.cend(); ++a) {
|
||||
|
@ -228,6 +228,9 @@ ErrCode SPTask::StartTask(std::function<void(std::string data)> msgTask)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(curTaskInfo.freq - costTime));
|
||||
}
|
||||
}
|
||||
if (!isRunning) {
|
||||
vmap.clear();
|
||||
}
|
||||
});
|
||||
LOGI("SPTask::StartTask complete");
|
||||
return ErrCode::OK;
|
||||
|
@ -587,7 +587,7 @@ bool SPUtils::IsHmKernel()
|
||||
utsname unameBuf;
|
||||
if ((uname(&unameBuf)) == 0) {
|
||||
std::string osRelease = unameBuf.release;
|
||||
isHM = osRelease.find("hmkernel") != std::string::npos;
|
||||
isHM = osRelease.find("HongMeng") != std::string::npos;
|
||||
}
|
||||
return isHM;
|
||||
}
|
||||
|
@ -91,7 +91,10 @@ void StallingRateTrace::AppList(std::string line, const std::string &signS, cons
|
||||
if (line.find("H:LAUNCHER_APP_LAUNCH_FROM_ICON,") != std::string::npos ||
|
||||
line.find("H:APP_LIST_FLING,") != std::string::npos ||
|
||||
line.find("H:WEB_LIST_FLING") != std::string::npos ||
|
||||
line.find("H:ABILITY_OR_PAGE_SWITCH,") != std::string::npos) {
|
||||
line.find("H:ABILITY_OR_PAGE_SWITCH,") != std::string::npos ||
|
||||
line.find("H:APP_TRANSITION_TO_OTHER_APP,") != std::string::npos ||
|
||||
line.find("H:LUNCHER_APP_LUNCH_FORH_DOCK,") != std::string::npos ||
|
||||
line.find("H:LUNCHER_APP_LUNCH_FORM_APPCENTER,") != std::string::npos) {
|
||||
if (animalFlag) {
|
||||
dynamicFinishTime = GetTimes(line, signF);
|
||||
LOGI("dynamicFinishTime=====: %s", std::to_string(dynamicFinishTime).c_str());
|
||||
|
@ -34,7 +34,7 @@ void StartUpDelay::GetTrace(const std::string &sessionID, const std::string &tra
|
||||
if (SPUtils::IsHmKernel()) {
|
||||
cmdString = "hitrace --trace_clock mono -t 5 -b 102400 --overwrite idle ace app ohos ability graphic nweb ";
|
||||
} else {
|
||||
cmdString = "hitrace --trace_clock mono -t 5 -b 20480 --overwrite idle ace app ohos ability graphic nweb ";
|
||||
cmdString = "hitrace --trace_clock mono -t 5 -b 204800 --overwrite idle ace app ohos ability graphic nweb ";
|
||||
}
|
||||
std::string cmdStringEnd { "sched freq sync workq multimodalinput > " };
|
||||
SPUtils::LoadCmd(cmdString + cmdStringEnd + traceName, result);
|
||||
|
@ -45,7 +45,6 @@ export class ProfilerTask {
|
||||
for (var key of keys) {
|
||||
if (globalThis.collectConfigs[key]) {
|
||||
let typeCollect = ProfilerFactory.getProfilerByConfig(key.toString());
|
||||
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask initModule: ' + typeCollect);
|
||||
if (typeCollect == null) {
|
||||
continue;
|
||||
} else {
|
||||
@ -102,7 +101,6 @@ export class ProfilerTask {
|
||||
}
|
||||
|
||||
taskStart() {
|
||||
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask taskStart call');
|
||||
var gpDataArr: GPData[] = [];
|
||||
this.collectItems.forEach((moduleName) => {
|
||||
let typeCollect = ProfilerFactory.getProfilerByConfig(moduleName.toString());
|
||||
@ -112,7 +110,6 @@ export class ProfilerTask {
|
||||
gpDataArr.push(typeCollect.readCPULoad());
|
||||
}
|
||||
gpDataArr.push(gpData);
|
||||
SPLogger.DEBUG(ProfilerTask.name, 'profiler ProfilerTask:curData:' + gpData);
|
||||
}
|
||||
});
|
||||
|
||||
@ -124,13 +121,9 @@ export class ProfilerTask {
|
||||
CommonEvent.publish('event', { code: 0, data: JSON.stringify(tTndex) }, (err) => {});
|
||||
}
|
||||
globalThis.collectIntervalNum++;
|
||||
SPLogger.DEBUG(ProfilerTask.name, 'profiler globalThis.collectIntervalNum ' + globalThis.collectIntervalNum);
|
||||
|
||||
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask taskStart called');
|
||||
}
|
||||
|
||||
taskSingleItemStart(collectorType: CollectorType) {
|
||||
SPLogger.ERROR('ProfilerTaskTest', 'ProfilerTask taskStart call collectorType' + collectorType.toString());
|
||||
let typeCollect = ProfilerFactory.getProfilerByConfig(collectorType.toString());
|
||||
if (typeCollect instanceof Power) {
|
||||
typeCollect.readFourTimesData();
|
||||
@ -146,10 +139,12 @@ export class ProfilerTask {
|
||||
database.insertData('t_index_info', globalThis.dbTime, tTndex);
|
||||
}
|
||||
}
|
||||
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask insertData success');
|
||||
createFilePath(
|
||||
globalThis.abilityContext.getApplicationContext().filesDir + '/' + globalThis.dbTime + '/t_index_info.csv',
|
||||
csvTIndexInfo(globalThis.tTndexs)
|
||||
);
|
||||
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask createFilePath index_info success');
|
||||
// t_general_info 入库
|
||||
globalThis.endTime = new Date().getTime();
|
||||
let tGeneralInfo = new TGeneralInfo(
|
||||
@ -168,7 +163,9 @@ export class ProfilerTask {
|
||||
tGeneralInfo.brand = deviceInfo.brand;
|
||||
tGeneralInfo.version = deviceInfo.displayVersion;
|
||||
tGeneralInfo.sn = deviceInfo.serial;
|
||||
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask insertGeneraData');
|
||||
database.insertGeneraData('t_general_info', tGeneralInfo);
|
||||
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask insertGeneraData success');
|
||||
createFilePath(
|
||||
globalThis.abilityContext.getApplicationContext().filesDir + '/' + globalThis.dbTime + '/t_general_info.csv',
|
||||
csvGeneralInfo(tGeneralInfo)
|
||||
|
@ -88,7 +88,6 @@ export function travelFile(path: string, regexp: string): Array<String> {
|
||||
}
|
||||
let name: String = dirent.name;
|
||||
if (name.match(regexp)) {
|
||||
SPLogger.DEBUG(TAG, 'travelFile get name:' + dirent.name);
|
||||
fileNames.push(name);
|
||||
}
|
||||
if (regexp == '') {
|
||||
|
@ -65,11 +65,9 @@ export class CPU extends BaseProfiler {
|
||||
try {
|
||||
var fd = -1;
|
||||
fd = fileio.openSync(path, 0o0);
|
||||
SPLogger.DEBUG(CPU.name, 'readCPULoad fd:' + fd);
|
||||
let buf = new ArrayBuffer(2048);
|
||||
fileio.readSync(fd, buf);
|
||||
let cpuStr: String = String.fromCharCode.apply(null, new Uint8Array(buf));
|
||||
SPLogger.DEBUG(CPU.name, 'readCPULoad cpuStr:' + cpuStr);
|
||||
let cpuStrArr = [];
|
||||
cpuStr = cpuStr.substring(0, cpuStr.indexOf('intr'));
|
||||
let nextj = 0;
|
||||
|
@ -48,7 +48,6 @@ export class DDR extends BaseProfiler {
|
||||
const path = DdrConfig.DDR_BASE;
|
||||
let ddr = fileOpen(path);
|
||||
this.ddrMap.set('ddrFreq', ddr);
|
||||
SPLogger.DEBUG(DDR.name, 'profile_readDDR' + ddr);
|
||||
return createGPData('DDR', this.ddrMap);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ export class FPS extends BaseProfiler implements SocketProfiler {
|
||||
|
||||
readMessageQueue() {
|
||||
mainWorker.postMessage({ fps: true, pkg: globalThis.collectPkg });
|
||||
SPLogger.DEBUG(FPS.name, 'messageQueue for fps' + globalThis.fpsArr.length);
|
||||
if (globalThis.fpsArr.length > 0) {
|
||||
let fpsQueue: String[] = globalThis.fpsArr;
|
||||
let fpsJitterQueue: String[] = globalThis.fpsJitterArr;
|
||||
|
@ -45,10 +45,6 @@ export class Power extends BaseProfiler {
|
||||
}
|
||||
});
|
||||
});
|
||||
SPLogger.DEBUG(
|
||||
Power.name,
|
||||
'pathNodes init length:' + pathNodes.length + 'support items:' + JSON.stringify(this.supportItemKey)
|
||||
);
|
||||
return CollectorType.TYPE_POWER;
|
||||
}
|
||||
|
||||
@ -83,13 +79,11 @@ export class Power extends BaseProfiler {
|
||||
if (powerKey == 'current_now') {
|
||||
let powerValue = fileOpen(PowerConfig.POWER_PATH + '/' + powerKey);
|
||||
globalThis.powerCurArr.push(powerValue);
|
||||
console.error('last CurrentNow-->push' + powerValue);
|
||||
}
|
||||
|
||||
if (powerKey == 'voltage_now') {
|
||||
let powerValue = fileOpen(PowerConfig.POWER_PATH + '/' + powerKey);
|
||||
globalThis.powerVoltArr.push(powerValue);
|
||||
console.error('last VoltageNow-->push' + powerValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,10 +95,8 @@ export class Power extends BaseProfiler {
|
||||
let lastValue = 0;
|
||||
while (powerQueue.length >= 4) {
|
||||
lastValue += StringUtils.s2L(powerQueue.pop().toString());
|
||||
console.error('last CurrentNow-->pop' + lastValue);
|
||||
}
|
||||
let avgCurrentNum = (lastValue / 4).toString();
|
||||
console.error('last CurrentNowAVG-->' + avgCurrentNum);
|
||||
return avgCurrentNum;
|
||||
}
|
||||
|
||||
@ -114,10 +106,8 @@ export class Power extends BaseProfiler {
|
||||
let lastValue = 0;
|
||||
while (powerQueue.length >= 4) {
|
||||
lastValue += StringUtils.s2L(powerQueue.pop().toString());
|
||||
console.error('last VoltageNow-->pop' + lastValue);
|
||||
}
|
||||
let avgCurrentNum = (lastValue / 4).toString();
|
||||
console.error('last VoltageNowAVG-->' + avgCurrentNum);
|
||||
return avgCurrentNum;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ export struct Report {
|
||||
})
|
||||
}
|
||||
}
|
||||
}, item => item.toString())
|
||||
}, item => item.startTime.toString())
|
||||
}
|
||||
.edgeEffect(EdgeEffect.None) // 滑动到边缘无效果
|
||||
.chainAnimation(false) // 联动特效关闭
|
||||
|
@ -102,18 +102,13 @@ struct FloatBall {
|
||||
|
||||
longEvent() {
|
||||
console.log('cm-floatBall-longEvent')
|
||||
this.playerState = TaskStatus.task_stop
|
||||
ProfilerTask.getInstance().taskStop()
|
||||
this.destroyAllWindow()
|
||||
this.clearAllInterVal()
|
||||
var now = new Date();
|
||||
var exitTime = now.getTime() + 1000;
|
||||
while (true) {
|
||||
now = new Date();
|
||||
if (now.getTime() > exitTime) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ProfilerTask.getInstance().taskGetDubai()
|
||||
setTimeout(() => {
|
||||
this.destroyAllWindow()
|
||||
this.clearAllInterVal()
|
||||
ProfilerTask.getInstance().taskGetDubai()
|
||||
}, 5000)
|
||||
}
|
||||
async dubai_data_to_disk() {
|
||||
mainWorker.postMessage({'setDuBaiDb': true})
|
||||
@ -264,6 +259,26 @@ struct FloatBall {
|
||||
})
|
||||
))
|
||||
}
|
||||
if (this.playerState == TaskStatus.task_stop) {
|
||||
Circle()
|
||||
.width('90vp')
|
||||
.height('90vp')
|
||||
.fill(Color.White)
|
||||
.fillOpacity(0)
|
||||
.opacity(0.8)
|
||||
.border({ radius: '90vp', width: '0.5vp', color: $r('app.color.colorPrimary') })
|
||||
.linearGradient({
|
||||
angle: 135,
|
||||
direction: GradientDirection.Left,
|
||||
colors: [[$r('app.color.colorPrimary'), 1.0], [$r('app.color.colorPrimary'), 1.0]]
|
||||
})
|
||||
Text('saving..')
|
||||
.fontSize(12)
|
||||
.textAlign(TextAlign.Center)
|
||||
.fontColor($r('app.color.color_fff'))
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
}.width('100%').height('100%')
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ ohos_unittest("plugin_module_api_ut") {
|
||||
"-Dprivate=public", #allow test code access private members
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"c_utils:utils",
|
||||
"drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
|
||||
"googletest:gtest",
|
||||
|
@ -32,7 +32,7 @@ ohos_source_set("proto_encoder_source") {
|
||||
":proto_encoder_config",
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_test_config",
|
||||
]
|
||||
external_deps = [ "bounds_checking_function:libsec_static" ]
|
||||
external_deps = [ "bounds_checking_function:libsec_shared" ]
|
||||
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
|
||||
part_name = "${OHOS_PROFILER_PART_NAME}"
|
||||
}
|
||||
|
@ -15,18 +15,18 @@ import("../build/config.gni")
|
||||
|
||||
subsys_name = OHOS_PROFILER_SUBSYS_NAME
|
||||
part_name = OHOS_PROFILER_PART_NAME
|
||||
subsys_x64_out = "clang_x64/thirdparty/grpc"
|
||||
proto_gen_ipc_dir = "clang_x64/$subsys_name/$part_name"
|
||||
subsys_x64_out = "clang_${host_cpu}/thirdparty/grpc"
|
||||
proto_gen_ipc_dir = "clang_${host_cpu}/$subsys_name/$part_name"
|
||||
libc_dir_proto = rebase_path("$asdk_libs_dir", "//")
|
||||
root_output_dir_proto = rebase_path("$root_out_dir", "//")
|
||||
|
||||
#host:clang_x64 default:arm mingw:mingw_x86_64
|
||||
if (current_toolchain != host_toolchain) {
|
||||
if (current_toolchain == default_toolchain) {
|
||||
root_output_dir_proto = "$root_output_dir_proto/clang_x64"
|
||||
root_output_dir_proto = "$root_output_dir_proto/clang_${host_cpu}"
|
||||
} else {
|
||||
root_output_dir_proto =
|
||||
get_path_info("$root_output_dir_proto", "dir") + "/clang_x64"
|
||||
get_path_info("$root_output_dir_proto", "dir") + "/clang_${host_cpu}"
|
||||
}
|
||||
}
|
||||
protoc = root_output_dir_proto
|
||||
|
@ -148,8 +148,8 @@ action("profiler_service_interface_gen") {
|
||||
args += rebase_path(sources, root_build_dir)
|
||||
deps = [ ":all_type_gen" ]
|
||||
external_deps = [
|
||||
"grpc:grpc_cpp_plugin(//build/toolchain/linux:clang_x64)",
|
||||
"protobuf:protoc(//build/toolchain/linux:clang_x64)",
|
||||
"grpc:grpc_cpp_plugin(//build/toolchain/linux:clang_${host_cpu})",
|
||||
"protobuf:protoc(//build/toolchain/linux:clang_${host_cpu})",
|
||||
]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user