Commit 0aba7f03 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Use build_id object in dso



Replace build_id byte array with struct build_id object and all the code
that references it.

The objective is to carry size together with build id array, so it's
better to keep both together.

This is preparatory change for following patches, and there's no
functional change.

Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarIan Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20201013192441.1299447-2-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 79bbbabd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -79,12 +79,12 @@ static int add_dso(const char *fpath, const struct stat *sb __maybe_unused,
		   int typeflag, struct FTW *ftwbuf __maybe_unused)
{
	struct bench_dso *dso = &dsos[nr_dsos];
	unsigned char build_id[BUILD_ID_SIZE];
	struct build_id bid;

	if (typeflag == FTW_D || typeflag == FTW_SL)
		return 0;

	if (filename__read_build_id(fpath, build_id, BUILD_ID_SIZE) < 0)
	if (filename__read_build_id(fpath, bid.data, sizeof(bid.data)) < 0)
		return 0;

	dso->name = realpath(fpath, NULL);
+1 −1
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused)

		pr_warning("Problems with %s file, consider removing it from the cache\n",
			   filename);
	} else if (memcmp(dso->build_id, build_id, sizeof(dso->build_id))) {
	} else if (memcmp(dso->bid.data, build_id, sizeof(dso->bid.data))) {
		pr_warning("Problems with %s file, consider removing it from the cache\n",
			   filename);
	}
+2 −2
Original line number Diff line number Diff line
@@ -522,8 +522,8 @@ static int dso__read_build_id(struct dso *dso)
		return 0;

	nsinfo__mountns_enter(dso->nsinfo, &nsc);
	if (filename__read_build_id(dso->long_name, dso->build_id,
				    sizeof(dso->build_id)) > 0) {
	if (filename__read_build_id(dso->long_name, dso->bid.data,
				    sizeof(dso->bid.data)) > 0) {
		dso->has_build_id = true;
	}
	nsinfo__mountns_exit(&nsc);
+2 −2
Original line number Diff line number Diff line
@@ -1578,8 +1578,8 @@ int symbol__strerror_disassemble(struct map_symbol *ms, int errnum, char *buf, s
		char *build_id_msg = NULL;

		if (dso->has_build_id) {
			build_id__sprintf(dso->build_id,
					  sizeof(dso->build_id), bf + 15);
			build_id__sprintf(dso->bid.data,
					  sizeof(dso->bid.data), bf + 15);
			build_id_msg = bf;
		}
		scnprintf(buf, buflen,
+3 −3
Original line number Diff line number Diff line
@@ -272,7 +272,7 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size,
	if (!dso->has_build_id)
		return NULL;

	build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
	build_id__sprintf(dso->bid.data, sizeof(dso->bid.data), sbuild_id);
	linkname = build_id_cache__linkname(sbuild_id, NULL, 0);
	if (!linkname)
		return NULL;
@@ -355,7 +355,7 @@ static int machine__write_buildid_table(struct machine *machine,
		in_kernel = pos->kernel ||
				is_kernel_module(name,
					PERF_RECORD_MISC_CPUMODE_UNKNOWN);
		err = write_buildid(name, name_len, pos->build_id, machine->pid,
		err = write_buildid(name, name_len, pos->bid.data, machine->pid,
				    in_kernel ? kmisc : umisc, fd);
		if (err)
			break;
@@ -841,7 +841,7 @@ static int dso__cache_build_id(struct dso *dso, struct machine *machine)
		is_kallsyms = true;
		name = machine->mmap_name;
	}
	return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id), name,
	return build_id_cache__add_b(dso->bid.data, sizeof(dso->bid.data), name,
				     dso->nsinfo, is_kallsyms, is_vdso);
}

Loading