Re: [PATCH v5 00/17] Reference count checker and related fixes

From: Arnaldo Carvalho de Melo
Date: Tue Apr 04 2023 - 15:53:27 EST


Applied to:

perf map: Add accessor for start and end

diff --git a/tools/perf/arch/arm/tests/dwarf-unwind.c b/tools/perf/arch/arm/tests/dwarf-unwind.c
index ccfa87055c4a3b9d..566fb6c0eae737c6 100644
--- a/tools/perf/arch/arm/tests/dwarf-unwind.c
+++ b/tools/perf/arch/arm/tests/dwarf-unwind.c
@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample,
return -1;
}

- stack_size = map->end - sp;
+ stack_size = map__end(map) - sp;
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;

memcpy(buf, (void *) sp, stack_size);
diff --git a/tools/perf/arch/arm64/tests/dwarf-unwind.c b/tools/perf/arch/arm64/tests/dwarf-unwind.c
index 46147a483049615d..90a7ef293ce76879 100644
--- a/tools/perf/arch/arm64/tests/dwarf-unwind.c
+++ b/tools/perf/arch/arm64/tests/dwarf-unwind.c
@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample,
return -1;
}

- stack_size = map->end - sp;
+ stack_size = map__end(map) - sp;
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;

memcpy(buf, (void *) sp, stack_size);
diff --git a/tools/perf/arch/powerpc/tests/dwarf-unwind.c b/tools/perf/arch/powerpc/tests/dwarf-unwind.c
index c9cb4b059392f6cf..32fffb593fbf0236 100644
--- a/tools/perf/arch/powerpc/tests/dwarf-unwind.c
+++ b/tools/perf/arch/powerpc/tests/dwarf-unwind.c
@@ -33,7 +33,7 @@ static int sample_ustack(struct perf_sample *sample,
return -1;
}

- stack_size = map->end - sp;
+ stack_size = map__end(map) - sp;
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;

memcpy(buf, (void *) sp, stack_size);
diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
index fe0e4530673c6661..b7223feec770dc33 100644
--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
+++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
@@ -262,7 +262,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
return skip_slot;
}

- rc = check_return_addr(dso, al.map->start, ip);
+ rc = check_return_addr(dso, map__start(al.map), ip);

pr_debug("[DSO %s, sym %s, ip 0x%" PRIx64 "] rc %d\n",
dso->long_name, al.sym->name, ip, rc);
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7852b97da10aa336..1cc6f338728f5499 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -903,7 +903,7 @@ static int machine__process_ksymbol_register(struct machine *machine,
}

map->start = event->ksymbol.addr;
- map->end = map__start(map) + event->ksymbol.len;
+ map__end(map) = map__start(map) + event->ksymbol.len;
err = maps__insert(machine__kernel_maps(machine), map);
map__put(map);
if (err)
diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c
index 1fd57db7222678ad..21010a2b8e16cc2e 100644
--- a/tools/perf/util/maps.c
+++ b/tools/perf/util/maps.c
@@ -339,7 +339,7 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
map__put(before);
}

- if (map->end < map__end(pos->map)) {
+ if (map__end(map) < map__end(pos->map)) {
struct map *after = map__clone(pos->map);

if (after == NULL) {
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index 108f7b1697a73465..1c13f43e7d22c84c 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -327,9 +327,10 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct unwind_info *ui,

maps__for_each_entry(ui->thread->maps, map_node) {
struct map *map = map_node->map;
+ u64 start = map__start(map);

- if (map__dso(map) == dso && map->start < base_addr)
- base_addr = map->start;
+ if (map__dso(map) == dso && start < base_addr)
+ base_addr = start;
}
base_addr -= dso->data.elf_base_addr;
/* Address of .eh_frame_hdr */
@@ -443,8 +444,8 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
if (!read_unwind_spec_eh_frame(dso, ui, &table_data, &segbase, &fde_count)) {
memset(&di, 0, sizeof(di));
di.format = UNW_INFO_FORMAT_REMOTE_TABLE;
- di.start_ip = map->start;
- di.end_ip = map->end;
+ di.start_ip = map__start(map);
+ di.end_ip = map__end(map);
di.u.rti.segbase = segbase;
di.u.rti.table_data = table_data;
di.u.rti.table_len = fde_count * sizeof(struct table_entry)
@@ -459,7 +460,8 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
!read_unwind_spec_debug_frame(dso, ui->machine, &segbase)) {
int fd = dso__data_get_fd(dso, ui->machine);
int is_exec = elf_is_exec(fd, dso->name);
- unw_word_t base = is_exec ? 0 : map->start;
+ u64 start = map__start(map);
+ unw_word_t base = is_exec ? 0 : start;
const char *symfile;

if (fd >= 0)
@@ -468,8 +470,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
symfile = dso->symsrc_filename ?: dso->name;

memset(&di, 0, sizeof(di));
- if (dwarf_find_debug_frame(0, &di, ip, base, symfile,
- map->start, map->end))
+ if (dwarf_find_debug_frame(0, &di, ip, base, symfile, start, map__end(map)))
return dwarf_search_unwind_table(as, ip, &di, pi,
need_unwind_info, arg);
}