diff --git a/device/plugins/native_hook/src/hook_client.cpp b/device/plugins/native_hook/src/hook_client.cpp index c3b2c9916a6a2ed00596974cefabd40f7c17b61f..bf947ee46b1b60647bcd9ba0b2fb50764673cb3d 100644 --- a/device/plugins/native_hook/src/hook_client.cpp +++ b/device/plugins/native_hook/src/hook_client.cpp @@ -32,6 +32,7 @@ #include "musl_preinit_common.h" #include "parameter.h" #include "stack_writer.h" +#include "socket_context.h" #include "runtime_stack_range.h" #include "get_thread_id.h" #include "hook_client.h" @@ -285,15 +286,6 @@ void* MallocHookStart(void* disableHookCallback) return nullptr; } PROFILER_LOG_INFO(LOG_CORE, "MallocHookStart begin!"); - g_addrHandler = std::make_shared(); -#ifdef __aarch64__ - g_wholeAddrHandler = std::make_shared(); - g_midPartHandler = std::make_shared(); - g_midPartHandler->SetSuccessor(std::move(g_wholeAddrHandler)); - g_addrHandler->SetSuccessor(std::move(g_midPartHandler)); - g_wholeAddrHandler = nullptr; - g_midPartHandler = nullptr; -#endif g_mallocTimes = 0; g_hookClient.reset(); g_hookPid = GetRealPid(); @@ -306,6 +298,17 @@ void* MallocHookStart(void* disableHookCallback) g_hookClient = std::make_shared(g_hookPid.load(), &g_ClientConfig, &g_sampler, &targetedRange, &g_sharedMemCount, reinterpret_cast(disableHookCallback)); + if (g_hookClient->Connect(DEFAULT_UNIX_SOCKET_HOOK_FULL_PATH)) { + g_addrHandler = std::make_shared(); +#ifdef __aarch64__ + g_wholeAddrHandler = std::make_shared(); + g_midPartHandler = std::make_shared(); + g_midPartHandler->SetSuccessor(std::move(g_wholeAddrHandler)); + g_addrHandler->SetSuccessor(std::move(g_midPartHandler)); + g_wholeAddrHandler = nullptr; + g_midPartHandler = nullptr; +#endif + } } g_hookReady = true; return nullptr; diff --git a/device/plugins/native_hook/src/hook_socket_client.cpp b/device/plugins/native_hook/src/hook_socket_client.cpp index bbc7c3e032d1d308f8d4e30026f4f6204f63353b..ebef47a800f580ae7ec68de2bf725ccf60487f83 100644 --- a/device/plugins/native_hook/src/hook_socket_client.cpp +++ b/device/plugins/native_hook/src/hook_socket_client.cpp @@ -91,7 +91,6 @@ HookSocketClient::HookSocketClient(int pid, ClientConfig *config, Sampling *samp stackWriterList_.reserve(sharedMemCount); unixSocketClient_ = nullptr; serviceName_ = "HookService"; - Connect(DEFAULT_UNIX_SOCKET_HOOK_FULL_PATH); } HookSocketClient::~HookSocketClient()