From 6e7107311eea70d7b762ea9560b178a644febd1e Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Thu, 21 Oct 2010 19:13:16 +0900 Subject: [PATCH] --- yaml --- r: 218643 b: refs/heads/master c: 632941c4f8fbd5b90dcb1672cd0422dfd7332bc9 h: refs/heads/master i: 218641: f05d4e14026e7e2b791d255e953809e1ab7c41e6 218639: 9e358ef5e52491d7ed268e18ddfe261ab8db3a66 v: v3 --- [refs] | 2 +- trunk/tools/perf/util/probe-finder.c | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index 773144d8cdc9..bb69c54f36c2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 378eeaad3e1cfea7f6614018fb335de93df2ba1f +refs/heads/master: 632941c4f8fbd5b90dcb1672cd0422dfd7332bc9 diff --git a/trunk/tools/perf/util/probe-finder.c b/trunk/tools/perf/util/probe-finder.c index abcaec555204..c6fe80ebb262 100644 --- a/trunk/tools/perf/util/probe-finder.c +++ b/trunk/tools/perf/util/probe-finder.c @@ -406,6 +406,9 @@ static int convert_variable_location(Dwarf_Die *vr_die, struct probe_finder *pf) struct probe_trace_arg *tvar = pf->tvar; int ret; + if (dwarf_attr(vr_die, DW_AT_external, &attr) != NULL) + goto static_var; + /* TODO: handle more than 1 exprs */ if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL || 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) } if (op->atom == DW_OP_addr) { +static_var: /* Static variables on memory (not stack), make @varname */ ret = strlen(dwarf_diename(vr_die)); tvar->value = zalloc(ret + 2); @@ -746,17 +750,22 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf) else { /* Search upper class */ nscopes = dwarf_getscopes_die(sp_die, &scopes); - if (nscopes > 0) { - ret = dwarf_getscopevar(scopes, nscopes, pf->pvar->var, - 0, NULL, 0, 0, &vr_die); - if (ret >= 0) + while (nscopes-- > 1) { + pr_debug("Searching variables in %s\n", + dwarf_diename(&scopes[nscopes])); + /* We should check this scope, so give dummy address */ + if (die_find_variable_at(&scopes[nscopes], + pf->pvar->var, 0, + &vr_die)) { ret = convert_variable(&vr_die, pf); - else - ret = -ENOENT; + goto found; + } + } + if (scopes) free(scopes); - } else - ret = -ENOENT; + ret = -ENOENT; } +found: if (ret < 0) pr_warning("Failed to find '%s' in this function.\n", pf->pvar->var);