| .. | .. |
|---|
| 14 | 14 | #include <errno.h> |
|---|
| 15 | 15 | #include <unistd.h> |
|---|
| 16 | 16 | #include "builtin.h" |
|---|
| 17 | | -#include "perf.h" |
|---|
| 18 | 17 | #include "namespaces.h" |
|---|
| 19 | | -#include "util/cache.h" |
|---|
| 20 | 18 | #include "util/debug.h" |
|---|
| 21 | 19 | #include "util/header.h" |
|---|
| 20 | +#include <subcmd/pager.h> |
|---|
| 22 | 21 | #include <subcmd/parse-options.h> |
|---|
| 23 | 22 | #include "util/strlist.h" |
|---|
| 24 | 23 | #include "util/build-id.h" |
|---|
| 25 | 24 | #include "util/session.h" |
|---|
| 25 | +#include "util/dso.h" |
|---|
| 26 | 26 | #include "util/symbol.h" |
|---|
| 27 | 27 | #include "util/time-utils.h" |
|---|
| 28 | +#include "util/util.h" |
|---|
| 28 | 29 | #include "util/probe-file.h" |
|---|
| 30 | +#include <linux/string.h> |
|---|
| 31 | +#include <linux/err.h> |
|---|
| 29 | 32 | |
|---|
| 30 | 33 | static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) |
|---|
| 31 | 34 | { |
|---|
| .. | .. |
|---|
| 171 | 174 | static int build_id_cache__add_file(const char *filename, struct nsinfo *nsi) |
|---|
| 172 | 175 | { |
|---|
| 173 | 176 | char sbuild_id[SBUILD_ID_SIZE]; |
|---|
| 174 | | - u8 build_id[BUILD_ID_SIZE]; |
|---|
| 177 | + struct build_id bid; |
|---|
| 175 | 178 | int err; |
|---|
| 176 | 179 | struct nscookie nsc; |
|---|
| 177 | 180 | |
|---|
| 178 | 181 | nsinfo__mountns_enter(nsi, &nsc); |
|---|
| 179 | | - err = filename__read_build_id(filename, &build_id, sizeof(build_id)); |
|---|
| 182 | + err = filename__read_build_id(filename, &bid); |
|---|
| 180 | 183 | nsinfo__mountns_exit(&nsc); |
|---|
| 181 | 184 | if (err < 0) { |
|---|
| 182 | 185 | pr_debug("Couldn't read a build-id in %s\n", filename); |
|---|
| 183 | 186 | return -1; |
|---|
| 184 | 187 | } |
|---|
| 185 | 188 | |
|---|
| 186 | | - build_id__sprintf(build_id, sizeof(build_id), sbuild_id); |
|---|
| 189 | + build_id__sprintf(&bid, sbuild_id); |
|---|
| 187 | 190 | err = build_id_cache__add_s(sbuild_id, filename, nsi, |
|---|
| 188 | 191 | false, false); |
|---|
| 189 | 192 | pr_debug("Adding %s %s: %s\n", sbuild_id, filename, |
|---|
| .. | .. |
|---|
| 193 | 196 | |
|---|
| 194 | 197 | static int build_id_cache__remove_file(const char *filename, struct nsinfo *nsi) |
|---|
| 195 | 198 | { |
|---|
| 196 | | - u8 build_id[BUILD_ID_SIZE]; |
|---|
| 197 | 199 | char sbuild_id[SBUILD_ID_SIZE]; |
|---|
| 200 | + struct build_id bid; |
|---|
| 198 | 201 | struct nscookie nsc; |
|---|
| 199 | 202 | |
|---|
| 200 | 203 | int err; |
|---|
| 201 | 204 | |
|---|
| 202 | 205 | nsinfo__mountns_enter(nsi, &nsc); |
|---|
| 203 | | - err = filename__read_build_id(filename, &build_id, sizeof(build_id)); |
|---|
| 206 | + err = filename__read_build_id(filename, &bid); |
|---|
| 204 | 207 | nsinfo__mountns_exit(&nsc); |
|---|
| 205 | 208 | if (err < 0) { |
|---|
| 206 | 209 | pr_debug("Couldn't read a build-id in %s\n", filename); |
|---|
| 207 | 210 | return -1; |
|---|
| 208 | 211 | } |
|---|
| 209 | 212 | |
|---|
| 210 | | - build_id__sprintf(build_id, sizeof(build_id), sbuild_id); |
|---|
| 213 | + build_id__sprintf(&bid, sbuild_id); |
|---|
| 211 | 214 | err = build_id_cache__remove_s(sbuild_id); |
|---|
| 212 | 215 | pr_debug("Removing %s %s: %s\n", sbuild_id, filename, |
|---|
| 213 | 216 | err ? "FAIL" : "Ok"); |
|---|
| .. | .. |
|---|
| 271 | 274 | static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused) |
|---|
| 272 | 275 | { |
|---|
| 273 | 276 | char filename[PATH_MAX]; |
|---|
| 274 | | - u8 build_id[BUILD_ID_SIZE]; |
|---|
| 277 | + struct build_id bid; |
|---|
| 275 | 278 | |
|---|
| 276 | 279 | if (dso__build_id_filename(dso, filename, sizeof(filename), false) && |
|---|
| 277 | | - filename__read_build_id(filename, build_id, |
|---|
| 278 | | - sizeof(build_id)) != sizeof(build_id)) { |
|---|
| 280 | + filename__read_build_id(filename, &bid) == -1) { |
|---|
| 279 | 281 | if (errno == ENOENT) |
|---|
| 280 | 282 | return false; |
|---|
| 281 | 283 | |
|---|
| 282 | 284 | pr_warning("Problems with %s file, consider removing it from the cache\n", |
|---|
| 283 | 285 | filename); |
|---|
| 284 | | - } else if (memcmp(dso->build_id, build_id, sizeof(dso->build_id))) { |
|---|
| 286 | + } else if (memcmp(dso->bid.data, bid.data, bid.size)) { |
|---|
| 285 | 287 | pr_warning("Problems with %s file, consider removing it from the cache\n", |
|---|
| 286 | 288 | filename); |
|---|
| 287 | 289 | } |
|---|
| .. | .. |
|---|
| 297 | 299 | |
|---|
| 298 | 300 | static int build_id_cache__update_file(const char *filename, struct nsinfo *nsi) |
|---|
| 299 | 301 | { |
|---|
| 300 | | - u8 build_id[BUILD_ID_SIZE]; |
|---|
| 301 | 302 | char sbuild_id[SBUILD_ID_SIZE]; |
|---|
| 303 | + struct build_id bid; |
|---|
| 302 | 304 | struct nscookie nsc; |
|---|
| 303 | 305 | |
|---|
| 304 | 306 | int err; |
|---|
| 305 | 307 | |
|---|
| 306 | 308 | nsinfo__mountns_enter(nsi, &nsc); |
|---|
| 307 | | - err = filename__read_build_id(filename, &build_id, sizeof(build_id)); |
|---|
| 309 | + err = filename__read_build_id(filename, &bid); |
|---|
| 308 | 310 | nsinfo__mountns_exit(&nsc); |
|---|
| 309 | 311 | if (err < 0) { |
|---|
| 310 | 312 | pr_debug("Couldn't read a build-id in %s\n", filename); |
|---|
| .. | .. |
|---|
| 312 | 314 | } |
|---|
| 313 | 315 | err = 0; |
|---|
| 314 | 316 | |
|---|
| 315 | | - build_id__sprintf(build_id, sizeof(build_id), sbuild_id); |
|---|
| 317 | + build_id__sprintf(&bid, sbuild_id); |
|---|
| 316 | 318 | if (build_id_cache__cached(sbuild_id)) |
|---|
| 317 | 319 | err = build_id_cache__remove_s(sbuild_id); |
|---|
| 318 | 320 | |
|---|
| .. | .. |
|---|
| 416 | 418 | nsi = nsinfo__new(ns_id); |
|---|
| 417 | 419 | |
|---|
| 418 | 420 | if (missing_filename) { |
|---|
| 419 | | - data.file.path = missing_filename; |
|---|
| 420 | | - data.force = force; |
|---|
| 421 | + data.path = missing_filename; |
|---|
| 422 | + data.force = force; |
|---|
| 421 | 423 | |
|---|
| 422 | 424 | session = perf_session__new(&data, false, NULL); |
|---|
| 423 | | - if (session == NULL) |
|---|
| 424 | | - return -1; |
|---|
| 425 | + if (IS_ERR(session)) |
|---|
| 426 | + return PTR_ERR(session); |
|---|
| 425 | 427 | } |
|---|
| 426 | 428 | |
|---|
| 427 | 429 | if (symbol__init(session ? &session->header.env : NULL) < 0) |
|---|