public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: Handle __print_hex(__get_dynamic_array(fieldname), len)
@ 2013-10-11 14:55 Howard Cochran
  2013-10-14  1:22 ` Namhyung Kim
  2013-11-04 20:22 ` [tip:perf/core] tools lib traceevent: Handle __print_hex( __get_dynamic_array(fieldname), len) tip-bot for Howard Cochran
  0 siblings, 2 replies; 4+ messages in thread
From: Howard Cochran @ 2013-10-11 14:55 UTC (permalink / raw)
  To: rostedt; +Cc: linux-kernel, Howard Cochran

The kernel has a few events with a format similar to this excerpt:
        field:unsigned int len;     offset:12;      size:4; signed:0;
        field:__data_loc unsigned char[] data_array;  offset:16;      size:4; signed:0;
print fmt: "%s", __print_hex(__get_dynamic_array(data_array), REC->len)

trace-cmd could already parse that arg correctly, but print_str_arg()
was unable to handle the first parameter being a dynamic array. (It
just printed a "field not found" warning).

Teach print_str_arg's PRINT_HEX case to handle the nested
PRINT_DYNAMIC_ARRAY correctly. The output now matches the kernel's own
formatting for this case.

Signed-off-by: Howard Cochran <hcochran@lexmark.com>
---
 event-parse.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/event-parse.c b/event-parse.c
index e961553..fdb176e 100644
--- a/event-parse.c
+++ b/event-parse.c
@@ -3550,15 +3550,23 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
 		}
 		break;
 	case PRINT_HEX:
-		field = arg->hex.field->field.field;
-		if (!field) {
-			str = arg->hex.field->field.name;
-			field = pevent_find_any_field(event, str);
-			if (!field)
-				goto out_warning_field;
-			arg->hex.field->field.field = field;
+		if (PRINT_DYNAMIC_ARRAY == arg->hex.field->type) {
+			unsigned long offset;
+			offset = pevent_read_number(pevent,
+				data + arg->hex.field->dynarray.field->offset,
+				arg->hex.field->dynarray.field->size);
+			hex = data + (offset & 0xffff);
+		} else {
+			field = arg->hex.field->field.field;
+			if (!field) {
+				str = arg->hex.field->field.name;
+				field = pevent_find_any_field(event, str);
+				if (!field)
+					goto out_warning_field;
+				arg->hex.field->field.field = field;
+			}
+			hex = data + field->offset;
 		}
-		hex = data + field->offset;
 		len = eval_num_arg(data, size, event, arg->hex.size);
 		for (i = 0; i < len; i++) {
 			if (i)
-- 
1.7.10.2.4.g36f8dc1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-04 20:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-11 14:55 [PATCH] trace-cmd: Handle __print_hex(__get_dynamic_array(fieldname), len) Howard Cochran
2013-10-14  1:22 ` Namhyung Kim
2013-10-14 18:45   ` [PATCH] tools lib traceevent: Handle __print_hex(__get_dynamic_array(fld), len) Howard Cochran
2013-11-04 20:22 ` [tip:perf/core] tools lib traceevent: Handle __print_hex( __get_dynamic_array(fieldname), len) tip-bot for Howard Cochran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox