diff options
Diffstat (limited to 'tools/perf/util')
| -rw-r--r-- | tools/perf/util/event.c | 1 | ||||
| -rw-r--r-- | tools/perf/util/machine.c | 1 | ||||
| -rw-r--r-- | tools/perf/util/symbol-elf.c | 1 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 69 | ||||
| -rw-r--r-- | tools/perf/util/symbol.h | 3 |
5 files changed, 4 insertions, 71 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index c77814bf01e1..694876877ae2 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "strlist.h" | 7 | #include "strlist.h" |
| 8 | #include "thread.h" | 8 | #include "thread.h" |
| 9 | #include "thread_map.h" | 9 | #include "thread_map.h" |
| 10 | #include "symbol/kallsyms.h" | ||
| 10 | 11 | ||
| 11 | static const char *perf_event__names[] = { | 12 | static const char *perf_event__names[] = { |
| 12 | [0] = "TOTAL", | 13 | [0] = "TOTAL", |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 751454bcde69..c78cc84f433e 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "strlist.h" | 9 | #include "strlist.h" |
| 10 | #include "thread.h" | 10 | #include "thread.h" |
| 11 | #include <stdbool.h> | 11 | #include <stdbool.h> |
| 12 | #include <symbol/kallsyms.h> | ||
| 12 | #include "unwind.h" | 13 | #include "unwind.h" |
| 13 | 14 | ||
| 14 | int machine__init(struct machine *machine, const char *root_dir, pid_t pid) | 15 | int machine__init(struct machine *machine, const char *root_dir, pid_t pid) |
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index eed0b96302af..bf0ce29567b6 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <inttypes.h> | 6 | #include <inttypes.h> |
| 7 | 7 | ||
| 8 | #include "symbol.h" | 8 | #include "symbol.h" |
| 9 | #include <symbol/kallsyms.h> | ||
| 9 | #include "debug.h" | 10 | #include "debug.h" |
| 10 | 11 | ||
| 11 | #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT | 12 | #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index e377c2e96191..61eb1cddf01a 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
| @@ -18,12 +18,9 @@ | |||
| 18 | 18 | ||
| 19 | #include <elf.h> | 19 | #include <elf.h> |
| 20 | #include <limits.h> | 20 | #include <limits.h> |
| 21 | #include <symbol/kallsyms.h> | ||
| 21 | #include <sys/utsname.h> | 22 | #include <sys/utsname.h> |
| 22 | 23 | ||
| 23 | #ifndef KSYM_NAME_LEN | ||
| 24 | #define KSYM_NAME_LEN 256 | ||
| 25 | #endif | ||
| 26 | |||
| 27 | static int dso__load_kernel_sym(struct dso *dso, struct map *map, | 24 | static int dso__load_kernel_sym(struct dso *dso, struct map *map, |
| 28 | symbol_filter_t filter); | 25 | symbol_filter_t filter); |
| 29 | static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map, | 26 | static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map, |
| @@ -446,62 +443,6 @@ size_t dso__fprintf_symbols_by_name(struct dso *dso, | |||
| 446 | return ret; | 443 | return ret; |
| 447 | } | 444 | } |
| 448 | 445 | ||
| 449 | int kallsyms__parse(const char *filename, void *arg, | ||
| 450 | int (*process_symbol)(void *arg, const char *name, | ||
| 451 | char type, u64 start)) | ||
| 452 | { | ||
| 453 | char *line = NULL; | ||
| 454 | size_t n; | ||
| 455 | int err = -1; | ||
| 456 | FILE *file = fopen(filename, "r"); | ||
| 457 | |||
| 458 | if (file == NULL) | ||
| 459 | goto out_failure; | ||
| 460 | |||
| 461 | err = 0; | ||
| 462 | |||
| 463 | while (!feof(file)) { | ||
| 464 | u64 start; | ||
| 465 | int line_len, len; | ||
| 466 | char symbol_type; | ||
| 467 | char *symbol_name; | ||
| 468 | |||
| 469 | line_len = getline(&line, &n, file); | ||
| 470 | if (line_len < 0 || !line) | ||
| 471 | break; | ||
| 472 | |||
| 473 | line[--line_len] = '\0'; /* \n */ | ||
| 474 | |||
| 475 | len = hex2u64(line, &start); | ||
| 476 | |||
| 477 | len++; | ||
| 478 | if (len + 2 >= line_len) | ||
| 479 | continue; | ||
| 480 | |||
| 481 | symbol_type = line[len]; | ||
| 482 | len += 2; | ||
| 483 | symbol_name = line + len; | ||
| 484 | len = line_len - len; | ||
| 485 | |||
| 486 | if (len >= KSYM_NAME_LEN) { | ||
| 487 | err = -1; | ||
| 488 | break; | ||
| 489 | } | ||
| 490 | |||
| 491 | err = process_symbol(arg, symbol_name, | ||
| 492 | symbol_type, start); | ||
| 493 | if (err) | ||
| 494 | break; | ||
| 495 | } | ||
| 496 | |||
| 497 | free(line); | ||
| 498 | fclose(file); | ||
| 499 | return err; | ||
| 500 | |||
| 501 | out_failure: | ||
| 502 | return -1; | ||
| 503 | } | ||
| 504 | |||
| 505 | int modules__parse(const char *filename, void *arg, | 446 | int modules__parse(const char *filename, void *arg, |
| 506 | int (*process_module)(void *arg, const char *name, | 447 | int (*process_module)(void *arg, const char *name, |
| 507 | u64 start)) | 448 | u64 start)) |
| @@ -565,14 +506,6 @@ struct process_kallsyms_args { | |||
| 565 | struct dso *dso; | 506 | struct dso *dso; |
| 566 | }; | 507 | }; |
| 567 | 508 | ||
| 568 | static u8 kallsyms2elf_type(char type) | ||
| 569 | { | ||
| 570 | if (type == 'W') | ||
| 571 | return STB_WEAK; | ||
| 572 | |||
| 573 | return isupper(type) ? STB_GLOBAL : STB_LOCAL; | ||
| 574 | } | ||
| 575 | |||
| 576 | bool symbol__is_idle(struct symbol *sym) | 509 | bool symbol__is_idle(struct symbol *sym) |
| 577 | { | 510 | { |
| 578 | const char * const idle_symbols[] = { | 511 | const char * const idle_symbols[] = { |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 6de9c2b8a601..8a9d910c5345 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
| @@ -221,9 +221,6 @@ struct symbol *dso__first_symbol(struct dso *dso, enum map_type type); | |||
| 221 | 221 | ||
| 222 | int filename__read_build_id(const char *filename, void *bf, size_t size); | 222 | int filename__read_build_id(const char *filename, void *bf, size_t size); |
| 223 | int sysfs__read_build_id(const char *filename, void *bf, size_t size); | 223 | int sysfs__read_build_id(const char *filename, void *bf, size_t size); |
| 224 | int kallsyms__parse(const char *filename, void *arg, | ||
| 225 | int (*process_symbol)(void *arg, const char *name, | ||
| 226 | char type, u64 start)); | ||
| 227 | int modules__parse(const char *filename, void *arg, | 224 | int modules__parse(const char *filename, void *arg, |
| 228 | int (*process_module)(void *arg, const char *name, | 225 | int (*process_module)(void *arg, const char *name, |
| 229 | u64 start)); | 226 | u64 start)); |
