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 static 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);
103 int trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
105 int len = (PAGE_SIZE - 1) - s->len;
111 ret = bstr_printf(s->buffer + s->len, len, fmt, binary);
113 /* If we can't write it all, don't bother writing anything */
123 * trace_seq_puts - trace sequence printing of simple string
124 * @s: trace sequence descriptor
125 * @str: simple string to record
127 * The tracer may use either the sequence operations or its own
128 * copy to user routines. This function records a simple string
129 * into a special buffer (@s) for later retrieval by a sequencer
130 * or other mechanism.
132 int trace_seq_puts(struct trace_seq *s, const char *str)
134 int len = strlen(str);
136 if (len > ((PAGE_SIZE - 1) - s->len))
139 memcpy(s->buffer + s->len, str, len);
145 int trace_seq_putc(struct trace_seq *s, unsigned char c)
147 if (s->len >= (PAGE_SIZE - 1))
150 s->buffer[s->len++] = c;
155 int trace_seq_putmem(struct trace_seq *s, const void *mem, size_t len)
157 if (len > ((PAGE_SIZE - 1) - s->len))
160 memcpy(s->buffer + s->len, mem, len);
166 int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, size_t len)
168 unsigned char hex[HEX_CHARS];
169 const unsigned char *data = mem;
173 for (i = 0, j = 0; i < len; i++) {
175 for (i = len-1, j = 0; i >= 0; i--) {
177 hex[j++] = hex_asc_hi(data[i]);
178 hex[j++] = hex_asc_lo(data[i]);
182 return trace_seq_putmem(s, hex, j);
185 void *trace_seq_reserve(struct trace_seq *s, size_t len)
189 if (len > ((PAGE_SIZE - 1) - s->len))
192 ret = s->buffer + s->len;
198 int trace_seq_path(struct trace_seq *s, struct path *path)
202 if (s->len >= (PAGE_SIZE - 1))
204 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
206 p = mangle_path(s->buffer + s->len, p, "\n");
208 s->len = p - s->buffer;
212 s->buffer[s->len++] = '?';
220 ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
222 const struct trace_print_flags *flag_array)
230 for (i = 0; flag_array[i].name && flags; i++) {
232 mask = flag_array[i].mask;
233 if ((flags & mask) != mask)
236 str = flag_array[i].name;
239 trace_seq_puts(p, delim);
240 trace_seq_puts(p, str);
243 /* check for left over flags */
246 trace_seq_puts(p, delim);
247 trace_seq_printf(p, "0x%lx", flags);
250 trace_seq_putc(p, 0);
254 EXPORT_SYMBOL(ftrace_print_flags_seq);
257 ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
258 const struct trace_print_flags *symbol_array)
264 for (i = 0; symbol_array[i].name; i++) {
266 if (val != symbol_array[i].mask)
269 trace_seq_puts(p, symbol_array[i].name);
274 trace_seq_printf(p, "0x%lx", val);
276 trace_seq_putc(p, 0);
280 EXPORT_SYMBOL(ftrace_print_symbols_seq);
282 #ifdef CONFIG_KRETPROBES
283 static inline const char *kretprobed(const char *name)
285 static const char tramp_name[] = "kretprobe_trampoline";
286 int size = sizeof(tramp_name);
288 if (strncmp(tramp_name, name, size) == 0)
289 return "[unknown/kretprobe'd]";
293 static inline const char *kretprobed(const char *name)
297 #endif /* CONFIG_KRETPROBES */
300 seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address)
302 #ifdef CONFIG_KALLSYMS
303 char str[KSYM_SYMBOL_LEN];
306 kallsyms_lookup(address, NULL, NULL, NULL, str);
308 name = kretprobed(str);
310 return trace_seq_printf(s, fmt, name);
316 seq_print_sym_offset(struct trace_seq *s, const char *fmt,
317 unsigned long address)
319 #ifdef CONFIG_KALLSYMS
320 char str[KSYM_SYMBOL_LEN];
323 sprint_symbol(str, address);
324 name = kretprobed(str);
326 return trace_seq_printf(s, fmt, name);
332 # define IP_FMT "%08lx"
334 # define IP_FMT "%016lx"
337 int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm,
338 unsigned long ip, unsigned long sym_flags)
340 struct file *file = NULL;
341 unsigned long vmstart = 0;
345 const struct vm_area_struct *vma;
347 down_read(&mm->mmap_sem);
348 vma = find_vma(mm, ip);
351 vmstart = vma->vm_start;
354 ret = trace_seq_path(s, &file->f_path);
356 ret = trace_seq_printf(s, "[+0x%lx]",
359 up_read(&mm->mmap_sem);
361 if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file))
362 ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
367 seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
368 unsigned long sym_flags)
370 struct mm_struct *mm = NULL;
374 if (trace_flags & TRACE_ITER_SYM_USEROBJ) {
375 struct task_struct *task;
377 * we do the lookup on the thread group leader,
378 * since individual threads might have already quit!
381 task = find_task_by_vpid(entry->ent.tgid);
383 mm = get_task_mm(task);
387 for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
388 unsigned long ip = entry->caller[i];
390 if (ip == ULONG_MAX || !ret)
393 ret = trace_seq_puts(s, " => ");
396 ret = trace_seq_puts(s, "??");
398 ret = trace_seq_puts(s, "\n");
404 ret = seq_print_user_ip(s, mm, ip, sym_flags);
405 ret = trace_seq_puts(s, "\n");
414 seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
419 return trace_seq_printf(s, "0");
421 if (sym_flags & TRACE_ITER_SYM_OFFSET)
422 ret = seq_print_sym_offset(s, "%s", ip);
424 ret = seq_print_sym_short(s, "%s", ip);
429 if (sym_flags & TRACE_ITER_SYM_ADDR)
430 ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
435 lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu)
437 int hardirq, softirq;
438 char comm[TASK_COMM_LEN];
440 trace_find_cmdline(entry->pid, comm);
441 hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
442 softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
444 if (!trace_seq_printf(s, "%8.8s-%-5d %3d%c%c%c",
445 comm, entry->pid, cpu,
446 (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
447 (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ?
449 (entry->flags & TRACE_FLAG_NEED_RESCHED) ?
451 (hardirq && softirq) ? 'H' :
452 hardirq ? 'h' : softirq ? 's' : '.'))
455 if (entry->preempt_count)
456 return trace_seq_printf(s, "%x", entry->preempt_count);
457 return trace_seq_puts(s, ".");
460 static unsigned long preempt_mark_thresh = 100;
463 lat_print_timestamp(struct trace_seq *s, u64 abs_usecs,
464 unsigned long rel_usecs)
466 return trace_seq_printf(s, " %4lldus%c: ", abs_usecs,
467 rel_usecs > preempt_mark_thresh ? '!' :
468 rel_usecs > 1 ? '+' : ' ');
471 int trace_print_context(struct trace_iterator *iter)
473 struct trace_seq *s = &iter->seq;
474 struct trace_entry *entry = iter->ent;
475 unsigned long long t = ns2usecs(iter->ts);
476 unsigned long usec_rem = do_div(t, USEC_PER_SEC);
477 unsigned long secs = (unsigned long)t;
478 char comm[TASK_COMM_LEN];
480 trace_find_cmdline(entry->pid, comm);
482 return trace_seq_printf(s, "%16s-%-5d [%03d] %5lu.%06lu: ",
483 comm, entry->pid, iter->cpu, secs, usec_rem);
486 int trace_print_lat_context(struct trace_iterator *iter)
490 struct trace_seq *s = &iter->seq;
491 struct trace_entry *entry = iter->ent,
492 *next_entry = trace_find_next_entry(iter, NULL,
494 unsigned long verbose = (trace_flags & TRACE_ITER_VERBOSE);
495 unsigned long abs_usecs = ns2usecs(iter->ts - iter->tr->time_start);
496 unsigned long rel_usecs;
500 rel_usecs = ns2usecs(next_ts - iter->ts);
503 char comm[TASK_COMM_LEN];
505 trace_find_cmdline(entry->pid, comm);
507 ret = trace_seq_printf(s, "%16s %5d %3d %d %08x %08lx [%08llx]"
508 " %ld.%03ldms (+%ld.%03ldms): ", comm,
509 entry->pid, iter->cpu, entry->flags,
510 entry->preempt_count, iter->idx,
512 abs_usecs / USEC_PER_MSEC,
513 abs_usecs % USEC_PER_MSEC,
514 rel_usecs / USEC_PER_MSEC,
515 rel_usecs % USEC_PER_MSEC);
517 ret = lat_print_generic(s, entry, iter->cpu);
519 ret = lat_print_timestamp(s, abs_usecs, rel_usecs);
525 static const char state_to_char[] = TASK_STATE_TO_CHAR_STR;
527 static int task_state_char(unsigned long state)
529 int bit = state ? __ffs(state) + 1 : 0;
531 return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?';
535 * ftrace_find_event - find a registered event
536 * @type: the type of event to look for
538 * Returns an event of type @type otherwise NULL
539 * Called with trace_event_read_lock() held.
541 struct trace_event *ftrace_find_event(int type)
543 struct trace_event *event;
544 struct hlist_node *n;
547 key = type & (EVENT_HASHSIZE - 1);
549 hlist_for_each_entry(event, n, &event_hash[key], node) {
550 if (event->type == type)
557 static LIST_HEAD(ftrace_event_list);
559 static int trace_search_list(struct list_head **list)
561 struct trace_event *e;
562 int last = __TRACE_LAST_TYPE;
564 if (list_empty(&ftrace_event_list)) {
565 *list = &ftrace_event_list;
570 * We used up all possible max events,
571 * lets see if somebody freed one.
573 list_for_each_entry(e, &ftrace_event_list, list) {
574 if (e->type != last + 1)
579 /* Did we used up all 65 thousand events??? */
580 if ((last + 1) > FTRACE_MAX_EVENT)
587 void trace_event_read_lock(void)
589 down_read(&trace_event_mutex);
592 void trace_event_read_unlock(void)
594 up_read(&trace_event_mutex);
598 * register_ftrace_event - register output for an event type
599 * @event: the event type to register
601 * Event types are stored in a hash and this hash is used to
602 * find a way to print an event. If the @event->type is set
603 * then it will use that type, otherwise it will assign a
606 * If you assign your own type, please make sure it is added
607 * to the trace_type enum in trace.h, to avoid collisions
608 * with the dynamic types.
610 * Returns the event type number or zero on error.
612 int register_ftrace_event(struct trace_event *event)
617 down_write(&trace_event_mutex);
622 INIT_LIST_HEAD(&event->list);
625 struct list_head *list = NULL;
627 if (next_event_type > FTRACE_MAX_EVENT) {
629 event->type = trace_search_list(&list);
635 event->type = next_event_type++;
636 list = &ftrace_event_list;
639 if (WARN_ON(ftrace_find_event(event->type)))
642 list_add_tail(&event->list, list);
644 } else if (event->type > __TRACE_LAST_TYPE) {
645 printk(KERN_WARNING "Need to add type to trace.h\n");
649 /* Is this event already used */
650 if (ftrace_find_event(event->type))
654 if (event->trace == NULL)
655 event->trace = trace_nop_print;
656 if (event->raw == NULL)
657 event->raw = trace_nop_print;
658 if (event->hex == NULL)
659 event->hex = trace_nop_print;
660 if (event->binary == NULL)
661 event->binary = trace_nop_print;
663 key = event->type & (EVENT_HASHSIZE - 1);
665 hlist_add_head(&event->node, &event_hash[key]);
669 up_write(&trace_event_mutex);
673 EXPORT_SYMBOL_GPL(register_ftrace_event);
676 * unregister_ftrace_event - remove a no longer used event
677 * @event: the event to remove
679 int unregister_ftrace_event(struct trace_event *event)
681 down_write(&trace_event_mutex);
682 hlist_del(&event->node);
683 list_del(&event->list);
684 up_write(&trace_event_mutex);
688 EXPORT_SYMBOL_GPL(unregister_ftrace_event);
694 enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags)
696 return TRACE_TYPE_HANDLED;
700 static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags)
702 struct ftrace_entry *field;
703 struct trace_seq *s = &iter->seq;
705 trace_assign_type(field, iter->ent);
707 if (!seq_print_ip_sym(s, field->ip, flags))
710 if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) {
711 if (!trace_seq_printf(s, " <-"))
713 if (!seq_print_ip_sym(s,
718 if (!trace_seq_printf(s, "\n"))
721 return TRACE_TYPE_HANDLED;
724 return TRACE_TYPE_PARTIAL_LINE;
727 static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags)
729 struct ftrace_entry *field;
731 trace_assign_type(field, iter->ent);
733 if (!trace_seq_printf(&iter->seq, "%lx %lx\n",
736 return TRACE_TYPE_PARTIAL_LINE;
738 return TRACE_TYPE_HANDLED;
741 static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags)
743 struct ftrace_entry *field;
744 struct trace_seq *s = &iter->seq;
746 trace_assign_type(field, iter->ent);
748 SEQ_PUT_HEX_FIELD_RET(s, field->ip);
749 SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip);
751 return TRACE_TYPE_HANDLED;
754 static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags)
756 struct ftrace_entry *field;
757 struct trace_seq *s = &iter->seq;
759 trace_assign_type(field, iter->ent);
761 SEQ_PUT_FIELD_RET(s, field->ip);
762 SEQ_PUT_FIELD_RET(s, field->parent_ip);
764 return TRACE_TYPE_HANDLED;
767 static struct trace_event trace_fn_event = {
769 .trace = trace_fn_trace,
772 .binary = trace_fn_bin,
775 /* TRACE_CTX an TRACE_WAKE */
776 static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter,
779 struct ctx_switch_entry *field;
780 char comm[TASK_COMM_LEN];
784 trace_assign_type(field, iter->ent);
786 T = task_state_char(field->next_state);
787 S = task_state_char(field->prev_state);
788 trace_find_cmdline(field->next_pid, comm);
789 if (!trace_seq_printf(&iter->seq,
790 " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n",
798 return TRACE_TYPE_PARTIAL_LINE;
800 return TRACE_TYPE_HANDLED;
803 static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags)
805 return trace_ctxwake_print(iter, "==>");
808 static enum print_line_t trace_wake_print(struct trace_iterator *iter,
811 return trace_ctxwake_print(iter, " +");
814 static int trace_ctxwake_raw(struct trace_iterator *iter, char S)
816 struct ctx_switch_entry *field;
819 trace_assign_type(field, iter->ent);
822 task_state_char(field->prev_state);
823 T = task_state_char(field->next_state);
824 if (!trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n",
832 return TRACE_TYPE_PARTIAL_LINE;
834 return TRACE_TYPE_HANDLED;
837 static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags)
839 return trace_ctxwake_raw(iter, 0);
842 static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags)
844 return trace_ctxwake_raw(iter, '+');
848 static int trace_ctxwake_hex(struct trace_iterator *iter, char S)
850 struct ctx_switch_entry *field;
851 struct trace_seq *s = &iter->seq;
854 trace_assign_type(field, iter->ent);
857 task_state_char(field->prev_state);
858 T = task_state_char(field->next_state);
860 SEQ_PUT_HEX_FIELD_RET(s, field->prev_pid);
861 SEQ_PUT_HEX_FIELD_RET(s, field->prev_prio);
862 SEQ_PUT_HEX_FIELD_RET(s, S);
863 SEQ_PUT_HEX_FIELD_RET(s, field->next_cpu);
864 SEQ_PUT_HEX_FIELD_RET(s, field->next_pid);
865 SEQ_PUT_HEX_FIELD_RET(s, field->next_prio);
866 SEQ_PUT_HEX_FIELD_RET(s, T);
868 return TRACE_TYPE_HANDLED;
871 static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags)
873 return trace_ctxwake_hex(iter, 0);
876 static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags)
878 return trace_ctxwake_hex(iter, '+');
881 static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter,
884 struct ctx_switch_entry *field;
885 struct trace_seq *s = &iter->seq;
887 trace_assign_type(field, iter->ent);
889 SEQ_PUT_FIELD_RET(s, field->prev_pid);
890 SEQ_PUT_FIELD_RET(s, field->prev_prio);
891 SEQ_PUT_FIELD_RET(s, field->prev_state);
892 SEQ_PUT_FIELD_RET(s, field->next_pid);
893 SEQ_PUT_FIELD_RET(s, field->next_prio);
894 SEQ_PUT_FIELD_RET(s, field->next_state);
896 return TRACE_TYPE_HANDLED;
899 static struct trace_event trace_ctx_event = {
901 .trace = trace_ctx_print,
902 .raw = trace_ctx_raw,
903 .hex = trace_ctx_hex,
904 .binary = trace_ctxwake_bin,
907 static struct trace_event trace_wake_event = {
909 .trace = trace_wake_print,
910 .raw = trace_wake_raw,
911 .hex = trace_wake_hex,
912 .binary = trace_ctxwake_bin,
916 static enum print_line_t trace_special_print(struct trace_iterator *iter,
919 struct special_entry *field;
921 trace_assign_type(field, iter->ent);
923 if (!trace_seq_printf(&iter->seq, "# %ld %ld %ld\n",
927 return TRACE_TYPE_PARTIAL_LINE;
929 return TRACE_TYPE_HANDLED;
932 static enum print_line_t trace_special_hex(struct trace_iterator *iter,
935 struct special_entry *field;
936 struct trace_seq *s = &iter->seq;
938 trace_assign_type(field, iter->ent);
940 SEQ_PUT_HEX_FIELD_RET(s, field->arg1);
941 SEQ_PUT_HEX_FIELD_RET(s, field->arg2);
942 SEQ_PUT_HEX_FIELD_RET(s, field->arg3);
944 return TRACE_TYPE_HANDLED;
947 static enum print_line_t trace_special_bin(struct trace_iterator *iter,
950 struct special_entry *field;
951 struct trace_seq *s = &iter->seq;
953 trace_assign_type(field, iter->ent);
955 SEQ_PUT_FIELD_RET(s, field->arg1);
956 SEQ_PUT_FIELD_RET(s, field->arg2);
957 SEQ_PUT_FIELD_RET(s, field->arg3);
959 return TRACE_TYPE_HANDLED;
962 static struct trace_event trace_special_event = {
963 .type = TRACE_SPECIAL,
964 .trace = trace_special_print,
965 .raw = trace_special_print,
966 .hex = trace_special_hex,
967 .binary = trace_special_bin,
972 static enum print_line_t trace_stack_print(struct trace_iterator *iter,
975 struct stack_entry *field;
976 struct trace_seq *s = &iter->seq;
979 trace_assign_type(field, iter->ent);
981 if (!trace_seq_puts(s, "\n"))
983 for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
984 if (!field->caller[i] || (field->caller[i] == ULONG_MAX))
986 if (!trace_seq_puts(s, " => "))
989 if (!seq_print_ip_sym(s, field->caller[i], flags))
991 if (!trace_seq_puts(s, "\n"))
995 return TRACE_TYPE_HANDLED;
998 return TRACE_TYPE_PARTIAL_LINE;
1001 static struct trace_event trace_stack_event = {
1002 .type = TRACE_STACK,
1003 .trace = trace_stack_print,
1004 .raw = trace_special_print,
1005 .hex = trace_special_hex,
1006 .binary = trace_special_bin,
1009 /* TRACE_USER_STACK */
1010 static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
1013 struct userstack_entry *field;
1014 struct trace_seq *s = &iter->seq;
1016 trace_assign_type(field, iter->ent);
1018 if (!trace_seq_putc(s, '\n'))
1021 if (!seq_print_userip_objs(field, s, flags))
1024 return TRACE_TYPE_HANDLED;
1027 return TRACE_TYPE_PARTIAL_LINE;
1030 static struct trace_event trace_user_stack_event = {
1031 .type = TRACE_USER_STACK,
1032 .trace = trace_user_stack_print,
1033 .raw = trace_special_print,
1034 .hex = trace_special_hex,
1035 .binary = trace_special_bin,
1039 static enum print_line_t
1040 trace_bprint_print(struct trace_iterator *iter, int flags)
1042 struct trace_entry *entry = iter->ent;
1043 struct trace_seq *s = &iter->seq;
1044 struct bprint_entry *field;
1046 trace_assign_type(field, entry);
1048 if (!seq_print_ip_sym(s, field->ip, flags))
1051 if (!trace_seq_puts(s, ": "))
1054 if (!trace_seq_bprintf(s, field->fmt, field->buf))
1057 return TRACE_TYPE_HANDLED;
1060 return TRACE_TYPE_PARTIAL_LINE;
1064 static enum print_line_t
1065 trace_bprint_raw(struct trace_iterator *iter, int flags)
1067 struct bprint_entry *field;
1068 struct trace_seq *s = &iter->seq;
1070 trace_assign_type(field, iter->ent);
1072 if (!trace_seq_printf(s, ": %lx : ", field->ip))
1075 if (!trace_seq_bprintf(s, field->fmt, field->buf))
1078 return TRACE_TYPE_HANDLED;
1081 return TRACE_TYPE_PARTIAL_LINE;
1085 static struct trace_event trace_bprint_event = {
1086 .type = TRACE_BPRINT,
1087 .trace = trace_bprint_print,
1088 .raw = trace_bprint_raw,
1092 static enum print_line_t trace_print_print(struct trace_iterator *iter,
1095 struct print_entry *field;
1096 struct trace_seq *s = &iter->seq;
1098 trace_assign_type(field, iter->ent);
1100 if (!seq_print_ip_sym(s, field->ip, flags))
1103 if (!trace_seq_printf(s, ": %s", field->buf))
1106 return TRACE_TYPE_HANDLED;
1109 return TRACE_TYPE_PARTIAL_LINE;
1112 static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags)
1114 struct print_entry *field;
1116 trace_assign_type(field, iter->ent);
1118 if (!trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf))
1121 return TRACE_TYPE_HANDLED;
1124 return TRACE_TYPE_PARTIAL_LINE;
1127 static struct trace_event trace_print_event = {
1128 .type = TRACE_PRINT,
1129 .trace = trace_print_print,
1130 .raw = trace_print_raw,
1134 static struct trace_event *events[] __initdata = {
1138 &trace_special_event,
1140 &trace_user_stack_event,
1141 &trace_bprint_event,
1146 __init static int init_events(void)
1148 struct trace_event *event;
1151 for (i = 0; events[i]; i++) {
1154 ret = register_ftrace_event(event);
1156 printk(KERN_WARNING "event %d failed to register\n",
1164 device_initcall(init_events);