From 1da0e433b6cc9ee90ecbb468f4d5c45edffc677b Mon Sep 17 00:00:00 2001 From: chen Date: Sat, 12 Nov 2022 16:23:14 +0800 Subject: [PATCH] add print Signed-off-by: chen Change-Id: Ida9d4287c326a7e28464ec521daca25215ab372a --- samgr_endpoint/source/endpoint.c | 23 +++++++++++++++++++++-- samgr_server/source/samgr_server.c | 13 +++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/samgr_endpoint/source/endpoint.c b/samgr_endpoint/source/endpoint.c index b9af601..d73da9b 100644 --- a/samgr_endpoint/source/endpoint.c +++ b/samgr_endpoint/source/endpoint.c @@ -102,6 +102,7 @@ Endpoint *SAMGR_CreateEndpoint(const char *name, RegisterEndpoint registry) int SAMGR_AddRouter(Endpoint *endpoint, const SaName *saName, const Identity *id, IUnknown *proxy) { + printf("HUAWEI_LOG: %s, %s, %s, %s, %d, pid:%d tid:%ld\r\n", __func__, __FILE__, saName->service, saName->feature, __LINE__, getpid(),(long int)syscall(224)); if (endpoint == NULL || id == NULL || proxy == NULL || saName == NULL) { return EC_INVALID; } @@ -134,7 +135,9 @@ int SAMGR_AddRouter(Endpoint *endpoint, const SaName *saName, const Identity *id SAMGR_Free(router); return EC_FAILURE; } + printf("HUAWEI_LOG: %s, %s, %s, %s, %d, pid : %d tid :%ld\r\n", __func__, __FILE__, saName->service, saName->feature, __LINE__, getpid(),(long int)syscall(224)); Listen(endpoint); + printf("HUAWEI_LOG: %s, %s, %s, %s, %d, pid : %d, tid:%ld\r\n", __func__, __FILE__, saName->service, saName->feature, __LINE__, getpid(),(long int)syscall(224)); return index; } @@ -311,6 +314,7 @@ static void Listen(Endpoint *endpoint) if (endpoint->boss != NULL) { return; } + printf("HUAWEI_LOG: Register endpoint<%s>, %s, %s, %d, pid : %d tid :%ld\r\n", endpoint->name, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); ThreadAttr attr = {endpoint->name, MAX_STACK_SIZE, PRI_ABOVE_NORMAL, 0, 0}; endpoint->boss = (ThreadId)THREAD_Create(Receive, endpoint, &attr); } @@ -357,17 +361,20 @@ static void *Receive(void *argv) if (endpoint == NULL || endpoint->registerEP == NULL) { return NULL; } - + printf("HUAWEI_LOG: endpoint<%s>, %s, %s, %d, pid : %d,tid:%ld\r\n", endpoint->name, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); int ret = EC_INVALID; uint32 retry = 0; while (retry < MAX_RETRY_TIMES) { + printf("HUAWEI_LOG: endpoint<%s>, %s, %s, %d, pid:%d,tid:%ld\r\n", endpoint->name, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); ret = endpoint->registerEP(endpoint->context, &endpoint->identity); if (ret == EC_SUCCESS) { + printf("HUAWEI_LOG: endpoint<%s>, %s, %s, %d,pid:%d,tid:%ld\r\n", endpoint->name, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); SvcIdentity samgr = {SAMGR_HANDLE, SAMGR_TOKEN, SAMGR_COOKIE}; (void)UnregisterDeathCallback(samgr, endpoint->deadId); (void)RegisterDeathCallback(endpoint->context, samgr, OnSamgrServerExit, endpoint, &endpoint->deadId); break; } + printf("HUAWEI_LOG: endpoint<%s>, %s, %s, %d,pid:%d,tid:%ld\r\n", endpoint->name, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); ++retry; usleep(RETRY_INTERVAL); } @@ -377,13 +384,15 @@ static void *Receive(void *argv) endpoint->name, endpoint->identity.handle); exit(-ret); } - + printf("HUAWEI_LOG: endpoint<%s>, %s, %s, %d,pid:%d,tid:%ld\r\n", endpoint->name, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); endpoint->running = TRUE; if (endpoint->identity.handle != SAMGR_HANDLE) { + printf("HUAWEI_LOG: endpoint<%s>, %s, %s, %d,pid:%d,tid:%ld\r\n", endpoint->name, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); int remain = RegisterRemoteFeatures(endpoint); HILOG_INFO(HILOG_MODULE_SAMGR, "Register endpoint<%s> and iunknown finished! remain<%d> iunknown!", endpoint->name, remain); } + printf("HUAWEI_LOG: endpoint<%s>, %s, %s, %d,pid:%d,tid:%ld\r\n", endpoint->name, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); StartLoop(endpoint->context, Dispatch, endpoint); return NULL; } @@ -490,6 +499,7 @@ static IServerProxy *GetIServerProxy(const Router *router) static int RegisterIdentity(const IpcContext *context, const SaName *saName, SvcIdentity *saInfo, PolicyTrans **policy, uint32 *policyNum) { + printf("HUAWEI_LOG: saName %s, %s, %s, %d,pid:%d,tid:%ld\r\n", saName->service, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); IpcIo req; uint8 data[MAX_DATA_LEN]; IpcIoInit(&req, data, MAX_DATA_LEN, 0); @@ -497,7 +507,9 @@ static int RegisterIdentity(const IpcContext *context, const SaName *saName, Svc IpcIoPushUint32(&req, OP_PUT); IpcIoPushString(&req, saName->service); IpcIoPushBool(&req, saName->feature == NULL); + printf("HUAWEI_LOG: saName %s, %s, %s, %d,pid:%d,tid:%ld\r\n", saName->service, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); if (saName->feature != NULL) { + printf("HUAWEI_LOG: saName %s, %s, %s, %d,pid:%d,tid:%ld\r\n", saName->service, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); IpcIoPushString(&req, saName->feature); } IpcIoPushUint32(&req, saInfo->token); @@ -505,15 +517,19 @@ static int RegisterIdentity(const IpcContext *context, const SaName *saName, Svc void *replyBuf = NULL; SvcIdentity samgr = {SAMGR_HANDLE, SAMGR_TOKEN, SAMGR_COOKIE}; int ret = Transact(context, samgr, INVALID_INDEX, &req, &reply, LITEIPC_FLAG_DEFAULT, (uintptr_t *)&replyBuf); + printf("HUAWEI_LOG: saName %s, %s, %s, %d,pid:%d,tid:%ld\r\n", saName->service, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); ret = -ret; if (ret == LITEIPC_OK) { + printf("HUAWEI_LOG: saName %s, %s, %s, %d,pid:%d,tid:%ld\r\n", saName->service, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); ret = IpcIoPopInt32(&reply); } if (ret == EC_SUCCESS) { + printf("HUAWEI_LOG: saName %s, %s, %s, %d,pid:%d,tid:%ld\r\n", saName->service, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); IpcIoPopSvc(&reply); GetRemotePolicy(&reply, policy, policyNum); } if (replyBuf != NULL) { + printf("HUAWEI_LOG: saName %s, %s, %s, %d,pid:%d,tid:%ld\r\n", saName->service, __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); FreeBuffer(context, replyBuf); } return ret; @@ -527,6 +543,7 @@ static int RegisterRemoteFeatures(Endpoint *endpoint) SvcIdentity identity; for (i = 0; i < size; ++i) { Router *router = VECTOR_At(&endpoint->routers, i); + printf("RegisterRemoteFeature enter<%s,%s>, %s, %s, %d\r\n",router->saName.service, router->saName.feature, __func__, __FILE__, __LINE__); if (router == NULL) { continue; } @@ -546,6 +563,7 @@ static int RegisterRemoteFeatures(Endpoint *endpoint) static int RegisterRemoteEndpoint(const IpcContext *context, SvcIdentity *identity) { + printf("HUAWEI_LOG: %s, %s, %d,pid:%d,tid:%ld\r\n", __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); IpcIo req; uint8 data[MAX_DATA_LEN]; IpcIoInit(&req, data, MAX_DATA_LEN, 0); @@ -553,6 +571,7 @@ static int RegisterRemoteEndpoint(const IpcContext *context, SvcIdentity *identi IpcIoPushUint32(&req, OP_POST); uint32 retry = 0; while (retry < MAX_RETRY_TIMES) { + printf("HUAWEI_LOG: %s, %s, %d,pid:%d,tid:%ld\r\n", __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); ++retry; IpcIo reply; void *replyBuf = NULL; diff --git a/samgr_server/source/samgr_server.c b/samgr_server/source/samgr_server.c index 650bcfe..0291276 100644 --- a/samgr_server/source/samgr_server.c +++ b/samgr_server/source/samgr_server.c @@ -146,6 +146,7 @@ static TaskConfig GetTaskConfig(Service *service) static int32 Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, IpcIo *reply) { + printf("HUAWEI_LOG: %s, %s, %d, pid:%d tid:%ld\r\n", __func__, __FILE__, __LINE__, getpid(),(long int)syscall(224)); SamgrServer *server = GET_OBJECT(iProxy, SamgrServer, iUnknown); uint32_t resource = IpcIoPopUint32(req); uint32_t option = IpcIoPopUint32(req); @@ -158,8 +159,10 @@ static int32 Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, static int ProcEndpoint(SamgrServer *server, int32 option, void *origin, IpcIo *req, IpcIo *reply) { + printf("HUAWEI_LOG: %s step0, %s, %d, callingpid:%d tid:%ld\r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin),(long int)syscall(224)); if (option != OP_POST) { IpcIoPushUint32(reply, (uint32)INVALID_INDEX); + printf("HUAWEI_LOG: %s step1 , %s, %d, callingpid:%d tid:%ld\r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin),(long int)syscall(224)); return EC_FAILURE; } @@ -171,6 +174,7 @@ static int ProcEndpoint(SamgrServer *server, int32 option, void *origin, IpcIo * SvcIdentity identity = {(uint32)INVALID_INDEX, (uint32)INVALID_INDEX, (uint32)INVALID_INDEX}; (void)GenServiceHandle(&identity, GetCallingTid(origin)); #ifdef __LINUX__ + printf("HUAWEI_LOG: %s step2, %s, %d, callingpid:%d tid:%ld\r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin), (long int)syscall(224)); IpcMsg* data = (IpcMsg*)origin; if (data == NULL) { HILOG_ERROR(HILOG_MODULE_SAMGR, "Register Endpoint origin null pointer!"); @@ -197,10 +201,12 @@ static int ProcEndpoint(SamgrServer *server, int32 option, void *origin, IpcIo * static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, IpcIo *reply, SvcIdentity *identity) { + printf("HUAWEI_LOG: %s step0, %s, %d, callingpid:%d tid:%ld\r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin),(long int)syscall(224)); size_t len = 0; char *service = (char *)IpcIoPopString(req, &len); if (service == NULL || len == 0) { IpcIoPushInt32(reply, EC_INVALID); + printf("HUAWEI_LOG: %s step1, %s, %d, callingpid:%d tid:%ld\r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin),(long int)syscall(224)); return EC_INVALID; } pid_t pid = GetCallingPid(origin); @@ -219,6 +225,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, if (identity->handle != INVALID_INDEX && identity->handle != handle.handle) { MUTEX_Unlock(server->mtx); IpcIoPushInt32(reply, EC_INVALID); + printf("HUAWEI_LOG: %s step2, %s, %d, callingpid:%d tid:%ld\r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin),(long int)syscall(224)); return EC_INVALID; } identity->token = IpcIoPopUint32(req); @@ -228,6 +235,7 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req, RegParams regParams = {service, feature, handle.uid, handle.pid}; uint32 policyNum = 0; int ret = g_server.ipcAuth->GetCommunicationStrategy(regParams, &policy, &policyNum); + printf("HUAWEI_LOG: %s step3, %s, %d, callingpid:%d \r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin)); if (ret != EC_SUCCESS || policy == NULL) { MUTEX_Unlock(server->mtx); SAMGR_Free(policy); @@ -335,8 +343,10 @@ static int32 ProcGetFeature(SamgrServer *server, const void *origin, IpcIo *req, static int ProcFeature(SamgrServer *server, int32 option, void *origin, IpcIo *req, IpcIo *reply) { + printf("HUAWEI_LOG: %s step0, %s, %d, callingpid:%d \r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin)); if (option != OP_PUT && option != OP_GET) { IpcIoPushInt32(reply, EC_INVALID); + printf("HUAWEI_LOG: %s step1, %s, %d, callingpid:%d \r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin)); return EC_INVALID; } @@ -345,15 +355,18 @@ static int ProcFeature(SamgrServer *server, int32 option, void *origin, IpcIo *r } if (g_server.ipcAuth == NULL) { IpcIoPushInt32(reply, EC_NOINIT); + printf("HUAWEI_LOG: %s step2, %s, %d, callingpid:%d \r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin)); return EC_NOINIT; } int ret = EC_SUCCESS; SvcIdentity identity = {INVALID_INDEX, INVALID_INDEX, INVALID_INDEX}; if (option == OP_PUT) { + printf("HUAWEI_LOG: %s step3, %s, %d, callingpid:%d \r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin)); ret = ProcPutFeature(server, origin, req, reply, &identity); } if (ret != EC_SUCCESS) { + printf("HUAWEI_LOG: %s step4, %s,%d, callingpid:%d \r\n", __func__, __FILE__, __LINE__, GetCallingPid(origin)); return ret; } -- Gitee