From 40edbf0319e2ea92fc337badfc93241e0fc9d0c3 Mon Sep 17 00:00:00 2001 From: yangzk Date: Mon, 10 Jan 2022 18:43:52 +0800 Subject: [PATCH] add trace Signed-off-by: yangzk Change-Id: If64a01c2d79a7d8f20f9e8ea80e0c50e4ff5f7bb --- BUILD.gn | 1 + interfaces/innerkits/BUILD.gn | 5 ++++- src/appspawn_msg_peer.cpp | 2 ++ src/appspawn_server.cpp | 5 +++++ src/socket/client_socket.cpp | 4 ++++ test/unittest/app_spawn_msg_peer_test/BUILD.gn | 5 ++++- test/unittest/app_spawn_server_test/BUILD.gn | 2 ++ test/unittest/client_socket_test/BUILD.gn | 5 ++++- 8 files changed, 26 insertions(+), 3 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index d0e4d285..881a1805 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -62,6 +62,7 @@ ohos_static_library("appspawn_server") { "//utils/native/base:utils", ] external_deps = [ + "bytrace_standard:bytrace_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 8e7b6ebd..e934a5f6 100755 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -27,7 +27,10 @@ ohos_static_library("appspawn_socket_client") { include_dirs = [ "${appspawn_path}/include" ] public_configs = [ ":exported_header_files" ] deps = [ "//utils/native/base:utils" ] - external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + external_deps = [ + "bytrace_standard:bytrace_core", + "hiviewdfx_hilog_native:libhilog", + ] subsystem_name = "${subsystem_name}" part_name = "${part_name}" diff --git a/src/appspawn_msg_peer.cpp b/src/appspawn_msg_peer.cpp index 57e3826b..0ffd1fa5 100644 --- a/src/appspawn_msg_peer.cpp +++ b/src/appspawn_msg_peer.cpp @@ -17,6 +17,7 @@ #include +#include "bytrace.h" #include "hilog/log.h" #include "securec.h" @@ -48,6 +49,7 @@ int AppSpawnMsgPeer::GetConnectFd() const int AppSpawnMsgPeer::Response(pid_t pid) { + BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); if ((socket_ == nullptr) || (connectFd_ < 0)) { HiLog::Error(LABEL, "Invalid socket params: connectFd %d", connectFd_); return -1; diff --git a/src/appspawn_server.cpp b/src/appspawn_server.cpp index 38ccf1e4..f76db440 100644 --- a/src/appspawn_server.cpp +++ b/src/appspawn_server.cpp @@ -23,6 +23,7 @@ #include #include +#include "bytrace.h" #include "errors.h" #include "hilog/log.h" #include "main_thread.h" @@ -126,6 +127,7 @@ AppSpawnServer::AppSpawnServer(const std::string &socketName) void AppSpawnServer::MsgPeer(int connectFd) { + BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); char err_string[ERR_STRING_SZ]; std::unique_ptr msgPeer = std::make_unique(socket_, connectFd); if (msgPeer == nullptr || msgPeer->MsgPeer() != 0) { @@ -152,6 +154,7 @@ void AppSpawnServer::ConnectionPeer() continue; } + BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); mut_.lock(); // Ensure that mutex in SaveConnection is unlocked before being forked socket_->SaveConnection(connectFd); mut_.unlock(); @@ -188,6 +191,7 @@ bool AppSpawnServer::ServerMain(char *longProcName, int64_t longProcNameLen) dataCond_.wait(lock, [this] { return !this->appQueue_.empty(); }); std::unique_ptr msg = std::move(appQueue_.front()); appQueue_.pop(); + BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); int connectFd = msg->GetConnectFd(); ClientSocket::AppProperty *appProperty = msg->GetMsg(); if (!CheckAppProperty(appProperty)) { @@ -212,6 +216,7 @@ bool AppSpawnServer::ServerMain(char *longProcName, int64_t longProcNameLen) msg->Response(-errno); continue; } else if (pid == 0) { + BYTRACE_NAME(BYTRACE_TAG_APP, "fork MainThread"); SpecialHandle(appProperty); SetAppProcProperty(connectFd, appProperty, longProcName, longProcNameLen, fd); _exit(0); diff --git a/src/socket/client_socket.cpp b/src/socket/client_socket.cpp index c39a0c95..52a8bed1 100644 --- a/src/socket/client_socket.cpp +++ b/src/socket/client_socket.cpp @@ -19,6 +19,7 @@ #include #include +#include "bytrace.h" #include "hilog/log.h" #include "securec.h" @@ -58,6 +59,7 @@ void ClientSocket::CloseClient() int ClientSocket::ConnectSocket(int connectFd) { + BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); char err_string[ERR_STRING_SZ]; if (connectFd < 0) { HiLog::Error(LABEL, "Client: Invalid socket fd: %d", connectFd); @@ -92,11 +94,13 @@ int ClientSocket::ConnectSocket() int ClientSocket::WriteSocketMessage(const void *buf, int len) { + BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); return WriteSocketMessage(socketFd_, buf, len); } int ClientSocket::ReadSocketMessage(void *buf, int len) { + BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); return ReadSocketMessage(socketFd_, buf, len); } } // namespace AppSpawn diff --git a/test/unittest/app_spawn_msg_peer_test/BUILD.gn b/test/unittest/app_spawn_msg_peer_test/BUILD.gn index 525b7f05..857f40ed 100644 --- a/test/unittest/app_spawn_msg_peer_test/BUILD.gn +++ b/test/unittest/app_spawn_msg_peer_test/BUILD.gn @@ -29,7 +29,10 @@ ohos_unittest("AppSpawnMsgPeerTest") { deps = [ "${appspawn_path}/test:appspawn_test_source" ] - external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + external_deps = [ + "bytrace_standard:bytrace_core", + "hiviewdfx_hilog_native:libhilog", + ] } group("unittest") { diff --git a/test/unittest/app_spawn_server_test/BUILD.gn b/test/unittest/app_spawn_server_test/BUILD.gn index 4ac518e2..9734cae0 100755 --- a/test/unittest/app_spawn_server_test/BUILD.gn +++ b/test/unittest/app_spawn_server_test/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("AppSpawnServerOverrideTest") { deps = [ "${appspawn_path}/test:appspawn_test_source" ] external_deps = [ + "bytrace_standard:bytrace_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] @@ -59,6 +60,7 @@ ohos_unittest("AppSpawnServerMockTest") { deps = [ "${appspawn_path}/test:appspawn_test_source" ] external_deps = [ + "bytrace_standard:bytrace_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/client_socket_test/BUILD.gn b/test/unittest/client_socket_test/BUILD.gn index 3b52e5af..42e733d9 100644 --- a/test/unittest/client_socket_test/BUILD.gn +++ b/test/unittest/client_socket_test/BUILD.gn @@ -30,7 +30,10 @@ ohos_unittest("ClientSocketTest") { deps = [ "${appspawn_path}/test:appspawn_test_source" ] - external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + external_deps = [ + "bytrace_standard:bytrace_core", + "hiviewdfx_hilog_native:libhilog", + ] } group("unittest") { -- Gitee