aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2016-01-09 05:16:29 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-01-12 10:42:08 -0500
commit34b7b0f95d41d2351a080e774d71085171db90e6 (patch)
tree065cfa3b53e86cd17ba2b4b13fc0179e58bd9fe4 /tools
parent090cff3eae8f02395009972d01b5dfdb95bcc327 (diff)
perf tools: Fallback to srcdir/Documentation/tips.txt
Some people don't install perf, but just use compiled version in the source. Fallback to lookup the source directory for those poor guys. :) Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1452334589-8782-4-git-send-email-namhyung@kernel.org [ Make perf_tip() return NULL for ENOENT, making the fallback to really take place ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-report.c10
-rw-r--r--tools/perf/util/util.c11
2 files changed, 15 insertions, 6 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d5a42ee12529..2bf537f190a0 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -28,6 +28,7 @@
28#include "util/tool.h" 28#include "util/tool.h"
29 29
30#include <subcmd/parse-options.h> 30#include <subcmd/parse-options.h>
31#include <subcmd/exec-cmd.h>
31#include "util/parse-events.h" 32#include "util/parse-events.h"
32 33
33#include "util/thread.h" 34#include "util/thread.h"
@@ -433,7 +434,14 @@ static int report__browse_hists(struct report *rep)
433 int ret; 434 int ret;
434 struct perf_session *session = rep->session; 435 struct perf_session *session = rep->session;
435 struct perf_evlist *evlist = session->evlist; 436 struct perf_evlist *evlist = session->evlist;
436 const char *help = perf_tip(TIPDIR); 437 const char *help = perf_tip(system_path(TIPDIR));
438
439 if (help == NULL) {
440 /* fallback for people who don't install perf ;-) */
441 help = perf_tip(DOCDIR);
442 if (help == NULL)
443 help = "Cannot load tips.txt file, please install perf!";
444 }
437 445
438 switch (use_browser) { 446 switch (use_browser) {
439 case 1: 447 case 1:
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 88b8f8d21f58..ead9509835d2 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -17,7 +17,6 @@
17#include <unistd.h> 17#include <unistd.h>
18#include "callchain.h" 18#include "callchain.h"
19#include "strlist.h" 19#include "strlist.h"
20#include <subcmd/exec-cmd.h>
21 20
22struct callchain_param callchain_param = { 21struct callchain_param callchain_param = {
23 .mode = CHAIN_GRAPH_ABS, 22 .mode = CHAIN_GRAPH_ABS,
@@ -672,14 +671,16 @@ const char *perf_tip(const char *dirpath)
672 struct str_node *node; 671 struct str_node *node;
673 char *tip = NULL; 672 char *tip = NULL;
674 struct strlist_config conf = { 673 struct strlist_config conf = {
675 .dirname = system_path(dirpath) , 674 .dirname = dirpath,
675 .file_only = true,
676 }; 676 };
677 677
678 tips = strlist__new("tips.txt", &conf); 678 tips = strlist__new("tips.txt", &conf);
679 if (tips == NULL || strlist__nr_entries(tips) == 1) { 679 if (tips == NULL)
680 tip = (char *)"Cannot find tips.txt file"; 680 return errno == ENOENT ? NULL : "Tip: get more memory! ;-p";
681
682 if (strlist__nr_entries(tips) == 0)
681 goto out; 683 goto out;
682 }
683 684
684 node = strlist__entry(tips, random() % strlist__nr_entries(tips)); 685 node = strlist__entry(tips, random() % strlist__nr_entries(tips));
685 if (asprintf(&tip, "Tip: %s", node->s) < 0) 686 if (asprintf(&tip, "Tip: %s", node->s) < 0)