diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2009-11-25 23:52:27 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2009-11-25 23:55:01 -0500 |
| commit | 2f4ca05dc388f56309c38bedda9722592cebabf1 (patch) | |
| tree | 24db821af382f570328098b8e13681f01c667f42 | |
| parent | f2d74555a9de36ae98d6ffa45c1d6d292cde6adb (diff) | |
Create default event override for function tracer
The libparsevent currently does special cases for the function tracer.
This patch replaces the special case with a event override. This is
loaded by libtracecmd.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | parse-events.c | 8 | ||||
| -rw-r--r-- | parse-events.h | 1 | ||||
| -rw-r--r-- | trace-cmd.h | 2 | ||||
| -rw-r--r-- | trace-ftrace.c | 50 | ||||
| -rw-r--r-- | trace-input.c | 2 |
6 files changed, 56 insertions, 9 deletions
| @@ -35,7 +35,7 @@ libparsevent.so: $(PEVENT_LIB_OBJS) | |||
| 35 | libparsevent.a: $(PEVENT_LIB_OBJS) | 35 | libparsevent.a: $(PEVENT_LIB_OBJS) |
| 36 | $(RM) $@; $(AR) rcs $@ $^ | 36 | $(RM) $@; $(AR) rcs $@ $^ |
| 37 | 37 | ||
| 38 | TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o | 38 | TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o |
| 39 | 39 | ||
| 40 | libtracecmd.a: $(TCMD_LIB_OBJS) | 40 | libtracecmd.a: $(TCMD_LIB_OBJS) |
| 41 | $(RM) $@; $(AR) rcs $@ $^ | 41 | $(RM) $@; $(AR) rcs $@ $^ |
diff --git a/parse-events.c b/parse-events.c index 82d5d21..7fdd64b 100644 --- a/parse-events.c +++ b/parse-events.c | |||
| @@ -2694,9 +2694,6 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
| 2694 | return; | 2694 | return; |
| 2695 | } | 2695 | } |
| 2696 | 2696 | ||
| 2697 | if (event->flags & EVENT_FL_ISFUNC) | ||
| 2698 | ptr = " %pF <-- %pF"; | ||
| 2699 | |||
| 2700 | if (event->flags & EVENT_FL_ISBPRINT) { | 2697 | if (event->flags & EVENT_FL_ISBPRINT) { |
| 2701 | bprint_fmt = get_bprint_format(data, size, event); | 2698 | bprint_fmt = get_bprint_format(data, size, event); |
| 2702 | args = make_bprint_args(bprint_fmt, data, size, event); | 2699 | args = make_bprint_args(bprint_fmt, data, size, event); |
| @@ -3467,10 +3464,7 @@ int pevent_parse_event(char *buf, unsigned long size, char *sys) | |||
| 3467 | 3464 | ||
| 3468 | event->flags |= EVENT_FL_ISFTRACE; | 3465 | event->flags |= EVENT_FL_ISFTRACE; |
| 3469 | 3466 | ||
| 3470 | if (strcmp(event->name, "function") == 0) | 3467 | if (strcmp(event->name, "funcgraph_entry") == 0) |
| 3471 | event->flags |= EVENT_FL_ISFUNC; | ||
| 3472 | |||
| 3473 | else if (strcmp(event->name, "funcgraph_entry") == 0) | ||
| 3474 | event->flags |= EVENT_FL_ISFUNCENT; | 3468 | event->flags |= EVENT_FL_ISFUNCENT; |
| 3475 | 3469 | ||
| 3476 | else if (strcmp(event->name, "funcgraph_exit") == 0) | 3470 | else if (strcmp(event->name, "funcgraph_exit") == 0) |
diff --git a/parse-events.h b/parse-events.h index 6adf526..138f140 100644 --- a/parse-events.h +++ b/parse-events.h | |||
| @@ -189,7 +189,6 @@ enum { | |||
| 189 | EVENT_FL_ISFTRACE = 0x01, | 189 | EVENT_FL_ISFTRACE = 0x01, |
| 190 | EVENT_FL_ISPRINT = 0x02, | 190 | EVENT_FL_ISPRINT = 0x02, |
| 191 | EVENT_FL_ISBPRINT = 0x04, | 191 | EVENT_FL_ISBPRINT = 0x04, |
| 192 | EVENT_FL_ISFUNC = 0x08, | ||
| 193 | EVENT_FL_ISFUNCENT = 0x10, | 192 | EVENT_FL_ISFUNCENT = 0x10, |
| 194 | EVENT_FL_ISFUNCRET = 0x20, | 193 | EVENT_FL_ISFUNCRET = 0x20, |
| 195 | 194 | ||
diff --git a/trace-cmd.h b/trace-cmd.h index e9e3b1e..34e4012 100644 --- a/trace-cmd.h +++ b/trace-cmd.h | |||
| @@ -42,5 +42,7 @@ tracecmd_peek_data(struct tracecmd_handle *handle, int cpu); | |||
| 42 | struct record * | 42 | struct record * |
| 43 | tracecmd_read_data(struct tracecmd_handle *handle, int cpu); | 43 | tracecmd_read_data(struct tracecmd_handle *handle, int cpu); |
| 44 | 44 | ||
| 45 | int tracecmd_ftrace_overrides(void); | ||
| 46 | |||
| 45 | 47 | ||
| 46 | #endif /* _TRACE_CMD_H */ | 48 | #endif /* _TRACE_CMD_H */ |
diff --git a/trace-ftrace.c b/trace-ftrace.c new file mode 100644 index 0000000..3174f89 --- /dev/null +++ b/trace-ftrace.c | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <string.h> | ||
| 4 | |||
| 5 | #include "parse-events.h" | ||
| 6 | |||
| 7 | static int function_handler(struct trace_seq *s, void *data, int size, | ||
| 8 | struct event *event) | ||
| 9 | { | ||
| 10 | struct format_field *ip = pevent_find_field(event, "ip"); | ||
| 11 | struct format_field *pip = pevent_find_field(event, "parent_ip"); | ||
| 12 | unsigned long long function; | ||
| 13 | const char *func; | ||
| 14 | |||
| 15 | if (!ip) | ||
| 16 | return trace_seq_printf(s, "CANT FIND FIELD IP"); | ||
| 17 | |||
| 18 | if (pevent_read_number_field(ip, data, &function)) | ||
| 19 | trace_seq_printf(s, " function=INVALID"); | ||
| 20 | else { | ||
| 21 | func = pevent_find_function(function); | ||
| 22 | if (func) | ||
| 23 | trace_seq_printf(s, "%s <-- ", func); | ||
| 24 | else | ||
| 25 | trace_seq_printf(s, "0x%llx", function); | ||
| 26 | } | ||
| 27 | |||
| 28 | if (!pip) | ||
| 29 | return trace_seq_printf(s, "CANT FIND FIELD PARENT_IP"); | ||
| 30 | |||
| 31 | if (pevent_read_number_field(pip, data, &function)) | ||
| 32 | trace_seq_printf(s, " function=INVALID"); | ||
| 33 | else { | ||
| 34 | func = pevent_find_function(function); | ||
| 35 | if (func) | ||
| 36 | trace_seq_printf(s, "%s", func); | ||
| 37 | else | ||
| 38 | trace_seq_printf(s, "0x%llx", function); | ||
| 39 | } | ||
| 40 | |||
| 41 | return 0; | ||
| 42 | } | ||
| 43 | |||
| 44 | int tracecmd_ftrace_overrides(void) | ||
| 45 | { | ||
| 46 | pevent_register_event_handler(-1, "ftrace", "function", | ||
| 47 | function_handler); | ||
| 48 | |||
| 49 | return 0; | ||
| 50 | } | ||
diff --git a/trace-input.c b/trace-input.c index 239c9d3..77db2f5 100644 --- a/trace-input.c +++ b/trace-input.c | |||
| @@ -399,6 +399,8 @@ int tracecmd_read_headers(struct tracecmd_handle *handle) | |||
| 399 | if (ret < 0) | 399 | if (ret < 0) |
| 400 | return -1; | 400 | return -1; |
| 401 | 401 | ||
| 402 | /* register default ftrace functions first */ | ||
| 403 | tracecmd_ftrace_overrides(); | ||
| 402 | 404 | ||
| 403 | trace_load_plugins(); | 405 | trace_load_plugins(); |
| 404 | 406 | ||
