From: Sung-hun Kim Date: Tue, 28 Feb 2023 05:16:22 +0000 (+0900) Subject: Increase the buffer size of PID X-Git-Tag: accepted/tizen/unified/20230309.161422^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=11fecb0aa56e2d83d2cbd3646b0968cca398d71c;p=tools%2Fttrace.git Increase the buffer size of PID 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 --- diff --git a/src/ttrace.c b/src/ttrace.c index 426d272..f1585e2 100755 --- a/src/ttrace.c +++ b/src/ttrace.c @@ -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);