diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-11-16 23:53:44 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-11-16 23:53:44 -0500 |
commit | 9a7533f99ed008e03de9455df31075e77789a207 (patch) | |
tree | 7c79c3c32c78d9ddb4c5af2e7d8a5b8ac2494a21 | |
parent | 68786449232dc6a9c989e8c9030078bac8c9f3f7 (diff) |
Separate out tracing setup functions
The functions that set up reading the data files may be used
by other routines. Separate them out into their own functions.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-read.c | 79 |
1 files changed, 47 insertions, 32 deletions
diff --git a/trace-read.c b/trace-read.c index f7fe6af..79530bc 100644 --- a/trace-read.c +++ b/trace-read.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include "parse-events.h" | 39 | #include "parse-events.h" |
40 | 40 | ||
41 | int input_fd; | 41 | int input_fd; |
42 | const char *input_file = "trace.dat"; | ||
42 | 43 | ||
43 | static int read_page; | 44 | static int read_page; |
44 | 45 | ||
@@ -591,13 +592,53 @@ static void read_data_info(void) | |||
591 | } while (next >= 0); | 592 | } while (next >= 0); |
592 | } | 593 | } |
593 | 594 | ||
594 | 595 | int read_trace_header(void) | |
595 | void trace_report (int argc, char **argv) | ||
596 | { | 596 | { |
597 | const char *input_file = "trace.dat"; | ||
598 | char buf[BUFSIZ]; | ||
599 | char test[] = { 23, 8, 68 }; | 597 | char test[] = { 23, 8, 68 }; |
600 | char *version; | 598 | char *version; |
599 | char buf[BUFSIZ]; | ||
600 | |||
601 | input_fd = open(input_file, O_RDONLY); | ||
602 | if (input_fd < 0) | ||
603 | die("opening '%s'\n", input_file); | ||
604 | |||
605 | read_or_die(buf, 3); | ||
606 | if (memcmp(buf, test, 3) != 0) | ||
607 | die("not an trace data file"); | ||
608 | |||
609 | read_or_die(buf, 7); | ||
610 | if (memcmp(buf, "tracing", 7) != 0) | ||
611 | die("not a trace file (missing tracing)"); | ||
612 | |||
613 | version = read_string(); | ||
614 | printf("version = %s\n", version); | ||
615 | free(version); | ||
616 | |||
617 | read_or_die(buf, 1); | ||
618 | file_bigendian = buf[0]; | ||
619 | host_bigendian = bigendian(); | ||
620 | |||
621 | read_or_die(buf, 1); | ||
622 | long_size = buf[0]; | ||
623 | |||
624 | page_size = read4(); | ||
625 | |||
626 | return 0; | ||
627 | } | ||
628 | |||
629 | int read_trace_files(void) | ||
630 | { | ||
631 | read_header_files(); | ||
632 | read_ftrace_files(); | ||
633 | read_event_files(); | ||
634 | read_proc_kallsyms(); | ||
635 | read_ftrace_printk(); | ||
636 | |||
637 | return 0; | ||
638 | } | ||
639 | |||
640 | void trace_report (int argc, char **argv) | ||
641 | { | ||
601 | int show_funcs = 0; | 642 | int show_funcs = 0; |
602 | int show_endian = 0; | 643 | int show_endian = 0; |
603 | int show_page_size = 0; | 644 | int show_page_size = 0; |
@@ -658,30 +699,8 @@ void trace_report (int argc, char **argv) | |||
658 | } | 699 | } |
659 | } | 700 | } |
660 | 701 | ||
661 | input_fd = open(input_file, O_RDONLY); | 702 | read_trace_header(); |
662 | if (input_fd < 0) | ||
663 | die("opening '%s'\n", input_file); | ||
664 | |||
665 | read_or_die(buf, 3); | ||
666 | if (memcmp(buf, test, 3) != 0) | ||
667 | die("not an trace data file"); | ||
668 | |||
669 | read_or_die(buf, 7); | ||
670 | if (memcmp(buf, "tracing", 7) != 0) | ||
671 | die("not a trace file (missing tracing)"); | ||
672 | 703 | ||
673 | version = read_string(); | ||
674 | printf("version = %s\n", version); | ||
675 | free(version); | ||
676 | |||
677 | read_or_die(buf, 1); | ||
678 | file_bigendian = buf[0]; | ||
679 | host_bigendian = bigendian(); | ||
680 | |||
681 | read_or_die(buf, 1); | ||
682 | long_size = buf[0]; | ||
683 | |||
684 | page_size = read4(); | ||
685 | if (show_page_size) { | 704 | if (show_page_size) { |
686 | printf("file page size is %d, and host page size is %d\n", | 705 | printf("file page size is %d, and host page size is %d\n", |
687 | page_size, | 706 | page_size, |
@@ -696,11 +715,7 @@ void trace_report (int argc, char **argv) | |||
696 | return; | 715 | return; |
697 | } | 716 | } |
698 | 717 | ||
699 | read_header_files(); | 718 | read_trace_files(); |
700 | read_ftrace_files(); | ||
701 | read_event_files(); | ||
702 | read_proc_kallsyms(); | ||
703 | read_ftrace_printk(); | ||
704 | 719 | ||
705 | if (show_funcs) { | 720 | if (show_funcs) { |
706 | print_funcs(); | 721 | print_funcs(); |