Skip to content

Commit e7c70ee

Browse files
mhiramatacmel
authored andcommitted
perf probe: Fix error message for failing to find line range
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 <[email protected]> Cc: Alexander Lobakin <[email protected]> Cc: Dima Kogan <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Przemek Kitszel <[email protected]> Link: https://lore.kernel.org/r/173099113381.2431889.16263147678401426107.stgit@mhiramat.roam.corp.google.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent fe4f9b4 commit e7c70ee

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tools/perf/util/probe-event.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,17 @@ static int _show_one_line(FILE *fp, int l, bool skip, bool show_num)
10391039
return rv;
10401040
}
10411041

1042+
static int sprint_line_description(char *sbuf, size_t size, struct line_range *lr)
1043+
{
1044+
if (!lr->function)
1045+
return snprintf(sbuf, size, "file: %s, line: %d", lr->file, lr->start);
1046+
1047+
if (lr->file)
1048+
return snprintf(sbuf, size, "function: %s, file:%s, line: %d", lr->function, lr->file, lr->start);
1049+
1050+
return snprintf(sbuf, size, "function: %s, line:%d", lr->function, lr->start);
1051+
}
1052+
10421053
#define show_one_line_with_num(f,l) _show_one_line(f,l,false,true)
10431054
#define show_one_line(f,l) _show_one_line(f,l,false,false)
10441055
#define skip_one_line(f,l) _show_one_line(f,l,true,false)
@@ -1071,14 +1082,17 @@ static int __show_line_range(struct line_range *lr, const char *module,
10711082
ret = get_alternative_line_range(dinfo, lr, module, user);
10721083
if (!ret)
10731084
ret = debuginfo__find_line_range(dinfo, lr);
1085+
else /* Ignore error, we just failed to find it. */
1086+
ret = -ENOENT;
10741087
}
10751088
if (dinfo->build_id) {
10761089
build_id__init(&bid, dinfo->build_id, BUILD_ID_SIZE);
10771090
build_id__sprintf(&bid, sbuild_id);
10781091
}
10791092
debuginfo__delete(dinfo);
10801093
if (ret == 0 || ret == -ENOENT) {
1081-
pr_warning("Specified source line is not found.\n");
1094+
sprint_line_description(sbuf, sizeof(sbuf), lr);
1095+
pr_warning("Specified source line(%s) is not found.\n", sbuf);
10821096
return -ENOENT;
10831097
} else if (ret < 0) {
10841098
pr_warning("Debuginfo analysis failed.\n");

0 commit comments

Comments
 (0)