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: Jiri Olsa <jolsa@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20201013192441.1299447-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Jiri Olsa
2020-10-13 21:24:33 +02:00
committed by Arnaldo Carvalho de Melo
parent 79bbbabd22
commit 0aba7f036a
15 changed files with 34 additions and 29 deletions

View File

@@ -172,8 +172,8 @@ int dso__read_binary_type_filename(const struct dso *dso,
break;
}
build_id__sprintf(dso->build_id,
sizeof(dso->build_id),
build_id__sprintf(dso->bid.data,
sizeof(dso->bid.data),
build_id_hex);
len = __symbol__join_symfs(filename, size, "/usr/lib/debug/.build-id/");
snprintf(filename + len, size - len, "%.2s/%s.debug",
@@ -1330,13 +1330,13 @@ void dso__put(struct dso *dso)
void dso__set_build_id(struct dso *dso, void *build_id)
{
memcpy(dso->build_id, build_id, sizeof(dso->build_id));
memcpy(dso->bid.data, build_id, sizeof(dso->bid.data));
dso->has_build_id = 1;
}
bool dso__build_id_equal(const struct dso *dso, u8 *build_id)
{
return memcmp(dso->build_id, build_id, sizeof(dso->build_id)) == 0;
return memcmp(dso->bid.data, build_id, sizeof(dso->bid.data)) == 0;
}
void dso__read_running_kernel_build_id(struct dso *dso, struct machine *machine)
@@ -1346,8 +1346,8 @@ void dso__read_running_kernel_build_id(struct dso *dso, struct machine *machine)
if (machine__is_default_guest(machine))
return;
sprintf(path, "%s/sys/kernel/notes", machine->root_dir);
if (sysfs__read_build_id(path, dso->build_id,
sizeof(dso->build_id)) == 0)
if (sysfs__read_build_id(path, dso->bid.data,
sizeof(dso->bid.data)) == 0)
dso->has_build_id = true;
}
@@ -1365,8 +1365,8 @@ int dso__kernel_module_get_build_id(struct dso *dso,
"%s/sys/module/%.*s/notes/.note.gnu.build-id",
root_dir, (int)strlen(name) - 1, name);
if (sysfs__read_build_id(filename, dso->build_id,
sizeof(dso->build_id)) == 0)
if (sysfs__read_build_id(filename, dso->bid.data,
sizeof(dso->bid.data)) == 0)
dso->has_build_id = true;
return 0;
@@ -1376,7 +1376,7 @@ size_t dso__fprintf_buildid(struct dso *dso, FILE *fp)
{
char sbuild_id[SBUILD_ID_SIZE];
build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
build_id__sprintf(dso->bid.data, sizeof(dso->bid.data), sbuild_id);
return fprintf(fp, "%s", sbuild_id);
}