提交 e36489b0 编写于 作者: C cheng_jinsong

fix dump trigger

Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
上级 7cf030e7
......@@ -30,6 +30,7 @@ int AclGetDevUdid(char *udid, int size)
if (udid == nullptr || size < UDID_LEN) {
return -1;
}
(void)memset_s(udid, size, 0, size);
#ifdef PARAM_FEATURE_DEVICEINFO
std::string result = {};
OHOS::device_info::DeviceInfoKits &instance = OHOS::device_info::DeviceInfoKits::GetInstance();
......
......@@ -74,6 +74,6 @@ MODULE_CONSTRUCTOR(void)
{"bootchart", bootchartCmdStop, "bootchart stop", "bootchart stop", "bootchart stop"},
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i]);
}
}
......@@ -30,14 +30,17 @@ static int main_cmd(BShellHandle shell, int argc, char **argv)
printf("dump service info \n");
CmdClientInit(INIT_CONTROL_FD_SOCKET_PATH, ACTION_DUMP, argv[1]);
} else if (argc == DUMP_SERVICE_BOOTEVENT_CMD_ARGS) {
if (strcmp(argv[1], "bootevent") == 0) {
printf("dump service bootevent info \n");
} else if (strcmp(argv[1], "parameter_service") == 0) {
printf("dump parameter service info \n");
}
size_t serviceNameLen = strlen(argv[1]) + strlen(argv[2]) + 2; // 2 is \0 and #
char *serviceBootevent = (char *)calloc(1, serviceNameLen);
BEGET_ERROR_CHECK(serviceBootevent != NULL, return 0, "failed to allocate bootevent memory");
BEGET_ERROR_CHECK(sprintf_s(serviceBootevent, serviceNameLen, "%s#%s", argv[1], argv[2]) >= 0,
free(serviceBootevent); return 0, "dumpservice arg create failed");
CmdClientInit(INIT_CONTROL_FD_SOCKET_PATH, ACTION_DUMP, serviceBootevent);
free(serviceBootevent);
char *cmd = (char *)calloc(1, serviceNameLen);
BEGET_ERROR_CHECK(sprintf_s(cmd, serviceNameLen, "%s#%s", argv[1], argv[2]) >= 0, free(cmd);
return 0, "dump service arg create failed");
CmdClientInit(INIT_CONTROL_FD_SOCKET_PATH, ACTION_DUMP, cmd);
free(cmd);
} else {
BShellCmdHelp(shell, argc, argv);
}
......@@ -49,17 +52,26 @@ static int ClearBootEvent(BShellHandle shell, int argc, char **argv)
return SystemSetParameter("ohos.servicectrl.clear", "bootevent");
}
static int SaveBootEvent(BShellHandle shell, int argc, char **argv)
{
return SystemSetParameter("ohos.servicectrl.save", "bootevent");
}
MODULE_CONSTRUCTOR(void)
{
const CmdInfo infos[] = {
{"dump_service", main_cmd, "dump one service info by serviceName", "dump_service serviceName", NULL},
{"dump_service", main_cmd, "dump one service bootevent", "dump_service serviceName bootevent", NULL},
{"dump_service", main_cmd, "dump all services info", "dump_service all", NULL},
{"dump_service", main_cmd, "dump parameter-service trigger",
"dump_service parameter_service trigger", "dump_service parameter_service trigger"},
{"dump_service", main_cmd, "dump all services bootevent", "dump_service all bootevent", NULL},
{"service", ClearBootEvent, "Clear all services bootevent", "service clear bootevent",
"service clear bootevent"},
{"service", SaveBootEvent, "Save all services bootevent", "service save bootevent",
"service save bootevent"},
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i]);
}
}
......@@ -77,6 +77,6 @@ MODULE_CONSTRUCTOR(void)
#endif
};
for (size_t i = sizeof(infos) / sizeof(infos[0]); i > 0; i--) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i - 1]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i - 1]);
}
}
......@@ -224,6 +224,6 @@ MODULE_CONSTRUCTOR(void)
}
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i]);
}
}
......@@ -59,6 +59,6 @@ MODULE_CONSTRUCTOR(void)
"modulectl uninstall moduleName", "modulectl uninstall"},
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i]);
}
}
......@@ -435,7 +435,7 @@ static int32_t BShellParamCmdRegForShell(BShellHandle shell)
{"pwd", BShellParamCmdPwd, "display current parameter", "pwd", NULL},
};
for (size_t i = sizeof(infos) / sizeof(infos[0]); i > 0; i--) {
BShellEnvRegitsterCmd(shell, &infos[i - 1]);
BShellEnvRegisterCmd(shell, &infos[i - 1]);
}
return 0;
}
......@@ -451,7 +451,7 @@ static int32_t BShellParamCmdRegForIndepent(BShellHandle shell)
{"param", BShellParamCmdShell, "shell system parameter", "param shell [name]", "param shell"},
};
for (size_t i = sizeof(infos) / sizeof(infos[0]); i > 0; i--) {
BShellEnvRegitsterCmd(shell, &infos[i - 1]);
BShellEnvRegisterCmd(shell, &infos[i - 1]);
}
return 0;
}
......
......@@ -108,6 +108,6 @@ MODULE_CONSTRUCTOR(void)
}
};
for (size_t i = sizeof(infos) / sizeof(infos[0]); i > 0; i--) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i - 1]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i - 1]);
}
}
......@@ -201,6 +201,6 @@ MODULE_CONSTRUCTOR(void)
}
};
for (size_t i = 0; i < ARRAY_LENGTH(infos); i++) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i]);
}
}
......@@ -76,6 +76,6 @@ MODULE_CONSTRUCTOR(void)
{"timer_stop", main_cmd, "stop service timer", "timer_stop servicename", ""},
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i]);
}
}
......@@ -93,7 +93,7 @@ int BShellEnvInit(BShellHandle *handle, const BShellInfo *info);
int BShellEnvStart(BShellHandle handle);
void BShellEnvDestory(BShellHandle handle);
int BShellEnvRegitsterCmd(BShellHandle handle, const CmdInfo *cmdInfo);
int BShellEnvRegisterCmd(BShellHandle handle, const CmdInfo *cmdInfo);
int BShellEnvSetParam(BShellHandle handle, const char *name, const char *desc, BShellParamType type, void *value);
const BShellParam *BShellEnvGetParam(BShellHandle handle, const char *name);
int BShellEnvRegisterKeyHandle(BShellHandle handle, uint8_t code, BShellkeyHandle keyHandle);
......
......@@ -436,7 +436,7 @@ int BShellEnvStart(BShellHandle handle)
{"help", BShellCmdHelp, "help command", "help"}
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(handle, &infos[i]);
BShellEnvRegisterCmd(handle, &infos[i]);
}
return 0;
}
......@@ -500,7 +500,7 @@ void BShellEnvDestory(BShellHandle handle)
free(shell);
}
int32_t BShellEnvRegitsterCmd(BShellHandle handle, const CmdInfo *cmdInfo)
int32_t BShellEnvRegisterCmd(BShellHandle handle, const CmdInfo *cmdInfo)
{
BSH_CHECK(handle != NULL, return BSH_INVALID_PARAM, "Invalid shell env");
BSH_CHECK(cmdInfo != NULL && cmdInfo->name != NULL, return BSH_INVALID_PARAM, "Invalid cmd name");
......
......@@ -25,6 +25,7 @@
#include "init_utils.h"
#include "init_log.h"
#include "init_group_manager.h"
#include "init_param.h"
#include "hookmgr.h"
#include "bootstage.h"
......@@ -187,6 +188,12 @@ static void ProcessDumpServiceControlFd(uint16_t type, const char *serviceCmd)
}
return;
}
if (strcmp(serviceCmd, "parameter_service") == 0) {
if (cmd != NULL && strcmp(cmd, "trigger") == 0) {
SystemDumpTriggers(0);
}
return;
}
Service *service = GetServiceByName(serviceCmd);
if (service != NULL) {
if (cmd != NULL) {
......
......@@ -127,12 +127,7 @@ INIT_LOCAL_API void ParamWorBaseLog(InitLogLevel logLevel, uint32_t domain, cons
exper; \
}
#ifdef INIT_AGENT
#define PARAM_DUMP printf
#else
#define PARAM_DUMP PARAM_LOGI
#endif
#define MAX_LABEL_LEN 256
#define PARAM_BUFFER_SIZE 256
......
......@@ -474,15 +474,15 @@ int CheckTrigger(TriggerWorkSpace *workSpace, int type,
static void DumpJobTrigger_(const TriggerWorkSpace *workSpace, const TriggerNode *trigger)
{
const JobNode *node = (const JobNode *)trigger;
PARAM_DUMP("trigger 0x%08x \n", trigger->flags);
PARAM_DUMP("trigger name %s \n", node->name);
PARAM_DUMP("trigger condition %s \n", node->condition);
PARAM_DUMP("trigger flags: 0x%08x \n", trigger->flags);
PARAM_DUMP("trigger name: %s \n", node->name);
PARAM_DUMP("trigger condition: %s \n", node->condition);
const int maxCmd = 1024;
int count = 0;
CommandNode *cmd = GetNextCmdNode(node, NULL);
while (cmd != NULL && count < maxCmd) {
PARAM_DUMP("\t command name %s \n", GetCmdKey(cmd->cmdKeyIndex));
PARAM_DUMP("\t command args %s \n", cmd->content);
PARAM_DUMP(" command name: %s \n", GetCmdKey(cmd->cmdKeyIndex));
PARAM_DUMP(" command args: %s \n", cmd->content);
cmd = GetNextCmdNode(node, cmd);
count++;
}
......@@ -491,19 +491,19 @@ static void DumpJobTrigger_(const TriggerWorkSpace *workSpace, const TriggerNode
static void DumpWatchTrigger_(const TriggerWorkSpace *workSpace, const TriggerNode *trigger)
{
const WatchNode *node = (const WatchNode *)trigger;
PARAM_DUMP("trigger 0x%08x \n", trigger->flags);
PARAM_DUMP("trigger condition %s \n", trigger->condition);
PARAM_DUMP("trigger watchId %d \n", node->watchId);
PARAM_DUMP("trigger flags: 0x%08x \n", trigger->flags);
PARAM_DUMP("trigger condition: %s \n", trigger->condition);
PARAM_DUMP("trigger watchId: %d \n", node->watchId);
}
static void DumpWaitTrigger_(const TriggerWorkSpace *workSpace, const TriggerNode *trigger)
{
const WaitNode *node = (const WaitNode *)trigger;
PARAM_DUMP("trigger 0x%08x \n", trigger->flags);
PARAM_DUMP("trigger name %s \n", GetTriggerName(trigger));
PARAM_DUMP("trigger condition %s \n", trigger->condition);
PARAM_DUMP("trigger waitId %d \n", node->waitId);
PARAM_DUMP("trigger timeout %d \n", node->timeout);
PARAM_DUMP("trigger flags: 0x%08x \n", trigger->flags);
PARAM_DUMP("trigger name: %s \n", GetTriggerName(trigger));
PARAM_DUMP("trigger condition: %s \n", trigger->condition);
PARAM_DUMP("trigger waitId: %d \n", node->waitId);
PARAM_DUMP("trigger timeout: %d \n", node->timeout);
}
static void DumpTrigger_(const TriggerWorkSpace *workSpace, int type)
......@@ -522,7 +522,6 @@ void SystemDumpTriggers(int verbose)
{
TriggerWorkSpace *workSpace = GetTriggerWorkSpace();
PARAM_CHECK(workSpace != NULL, return, "Invalid workSpace ");
PARAM_DUMP("Ready to dump all trigger memory \n");
PARAM_DUMP("workspace queue BOOT info:\n");
DumpTrigger_(workSpace, TRIGGER_BOOT);
PARAM_DUMP("workspace queue parameter info:\n");
......@@ -540,7 +539,7 @@ void SystemDumpTriggers(int verbose)
for (uint32_t index = workSpace->executeQueue.startIndex; index < workSpace->executeQueue.endIndex; index++) {
TriggerNode *trigger = workSpace->executeQueue.executeQueue[index % workSpace->executeQueue.queueCount];
if (trigger != 0) {
PARAM_DUMP("queue node trigger name: %s \n", GetTriggerName(trigger));
PARAM_DUMP(" queue node trigger name: %s \n", GetTriggerName(trigger));
}
}
}
......
......@@ -164,7 +164,7 @@ int32_t BShellCmdRegister(BShellHandle shell, int execMode)
{"init", BShellParamCmdGroupTest, "init group test", "init group test [stage]", "init group test"},
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(shell, &infos[i]);
BShellEnvRegisterCmd(shell, &infos[i]);
}
} else {
const CmdInfo infos[] = {
......@@ -177,7 +177,7 @@ int32_t BShellCmdRegister(BShellHandle shell, int execMode)
{"display", BShellParamCmdUdidGet, "display udid", "display udid", "display udid"},
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i]);
}
}
return 0;
......
......@@ -93,6 +93,6 @@ MODULE_CONSTRUCTOR(void)
{(char *)"dump", SysParaApiDumpCmd, (char *)"dump api", (char *)"dump api", (char *)"dump api"},
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
BShellEnvRegisterCmd(GetShellHandle(), &infos[i]);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册