Increase the buffer size of PID 62/289062/2 accepted/tizen/unified/20230309.161422
authorSung-hun Kim <sfoon.kim@samsung.com>
Tue, 28 Feb 2023 05:16:22 +0000 (14:16 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Tue, 28 Feb 2023 07:55:49 +0000 (16:55 +0900)
If the length of a PID number crosses 5, printed PID spoils the format
of the trace. In this case, systrace viewer cannot parse this trace.

To prevent this situation, this patch increases the buffer size of
PID from 5 to 8. It will be safe as long as PID is less or equal than
99,999,999.

Change-Id: Ia374a8b9846402f2578dd5bbefc1eabd75cd319b
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
src/ttrace.c

index 426d2723112174e84f89b0ef0d9e738052270bb0..f1585e2f17fa04448d4459c3a33b25cc0a9b8764 100755 (executable)
@@ -45,7 +45,7 @@
 #define MAX_TRACE_LEN 1024
 #define MAX_LEN 512
 #define MAX_TAIL_LEN 13
-#define MAX_HEAD_LEN 8
+#define MAX_HEAD_LEN 11
 #define POS_LABEL_ST (MAX_LEN - MAX_HEAD_LEN)
 #define POS_LABEL_ED (MAX_LEN - MAX_TAIL_LEN)
 
@@ -159,7 +159,7 @@ void traceBegin(uint64_t tag, const char *name, ...)
                TTRACE_LOG("traceBegin:: write >> tag: %" PRIu64 " tag_bit: %" PRIu64, tag, *cur_enabled_tag);
 
                va_start(ap, name);
-               snprintf(buf, MAX_LEN, "B|%5d|", getpid());
+               snprintf(buf, MAX_LEN, "B|%8d|", getpid());
                len += vsnprintf(buf + MAX_HEAD_LEN, POS_LABEL_ST, name, ap);
                va_end(ap);
 
@@ -216,7 +216,7 @@ void traceAsyncBegin(uint64_t tag, int32_t cookie, const char *name, ...)
                TTRACE_LOG("traceAsyncBegin:: write >> tag: %" PRIu64 " tag_bit: %" PRIu64 " cookie: %d", tag, *cur_enabled_tag, cookie);
 
                va_start(ap, name);
-               snprintf(buf, MAX_LEN, "S|%5d|", getpid());
+               snprintf(buf, MAX_LEN, "S|%8d|", getpid());
                len += vsnprintf(buf + MAX_HEAD_LEN, POS_LABEL_ST, name, ap);
                va_end(ap);
 
@@ -249,7 +249,7 @@ void traceAsyncEnd(uint64_t tag, int32_t cookie, const char *name, ...)
 
                TTRACE_LOG("traceAsyncEnd:: write>> tag: %" PRIu64 " tag_bit: %" PRIu64, tag, *cur_enabled_tag);
                va_start(ap, name);
-               snprintf(buf, MAX_LEN, "F|%5d|", getpid());
+               snprintf(buf, MAX_LEN, "F|%8d|", getpid());
                len += vsnprintf(buf + MAX_HEAD_LEN, POS_LABEL_ST, name, ap);
                va_end(ap);
 
@@ -288,7 +288,7 @@ void traceMark(uint64_t tag, const char *name, ...)
 
                TTRACE_LOG("traceMark:: write >> tag: %" PRIu64 " tag_bit: %" PRIu64, tag, *cur_enabled_tag);
                va_start(ap, name);
-               snprintf(buf, MAX_LEN, "B|%5d|", getpid());
+               snprintf(buf, MAX_LEN, "B|%8d|", getpid());
                len += vsnprintf(buf + MAX_HEAD_LEN, POS_LABEL_ST, name, ap);
                va_end(ap);
 
@@ -330,7 +330,7 @@ void traceCounter(uint64_t tag, int32_t value, const char *name, ...)
 
                va_start(ap, name);
 
-               snprintf(buf, MAX_LEN, "C|%5d|", getpid());
+               snprintf(buf, MAX_LEN, "C|%8d|", getpid());
                len += vsnprintf(buf + MAX_HEAD_LEN, POS_LABEL_ST, name, ap);
                va_end(ap);