or
'perf probe' --line='FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]'
or
-'perf probe' --vars='PROBEPOINT'
+'perf probe' [--externs] --vars='PROBEPOINT'
DESCRIPTION
-----------
Show available local variables at given probe point. The argument
syntax is same as PROBE SYNTAX, but NO ARGs.
+--externs::
+ (Only for --vars) Show external defined variables in addition to local
+ variables.
+
-f::
--force::
Forcibly add events with existing name.
bool force_add;
bool show_lines;
bool show_vars;
+ bool show_ext_vars;
bool mod_events;
int nevents;
struct perf_probe_event events[MAX_PROBES];
"perf probe --list",
#ifdef DWARF_SUPPORT
"perf probe --line 'LINEDESC'",
- "perf probe --vars 'PROBEPOINT'",
+ "perf probe [--externs] --vars 'PROBEPOINT'",
#endif
NULL
};
OPT_CALLBACK('V', "vars", NULL,
"FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT",
"Show accessible variables on PROBEDEF", opt_show_vars),
+ OPT_BOOLEAN('\0', "externs", ¶ms.show_ext_vars,
+ "Show external variables too (with --vars only)"),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
OPT_STRING('s', "source", &symbol_conf.source_prefix,
usage_with_options(probe_usage, options);
}
ret = show_available_vars(params.events, params.nevents,
- params.max_probe_points);
+ params.max_probe_points,
+ params.show_ext_vars);
if (ret < 0)
pr_err(" Error: Failed to show vars. (%d)\n", ret);
return ret;
}
static int show_available_vars_at(int fd, struct perf_probe_event *pev,
- int max_vls)
+ int max_vls, bool externs)
{
char *buf;
int ret, i;
return -EINVAL;
pr_debug("Searching variables at %s\n", buf);
- ret = find_available_vars_at(fd, pev, &vls, max_vls);
+ ret = find_available_vars_at(fd, pev, &vls, max_vls, externs);
if (ret > 0) {
/* Some variables were found */
fprintf(stdout, "Available variables at %s\n", buf);
/* Show available variables on given probe point */
int show_available_vars(struct perf_probe_event *pevs, int npevs,
- int max_vls)
+ int max_vls, bool externs)
{
int i, fd, ret = 0;
setup_pager();
for (i = 0; i < npevs && ret >= 0; i++)
- ret = show_available_vars_at(fd, &pevs[i], max_vls);
+ ret = show_available_vars_at(fd, &pevs[i], max_vls, externs);
close(fd);
return ret;
extern int show_perf_probe_events(void);
extern int show_line_range(struct line_range *lr);
extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
- int max_probe_points);
+ int max_probe_points, bool externs);
/* Maximum index number of event-name postfix */
af->pf.fb_ops, NULL);
if (ret == 0) {
ret = die_get_varname(die_mem, buf, MAX_VAR_LEN);
+ pr_debug2("Add new var: %s\n", buf);
if (ret > 0)
strlist__add(vl->vars, buf);
}
}
- if (dwarf_haspc(die_mem, af->pf.addr))
+ if (af->child && dwarf_haspc(die_mem, af->pf.addr))
return DIE_FIND_CB_CONTINUE;
else
return DIE_FIND_CB_SIBLING;
struct available_var_finder *af =
container_of(pf, struct available_var_finder, pf);
struct variable_list *vl;
- Dwarf_Die die_mem;
- int ret;
+ Dwarf_Die die_mem, *scopes = NULL;
+ int ret, nscopes;
/* Check number of tevs */
if (af->nvls == af->max_vls) {
vl->vars = strlist__new(true, NULL);
if (vl->vars == NULL)
return -ENOMEM;
+ af->child = true;
die_find_child(sp_die, collect_variables_cb, (void *)af, &die_mem);
+ /* Find external variables */
+ if (!af->externs)
+ goto out;
+ /* Don't need to search child DIE for externs. */
+ af->child = false;
+ nscopes = dwarf_getscopes_die(sp_die, &scopes);
+ while (nscopes-- > 1)
+ die_find_child(&scopes[nscopes], collect_variables_cb,
+ (void *)af, &die_mem);
+ if (scopes)
+ free(scopes);
+
+out:
if (strlist__empty(vl->vars)) {
strlist__delete(vl->vars);
vl->vars = NULL;
/* Find available variables at given probe point */
int find_available_vars_at(int fd, struct perf_probe_event *pev,
- struct variable_list **vls, int max_vls)
+ struct variable_list **vls, int max_vls,
+ bool externs)
{
struct available_var_finder af = {
.pf = {.pev = pev, .callback = add_available_vars},
- .max_vls = max_vls};
+ .max_vls = max_vls, .externs = externs};
int ret;
/* Allocate result vls array */
/* Find available variables */
extern int find_available_vars_at(int fd, struct perf_probe_event *pev,
- struct variable_list **vls, int max_points);
+ struct variable_list **vls, int max_points,
+ bool externs);
#include <dwarf.h>
#include <libdw.h>
struct variable_list *vls; /* Found variable lists */
int nvls; /* Number of variable lists */
int max_vls; /* Max no. of variable lists */
+ bool externs; /* Find external vars too */
+ bool child; /* Search child scopes */
};
struct line_finder {