Skip to content

Commit

Permalink
perf tools: Add --buildid-dir option to set cache directory
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Dec 9, 2014
1 parent eec5a68 commit 99ce8e9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions tools/perf/Documentation/perf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ OPTIONS
--debug verbose # sets verbose = 1
--debug verbose=2 # sets verbose = 2

--buildid-dir::
Setup buildid cache directory. It has higher priority than
buildid.dir config file option.

DESCRIPTION
-----------
Performance counters for Linux are a new kernel-based subsystem
Expand Down
14 changes: 12 additions & 2 deletions tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
*envchanged = 1;
(*argv)++;
(*argc)--;
} else if (!strcmp(cmd, "--buildid-dir")) {
if (*argc < 2) {
fprintf(stderr, "No directory given for --buildid-dir.\n");
usage(perf_usage_string);
}
set_buildid_dir((*argv)[1]);
if (envchanged)
*envchanged = 1;
(*argv)++;
(*argc)--;
} else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) {
perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR));
fprintf(stderr, "dir: %s\n", debugfs_mountpoint);
Expand Down Expand Up @@ -499,7 +509,7 @@ int main(int argc, const char **argv)
}
if (!prefixcmp(cmd, "trace")) {
#ifdef HAVE_LIBAUDIT_SUPPORT
set_buildid_dir();
set_buildid_dir(NULL);
setup_path();
argv[0] = "trace";
return cmd_trace(argc, argv, NULL);
Expand All @@ -514,7 +524,7 @@ int main(int argc, const char **argv)
argc--;
handle_options(&argv, &argc, NULL);
commit_pager_choice();
set_buildid_dir();
set_buildid_dir(NULL);

if (argc > 0) {
if (!prefixcmp(argv[0], "--"))
Expand Down
8 changes: 5 additions & 3 deletions tools/perf/util/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,14 @@ static void check_buildid_dir_config(void)
perf_config(buildid_dir_command_config, &c);
}

void set_buildid_dir(void)
void set_buildid_dir(const char *dir)
{
buildid_dir[0] = '\0';
if (dir)
scnprintf(buildid_dir, MAXPATHLEN-1, "%s", dir);

/* try config file */
check_buildid_dir_config();
if (buildid_dir[0] == '\0')
check_buildid_dir_config();

/* default to $HOME/.debug */
if (buildid_dir[0] == '\0') {
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN);

extern int prefixcmp(const char *str, const char *prefix);
extern void set_buildid_dir(void);
extern void set_buildid_dir(const char *dir);

static inline const char *skip_prefix(const char *str, const char *prefix)
{
Expand Down

0 comments on commit 99ce8e9

Please sign in to comment.