aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorLai Jiangshan <laijs@cn.fujitsu.com>2009-12-15 02:39:53 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-01-06 12:08:20 -0500
commit5a65e956220efc2421e21ee56d6153fd5c533a95 (patch)
tree66cb79949a14f79ec5ece050c12a8cc587a0b2e2 /kernel/trace
parentc7ef3a9004201bca90626db246a19dadd2c29c9b (diff)
tracing: Use defined fields and print_fmt to print formats
The calls ftrace_format_##call() and ftrace_define_fields_##call() are almost duplicate in functionality. With the addition of the print_fmt in previous patches, these two functions can be merged into one. The trace_define_field() defines the fields and links them into the struct ftrace_event_call. The previous patches introduced the print_fmt field and this can now be used with the trace_define_field() to create the event format file fields and print_fmt field. The struct ftrace_event_call->fields are used to print the fields The struct ftrace_event_call->print_fmt is used to print the "print fmt: XXXXXXXXXXX" line. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> LKML-Reference: <4B273D49.5000006@cn.fujitsu.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace_events.c65
1 files changed, 41 insertions, 24 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 189b09baf4f..250ec865d5f 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -528,33 +528,16 @@ extern char *__bad_type_size(void);
528 #type, "common_" #name, offsetof(typeof(field), name), \ 528 #type, "common_" #name, offsetof(typeof(field), name), \
529 sizeof(field.name), is_signed_type(type) 529 sizeof(field.name), is_signed_type(type)
530 530
531static int trace_write_header(struct trace_seq *s)
532{
533 struct trace_entry field;
534
535 /* struct trace_entry */
536 return trace_seq_printf(s,
537 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
538 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
539 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
540 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
541 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
542 "\n",
543 FIELD(unsigned short, type),
544 FIELD(unsigned char, flags),
545 FIELD(unsigned char, preempt_count),
546 FIELD(int, pid),
547 FIELD(int, lock_depth));
548}
549
550static ssize_t 531static ssize_t
551event_format_read(struct file *filp, char __user *ubuf, size_t cnt, 532event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
552 loff_t *ppos) 533 loff_t *ppos)
553{ 534{
554 struct ftrace_event_call *call = filp->private_data; 535 struct ftrace_event_call *call = filp->private_data;
536 struct ftrace_event_field *field;
555 struct trace_seq *s; 537 struct trace_seq *s;
538 int common_field_count = 5;
556 char *buf; 539 char *buf;
557 int r; 540 int r = 0;
558 541
559 if (*ppos) 542 if (*ppos)
560 return 0; 543 return 0;
@@ -565,14 +548,48 @@ event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
565 548
566 trace_seq_init(s); 549 trace_seq_init(s);
567 550
568 /* If any of the first writes fail, so will the show_format. */
569
570 trace_seq_printf(s, "name: %s\n", call->name); 551 trace_seq_printf(s, "name: %s\n", call->name);
571 trace_seq_printf(s, "ID: %d\n", call->id); 552 trace_seq_printf(s, "ID: %d\n", call->id);
572 trace_seq_printf(s, "format:\n"); 553 trace_seq_printf(s, "format:\n");
573 trace_write_header(s);
574 554
575 r = call->show_format(call, s); 555 list_for_each_entry_reverse(field, &call->fields, link) {
556 /*
557 * Smartly shows the array type(except dynamic array).
558 * Normal:
559 * field:TYPE VAR
560 * If TYPE := TYPE[LEN], it is shown:
561 * field:TYPE VAR[LEN]
562 */
563 const char *array_descriptor = strchr(field->type, '[');
564
565 if (!strncmp(field->type, "__data_loc", 10))
566 array_descriptor = NULL;
567
568 if (!array_descriptor) {
569 r = trace_seq_printf(s, "\tfield:%s %s;\toffset:%u;"
570 "\tsize:%u;\tsigned:%d;\n",
571 field->type, field->name, field->offset,
572 field->size, !!field->is_signed);
573 } else {
574 r = trace_seq_printf(s, "\tfield:%.*s %s%s;\toffset:%u;"
575 "\tsize:%u;\tsigned:%d;\n",
576 (int)(array_descriptor - field->type),
577 field->type, field->name,
578 array_descriptor, field->offset,
579 field->size, !!field->is_signed);
580 }
581
582 if (--common_field_count == 0)
583 r = trace_seq_printf(s, "\n");
584
585 if (!r)
586 break;
587 }
588
589 if (r)
590 r = trace_seq_printf(s, "\nprint fmt: %s\n",
591 call->print_fmt);
592
576 if (!r) { 593 if (!r) {
577 /* 594 /*
578 * ug! The format output is bigger than a PAGE!! 595 * ug! The format output is bigger than a PAGE!!