From 1469698232db992caf20901237eb9dfae9a83ab8 Mon Sep 17 00:00:00 2001 From: xionglei6 Date: Mon, 21 Feb 2022 17:40:23 +0800 Subject: [PATCH] add bootchart Signed-off-by: xionglei6 --- services/plugin/bootchart/bootchart.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/services/plugin/bootchart/bootchart.c b/services/plugin/bootchart/bootchart.c index 431731da3..5514fd031 100755 --- a/services/plugin/bootchart/bootchart.c +++ b/services/plugin/bootchart/bootchart.c @@ -112,13 +112,12 @@ static void BootchartLogProcessStat(FILE *log, pid_t pid) { static char path[255] = { }; // 255 path length static char nameBuffer[255] = { }; // 255 path length - // /proc//stat only has truncated task names, so get the full name from /proc//cmdline. int ret = sprintf_s(path, sizeof(path) - 1, "/proc/%d/cmdline", pid); PLUGIN_CHECK(ret > 0, return, "Failed to format path %d", pid); path[ret] = '\0'; char *name = ReadFileToBuffer(path, nameBuffer, sizeof(nameBuffer)); - // Read process stat line. + // Read process stat line ret = sprintf_s(path, sizeof(path) - 1, "/proc/%d/stat", pid); PLUGIN_CHECK(ret > 0, return, "Failed to format path %d", pid); path[ret] = '\0'; @@ -128,7 +127,6 @@ static void BootchartLogProcessStat(FILE *log, pid_t pid) return; } if (name != NULL && strlen(name) > 0) { - // Substitute the process name with its real name. char *end = NULL; char *start = strstr(stat, "("); if (start != NULL) { @@ -154,7 +152,7 @@ static void bootchartLogProcess(FILE *log) PLUGIN_CHECK(pDir != NULL, return, "Read dir /proc failed.%d", errno); struct dirent *entry; while ((entry = readdir(pDir)) != NULL) { - pid_t pid = (pid_t)atoi(entry->d_name); // // Only process processor + pid_t pid = (pid_t)atoi(entry->d_name); // Only process processor if (pid == 0) { continue; } @@ -228,7 +226,6 @@ static int DoBootchartStart(void) PLUGIN_LOGI("Invalid bootchart plugin"); return -1; } - // We don't care about the content, but we do care that /data/bootchart/enabled actually exists. char enable[4] = {}; // 4 enable size uint32_t size = sizeof(enable); if (g_pluginInterface->systemReadParam != NULL) {