summaryrefslogtreecommitdiff
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-09-08 22:58:20 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-09-14 18:50:21 +0300
commitb699869285c4f6949f281ea57ac35ea9b9c6f467 (patch)
tree24f5f5f14f02dc35e19abc158478ecafda6a9179 /tools/perf/util/header.c
parenteebd0bfca5cb83f6e1ef0d872a16d45af0422114 (diff)
downloadlinux-b699869285c4f6949f281ea57ac35ea9b9c6f467.tar.xz
perf env: Adopt perf_header__set_cmdline
Move this from two globals to perf_env global, that eventually will be just perf_header->env or something else, to ease the refactoring series, leave it as a global and go on reading more of its fields, not as part of the header writing process but as a perf_env init one that will be used for perf.data-less situations. Tested-by: Wang Nan <wangnan0@huawei.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-2j78tdf8zn1ci0y6ji15bifj@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c44
1 files changed, 5 insertions, 39 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 8fd7b7de1acd..151b8310ac70 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -24,9 +24,6 @@
#include "build-id.h"
#include "data.h"
-static u32 header_argc;
-static const char **header_argv;
-
/*
* magic2 = "PERFILE2"
* must be a numerical value to let the endianness
@@ -138,37 +135,6 @@ static char *do_read_string(int fd, struct perf_header *ph)
return NULL;
}
-int
-perf_header__set_cmdline(int argc, const char **argv)
-{
- int i;
-
- /*
- * If header_argv has already been set, do not override it.
- * This allows a command to set the cmdline, parse args and
- * then call another builtin function that implements a
- * command -- e.g, cmd_kvm calling cmd_record.
- */
- if (header_argv)
- return 0;
-
- header_argc = (u32)argc;
-
- /* do not include NULL termination */
- header_argv = calloc(argc, sizeof(char *));
- if (!header_argv)
- return -ENOMEM;
-
- /*
- * must copy argv contents because it gets moved
- * around during option parsing
- */
- for (i = 0; i < argc ; i++)
- header_argv[i] = argv[i];
-
- return 0;
-}
-
static int write_tracing_data(int fd, struct perf_header *h __maybe_unused,
struct perf_evlist *evlist)
{
@@ -405,8 +371,8 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused,
{
char buf[MAXPATHLEN];
char proc[32];
- u32 i, n;
- int ret;
+ u32 n;
+ int i, ret;
/*
* actual atual path to perf binary
@@ -420,7 +386,7 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused,
buf[ret] = '\0';
/* account for binary path */
- n = header_argc + 1;
+ n = perf_env.nr_cmdline + 1;
ret = do_write(fd, &n, sizeof(n));
if (ret < 0)
@@ -430,8 +396,8 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused,
if (ret < 0)
return ret;
- for (i = 0 ; i < header_argc; i++) {
- ret = do_write_string(fd, header_argv[i]);
+ for (i = 0 ; i < perf_env.nr_cmdline; i++) {
+ ret = do_write_string(fd, perf_env.cmdline_argv[i]);
if (ret < 0)
return ret;
}