aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-finder.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2010-04-12 13:16:53 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-04-14 16:26:04 -0400
commit48481938b02471d505296d7557ed296eb093d496 (patch)
tree7549d861d76621d1e3d2ddd75eae4575901f1fd0 /tools/perf/util/probe-finder.c
parentfcd1498405c2c88ac632e7c3c3fce3213d9196db (diff)
perf probe: Support argument name
Set given names to event arguments. The syntax is same as kprobe-tracer, you can add 'NAME=' right before each argument. e.g. ./perf probe vfs_read foo=file then, 'foo' is set to the argument name as below. ./perf probe -l probe:vfs_read (on vfs_read@linux-2.6-tip/fs/read_write.c with foo) Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <20100412171653.3790.74624.stgit@localhost6.localdomain6> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.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.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index a8513772df08..105e95c95eeb 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -484,35 +484,40 @@ static void convert_variable(Dwarf_Die *vr_die, struct probe_finder *pf)
484 convert_location(expr, pf); 484 convert_location(expr, pf);
485 485
486 if (pf->pvar->field) 486 if (pf->pvar->field)
487 convert_variable_fields(vr_die, pf->pvar->name, 487 convert_variable_fields(vr_die, pf->pvar->var,
488 pf->pvar->field, &pf->tvar->ref); 488 pf->pvar->field, &pf->tvar->ref);
489 /* *expr will be cached in libdw. Don't free it. */ 489 /* *expr will be cached in libdw. Don't free it. */
490 return ; 490 return ;
491error: 491error:
492 /* TODO: Support const_value */ 492 /* TODO: Support const_value */
493 die("Failed to find the location of %s at this address.\n" 493 die("Failed to find the location of %s at this address.\n"
494 " Perhaps, it has been optimized out.", pf->pvar->name); 494 " Perhaps, it has been optimized out.", pf->pvar->var);
495} 495}
496 496
497/* Find a variable in a subprogram die */ 497/* Find a variable in a subprogram die */
498static void find_variable(Dwarf_Die *sp_die, struct probe_finder *pf) 498static void find_variable(Dwarf_Die *sp_die, struct probe_finder *pf)
499{ 499{
500 Dwarf_Die vr_die; 500 Dwarf_Die vr_die;
501 char buf[128]; 501 char buf[32];
502 502
503 /* TODO: Support struct members and arrays */ 503 /* TODO: Support arrays */
504 if (!is_c_varname(pf->pvar->name)) { 504 if (pf->pvar->name)
505 pf->tvar->name = xstrdup(pf->pvar->name);
506 else {
507 synthesize_perf_probe_arg(pf->pvar, buf, 32);
508 pf->tvar->name = xstrdup(buf);
509 }
510
511 if (!is_c_varname(pf->pvar->var)) {
505 /* Copy raw parameters */ 512 /* Copy raw parameters */
506 pf->tvar->value = xstrdup(pf->pvar->name); 513 pf->tvar->value = xstrdup(pf->pvar->var);
507 } else { 514 } else {
508 synthesize_perf_probe_arg(pf->pvar, buf, 128);
509 pf->tvar->name = xstrdup(buf);
510 pr_debug("Searching '%s' variable in context.\n", 515 pr_debug("Searching '%s' variable in context.\n",
511 pf->pvar->name); 516 pf->pvar->var);
512 /* Search child die for local variables and parameters. */ 517 /* Search child die for local variables and parameters. */
513 if (!die_find_variable(sp_die, pf->pvar->name, &vr_die)) 518 if (!die_find_variable(sp_die, pf->pvar->var, &vr_die))
514 die("Failed to find '%s' in this function.", 519 die("Failed to find '%s' in this function.",
515 pf->pvar->name); 520 pf->pvar->var);
516 convert_variable(&vr_die, pf); 521 convert_variable(&vr_die, pf);
517 } 522 }
518} 523}