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);
254 #ifdef CONFIG_KRETPROBES
255 static inline const char *kretprobed(const char *name)
257 static const char tramp_name[] = "kretprobe_trampoline";
258 int size = sizeof(tramp_name);
260 if (strncmp(tramp_name, name, size) == 0)
261 return "[unknown/kretprobe'd]";
265 static inline const char *kretprobed(const char *name)
269 #endif /* CONFIG_KRETPROBES */
272 seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address)
274 #ifdef CONFIG_KALLSYMS
275 char str[KSYM_SYMBOL_LEN];
278 kallsyms_lookup(address, NULL, NULL, NULL, str);
280 name = kretprobed(str);
282 return trace_seq_printf(s, fmt, name);
288 seq_print_sym_offset(struct trace_seq *s, const char *fmt,
289 unsigned long address)
291 #ifdef CONFIG_KALLSYMS
292 char str[KSYM_SYMBOL_LEN];
295 sprint_symbol(str, address);
296 name = kretprobed(str);
298 return trace_seq_printf(s, fmt, name);
304 # define IP_FMT "%08lx"
306 # define IP_FMT "%016lx"
309 int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm,
310 unsigned long ip, unsigned long sym_flags)
312 struct file *file = NULL;
313 unsigned long vmstart = 0;
317 const struct vm_area_struct *vma;
319 down_read(&mm->mmap_sem);
320 vma = find_vma(mm, ip);
323 vmstart = vma->vm_start;
326 ret = trace_seq_path(s, &file->f_path);
328 ret = trace_seq_printf(s, "[+0x%lx]",
331 up_read(&mm->mmap_sem);
333 if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file))
334 ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
339 seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
340 unsigned long sym_flags)
342 struct mm_struct *mm = NULL;
346 if (trace_flags & TRACE_ITER_SYM_USEROBJ) {
347 struct task_struct *task;
349 * we do the lookup on the thread group leader,
350 * since individual threads might have already quit!
353 task = find_task_by_vpid(entry->ent.tgid);
355 mm = get_task_mm(task);
359 for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
360 unsigned long ip = entry->caller[i];
362 if (ip == ULONG_MAX || !ret)
365 ret = trace_seq_puts(s, " <- ");
368 ret = trace_seq_puts(s, "??");
374 ret = seq_print_user_ip(s, mm, ip, sym_flags);
383 seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
388 return trace_seq_printf(s, "0");
390 if (sym_flags & TRACE_ITER_SYM_OFFSET)
391 ret = seq_print_sym_offset(s, "%s", ip);
393 ret = seq_print_sym_short(s, "%s", ip);
398 if (sym_flags & TRACE_ITER_SYM_ADDR)
399 ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
404 lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu)
406 int hardirq, softirq;
407 char comm[TASK_COMM_LEN];
409 trace_find_cmdline(entry->pid, comm);
410 hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
411 softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
413 if (!trace_seq_printf(s, "%8.8s-%-5d %3d%c%c%c",
414 comm, entry->pid, cpu,
415 (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
416 (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ?
418 (entry->flags & TRACE_FLAG_NEED_RESCHED) ?
420 (hardirq && softirq) ? 'H' :
421 hardirq ? 'h' : softirq ? 's' : '.'))
424 if (entry->preempt_count)
425 return trace_seq_printf(s, "%x", entry->preempt_count);
426 return trace_seq_puts(s, ".");
429 static unsigned long preempt_mark_thresh = 100;
432 lat_print_timestamp(struct trace_seq *s, u64 abs_usecs,
433 unsigned long rel_usecs)
435 return trace_seq_printf(s, " %4lldus%c: ", abs_usecs,
436 rel_usecs > preempt_mark_thresh ? '!' :
437 rel_usecs > 1 ? '+' : ' ');
440 int trace_print_context(struct trace_iterator *iter)
442 struct trace_seq *s = &iter->seq;
443 struct trace_entry *entry = iter->ent;
444 unsigned long long t = ns2usecs(iter->ts);
445 unsigned long usec_rem = do_div(t, USEC_PER_SEC);
446 unsigned long secs = (unsigned long)t;
447 char comm[TASK_COMM_LEN];
449 trace_find_cmdline(entry->pid, comm);
451 return trace_seq_printf(s, "%16s-%-5d [%03d] %5lu.%06lu: ",
452 comm, entry->pid, iter->cpu, secs, usec_rem);
455 int trace_print_lat_context(struct trace_iterator *iter)
459 struct trace_seq *s = &iter->seq;
460 struct trace_entry *entry = iter->ent,
461 *next_entry = trace_find_next_entry(iter, NULL,
463 unsigned long verbose = (trace_flags & TRACE_ITER_VERBOSE);
464 unsigned long abs_usecs = ns2usecs(iter->ts - iter->tr->time_start);
465 unsigned long rel_usecs;
469 rel_usecs = ns2usecs(next_ts - iter->ts);
472 char comm[TASK_COMM_LEN];
474 trace_find_cmdline(entry->pid, comm);
476 ret = trace_seq_printf(s, "%16s %5d %3d %d %08x %08lx [%08llx]"
477 " %ld.%03ldms (+%ld.%03ldms): ", comm,
478 entry->pid, iter->cpu, entry->flags,
479 entry->preempt_count, iter->idx,
481 abs_usecs / USEC_PER_MSEC,
482 abs_usecs % USEC_PER_MSEC,
483 rel_usecs / USEC_PER_MSEC,
484 rel_usecs % USEC_PER_MSEC);
486 ret = lat_print_generic(s, entry, iter->cpu);
488 ret = lat_print_timestamp(s, abs_usecs, rel_usecs);
494 static const char state_to_char[] = TASK_STATE_TO_CHAR_STR;
496 static int task_state_char(unsigned long state)
498 int bit = state ? __ffs(state) + 1 : 0;
500 return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?';
504 * ftrace_find_event - find a registered event
505 * @type: the type of event to look for
507 * Returns an event of type @type otherwise NULL
508 * Called with trace_event_read_lock() held.
510 struct trace_event *ftrace_find_event(int type)
512 struct trace_event *event;
513 struct hlist_node *n;
516 key = type & (EVENT_HASHSIZE - 1);
518 hlist_for_each_entry(event, n, &event_hash[key], node) {
519 if (event->type == type)
526 static LIST_HEAD(ftrace_event_list);
528 static int trace_search_list(struct list_head **list)
530 struct trace_event *e;
531 int last = __TRACE_LAST_TYPE;
533 if (list_empty(&ftrace_event_list)) {
534 *list = &ftrace_event_list;
539 * We used up all possible max events,
540 * lets see if somebody freed one.
542 list_for_each_entry(e, &ftrace_event_list, list) {
543 if (e->type != last + 1)
548 /* Did we used up all 65 thousand events??? */
549 if ((last + 1) > FTRACE_MAX_EVENT)
556 void trace_event_read_lock(void)
558 down_read(&trace_event_mutex);
561 void trace_event_read_unlock(void)
563 up_read(&trace_event_mutex);
567 * register_ftrace_event - register output for an event type
568 * @event: the event type to register
570 * Event types are stored in a hash and this hash is used to
571 * find a way to print an event. If the @event->type is set
572 * then it will use that type, otherwise it will assign a
575 * If you assign your own type, please make sure it is added
576 * to the trace_type enum in trace.h, to avoid collisions
577 * with the dynamic types.
579 * Returns the event type number or zero on error.
581 int register_ftrace_event(struct trace_event *event)
586 down_write(&trace_event_mutex);
591 INIT_LIST_HEAD(&event->list);
594 struct list_head *list = NULL;
596 if (next_event_type > FTRACE_MAX_EVENT) {
598 event->type = trace_search_list(&list);
604 event->type = next_event_type++;
605 list = &ftrace_event_list;
608 if (WARN_ON(ftrace_find_event(event->type)))
611 list_add_tail(&event->list, list);
613 } else if (event->type > __TRACE_LAST_TYPE) {
614 printk(KERN_WARNING "Need to add type to trace.h\n");
618 /* Is this event already used */
619 if (ftrace_find_event(event->type))
623 if (event->trace == NULL)
624 event->trace = trace_nop_print;
625 if (event->raw == NULL)
626 event->raw = trace_nop_print;
627 if (event->hex == NULL)
628 event->hex = trace_nop_print;
629 if (event->binary == NULL)
630 event->binary = trace_nop_print;
632 key = event->type & (EVENT_HASHSIZE - 1);
634 hlist_add_head(&event->node, &event_hash[key]);
638 up_write(&trace_event_mutex);
642 EXPORT_SYMBOL_GPL(register_ftrace_event);
645 * unregister_ftrace_event - remove a no longer used event
646 * @event: the event to remove
648 int unregister_ftrace_event(struct trace_event *event)
650 down_write(&trace_event_mutex);
651 hlist_del(&event->node);
652 list_del(&event->list);
653 up_write(&trace_event_mutex);
657 EXPORT_SYMBOL_GPL(unregister_ftrace_event);
663 enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags)
665 return TRACE_TYPE_HANDLED;
669 static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags)
671 struct ftrace_entry *field;
672 struct trace_seq *s = &iter->seq;
674 trace_assign_type(field, iter->ent);
676 if (!seq_print_ip_sym(s, field->ip, flags))
679 if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) {
680 if (!trace_seq_printf(s, " <-"))
682 if (!seq_print_ip_sym(s,
687 if (!trace_seq_printf(s, "\n"))
690 return TRACE_TYPE_HANDLED;
693 return TRACE_TYPE_PARTIAL_LINE;
696 static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags)
698 struct ftrace_entry *field;
700 trace_assign_type(field, iter->ent);
702 if (!trace_seq_printf(&iter->seq, "%lx %lx\n",
705 return TRACE_TYPE_PARTIAL_LINE;
707 return TRACE_TYPE_HANDLED;
710 static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags)
712 struct ftrace_entry *field;
713 struct trace_seq *s = &iter->seq;
715 trace_assign_type(field, iter->ent);
717 SEQ_PUT_HEX_FIELD_RET(s, field->ip);
718 SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip);
720 return TRACE_TYPE_HANDLED;
723 static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags)
725 struct ftrace_entry *field;
726 struct trace_seq *s = &iter->seq;
728 trace_assign_type(field, iter->ent);
730 SEQ_PUT_FIELD_RET(s, field->ip);
731 SEQ_PUT_FIELD_RET(s, field->parent_ip);
733 return TRACE_TYPE_HANDLED;
736 static struct trace_event trace_fn_event = {
738 .trace = trace_fn_trace,
741 .binary = trace_fn_bin,
744 /* TRACE_CTX an TRACE_WAKE */
745 static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter,
748 struct ctx_switch_entry *field;
749 char comm[TASK_COMM_LEN];
753 trace_assign_type(field, iter->ent);
755 T = task_state_char(field->next_state);
756 S = task_state_char(field->prev_state);
757 trace_find_cmdline(field->next_pid, comm);
758 if (!trace_seq_printf(&iter->seq,
759 " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n",
767 return TRACE_TYPE_PARTIAL_LINE;
769 return TRACE_TYPE_HANDLED;
772 static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags)
774 return trace_ctxwake_print(iter, "==>");
777 static enum print_line_t trace_wake_print(struct trace_iterator *iter,
780 return trace_ctxwake_print(iter, " +");
783 static int trace_ctxwake_raw(struct trace_iterator *iter, char S)
785 struct ctx_switch_entry *field;
788 trace_assign_type(field, iter->ent);
791 task_state_char(field->prev_state);
792 T = task_state_char(field->next_state);
793 if (!trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n",
801 return TRACE_TYPE_PARTIAL_LINE;
803 return TRACE_TYPE_HANDLED;
806 static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags)
808 return trace_ctxwake_raw(iter, 0);
811 static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags)
813 return trace_ctxwake_raw(iter, '+');
817 static int trace_ctxwake_hex(struct trace_iterator *iter, char S)
819 struct ctx_switch_entry *field;
820 struct trace_seq *s = &iter->seq;
823 trace_assign_type(field, iter->ent);
826 task_state_char(field->prev_state);
827 T = task_state_char(field->next_state);
829 SEQ_PUT_HEX_FIELD_RET(s, field->prev_pid);
830 SEQ_PUT_HEX_FIELD_RET(s, field->prev_prio);
831 SEQ_PUT_HEX_FIELD_RET(s, S);
832 SEQ_PUT_HEX_FIELD_RET(s, field->next_cpu);
833 SEQ_PUT_HEX_FIELD_RET(s, field->next_pid);
834 SEQ_PUT_HEX_FIELD_RET(s, field->next_prio);
835 SEQ_PUT_HEX_FIELD_RET(s, T);
837 return TRACE_TYPE_HANDLED;
840 static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags)
842 return trace_ctxwake_hex(iter, 0);
845 static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags)
847 return trace_ctxwake_hex(iter, '+');
850 static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter,
853 struct ctx_switch_entry *field;
854 struct trace_seq *s = &iter->seq;
856 trace_assign_type(field, iter->ent);
858 SEQ_PUT_FIELD_RET(s, field->prev_pid);
859 SEQ_PUT_FIELD_RET(s, field->prev_prio);
860 SEQ_PUT_FIELD_RET(s, field->prev_state);
861 SEQ_PUT_FIELD_RET(s, field->next_pid);
862 SEQ_PUT_FIELD_RET(s, field->next_prio);
863 SEQ_PUT_FIELD_RET(s, field->next_state);
865 return TRACE_TYPE_HANDLED;
868 static struct trace_event trace_ctx_event = {
870 .trace = trace_ctx_print,
871 .raw = trace_ctx_raw,
872 .hex = trace_ctx_hex,
873 .binary = trace_ctxwake_bin,
876 static struct trace_event trace_wake_event = {
878 .trace = trace_wake_print,
879 .raw = trace_wake_raw,
880 .hex = trace_wake_hex,
881 .binary = trace_ctxwake_bin,
885 static enum print_line_t trace_special_print(struct trace_iterator *iter,
888 struct special_entry *field;
890 trace_assign_type(field, iter->ent);
892 if (!trace_seq_printf(&iter->seq, "# %ld %ld %ld\n",
896 return TRACE_TYPE_PARTIAL_LINE;
898 return TRACE_TYPE_HANDLED;
901 static enum print_line_t trace_special_hex(struct trace_iterator *iter,
904 struct special_entry *field;
905 struct trace_seq *s = &iter->seq;
907 trace_assign_type(field, iter->ent);
909 SEQ_PUT_HEX_FIELD_RET(s, field->arg1);
910 SEQ_PUT_HEX_FIELD_RET(s, field->arg2);
911 SEQ_PUT_HEX_FIELD_RET(s, field->arg3);
913 return TRACE_TYPE_HANDLED;
916 static enum print_line_t trace_special_bin(struct trace_iterator *iter,
919 struct special_entry *field;
920 struct trace_seq *s = &iter->seq;
922 trace_assign_type(field, iter->ent);
924 SEQ_PUT_FIELD_RET(s, field->arg1);
925 SEQ_PUT_FIELD_RET(s, field->arg2);
926 SEQ_PUT_FIELD_RET(s, field->arg3);
928 return TRACE_TYPE_HANDLED;
931 static struct trace_event trace_special_event = {
932 .type = TRACE_SPECIAL,
933 .trace = trace_special_print,
934 .raw = trace_special_print,
935 .hex = trace_special_hex,
936 .binary = trace_special_bin,
941 static enum print_line_t trace_stack_print(struct trace_iterator *iter,
944 struct stack_entry *field;
945 struct trace_seq *s = &iter->seq;
948 trace_assign_type(field, iter->ent);
950 for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
951 if (!field->caller[i])
954 if (!trace_seq_puts(s, " <= "))
957 if (!seq_print_ip_sym(s, field->caller[i], flags))
960 if (!trace_seq_puts(s, "\n"))
964 return TRACE_TYPE_HANDLED;
967 return TRACE_TYPE_PARTIAL_LINE;
970 static struct trace_event trace_stack_event = {
972 .trace = trace_stack_print,
973 .raw = trace_special_print,
974 .hex = trace_special_hex,
975 .binary = trace_special_bin,
978 /* TRACE_USER_STACK */
979 static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
982 struct userstack_entry *field;
983 struct trace_seq *s = &iter->seq;
985 trace_assign_type(field, iter->ent);
987 if (!seq_print_userip_objs(field, s, flags))
990 if (!trace_seq_putc(s, '\n'))
993 return TRACE_TYPE_HANDLED;
996 return TRACE_TYPE_PARTIAL_LINE;
999 static struct trace_event trace_user_stack_event = {
1000 .type = TRACE_USER_STACK,
1001 .trace = trace_user_stack_print,
1002 .raw = trace_special_print,
1003 .hex = trace_special_hex,
1004 .binary = trace_special_bin,
1008 static enum print_line_t
1009 trace_bprint_print(struct trace_iterator *iter, int flags)
1011 struct trace_entry *entry = iter->ent;
1012 struct trace_seq *s = &iter->seq;
1013 struct bprint_entry *field;
1015 trace_assign_type(field, entry);
1017 if (!seq_print_ip_sym(s, field->ip, flags))
1020 if (!trace_seq_puts(s, ": "))
1023 if (!trace_seq_bprintf(s, field->fmt, field->buf))
1026 return TRACE_TYPE_HANDLED;
1029 return TRACE_TYPE_PARTIAL_LINE;
1033 static enum print_line_t
1034 trace_bprint_raw(struct trace_iterator *iter, int flags)
1036 struct bprint_entry *field;
1037 struct trace_seq *s = &iter->seq;
1039 trace_assign_type(field, iter->ent);
1041 if (!trace_seq_printf(s, ": %lx : ", field->ip))
1044 if (!trace_seq_bprintf(s, field->fmt, field->buf))
1047 return TRACE_TYPE_HANDLED;
1050 return TRACE_TYPE_PARTIAL_LINE;
1054 static struct trace_event trace_bprint_event = {
1055 .type = TRACE_BPRINT,
1056 .trace = trace_bprint_print,
1057 .raw = trace_bprint_raw,
1061 static enum print_line_t trace_print_print(struct trace_iterator *iter,
1064 struct print_entry *field;
1065 struct trace_seq *s = &iter->seq;
1067 trace_assign_type(field, iter->ent);
1069 if (!seq_print_ip_sym(s, field->ip, flags))
1072 if (!trace_seq_printf(s, ": %s", field->buf))
1075 return TRACE_TYPE_HANDLED;
1078 return TRACE_TYPE_PARTIAL_LINE;
1081 static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags)
1083 struct print_entry *field;
1085 trace_assign_type(field, iter->ent);
1087 if (!trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf))
1090 return TRACE_TYPE_HANDLED;
1093 return TRACE_TYPE_PARTIAL_LINE;
1096 static struct trace_event trace_print_event = {
1097 .type = TRACE_PRINT,
1098 .trace = trace_print_print,
1099 .raw = trace_print_raw,
1103 static struct trace_event *events[] __initdata = {
1107 &trace_special_event,
1109 &trace_user_stack_event,
1110 &trace_bprint_event,
1115 __init static int init_events(void)
1117 struct trace_event *event;
1120 for (i = 0; events[i]; i++) {
1123 ret = register_ftrace_event(event);
1125 printk(KERN_WARNING "event %d failed to register\n",
1133 device_initcall(init_events);