Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 71a84b5a authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf thread: Make thread__find_map() return the map

It was returning the searched map just on the addr_location passed, with
the function itself returning void.

Make it return the map so that we can make the code more compact.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-tzlrrzdeoof4i6ktyqv1t6ks@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent cc5f02f2
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -440,9 +440,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,
		goto repipe;
	}

	thread__find_map(thread, sample->cpumode, sample->ip, &al);

	if (al.map != NULL) {
	if (thread__find_map(thread, sample->cpumode, sample->ip, &al)) {
		if (!al.map->dso->hit) {
			al.map->dso->hit = 1;
			if (map__load(al.map) >= 0) {
+6 −8
Original line number Diff line number Diff line
@@ -809,12 +809,12 @@ static int perf_sample__fprintf_brstackoff(struct perf_sample *sample,
		from = br->entries[i].from;
		to   = br->entries[i].to;

		thread__find_map(thread, sample->cpumode, from, &alf);
		if (alf.map && !alf.map->dso->adjust_symbols)
		if (thread__find_map(thread, sample->cpumode, from, &alf) &&
		    !alf.map->dso->adjust_symbols)
			from = map__map_ip(alf.map, from);

		thread__find_map(thread, sample->cpumode, to, &alt);
		if (alt.map && !alt.map->dso->adjust_symbols)
		if (thread__find_map(thread, sample->cpumode, to, &alt) &&
		    !alt.map->dso->adjust_symbols)
			to = map__map_ip(alt.map, to);

		printed += fprintf(fp, " 0x%"PRIx64, from);
@@ -877,8 +877,7 @@ static int grab_bb(u8 *buffer, u64 start, u64 end,
		return 0;
	}

	thread__find_map(thread, *cpumode, start, &al);
	if (!al.map || !al.map->dso) {
	if (!thread__find_map(thread, *cpumode, start, &al) || !al.map->dso) {
		pr_debug("\tcannot resolve %" PRIx64 "-%" PRIx64 "\n", start, end);
		return 0;
	}
@@ -928,8 +927,7 @@ static int ip__fprintf_sym(uint64_t addr, struct thread *thread,

	memset(&al, 0, sizeof(al));

	thread__find_map(thread, cpumode, addr, &al);
	if (!al.map)
	if (!thread__find_map(thread, cpumode, addr, &al))
		__thread__find_map(thread, cpumode, MAP__VARIABLE, addr, &al);
	if ((*lastsym) && al.addr >= (*lastsym)->start && al.addr < (*lastsym)->end)
		return 0;
+1 −2
Original line number Diff line number Diff line
@@ -236,8 +236,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,

	pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr);

	thread__find_map(thread, cpumode, addr, &al);
	if (!al.map || !al.map->dso) {
	if (!thread__find_map(thread, cpumode, addr, &al) || !al.map->dso) {
		if (cpumode == PERF_RECORD_MISC_HYPERVISOR) {
			pr_debug("Hypervisor address can not be resolved - skipping\n");
			return 0;
+1 −3
Original line number Diff line number Diff line
@@ -47,9 +47,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
		return -1;
	}

	thread__find_map(thread, sample->cpumode, sample->ip, &al);

	if (al.map != NULL)
	if (thread__find_map(thread, sample->cpumode, sample->ip, &al))
		al.map->dso->hit = 1;

	thread__put(thread);
+1 −3
Original line number Diff line number Diff line
@@ -269,9 +269,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address,
		thread = etmq->etm->unknown_thread;
	}

	thread__find_map(thread, cpumode, address, &al);

	if (!al.map || !al.map->dso)
	if (!thread__find_map(thread, cpumode, address, &al) || !al.map->dso)
		return 0;

	if (al.map->dso->data.status == DSO_DATA_STATUS_ERROR &&
Loading