Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 1 | /* |
| 2 | * trace_output.c |
| 3 | * |
| 4 | * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/mutex.h> |
| 10 | #include <linux/ftrace.h> |
| 11 | |
| 12 | #include "trace_output.h" |
| 13 | |
| 14 | /* must be a power of 2 */ |
| 15 | #define EVENT_HASHSIZE 128 |
| 16 | |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 17 | static DECLARE_RWSEM(trace_event_mutex); |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 18 | |
| 19 | DEFINE_PER_CPU(struct trace_seq, ftrace_event_seq); |
Steven Whitehouse | ec081dd | 2009-06-01 15:53:35 +0100 | [diff] [blame] | 20 | EXPORT_PER_CPU_SYMBOL(ftrace_event_seq); |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 21 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 22 | static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly; |
| 23 | |
| 24 | static int next_event_type = __TRACE_LAST_TYPE + 1; |
| 25 | |
Steven Rostedt | 0706f1c | 2009-03-23 23:12:58 -0400 | [diff] [blame] | 26 | void trace_print_seq(struct seq_file *m, struct trace_seq *s) |
| 27 | { |
| 28 | int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len; |
| 29 | |
| 30 | s->buffer[len] = 0; |
| 31 | seq_puts(m, s->buffer); |
| 32 | |
| 33 | trace_seq_init(s); |
| 34 | } |
| 35 | |
Steven Rostedt | 5ef841f | 2009-03-19 12:20:38 -0400 | [diff] [blame] | 36 | enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter) |
| 37 | { |
| 38 | struct trace_seq *s = &iter->seq; |
| 39 | struct trace_entry *entry = iter->ent; |
| 40 | struct bprint_entry *field; |
| 41 | int ret; |
| 42 | |
| 43 | trace_assign_type(field, entry); |
| 44 | |
| 45 | ret = trace_seq_bprintf(s, field->fmt, field->buf); |
| 46 | if (!ret) |
| 47 | return TRACE_TYPE_PARTIAL_LINE; |
| 48 | |
| 49 | return TRACE_TYPE_HANDLED; |
| 50 | } |
| 51 | |
| 52 | enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter) |
| 53 | { |
| 54 | struct trace_seq *s = &iter->seq; |
| 55 | struct trace_entry *entry = iter->ent; |
| 56 | struct print_entry *field; |
| 57 | int ret; |
| 58 | |
| 59 | trace_assign_type(field, entry); |
| 60 | |
| 61 | ret = trace_seq_printf(s, "%s", field->buf); |
| 62 | if (!ret) |
| 63 | return TRACE_TYPE_PARTIAL_LINE; |
| 64 | |
| 65 | return TRACE_TYPE_HANDLED; |
| 66 | } |
| 67 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 68 | /** |
| 69 | * trace_seq_printf - sequence printing of trace information |
| 70 | * @s: trace sequence descriptor |
| 71 | * @fmt: printf format string |
| 72 | * |
| 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. |
| 78 | */ |
| 79 | int |
| 80 | trace_seq_printf(struct trace_seq *s, const char *fmt, ...) |
| 81 | { |
| 82 | int len = (PAGE_SIZE - 1) - s->len; |
| 83 | va_list ap; |
| 84 | int ret; |
| 85 | |
| 86 | if (!len) |
| 87 | return 0; |
| 88 | |
| 89 | va_start(ap, fmt); |
| 90 | ret = vsnprintf(s->buffer + s->len, len, fmt, ap); |
| 91 | va_end(ap); |
| 92 | |
| 93 | /* If we can't write it all, don't bother writing anything */ |
| 94 | if (ret >= len) |
| 95 | return 0; |
| 96 | |
| 97 | s->len += ret; |
| 98 | |
| 99 | return len; |
| 100 | } |
Steven Rostedt | 17c873e | 2009-04-10 18:12:50 -0400 | [diff] [blame] | 101 | EXPORT_SYMBOL_GPL(trace_seq_printf); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 102 | |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 103 | int trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 104 | { |
| 105 | int len = (PAGE_SIZE - 1) - s->len; |
| 106 | int ret; |
| 107 | |
| 108 | if (!len) |
| 109 | return 0; |
| 110 | |
| 111 | ret = bstr_printf(s->buffer + s->len, len, fmt, binary); |
| 112 | |
| 113 | /* If we can't write it all, don't bother writing anything */ |
| 114 | if (ret >= len) |
| 115 | return 0; |
| 116 | |
| 117 | s->len += ret; |
| 118 | |
| 119 | return len; |
| 120 | } |
| 121 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 122 | /** |
| 123 | * trace_seq_puts - trace sequence printing of simple string |
| 124 | * @s: trace sequence descriptor |
| 125 | * @str: simple string to record |
| 126 | * |
| 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. |
| 131 | */ |
| 132 | int trace_seq_puts(struct trace_seq *s, const char *str) |
| 133 | { |
| 134 | int len = strlen(str); |
| 135 | |
| 136 | if (len > ((PAGE_SIZE - 1) - s->len)) |
| 137 | return 0; |
| 138 | |
| 139 | memcpy(s->buffer + s->len, str, len); |
| 140 | s->len += len; |
| 141 | |
| 142 | return len; |
| 143 | } |
| 144 | |
| 145 | int trace_seq_putc(struct trace_seq *s, unsigned char c) |
| 146 | { |
| 147 | if (s->len >= (PAGE_SIZE - 1)) |
| 148 | return 0; |
| 149 | |
| 150 | s->buffer[s->len++] = c; |
| 151 | |
| 152 | return 1; |
| 153 | } |
| 154 | |
Li Zefan | b14b70a | 2009-03-27 10:21:00 +0800 | [diff] [blame] | 155 | int trace_seq_putmem(struct trace_seq *s, const void *mem, size_t len) |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 156 | { |
| 157 | if (len > ((PAGE_SIZE - 1) - s->len)) |
| 158 | return 0; |
| 159 | |
| 160 | memcpy(s->buffer + s->len, mem, len); |
| 161 | s->len += len; |
| 162 | |
| 163 | return len; |
| 164 | } |
| 165 | |
Li Zefan | b14b70a | 2009-03-27 10:21:00 +0800 | [diff] [blame] | 166 | int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, size_t len) |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 167 | { |
| 168 | unsigned char hex[HEX_CHARS]; |
Li Zefan | b14b70a | 2009-03-27 10:21:00 +0800 | [diff] [blame] | 169 | const unsigned char *data = mem; |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 170 | int i, j; |
| 171 | |
| 172 | #ifdef __BIG_ENDIAN |
| 173 | for (i = 0, j = 0; i < len; i++) { |
| 174 | #else |
| 175 | for (i = len-1, j = 0; i >= 0; i--) { |
| 176 | #endif |
| 177 | hex[j++] = hex_asc_hi(data[i]); |
| 178 | hex[j++] = hex_asc_lo(data[i]); |
| 179 | } |
| 180 | hex[j++] = ' '; |
| 181 | |
| 182 | return trace_seq_putmem(s, hex, j); |
| 183 | } |
| 184 | |
Eduard - Gabriel Munteanu | bdd6df6 | 2009-03-23 15:12:22 +0200 | [diff] [blame] | 185 | void *trace_seq_reserve(struct trace_seq *s, size_t len) |
| 186 | { |
| 187 | void *ret; |
| 188 | |
| 189 | if (len > ((PAGE_SIZE - 1) - s->len)) |
| 190 | return NULL; |
| 191 | |
| 192 | ret = s->buffer + s->len; |
| 193 | s->len += len; |
| 194 | |
| 195 | return ret; |
| 196 | } |
| 197 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 198 | int trace_seq_path(struct trace_seq *s, struct path *path) |
| 199 | { |
| 200 | unsigned char *p; |
| 201 | |
| 202 | if (s->len >= (PAGE_SIZE - 1)) |
| 203 | return 0; |
| 204 | p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len); |
| 205 | if (!IS_ERR(p)) { |
| 206 | p = mangle_path(s->buffer + s->len, p, "\n"); |
| 207 | if (p) { |
| 208 | s->len = p - s->buffer; |
| 209 | return 1; |
| 210 | } |
| 211 | } else { |
| 212 | s->buffer[s->len++] = '?'; |
| 213 | return 1; |
| 214 | } |
| 215 | |
| 216 | return 0; |
| 217 | } |
| 218 | |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 219 | const char * |
| 220 | ftrace_print_flags_seq(struct trace_seq *p, const char *delim, |
| 221 | unsigned long flags, |
| 222 | const struct trace_print_flags *flag_array) |
| 223 | { |
| 224 | unsigned long mask; |
| 225 | const char *str; |
| 226 | int i; |
| 227 | |
| 228 | trace_seq_init(p); |
| 229 | |
| 230 | for (i = 0; flag_array[i].name && flags; i++) { |
| 231 | |
| 232 | mask = flag_array[i].mask; |
| 233 | if ((flags & mask) != mask) |
| 234 | continue; |
| 235 | |
| 236 | str = flag_array[i].name; |
| 237 | flags &= ~mask; |
| 238 | if (p->len && delim) |
| 239 | trace_seq_puts(p, delim); |
| 240 | trace_seq_puts(p, str); |
| 241 | } |
| 242 | |
| 243 | /* check for left over flags */ |
| 244 | if (flags) { |
| 245 | if (p->len && delim) |
| 246 | trace_seq_puts(p, delim); |
| 247 | trace_seq_printf(p, "0x%lx", flags); |
| 248 | } |
| 249 | |
| 250 | trace_seq_putc(p, 0); |
| 251 | |
| 252 | return p->buffer; |
| 253 | } |
Steven Whitehouse | ec081dd | 2009-06-01 15:53:35 +0100 | [diff] [blame] | 254 | EXPORT_SYMBOL(ftrace_print_flags_seq); |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 255 | |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 256 | const char * |
| 257 | ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val, |
| 258 | const struct trace_print_flags *symbol_array) |
| 259 | { |
| 260 | int i; |
| 261 | |
| 262 | trace_seq_init(p); |
| 263 | |
| 264 | for (i = 0; symbol_array[i].name; i++) { |
| 265 | |
| 266 | if (val != symbol_array[i].mask) |
| 267 | continue; |
| 268 | |
| 269 | trace_seq_puts(p, symbol_array[i].name); |
| 270 | break; |
| 271 | } |
| 272 | |
| 273 | if (!p->len) |
| 274 | trace_seq_printf(p, "0x%lx", val); |
| 275 | |
| 276 | trace_seq_putc(p, 0); |
| 277 | |
| 278 | return p->buffer; |
| 279 | } |
Steven Whitehouse | ec081dd | 2009-06-01 15:53:35 +0100 | [diff] [blame] | 280 | EXPORT_SYMBOL(ftrace_print_symbols_seq); |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 281 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 282 | #ifdef CONFIG_KRETPROBES |
| 283 | static inline const char *kretprobed(const char *name) |
| 284 | { |
| 285 | static const char tramp_name[] = "kretprobe_trampoline"; |
| 286 | int size = sizeof(tramp_name); |
| 287 | |
| 288 | if (strncmp(tramp_name, name, size) == 0) |
| 289 | return "[unknown/kretprobe'd]"; |
| 290 | return name; |
| 291 | } |
| 292 | #else |
| 293 | static inline const char *kretprobed(const char *name) |
| 294 | { |
| 295 | return name; |
| 296 | } |
| 297 | #endif /* CONFIG_KRETPROBES */ |
| 298 | |
| 299 | static int |
| 300 | seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address) |
| 301 | { |
| 302 | #ifdef CONFIG_KALLSYMS |
| 303 | char str[KSYM_SYMBOL_LEN]; |
| 304 | const char *name; |
| 305 | |
| 306 | kallsyms_lookup(address, NULL, NULL, NULL, str); |
| 307 | |
| 308 | name = kretprobed(str); |
| 309 | |
| 310 | return trace_seq_printf(s, fmt, name); |
| 311 | #endif |
| 312 | return 1; |
| 313 | } |
| 314 | |
| 315 | static int |
| 316 | seq_print_sym_offset(struct trace_seq *s, const char *fmt, |
| 317 | unsigned long address) |
| 318 | { |
| 319 | #ifdef CONFIG_KALLSYMS |
| 320 | char str[KSYM_SYMBOL_LEN]; |
| 321 | const char *name; |
| 322 | |
| 323 | sprint_symbol(str, address); |
| 324 | name = kretprobed(str); |
| 325 | |
| 326 | return trace_seq_printf(s, fmt, name); |
| 327 | #endif |
| 328 | return 1; |
| 329 | } |
| 330 | |
| 331 | #ifndef CONFIG_64BIT |
| 332 | # define IP_FMT "%08lx" |
| 333 | #else |
| 334 | # define IP_FMT "%016lx" |
| 335 | #endif |
| 336 | |
| 337 | int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm, |
| 338 | unsigned long ip, unsigned long sym_flags) |
| 339 | { |
| 340 | struct file *file = NULL; |
| 341 | unsigned long vmstart = 0; |
| 342 | int ret = 1; |
| 343 | |
| 344 | if (mm) { |
| 345 | const struct vm_area_struct *vma; |
| 346 | |
| 347 | down_read(&mm->mmap_sem); |
| 348 | vma = find_vma(mm, ip); |
| 349 | if (vma) { |
| 350 | file = vma->vm_file; |
| 351 | vmstart = vma->vm_start; |
| 352 | } |
| 353 | if (file) { |
| 354 | ret = trace_seq_path(s, &file->f_path); |
| 355 | if (ret) |
| 356 | ret = trace_seq_printf(s, "[+0x%lx]", |
| 357 | ip - vmstart); |
| 358 | } |
| 359 | up_read(&mm->mmap_sem); |
| 360 | } |
| 361 | if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file)) |
| 362 | ret = trace_seq_printf(s, " <" IP_FMT ">", ip); |
| 363 | return ret; |
| 364 | } |
| 365 | |
| 366 | int |
| 367 | seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s, |
| 368 | unsigned long sym_flags) |
| 369 | { |
| 370 | struct mm_struct *mm = NULL; |
| 371 | int ret = 1; |
| 372 | unsigned int i; |
| 373 | |
| 374 | if (trace_flags & TRACE_ITER_SYM_USEROBJ) { |
| 375 | struct task_struct *task; |
| 376 | /* |
| 377 | * we do the lookup on the thread group leader, |
| 378 | * since individual threads might have already quit! |
| 379 | */ |
| 380 | rcu_read_lock(); |
| 381 | task = find_task_by_vpid(entry->ent.tgid); |
| 382 | if (task) |
| 383 | mm = get_task_mm(task); |
| 384 | rcu_read_unlock(); |
| 385 | } |
| 386 | |
| 387 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { |
| 388 | unsigned long ip = entry->caller[i]; |
| 389 | |
| 390 | if (ip == ULONG_MAX || !ret) |
| 391 | break; |
walimis | 048dc50 | 2009-06-03 16:01:30 +0800 | [diff] [blame^] | 392 | if (ret) |
| 393 | ret = trace_seq_puts(s, " => "); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 394 | if (!ip) { |
| 395 | if (ret) |
| 396 | ret = trace_seq_puts(s, "??"); |
walimis | 048dc50 | 2009-06-03 16:01:30 +0800 | [diff] [blame^] | 397 | if (ret) |
| 398 | ret = trace_seq_puts(s, "\n"); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 399 | continue; |
| 400 | } |
| 401 | if (!ret) |
| 402 | break; |
| 403 | if (ret) |
| 404 | ret = seq_print_user_ip(s, mm, ip, sym_flags); |
walimis | 048dc50 | 2009-06-03 16:01:30 +0800 | [diff] [blame^] | 405 | ret = trace_seq_puts(s, "\n"); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | if (mm) |
| 409 | mmput(mm); |
| 410 | return ret; |
| 411 | } |
| 412 | |
| 413 | int |
| 414 | seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags) |
| 415 | { |
| 416 | int ret; |
| 417 | |
| 418 | if (!ip) |
| 419 | return trace_seq_printf(s, "0"); |
| 420 | |
| 421 | if (sym_flags & TRACE_ITER_SYM_OFFSET) |
| 422 | ret = seq_print_sym_offset(s, "%s", ip); |
| 423 | else |
| 424 | ret = seq_print_sym_short(s, "%s", ip); |
| 425 | |
| 426 | if (!ret) |
| 427 | return 0; |
| 428 | |
| 429 | if (sym_flags & TRACE_ITER_SYM_ADDR) |
| 430 | ret = trace_seq_printf(s, " <" IP_FMT ">", ip); |
| 431 | return ret; |
| 432 | } |
| 433 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 434 | static int |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 435 | lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu) |
| 436 | { |
| 437 | int hardirq, softirq; |
Steven Rostedt | 4ca5308 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 438 | char comm[TASK_COMM_LEN]; |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 439 | |
Steven Rostedt | 4ca5308 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 440 | trace_find_cmdline(entry->pid, comm); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 441 | hardirq = entry->flags & TRACE_FLAG_HARDIRQ; |
| 442 | softirq = entry->flags & TRACE_FLAG_SOFTIRQ; |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 443 | |
| 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) ? |
| 448 | 'X' : '.', |
| 449 | (entry->flags & TRACE_FLAG_NEED_RESCHED) ? |
| 450 | 'N' : '.', |
| 451 | (hardirq && softirq) ? 'H' : |
| 452 | hardirq ? 'h' : softirq ? 's' : '.')) |
| 453 | return 0; |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 454 | |
| 455 | if (entry->preempt_count) |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 456 | return trace_seq_printf(s, "%x", entry->preempt_count); |
| 457 | return trace_seq_puts(s, "."); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | static unsigned long preempt_mark_thresh = 100; |
| 461 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 462 | static int |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 463 | lat_print_timestamp(struct trace_seq *s, u64 abs_usecs, |
| 464 | unsigned long rel_usecs) |
| 465 | { |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 466 | return trace_seq_printf(s, " %4lldus%c: ", abs_usecs, |
| 467 | rel_usecs > preempt_mark_thresh ? '!' : |
| 468 | rel_usecs > 1 ? '+' : ' '); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | int trace_print_context(struct trace_iterator *iter) |
| 472 | { |
| 473 | struct trace_seq *s = &iter->seq; |
| 474 | struct trace_entry *entry = iter->ent; |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 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; |
Steven Rostedt | 4ca5308 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 478 | char comm[TASK_COMM_LEN]; |
| 479 | |
| 480 | trace_find_cmdline(entry->pid, comm); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 481 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 482 | return trace_seq_printf(s, "%16s-%-5d [%03d] %5lu.%06lu: ", |
Steven Rostedt | 1830b52 | 2009-02-07 19:38:43 -0500 | [diff] [blame] | 483 | comm, entry->pid, iter->cpu, secs, usec_rem); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | int trace_print_lat_context(struct trace_iterator *iter) |
| 487 | { |
| 488 | u64 next_ts; |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 489 | int ret; |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 490 | struct trace_seq *s = &iter->seq; |
| 491 | struct trace_entry *entry = iter->ent, |
| 492 | *next_entry = trace_find_next_entry(iter, NULL, |
| 493 | &next_ts); |
| 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; |
| 497 | |
| 498 | if (!next_entry) |
| 499 | next_ts = iter->ts; |
| 500 | rel_usecs = ns2usecs(next_ts - iter->ts); |
| 501 | |
| 502 | if (verbose) { |
Steven Rostedt | 4ca5308 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 503 | char comm[TASK_COMM_LEN]; |
| 504 | |
| 505 | trace_find_cmdline(entry->pid, comm); |
| 506 | |
Lai Jiangshan | cf8e347 | 2009-03-30 13:48:00 +0800 | [diff] [blame] | 507 | ret = trace_seq_printf(s, "%16s %5d %3d %d %08x %08lx [%08llx]" |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 508 | " %ld.%03ldms (+%ld.%03ldms): ", comm, |
Steven Rostedt | 1830b52 | 2009-02-07 19:38:43 -0500 | [diff] [blame] | 509 | entry->pid, iter->cpu, entry->flags, |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 510 | entry->preempt_count, iter->idx, |
| 511 | ns2usecs(iter->ts), |
| 512 | abs_usecs / USEC_PER_MSEC, |
| 513 | abs_usecs % USEC_PER_MSEC, |
| 514 | rel_usecs / USEC_PER_MSEC, |
| 515 | rel_usecs % USEC_PER_MSEC); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 516 | } else { |
Steven Rostedt | 1830b52 | 2009-02-07 19:38:43 -0500 | [diff] [blame] | 517 | ret = lat_print_generic(s, entry, iter->cpu); |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 518 | if (ret) |
| 519 | ret = lat_print_timestamp(s, abs_usecs, rel_usecs); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 520 | } |
| 521 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 522 | return ret; |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 523 | } |
| 524 | |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 525 | static const char state_to_char[] = TASK_STATE_TO_CHAR_STR; |
| 526 | |
| 527 | static int task_state_char(unsigned long state) |
| 528 | { |
| 529 | int bit = state ? __ffs(state) + 1 : 0; |
| 530 | |
| 531 | return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?'; |
| 532 | } |
| 533 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 534 | /** |
| 535 | * ftrace_find_event - find a registered event |
| 536 | * @type: the type of event to look for |
| 537 | * |
| 538 | * Returns an event of type @type otherwise NULL |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 539 | * Called with trace_event_read_lock() held. |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 540 | */ |
| 541 | struct trace_event *ftrace_find_event(int type) |
| 542 | { |
| 543 | struct trace_event *event; |
| 544 | struct hlist_node *n; |
| 545 | unsigned key; |
| 546 | |
| 547 | key = type & (EVENT_HASHSIZE - 1); |
| 548 | |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 549 | hlist_for_each_entry(event, n, &event_hash[key], node) { |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 550 | if (event->type == type) |
| 551 | return event; |
| 552 | } |
| 553 | |
| 554 | return NULL; |
| 555 | } |
| 556 | |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 557 | static LIST_HEAD(ftrace_event_list); |
| 558 | |
| 559 | static int trace_search_list(struct list_head **list) |
| 560 | { |
| 561 | struct trace_event *e; |
| 562 | int last = __TRACE_LAST_TYPE; |
| 563 | |
| 564 | if (list_empty(&ftrace_event_list)) { |
| 565 | *list = &ftrace_event_list; |
| 566 | return last + 1; |
| 567 | } |
| 568 | |
| 569 | /* |
| 570 | * We used up all possible max events, |
| 571 | * lets see if somebody freed one. |
| 572 | */ |
| 573 | list_for_each_entry(e, &ftrace_event_list, list) { |
| 574 | if (e->type != last + 1) |
| 575 | break; |
| 576 | last++; |
| 577 | } |
| 578 | |
| 579 | /* Did we used up all 65 thousand events??? */ |
| 580 | if ((last + 1) > FTRACE_MAX_EVENT) |
| 581 | return 0; |
| 582 | |
| 583 | *list = &e->list; |
| 584 | return last + 1; |
| 585 | } |
| 586 | |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 587 | void trace_event_read_lock(void) |
| 588 | { |
| 589 | down_read(&trace_event_mutex); |
| 590 | } |
| 591 | |
| 592 | void trace_event_read_unlock(void) |
| 593 | { |
| 594 | up_read(&trace_event_mutex); |
| 595 | } |
| 596 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 597 | /** |
| 598 | * register_ftrace_event - register output for an event type |
| 599 | * @event: the event type to register |
| 600 | * |
| 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 |
| 604 | * type to use. |
| 605 | * |
| 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. |
| 609 | * |
| 610 | * Returns the event type number or zero on error. |
| 611 | */ |
| 612 | int register_ftrace_event(struct trace_event *event) |
| 613 | { |
| 614 | unsigned key; |
| 615 | int ret = 0; |
| 616 | |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 617 | down_write(&trace_event_mutex); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 618 | |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 619 | if (WARN_ON(!event)) |
Peter Zijlstra | 28bea27 | 2009-03-19 20:26:14 +0100 | [diff] [blame] | 620 | goto out; |
Peter Zijlstra | 28bea27 | 2009-03-19 20:26:14 +0100 | [diff] [blame] | 621 | |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 622 | INIT_LIST_HEAD(&event->list); |
| 623 | |
| 624 | if (!event->type) { |
Jaswinder Singh Rajput | 48dd0fe | 2009-05-06 15:45:45 +0530 | [diff] [blame] | 625 | struct list_head *list = NULL; |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 626 | |
| 627 | if (next_event_type > FTRACE_MAX_EVENT) { |
| 628 | |
| 629 | event->type = trace_search_list(&list); |
| 630 | if (!event->type) |
| 631 | goto out; |
| 632 | |
| 633 | } else { |
| 634 | |
| 635 | event->type = next_event_type++; |
| 636 | list = &ftrace_event_list; |
| 637 | } |
| 638 | |
| 639 | if (WARN_ON(ftrace_find_event(event->type))) |
| 640 | goto out; |
| 641 | |
| 642 | list_add_tail(&event->list, list); |
| 643 | |
| 644 | } else if (event->type > __TRACE_LAST_TYPE) { |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 645 | printk(KERN_WARNING "Need to add type to trace.h\n"); |
| 646 | WARN_ON(1); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 647 | goto out; |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 648 | } else { |
| 649 | /* Is this event already used */ |
| 650 | if (ftrace_find_event(event->type)) |
| 651 | goto out; |
| 652 | } |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 653 | |
Arnaldo Carvalho de Melo | 268ccda | 2009-02-04 20:16:39 -0200 | [diff] [blame] | 654 | if (event->trace == NULL) |
| 655 | event->trace = trace_nop_print; |
Arnaldo Carvalho de Melo | 268ccda | 2009-02-04 20:16:39 -0200 | [diff] [blame] | 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; |
| 662 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 663 | key = event->type & (EVENT_HASHSIZE - 1); |
| 664 | |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 665 | hlist_add_head(&event->node, &event_hash[key]); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 666 | |
| 667 | ret = event->type; |
| 668 | out: |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 669 | up_write(&trace_event_mutex); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 670 | |
| 671 | return ret; |
| 672 | } |
Steven Rostedt | 17c873e | 2009-04-10 18:12:50 -0400 | [diff] [blame] | 673 | EXPORT_SYMBOL_GPL(register_ftrace_event); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 674 | |
| 675 | /** |
| 676 | * unregister_ftrace_event - remove a no longer used event |
| 677 | * @event: the event to remove |
| 678 | */ |
| 679 | int unregister_ftrace_event(struct trace_event *event) |
| 680 | { |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 681 | down_write(&trace_event_mutex); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 682 | hlist_del(&event->node); |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 683 | list_del(&event->list); |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 684 | up_write(&trace_event_mutex); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 685 | |
| 686 | return 0; |
| 687 | } |
Steven Rostedt | 17c873e | 2009-04-10 18:12:50 -0400 | [diff] [blame] | 688 | EXPORT_SYMBOL_GPL(unregister_ftrace_event); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 689 | |
| 690 | /* |
| 691 | * Standard events |
| 692 | */ |
| 693 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 694 | enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 695 | { |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 696 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | /* TRACE_FN */ |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 700 | static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 701 | { |
| 702 | struct ftrace_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 703 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 704 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 705 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 706 | |
| 707 | if (!seq_print_ip_sym(s, field->ip, flags)) |
| 708 | goto partial; |
| 709 | |
| 710 | if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) { |
| 711 | if (!trace_seq_printf(s, " <-")) |
| 712 | goto partial; |
| 713 | if (!seq_print_ip_sym(s, |
| 714 | field->parent_ip, |
| 715 | flags)) |
| 716 | goto partial; |
| 717 | } |
| 718 | if (!trace_seq_printf(s, "\n")) |
| 719 | goto partial; |
| 720 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 721 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 722 | |
| 723 | partial: |
| 724 | return TRACE_TYPE_PARTIAL_LINE; |
| 725 | } |
| 726 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 727 | static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 728 | { |
| 729 | struct ftrace_entry *field; |
| 730 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 731 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 732 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 733 | if (!trace_seq_printf(&iter->seq, "%lx %lx\n", |
Lai Jiangshan | 6c1a99a | 2009-01-15 18:05:40 +0800 | [diff] [blame] | 734 | field->ip, |
| 735 | field->parent_ip)) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 736 | return TRACE_TYPE_PARTIAL_LINE; |
| 737 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 738 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 739 | } |
| 740 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 741 | static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 742 | { |
| 743 | struct ftrace_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 744 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 745 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 746 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 747 | |
| 748 | SEQ_PUT_HEX_FIELD_RET(s, field->ip); |
| 749 | SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip); |
| 750 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 751 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 752 | } |
| 753 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 754 | static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 755 | { |
| 756 | struct ftrace_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 757 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 758 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 759 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 760 | |
| 761 | SEQ_PUT_FIELD_RET(s, field->ip); |
| 762 | SEQ_PUT_FIELD_RET(s, field->parent_ip); |
| 763 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 764 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | static struct trace_event trace_fn_event = { |
Steven Rostedt | ef18012 | 2009-03-10 14:10:56 -0400 | [diff] [blame] | 768 | .type = TRACE_FN, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 769 | .trace = trace_fn_trace, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 770 | .raw = trace_fn_raw, |
| 771 | .hex = trace_fn_hex, |
| 772 | .binary = trace_fn_bin, |
| 773 | }; |
| 774 | |
| 775 | /* TRACE_CTX an TRACE_WAKE */ |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 776 | static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter, |
| 777 | char *delim) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 778 | { |
| 779 | struct ctx_switch_entry *field; |
Steven Rostedt | 4ca5308 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 780 | char comm[TASK_COMM_LEN]; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 781 | int S, T; |
| 782 | |
Steven Rostedt | 4ca5308 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 783 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 784 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 785 | |
| 786 | T = task_state_char(field->next_state); |
| 787 | S = task_state_char(field->prev_state); |
Steven Rostedt | 4ca5308 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 788 | trace_find_cmdline(field->next_pid, comm); |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 789 | if (!trace_seq_printf(&iter->seq, |
| 790 | " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n", |
Lai Jiangshan | 6c1a99a | 2009-01-15 18:05:40 +0800 | [diff] [blame] | 791 | field->prev_pid, |
| 792 | field->prev_prio, |
| 793 | S, delim, |
| 794 | field->next_cpu, |
| 795 | field->next_pid, |
| 796 | field->next_prio, |
| 797 | T, comm)) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 798 | return TRACE_TYPE_PARTIAL_LINE; |
| 799 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 800 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 801 | } |
| 802 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 803 | static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 804 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 805 | return trace_ctxwake_print(iter, "==>"); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 806 | } |
| 807 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 808 | static enum print_line_t trace_wake_print(struct trace_iterator *iter, |
| 809 | int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 810 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 811 | return trace_ctxwake_print(iter, " +"); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 812 | } |
| 813 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 814 | static int trace_ctxwake_raw(struct trace_iterator *iter, char S) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 815 | { |
| 816 | struct ctx_switch_entry *field; |
| 817 | int T; |
| 818 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 819 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 820 | |
| 821 | if (!S) |
| 822 | task_state_char(field->prev_state); |
| 823 | T = task_state_char(field->next_state); |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 824 | if (!trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n", |
Lai Jiangshan | 6c1a99a | 2009-01-15 18:05:40 +0800 | [diff] [blame] | 825 | field->prev_pid, |
| 826 | field->prev_prio, |
| 827 | S, |
| 828 | field->next_cpu, |
| 829 | field->next_pid, |
| 830 | field->next_prio, |
| 831 | T)) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 832 | return TRACE_TYPE_PARTIAL_LINE; |
| 833 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 834 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 835 | } |
| 836 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 837 | static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 838 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 839 | return trace_ctxwake_raw(iter, 0); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 840 | } |
| 841 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 842 | static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 843 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 844 | return trace_ctxwake_raw(iter, '+'); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 848 | static int trace_ctxwake_hex(struct trace_iterator *iter, char S) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 849 | { |
| 850 | struct ctx_switch_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 851 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 852 | int T; |
| 853 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 854 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 855 | |
| 856 | if (!S) |
| 857 | task_state_char(field->prev_state); |
| 858 | T = task_state_char(field->next_state); |
| 859 | |
| 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); |
| 867 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 868 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 869 | } |
| 870 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 871 | static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 872 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 873 | return trace_ctxwake_hex(iter, 0); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 874 | } |
| 875 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 876 | static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 877 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 878 | return trace_ctxwake_hex(iter, '+'); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 879 | } |
| 880 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 881 | static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter, |
| 882 | int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 883 | { |
| 884 | struct ctx_switch_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 885 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 886 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 887 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 888 | |
| 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); |
| 895 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 896 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | static struct trace_event trace_ctx_event = { |
Steven Rostedt | ef18012 | 2009-03-10 14:10:56 -0400 | [diff] [blame] | 900 | .type = TRACE_CTX, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 901 | .trace = trace_ctx_print, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 902 | .raw = trace_ctx_raw, |
| 903 | .hex = trace_ctx_hex, |
| 904 | .binary = trace_ctxwake_bin, |
| 905 | }; |
| 906 | |
| 907 | static struct trace_event trace_wake_event = { |
Steven Rostedt | ef18012 | 2009-03-10 14:10:56 -0400 | [diff] [blame] | 908 | .type = TRACE_WAKE, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 909 | .trace = trace_wake_print, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 910 | .raw = trace_wake_raw, |
| 911 | .hex = trace_wake_hex, |
| 912 | .binary = trace_ctxwake_bin, |
| 913 | }; |
| 914 | |
| 915 | /* TRACE_SPECIAL */ |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 916 | static enum print_line_t trace_special_print(struct trace_iterator *iter, |
| 917 | int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 918 | { |
| 919 | struct special_entry *field; |
| 920 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 921 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 922 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 923 | if (!trace_seq_printf(&iter->seq, "# %ld %ld %ld\n", |
Lai Jiangshan | 6c1a99a | 2009-01-15 18:05:40 +0800 | [diff] [blame] | 924 | field->arg1, |
| 925 | field->arg2, |
| 926 | field->arg3)) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 927 | return TRACE_TYPE_PARTIAL_LINE; |
| 928 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 929 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 930 | } |
| 931 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 932 | static enum print_line_t trace_special_hex(struct trace_iterator *iter, |
| 933 | int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 934 | { |
| 935 | struct special_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 936 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 937 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 938 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 939 | |
| 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); |
| 943 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 944 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 945 | } |
| 946 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 947 | static enum print_line_t trace_special_bin(struct trace_iterator *iter, |
| 948 | int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 949 | { |
| 950 | struct special_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 951 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 952 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 953 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 954 | |
| 955 | SEQ_PUT_FIELD_RET(s, field->arg1); |
| 956 | SEQ_PUT_FIELD_RET(s, field->arg2); |
| 957 | SEQ_PUT_FIELD_RET(s, field->arg3); |
| 958 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 959 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | static struct trace_event trace_special_event = { |
Steven Rostedt | ef18012 | 2009-03-10 14:10:56 -0400 | [diff] [blame] | 963 | .type = TRACE_SPECIAL, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 964 | .trace = trace_special_print, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 965 | .raw = trace_special_print, |
| 966 | .hex = trace_special_hex, |
| 967 | .binary = trace_special_bin, |
| 968 | }; |
| 969 | |
| 970 | /* TRACE_STACK */ |
| 971 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 972 | static enum print_line_t trace_stack_print(struct trace_iterator *iter, |
| 973 | int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 974 | { |
| 975 | struct stack_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 976 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 977 | int i; |
| 978 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 979 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 980 | |
walimis | f11b3f4 | 2009-06-03 16:01:29 +0800 | [diff] [blame] | 981 | if (!trace_seq_puts(s, "\n")) |
| 982 | goto partial; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 983 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { |
walimis | f11b3f4 | 2009-06-03 16:01:29 +0800 | [diff] [blame] | 984 | if (!field->caller[i] || (field->caller[i] == ULONG_MAX)) |
Steven Rostedt | 1ec7c48 | 2009-05-14 23:40:06 -0400 | [diff] [blame] | 985 | break; |
walimis | f11b3f4 | 2009-06-03 16:01:29 +0800 | [diff] [blame] | 986 | if (!trace_seq_puts(s, " => ")) |
| 987 | goto partial; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 988 | |
walimis | f11b3f4 | 2009-06-03 16:01:29 +0800 | [diff] [blame] | 989 | if (!seq_print_ip_sym(s, field->caller[i], flags)) |
| 990 | goto partial; |
Lai Jiangshan | 6c1a99a | 2009-01-15 18:05:40 +0800 | [diff] [blame] | 991 | if (!trace_seq_puts(s, "\n")) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 992 | goto partial; |
| 993 | } |
| 994 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 995 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 996 | |
| 997 | partial: |
| 998 | return TRACE_TYPE_PARTIAL_LINE; |
| 999 | } |
| 1000 | |
| 1001 | static struct trace_event trace_stack_event = { |
Steven Rostedt | ef18012 | 2009-03-10 14:10:56 -0400 | [diff] [blame] | 1002 | .type = TRACE_STACK, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1003 | .trace = trace_stack_print, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1004 | .raw = trace_special_print, |
| 1005 | .hex = trace_special_hex, |
| 1006 | .binary = trace_special_bin, |
| 1007 | }; |
| 1008 | |
| 1009 | /* TRACE_USER_STACK */ |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 1010 | static enum print_line_t trace_user_stack_print(struct trace_iterator *iter, |
| 1011 | int flags) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1012 | { |
| 1013 | struct userstack_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 1014 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1015 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 1016 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1017 | |
walimis | 048dc50 | 2009-06-03 16:01:30 +0800 | [diff] [blame^] | 1018 | if (!trace_seq_putc(s, '\n')) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1019 | goto partial; |
| 1020 | |
walimis | 048dc50 | 2009-06-03 16:01:30 +0800 | [diff] [blame^] | 1021 | if (!seq_print_userip_objs(field, s, flags)) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1022 | goto partial; |
| 1023 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 1024 | return TRACE_TYPE_HANDLED; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1025 | |
| 1026 | partial: |
| 1027 | return TRACE_TYPE_PARTIAL_LINE; |
| 1028 | } |
| 1029 | |
| 1030 | static struct trace_event trace_user_stack_event = { |
Steven Rostedt | ef18012 | 2009-03-10 14:10:56 -0400 | [diff] [blame] | 1031 | .type = TRACE_USER_STACK, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1032 | .trace = trace_user_stack_print, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1033 | .raw = trace_special_print, |
| 1034 | .hex = trace_special_hex, |
| 1035 | .binary = trace_special_bin, |
| 1036 | }; |
| 1037 | |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1038 | /* TRACE_BPRINT */ |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1039 | static enum print_line_t |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1040 | trace_bprint_print(struct trace_iterator *iter, int flags) |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1041 | { |
| 1042 | struct trace_entry *entry = iter->ent; |
| 1043 | struct trace_seq *s = &iter->seq; |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1044 | struct bprint_entry *field; |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1045 | |
| 1046 | trace_assign_type(field, entry); |
| 1047 | |
| 1048 | if (!seq_print_ip_sym(s, field->ip, flags)) |
| 1049 | goto partial; |
| 1050 | |
| 1051 | if (!trace_seq_puts(s, ": ")) |
| 1052 | goto partial; |
| 1053 | |
| 1054 | if (!trace_seq_bprintf(s, field->fmt, field->buf)) |
| 1055 | goto partial; |
| 1056 | |
| 1057 | return TRACE_TYPE_HANDLED; |
| 1058 | |
| 1059 | partial: |
| 1060 | return TRACE_TYPE_PARTIAL_LINE; |
| 1061 | } |
| 1062 | |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1063 | |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1064 | static enum print_line_t |
| 1065 | trace_bprint_raw(struct trace_iterator *iter, int flags) |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 1066 | { |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1067 | struct bprint_entry *field; |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 1068 | struct trace_seq *s = &iter->seq; |
| 1069 | |
| 1070 | trace_assign_type(field, iter->ent); |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1071 | |
| 1072 | if (!trace_seq_printf(s, ": %lx : ", field->ip)) |
| 1073 | goto partial; |
| 1074 | |
| 1075 | if (!trace_seq_bprintf(s, field->fmt, field->buf)) |
| 1076 | goto partial; |
| 1077 | |
| 1078 | return TRACE_TYPE_HANDLED; |
| 1079 | |
| 1080 | partial: |
| 1081 | return TRACE_TYPE_PARTIAL_LINE; |
| 1082 | } |
| 1083 | |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 1084 | |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1085 | static struct trace_event trace_bprint_event = { |
| 1086 | .type = TRACE_BPRINT, |
| 1087 | .trace = trace_bprint_print, |
| 1088 | .raw = trace_bprint_raw, |
| 1089 | }; |
| 1090 | |
| 1091 | /* TRACE_PRINT */ |
| 1092 | static enum print_line_t trace_print_print(struct trace_iterator *iter, |
| 1093 | int flags) |
| 1094 | { |
| 1095 | struct print_entry *field; |
| 1096 | struct trace_seq *s = &iter->seq; |
| 1097 | |
| 1098 | trace_assign_type(field, iter->ent); |
| 1099 | |
| 1100 | if (!seq_print_ip_sym(s, field->ip, flags)) |
| 1101 | goto partial; |
| 1102 | |
| 1103 | if (!trace_seq_printf(s, ": %s", field->buf)) |
| 1104 | goto partial; |
| 1105 | |
| 1106 | return TRACE_TYPE_HANDLED; |
| 1107 | |
| 1108 | partial: |
| 1109 | return TRACE_TYPE_PARTIAL_LINE; |
| 1110 | } |
| 1111 | |
| 1112 | static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags) |
| 1113 | { |
| 1114 | struct print_entry *field; |
| 1115 | |
| 1116 | trace_assign_type(field, iter->ent); |
| 1117 | |
| 1118 | if (!trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf)) |
| 1119 | goto partial; |
| 1120 | |
| 1121 | return TRACE_TYPE_HANDLED; |
| 1122 | |
| 1123 | partial: |
| 1124 | return TRACE_TYPE_PARTIAL_LINE; |
| 1125 | } |
| 1126 | |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 1127 | static struct trace_event trace_print_event = { |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1128 | .type = TRACE_PRINT, |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 1129 | .trace = trace_print_print, |
| 1130 | .raw = trace_print_raw, |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1131 | }; |
| 1132 | |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1133 | |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1134 | static struct trace_event *events[] __initdata = { |
| 1135 | &trace_fn_event, |
| 1136 | &trace_ctx_event, |
| 1137 | &trace_wake_event, |
| 1138 | &trace_special_event, |
| 1139 | &trace_stack_event, |
| 1140 | &trace_user_stack_event, |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1141 | &trace_bprint_event, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1142 | &trace_print_event, |
| 1143 | NULL |
| 1144 | }; |
| 1145 | |
| 1146 | __init static int init_events(void) |
| 1147 | { |
| 1148 | struct trace_event *event; |
| 1149 | int i, ret; |
| 1150 | |
| 1151 | for (i = 0; events[i]; i++) { |
| 1152 | event = events[i]; |
| 1153 | |
| 1154 | ret = register_ftrace_event(event); |
| 1155 | if (!ret) { |
| 1156 | printk(KERN_WARNING "event %d failed to register\n", |
| 1157 | event->type); |
| 1158 | WARN_ON_ONCE(1); |
| 1159 | } |
| 1160 | } |
| 1161 | |
| 1162 | return 0; |
| 1163 | } |
| 1164 | device_initcall(init_events); |