!58 新增特性:应用启动流程和组件切换流程trace

Merge pull request !58 from yangzk/rk_dev
This commit is contained in:
openharmony_ci 2022-01-11 07:25:04 +00:00 committed by Gitee
commit a70132af38
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 26 additions and 3 deletions

View File

@ -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",
]

View File

@ -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}"

View File

@ -17,6 +17,7 @@
#include <memory>
#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;

View File

@ -23,6 +23,7 @@
#include <sys/capability.h>
#include <thread>
#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<AppSpawnMsgPeer> msgPeer = std::make_unique<AppSpawnMsgPeer>(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<AppSpawnMsgPeer> 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);

View File

@ -19,6 +19,7 @@
#include <iostream>
#include <sys/socket.h>
#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

View File

@ -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") {

View File

@ -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",
]

View File

@ -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") {