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);
21 static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;
23 static int next_event_type = __TRACE_LAST_TYPE + 1;
25 void trace_print_seq(struct seq_file *m, struct trace_seq *s)
27 int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len;
30 seq_puts(m, s->buffer);
35 enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter)
37 struct trace_seq *s = &iter->seq;
38 struct trace_entry *entry = iter->ent;
39 struct bprint_entry *field;
42 trace_assign_type(field, entry);
44 ret = trace_seq_bprintf(s, field->fmt, field->buf);
46 return TRACE_TYPE_PARTIAL_LINE;
48 return TRACE_TYPE_HANDLED;
51 enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter)
53 struct trace_seq *s = &iter->seq;
54 struct trace_entry *entry = iter->ent;
55 struct print_entry *field;
58 trace_assign_type(field, entry);
60 ret = trace_seq_printf(s, "%s", field->buf);
62 return TRACE_TYPE_PARTIAL_LINE;
64 return TRACE_TYPE_HANDLED;
68 * trace_seq_printf - sequence printing of trace information
69 * @s: trace sequence descriptor
70 * @fmt: printf format string
72 * The tracer may use either sequence operations or its own
73 * copy to user routines. To simplify formating of a trace
74 * trace_seq_printf is used to store strings into a special
75 * buffer (@s). Then the output may be either used by
76 * the sequencer or pulled into another buffer.
79 trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
81 int len = (PAGE_SIZE - 1) - s->len;
89 ret = vsnprintf(s->buffer + s->len, len, fmt, ap);
92 /* If we can't write it all, don't bother writing anything */
100 EXPORT_SYMBOL_GPL(trace_seq_printf);
102 int trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
104 int len = (PAGE_SIZE - 1) - s->len;
110 ret = bstr_printf(s->buffer + s->len, len, fmt, binary);
112 /* If we can't write it all, don't bother writing anything */
122 * trace_seq_puts - trace sequence printing of simple string
123 * @s: trace sequence descriptor
124 * @str: simple string to record
126 * The tracer may use either the sequence operations or its own
127 * copy to user routines. This function records a simple string
128 * into a special buffer (@s) for later retrieval by a sequencer
129 * or other mechanism.
131 int trace_seq_puts(struct trace_seq *s, const char *str)
133 int len = strlen(str);
135 if (len > ((PAGE_SIZE - 1) - s->len))
138 memcpy(s->buffer + s->len, str, len);
144 int trace_seq_putc(struct trace_seq *s, unsigned char c)
146 if (s->len >= (PAGE_SIZE - 1))
149 s->buffer[s->len++] = c;
154 int trace_seq_putmem(struct trace_seq *s, const void *mem, size_t len)
156 if (len > ((PAGE_SIZE - 1) - s->len))
159 memcpy(s->buffer + s->len, mem, len);
165 int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, size_t len)
167 unsigned char hex[HEX_CHARS];
168 const unsigned char *data = mem;
172 for (i = 0, j = 0; i < len; i++) {
174 for (i = len-1, j = 0; i >= 0; i--) {
176 hex[j++] = hex_asc_hi(data[i]);
177 hex[j++] = hex_asc_lo(data[i]);
181 return trace_seq_putmem(s, hex, j);
184 void *trace_seq_reserve(struct trace_seq *s, size_t len)
188 if (len > ((PAGE_SIZE - 1) - s->len))
191 ret = s->buffer + s->len;
197 int trace_seq_path(struct trace_seq *s, struct path *path)
201 if (s->len >= (PAGE_SIZE - 1))
203 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
205 p = mangle_path(s->buffer + s->len, p, "\n");
207 s->len = p - s->buffer;
211 s->buffer[s->len++] = '?';
219 ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
221 const struct trace_print_flags *flag_array)
229 for (i = 0; flag_array[i].name && flags; i++) {
231 mask = flag_array[i].mask;
232 if ((flags & mask) != mask)
235 str = flag_array[i].name;
238 trace_seq_puts(p, delim);
239 trace_seq_puts(p, str);
242 /* check for left over flags */
245 trace_seq_puts(p, delim);
246 trace_seq_printf(p, "0x%lx", flags);
249 trace_seq_putc(p, 0);
255 ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
256 const struct trace_print_flags *symbol_array)
262 for (i = 0; symbol_array[i].name; i++) {
264 if (val != symbol_array[i].mask)
267 trace_seq_puts(p, symbol_array[i].name);
272 trace_seq_printf(p, "0x%lx", val);
274 trace_seq_putc(p, 0);
279 #ifdef CONFIG_KRETPROBES
280 static inline const char *kretprobed(const char *name)
282 static const char tramp_name[] = "kretprobe_trampoline";
283 int size = sizeof(tramp_name);
285 if (strncmp(tramp_name, name, size) == 0)
286 return "[unknown/kretprobe'd]";
290 static inline const char *kretprobed(const char *name)
294 #endif /* CONFIG_KRETPROBES */
297 seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address)
299 #ifdef CONFIG_KALLSYMS
300 char str[KSYM_SYMBOL_LEN];
303 kallsyms_lookup(address, NULL, NULL, NULL, str);
305 name = kretprobed(str);
307 return trace_seq_printf(s, fmt, name);
313 seq_print_sym_offset(struct trace_seq *s, const char *fmt,
314 unsigned long address)
316 #ifdef CONFIG_KALLSYMS
317 char str[KSYM_SYMBOL_LEN];
320 sprint_symbol(str, address);
321 name = kretprobed(str);
323 return trace_seq_printf(s, fmt, name);
329 # define IP_FMT "%08lx"
331 # define IP_FMT "%016lx"
334 int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm,
335 unsigned long ip, unsigned long sym_flags)
337 struct file *file = NULL;
338 unsigned long vmstart = 0;
342 const struct vm_area_struct *vma;
344 down_read(&mm->mmap_sem);
345 vma = find_vma(mm, ip);
348 vmstart = vma->vm_start;
351 ret = trace_seq_path(s, &file->f_path);
353 ret = trace_seq_printf(s, "[+0x%lx]",
356 up_read(&mm->mmap_sem);
358 if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file))
359 ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
364 seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
365 unsigned long sym_flags)
367 struct mm_struct *mm = NULL;
371 if (trace_flags & TRACE_ITER_SYM_USEROBJ) {
372 struct task_struct *task;
374 * we do the lookup on the thread group leader,
375 * since individual threads might have already quit!
378 task = find_task_by_vpid(entry->ent.tgid);
380 mm = get_task_mm(task);
384 for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
385 unsigned long ip = entry->caller[i];
387 if (ip == ULONG_MAX || !ret)
390 ret = trace_seq_puts(s, " <- ");
393 ret = trace_seq_puts(s, "??");
399 ret = seq_print_user_ip(s, mm, ip, sym_flags);
408 seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
413 return trace_seq_printf(s, "0");
415 if (sym_flags & TRACE_ITER_SYM_OFFSET)
416 ret = seq_print_sym_offset(s, "%s", ip);
418 ret = seq_print_sym_short(s, "%s", ip);
423 if (sym_flags & TRACE_ITER_SYM_ADDR)
424 ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
429 lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu)
431 int hardirq, softirq;
432 char comm[TASK_COMM_LEN];
434 trace_find_cmdline(entry->pid, comm);
435 hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
436 softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
438 if (!trace_seq_printf(s, "%8.8s-%-5d %3d%c%c%c",
439 comm, entry->pid, cpu,
440 (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
441 (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ?
443 (entry->flags & TRACE_FLAG_NEED_RESCHED) ?
445 (hardirq && softirq) ? 'H' :
446 hardirq ? 'h' : softirq ? 's' : '.'))
449 if (entry->preempt_count)
450 return trace_seq_printf(s, "%x", entry->preempt_count);
451 return trace_seq_puts(s, ".");
454 static unsigned long preempt_mark_thresh = 100;
457 lat_print_timestamp(struct trace_seq *s, u64 abs_usecs,
458 unsigned long rel_usecs)
460 return trace_seq_printf(s, " %4lldus%c: ", abs_usecs,
461 rel_usecs > preempt_mark_thresh ? '!' :
462 rel_usecs > 1 ? '+' : ' ');
465 int trace_print_context(struct trace_iterator *iter)
467 struct trace_seq *s = &iter->seq;
468 struct trace_entry *entry = iter->ent;
469 unsigned long long t = ns2usecs(iter->ts);
470 unsigned long usec_rem = do_div(t, USEC_PER_SEC);
471 unsigned long secs = (unsigned long)t;
472 char comm[TASK_COMM_LEN];
474 trace_find_cmdline(entry->pid, comm);
476 return trace_seq_printf(s, "%16s-%-5d [%03d] %5lu.%06lu: ",
477 comm, entry->pid, iter->cpu, secs, usec_rem);
480 int trace_print_lat_context(struct trace_iterator *iter)
484 struct trace_seq *s = &iter->seq;
485 struct trace_entry *entry = iter->ent,
486 *next_entry = trace_find_next_entry(iter, NULL,
488 unsigned long verbose = (trace_flags & TRACE_ITER_VERBOSE);
489 unsigned long abs_usecs = ns2usecs(iter->ts - iter->tr->time_start);
490 unsigned long rel_usecs;
494 rel_usecs = ns2usecs(next_ts - iter->ts);
497 char comm[TASK_COMM_LEN];
499 trace_find_cmdline(entry->pid, comm);
501 ret = trace_seq_printf(s, "%16s %5d %3d %d %08x %08lx [%08llx]"
502 " %ld.%03ldms (+%ld.%03ldms): ", comm,
503 entry->pid, iter->cpu, entry->flags,
504 entry->preempt_count, iter->idx,
506 abs_usecs / USEC_PER_MSEC,
507 abs_usecs % USEC_PER_MSEC,
508 rel_usecs / USEC_PER_MSEC,
509 rel_usecs % USEC_PER_MSEC);
511 ret = lat_print_generic(s, entry, iter->cpu);
513 ret = lat_print_timestamp(s, abs_usecs, rel_usecs);
519 static const char state_to_char[] = TASK_STATE_TO_CHAR_STR;
521 static int task_state_char(unsigned long state)
523 int bit = state ? __ffs(state) + 1 : 0;
525 return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?';
529 * ftrace_find_event - find a registered event
530 * @type: the type of event to look for
532 * Returns an event of type @type otherwise NULL
533 * Called with trace_event_read_lock() held.
535 struct trace_event *ftrace_find_event(int type)
537 struct trace_event *event;
538 struct hlist_node *n;
541 key = type & (EVENT_HASHSIZE - 1);
543 hlist_for_each_entry(event, n, &event_hash[key], node) {
544 if (event->type == type)
551 static LIST_HEAD(ftrace_event_list);
553 static int trace_search_list(struct list_head **list)
555 struct trace_event *e;
556 int last = __TRACE_LAST_TYPE;
558 if (list_empty(&ftrace_event_list)) {
559 *list = &ftrace_event_list;
564 * We used up all possible max events,
565 * lets see if somebody freed one.
567 list_for_each_entry(e, &ftrace_event_list, list) {
568 if (e->type != last + 1)
573 /* Did we used up all 65 thousand events??? */
574 if ((last + 1) > FTRACE_MAX_EVENT)
581 void trace_event_read_lock(void)
583 down_read(&trace_event_mutex);
586 void trace_event_read_unlock(void)
588 up_read(&trace_event_mutex);
592 * register_ftrace_event - register output for an event type
593 * @event: the event type to register
595 * Event types are stored in a hash and this hash is used to
596 * find a way to print an event. If the @event->type is set
597 * then it will use that type, otherwise it will assign a
600 * If you assign your own type, please make sure it is added
601 * to the trace_type enum in trace.h, to avoid collisions
602 * with the dynamic types.
604 * Returns the event type number or zero on error.
606 int register_ftrace_event(struct trace_event *event)
611 down_write(&trace_event_mutex);
616 INIT_LIST_HEAD(&event->list);
619 struct list_head *list = NULL;
621 if (next_event_type > FTRACE_MAX_EVENT) {
623 event->type = trace_search_list(&list);
629 event->type = next_event_type++;
630 list = &ftrace_event_list;
633 if (WARN_ON(ftrace_find_event(event->type)))
636 list_add_tail(&event->list, list);
638 } else if (event->type > __TRACE_LAST_TYPE) {
639 printk(KERN_WARNING "Need to add type to trace.h\n");
643 /* Is this event already used */
644 if (ftrace_find_event(event->type))
648 if (event->trace == NULL)
649 event->trace = trace_nop_print;
650 if (event->raw == NULL)
651 event->raw = trace_nop_print;
652 if (event->hex == NULL)
653 event->hex = trace_nop_print;
654 if (event->binary == NULL)
655 event->binary = trace_nop_print;
657 key = event->type & (EVENT_HASHSIZE - 1);
659 hlist_add_head(&event->node, &event_hash[key]);
663 up_write(&trace_event_mutex);
667 EXPORT_SYMBOL_GPL(register_ftrace_event);
670 * unregister_ftrace_event - remove a no longer used event
671 * @event: the event to remove
673 int unregister_ftrace_event(struct trace_event *event)
675 down_write(&trace_event_mutex);
676 hlist_del(&event->node);
677 list_del(&event->list);
678 up_write(&trace_event_mutex);
682 EXPORT_SYMBOL_GPL(unregister_ftrace_event);
688 enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags)
690 return TRACE_TYPE_HANDLED;
694 static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags)
696 struct ftrace_entry *field;
697 struct trace_seq *s = &iter->seq;
699 trace_assign_type(field, iter->ent);
701 if (!seq_print_ip_sym(s, field->ip, flags))
704 if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) {
705 if (!trace_seq_printf(s, " <-"))
707 if (!seq_print_ip_sym(s,
712 if (!trace_seq_printf(s, "\n"))
715 return TRACE_TYPE_HANDLED;
718 return TRACE_TYPE_PARTIAL_LINE;
721 static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags)
723 struct ftrace_entry *field;
725 trace_assign_type(field, iter->ent);
727 if (!trace_seq_printf(&iter->seq, "%lx %lx\n",
730 return TRACE_TYPE_PARTIAL_LINE;
732 return TRACE_TYPE_HANDLED;
735 static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags)
737 struct ftrace_entry *field;
738 struct trace_seq *s = &iter->seq;
740 trace_assign_type(field, iter->ent);
742 SEQ_PUT_HEX_FIELD_RET(s, field->ip);
743 SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip);
745 return TRACE_TYPE_HANDLED;
748 static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags)
750 struct ftrace_entry *field;
751 struct trace_seq *s = &iter->seq;
753 trace_assign_type(field, iter->ent);
755 SEQ_PUT_FIELD_RET(s, field->ip);
756 SEQ_PUT_FIELD_RET(s, field->parent_ip);
758 return TRACE_TYPE_HANDLED;
761 static struct trace_event trace_fn_event = {
763 .trace = trace_fn_trace,
766 .binary = trace_fn_bin,
769 /* TRACE_CTX an TRACE_WAKE */
770 static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter,
773 struct ctx_switch_entry *field;
774 char comm[TASK_COMM_LEN];
778 trace_assign_type(field, iter->ent);
780 T = task_state_char(field->next_state);
781 S = task_state_char(field->prev_state);
782 trace_find_cmdline(field->next_pid, comm);
783 if (!trace_seq_printf(&iter->seq,
784 " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n",
792 return TRACE_TYPE_PARTIAL_LINE;
794 return TRACE_TYPE_HANDLED;
797 static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags)
799 return trace_ctxwake_print(iter, "==>");
802 static enum print_line_t trace_wake_print(struct trace_iterator *iter,
805 return trace_ctxwake_print(iter, " +");
808 static int trace_ctxwake_raw(struct trace_iterator *iter, char S)
810 struct ctx_switch_entry *field;
813 trace_assign_type(field, iter->ent);
816 task_state_char(field->prev_state);
817 T = task_state_char(field->next_state);
818 if (!trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n",
826 return TRACE_TYPE_PARTIAL_LINE;
828 return TRACE_TYPE_HANDLED;
831 static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags)
833 return trace_ctxwake_raw(iter, 0);
836 static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags)
838 return trace_ctxwake_raw(iter, '+');
842 static int trace_ctxwake_hex(struct trace_iterator *iter, char S)
844 struct ctx_switch_entry *field;
845 struct trace_seq *s = &iter->seq;
848 trace_assign_type(field, iter->ent);
851 task_state_char(field->prev_state);
852 T = task_state_char(field->next_state);
854 SEQ_PUT_HEX_FIELD_RET(s, field->prev_pid);
855 SEQ_PUT_HEX_FIELD_RET(s, field->prev_prio);
856 SEQ_PUT_HEX_FIELD_RET(s, S);
857 SEQ_PUT_HEX_FIELD_RET(s, field->next_cpu);
858 SEQ_PUT_HEX_FIELD_RET(s, field->next_pid);
859 SEQ_PUT_HEX_FIELD_RET(s, field->next_prio);
860 SEQ_PUT_HEX_FIELD_RET(s, T);
862 return TRACE_TYPE_HANDLED;
865 static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags)
867 return trace_ctxwake_hex(iter, 0);
870 static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags)
872 return trace_ctxwake_hex(iter, '+');
875 static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter,
878 struct ctx_switch_entry *field;
879 struct trace_seq *s = &iter->seq;
881 trace_assign_type(field, iter->ent);
883 SEQ_PUT_FIELD_RET(s, field->prev_pid);
884 SEQ_PUT_FIELD_RET(s, field->prev_prio);
885 SEQ_PUT_FIELD_RET(s, field->prev_state);
886 SEQ_PUT_FIELD_RET(s, field->next_pid);
887 SEQ_PUT_FIELD_RET(s, field->next_prio);
888 SEQ_PUT_FIELD_RET(s, field->next_state);
890 return TRACE_TYPE_HANDLED;
893 static struct trace_event trace_ctx_event = {
895 .trace = trace_ctx_print,
896 .raw = trace_ctx_raw,
897 .hex = trace_ctx_hex,
898 .binary = trace_ctxwake_bin,
901 static struct trace_event trace_wake_event = {
903 .trace = trace_wake_print,
904 .raw = trace_wake_raw,
905 .hex = trace_wake_hex,
906 .binary = trace_ctxwake_bin,
910 static enum print_line_t trace_special_print(struct trace_iterator *iter,
913 struct special_entry *field;
915 trace_assign_type(field, iter->ent);
917 if (!trace_seq_printf(&iter->seq, "# %ld %ld %ld\n",
921 return TRACE_TYPE_PARTIAL_LINE;
923 return TRACE_TYPE_HANDLED;
926 static enum print_line_t trace_special_hex(struct trace_iterator *iter,
929 struct special_entry *field;
930 struct trace_seq *s = &iter->seq;
932 trace_assign_type(field, iter->ent);
934 SEQ_PUT_HEX_FIELD_RET(s, field->arg1);
935 SEQ_PUT_HEX_FIELD_RET(s, field->arg2);
936 SEQ_PUT_HEX_FIELD_RET(s, field->arg3);
938 return TRACE_TYPE_HANDLED;
941 static enum print_line_t trace_special_bin(struct trace_iterator *iter,
944 struct special_entry *field;
945 struct trace_seq *s = &iter->seq;
947 trace_assign_type(field, iter->ent);
949 SEQ_PUT_FIELD_RET(s, field->arg1);
950 SEQ_PUT_FIELD_RET(s, field->arg2);
951 SEQ_PUT_FIELD_RET(s, field->arg3);
953 return TRACE_TYPE_HANDLED;
956 static struct trace_event trace_special_event = {
957 .type = TRACE_SPECIAL,
958 .trace = trace_special_print,
959 .raw = trace_special_print,
960 .hex = trace_special_hex,
961 .binary = trace_special_bin,
966 static enum print_line_t trace_stack_print(struct trace_iterator *iter,
969 struct stack_entry *field;
970 struct trace_seq *s = &iter->seq;
973 trace_assign_type(field, iter->ent);
975 for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
976 if (!field->caller[i])
979 if (!trace_seq_puts(s, " <= "))
982 if (!seq_print_ip_sym(s, field->caller[i], flags))
985 if (!trace_seq_puts(s, "\n"))
989 return TRACE_TYPE_HANDLED;
992 return TRACE_TYPE_PARTIAL_LINE;
995 static struct trace_event trace_stack_event = {
997 .trace = trace_stack_print,
998 .raw = trace_special_print,
999 .hex = trace_special_hex,
1000 .binary = trace_special_bin,
1003 /* TRACE_USER_STACK */
1004 static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
1007 struct userstack_entry *field;
1008 struct trace_seq *s = &iter->seq;
1010 trace_assign_type(field, iter->ent);
1012 if (!seq_print_userip_objs(field, s, flags))
1015 if (!trace_seq_putc(s, '\n'))
1018 return TRACE_TYPE_HANDLED;
1021 return TRACE_TYPE_PARTIAL_LINE;
1024 static struct trace_event trace_user_stack_event = {
1025 .type = TRACE_USER_STACK,
1026 .trace = trace_user_stack_print,
1027 .raw = trace_special_print,
1028 .hex = trace_special_hex,
1029 .binary = trace_special_bin,
1033 static enum print_line_t
1034 trace_bprint_print(struct trace_iterator *iter, int flags)
1036 struct trace_entry *entry = iter->ent;
1037 struct trace_seq *s = &iter->seq;
1038 struct bprint_entry *field;
1040 trace_assign_type(field, entry);
1042 if (!seq_print_ip_sym(s, field->ip, flags))
1045 if (!trace_seq_puts(s, ": "))
1048 if (!trace_seq_bprintf(s, field->fmt, field->buf))
1051 return TRACE_TYPE_HANDLED;
1054 return TRACE_TYPE_PARTIAL_LINE;
1058 static enum print_line_t
1059 trace_bprint_raw(struct trace_iterator *iter, int flags)
1061 struct bprint_entry *field;
1062 struct trace_seq *s = &iter->seq;
1064 trace_assign_type(field, iter->ent);
1066 if (!trace_seq_printf(s, ": %lx : ", field->ip))
1069 if (!trace_seq_bprintf(s, field->fmt, field->buf))
1072 return TRACE_TYPE_HANDLED;
1075 return TRACE_TYPE_PARTIAL_LINE;
1079 static struct trace_event trace_bprint_event = {
1080 .type = TRACE_BPRINT,
1081 .trace = trace_bprint_print,
1082 .raw = trace_bprint_raw,
1086 static enum print_line_t trace_print_print(struct trace_iterator *iter,
1089 struct print_entry *field;
1090 struct trace_seq *s = &iter->seq;
1092 trace_assign_type(field, iter->ent);
1094 if (!seq_print_ip_sym(s, field->ip, flags))
1097 if (!trace_seq_printf(s, ": %s", field->buf))
1100 return TRACE_TYPE_HANDLED;
1103 return TRACE_TYPE_PARTIAL_LINE;
1106 static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags)
1108 struct print_entry *field;
1110 trace_assign_type(field, iter->ent);
1112 if (!trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf))
1115 return TRACE_TYPE_HANDLED;
1118 return TRACE_TYPE_PARTIAL_LINE;
1121 static struct trace_event trace_print_event = {
1122 .type = TRACE_PRINT,
1123 .trace = trace_print_print,
1124 .raw = trace_print_raw,
1128 static struct trace_event *events[] __initdata = {
1132 &trace_special_event,
1134 &trace_user_stack_event,
1135 &trace_bprint_event,
1140 __init static int init_events(void)
1142 struct trace_event *event;
1145 for (i = 0; events[i]; i++) {
1148 ret = register_ftrace_event(event);
1150 printk(KERN_WARNING "event %d failed to register\n",
1158 device_initcall(init_events);