Skip to content

Commit

Permalink
perf evsel: Fall back to global 'perf_env' in perf_evsel__env()
Browse files Browse the repository at this point in the history
I.e. if evsel->evlist or evsel->evlist->env isn't set, return the
environment for the running machine, as that would be set if reading
from a perf.data file.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-uqq4grmhbi12rwb0lfpo6lfu@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Sep 30, 2019
1 parent f67001a commit 9db0e36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "counts.h"
#include "event.h"
#include "evsel.h"
#include "util/env.h"
#include "util/evsel_config.h"
#include "util/evsel_fprintf.h"
#include "evlist.h"
Expand Down Expand Up @@ -2512,7 +2513,7 @@ struct perf_env *perf_evsel__env(struct evsel *evsel)
{
if (evsel && evsel->evlist)
return evsel->evlist->env;
return NULL;
return &perf_env;
}

static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist)
Expand Down
6 changes: 6 additions & 0 deletions tools/perf/util/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "thread_map.h"
#include "trace-event.h"
#include "mmap.h"
#include "util/env.h"
#include <internal/lib.h>
#include "../perf-sys.h"

Expand Down Expand Up @@ -53,6 +54,11 @@ int parse_callchain_record(const char *arg __maybe_unused,
return 0;
}

/*
* Add this one here not to drag util/env.c
*/
struct perf_env perf_env;

/*
* Support debug printing even though util/debug.c is not linked. That means
* implementing 'verbose' and 'eprintf'.
Expand Down

0 comments on commit 9db0e36

Please sign in to comment.