diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2010-10-21 06:13:16 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-10-21 13:58:27 -0400 |
commit | 632941c4f8fbd5b90dcb1672cd0422dfd7332bc9 (patch) | |
tree | 23aa4419c82a10a9a4de2d4672888d64d874b4ec /tools | |
parent | 378eeaad3e1cfea7f6614018fb335de93df2ba1f (diff) |
perf probe: Support global variables
Allow users to set external defined global variables as event arguments (e.g.
jiffies).
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
LKML-Reference: <20101021101316.3542.1999.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')
-rw-r--r-- | tools/perf/util/probe-finder.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index abcaec555204..c6fe80ebb262 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -406,6 +406,9 @@ static int convert_variable_location(Dwarf_Die *vr_die, struct probe_finder *pf) | |||
406 | struct probe_trace_arg *tvar = pf->tvar; | 406 | struct probe_trace_arg *tvar = pf->tvar; |
407 | int ret; | 407 | int ret; |
408 | 408 | ||
409 | if (dwarf_attr(vr_die, DW_AT_external, &attr) != NULL) | ||
410 | goto static_var; | ||
411 | |||
409 | /* TODO: handle more than 1 exprs */ | 412 | /* TODO: handle more than 1 exprs */ |
410 | if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL || | 413 | if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL || |
411 | dwarf_getlocation_addr(&attr, pf->addr, &op, &nops, 1) <= 0 || | 414 | dwarf_getlocation_addr(&attr, pf->addr, &op, &nops, 1) <= 0 || |
@@ -417,6 +420,7 @@ static int convert_variable_location(Dwarf_Die *vr_die, struct probe_finder *pf) | |||
417 | } | 420 | } |
418 | 421 | ||
419 | if (op->atom == DW_OP_addr) { | 422 | if (op->atom == DW_OP_addr) { |
423 | static_var: | ||
420 | /* Static variables on memory (not stack), make @varname */ | 424 | /* Static variables on memory (not stack), make @varname */ |
421 | ret = strlen(dwarf_diename(vr_die)); | 425 | ret = strlen(dwarf_diename(vr_die)); |
422 | tvar->value = zalloc(ret + 2); | 426 | tvar->value = zalloc(ret + 2); |
@@ -746,17 +750,22 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf) | |||
746 | else { | 750 | else { |
747 | /* Search upper class */ | 751 | /* Search upper class */ |
748 | nscopes = dwarf_getscopes_die(sp_die, &scopes); | 752 | nscopes = dwarf_getscopes_die(sp_die, &scopes); |
749 | if (nscopes > 0) { | 753 | while (nscopes-- > 1) { |
750 | ret = dwarf_getscopevar(scopes, nscopes, pf->pvar->var, | 754 | pr_debug("Searching variables in %s\n", |
751 | 0, NULL, 0, 0, &vr_die); | 755 | dwarf_diename(&scopes[nscopes])); |
752 | if (ret >= 0) | 756 | /* We should check this scope, so give dummy address */ |
757 | if (die_find_variable_at(&scopes[nscopes], | ||
758 | pf->pvar->var, 0, | ||
759 | &vr_die)) { | ||
753 | ret = convert_variable(&vr_die, pf); | 760 | ret = convert_variable(&vr_die, pf); |
754 | else | 761 | goto found; |
755 | ret = -ENOENT; | 762 | } |
763 | } | ||
764 | if (scopes) | ||
756 | free(scopes); | 765 | free(scopes); |
757 | } else | 766 | ret = -ENOENT; |
758 | ret = -ENOENT; | ||
759 | } | 767 | } |
768 | found: | ||
760 | if (ret < 0) | 769 | if (ret < 0) |
761 | pr_warning("Failed to find '%s' in this function.\n", | 770 | pr_warning("Failed to find '%s' in this function.\n", |
762 | pf->pvar->var); | 771 | pf->pvar->var); |