Skip to contentSkip to conversation

perf annotate: Improve error message for symbol filter

PATCH New Namhyung Kim 1 participant 1 message Jul 6, 2016 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf annotate: Improve error message for symbol filter

When symbol filter is given and it doesn't have a sample, the error message is a bit confusing.

Before:

  $ perf annotate --stdio non_existing_function
  Error:
  The perf.data file has no samples!

After:

  $ perf annotate --stdio non_existing_function
  Error:
  The non_existing_function symbol has no samples!
---
 tools/perf/builtin-annotate.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/perf/builtin-annotate.c +7 -1
index 9c1034d81b4f..ba8a75ec5801 100644
@@ -256,7 +256,13 @@ static int __cmd_annotate(struct perf_annotate *ann)
 	}
 
 	if (total_nr_samples == 0) {
-		ui__error("The %s file has no samples!\n", session->file->path);
+		if (ann->sym_hist_filter) {
+			ui__error("The %s symbol has no samples!\n",
+				  ann->sym_hist_filter);
+		} else {
+			ui__error("The %s file has no samples!\n",
+				  session->file->path);
+		}
 		goto out;
 	}
 
Signature · 1 line
2.8.0