[PATCH 10/10] libtraceevent: Have print_field_raw() handle old data layout

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

 



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

Old kernels would produce dynamic strings with only a two byte offset. The
length of the array was determined by the string length. When parsing, if
the field is dynamic with a size of 2, then it is the old dynamic string
layout. Set the field to both a string and an array.

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
 src/event-parse.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/event-parse.c b/src/event-parse.c
index 40af92f4295f..9bd605d74b1f 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -1828,6 +1828,16 @@ static int event_read_fields(struct tep_event *event, struct tep_format_field **
 		field->size = strtoul(token, NULL, 0);
 		free_token(token);
 
+		/*
+		 * The old data format before dynamic arrays had dynamic
+		 * strings defined with just a 2 byte offset (the length
+		 * is defined by the strlen() of the string. To process them
+		 * correctly, check if the field is dynamic and has a size of
+		 * 2 bytes. All current dynamic events have a size of 4.
+		 */
+		if ((field->flags & TEP_FIELD_IS_DYNAMIC) && field->size == 2)
+			field->flags |= TEP_FIELD_IS_STRING | TEP_FIELD_IS_ARRAY;
+
 		if (read_expected(TEP_EVENT_OP, ";") < 0)
 			goto fail_expect;
 
-- 
2.33.0




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

  Powered by Linux