From 697cb6c6747b00775d2a5ce9c24b4465fb426163 Mon Sep 17 00:00:00 2001 From: anderskov Date: Wed, 19 Jan 2022 19:42:48 +0800 Subject: [PATCH] disable malloc hook when musl is not used Signed-off-by: anderskov --- device/BUILD.gn | 4 ++-- device/plugins/native_daemon/src/hook_manager.cpp | 8 ++++---- device/plugins/native_daemon/src/hook_standalone.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/device/BUILD.gn b/device/BUILD.gn index a75a390d2..4f935c37e 100755 --- a/device/BUILD.gn +++ b/device/BUILD.gn @@ -35,7 +35,7 @@ group("hiprofiler_targets") { "services/profiler_service:hiprofilerd", "services/shared_memory:shared_memory", ] - if (is_ohos) { + if (is_ohos && use_musl) { deps += [ "plugins/native_daemon:native_daemon", "plugins/native_hook:native_hook", @@ -61,7 +61,7 @@ group("unittest") { "services/profiler_service/test:unittest", "services/shared_memory/test:unittest", ] - if (is_ohos) { + if (is_ohos && use_musl) { deps += [ "plugins/native_daemon/test:unittest", "plugins/native_hook/test:unittest", diff --git a/device/plugins/native_daemon/src/hook_manager.cpp b/device/plugins/native_daemon/src/hook_manager.cpp index 18392eb06..2186468e5 100755 --- a/device/plugins/native_daemon/src/hook_manager.cpp +++ b/device/plugins/native_daemon/src/hook_manager.cpp @@ -34,11 +34,11 @@ void HookManager::writeFrames(int type, const struct timespec& ts, void* addr, u const std::vector& callsFrames) { if (type == 0) { - fprintf(fpHookData_.get(), "malloc;%" PRId64 ";%ld;0x%" PRIx64 ";%u\n", ts.tv_sec, ts.tv_nsec, - (uint64_t)addr, mallocSize); + fprintf(fpHookData_.get(), "malloc;%" PRId64 ";%ld;0x%" PRIx64 ";%u\n", + (int64_t)ts.tv_sec, ts.tv_nsec, (uint64_t)addr, mallocSize); } else if (type == 1) { - fprintf(fpHookData_.get(), "free;%" PRId64 ";%ld;0x%" PRIx64 "\n", ts.tv_sec, ts.tv_nsec, - (uint64_t)addr); + fprintf(fpHookData_.get(), "free;%" PRId64 ";%ld;0x%" PRIx64 "\n", + (int64_t)ts.tv_sec, ts.tv_nsec, (uint64_t)addr); } else { return; } diff --git a/device/plugins/native_daemon/src/hook_standalone.cpp b/device/plugins/native_daemon/src/hook_standalone.cpp index 6fe51ce4a..c60e8aea3 100755 --- a/device/plugins/native_daemon/src/hook_standalone.cpp +++ b/device/plugins/native_daemon/src/hook_standalone.cpp @@ -41,11 +41,11 @@ void writeFrames(int type, const struct timespec& ts, void* addr, uint32_t mallo const std::vector& callsFrames) { if (type == 0) { - fprintf(g_fpHookFile.get(), "malloc;%" PRId64 ";%ld;0x%" PRIx64 ";%u\n", ts.tv_sec, ts.tv_nsec, - (uint64_t)addr, mallocSize); + fprintf(g_fpHookFile.get(), "malloc;%" PRId64 ";%ld;0x%" PRIx64 ";%u\n", + (int64_t)ts.tv_sec, ts.tv_nsec, (uint64_t)addr, mallocSize); } else if (type == 1) { - fprintf(g_fpHookFile.get(), "free;%" PRId64 ";%ld;0x%" PRIx64 "\n", ts.tv_sec, ts.tv_nsec, - (uint64_t)addr); + fprintf(g_fpHookFile.get(), "free;%" PRId64 ";%ld;0x%" PRIx64 "\n", + (int64_t)ts.tv_sec, ts.tv_nsec, (uint64_t)addr); } else { return; } @@ -195,4 +195,4 @@ bool StartHook(HookData& hookData) } // namespace Hook } // namespace Profiler } // namespace Developtools -} // namespace OHOS \ No newline at end of file +} // namespace OHOS -- Gitee