Skip to content

Commit 9b8179b

Browse files
rostedtacmel
authored andcommitted
tools lib traceevent: Add builtin handler for trace_marker_raw
When something is written into trace_marker_raw, it goes in as a binary. But the printk_fmt() of the event that is created (raw_data)'s format file only prints the first byte of data: print fmt: "id:%04x %08x", REC->id, (int)REC->buf[0] This is not very useful if we want to see the full data output. Implement the processing of the raw_data event like it is in the kernel. Link: http://lore.kernel.org/linux-trace-devel/20200702174950.123454-5-tz.stoyanov@gmail.com Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> [ Ported from trace-cmd.git ] Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: linux-trace-devel@vger.kernel.org Link: http://lore.kernel.org/lkml/20200702185705.445969275@goodmis.org Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 0dfceef commit 9b8179b

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

‎tools/lib/traceevent/plugins/plugin_function.c‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,44 @@ trace_stack_handler(struct trace_seq *s, struct tep_record *record,
222222
return 0;
223223
}
224224

225+
static int
226+
trace_raw_data_handler(struct trace_seq *s, struct tep_record *record,
227+
struct tep_event *event, void *context)
228+
{
229+
struct tep_format_field *field;
230+
unsigned long long id;
231+
int long_size;
232+
void *data = record->data;
233+
234+
if (tep_get_field_val(s, event, "id", record, &id, 1))
235+
return trace_seq_putc(s, '!');
236+
237+
trace_seq_printf(s, "# %llx", id);
238+
239+
field = tep_find_any_field(event, "buf");
240+
if (!field) {
241+
trace_seq_printf(s, "<CANT FIND FIELD %s>", "buf");
242+
return 0;
243+
}
244+
245+
long_size = tep_get_long_size(event->tep);
246+
247+
for (data += field->offset; data < record->data + record->size;
248+
data += long_size) {
249+
int size = sizeof(long);
250+
int left = (record->data + record->size) - data;
251+
int i;
252+
253+
if (size > left)
254+
size = left;
255+
256+
for (i = 0; i < size; i++)
257+
trace_seq_printf(s, " %02x", *(unsigned char *)(data + i));
258+
}
259+
260+
return 0;
261+
}
262+
225263
int TEP_PLUGIN_LOADER(struct tep_handle *tep)
226264
{
227265
tep_register_event_handler(tep, -1, "ftrace", "function",
@@ -230,6 +268,9 @@ int TEP_PLUGIN_LOADER(struct tep_handle *tep)
230268
tep_register_event_handler(tep, -1, "ftrace", "kernel_stack",
231269
trace_stack_handler, NULL);
232270

271+
tep_register_event_handler(tep, -1, "ftrace", "raw_data",
272+
trace_raw_data_handler, NULL);
273+
233274
tep_plugin_add_options("ftrace", plugin_options);
234275

235276
return 0;

0 commit comments

Comments
 (0)