diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2011-01-13 07:46:05 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-24 07:57:03 -0500 |
commit | 5069ed86be3c2f28bcdf7fae1374ec0c325aafba (patch) | |
tree | e8b1dc51c435a47e1c1761b8b43090c4a3f78c24 /tools/perf/util/probe-finder.c | |
parent | 4cc9cec636e7f78aba7f17606ac13cac07ea5787 (diff) |
perf probe: Enable to put probe inline function call site
Enable to put probe inline function call site. This will increase line-based
probe-ability.
<Without this patch>
$ ./perf probe -L schedule:48
<schedule:48>
pre_schedule(rq, prev);
50 if (unlikely(!rq->nr_running))
idle_balance(cpu, rq);
put_prev_task(rq, prev);
next = pick_next_task(rq);
56 if (likely(prev != next)) {
sched_info_switch(prev, next);
trace_sched_switch_out(prev, next);
perf_event_task_sched_out(prev, next);
<With this patch>
$ ./perf probe -L schedule:48
<schedule:48>
48 pre_schedule(rq, prev);
50 if (unlikely(!rq->nr_running))
51 idle_balance(cpu, rq);
53 put_prev_task(rq, prev);
54 next = pick_next_task(rq);
56 if (likely(prev != next)) {
57 sched_info_switch(prev, next);
58 trace_sched_switch_out(prev, next);
59 perf_event_task_sched_out(prev, next);
Cc: 2nddept-manager@sdl.hitachi.co.jp
Cc: Franck Bui-Huu <fbuihuu@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20110113124604.22426.48873.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-finder.c')
-rw-r--r-- | tools/perf/util/probe-finder.c | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 508c017f566a..69215bff17e9 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -280,6 +280,19 @@ static bool die_compare_name(Dwarf_Die *dw_die, const char *tname) | |||
280 | return name ? (strcmp(tname, name) == 0) : false; | 280 | return name ? (strcmp(tname, name) == 0) : false; |
281 | } | 281 | } |
282 | 282 | ||
283 | /* Get callsite line number of inline-function instance */ | ||
284 | static int die_get_call_lineno(Dwarf_Die *in_die) | ||
285 | { | ||
286 | Dwarf_Attribute attr; | ||
287 | Dwarf_Word ret; | ||
288 | |||
289 | if (!dwarf_attr(in_die, DW_AT_call_line, &attr)) | ||
290 | return -ENOENT; | ||
291 | |||
292 | dwarf_formudata(&attr, &ret); | ||
293 | return (int)ret; | ||
294 | } | ||
295 | |||
283 | /* Get type die */ | 296 | /* Get type die */ |
284 | static Dwarf_Die *die_get_type(Dwarf_Die *vr_die, Dwarf_Die *die_mem) | 297 | static Dwarf_Die *die_get_type(Dwarf_Die *vr_die, Dwarf_Die *die_mem) |
285 | { | 298 | { |
@@ -463,27 +476,54 @@ typedef int (* line_walk_handler_t) (const char *fname, int lineno, | |||
463 | Dwarf_Addr addr, void *data); | 476 | Dwarf_Addr addr, void *data); |
464 | 477 | ||
465 | struct __line_walk_param { | 478 | struct __line_walk_param { |
479 | const char *fname; | ||
466 | line_walk_handler_t handler; | 480 | line_walk_handler_t handler; |
467 | void *data; | 481 | void *data; |
468 | int retval; | 482 | int retval; |
469 | }; | 483 | }; |
470 | 484 | ||
471 | /* Walk on decl lines in given DIE */ | 485 | static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data) |
486 | { | ||
487 | struct __line_walk_param *lw = data; | ||
488 | Dwarf_Addr addr; | ||
489 | int lineno; | ||
490 | |||
491 | if (dwarf_tag(in_die) == DW_TAG_inlined_subroutine) { | ||
492 | lineno = die_get_call_lineno(in_die); | ||
493 | if (lineno > 0 && dwarf_entrypc(in_die, &addr) == 0) { | ||
494 | lw->retval = lw->handler(lw->fname, lineno, addr, | ||
495 | lw->data); | ||
496 | if (lw->retval != 0) | ||
497 | return DIE_FIND_CB_FOUND; | ||
498 | } | ||
499 | } | ||
500 | return DIE_FIND_CB_SIBLING; | ||
501 | } | ||
502 | |||
503 | /* Walk on lines of blocks included in given DIE */ | ||
472 | static int __die_walk_funclines(Dwarf_Die *sp_die, | 504 | static int __die_walk_funclines(Dwarf_Die *sp_die, |
473 | line_walk_handler_t handler, void *data) | 505 | line_walk_handler_t handler, void *data) |
474 | { | 506 | { |
475 | const char *fname; | 507 | struct __line_walk_param lw = { |
508 | .handler = handler, | ||
509 | .data = data, | ||
510 | .retval = 0, | ||
511 | }; | ||
512 | Dwarf_Die die_mem; | ||
476 | Dwarf_Addr addr; | 513 | Dwarf_Addr addr; |
477 | int lineno, ret = 0; | 514 | int lineno; |
478 | 515 | ||
479 | /* Handle function declaration line */ | 516 | /* Handle function declaration line */ |
480 | fname = dwarf_decl_file(sp_die); | 517 | lw.fname = dwarf_decl_file(sp_die); |
481 | if (fname && dwarf_decl_line(sp_die, &lineno) == 0 && | 518 | if (lw.fname && dwarf_decl_line(sp_die, &lineno) == 0 && |
482 | dwarf_entrypc(sp_die, &addr) == 0) { | 519 | dwarf_entrypc(sp_die, &addr) == 0) { |
483 | ret = handler(fname, lineno, addr, data); | 520 | lw.retval = handler(lw.fname, lineno, addr, data); |
521 | if (lw.retval != 0) | ||
522 | goto done; | ||
484 | } | 523 | } |
485 | 524 | die_find_child(sp_die, __die_walk_funclines_cb, &lw, &die_mem); | |
486 | return ret; | 525 | done: |
526 | return lw.retval; | ||
487 | } | 527 | } |
488 | 528 | ||
489 | static int __die_walk_culines_cb(Dwarf_Die *sp_die, void *data) | 529 | static int __die_walk_culines_cb(Dwarf_Die *sp_die, void *data) |