aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2022-12-14 15:44:04 -0500
committerYordan Karadzhov <y.karadz@gmail.com>2022-12-17 12:49:41 +0200
commit3146d0b3d873546461163df2701ee1068e27ee04 (patch)
tree3e2e8efcb7975649eb6f4491732a667252309f10
parent843903f5cd12990c5786ae6c9bbc6422f8746bb4 (diff)
downloadkernel-shark-3146d0b3d873546461163df2701ee1068e27ee04.tar.gz
kernel-shark: Do not truncate multi-line events
Some events have more than one line. The libkshark-tepdata.c get_info function did a string search for the first occurrence of '\n' and set it to '\0', with the comment of removing trailing newlines. Unfortunately, it removed more than the trailing newline and removed most of the event. This is particularly true with stack traces. Instead, use the trace_seq.len to check the last written character, and if that is a newline, remove it. Fixes: 836ce858246b7 ("kernel-shark: Add stream interface for trace-cmd data") Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Yordan Karadzhov <y.karadz@gmail.com>
-rw-r--r--src/libkshark-tepdata.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libkshark-tepdata.c b/src/libkshark-tepdata.c
index b435a297..2009ca6a 100644
--- a/src/libkshark-tepdata.c
+++ b/src/libkshark-tepdata.c
@@ -816,7 +816,7 @@ static char *get_info_str(struct kshark_data_stream *stream,
struct tep_record *record,
struct tep_event *event)
{
- char *pos, *buffer;
+ char *buffer;
if (!init_thread_seq() || !record || !event)
return NULL;
@@ -829,8 +829,8 @@ static char *get_info_str(struct kshark_data_stream *stream,
* The event info string contains a trailing newline.
* Remove this newline.
*/
- if ((pos = strchr(seq.buffer, '\n')) != NULL)
- *pos = '\0';
+ if (seq.buffer[seq.len - 1] == '\n')
+ seq.buffer[seq.len - 1] = '\0';
if (asprintf(&buffer, "%s", seq.buffer) <= 0)
return NULL;