summaryrefslogtreecommitdiff
path: root/tools/perf/tests/code-reading.c
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2023-03-20 14:22:35 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-04 16:41:57 -0300
commit63df0e4bc368adbd12ed70ed4789d8d52d65661d (patch)
tree8d023dd3ba21bc4306f672aa2c0b5c8b7866959e /tools/perf/tests/code-reading.c
parent5ab6d715c32f6249415bcd1972bae7e6c03636f0 (diff)
perf map: Add accessor for dso
Later changes will add reference count checking for struct map, with dso being the most frequently accessed variable. Add an accessor so that the reference count check is only necessary in one place. Additional changes: - add a dso variable to avoid repeated map__dso calls. - in builtin-mem.c dump_raw_samples, code only partially tested for dso == NULL. Make the possibility of NULL consistent. - in thread.c thread__memcpy fix use of spaces and use tabs. Committer notes: Did missing conversions on these files: tools/perf/arch/powerpc/util/skip-callchain-idx.c tools/perf/arch/powerpc/util/sym-handling.c tools/perf/ui/browsers/hists.c tools/perf/ui/gtk/annotate.c tools/perf/util/cs-etm.c tools/perf/util/thread.c tools/perf/util/unwind-libunwind-local.c tools/perf/util/unwind-libunwind.c Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Darren Hart <dvhart@infradead.org> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Eric Dumazet <edumazet@google.com> Cc: German Gomez <german.gomez@arm.com> Cc: Hao Luo <haoluo@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Miaoqian Lin <linmq006@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Riccardo Mancini <rickyman7@gmail.com> Cc: Shunsuke Nakamura <nakamura.shun@fujitsu.com> Cc: Song Liu <song@kernel.org> Cc: Stephane Eranian <eranian@google.com> Cc: Stephen Brennan <stephen.s.brennan@oracle.com> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: Yury Norov <yury.norov@gmail.com> Link: https://lore.kernel.org/r/20230320212248.1175731-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/code-reading.c')
-rw-r--r--tools/perf/tests/code-reading.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 8d2036f2f944..936c61546e64 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -237,10 +237,11 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
char decomp_name[KMOD_DECOMP_LEN];
bool decomp = false;
int ret, err = 0;
+ struct dso *dso;
pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr);
- if (!thread__find_map(thread, cpumode, addr, &al) || !al.map->dso) {
+ if (!thread__find_map(thread, cpumode, addr, &al) || !map__dso(al.map)) {
if (cpumode == PERF_RECORD_MISC_HYPERVISOR) {
pr_debug("Hypervisor address can not be resolved - skipping\n");
goto out;
@@ -250,11 +251,10 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
err = -1;
goto out;
}
+ dso = map__dso(al.map);
+ pr_debug("File is: %s\n", dso->long_name);
- pr_debug("File is: %s\n", al.map->dso->long_name);
-
- if (al.map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS &&
- !dso__is_kcore(al.map->dso)) {
+ if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && !dso__is_kcore(dso)) {
pr_debug("Unexpected kernel address - skipping\n");
goto out;
}
@@ -269,7 +269,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
len = al.map->end - addr;
/* Read the object code using perf */
- ret_len = dso__data_read_offset(al.map->dso, maps__machine(thread->maps),
+ ret_len = dso__data_read_offset(dso, maps__machine(thread->maps),
al.addr, buf1, len);
if (ret_len != len) {
pr_debug("dso__data_read_offset failed\n");
@@ -287,7 +287,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
}
/* objdump struggles with kcore - try each map only once */
- if (dso__is_kcore(al.map->dso)) {
+ if (dso__is_kcore(dso)) {
size_t d;
for (d = 0; d < state->done_cnt; d++) {
@@ -304,9 +304,9 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
state->done[state->done_cnt++] = al.map->start;
}
- objdump_name = al.map->dso->long_name;
- if (dso__needs_decompress(al.map->dso)) {
- if (dso__decompress_kmodule_path(al.map->dso, objdump_name,
+ objdump_name = dso->long_name;
+ if (dso__needs_decompress(dso)) {
+ if (dso__decompress_kmodule_path(dso, objdump_name,
decomp_name,
sizeof(decomp_name)) < 0) {
pr_debug("decompression failed\n");
@@ -335,7 +335,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
len -= ret;
if (len) {
pr_debug("Reducing len to %zu\n", len);
- } else if (dso__is_kcore(al.map->dso)) {
+ } else if (dso__is_kcore(dso)) {
/*
* objdump cannot handle very large segments
* that may be found in kcore.
@@ -572,6 +572,7 @@ static int do_test_code_reading(bool try_kcore)
pid_t pid;
struct map *map;
bool have_vmlinux, have_kcore, excl_kernel = false;
+ struct dso *dso;
pid = getpid();
@@ -595,8 +596,9 @@ static int do_test_code_reading(bool try_kcore)
pr_debug("map__load failed\n");
goto out_err;
}
- have_vmlinux = dso__is_vmlinux(map->dso);
- have_kcore = dso__is_kcore(map->dso);
+ dso = map__dso(map);
+ have_vmlinux = dso__is_vmlinux(dso);
+ have_kcore = dso__is_kcore(dso);
/* 2nd time through we just try kcore */
if (try_kcore && !have_kcore)