[PATCH] kernel-shark: Do not truncate multi-line events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---
 src/libkshark-tepdata.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libkshark-tepdata.c b/src/libkshark-tepdata.c
index 08aca0989a59..58be934f7d20 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;
-- 
2.35.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux