diff options
| author | Ian Rogers <irogers@google.com> | 2025-07-24 09:32:56 -0700 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2025-07-25 10:37:57 -0700 |
| commit | e481066388fe8003916461a54bf0ecffc02505a8 (patch) | |
| tree | cb2e7115cde919a56cabc72ec6e8a3bb7e9fe700 /tools/perf/util/debug.c | |
| parent | aa91baa09b2a3c38deff05b83410ce86833258d5 (diff) | |
| download | lwn-e481066388fe8003916461a54bf0ecffc02505a8.tar.gz lwn-e481066388fe8003916461a54bf0ecffc02505a8.zip | |
perf machine: Explicitly pass in host perf_env
When creating a machine for the host explicitly pass in a scoped
perf_env. This removes a use of the global perf_env.
Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250724163302.596743-17-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/util/debug.c')
| -rw-r--r-- | tools/perf/util/debug.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 2878a7363ac8..1dfa4d0eec4d 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -17,6 +17,7 @@ #include "addr_location.h" #include "color.h" #include "debug.h" +#include "env.h" #include "event.h" #include "machine.h" #include "map.h" @@ -309,8 +310,12 @@ void __dump_stack(FILE *file, void **stackdump, size_t stackdump_size) { /* TODO: async safety. printf, malloc, etc. aren't safe inside a signal handler. */ pid_t pid = getpid(); - struct machine *machine = machine__new_live(/*kernel_maps=*/false, pid); + struct machine *machine; struct thread *thread = NULL; + struct perf_env host_env; + + perf_env__init(&host_env); + machine = machine__new_live(&host_env, /*kernel_maps=*/false, pid); if (machine) thread = machine__find_thread(machine, pid, pid); @@ -323,6 +328,7 @@ void __dump_stack(FILE *file, void **stackdump, size_t stackdump_size) */ backtrace_symbols_fd(stackdump, stackdump_size, fileno(file)); machine__delete(machine); + perf_env__exit(&host_env); return; } #endif @@ -349,6 +355,7 @@ void __dump_stack(FILE *file, void **stackdump, size_t stackdump_size) } thread__put(thread); machine__delete(machine); + perf_env__exit(&host_env); } /* Obtain a backtrace and print it to stdout. */ |
