diff options
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r-- | tools/perf/util/util.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index aff0cfd83662..88b8f8d21f58 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -16,6 +16,8 @@ #include <linux/kernel.h> #include <unistd.h> #include "callchain.h" +#include "strlist.h" +#include <subcmd/exec-cmd.h> struct callchain_param callchain_param = { .mode = CHAIN_GRAPH_ABS, @@ -663,3 +665,28 @@ fetch_kernel_version(unsigned int *puint, char *str, *puint = (version << 16) + (patchlevel << 8) + sublevel; return 0; } + +const char *perf_tip(const char *dirpath) +{ + struct strlist *tips; + struct str_node *node; + char *tip = NULL; + struct strlist_config conf = { + .dirname = system_path(dirpath) , + }; + + tips = strlist__new("tips.txt", &conf); + if (tips == NULL || strlist__nr_entries(tips) == 1) { + tip = (char *)"Cannot find tips.txt file"; + goto out; + } + + node = strlist__entry(tips, random() % strlist__nr_entries(tips)); + if (asprintf(&tip, "Tip: %s", node->s) < 0) + tip = (char *)"Tip: get more memory! ;-)"; + +out: + strlist__delete(tips); + + return tip; +} |