4 * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
8 #include <linux/module.h>
9 #include <linux/mutex.h>
10 #include <linux/ftrace.h>
12 #include "trace_output.h"
14 /* must be a power of 2 */
15 #define EVENT_HASHSIZE 128
17 DECLARE_RWSEM(trace_event_mutex
);
19 DEFINE_PER_CPU(struct trace_seq
, ftrace_event_seq
);
20 EXPORT_PER_CPU_SYMBOL(ftrace_event_seq
);
22 static struct hlist_head event_hash
[EVENT_HASHSIZE
] __read_mostly
;
24 static int next_event_type
= __TRACE_LAST_TYPE
+ 1;
26 void trace_print_seq(struct seq_file
*m
, struct trace_seq
*s
)
28 int len
= s
->len
>= PAGE_SIZE
? PAGE_SIZE
- 1 : s
->len
;
31 seq_puts(m
, s
->buffer
);
36 enum print_line_t
trace_print_bprintk_msg_only(struct trace_iterator
*iter
)
38 struct trace_seq
*s
= &iter
->seq
;
39 struct trace_entry
*entry
= iter
->ent
;
40 struct bprint_entry
*field
;
43 trace_assign_type(field
, entry
);
45 ret
= trace_seq_bprintf(s
, field
->fmt
, field
->buf
);
47 return TRACE_TYPE_PARTIAL_LINE
;
49 return TRACE_TYPE_HANDLED
;
52 enum print_line_t
trace_print_printk_msg_only(struct trace_iterator
*iter
)
54 struct trace_seq
*s
= &iter
->seq
;
55 struct trace_entry
*entry
= iter
->ent
;
56 struct print_entry
*field
;
59 trace_assign_type(field
, entry
);
61 ret
= trace_seq_printf(s
, "%s", field
->buf
);
63 return TRACE_TYPE_PARTIAL_LINE
;
65 return TRACE_TYPE_HANDLED
;
69 * trace_seq_printf - sequence printing of trace information
70 * @s: trace sequence descriptor
71 * @fmt: printf format string
73 * The tracer may use either sequence operations or its own
74 * copy to user routines. To simplify formating of a trace
75 * trace_seq_printf is used to store strings into a special
76 * buffer (@s). Then the output may be either used by
77 * the sequencer or pulled into another buffer.
80 trace_seq_printf(struct trace_seq
*s
, const char *fmt
, ...)
82 int len
= (PAGE_SIZE
- 1) - s
->len
;
90 ret
= vsnprintf(s
->buffer
+ s
->len
, len
, fmt
, ap
);
93 /* If we can't write it all, don't bother writing anything */
101 EXPORT_SYMBOL_GPL(trace_seq_printf
);
104 * trace_seq_vprintf - sequence printing of trace information
105 * @s: trace sequence descriptor
106 * @fmt: printf format string
108 * The tracer may use either sequence operations or its own
109 * copy to user routines. To simplify formating of a trace
110 * trace_seq_printf is used to store strings into a special
111 * buffer (@s). Then the output may be either used by
112 * the sequencer or pulled into another buffer.
115 trace_seq_vprintf(struct trace_seq
*s
, const char *fmt
, va_list args
)
117 int len
= (PAGE_SIZE
- 1) - s
->len
;
123 ret
= vsnprintf(s
->buffer
+ s
->len
, len
, fmt
, args
);
125 /* If we can't write it all, don't bother writing anything */
133 EXPORT_SYMBOL_GPL(trace_seq_vprintf
);
135 int trace_seq_bprintf(struct trace_seq
*s
, const char *fmt
, const u32
*binary
)
137 int len
= (PAGE_SIZE
- 1) - s
->len
;
143 ret
= bstr_printf(s
->buffer
+ s
->len
, len
, fmt
, binary
);
145 /* If we can't write it all, don't bother writing anything */
155 * trace_seq_puts - trace sequence printing of simple string
156 * @s: trace sequence descriptor
157 * @str: simple string to record
159 * The tracer may use either the sequence operations or its own
160 * copy to user routines. This function records a simple string
161 * into a special buffer (@s) for later retrieval by a sequencer
162 * or other mechanism.
164 int trace_seq_puts(struct trace_seq
*s
, const char *str
)
166 int len
= strlen(str
);
168 if (len
> ((PAGE_SIZE
- 1) - s
->len
))
171 memcpy(s
->buffer
+ s
->len
, str
, len
);
177 int trace_seq_putc(struct trace_seq
*s
, unsigned char c
)
179 if (s
->len
>= (PAGE_SIZE
- 1))
182 s
->buffer
[s
->len
++] = c
;
187 int trace_seq_putmem(struct trace_seq
*s
, const void *mem
, size_t len
)
189 if (len
> ((PAGE_SIZE
- 1) - s
->len
))
192 memcpy(s
->buffer
+ s
->len
, mem
, len
);
198 int trace_seq_putmem_hex(struct trace_seq
*s
, const void *mem
, size_t len
)
200 unsigned char hex
[HEX_CHARS
];
201 const unsigned char *data
= mem
;
205 for (i
= 0, j
= 0; i
< len
; i
++) {
207 for (i
= len
-1, j
= 0; i
>= 0; i
--) {
209 hex
[j
++] = hex_asc_hi(data
[i
]);
210 hex
[j
++] = hex_asc_lo(data
[i
]);
214 return trace_seq_putmem(s
, hex
, j
);
217 void *trace_seq_reserve(struct trace_seq
*s
, size_t len
)
221 if (len
> ((PAGE_SIZE
- 1) - s
->len
))
224 ret
= s
->buffer
+ s
->len
;
230 int trace_seq_path(struct trace_seq
*s
, struct path
*path
)
234 if (s
->len
>= (PAGE_SIZE
- 1))
236 p
= d_path(path
, s
->buffer
+ s
->len
, PAGE_SIZE
- s
->len
);
238 p
= mangle_path(s
->buffer
+ s
->len
, p
, "\n");
240 s
->len
= p
- s
->buffer
;
244 s
->buffer
[s
->len
++] = '?';
252 ftrace_print_flags_seq(struct trace_seq
*p
, const char *delim
,
254 const struct trace_print_flags
*flag_array
)
258 const char *ret
= p
->buffer
+ p
->len
;
261 for (i
= 0; flag_array
[i
].name
&& flags
; i
++) {
263 mask
= flag_array
[i
].mask
;
264 if ((flags
& mask
) != mask
)
267 str
= flag_array
[i
].name
;
270 trace_seq_puts(p
, delim
);
271 trace_seq_puts(p
, str
);
274 /* check for left over flags */
277 trace_seq_puts(p
, delim
);
278 trace_seq_printf(p
, "0x%lx", flags
);
281 trace_seq_putc(p
, 0);
285 EXPORT_SYMBOL(ftrace_print_flags_seq
);
288 ftrace_print_symbols_seq(struct trace_seq
*p
, unsigned long val
,
289 const struct trace_print_flags
*symbol_array
)
292 const char *ret
= p
->buffer
+ p
->len
;
294 for (i
= 0; symbol_array
[i
].name
; i
++) {
296 if (val
!= symbol_array
[i
].mask
)
299 trace_seq_puts(p
, symbol_array
[i
].name
);
304 trace_seq_printf(p
, "0x%lx", val
);
306 trace_seq_putc(p
, 0);
310 EXPORT_SYMBOL(ftrace_print_symbols_seq
);
312 #ifdef CONFIG_KRETPROBES
313 static inline const char *kretprobed(const char *name
)
315 static const char tramp_name
[] = "kretprobe_trampoline";
316 int size
= sizeof(tramp_name
);
318 if (strncmp(tramp_name
, name
, size
) == 0)
319 return "[unknown/kretprobe'd]";
323 static inline const char *kretprobed(const char *name
)
327 #endif /* CONFIG_KRETPROBES */
330 seq_print_sym_short(struct trace_seq
*s
, const char *fmt
, unsigned long address
)
332 #ifdef CONFIG_KALLSYMS
333 char str
[KSYM_SYMBOL_LEN
];
336 kallsyms_lookup(address
, NULL
, NULL
, NULL
, str
);
338 name
= kretprobed(str
);
340 return trace_seq_printf(s
, fmt
, name
);
346 seq_print_sym_offset(struct trace_seq
*s
, const char *fmt
,
347 unsigned long address
)
349 #ifdef CONFIG_KALLSYMS
350 char str
[KSYM_SYMBOL_LEN
];
353 sprint_symbol(str
, address
);
354 name
= kretprobed(str
);
356 return trace_seq_printf(s
, fmt
, name
);
362 # define IP_FMT "%08lx"
364 # define IP_FMT "%016lx"
367 int seq_print_user_ip(struct trace_seq
*s
, struct mm_struct
*mm
,
368 unsigned long ip
, unsigned long sym_flags
)
370 struct file
*file
= NULL
;
371 unsigned long vmstart
= 0;
375 const struct vm_area_struct
*vma
;
377 down_read(&mm
->mmap_sem
);
378 vma
= find_vma(mm
, ip
);
381 vmstart
= vma
->vm_start
;
384 ret
= trace_seq_path(s
, &file
->f_path
);
386 ret
= trace_seq_printf(s
, "[+0x%lx]",
389 up_read(&mm
->mmap_sem
);
391 if (ret
&& ((sym_flags
& TRACE_ITER_SYM_ADDR
) || !file
))
392 ret
= trace_seq_printf(s
, " <" IP_FMT
">", ip
);
397 seq_print_userip_objs(const struct userstack_entry
*entry
, struct trace_seq
*s
,
398 unsigned long sym_flags
)
400 struct mm_struct
*mm
= NULL
;
404 if (trace_flags
& TRACE_ITER_SYM_USEROBJ
) {
405 struct task_struct
*task
;
407 * we do the lookup on the thread group leader,
408 * since individual threads might have already quit!
411 task
= find_task_by_vpid(entry
->ent
.tgid
);
413 mm
= get_task_mm(task
);
417 for (i
= 0; i
< FTRACE_STACK_ENTRIES
; i
++) {
418 unsigned long ip
= entry
->caller
[i
];
420 if (ip
== ULONG_MAX
|| !ret
)
423 ret
= trace_seq_puts(s
, " => ");
426 ret
= trace_seq_puts(s
, "??");
428 ret
= trace_seq_puts(s
, "\n");
434 ret
= seq_print_user_ip(s
, mm
, ip
, sym_flags
);
435 ret
= trace_seq_puts(s
, "\n");
444 seq_print_ip_sym(struct trace_seq
*s
, unsigned long ip
, unsigned long sym_flags
)
449 return trace_seq_printf(s
, "0");
451 if (sym_flags
& TRACE_ITER_SYM_OFFSET
)
452 ret
= seq_print_sym_offset(s
, "%s", ip
);
454 ret
= seq_print_sym_short(s
, "%s", ip
);
459 if (sym_flags
& TRACE_ITER_SYM_ADDR
)
460 ret
= trace_seq_printf(s
, " <" IP_FMT
">", ip
);
465 lat_print_generic(struct trace_seq
*s
, struct trace_entry
*entry
, int cpu
)
467 int hardirq
, softirq
;
468 char comm
[TASK_COMM_LEN
];
470 trace_find_cmdline(entry
->pid
, comm
);
471 hardirq
= entry
->flags
& TRACE_FLAG_HARDIRQ
;
472 softirq
= entry
->flags
& TRACE_FLAG_SOFTIRQ
;
474 if (!trace_seq_printf(s
, "%8.8s-%-5d %3d%c%c%c",
475 comm
, entry
->pid
, cpu
,
476 (entry
->flags
& TRACE_FLAG_IRQS_OFF
) ? 'd' :
477 (entry
->flags
& TRACE_FLAG_IRQS_NOSUPPORT
) ?
479 (entry
->flags
& TRACE_FLAG_NEED_RESCHED
) ?
481 (hardirq
&& softirq
) ? 'H' :
482 hardirq
? 'h' : softirq
? 's' : '.'))
485 if (entry
->preempt_count
)
486 return trace_seq_printf(s
, "%x", entry
->preempt_count
);
487 return trace_seq_puts(s
, ".");
490 static unsigned long preempt_mark_thresh
= 100;
493 lat_print_timestamp(struct trace_seq
*s
, u64 abs_usecs
,
494 unsigned long rel_usecs
)
496 return trace_seq_printf(s
, " %4lldus%c: ", abs_usecs
,
497 rel_usecs
> preempt_mark_thresh
? '!' :
498 rel_usecs
> 1 ? '+' : ' ');
501 int trace_print_context(struct trace_iterator
*iter
)
503 struct trace_seq
*s
= &iter
->seq
;
504 struct trace_entry
*entry
= iter
->ent
;
505 unsigned long long t
= ns2usecs(iter
->ts
);
506 unsigned long usec_rem
= do_div(t
, USEC_PER_SEC
);
507 unsigned long secs
= (unsigned long)t
;
508 char comm
[TASK_COMM_LEN
];
510 trace_find_cmdline(entry
->pid
, comm
);
512 return trace_seq_printf(s
, "%16s-%-5d [%03d] %5lu.%06lu: ",
513 comm
, entry
->pid
, iter
->cpu
, secs
, usec_rem
);
516 int trace_print_lat_context(struct trace_iterator
*iter
)
520 struct trace_seq
*s
= &iter
->seq
;
521 struct trace_entry
*entry
= iter
->ent
,
522 *next_entry
= trace_find_next_entry(iter
, NULL
,
524 unsigned long verbose
= (trace_flags
& TRACE_ITER_VERBOSE
);
525 unsigned long abs_usecs
= ns2usecs(iter
->ts
- iter
->tr
->time_start
);
526 unsigned long rel_usecs
;
530 rel_usecs
= ns2usecs(next_ts
- iter
->ts
);
533 char comm
[TASK_COMM_LEN
];
535 trace_find_cmdline(entry
->pid
, comm
);
537 ret
= trace_seq_printf(s
, "%16s %5d %3d %d %08x %08lx [%08llx]"
538 " %ld.%03ldms (+%ld.%03ldms): ", comm
,
539 entry
->pid
, iter
->cpu
, entry
->flags
,
540 entry
->preempt_count
, iter
->idx
,
542 abs_usecs
/ USEC_PER_MSEC
,
543 abs_usecs
% USEC_PER_MSEC
,
544 rel_usecs
/ USEC_PER_MSEC
,
545 rel_usecs
% USEC_PER_MSEC
);
547 ret
= lat_print_generic(s
, entry
, iter
->cpu
);
549 ret
= lat_print_timestamp(s
, abs_usecs
, rel_usecs
);
555 static const char state_to_char
[] = TASK_STATE_TO_CHAR_STR
;
557 static int task_state_char(unsigned long state
)
559 int bit
= state
? __ffs(state
) + 1 : 0;
561 return bit
< sizeof(state_to_char
) - 1 ? state_to_char
[bit
] : '?';
565 * ftrace_find_event - find a registered event
566 * @type: the type of event to look for
568 * Returns an event of type @type otherwise NULL
569 * Called with trace_event_read_lock() held.
571 struct trace_event
*ftrace_find_event(int type
)
573 struct trace_event
*event
;
574 struct hlist_node
*n
;
577 key
= type
& (EVENT_HASHSIZE
- 1);
579 hlist_for_each_entry(event
, n
, &event_hash
[key
], node
) {
580 if (event
->type
== type
)
587 static LIST_HEAD(ftrace_event_list
);
589 static int trace_search_list(struct list_head
**list
)
591 struct trace_event
*e
;
592 int last
= __TRACE_LAST_TYPE
;
594 if (list_empty(&ftrace_event_list
)) {
595 *list
= &ftrace_event_list
;
600 * We used up all possible max events,
601 * lets see if somebody freed one.
603 list_for_each_entry(e
, &ftrace_event_list
, list
) {
604 if (e
->type
!= last
+ 1)
609 /* Did we used up all 65 thousand events??? */
610 if ((last
+ 1) > FTRACE_MAX_EVENT
)
617 void trace_event_read_lock(void)
619 down_read(&trace_event_mutex
);
622 void trace_event_read_unlock(void)
624 up_read(&trace_event_mutex
);
628 * register_ftrace_event - register output for an event type
629 * @event: the event type to register
631 * Event types are stored in a hash and this hash is used to
632 * find a way to print an event. If the @event->type is set
633 * then it will use that type, otherwise it will assign a
636 * If you assign your own type, please make sure it is added
637 * to the trace_type enum in trace.h, to avoid collisions
638 * with the dynamic types.
640 * Returns the event type number or zero on error.
642 int register_ftrace_event(struct trace_event
*event
)
647 down_write(&trace_event_mutex
);
652 INIT_LIST_HEAD(&event
->list
);
655 struct list_head
*list
= NULL
;
657 if (next_event_type
> FTRACE_MAX_EVENT
) {
659 event
->type
= trace_search_list(&list
);
665 event
->type
= next_event_type
++;
666 list
= &ftrace_event_list
;
669 if (WARN_ON(ftrace_find_event(event
->type
)))
672 list_add_tail(&event
->list
, list
);
674 } else if (event
->type
> __TRACE_LAST_TYPE
) {
675 printk(KERN_WARNING
"Need to add type to trace.h\n");
679 /* Is this event already used */
680 if (ftrace_find_event(event
->type
))
684 if (event
->trace
== NULL
)
685 event
->trace
= trace_nop_print
;
686 if (event
->raw
== NULL
)
687 event
->raw
= trace_nop_print
;
688 if (event
->hex
== NULL
)
689 event
->hex
= trace_nop_print
;
690 if (event
->binary
== NULL
)
691 event
->binary
= trace_nop_print
;
693 key
= event
->type
& (EVENT_HASHSIZE
- 1);
695 hlist_add_head(&event
->node
, &event_hash
[key
]);
699 up_write(&trace_event_mutex
);
703 EXPORT_SYMBOL_GPL(register_ftrace_event
);
706 * Used by module code with the trace_event_mutex held for write.
708 int __unregister_ftrace_event(struct trace_event
*event
)
710 hlist_del(&event
->node
);
711 list_del(&event
->list
);
716 * unregister_ftrace_event - remove a no longer used event
717 * @event: the event to remove
719 int unregister_ftrace_event(struct trace_event
*event
)
721 down_write(&trace_event_mutex
);
722 __unregister_ftrace_event(event
);
723 up_write(&trace_event_mutex
);
727 EXPORT_SYMBOL_GPL(unregister_ftrace_event
);
733 enum print_line_t
trace_nop_print(struct trace_iterator
*iter
, int flags
)
735 return TRACE_TYPE_HANDLED
;
739 static enum print_line_t
trace_fn_trace(struct trace_iterator
*iter
, int flags
)
741 struct ftrace_entry
*field
;
742 struct trace_seq
*s
= &iter
->seq
;
744 trace_assign_type(field
, iter
->ent
);
746 if (!seq_print_ip_sym(s
, field
->ip
, flags
))
749 if ((flags
& TRACE_ITER_PRINT_PARENT
) && field
->parent_ip
) {
750 if (!trace_seq_printf(s
, " <-"))
752 if (!seq_print_ip_sym(s
,
757 if (!trace_seq_printf(s
, "\n"))
760 return TRACE_TYPE_HANDLED
;
763 return TRACE_TYPE_PARTIAL_LINE
;
766 static enum print_line_t
trace_fn_raw(struct trace_iterator
*iter
, int flags
)
768 struct ftrace_entry
*field
;
770 trace_assign_type(field
, iter
->ent
);
772 if (!trace_seq_printf(&iter
->seq
, "%lx %lx\n",
775 return TRACE_TYPE_PARTIAL_LINE
;
777 return TRACE_TYPE_HANDLED
;
780 static enum print_line_t
trace_fn_hex(struct trace_iterator
*iter
, int flags
)
782 struct ftrace_entry
*field
;
783 struct trace_seq
*s
= &iter
->seq
;
785 trace_assign_type(field
, iter
->ent
);
787 SEQ_PUT_HEX_FIELD_RET(s
, field
->ip
);
788 SEQ_PUT_HEX_FIELD_RET(s
, field
->parent_ip
);
790 return TRACE_TYPE_HANDLED
;
793 static enum print_line_t
trace_fn_bin(struct trace_iterator
*iter
, int flags
)
795 struct ftrace_entry
*field
;
796 struct trace_seq
*s
= &iter
->seq
;
798 trace_assign_type(field
, iter
->ent
);
800 SEQ_PUT_FIELD_RET(s
, field
->ip
);
801 SEQ_PUT_FIELD_RET(s
, field
->parent_ip
);
803 return TRACE_TYPE_HANDLED
;
806 static struct trace_event trace_fn_event
= {
808 .trace
= trace_fn_trace
,
811 .binary
= trace_fn_bin
,
814 /* TRACE_CTX an TRACE_WAKE */
815 static enum print_line_t
trace_ctxwake_print(struct trace_iterator
*iter
,
818 struct ctx_switch_entry
*field
;
819 char comm
[TASK_COMM_LEN
];
823 trace_assign_type(field
, iter
->ent
);
825 T
= task_state_char(field
->next_state
);
826 S
= task_state_char(field
->prev_state
);
827 trace_find_cmdline(field
->next_pid
, comm
);
828 if (!trace_seq_printf(&iter
->seq
,
829 " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n",
837 return TRACE_TYPE_PARTIAL_LINE
;
839 return TRACE_TYPE_HANDLED
;
842 static enum print_line_t
trace_ctx_print(struct trace_iterator
*iter
, int flags
)
844 return trace_ctxwake_print(iter
, "==>");
847 static enum print_line_t
trace_wake_print(struct trace_iterator
*iter
,
850 return trace_ctxwake_print(iter
, " +");
853 static int trace_ctxwake_raw(struct trace_iterator
*iter
, char S
)
855 struct ctx_switch_entry
*field
;
858 trace_assign_type(field
, iter
->ent
);
861 task_state_char(field
->prev_state
);
862 T
= task_state_char(field
->next_state
);
863 if (!trace_seq_printf(&iter
->seq
, "%d %d %c %d %d %d %c\n",
871 return TRACE_TYPE_PARTIAL_LINE
;
873 return TRACE_TYPE_HANDLED
;
876 static enum print_line_t
trace_ctx_raw(struct trace_iterator
*iter
, int flags
)
878 return trace_ctxwake_raw(iter
, 0);
881 static enum print_line_t
trace_wake_raw(struct trace_iterator
*iter
, int flags
)
883 return trace_ctxwake_raw(iter
, '+');
887 static int trace_ctxwake_hex(struct trace_iterator
*iter
, char S
)
889 struct ctx_switch_entry
*field
;
890 struct trace_seq
*s
= &iter
->seq
;
893 trace_assign_type(field
, iter
->ent
);
896 task_state_char(field
->prev_state
);
897 T
= task_state_char(field
->next_state
);
899 SEQ_PUT_HEX_FIELD_RET(s
, field
->prev_pid
);
900 SEQ_PUT_HEX_FIELD_RET(s
, field
->prev_prio
);
901 SEQ_PUT_HEX_FIELD_RET(s
, S
);
902 SEQ_PUT_HEX_FIELD_RET(s
, field
->next_cpu
);
903 SEQ_PUT_HEX_FIELD_RET(s
, field
->next_pid
);
904 SEQ_PUT_HEX_FIELD_RET(s
, field
->next_prio
);
905 SEQ_PUT_HEX_FIELD_RET(s
, T
);
907 return TRACE_TYPE_HANDLED
;
910 static enum print_line_t
trace_ctx_hex(struct trace_iterator
*iter
, int flags
)
912 return trace_ctxwake_hex(iter
, 0);
915 static enum print_line_t
trace_wake_hex(struct trace_iterator
*iter
, int flags
)
917 return trace_ctxwake_hex(iter
, '+');
920 static enum print_line_t
trace_ctxwake_bin(struct trace_iterator
*iter
,
923 struct ctx_switch_entry
*field
;
924 struct trace_seq
*s
= &iter
->seq
;
926 trace_assign_type(field
, iter
->ent
);
928 SEQ_PUT_FIELD_RET(s
, field
->prev_pid
);
929 SEQ_PUT_FIELD_RET(s
, field
->prev_prio
);
930 SEQ_PUT_FIELD_RET(s
, field
->prev_state
);
931 SEQ_PUT_FIELD_RET(s
, field
->next_pid
);
932 SEQ_PUT_FIELD_RET(s
, field
->next_prio
);
933 SEQ_PUT_FIELD_RET(s
, field
->next_state
);
935 return TRACE_TYPE_HANDLED
;
938 static struct trace_event trace_ctx_event
= {
940 .trace
= trace_ctx_print
,
941 .raw
= trace_ctx_raw
,
942 .hex
= trace_ctx_hex
,
943 .binary
= trace_ctxwake_bin
,
946 static struct trace_event trace_wake_event
= {
948 .trace
= trace_wake_print
,
949 .raw
= trace_wake_raw
,
950 .hex
= trace_wake_hex
,
951 .binary
= trace_ctxwake_bin
,
955 static enum print_line_t
trace_special_print(struct trace_iterator
*iter
,
958 struct special_entry
*field
;
960 trace_assign_type(field
, iter
->ent
);
962 if (!trace_seq_printf(&iter
->seq
, "# %ld %ld %ld\n",
966 return TRACE_TYPE_PARTIAL_LINE
;
968 return TRACE_TYPE_HANDLED
;
971 static enum print_line_t
trace_special_hex(struct trace_iterator
*iter
,
974 struct special_entry
*field
;
975 struct trace_seq
*s
= &iter
->seq
;
977 trace_assign_type(field
, iter
->ent
);
979 SEQ_PUT_HEX_FIELD_RET(s
, field
->arg1
);
980 SEQ_PUT_HEX_FIELD_RET(s
, field
->arg2
);
981 SEQ_PUT_HEX_FIELD_RET(s
, field
->arg3
);
983 return TRACE_TYPE_HANDLED
;
986 static enum print_line_t
trace_special_bin(struct trace_iterator
*iter
,
989 struct special_entry
*field
;
990 struct trace_seq
*s
= &iter
->seq
;
992 trace_assign_type(field
, iter
->ent
);
994 SEQ_PUT_FIELD_RET(s
, field
->arg1
);
995 SEQ_PUT_FIELD_RET(s
, field
->arg2
);
996 SEQ_PUT_FIELD_RET(s
, field
->arg3
);
998 return TRACE_TYPE_HANDLED
;
1001 static struct trace_event trace_special_event
= {
1002 .type
= TRACE_SPECIAL
,
1003 .trace
= trace_special_print
,
1004 .raw
= trace_special_print
,
1005 .hex
= trace_special_hex
,
1006 .binary
= trace_special_bin
,
1011 static enum print_line_t
trace_stack_print(struct trace_iterator
*iter
,
1014 struct stack_entry
*field
;
1015 struct trace_seq
*s
= &iter
->seq
;
1018 trace_assign_type(field
, iter
->ent
);
1020 if (!trace_seq_puts(s
, "<stack trace>\n"))
1022 for (i
= 0; i
< FTRACE_STACK_ENTRIES
; i
++) {
1023 if (!field
->caller
[i
] || (field
->caller
[i
] == ULONG_MAX
))
1025 if (!trace_seq_puts(s
, " => "))
1028 if (!seq_print_ip_sym(s
, field
->caller
[i
], flags
))
1030 if (!trace_seq_puts(s
, "\n"))
1034 return TRACE_TYPE_HANDLED
;
1037 return TRACE_TYPE_PARTIAL_LINE
;
1040 static struct trace_event trace_stack_event
= {
1041 .type
= TRACE_STACK
,
1042 .trace
= trace_stack_print
,
1043 .raw
= trace_special_print
,
1044 .hex
= trace_special_hex
,
1045 .binary
= trace_special_bin
,
1048 /* TRACE_USER_STACK */
1049 static enum print_line_t
trace_user_stack_print(struct trace_iterator
*iter
,
1052 struct userstack_entry
*field
;
1053 struct trace_seq
*s
= &iter
->seq
;
1055 trace_assign_type(field
, iter
->ent
);
1057 if (!trace_seq_puts(s
, "<user stack trace>\n"))
1060 if (!seq_print_userip_objs(field
, s
, flags
))
1063 return TRACE_TYPE_HANDLED
;
1066 return TRACE_TYPE_PARTIAL_LINE
;
1069 static struct trace_event trace_user_stack_event
= {
1070 .type
= TRACE_USER_STACK
,
1071 .trace
= trace_user_stack_print
,
1072 .raw
= trace_special_print
,
1073 .hex
= trace_special_hex
,
1074 .binary
= trace_special_bin
,
1078 static enum print_line_t
1079 trace_bprint_print(struct trace_iterator
*iter
, int flags
)
1081 struct trace_entry
*entry
= iter
->ent
;
1082 struct trace_seq
*s
= &iter
->seq
;
1083 struct bprint_entry
*field
;
1085 trace_assign_type(field
, entry
);
1087 if (!seq_print_ip_sym(s
, field
->ip
, flags
))
1090 if (!trace_seq_puts(s
, ": "))
1093 if (!trace_seq_bprintf(s
, field
->fmt
, field
->buf
))
1096 return TRACE_TYPE_HANDLED
;
1099 return TRACE_TYPE_PARTIAL_LINE
;
1103 static enum print_line_t
1104 trace_bprint_raw(struct trace_iterator
*iter
, int flags
)
1106 struct bprint_entry
*field
;
1107 struct trace_seq
*s
= &iter
->seq
;
1109 trace_assign_type(field
, iter
->ent
);
1111 if (!trace_seq_printf(s
, ": %lx : ", field
->ip
))
1114 if (!trace_seq_bprintf(s
, field
->fmt
, field
->buf
))
1117 return TRACE_TYPE_HANDLED
;
1120 return TRACE_TYPE_PARTIAL_LINE
;
1124 static struct trace_event trace_bprint_event
= {
1125 .type
= TRACE_BPRINT
,
1126 .trace
= trace_bprint_print
,
1127 .raw
= trace_bprint_raw
,
1131 static enum print_line_t
trace_print_print(struct trace_iterator
*iter
,
1134 struct print_entry
*field
;
1135 struct trace_seq
*s
= &iter
->seq
;
1137 trace_assign_type(field
, iter
->ent
);
1139 if (!seq_print_ip_sym(s
, field
->ip
, flags
))
1142 if (!trace_seq_printf(s
, ": %s", field
->buf
))
1145 return TRACE_TYPE_HANDLED
;
1148 return TRACE_TYPE_PARTIAL_LINE
;
1151 static enum print_line_t
trace_print_raw(struct trace_iterator
*iter
, int flags
)
1153 struct print_entry
*field
;
1155 trace_assign_type(field
, iter
->ent
);
1157 if (!trace_seq_printf(&iter
->seq
, "# %lx %s", field
->ip
, field
->buf
))
1160 return TRACE_TYPE_HANDLED
;
1163 return TRACE_TYPE_PARTIAL_LINE
;
1166 static struct trace_event trace_print_event
= {
1167 .type
= TRACE_PRINT
,
1168 .trace
= trace_print_print
,
1169 .raw
= trace_print_raw
,
1173 static struct trace_event
*events
[] __initdata
= {
1177 &trace_special_event
,
1179 &trace_user_stack_event
,
1180 &trace_bprint_event
,
1185 __init
static int init_events(void)
1187 struct trace_event
*event
;
1190 for (i
= 0; events
[i
]; i
++) {
1193 ret
= register_ftrace_event(event
);
1195 printk(KERN_WARNING
"event %d failed to register\n",
1203 device_initcall(init_events
);