Skip to content

Commit

Permalink
perf probe: Fix error message for failing to find line range
Browse files Browse the repository at this point in the history
With --lines option, if perf-probe fails to find the specified line, it
warns as "Debuginfo analysis failed." but this misleads user as the
debuginfo is broken.

Fix this message to "Specified source line(LINESPEC) is not found." so
that user can understand the error correctly.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: Dima Kogan <dima@secretsauce.net>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://lore.kernel.org/r/173099113381.2431889.16263147678401426107.stgit@mhiramat.roam.corp.google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Masami Hiramatsu (Google) authored and Arnaldo Carvalho de Melo committed Nov 14, 2024
1 parent fe4f9b4 commit e7c70ee
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,17 @@ static int _show_one_line(FILE *fp, int l, bool skip, bool show_num)
return rv;
}

static int sprint_line_description(char *sbuf, size_t size, struct line_range *lr)
{
if (!lr->function)
return snprintf(sbuf, size, "file: %s, line: %d", lr->file, lr->start);

if (lr->file)
return snprintf(sbuf, size, "function: %s, file:%s, line: %d", lr->function, lr->file, lr->start);

return snprintf(sbuf, size, "function: %s, line:%d", lr->function, lr->start);
}

#define show_one_line_with_num(f,l) _show_one_line(f,l,false,true)
#define show_one_line(f,l) _show_one_line(f,l,false,false)
#define skip_one_line(f,l) _show_one_line(f,l,true,false)
Expand Down Expand Up @@ -1071,14 +1082,17 @@ static int __show_line_range(struct line_range *lr, const char *module,
ret = get_alternative_line_range(dinfo, lr, module, user);
if (!ret)
ret = debuginfo__find_line_range(dinfo, lr);
else /* Ignore error, we just failed to find it. */
ret = -ENOENT;
}
if (dinfo->build_id) {
build_id__init(&bid, dinfo->build_id, BUILD_ID_SIZE);
build_id__sprintf(&bid, sbuild_id);
}
debuginfo__delete(dinfo);
if (ret == 0 || ret == -ENOENT) {
pr_warning("Specified source line is not found.\n");
sprint_line_description(sbuf, sizeof(sbuf), lr);
pr_warning("Specified source line(%s) is not found.\n", sbuf);
return -ENOENT;
} else if (ret < 0) {
pr_warning("Debuginfo analysis failed.\n");
Expand Down

0 comments on commit e7c70ee

Please sign in to comment.