Browse Source

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements from Arnaldo Carvalho de Melo:

User visible:

  * Improve 'perf probe' error messages, moving some diagnostic messages to
    only appear in --verbose mode and fixing up some error reporting related
    to variables and struct members. (Masami Hiramatsu)

  * Reflow 'perf timechart' man page. (Stanislav Fomichev)

Developer stuff:

  * Be more precise when reporting missing libraries in a static tool build.
    (Arnaldo Carvalho de Melo)

  * Show error messages from the multiple make invoked from 'make build-test'.
    (Arnaldo Carvalho de Melo)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Ingo Molnar 11 years ago
parent
commit
7184062b94

+ 20 - 21
tools/perf/Documentation/perf-timechart.txt

@@ -43,27 +43,6 @@ TIMECHART OPTIONS
 
 
 --symfs=<directory>::
 --symfs=<directory>::
         Look for files with symbols relative to this directory.
         Look for files with symbols relative to this directory.
-
-EXAMPLES
---------
-
-$ perf timechart record git pull
-
-  [ perf record: Woken up 13 times to write data ]
-  [ perf record: Captured and wrote 4.253 MB perf.data (~185801 samples) ]
-
-$ perf timechart
-
-  Written 10.2 seconds of trace to output.svg.
-
-Record system-wide timechart:
-
-  $ perf timechart record
-
-  then generate timechart and highlight 'gcc' tasks:
-
-  $ perf timechart --highlight gcc
-
 -n::
 -n::
 --proc-num::
 --proc-num::
         Print task info for at least given number of tasks.
         Print task info for at least given number of tasks.
@@ -88,6 +67,26 @@ RECORD OPTIONS
 --callchain::
 --callchain::
         Do call-graph (stack chain/backtrace) recording
         Do call-graph (stack chain/backtrace) recording
 
 
+EXAMPLES
+--------
+
+$ perf timechart record git pull
+
+  [ perf record: Woken up 13 times to write data ]
+  [ perf record: Captured and wrote 4.253 MB perf.data (~185801 samples) ]
+
+$ perf timechart
+
+  Written 10.2 seconds of trace to output.svg.
+
+Record system-wide timechart:
+
+  $ perf timechart record
+
+  then generate timechart and highlight 'gcc' tasks:
+
+  $ perf timechart --highlight gcc
+
 SEE ALSO
 SEE ALSO
 --------
 --------
 linkperf:perf-record[1]
 linkperf:perf-record[1]

+ 14 - 9
tools/perf/builtin-probe.c

@@ -288,6 +288,13 @@ static void cleanup_params(void)
 	memset(&params, 0, sizeof(params));
 	memset(&params, 0, sizeof(params));
 }
 }
 
 
+static void pr_err_with_code(const char *msg, int err)
+{
+	pr_err("%s", msg);
+	pr_debug(" Reason: %s (Code: %d)", strerror(-err), err);
+	pr_err("\n");
+}
+
 static int
 static int
 __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 {
 {
@@ -379,7 +386,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 		}
 		}
 		ret = parse_probe_event_argv(argc, argv);
 		ret = parse_probe_event_argv(argc, argv);
 		if (ret < 0) {
 		if (ret < 0) {
-			pr_err("  Error: Parse Error.  (%d)\n", ret);
+			pr_err_with_code("  Error: Command Parse Error.", ret);
 			return ret;
 			return ret;
 		}
 		}
 	}
 	}
@@ -419,8 +426,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 		}
 		}
 		ret = show_perf_probe_events();
 		ret = show_perf_probe_events();
 		if (ret < 0)
 		if (ret < 0)
-			pr_err("  Error: Failed to show event list. (%d)\n",
-			       ret);
+			pr_err_with_code("  Error: Failed to show event list.", ret);
 		return ret;
 		return ret;
 	}
 	}
 	if (params.show_funcs) {
 	if (params.show_funcs) {
@@ -445,8 +451,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 		strfilter__delete(params.filter);
 		strfilter__delete(params.filter);
 		params.filter = NULL;
 		params.filter = NULL;
 		if (ret < 0)
 		if (ret < 0)
-			pr_err("  Error: Failed to show functions."
-			       " (%d)\n", ret);
+			pr_err_with_code("  Error: Failed to show functions.", ret);
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -464,7 +469,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 
 
 		ret = show_line_range(&params.line_range, params.target);
 		ret = show_line_range(&params.line_range, params.target);
 		if (ret < 0)
 		if (ret < 0)
-			pr_err("  Error: Failed to show lines. (%d)\n", ret);
+			pr_err_with_code("  Error: Failed to show lines.", ret);
 		return ret;
 		return ret;
 	}
 	}
 	if (params.show_vars) {
 	if (params.show_vars) {
@@ -485,7 +490,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 		strfilter__delete(params.filter);
 		strfilter__delete(params.filter);
 		params.filter = NULL;
 		params.filter = NULL;
 		if (ret < 0)
 		if (ret < 0)
-			pr_err("  Error: Failed to show vars. (%d)\n", ret);
+			pr_err_with_code("  Error: Failed to show vars.", ret);
 		return ret;
 		return ret;
 	}
 	}
 #endif
 #endif
@@ -493,7 +498,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (params.dellist) {
 	if (params.dellist) {
 		ret = del_perf_probe_events(params.dellist);
 		ret = del_perf_probe_events(params.dellist);
 		if (ret < 0) {
 		if (ret < 0) {
-			pr_err("  Error: Failed to delete events. (%d)\n", ret);
+			pr_err_with_code("  Error: Failed to delete events.", ret);
 			return ret;
 			return ret;
 		}
 		}
 	}
 	}
@@ -504,7 +509,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 					    params.target,
 					    params.target,
 					    params.force_add);
 					    params.force_add);
 		if (ret < 0) {
 		if (ret < 0) {
-			pr_err("  Error: Failed to add events. (%d)\n", ret);
+			pr_err_with_code("  Error: Failed to add events.", ret);
 			return ret;
 			return ret;
 		}
 		}
 	}
 	}

+ 5 - 1
tools/perf/config/Makefile

@@ -299,7 +299,11 @@ else
       NO_LIBUNWIND := 1
       NO_LIBUNWIND := 1
       NO_LIBDW_DWARF_UNWIND := 1
       NO_LIBDW_DWARF_UNWIND := 1
     else
     else
-      msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
+      ifneq ($(filter s% -static%,$(LDFLAGS),),)
+        msg := $(error No static glibc found, please install glibc-static);
+      else
+        msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
+      endif
     endif
     endif
   else
   else
     ifndef NO_LIBDW_DWARF_UNWIND
     ifndef NO_LIBDW_DWARF_UNWIND

+ 2 - 5
tools/perf/tests/make

@@ -205,8 +205,7 @@ $(run):
 	( eval $$cmd ) >> $@ 2>&1; \
 	( eval $$cmd ) >> $@ 2>&1; \
 	echo "  test: $(call test,$@)" >> $@ 2>&1; \
 	echo "  test: $(call test,$@)" >> $@ 2>&1; \
 	$(call test,$@) && \
 	$(call test,$@) && \
-	rm -f $@ \
-	rm -rf $$TMP_DEST
+	rm -rf $@ $$TMP_DEST || (cat $@ ; false)
 
 
 $(run_O):
 $(run_O):
 	$(call clean)
 	$(call clean)
@@ -217,9 +216,7 @@ $(run_O):
 	( eval $$cmd ) >> $@ 2>&1 && \
 	( eval $$cmd ) >> $@ 2>&1 && \
 	echo "  test: $(call test_O,$@)" >> $@ 2>&1; \
 	echo "  test: $(call test_O,$@)" >> $@ 2>&1; \
 	$(call test_O,$@) && \
 	$(call test_O,$@) && \
-	rm -f $@ && \
-	rm -rf $$TMP_O \
-	rm -rf $$TMP_DEST
+	rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false)
 
 
 tarpkg:
 tarpkg:
 	@cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \
 	@cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \

+ 9 - 4
tools/perf/util/probe-event.c

@@ -628,11 +628,11 @@ static int __show_line_range(struct line_range *lr, const char *module)
 
 
 	ret = debuginfo__find_line_range(dinfo, lr);
 	ret = debuginfo__find_line_range(dinfo, lr);
 	debuginfo__delete(dinfo);
 	debuginfo__delete(dinfo);
-	if (ret == 0) {
+	if (ret == 0 || ret == -ENOENT) {
 		pr_warning("Specified source line is not found.\n");
 		pr_warning("Specified source line is not found.\n");
 		return -ENOENT;
 		return -ENOENT;
 	} else if (ret < 0) {
 	} else if (ret < 0) {
-		pr_warning("Debuginfo analysis failed. (%d)\n", ret);
+		pr_warning("Debuginfo analysis failed.\n");
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -641,7 +641,7 @@ static int __show_line_range(struct line_range *lr, const char *module)
 	ret = get_real_path(tmp, lr->comp_dir, &lr->path);
 	ret = get_real_path(tmp, lr->comp_dir, &lr->path);
 	free(tmp);	/* Free old path */
 	free(tmp);	/* Free old path */
 	if (ret < 0) {
 	if (ret < 0) {
-		pr_warning("Failed to find source file. (%d)\n", ret);
+		pr_warning("Failed to find source file path.\n");
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -721,9 +721,14 @@ static int show_available_vars_at(struct debuginfo *dinfo,
 	ret = debuginfo__find_available_vars_at(dinfo, pev, &vls,
 	ret = debuginfo__find_available_vars_at(dinfo, pev, &vls,
 						max_vls, externs);
 						max_vls, externs);
 	if (ret <= 0) {
 	if (ret <= 0) {
-		pr_err("Failed to find variables at %s (%d)\n", buf, ret);
+		if (ret == 0 || ret == -ENOENT) {
+			pr_err("Failed to find the address of %s\n", buf);
+			ret = -ENOENT;
+		} else
+			pr_warning("Debuginfo analysis failed.\n");
 		goto end;
 		goto end;
 	}
 	}
+
 	/* Some variables are found */
 	/* Some variables are found */
 	fprintf(stdout, "Available variables at %s\n", buf);
 	fprintf(stdout, "Available variables at %s\n", buf);
 	for (i = 0; i < ret; i++) {
 	for (i = 0; i < ret; i++) {

+ 7 - 4
tools/perf/util/probe-finder.c

@@ -573,14 +573,13 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
 	if (!die_find_variable_at(sc_die, pf->pvar->var, pf->addr, &vr_die)) {
 	if (!die_find_variable_at(sc_die, pf->pvar->var, pf->addr, &vr_die)) {
 		/* Search again in global variables */
 		/* Search again in global variables */
 		if (!die_find_variable_at(&pf->cu_die, pf->pvar->var, 0, &vr_die))
 		if (!die_find_variable_at(&pf->cu_die, pf->pvar->var, 0, &vr_die))
+			pr_warning("Failed to find '%s' in this function.\n",
+				   pf->pvar->var);
 			ret = -ENOENT;
 			ret = -ENOENT;
 	}
 	}
 	if (ret >= 0)
 	if (ret >= 0)
 		ret = convert_variable(&vr_die, pf);
 		ret = convert_variable(&vr_die, pf);
 
 
-	if (ret < 0)
-		pr_warning("Failed to find '%s' in this function.\n",
-			   pf->pvar->var);
 	return ret;
 	return ret;
 }
 }
 
 
@@ -1281,7 +1280,11 @@ out:
 	return ret;
 	return ret;
 }
 }
 
 
-/* Find available variables at given probe point */
+/*
+ * Find available variables at given probe point
+ * Return the number of found probe points. Return 0 if there is no
+ * matched probe point. Return <0 if an error occurs.
+ */
 int debuginfo__find_available_vars_at(struct debuginfo *dbg,
 int debuginfo__find_available_vars_at(struct debuginfo *dbg,
 				      struct perf_probe_event *pev,
 				      struct perf_probe_event *pev,
 				      struct variable_list **vls,
 				      struct variable_list **vls,