Re: [PATCH 2/3] perf probe: Add flag for options when showing variables

From: Masami Hiramatsu
Date: Fri May 08 2015 - 09:16:11 EST


On 2015/05/08 21:23, He Kuang wrote:
> Change current boolean flag 'externs' to unsigned long 'var_flags' for
> more options related to variables. These options work with --vars only.

NAK, please check my latest patch.

https://lkml.org/lkml/2015/5/7/1024

If you need to add some configurations, please considering to add something
on probe_conf to pass.

Thanks,

>
> Signed-off-by: He Kuang <hekuang@xxxxxxxxxx>
> ---
> tools/perf/builtin-probe.c | 8 +++++++-
> tools/perf/util/probe-event.c | 12 ++++++------
> tools/perf/util/probe-event.h | 3 ++-
> tools/perf/util/probe-finder.c | 6 +++---
> tools/perf/util/probe-finder.h | 9 +++++++--
> 5 files changed, 25 insertions(+), 13 deletions(-)
>
> diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> index 9c4cf5e..19ebe93 100644
> --- a/tools/perf/builtin-probe.c
> +++ b/tools/perf/builtin-probe.c
> @@ -472,18 +472,24 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
> pr_err_with_code(" Error: Failed to show lines.", ret);
> return ret;
> case 'V':
> + {
> + unsigned long var_flags;
> +
> if (!params.filter)
> params.filter = strfilter__new(DEFAULT_VAR_FILTER,
> NULL);
>
> + var_flags = params.show_ext_vars << VAR_FLAGS_EXTERN;
> +
> ret = show_available_vars(params.events, params.nevents,
> params.max_probe_points,
> params.target,
> params.filter,
> - params.show_ext_vars);
> + var_flags);
> if (ret < 0)
> pr_err_with_code(" Error: Failed to show vars.", ret);
> return ret;
> + }
> #endif
> case 'd':
> ret = del_perf_probe_events(params.filter);
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 37a3a8b..4859656 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -824,7 +824,7 @@ int show_line_range(struct line_range *lr, const char *module, bool user)
> static int show_available_vars_at(struct debuginfo *dinfo,
> struct perf_probe_event *pev,
> int max_vls, struct strfilter *_filter,
> - bool externs, const char *target)
> + unsigned long var_flags, const char *target)
> {
> char *buf;
> int ret, i, nvars;
> @@ -839,12 +839,12 @@ static int show_available_vars_at(struct debuginfo *dinfo,
> pr_debug("Searching variables at %s\n", buf);
>
> ret = debuginfo__find_available_vars_at(dinfo, pev, &vls,
> - max_vls, externs);
> + max_vls, var_flags);
> if (!ret) { /* Not found, retry with an alternative */
> ret = get_alternative_probe_event(dinfo, pev, &tmp, target);
> if (!ret) {
> ret = debuginfo__find_available_vars_at(dinfo, pev,
> - &vls, max_vls, externs);
> + &vls, max_vls, var_flags);
> /* Release the old probe_point */
> clear_perf_probe_point(&tmp);
> }
> @@ -892,7 +892,7 @@ end:
> /* Show available variables on given probe point */
> int show_available_vars(struct perf_probe_event *pevs, int npevs,
> int max_vls, const char *module,
> - struct strfilter *_filter, bool externs)
> + struct strfilter *_filter, unsigned long var_flags)
> {
> int i, ret = 0;
> struct debuginfo *dinfo;
> @@ -911,7 +911,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs,
>
> for (i = 0; i < npevs && ret >= 0; i++)
> ret = show_available_vars_at(dinfo, &pevs[i], max_vls, _filter,
> - externs, module);
> + var_flags, module);
>
> debuginfo__delete(dinfo);
> out:
> @@ -954,7 +954,7 @@ int show_available_vars(struct perf_probe_event *pevs __maybe_unused,
> int npevs __maybe_unused, int max_vls __maybe_unused,
> const char *module __maybe_unused,
> struct strfilter *filter __maybe_unused,
> - bool externs __maybe_unused)
> + unsigned long var_flags __maybe_unused)
> {
> pr_warning("Debuginfo-analysis is not supported.\n");
> return -ENOSYS;
> diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
> index e10aedc..637b59e 100644
> --- a/tools/perf/util/probe-event.h
> +++ b/tools/perf/util/probe-event.h
> @@ -132,7 +132,8 @@ extern int show_line_range(struct line_range *lr, const char *module,
> bool user);
> extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
> int max_probe_points, const char *module,
> - struct strfilter *filter, bool externs);
> + struct strfilter *filter,
> + unsigned long var_flags);
> extern int show_available_funcs(const char *module, struct strfilter *filter,
> bool user);
> bool arch__prefers_symtab(void);
> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> index 7b645ff40..6bbdf3f 100644
> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -1305,7 +1305,7 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
> die_find_child(sc_die, collect_variables_cb, (void *)af, &die_mem);
>
> /* Find external variables */
> - if (!af->externs)
> + if (!test_bit(VAR_FLAGS_EXTERN, &af->var_flags))
> goto out;
> /* Don't need to search child DIE for externs. */
> af->child = false;
> @@ -1328,12 +1328,12 @@ out:
> int debuginfo__find_available_vars_at(struct debuginfo *dbg,
> struct perf_probe_event *pev,
> struct variable_list **vls,
> - int max_vls, bool externs)
> + int max_vls, unsigned long var_flags)
> {
> struct available_var_finder af = {
> .pf = {.pev = pev, .callback = add_available_vars},
> .mod = dbg->mod,
> - .max_vls = max_vls, .externs = externs};
> + .max_vls = max_vls, .var_flags = var_flags};
> int ret;
>
> /* Allocate result vls array */
> diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
> index f53553d..95bb79d 100644
> --- a/tools/perf/util/probe-finder.h
> +++ b/tools/perf/util/probe-finder.h
> @@ -10,6 +10,10 @@
> #define MAX_PROBES 128
> #define MAX_PROBE_ARGS 128
>
> +enum var_flags_bits {
> + VAR_FLAGS_EXTERN
> +};
> +
> #define PROBE_ARG_VARS "$vars"
> #define PROBE_ARG_PARAMS "$params"
>
> @@ -56,7 +60,8 @@ extern int debuginfo__find_line_range(struct debuginfo *dbg,
> extern int debuginfo__find_available_vars_at(struct debuginfo *dbg,
> struct perf_probe_event *pev,
> struct variable_list **vls,
> - int max_points, bool externs);
> + int max_points,
> + unsigned long var_flags);
>
> /* Find a src file from a DWARF tag path */
> int get_real_path(const char *raw_path, const char *comp_dir,
> @@ -99,7 +104,7 @@ struct available_var_finder {
> 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 */
> + unsigned long var_flags; /* Variable flags */
> bool child; /* Search child scopes */
> };
>
>


--
Masami HIRAMATSU
Linux Technology Research Center, System Productivity Research Dept.
Center for Technology Innovation - Systems Engineering
Hitachi, Ltd., Research & Development Group
E-mail: masami.hiramatsu.pt@xxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/