diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2011-02-14 13:47:53 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2011-02-14 15:37:06 -0500 |
| commit | d4b6a3efdf7604d2edcb8470543b39cdedce60f4 (patch) | |
| tree | b1df96346028b16311ffd5e5440c0da2f24c98f7 | |
| parent | 00bacb780b8b5076224577ec15be8b4d7d6ec99d (diff) | |
trace-cmd/report: Add --kallsyms to insert function list
If for some reason a trace.dat file is missing the function list
(sometimes happens when creating a trace.dat from restore), add
away to allow trace-cmd report to pull in a kallsyms file to
use instead.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-read.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/trace-read.c b/trace-read.c index 15284f5..326054e 100644 --- a/trace-read.c +++ b/trace-read.c | |||
| @@ -679,10 +679,47 @@ static void add_cpu(const char *cpu_str) | |||
| 679 | __add_cpu(cpu); | 679 | __add_cpu(cpu); |
| 680 | } | 680 | } |
| 681 | 681 | ||
| 682 | static void read_file_fd(int fd, char *dst, int len) | ||
| 683 | { | ||
| 684 | size_t size = 0; | ||
| 685 | int r; | ||
| 686 | |||
| 687 | do { | ||
| 688 | r = read(fd, dst+size, len); | ||
| 689 | if (r > 0) { | ||
| 690 | size += r; | ||
| 691 | len -= r; | ||
| 692 | } | ||
| 693 | } while (r > 0); | ||
| 694 | } | ||
| 695 | |||
| 696 | static void add_functions(struct pevent *pevent, const char *file) | ||
| 697 | { | ||
| 698 | struct stat st; | ||
| 699 | char *buf; | ||
| 700 | int ret; | ||
| 701 | int fd; | ||
| 702 | |||
| 703 | fd = open(file, O_RDONLY); | ||
| 704 | if (fd < 0) | ||
| 705 | die("Can't read file %s", file); | ||
| 706 | |||
| 707 | ret = fstat(fd, &st); | ||
| 708 | if (ret < 0) | ||
| 709 | die("Can't stat file %s", file); | ||
| 710 | |||
| 711 | buf = malloc_or_die(st.st_size); | ||
| 712 | read_file_fd(fd, buf, st.st_size); | ||
| 713 | close(fd); | ||
| 714 | parse_proc_kallsyms(pevent, buf, st.st_size); | ||
| 715 | free(buf); | ||
| 716 | } | ||
| 717 | |||
| 682 | void trace_report (int argc, char **argv) | 718 | void trace_report (int argc, char **argv) |
| 683 | { | 719 | { |
| 684 | struct tracecmd_input *handle; | 720 | struct tracecmd_input *handle; |
| 685 | struct pevent *pevent; | 721 | struct pevent *pevent; |
| 722 | const char *functions = NULL; | ||
| 686 | int show_funcs = 0; | 723 | int show_funcs = 0; |
| 687 | int show_endian = 0; | 724 | int show_endian = 0; |
| 688 | int show_page_size = 0; | 725 | int show_page_size = 0; |
| @@ -709,6 +746,7 @@ void trace_report (int argc, char **argv) | |||
| 709 | {"cpu", required_argument, NULL, 0}, | 746 | {"cpu", required_argument, NULL, 0}, |
| 710 | {"events", no_argument, NULL, 0}, | 747 | {"events", no_argument, NULL, 0}, |
| 711 | {"filter-test", no_argument, NULL, 'T'}, | 748 | {"filter-test", no_argument, NULL, 'T'}, |
| 749 | {"kallsyms", required_argument, NULL, 0}, | ||
| 712 | {"help", no_argument, NULL, '?'}, | 750 | {"help", no_argument, NULL, '?'}, |
| 713 | {NULL, 0, NULL, 0} | 751 | {NULL, 0, NULL, 0} |
| 714 | }; | 752 | }; |
| @@ -785,6 +823,9 @@ void trace_report (int argc, char **argv) | |||
| 785 | case 2: /* filter-test */ | 823 | case 2: /* filter-test */ |
| 786 | test_filters = 1; | 824 | test_filters = 1; |
| 787 | break; | 825 | break; |
| 826 | case 3: /* kallsyms */ | ||
| 827 | functions = optarg; | ||
| 828 | break; | ||
| 788 | default: | 829 | default: |
| 789 | usage(argv); | 830 | usage(argv); |
| 790 | } | 831 | } |
| @@ -824,6 +865,9 @@ void trace_report (int argc, char **argv) | |||
| 824 | if (test_filters) | 865 | if (test_filters) |
| 825 | pevent->test_filters = 1; | 866 | pevent->test_filters = 1; |
| 826 | 867 | ||
| 868 | if (functions) | ||
| 869 | add_functions(pevent, functions); | ||
| 870 | |||
| 827 | if (show_endian) { | 871 | if (show_endian) { |
| 828 | printf("file is %s endian and host is %s endian\n", | 872 | printf("file is %s endian and host is %s endian\n", |
| 829 | pevent_is_file_bigendian(pevent) ? "big" : "little", | 873 | pevent_is_file_bigendian(pevent) ? "big" : "little", |
