diff options
| author | Ian Rogers <irogers@google.com> | 2026-01-23 14:22:06 -0800 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-01-26 18:21:20 -0300 |
| commit | 7d0ebeb6c0f735d4eddc679283a1de1dea2ae878 (patch) | |
| tree | ab4a0927832e10f163599392c9bf3eab73438ad7 /tools/perf/util/thread.c | |
| parent | 76b2cf07a6d2a836108f9c2486d76599f7adf6e8 (diff) | |
| download | linux-7d0ebeb6c0f735d4eddc679283a1de1dea2ae878.tar.gz linux-7d0ebeb6c0f735d4eddc679283a1de1dea2ae878.zip | |
perf dso: Factor out e_machine reading for use in thread
Factor out the resilient e_machine reading code in dso so that it may
be used in thread.
As there is no dso in that case, make the dso optional.
This makes some minor other changes as the swap type from the dso cannot
be ascertained.
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Chun-Tse Shao <ctshao@google.com>
Cc: Guo Ren <guoren@kernel.org>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sergei Trofimovich <slyich@gmail.com>
Cc: Shimin Guo <shimin.guo@skydio.com>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Swapnil Sapkal <swapnil.sapkal@amd.com>
Cc: Tianyou Li <tianyou.li@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/thread.c')
| -rw-r--r-- | tools/perf/util/thread.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index aa9c58bbf9d3..3642858e6cbc 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -458,10 +458,7 @@ static uint16_t read_proc_e_machine_for_pid(pid_t pid) snprintf(path, sizeof(path), "/proc/%d/exe", pid); fd = open(path, O_RDONLY); if (fd >= 0) { - _Static_assert(offsetof(Elf32_Ehdr, e_machine) == 18, "Unexpected offset"); - _Static_assert(offsetof(Elf64_Ehdr, e_machine) == 18, "Unexpected offset"); - if (pread(fd, &e_machine, sizeof(e_machine), 18) != sizeof(e_machine)) - e_machine = EM_NONE; + e_machine = dso__read_e_machine(/*optional_dso=*/NULL, fd); close(fd); } return e_machine; |
