diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2014-11-12 10:29:54 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-11-19 15:25:39 -0500 |
commit | 19a7fe206232cc875a3083211e0a21c08edd756e (patch) | |
tree | 948aba93b9f2f6681eb7cc3209b0ec87e19470d1 /kernel/trace/trace_output.c | |
parent | e400a40cffa77e45c60c5431ec8757579247cae2 (diff) |
tracing: Add trace_seq_has_overflowed() and trace_handle_return()
Adding a trace_seq_has_overflowed() which returns true if the trace_seq
had too much written into it allows us to simplify the code.
Instead of checking the return value of every call to trace_seq_printf()
and friends, they can all be called normally, and at the end we can
return !trace_seq_has_overflowed() instead.
Several functions also return TRACE_TYPE_PARTIAL_LINE when the trace_seq
overflowed and TRACE_TYPE_HANDLED otherwise. Another helper function
was created called trace_handle_return() which takes a trace_seq and
returns these enums. Using this helper function also simplifies the
code.
This change also makes it possible to remove the return values of
trace_seq_printf() and friends. They should instead just be
void functions.
Link: http://lkml.kernel.org/r/20141114011410.365183157@goodmis.org
Reviewed-by: Petr Mladek <pmladek@suse.cz>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_output.c')
-rw-r--r-- | kernel/trace/trace_output.c | 416 |
1 files changed, 165 insertions, 251 deletions
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index cfa91de22e27..163c11b6b8ff 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c | |||
@@ -25,15 +25,12 @@ enum print_line_t trace_print_bputs_msg_only(struct trace_iterator *iter) | |||
25 | struct trace_seq *s = &iter->seq; | 25 | struct trace_seq *s = &iter->seq; |
26 | struct trace_entry *entry = iter->ent; | 26 | struct trace_entry *entry = iter->ent; |
27 | struct bputs_entry *field; | 27 | struct bputs_entry *field; |
28 | int ret; | ||
29 | 28 | ||
30 | trace_assign_type(field, entry); | 29 | trace_assign_type(field, entry); |
31 | 30 | ||
32 | ret = trace_seq_puts(s, field->str); | 31 | trace_seq_puts(s, field->str); |
33 | if (!ret) | ||
34 | return TRACE_TYPE_PARTIAL_LINE; | ||
35 | 32 | ||
36 | return TRACE_TYPE_HANDLED; | 33 | return trace_handle_return(s); |
37 | } | 34 | } |
38 | 35 | ||
39 | enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter) | 36 | enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter) |
@@ -41,15 +38,12 @@ enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter) | |||
41 | struct trace_seq *s = &iter->seq; | 38 | struct trace_seq *s = &iter->seq; |
42 | struct trace_entry *entry = iter->ent; | 39 | struct trace_entry *entry = iter->ent; |
43 | struct bprint_entry *field; | 40 | struct bprint_entry *field; |
44 | int ret; | ||
45 | 41 | ||
46 | trace_assign_type(field, entry); | 42 | trace_assign_type(field, entry); |
47 | 43 | ||
48 | ret = trace_seq_bprintf(s, field->fmt, field->buf); | 44 | trace_seq_bprintf(s, field->fmt, field->buf); |
49 | if (!ret) | ||
50 | return TRACE_TYPE_PARTIAL_LINE; | ||
51 | 45 | ||
52 | return TRACE_TYPE_HANDLED; | 46 | return trace_handle_return(s); |
53 | } | 47 | } |
54 | 48 | ||
55 | enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter) | 49 | enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter) |
@@ -57,15 +51,12 @@ enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter) | |||
57 | struct trace_seq *s = &iter->seq; | 51 | struct trace_seq *s = &iter->seq; |
58 | struct trace_entry *entry = iter->ent; | 52 | struct trace_entry *entry = iter->ent; |
59 | struct print_entry *field; | 53 | struct print_entry *field; |
60 | int ret; | ||
61 | 54 | ||
62 | trace_assign_type(field, entry); | 55 | trace_assign_type(field, entry); |
63 | 56 | ||
64 | ret = trace_seq_puts(s, field->buf); | 57 | trace_seq_puts(s, field->buf); |
65 | if (!ret) | ||
66 | return TRACE_TYPE_PARTIAL_LINE; | ||
67 | 58 | ||
68 | return TRACE_TYPE_HANDLED; | 59 | return trace_handle_return(s); |
69 | } | 60 | } |
70 | 61 | ||
71 | const char * | 62 | const char * |
@@ -193,7 +184,6 @@ int ftrace_raw_output_prep(struct trace_iterator *iter, | |||
193 | struct trace_seq *s = &iter->seq; | 184 | struct trace_seq *s = &iter->seq; |
194 | struct trace_seq *p = &iter->tmp_seq; | 185 | struct trace_seq *p = &iter->tmp_seq; |
195 | struct trace_entry *entry; | 186 | struct trace_entry *entry; |
196 | int ret; | ||
197 | 187 | ||
198 | event = container_of(trace_event, struct ftrace_event_call, event); | 188 | event = container_of(trace_event, struct ftrace_event_call, event); |
199 | entry = iter->ent; | 189 | entry = iter->ent; |
@@ -204,8 +194,9 @@ int ftrace_raw_output_prep(struct trace_iterator *iter, | |||
204 | } | 194 | } |
205 | 195 | ||
206 | trace_seq_init(p); | 196 | trace_seq_init(p); |
207 | ret = trace_seq_printf(s, "%s: ", ftrace_event_name(event)); | 197 | trace_seq_printf(s, "%s: ", ftrace_event_name(event)); |
208 | if (!ret) | 198 | |
199 | if (trace_seq_has_overflowed(s)) | ||
209 | return TRACE_TYPE_PARTIAL_LINE; | 200 | return TRACE_TYPE_PARTIAL_LINE; |
210 | 201 | ||
211 | return 0; | 202 | return 0; |
@@ -216,18 +207,11 @@ static int ftrace_output_raw(struct trace_iterator *iter, char *name, | |||
216 | char *fmt, va_list ap) | 207 | char *fmt, va_list ap) |
217 | { | 208 | { |
218 | struct trace_seq *s = &iter->seq; | 209 | struct trace_seq *s = &iter->seq; |
219 | int ret; | ||
220 | 210 | ||
221 | ret = trace_seq_printf(s, "%s: ", name); | 211 | trace_seq_printf(s, "%s: ", name); |
222 | if (!ret) | 212 | trace_seq_vprintf(s, fmt, ap); |
223 | return TRACE_TYPE_PARTIAL_LINE; | ||
224 | |||
225 | ret = trace_seq_vprintf(s, fmt, ap); | ||
226 | 213 | ||
227 | if (!ret) | 214 | return trace_handle_return(s); |
228 | return TRACE_TYPE_PARTIAL_LINE; | ||
229 | |||
230 | return TRACE_TYPE_HANDLED; | ||
231 | } | 215 | } |
232 | 216 | ||
233 | int ftrace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...) | 217 | int ftrace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...) |
@@ -260,7 +244,7 @@ static inline const char *kretprobed(const char *name) | |||
260 | } | 244 | } |
261 | #endif /* CONFIG_KRETPROBES */ | 245 | #endif /* CONFIG_KRETPROBES */ |
262 | 246 | ||
263 | static int | 247 | static void |
264 | seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address) | 248 | seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address) |
265 | { | 249 | { |
266 | #ifdef CONFIG_KALLSYMS | 250 | #ifdef CONFIG_KALLSYMS |
@@ -271,12 +255,11 @@ seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address) | |||
271 | 255 | ||
272 | name = kretprobed(str); | 256 | name = kretprobed(str); |
273 | 257 | ||
274 | return trace_seq_printf(s, fmt, name); | 258 | trace_seq_printf(s, fmt, name); |
275 | #endif | 259 | #endif |
276 | return 1; | ||
277 | } | 260 | } |
278 | 261 | ||
279 | static int | 262 | static void |
280 | seq_print_sym_offset(struct trace_seq *s, const char *fmt, | 263 | seq_print_sym_offset(struct trace_seq *s, const char *fmt, |
281 | unsigned long address) | 264 | unsigned long address) |
282 | { | 265 | { |
@@ -287,9 +270,8 @@ seq_print_sym_offset(struct trace_seq *s, const char *fmt, | |||
287 | sprint_symbol(str, address); | 270 | sprint_symbol(str, address); |
288 | name = kretprobed(str); | 271 | name = kretprobed(str); |
289 | 272 | ||
290 | return trace_seq_printf(s, fmt, name); | 273 | trace_seq_printf(s, fmt, name); |
291 | #endif | 274 | #endif |
292 | return 1; | ||
293 | } | 275 | } |
294 | 276 | ||
295 | #ifndef CONFIG_64BIT | 277 | #ifndef CONFIG_64BIT |
@@ -320,14 +302,14 @@ int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm, | |||
320 | if (file) { | 302 | if (file) { |
321 | ret = trace_seq_path(s, &file->f_path); | 303 | ret = trace_seq_path(s, &file->f_path); |
322 | if (ret) | 304 | if (ret) |
323 | ret = trace_seq_printf(s, "[+0x%lx]", | 305 | trace_seq_printf(s, "[+0x%lx]", |
324 | ip - vmstart); | 306 | ip - vmstart); |
325 | } | 307 | } |
326 | up_read(&mm->mmap_sem); | 308 | up_read(&mm->mmap_sem); |
327 | } | 309 | } |
328 | if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file)) | 310 | if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file)) |
329 | ret = trace_seq_printf(s, " <" IP_FMT ">", ip); | 311 | trace_seq_printf(s, " <" IP_FMT ">", ip); |
330 | return ret; | 312 | return !trace_seq_has_overflowed(s); |
331 | } | 313 | } |
332 | 314 | ||
333 | int | 315 | int |
@@ -335,7 +317,6 @@ seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s, | |||
335 | unsigned long sym_flags) | 317 | unsigned long sym_flags) |
336 | { | 318 | { |
337 | struct mm_struct *mm = NULL; | 319 | struct mm_struct *mm = NULL; |
338 | int ret = 1; | ||
339 | unsigned int i; | 320 | unsigned int i; |
340 | 321 | ||
341 | if (trace_flags & TRACE_ITER_SYM_USEROBJ) { | 322 | if (trace_flags & TRACE_ITER_SYM_USEROBJ) { |
@@ -354,48 +335,45 @@ seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s, | |||
354 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { | 335 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { |
355 | unsigned long ip = entry->caller[i]; | 336 | unsigned long ip = entry->caller[i]; |
356 | 337 | ||
357 | if (ip == ULONG_MAX || !ret) | 338 | if (ip == ULONG_MAX || trace_seq_has_overflowed(s)) |
358 | break; | 339 | break; |
359 | if (ret) | 340 | |
360 | ret = trace_seq_puts(s, " => "); | 341 | trace_seq_puts(s, " => "); |
342 | |||
361 | if (!ip) { | 343 | if (!ip) { |
362 | if (ret) | 344 | trace_seq_puts(s, "??"); |
363 | ret = trace_seq_puts(s, "??"); | 345 | trace_seq_putc(s, '\n'); |
364 | if (ret) | ||
365 | ret = trace_seq_putc(s, '\n'); | ||
366 | continue; | 346 | continue; |
367 | } | 347 | } |
368 | if (!ret) | 348 | |
369 | break; | 349 | seq_print_user_ip(s, mm, ip, sym_flags); |
370 | if (ret) | 350 | trace_seq_putc(s, '\n'); |
371 | ret = seq_print_user_ip(s, mm, ip, sym_flags); | ||
372 | ret = trace_seq_putc(s, '\n'); | ||
373 | } | 351 | } |
374 | 352 | ||
375 | if (mm) | 353 | if (mm) |
376 | mmput(mm); | 354 | mmput(mm); |
377 | return ret; | 355 | |
356 | return !trace_seq_has_overflowed(s); | ||
378 | } | 357 | } |
379 | 358 | ||
380 | int | 359 | int |
381 | seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags) | 360 | seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags) |
382 | { | 361 | { |
383 | int ret; | 362 | if (!ip) { |
384 | 363 | trace_seq_putc(s, '0'); | |
385 | if (!ip) | 364 | goto out; |
386 | return trace_seq_putc(s, '0'); | 365 | } |
387 | 366 | ||
388 | if (sym_flags & TRACE_ITER_SYM_OFFSET) | 367 | if (sym_flags & TRACE_ITER_SYM_OFFSET) |
389 | ret = seq_print_sym_offset(s, "%s", ip); | 368 | seq_print_sym_offset(s, "%s", ip); |
390 | else | 369 | else |
391 | ret = seq_print_sym_short(s, "%s", ip); | 370 | seq_print_sym_short(s, "%s", ip); |
392 | |||
393 | if (!ret) | ||
394 | return 0; | ||
395 | 371 | ||
396 | if (sym_flags & TRACE_ITER_SYM_ADDR) | 372 | if (sym_flags & TRACE_ITER_SYM_ADDR) |
397 | ret = trace_seq_printf(s, " <" IP_FMT ">", ip); | 373 | trace_seq_printf(s, " <" IP_FMT ">", ip); |
398 | return ret; | 374 | |
375 | out: | ||
376 | return !trace_seq_has_overflowed(s); | ||
399 | } | 377 | } |
400 | 378 | ||
401 | /** | 379 | /** |
@@ -413,7 +391,6 @@ int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry) | |||
413 | char irqs_off; | 391 | char irqs_off; |
414 | int hardirq; | 392 | int hardirq; |
415 | int softirq; | 393 | int softirq; |
416 | int ret; | ||
417 | 394 | ||
418 | hardirq = entry->flags & TRACE_FLAG_HARDIRQ; | 395 | hardirq = entry->flags & TRACE_FLAG_HARDIRQ; |
419 | softirq = entry->flags & TRACE_FLAG_SOFTIRQ; | 396 | softirq = entry->flags & TRACE_FLAG_SOFTIRQ; |
@@ -445,16 +422,15 @@ int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry) | |||
445 | softirq ? 's' : | 422 | softirq ? 's' : |
446 | '.'; | 423 | '.'; |
447 | 424 | ||
448 | if (!trace_seq_printf(s, "%c%c%c", | 425 | trace_seq_printf(s, "%c%c%c", |
449 | irqs_off, need_resched, hardsoft_irq)) | 426 | irqs_off, need_resched, hardsoft_irq); |
450 | return 0; | ||
451 | 427 | ||
452 | if (entry->preempt_count) | 428 | if (entry->preempt_count) |
453 | ret = trace_seq_printf(s, "%x", entry->preempt_count); | 429 | trace_seq_printf(s, "%x", entry->preempt_count); |
454 | else | 430 | else |
455 | ret = trace_seq_putc(s, '.'); | 431 | trace_seq_putc(s, '.'); |
456 | 432 | ||
457 | return ret; | 433 | return !trace_seq_has_overflowed(s); |
458 | } | 434 | } |
459 | 435 | ||
460 | static int | 436 | static int |
@@ -464,9 +440,8 @@ lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu) | |||
464 | 440 | ||
465 | trace_find_cmdline(entry->pid, comm); | 441 | trace_find_cmdline(entry->pid, comm); |
466 | 442 | ||
467 | if (!trace_seq_printf(s, "%8.8s-%-5d %3d", | 443 | trace_seq_printf(s, "%8.8s-%-5d %3d", |
468 | comm, entry->pid, cpu)) | 444 | comm, entry->pid, cpu); |
469 | return 0; | ||
470 | 445 | ||
471 | return trace_print_lat_fmt(s, entry); | 446 | return trace_print_lat_fmt(s, entry); |
472 | } | 447 | } |
@@ -493,24 +468,29 @@ lat_print_timestamp(struct trace_iterator *iter, u64 next_ts) | |||
493 | unsigned long rel_usec = do_div(rel_ts, USEC_PER_MSEC); | 468 | unsigned long rel_usec = do_div(rel_ts, USEC_PER_MSEC); |
494 | unsigned long rel_msec = (unsigned long)rel_ts; | 469 | unsigned long rel_msec = (unsigned long)rel_ts; |
495 | 470 | ||
496 | return trace_seq_printf( | 471 | trace_seq_printf( |
497 | s, "[%08llx] %ld.%03ldms (+%ld.%03ldms): ", | 472 | s, "[%08llx] %ld.%03ldms (+%ld.%03ldms): ", |
498 | ns2usecs(iter->ts), | 473 | ns2usecs(iter->ts), |
499 | abs_msec, abs_usec, | 474 | abs_msec, abs_usec, |
500 | rel_msec, rel_usec); | 475 | rel_msec, rel_usec); |
476 | |||
501 | } else if (verbose && !in_ns) { | 477 | } else if (verbose && !in_ns) { |
502 | return trace_seq_printf( | 478 | trace_seq_printf( |
503 | s, "[%016llx] %lld (+%lld): ", | 479 | s, "[%016llx] %lld (+%lld): ", |
504 | iter->ts, abs_ts, rel_ts); | 480 | iter->ts, abs_ts, rel_ts); |
481 | |||
505 | } else if (!verbose && in_ns) { | 482 | } else if (!verbose && in_ns) { |
506 | return trace_seq_printf( | 483 | trace_seq_printf( |
507 | s, " %4lldus%c: ", | 484 | s, " %4lldus%c: ", |
508 | abs_ts, | 485 | abs_ts, |
509 | rel_ts > preempt_mark_thresh_us ? '!' : | 486 | rel_ts > preempt_mark_thresh_us ? '!' : |
510 | rel_ts > 1 ? '+' : ' '); | 487 | rel_ts > 1 ? '+' : ' '); |
488 | |||
511 | } else { /* !verbose && !in_ns */ | 489 | } else { /* !verbose && !in_ns */ |
512 | return trace_seq_printf(s, " %4lld: ", abs_ts); | 490 | trace_seq_printf(s, " %4lld: ", abs_ts); |
513 | } | 491 | } |
492 | |||
493 | return !trace_seq_has_overflowed(s); | ||
514 | } | 494 | } |
515 | 495 | ||
516 | int trace_print_context(struct trace_iterator *iter) | 496 | int trace_print_context(struct trace_iterator *iter) |
@@ -520,34 +500,29 @@ int trace_print_context(struct trace_iterator *iter) | |||
520 | unsigned long long t; | 500 | unsigned long long t; |
521 | unsigned long secs, usec_rem; | 501 | unsigned long secs, usec_rem; |
522 | char comm[TASK_COMM_LEN]; | 502 | char comm[TASK_COMM_LEN]; |
523 | int ret; | ||
524 | 503 | ||
525 | trace_find_cmdline(entry->pid, comm); | 504 | trace_find_cmdline(entry->pid, comm); |
526 | 505 | ||
527 | ret = trace_seq_printf(s, "%16s-%-5d [%03d] ", | 506 | trace_seq_printf(s, "%16s-%-5d [%03d] ", |
528 | comm, entry->pid, iter->cpu); | 507 | comm, entry->pid, iter->cpu); |
529 | if (!ret) | ||
530 | return 0; | ||
531 | 508 | ||
532 | if (trace_flags & TRACE_ITER_IRQ_INFO) { | 509 | if (trace_flags & TRACE_ITER_IRQ_INFO) |
533 | ret = trace_print_lat_fmt(s, entry); | 510 | trace_print_lat_fmt(s, entry); |
534 | if (!ret) | ||
535 | return 0; | ||
536 | } | ||
537 | 511 | ||
538 | if (iter->iter_flags & TRACE_FILE_TIME_IN_NS) { | 512 | if (iter->iter_flags & TRACE_FILE_TIME_IN_NS) { |
539 | t = ns2usecs(iter->ts); | 513 | t = ns2usecs(iter->ts); |
540 | usec_rem = do_div(t, USEC_PER_SEC); | 514 | usec_rem = do_div(t, USEC_PER_SEC); |
541 | secs = (unsigned long)t; | 515 | secs = (unsigned long)t; |
542 | return trace_seq_printf(s, " %5lu.%06lu: ", secs, usec_rem); | 516 | trace_seq_printf(s, " %5lu.%06lu: ", secs, usec_rem); |
543 | } else | 517 | } else |
544 | return trace_seq_printf(s, " %12llu: ", iter->ts); | 518 | trace_seq_printf(s, " %12llu: ", iter->ts); |
519 | |||
520 | return !trace_seq_has_overflowed(s); | ||
545 | } | 521 | } |
546 | 522 | ||
547 | int trace_print_lat_context(struct trace_iterator *iter) | 523 | int trace_print_lat_context(struct trace_iterator *iter) |
548 | { | 524 | { |
549 | u64 next_ts; | 525 | u64 next_ts; |
550 | int ret; | ||
551 | /* trace_find_next_entry will reset ent_size */ | 526 | /* trace_find_next_entry will reset ent_size */ |
552 | int ent_size = iter->ent_size; | 527 | int ent_size = iter->ent_size; |
553 | struct trace_seq *s = &iter->seq; | 528 | struct trace_seq *s = &iter->seq; |
@@ -567,18 +542,17 @@ int trace_print_lat_context(struct trace_iterator *iter) | |||
567 | 542 | ||
568 | trace_find_cmdline(entry->pid, comm); | 543 | trace_find_cmdline(entry->pid, comm); |
569 | 544 | ||
570 | ret = trace_seq_printf( | 545 | trace_seq_printf( |
571 | s, "%16s %5d %3d %d %08x %08lx ", | 546 | s, "%16s %5d %3d %d %08x %08lx ", |
572 | comm, entry->pid, iter->cpu, entry->flags, | 547 | comm, entry->pid, iter->cpu, entry->flags, |
573 | entry->preempt_count, iter->idx); | 548 | entry->preempt_count, iter->idx); |
574 | } else { | 549 | } else { |
575 | ret = lat_print_generic(s, entry, iter->cpu); | 550 | lat_print_generic(s, entry, iter->cpu); |
576 | } | 551 | } |
577 | 552 | ||
578 | if (ret) | 553 | lat_print_timestamp(iter, next_ts); |
579 | ret = lat_print_timestamp(iter, next_ts); | ||
580 | 554 | ||
581 | return ret; | 555 | return !trace_seq_has_overflowed(s); |
582 | } | 556 | } |
583 | 557 | ||
584 | static const char state_to_char[] = TASK_STATE_TO_CHAR_STR; | 558 | static const char state_to_char[] = TASK_STATE_TO_CHAR_STR; |
@@ -764,10 +738,9 @@ EXPORT_SYMBOL_GPL(unregister_ftrace_event); | |||
764 | enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags, | 738 | enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags, |
765 | struct trace_event *event) | 739 | struct trace_event *event) |
766 | { | 740 | { |
767 | if (!trace_seq_printf(&iter->seq, "type: %d\n", iter->ent->type)) | 741 | trace_seq_printf(&iter->seq, "type: %d\n", iter->ent->type); |
768 | return TRACE_TYPE_PARTIAL_LINE; | ||
769 | 742 | ||
770 | return TRACE_TYPE_HANDLED; | 743 | return trace_handle_return(&iter->seq); |
771 | } | 744 | } |
772 | 745 | ||
773 | /* TRACE_FN */ | 746 | /* TRACE_FN */ |
@@ -779,24 +752,16 @@ static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags, | |||
779 | 752 | ||
780 | trace_assign_type(field, iter->ent); | 753 | trace_assign_type(field, iter->ent); |
781 | 754 | ||
782 | if (!seq_print_ip_sym(s, field->ip, flags)) | 755 | seq_print_ip_sym(s, field->ip, flags); |
783 | goto partial; | ||
784 | 756 | ||
785 | if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) { | 757 | if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) { |
786 | if (!trace_seq_puts(s, " <-")) | 758 | trace_seq_puts(s, " <-"); |
787 | goto partial; | 759 | seq_print_ip_sym(s, field->parent_ip, flags); |
788 | if (!seq_print_ip_sym(s, | ||
789 | field->parent_ip, | ||
790 | flags)) | ||
791 | goto partial; | ||
792 | } | 760 | } |
793 | if (!trace_seq_putc(s, '\n')) | ||
794 | goto partial; | ||
795 | 761 | ||
796 | return TRACE_TYPE_HANDLED; | 762 | trace_seq_putc(s, '\n'); |
797 | 763 | ||
798 | partial: | 764 | return trace_handle_return(s); |
799 | return TRACE_TYPE_PARTIAL_LINE; | ||
800 | } | 765 | } |
801 | 766 | ||
802 | static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags, | 767 | static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags, |
@@ -806,12 +771,11 @@ static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags, | |||
806 | 771 | ||
807 | trace_assign_type(field, iter->ent); | 772 | trace_assign_type(field, iter->ent); |
808 | 773 | ||
809 | if (!trace_seq_printf(&iter->seq, "%lx %lx\n", | 774 | trace_seq_printf(&iter->seq, "%lx %lx\n", |
810 | field->ip, | 775 | field->ip, |
811 | field->parent_ip)) | 776 | field->parent_ip); |
812 | return TRACE_TYPE_PARTIAL_LINE; | ||
813 | 777 | ||
814 | return TRACE_TYPE_HANDLED; | 778 | return trace_handle_return(&iter->seq); |
815 | } | 779 | } |
816 | 780 | ||
817 | static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags, | 781 | static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags, |
@@ -822,10 +786,10 @@ static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags, | |||
822 | 786 | ||
823 | trace_assign_type(field, iter->ent); | 787 | trace_assign_type(field, iter->ent); |
824 | 788 | ||
825 | SEQ_PUT_HEX_FIELD_RET(s, field->ip); | 789 | SEQ_PUT_HEX_FIELD(s, field->ip); |
826 | SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip); | 790 | SEQ_PUT_HEX_FIELD(s, field->parent_ip); |
827 | 791 | ||
828 | return TRACE_TYPE_HANDLED; | 792 | return trace_handle_return(s); |
829 | } | 793 | } |
830 | 794 | ||
831 | static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags, | 795 | static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags, |
@@ -836,10 +800,10 @@ static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags, | |||
836 | 800 | ||
837 | trace_assign_type(field, iter->ent); | 801 | trace_assign_type(field, iter->ent); |
838 | 802 | ||
839 | SEQ_PUT_FIELD_RET(s, field->ip); | 803 | SEQ_PUT_FIELD(s, field->ip); |
840 | SEQ_PUT_FIELD_RET(s, field->parent_ip); | 804 | SEQ_PUT_FIELD(s, field->parent_ip); |
841 | 805 | ||
842 | return TRACE_TYPE_HANDLED; | 806 | return trace_handle_return(s); |
843 | } | 807 | } |
844 | 808 | ||
845 | static struct trace_event_functions trace_fn_funcs = { | 809 | static struct trace_event_functions trace_fn_funcs = { |
@@ -868,18 +832,17 @@ static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter, | |||
868 | T = task_state_char(field->next_state); | 832 | T = task_state_char(field->next_state); |
869 | S = task_state_char(field->prev_state); | 833 | S = task_state_char(field->prev_state); |
870 | trace_find_cmdline(field->next_pid, comm); | 834 | trace_find_cmdline(field->next_pid, comm); |
871 | if (!trace_seq_printf(&iter->seq, | 835 | trace_seq_printf(&iter->seq, |
872 | " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n", | 836 | " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n", |
873 | field->prev_pid, | 837 | field->prev_pid, |
874 | field->prev_prio, | 838 | field->prev_prio, |
875 | S, delim, | 839 | S, delim, |
876 | field->next_cpu, | 840 | field->next_cpu, |
877 | field->next_pid, | 841 | field->next_pid, |
878 | field->next_prio, | 842 | field->next_prio, |
879 | T, comm)) | 843 | T, comm); |
880 | return TRACE_TYPE_PARTIAL_LINE; | 844 | |
881 | 845 | return trace_handle_return(&iter->seq); | |
882 | return TRACE_TYPE_HANDLED; | ||
883 | } | 846 | } |
884 | 847 | ||
885 | static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags, | 848 | static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags, |
@@ -904,17 +867,16 @@ static int trace_ctxwake_raw(struct trace_iterator *iter, char S) | |||
904 | if (!S) | 867 | if (!S) |
905 | S = task_state_char(field->prev_state); | 868 | S = task_state_char(field->prev_state); |
906 | T = task_state_char(field->next_state); | 869 | T = task_state_char(field->next_state); |
907 | if (!trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n", | 870 | trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n", |
908 | field->prev_pid, | 871 | field->prev_pid, |
909 | field->prev_prio, | 872 | field->prev_prio, |
910 | S, | 873 | S, |
911 | field->next_cpu, | 874 | field->next_cpu, |
912 | field->next_pid, | 875 | field->next_pid, |
913 | field->next_prio, | 876 | field->next_prio, |
914 | T)) | 877 | T); |
915 | return TRACE_TYPE_PARTIAL_LINE; | 878 | |
916 | 879 | return trace_handle_return(&iter->seq); | |
917 | return TRACE_TYPE_HANDLED; | ||
918 | } | 880 | } |
919 | 881 | ||
920 | static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags, | 882 | static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags, |
@@ -942,15 +904,15 @@ static int trace_ctxwake_hex(struct trace_iterator *iter, char S) | |||
942 | S = task_state_char(field->prev_state); | 904 | S = task_state_char(field->prev_state); |
943 | T = task_state_char(field->next_state); | 905 | T = task_state_char(field->next_state); |
944 | 906 | ||
945 | SEQ_PUT_HEX_FIELD_RET(s, field->prev_pid); | 907 | SEQ_PUT_HEX_FIELD(s, field->prev_pid); |
946 | SEQ_PUT_HEX_FIELD_RET(s, field->prev_prio); | 908 | SEQ_PUT_HEX_FIELD(s, field->prev_prio); |
947 | SEQ_PUT_HEX_FIELD_RET(s, S); | 909 | SEQ_PUT_HEX_FIELD(s, S); |
948 | SEQ_PUT_HEX_FIELD_RET(s, field->next_cpu); | 910 | SEQ_PUT_HEX_FIELD(s, field->next_cpu); |
949 | SEQ_PUT_HEX_FIELD_RET(s, field->next_pid); | 911 | SEQ_PUT_HEX_FIELD(s, field->next_pid); |
950 | SEQ_PUT_HEX_FIELD_RET(s, field->next_prio); | 912 | SEQ_PUT_HEX_FIELD(s, field->next_prio); |
951 | SEQ_PUT_HEX_FIELD_RET(s, T); | 913 | SEQ_PUT_HEX_FIELD(s, T); |
952 | 914 | ||
953 | return TRACE_TYPE_HANDLED; | 915 | return trace_handle_return(s); |
954 | } | 916 | } |
955 | 917 | ||
956 | static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags, | 918 | static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags, |
@@ -973,15 +935,15 @@ static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter, | |||
973 | 935 | ||
974 | trace_assign_type(field, iter->ent); | 936 | trace_assign_type(field, iter->ent); |
975 | 937 | ||
976 | SEQ_PUT_FIELD_RET(s, field->prev_pid); | 938 | SEQ_PUT_FIELD(s, field->prev_pid); |
977 | SEQ_PUT_FIELD_RET(s, field->prev_prio); | 939 | SEQ_PUT_FIELD(s, field->prev_prio); |
978 | SEQ_PUT_FIELD_RET(s, field->prev_state); | 940 | SEQ_PUT_FIELD(s, field->prev_state); |
979 | SEQ_PUT_FIELD_RET(s, field->next_cpu); | 941 | SEQ_PUT_FIELD(s, field->next_cpu); |
980 | SEQ_PUT_FIELD_RET(s, field->next_pid); | 942 | SEQ_PUT_FIELD(s, field->next_pid); |
981 | SEQ_PUT_FIELD_RET(s, field->next_prio); | 943 | SEQ_PUT_FIELD(s, field->next_prio); |
982 | SEQ_PUT_FIELD_RET(s, field->next_state); | 944 | SEQ_PUT_FIELD(s, field->next_state); |
983 | 945 | ||
984 | return TRACE_TYPE_HANDLED; | 946 | return trace_handle_return(s); |
985 | } | 947 | } |
986 | 948 | ||
987 | static struct trace_event_functions trace_ctx_funcs = { | 949 | static struct trace_event_functions trace_ctx_funcs = { |
@@ -1021,23 +983,19 @@ static enum print_line_t trace_stack_print(struct trace_iterator *iter, | |||
1021 | trace_assign_type(field, iter->ent); | 983 | trace_assign_type(field, iter->ent); |
1022 | end = (unsigned long *)((long)iter->ent + iter->ent_size); | 984 | end = (unsigned long *)((long)iter->ent + iter->ent_size); |
1023 | 985 | ||
1024 | if (!trace_seq_puts(s, "<stack trace>\n")) | 986 | trace_seq_puts(s, "<stack trace>\n"); |
1025 | goto partial; | ||
1026 | 987 | ||
1027 | for (p = field->caller; p && *p != ULONG_MAX && p < end; p++) { | 988 | for (p = field->caller; p && *p != ULONG_MAX && p < end; p++) { |
1028 | if (!trace_seq_puts(s, " => ")) | ||
1029 | goto partial; | ||
1030 | 989 | ||
1031 | if (!seq_print_ip_sym(s, *p, flags)) | 990 | if (trace_seq_has_overflowed(s)) |
1032 | goto partial; | 991 | break; |
1033 | if (!trace_seq_putc(s, '\n')) | ||
1034 | goto partial; | ||
1035 | } | ||
1036 | 992 | ||
1037 | return TRACE_TYPE_HANDLED; | 993 | trace_seq_puts(s, " => "); |
994 | seq_print_ip_sym(s, *p, flags); | ||
995 | trace_seq_putc(s, '\n'); | ||
996 | } | ||
1038 | 997 | ||
1039 | partial: | 998 | return trace_handle_return(s); |
1040 | return TRACE_TYPE_PARTIAL_LINE; | ||
1041 | } | 999 | } |
1042 | 1000 | ||
1043 | static struct trace_event_functions trace_stack_funcs = { | 1001 | static struct trace_event_functions trace_stack_funcs = { |
@@ -1058,16 +1016,10 @@ static enum print_line_t trace_user_stack_print(struct trace_iterator *iter, | |||
1058 | 1016 | ||
1059 | trace_assign_type(field, iter->ent); | 1017 | trace_assign_type(field, iter->ent); |
1060 | 1018 | ||
1061 | if (!trace_seq_puts(s, "<user stack trace>\n")) | 1019 | trace_seq_puts(s, "<user stack trace>\n"); |
1062 | goto partial; | 1020 | seq_print_userip_objs(field, s, flags); |
1063 | |||
1064 | if (!seq_print_userip_objs(field, s, flags)) | ||
1065 | goto partial; | ||
1066 | |||
1067 | return TRACE_TYPE_HANDLED; | ||
1068 | 1021 | ||
1069 | partial: | 1022 | return trace_handle_return(s); |
1070 | return TRACE_TYPE_PARTIAL_LINE; | ||
1071 | } | 1023 | } |
1072 | 1024 | ||
1073 | static struct trace_event_functions trace_user_stack_funcs = { | 1025 | static struct trace_event_functions trace_user_stack_funcs = { |
@@ -1090,19 +1042,11 @@ trace_bputs_print(struct trace_iterator *iter, int flags, | |||
1090 | 1042 | ||
1091 | trace_assign_type(field, entry); | 1043 | trace_assign_type(field, entry); |
1092 | 1044 | ||
1093 | if (!seq_print_ip_sym(s, field->ip, flags)) | 1045 | seq_print_ip_sym(s, field->ip, flags); |
1094 | goto partial; | 1046 | trace_seq_puts(s, ": "); |
1047 | trace_seq_puts(s, field->str); | ||
1095 | 1048 | ||
1096 | if (!trace_seq_puts(s, ": ")) | 1049 | return trace_handle_return(s); |
1097 | goto partial; | ||
1098 | |||
1099 | if (!trace_seq_puts(s, field->str)) | ||
1100 | goto partial; | ||
1101 | |||
1102 | return TRACE_TYPE_HANDLED; | ||
1103 | |||
1104 | partial: | ||
1105 | return TRACE_TYPE_PARTIAL_LINE; | ||
1106 | } | 1050 | } |
1107 | 1051 | ||
1108 | 1052 | ||
@@ -1115,16 +1059,10 @@ trace_bputs_raw(struct trace_iterator *iter, int flags, | |||
1115 | 1059 | ||
1116 | trace_assign_type(field, iter->ent); | 1060 | trace_assign_type(field, iter->ent); |
1117 | 1061 | ||
1118 | if (!trace_seq_printf(s, ": %lx : ", field->ip)) | 1062 | trace_seq_printf(s, ": %lx : ", field->ip); |
1119 | goto partial; | 1063 | trace_seq_puts(s, field->str); |
1120 | |||
1121 | if (!trace_seq_puts(s, field->str)) | ||
1122 | goto partial; | ||
1123 | 1064 | ||
1124 | return TRACE_TYPE_HANDLED; | 1065 | return trace_handle_return(s); |
1125 | |||
1126 | partial: | ||
1127 | return TRACE_TYPE_PARTIAL_LINE; | ||
1128 | } | 1066 | } |
1129 | 1067 | ||
1130 | static struct trace_event_functions trace_bputs_funcs = { | 1068 | static struct trace_event_functions trace_bputs_funcs = { |
@@ -1148,19 +1086,11 @@ trace_bprint_print(struct trace_iterator *iter, int flags, | |||
1148 | 1086 | ||
1149 | trace_assign_type(field, entry); | 1087 | trace_assign_type(field, entry); |
1150 | 1088 | ||
1151 | if (!seq_print_ip_sym(s, field->ip, flags)) | 1089 | seq_print_ip_sym(s, field->ip, flags); |
1152 | goto partial; | 1090 | trace_seq_puts(s, ": "); |
1153 | 1091 | trace_seq_bprintf(s, field->fmt, field->buf); | |
1154 | if (!trace_seq_puts(s, ": ")) | ||
1155 | goto partial; | ||
1156 | |||
1157 | if (!trace_seq_bprintf(s, field->fmt, field->buf)) | ||
1158 | goto partial; | ||
1159 | 1092 | ||
1160 | return TRACE_TYPE_HANDLED; | 1093 | return trace_handle_return(s); |
1161 | |||
1162 | partial: | ||
1163 | return TRACE_TYPE_PARTIAL_LINE; | ||
1164 | } | 1094 | } |
1165 | 1095 | ||
1166 | 1096 | ||
@@ -1173,16 +1103,10 @@ trace_bprint_raw(struct trace_iterator *iter, int flags, | |||
1173 | 1103 | ||
1174 | trace_assign_type(field, iter->ent); | 1104 | trace_assign_type(field, iter->ent); |
1175 | 1105 | ||
1176 | if (!trace_seq_printf(s, ": %lx : ", field->ip)) | 1106 | trace_seq_printf(s, ": %lx : ", field->ip); |
1177 | goto partial; | 1107 | trace_seq_bprintf(s, field->fmt, field->buf); |
1178 | |||
1179 | if (!trace_seq_bprintf(s, field->fmt, field->buf)) | ||
1180 | goto partial; | ||
1181 | 1108 | ||
1182 | return TRACE_TYPE_HANDLED; | 1109 | return trace_handle_return(s); |
1183 | |||
1184 | partial: | ||
1185 | return TRACE_TYPE_PARTIAL_LINE; | ||
1186 | } | 1110 | } |
1187 | 1111 | ||
1188 | static struct trace_event_functions trace_bprint_funcs = { | 1112 | static struct trace_event_functions trace_bprint_funcs = { |
@@ -1204,16 +1128,10 @@ static enum print_line_t trace_print_print(struct trace_iterator *iter, | |||
1204 | 1128 | ||
1205 | trace_assign_type(field, iter->ent); | 1129 | trace_assign_type(field, iter->ent); |
1206 | 1130 | ||
1207 | if (!seq_print_ip_sym(s, field->ip, flags)) | 1131 | seq_print_ip_sym(s, field->ip, flags); |
1208 | goto partial; | 1132 | trace_seq_printf(s, ": %s", field->buf); |
1209 | |||
1210 | if (!trace_seq_printf(s, ": %s", field->buf)) | ||
1211 | goto partial; | ||
1212 | 1133 | ||
1213 | return TRACE_TYPE_HANDLED; | 1134 | return trace_handle_return(s); |
1214 | |||
1215 | partial: | ||
1216 | return TRACE_TYPE_PARTIAL_LINE; | ||
1217 | } | 1135 | } |
1218 | 1136 | ||
1219 | static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags, | 1137 | static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags, |
@@ -1223,13 +1141,9 @@ static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags, | |||
1223 | 1141 | ||
1224 | trace_assign_type(field, iter->ent); | 1142 | trace_assign_type(field, iter->ent); |
1225 | 1143 | ||
1226 | if (!trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf)) | 1144 | trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf); |
1227 | goto partial; | ||
1228 | |||
1229 | return TRACE_TYPE_HANDLED; | ||
1230 | 1145 | ||
1231 | partial: | 1146 | return trace_handle_return(&iter->seq); |
1232 | return TRACE_TYPE_PARTIAL_LINE; | ||
1233 | } | 1147 | } |
1234 | 1148 | ||
1235 | static struct trace_event_functions trace_print_funcs = { | 1149 | static struct trace_event_functions trace_print_funcs = { |