[PATCH 06/12] perf, tools, probe: Support a quiet argument for debug info open

From: Andi Kleen
Date: Mon Nov 27 2017 - 19:26:51 EST


From: Andi Kleen <ak@xxxxxxxxxxxxxxx>

Add a extra quiet argument to the debug info open / probe finder
code that allows perf script to make them quieter. Otherwise
we may end up with too many error messages when lots of
instructions fail debug info parsing.

Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
---
tools/perf/util/probe-event.c | 4 ++--
tools/perf/util/probe-finder.c | 19 ++++++++++++-------
tools/perf/util/probe-finder.h | 5 ++++-
3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b7aaf9b2294d..2f9469e862fb 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1071,12 +1071,12 @@ static int show_available_vars_at(struct debuginfo *dinfo,
return -EINVAL;
pr_debug("Searching variables at %s\n", buf);

- ret = debuginfo__find_available_vars_at(dinfo, pev, &vls);
+ ret = debuginfo__find_available_vars_at(dinfo, pev, &vls, false);
if (!ret) { /* Not found, retry with an alternative */
ret = get_alternative_probe_event(dinfo, pev, &tmp);
if (!ret) {
ret = debuginfo__find_available_vars_at(dinfo, pev,
- &vls);
+ &vls, false);
/* Release the old probe_point */
clear_perf_probe_point(&tmp);
}
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 699f29d8a28e..137b2fe71838 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -685,12 +685,14 @@ static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf)
if (!die_is_func_def(sc_die)) {
if (!die_find_realfunc(&pf->cu_die, pf->addr, &pf->sp_die)) {
if (die_find_tailfunc(&pf->cu_die, pf->addr, &pf->sp_die)) {
- pr_warning("Ignoring tail call from %s\n",
+ if (!pf->quiet)
+ pr_warning("Ignoring tail call from %s\n",
dwarf_diename(&pf->sp_die));
return 0;
} else {
- pr_warning("Failed to find probe point in any "
- "functions.\n");
+ if (!pf->quiet)
+ pr_warning("Failed to find probe point in any "
+ "functions.\n");
return -ENOENT;
}
}
@@ -708,8 +710,9 @@ static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf)
if ((dwarf_cfi_addrframe(pf->cfi_eh, pf->addr, &frame) != 0 &&
(dwarf_cfi_addrframe(pf->cfi_dbg, pf->addr, &frame) != 0)) ||
dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) {
- pr_warning("Failed to get call frame on 0x%jx\n",
- (uintmax_t)pf->addr);
+ if (!pf->quiet)
+ pr_warning("Failed to get call frame on 0x%jx\n",
+ (uintmax_t)pf->addr);
free(frame);
return -ENOENT;
}
@@ -1499,10 +1502,12 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
*/
int debuginfo__find_available_vars_at(struct debuginfo *dbg,
struct perf_probe_event *pev,
- struct variable_list **vls)
+ struct variable_list **vls,
+ bool be_quiet)
{
struct available_var_finder af = {
- .pf = {.pev = pev, .callback = add_available_vars},
+ .pf = {.pev = pev, .callback = add_available_vars,
+ .quiet = be_quiet},
.mod = dbg->mod,
.max_vls = probe_conf.max_probes};
int ret;
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index 6368e95a5d16..abcb2262ea72 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -57,7 +57,8 @@ int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr);
/* Find available variables */
int debuginfo__find_available_vars_at(struct debuginfo *dbg,
struct perf_probe_event *pev,
- struct variable_list **vls);
+ struct variable_list **vls,
+ bool quiet);

/* Find a src file from a DWARF tag path */
int get_real_path(const char *raw_path, const char *comp_dir,
@@ -88,6 +89,8 @@ struct probe_finder {
unsigned int machine; /* Target machine arch */
struct perf_probe_arg *pvar; /* Current target variable */
struct probe_trace_arg *tvar; /* Current result variable */
+
+ bool quiet; /* Avoid warnings */
};

struct trace_event_finder {
--
2.13.6