History

perf probe: Support global variables

Allow users to set external defined global variables as event arguments (e.g. jiffies).

Masami Hiramatsu committed 16 years ago

Commit 632941c1 parent 378eeaa1 file · +17 −8Browse files

Unified · Split

tools/perf/util/probe-finder.c+17−8
@@ -406,6 +406,9 @@ static int convert_variable_location(Dwarf_Die *vr_die, struct probe_finder *pf) · 405 unmodified lines
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) · 5 unmodified lines
417 }420 }
418 421
419 if (op->atom == DW_OP_addr) {422 if (op->atom == DW_OP_addr) {
423static_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) · 323 unmodified lines
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 else761 goto found;
755 ret = -ENOENT;762 }
763 }
764 if (scopes)
756 free(scopes);765 free(scopes);
757 } else766 ret = -ENOENT;
758 ret = -ENOENT;
759 }767 }
768found:
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);