diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-12-01 14:06:24 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-12-09 07:14:35 -0500 |
commit | 99ce8e9fce99147f865cda8a8e471900518c9a49 (patch) | |
tree | 3df52ba599da96ec305c0437c5324caee2359e8d /tools/perf | |
parent | eec5a688f426d6fe4097feb0b916ad41803d2ebb (diff) |
perf tools: Add --buildid-dir option to set cache directory
Adding --buildid-dir to be able to set specific cache directory. It's
going to be handy for buildid tests coming in shortly.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1417460789-13874-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/Documentation/perf.txt | 4 | ||||
-rw-r--r-- | tools/perf/perf.c | 14 | ||||
-rw-r--r-- | tools/perf/util/config.c | 8 | ||||
-rw-r--r-- | tools/perf/util/util.h | 2 |
4 files changed, 22 insertions, 6 deletions
diff --git a/tools/perf/Documentation/perf.txt b/tools/perf/Documentation/perf.txt index d240bb2e5b22..1e8e400b4493 100644 --- a/tools/perf/Documentation/perf.txt +++ b/tools/perf/Documentation/perf.txt | |||
@@ -18,6 +18,10 @@ OPTIONS | |||
18 | --debug verbose # sets verbose = 1 | 18 | --debug verbose # sets verbose = 1 |
19 | --debug verbose=2 # sets verbose = 2 | 19 | --debug verbose=2 # sets verbose = 2 |
20 | 20 | ||
21 | --buildid-dir:: | ||
22 | Setup buildid cache directory. It has higher priority than | ||
23 | buildid.dir config file option. | ||
24 | |||
21 | DESCRIPTION | 25 | DESCRIPTION |
22 | ----------- | 26 | ----------- |
23 | Performance counters for Linux are a new kernel-based subsystem | 27 | Performance counters for Linux are a new kernel-based subsystem |
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 452a8474d29d..3700a7faca6c 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -200,6 +200,16 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) | |||
200 | *envchanged = 1; | 200 | *envchanged = 1; |
201 | (*argv)++; | 201 | (*argv)++; |
202 | (*argc)--; | 202 | (*argc)--; |
203 | } else if (!strcmp(cmd, "--buildid-dir")) { | ||
204 | if (*argc < 2) { | ||
205 | fprintf(stderr, "No directory given for --buildid-dir.\n"); | ||
206 | usage(perf_usage_string); | ||
207 | } | ||
208 | set_buildid_dir((*argv)[1]); | ||
209 | if (envchanged) | ||
210 | *envchanged = 1; | ||
211 | (*argv)++; | ||
212 | (*argc)--; | ||
203 | } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) { | 213 | } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) { |
204 | perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR)); | 214 | perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR)); |
205 | fprintf(stderr, "dir: %s\n", debugfs_mountpoint); | 215 | fprintf(stderr, "dir: %s\n", debugfs_mountpoint); |
@@ -499,7 +509,7 @@ int main(int argc, const char **argv) | |||
499 | } | 509 | } |
500 | if (!prefixcmp(cmd, "trace")) { | 510 | if (!prefixcmp(cmd, "trace")) { |
501 | #ifdef HAVE_LIBAUDIT_SUPPORT | 511 | #ifdef HAVE_LIBAUDIT_SUPPORT |
502 | set_buildid_dir(); | 512 | set_buildid_dir(NULL); |
503 | setup_path(); | 513 | setup_path(); |
504 | argv[0] = "trace"; | 514 | argv[0] = "trace"; |
505 | return cmd_trace(argc, argv, NULL); | 515 | return cmd_trace(argc, argv, NULL); |
@@ -514,7 +524,7 @@ int main(int argc, const char **argv) | |||
514 | argc--; | 524 | argc--; |
515 | handle_options(&argv, &argc, NULL); | 525 | handle_options(&argv, &argc, NULL); |
516 | commit_pager_choice(); | 526 | commit_pager_choice(); |
517 | set_buildid_dir(); | 527 | set_buildid_dir(NULL); |
518 | 528 | ||
519 | if (argc > 0) { | 529 | if (argc > 0) { |
520 | if (!prefixcmp(argv[0], "--")) | 530 | if (!prefixcmp(argv[0], "--")) |
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index c802236b2bfe..e18f653cd7db 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c | |||
@@ -539,12 +539,14 @@ static void check_buildid_dir_config(void) | |||
539 | perf_config(buildid_dir_command_config, &c); | 539 | perf_config(buildid_dir_command_config, &c); |
540 | } | 540 | } |
541 | 541 | ||
542 | void set_buildid_dir(void) | 542 | void set_buildid_dir(const char *dir) |
543 | { | 543 | { |
544 | buildid_dir[0] = '\0'; | 544 | if (dir) |
545 | scnprintf(buildid_dir, MAXPATHLEN-1, "%s", dir); | ||
545 | 546 | ||
546 | /* try config file */ | 547 | /* try config file */ |
547 | check_buildid_dir_config(); | 548 | if (buildid_dir[0] == '\0') |
549 | check_buildid_dir_config(); | ||
548 | 550 | ||
549 | /* default to $HOME/.debug */ | 551 | /* default to $HOME/.debug */ |
550 | if (buildid_dir[0] == '\0') { | 552 | if (buildid_dir[0] == '\0') { |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 419bee030f83..abc445ee4f60 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -153,7 +153,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))) | |||
153 | extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN); | 153 | extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN); |
154 | 154 | ||
155 | extern int prefixcmp(const char *str, const char *prefix); | 155 | extern int prefixcmp(const char *str, const char *prefix); |
156 | extern void set_buildid_dir(void); | 156 | extern void set_buildid_dir(const char *dir); |
157 | 157 | ||
158 | static inline const char *skip_prefix(const char *str, const char *prefix) | 158 | static inline const char *skip_prefix(const char *str, const char *prefix) |
159 | { | 159 | { |