From d7210c2337a6284bbffa20ff516e2e4a2f5b5a72 Mon Sep 17 00:00:00 2001 From: yanghang Date: Sat, 19 Oct 2024 17:00:50 +0800 Subject: [PATCH] =?UTF-8?q?ipc-log=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanghang --- ipc/native/src/core/source/ipc_workthread.cpp | 6 +++--- ipc/native/src/core/source/message_parcel.cpp | 2 +- .../src/core/source/process_skeleton.cpp | 15 +++++---------- ipc/native/src/mock/source/binder_invoker.cpp | 4 +++- ipc/native/src/napi/src/napi_remote_proxy.cpp | 18 ++++++++---------- .../src/napi_common/source/napi_ashmem.cpp | 2 +- .../napi_common/source/napi_remote_object.cpp | 2 +- .../source/napi_remote_proxy_holder.cpp | 2 +- 8 files changed, 23 insertions(+), 28 deletions(-) diff --git a/ipc/native/src/core/source/ipc_workthread.cpp b/ipc/native/src/core/source/ipc_workthread.cpp index f23a5104..7c1abd1b 100644 --- a/ipc/native/src/core/source/ipc_workthread.cpp +++ b/ipc/native/src/core/source/ipc_workthread.cpp @@ -113,13 +113,13 @@ void *IPCWorkThread::ThreadHandler(void *args) return nullptr; } + IRemoteInvoker *invoker = IPCThreadSkeleton::GetRemoteInvoker(param->proto); std::string basicName = MakeBasicThreadName(param->proto, param->index); std::string threadName = basicName + "_" + std::to_string(syscall(SYS_gettid)); int32_t ret = prctl(PR_SET_NAME, threadName.c_str()); if (ret != 0) { ZLOGE(LOG_LABEL, "set thread name:%{public}s fail, ret:%{public}d", threadName.c_str(), ret); } else { - IRemoteInvoker *invoker = IPCThreadSkeleton::GetRemoteInvoker(param->proto); ZLOGI(LOG_LABEL, "proto:%{public}d policy:%{public}d name:%{public}s invoker:%{public}u", param->proto, param->policy, threadName.c_str(), ProcessSkeleton::ConvertAddr(invoker)); } @@ -131,8 +131,8 @@ void *IPCWorkThread::ThreadHandler(void *args) if (current != nullptr) { current->OnThreadTerminated(basicName); } - ZLOGW(LOG_LABEL, "exit, proto:%{public}d policy:%{public}d name:%{public}s", - param->proto, param->policy, threadName.c_str()); + ZLOGI(LOG_LABEL, "exit, proto:%{public}d policy:%{public}d name:%{public}s invoker:%{public}u", + param->proto, param->policy, threadName.c_str(), ProcessSkeleton::ConvertAddr(invoker)); delete param; return nullptr; } diff --git a/ipc/native/src/core/source/message_parcel.cpp b/ipc/native/src/core/source/message_parcel.cpp index b2b7eaa3..96f984f1 100644 --- a/ipc/native/src/core/source/message_parcel.cpp +++ b/ipc/native/src/core/source/message_parcel.cpp @@ -558,7 +558,7 @@ bool MessageParcel::Append(MessageParcel &data) { size_t dataSize = data.GetDataSize(); if (dataSize == 0) { - ZLOGE(LOG_LABEL, "no data to append"); + ZLOGI(LOG_LABEL, "no data to append"); return true; } uintptr_t dataPtr = data.GetData(); diff --git a/ipc/native/src/core/source/process_skeleton.cpp b/ipc/native/src/core/source/process_skeleton.cpp index 67d21ba0..180ac68c 100644 --- a/ipc/native/src/core/source/process_skeleton.cpp +++ b/ipc/native/src/core/source/process_skeleton.cpp @@ -135,7 +135,7 @@ bool ProcessSkeleton::DetachObject(IRemoteObject *object, const std::u16string & } if (iterator->second.GetRefPtr() != object) { - ZLOGD(LOG_LABEL, "can not erase it because addr if different, " + ZLOGI(LOG_LABEL, "can not erase it because addr if different, " "desc:%{public}s, recorded object:%{public}u, detach object:%{public}u", ConvertToSecureDesc(Str16ToStr8(descriptor)).c_str(), ConvertAddr(iterator->second.GetRefPtr()), ConvertAddr(object)); @@ -172,13 +172,8 @@ bool ProcessSkeleton::AttachObject(IRemoteObject *object, const std::u16string & } } auto result = objects_.insert_or_assign(descriptor, wp); - if (result.second) { - ZLOGD(LOG_LABEL, "attach %{public}d desc:%{public}s inserted", - ConvertAddr(object), ConvertToSecureDesc(Str16ToStr8(descriptor)).c_str()); - } else { - ZLOGW(LOG_LABEL, "attach %{public}d desc:%{public}s assign", - ConvertAddr(object), ConvertToSecureDesc(Str16ToStr8(descriptor)).c_str()); - } + ZLOGD(LOG_LABEL, "attach %{public}u desc:%{public}s type:%{public}s", + ConvertAddr(object), ConvertToSecureDesc(Str16ToStr8(descriptor)).c_str(), result.second ? "insert" : "assign"); return true; } @@ -211,12 +206,12 @@ sptr ProcessSkeleton::QueryObject(const std::u16string &descripto } std::u16string desc; if (!IsValidObject(remoteObject, desc)) { - ZLOGD(LOG_LABEL, "object %{public}d is inValid", ConvertAddr(remoteObject)); + ZLOGD(LOG_LABEL, "object %{public}u is inValid", ConvertAddr(remoteObject)); return result; } if (!remoteObject->AttemptIncStrong(this)) { - ZLOGD(LOG_LABEL, "object %{public}d AttemptIncStrong failed", ConvertAddr(remoteObject)); + ZLOGD(LOG_LABEL, "object %{public}u AttemptIncStrong failed", ConvertAddr(remoteObject)); return result; } diff --git a/ipc/native/src/mock/source/binder_invoker.cpp b/ipc/native/src/mock/source/binder_invoker.cpp index ffb853d6..674826ae 100644 --- a/ipc/native/src/mock/source/binder_invoker.cpp +++ b/ipc/native/src/mock/source/binder_invoker.cpp @@ -90,10 +90,12 @@ BinderInvoker::BinderInvoker() reinterpret_cast(this) }; input_.SetDataCapacity(IPC_DEFAULT_PARCEL_SIZE); binderConnector_ = BinderConnector::GetInstance(); + ZLOGD(LABEL, ":%{public}u", ProcessSkeleton::ConvertAddr(this)); } BinderInvoker::~BinderInvoker() { + ZLOGD(LABEL, ":%{public}u", ProcessSkeleton::ConvertAddr(this)); auto current = ProcessSkeleton::GetInstance(); if (current != nullptr) { current->DetachInvokerProcInfo(true); @@ -1011,7 +1013,7 @@ int BinderInvoker::HandleCommands(uint32_t cmd) { auto start = std::chrono::steady_clock::now(); int error = HandleCommandsInner(cmd); - if (error != ERR_NONE) { + if (error != ERR_NONE && error != -ERR_TIMED_OUT) { if (ProcessSkeleton::IsPrint(error, lastErr_, lastErrCnt_)) { ZLOGE(LABEL, "HandleCommands cmd:%{public}u error:%{public}d", cmd, error); PrintParcelData(input_, "input_"); diff --git a/ipc/native/src/napi/src/napi_remote_proxy.cpp b/ipc/native/src/napi/src/napi_remote_proxy.cpp index c48047e9..0325890d 100644 --- a/ipc/native/src/napi/src/napi_remote_proxy.cpp +++ b/ipc/native/src/napi/src/napi_remote_proxy.cpp @@ -415,7 +415,6 @@ napi_value NAPI_RemoteProxy_checkRegisterDeathRecipientArgs(napi_env env, size_t napi_value NAPI_RemoteProxy_registerDeathRecipient(napi_env env, napi_callback_info info) { - ZLOGI(LOG_LABEL, "register death recipient"); size_t argc = 2; napi_value argv[ARGV_LENGTH_2] = { 0 }; napi_value thisVar = nullptr; @@ -450,20 +449,19 @@ napi_value NAPI_RemoteProxy_registerDeathRecipient(napi_env env, napi_callback_i } sptr nativeRecipient = new NAPIDeathRecipient(env, argv[ARGV_INDEX_0]); - if (target->AddDeathRecipient(nativeRecipient)) { + bool ret = target->AddDeathRecipient(nativeRecipient); + if (ret) { NAPIDeathRecipientList *list = proxyHolder->list_; - if (list->Add(nativeRecipient)) { - ZLOGD(LOG_LABEL, "register recipient success"); - } + list->Add(nativeRecipient); } napi_value result = nullptr; napi_get_undefined(env, &result); + ZLOGI(LOG_LABEL, "%{public}s", ret ? "succ" : "fail"); return result; } napi_value NAPI_RemoteProxy_removeDeathRecipient(napi_env env, napi_callback_info info) { - ZLOGI(LOG_LABEL, "remove death recipient"); size_t argc = 2; napi_value argv[ARGV_LENGTH_2] = { 0 }; napi_value thisVar = nullptr; @@ -504,14 +502,14 @@ napi_value NAPI_RemoteProxy_removeDeathRecipient(napi_env env, napi_callback_inf napi_get_boolean(env, false, &result); return result; } - target->RemoveDeathRecipient(nativeRecipient); + bool ret = target->RemoveDeathRecipient(nativeRecipient); if (list->Remove(nativeRecipient)) { napi_get_boolean(env, true, &result); - return result; } else { napi_get_boolean(env, false, &result); - return result; } + ZLOGI(LOG_LABEL, "%{public}s", ret ? "succ" : "fail"); + return result; } napi_value NAPI_RemoteProxy_checkUnregisterDeathRecipientArgs(napi_env env, size_t argc, napi_value* argv) @@ -643,7 +641,7 @@ napi_value NAPI_RemoteProxy_getDescriptor(napi_env env, napi_callback_info info) napi_value NAPI_RemoteProxy_isObjectDead(napi_env env, napi_callback_info info) { - ZLOGI(LOG_LABEL, "call isObjectDead"); + ZLOGD(LOG_LABEL, "call isObjectDead"); napi_value thisVar = nullptr; napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); NAPIRemoteProxyHolder *holder = nullptr; diff --git a/ipc/native/src/napi_common/source/napi_ashmem.cpp b/ipc/native/src/napi_common/source/napi_ashmem.cpp index f4f0219b..b2764637 100644 --- a/ipc/native/src/napi_common/source/napi_ashmem.cpp +++ b/ipc/native/src/napi_common/source/napi_ashmem.cpp @@ -956,7 +956,7 @@ napi_value NAPIAshmem::Ashmem_JS_Constructor(napi_env env, napi_callback_info in napi_status status = napi_wrap( env, thisVar, napiAshmem, [](napi_env env, void *data, void *hint) { - ZLOGI(LOG_LABEL, "Ashmem destructed by js callback"); + ZLOGD(LOG_LABEL, "Ashmem destructed by js callback"); delete (reinterpret_cast(data)); }, nullptr, nullptr); diff --git a/ipc/native/src/napi_common/source/napi_remote_object.cpp b/ipc/native/src/napi_common/source/napi_remote_object.cpp index 46e60ef7..663b907a 100644 --- a/ipc/native/src/napi_common/source/napi_remote_object.cpp +++ b/ipc/native/src/napi_common/source/napi_remote_object.cpp @@ -367,7 +367,7 @@ static void OnJsRemoteRequestCallBack(uv_work_t *work, int status) uint64_t curTime = static_cast(std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()).count()); - ZLOGD(LOG_LABEL, "enter thread pool time:%{public}" PRIu64, curTime); + ZLOGI(LOG_LABEL, "enter thread pool time:%{public}" PRIu64, curTime); CallbackParam *param = reinterpret_cast(work->data); napi_handle_scope scope = nullptr; napi_open_handle_scope(param->env, &scope); diff --git a/ipc/native/src/napi_common/source/napi_remote_proxy_holder.cpp b/ipc/native/src/napi_common/source/napi_remote_proxy_holder.cpp index e7806f4d..eca73bdf 100644 --- a/ipc/native/src/napi_common/source/napi_remote_proxy_holder.cpp +++ b/ipc/native/src/napi_common/source/napi_remote_proxy_holder.cpp @@ -37,7 +37,7 @@ void NAPIDeathRecipient::AfterWorkCallback(uv_work_t *work, int status) ZLOGE(LOG_LABEL, "work or work->data is nullptr"); return; } - ZLOGI(LOG_LABEL, "start to call onRemoteDied"); + ZLOGD(LOG_LABEL, "start to call onRemoteDied"); OnRemoteDiedParam *param = reinterpret_cast(work->data); napi_handle_scope scope = nullptr; napi_open_handle_scope(param->env, &scope);