diff options
| -rw-r--r-- | tools/perf/builtin-buildid-cache.c | 37 | ||||
| -rw-r--r-- | tools/perf/util/build-id.c | 44 | ||||
| -rw-r--r-- | tools/perf/util/build-id.h | 4 |
3 files changed, 38 insertions, 47 deletions
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 50e6b66aea1f..d929d9544664 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
| @@ -125,8 +125,7 @@ static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir, | |||
| 125 | return ret; | 125 | return ret; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | static int build_id_cache__add_kcore(const char *filename, const char *debugdir, | 128 | static int build_id_cache__add_kcore(const char *filename, bool force) |
| 129 | bool force) | ||
| 130 | { | 129 | { |
| 131 | char dir[32], sbuildid[BUILD_ID_SIZE * 2 + 1]; | 130 | char dir[32], sbuildid[BUILD_ID_SIZE * 2 + 1]; |
| 132 | char from_dir[PATH_MAX], to_dir[PATH_MAX]; | 131 | char from_dir[PATH_MAX], to_dir[PATH_MAX]; |
| @@ -143,7 +142,7 @@ static int build_id_cache__add_kcore(const char *filename, const char *debugdir, | |||
| 143 | return -1; | 142 | return -1; |
| 144 | 143 | ||
| 145 | scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s", | 144 | scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s", |
| 146 | debugdir, sbuildid); | 145 | buildid_dir, sbuildid); |
| 147 | 146 | ||
| 148 | if (!force && | 147 | if (!force && |
| 149 | !build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) { | 148 | !build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) { |
| @@ -155,7 +154,7 @@ static int build_id_cache__add_kcore(const char *filename, const char *debugdir, | |||
| 155 | return -1; | 154 | return -1; |
| 156 | 155 | ||
| 157 | scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s/%s", | 156 | scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s/%s", |
| 158 | debugdir, sbuildid, dir); | 157 | buildid_dir, sbuildid, dir); |
| 159 | 158 | ||
| 160 | if (mkdir_p(to_dir, 0755)) | 159 | if (mkdir_p(to_dir, 0755)) |
| 161 | return -1; | 160 | return -1; |
| @@ -183,7 +182,7 @@ static int build_id_cache__add_kcore(const char *filename, const char *debugdir, | |||
| 183 | return 0; | 182 | return 0; |
| 184 | } | 183 | } |
| 185 | 184 | ||
| 186 | static int build_id_cache__add_file(const char *filename, const char *debugdir) | 185 | static int build_id_cache__add_file(const char *filename) |
| 187 | { | 186 | { |
| 188 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | 187 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; |
| 189 | u8 build_id[BUILD_ID_SIZE]; | 188 | u8 build_id[BUILD_ID_SIZE]; |
| @@ -195,7 +194,7 @@ static int build_id_cache__add_file(const char *filename, const char *debugdir) | |||
| 195 | } | 194 | } |
| 196 | 195 | ||
| 197 | build_id__sprintf(build_id, sizeof(build_id), sbuild_id); | 196 | build_id__sprintf(build_id, sizeof(build_id), sbuild_id); |
| 198 | err = build_id_cache__add_s(sbuild_id, debugdir, filename, | 197 | err = build_id_cache__add_s(sbuild_id, filename, |
| 199 | false, false); | 198 | false, false); |
| 200 | if (verbose) | 199 | if (verbose) |
| 201 | pr_info("Adding %s %s: %s\n", sbuild_id, filename, | 200 | pr_info("Adding %s %s: %s\n", sbuild_id, filename, |
| @@ -203,8 +202,7 @@ static int build_id_cache__add_file(const char *filename, const char *debugdir) | |||
| 203 | return err; | 202 | return err; |
| 204 | } | 203 | } |
| 205 | 204 | ||
| 206 | static int build_id_cache__remove_file(const char *filename, | 205 | static int build_id_cache__remove_file(const char *filename) |
| 207 | const char *debugdir) | ||
| 208 | { | 206 | { |
| 209 | u8 build_id[BUILD_ID_SIZE]; | 207 | u8 build_id[BUILD_ID_SIZE]; |
| 210 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | 208 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; |
| @@ -217,7 +215,7 @@ static int build_id_cache__remove_file(const char *filename, | |||
| 217 | } | 215 | } |
| 218 | 216 | ||
| 219 | build_id__sprintf(build_id, sizeof(build_id), sbuild_id); | 217 | build_id__sprintf(build_id, sizeof(build_id), sbuild_id); |
| 220 | err = build_id_cache__remove_s(sbuild_id, debugdir); | 218 | err = build_id_cache__remove_s(sbuild_id); |
| 221 | if (verbose) | 219 | if (verbose) |
| 222 | pr_info("Removing %s %s: %s\n", sbuild_id, filename, | 220 | pr_info("Removing %s %s: %s\n", sbuild_id, filename, |
| 223 | err ? "FAIL" : "Ok"); | 221 | err ? "FAIL" : "Ok"); |
| @@ -252,8 +250,7 @@ static int build_id_cache__fprintf_missing(struct perf_session *session, FILE *f | |||
| 252 | return 0; | 250 | return 0; |
| 253 | } | 251 | } |
| 254 | 252 | ||
| 255 | static int build_id_cache__update_file(const char *filename, | 253 | static int build_id_cache__update_file(const char *filename) |
| 256 | const char *debugdir) | ||
| 257 | { | 254 | { |
| 258 | u8 build_id[BUILD_ID_SIZE]; | 255 | u8 build_id[BUILD_ID_SIZE]; |
| 259 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | 256 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; |
| @@ -266,11 +263,10 @@ static int build_id_cache__update_file(const char *filename, | |||
| 266 | } | 263 | } |
| 267 | 264 | ||
| 268 | build_id__sprintf(build_id, sizeof(build_id), sbuild_id); | 265 | build_id__sprintf(build_id, sizeof(build_id), sbuild_id); |
| 269 | err = build_id_cache__remove_s(sbuild_id, debugdir); | 266 | err = build_id_cache__remove_s(sbuild_id); |
| 270 | if (!err) { | 267 | if (!err) |
| 271 | err = build_id_cache__add_s(sbuild_id, debugdir, filename, | 268 | err = build_id_cache__add_s(sbuild_id, filename, false, false); |
| 272 | false, false); | 269 | |
| 273 | } | ||
| 274 | if (verbose) | 270 | if (verbose) |
| 275 | pr_info("Updating %s %s: %s\n", sbuild_id, filename, | 271 | pr_info("Updating %s %s: %s\n", sbuild_id, filename, |
| 276 | err ? "FAIL" : "Ok"); | 272 | err ? "FAIL" : "Ok"); |
| @@ -338,7 +334,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
| 338 | list = strlist__new(true, add_name_list_str); | 334 | list = strlist__new(true, add_name_list_str); |
| 339 | if (list) { | 335 | if (list) { |
| 340 | strlist__for_each(pos, list) | 336 | strlist__for_each(pos, list) |
| 341 | if (build_id_cache__add_file(pos->s, buildid_dir)) { | 337 | if (build_id_cache__add_file(pos->s)) { |
| 342 | if (errno == EEXIST) { | 338 | if (errno == EEXIST) { |
| 343 | pr_debug("%s already in the cache\n", | 339 | pr_debug("%s already in the cache\n", |
| 344 | pos->s); | 340 | pos->s); |
| @@ -356,7 +352,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
| 356 | list = strlist__new(true, remove_name_list_str); | 352 | list = strlist__new(true, remove_name_list_str); |
| 357 | if (list) { | 353 | if (list) { |
| 358 | strlist__for_each(pos, list) | 354 | strlist__for_each(pos, list) |
| 359 | if (build_id_cache__remove_file(pos->s, buildid_dir)) { | 355 | if (build_id_cache__remove_file(pos->s)) { |
| 360 | if (errno == ENOENT) { | 356 | if (errno == ENOENT) { |
| 361 | pr_debug("%s wasn't in the cache\n", | 357 | pr_debug("%s wasn't in the cache\n", |
| 362 | pos->s); | 358 | pos->s); |
| @@ -377,7 +373,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
| 377 | list = strlist__new(true, update_name_list_str); | 373 | list = strlist__new(true, update_name_list_str); |
| 378 | if (list) { | 374 | if (list) { |
| 379 | strlist__for_each(pos, list) | 375 | strlist__for_each(pos, list) |
| 380 | if (build_id_cache__update_file(pos->s, buildid_dir)) { | 376 | if (build_id_cache__update_file(pos->s)) { |
| 381 | if (errno == ENOENT) { | 377 | if (errno == ENOENT) { |
| 382 | pr_debug("%s wasn't in the cache\n", | 378 | pr_debug("%s wasn't in the cache\n", |
| 383 | pos->s); | 379 | pos->s); |
| @@ -391,8 +387,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
| 391 | } | 387 | } |
| 392 | } | 388 | } |
| 393 | 389 | ||
| 394 | if (kcore_filename && | 390 | if (kcore_filename && build_id_cache__add_kcore(kcore_filename, force)) |
| 395 | build_id_cache__add_kcore(kcore_filename, buildid_dir, force)) | ||
| 396 | pr_warning("Couldn't add %s\n", kcore_filename); | 391 | pr_warning("Couldn't add %s\n", kcore_filename); |
| 397 | 392 | ||
| 398 | out: | 393 | out: |
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 0c72680a977f..9f764f633e57 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c | |||
| @@ -259,8 +259,8 @@ void disable_buildid_cache(void) | |||
| 259 | no_buildid_cache = true; | 259 | no_buildid_cache = true; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | 262 | int build_id_cache__add_s(const char *sbuild_id, const char *name, |
| 263 | const char *name, bool is_kallsyms, bool is_vdso) | 263 | bool is_kallsyms, bool is_vdso) |
| 264 | { | 264 | { |
| 265 | const size_t size = PATH_MAX; | 265 | const size_t size = PATH_MAX; |
| 266 | char *realname, *filename = zalloc(size), | 266 | char *realname, *filename = zalloc(size), |
| @@ -282,7 +282,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
| 282 | goto out_free; | 282 | goto out_free; |
| 283 | 283 | ||
| 284 | len = scnprintf(filename, size, "%s%s%s", | 284 | len = scnprintf(filename, size, "%s%s%s", |
| 285 | debugdir, slash ? "/" : "", | 285 | buildid_dir, slash ? "/" : "", |
| 286 | is_vdso ? DSO__NAME_VDSO : realname); | 286 | is_vdso ? DSO__NAME_VDSO : realname); |
| 287 | if (mkdir_p(filename, 0755)) | 287 | if (mkdir_p(filename, 0755)) |
| 288 | goto out_free; | 288 | goto out_free; |
| @@ -298,13 +298,13 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
