aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/trace-event-parse.c
diff options
context:
space:
mode:
authorTom Zanussi <tzanussi@gmail.com>2009-11-25 02:15:48 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-28 04:04:26 -0500
commit16c632de64a74644a46e7636db26b2cfb530ca13 (patch)
tree4e7fdb4f84a1fba8b299c61a97bc76a8033e0565 /tools/perf/util/trace-event-parse.c
parenteb9a42caa7a926beb935a22bc59d981b35f0b652 (diff)
perf trace: Add Perl scripting support
Implement trace_scripting_ops to make Perl a supported perf trace scripting language. Additionally adds code that allows Perl trace scripts to access the 'flag' and 'symbolic' (__print_flags(), __print_symbolic()) field information parsed from the trace format files. Also adds the Perl implementation of the generate_script() trace_scripting_op, which creates a ready-to-run perf trace Perl script based on existing trace data. Scripts generated by this implementation print out all the fields for each event mentioned in perf.data (and will detect and generate the proper scripting code for 'flag' and 'symbolic' fields), and will additionally generate handlers for the special 'trace_unhandled', 'trace_begin' and 'trace_end' handlers. Script authors can simply remove the printing code to implement their own custom event handling. Signed-off-by: Tom Zanussi <tzanussi@gmail.com> Cc: fweisbec@gmail.com Cc: rostedt@goodmis.org Cc: anton@samba.org Cc: hch@infradead.org LKML-Reference: <1259133352-23685-4-git-send-email-tzanussi@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/trace-event-parse.c')
-rw-r--r--tools/perf/util/trace-event-parse.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 85d7163a9fd4..1f16495e5597 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1888,7 +1888,7 @@ find_any_field(struct event *event, const char *name)
1888 return find_field(event, name); 1888 return find_field(event, name);
1889} 1889}
1890 1890
1891static unsigned long long read_size(void *ptr, int size) 1891unsigned long long read_size(void *ptr, int size)
1892{ 1892{
1893 switch (size) { 1893 switch (size) {
1894 case 1: 1894 case 1:
@@ -1973,7 +1973,7 @@ int trace_parse_common_type(void *data)
1973 "common_type"); 1973 "common_type");
1974} 1974}
1975 1975
1976static int parse_common_pid(void *data) 1976int trace_parse_common_pid(void *data)
1977{ 1977{
1978 static int pid_offset; 1978 static int pid_offset;
1979 static int pid_size; 1979 static int pid_size;
@@ -2025,6 +2025,14 @@ struct event *trace_find_event(int id)
2025 return event; 2025 return event;
2026} 2026}
2027 2027
2028struct event *trace_find_next_event(struct event *event)
2029{
2030 if (!event)
2031 return event_list;
2032
2033 return event->next;
2034}
2035
2028static unsigned long long eval_num_arg(void *data, int size, 2036static unsigned long long eval_num_arg(void *data, int size,
2029 struct event *event, struct print_arg *arg) 2037 struct event *event, struct print_arg *arg)
2030{ 2038{
@@ -2164,7 +2172,7 @@ static const struct flag flags[] = {
2164 { "HRTIMER_RESTART", 1 }, 2172 { "HRTIMER_RESTART", 1 },
2165}; 2173};
2166 2174
2167static unsigned long long eval_flag(const char *flag) 2175unsigned long long eval_flag(const char *flag)
2168{ 2176{
2169 int i; 2177 int i;
2170 2178
@@ -2694,7 +2702,7 @@ get_return_for_leaf(int cpu, int cur_pid, unsigned long long cur_func,
2694 if (!(event->flags & EVENT_FL_ISFUNCRET)) 2702 if (!(event->flags & EVENT_FL_ISFUNCRET))
2695 return NULL; 2703 return NULL;
2696 2704
2697 pid = parse_common_pid(next->data); 2705 pid = trace_parse_common_pid(next->data);
2698 field = find_field(event, "func"); 2706 field = find_field(event, "func");
2699 if (!field) 2707 if (!field)
2700 die("function return does not have field func"); 2708 die("function return does not have field func");
@@ -2980,7 +2988,7 @@ void print_event(int cpu, void *data, int size, unsigned long long nsecs,
2980 return; 2988 return;
2981 } 2989 }
2982 2990
2983 pid = parse_common_pid(data); 2991 pid = trace_parse_common_pid(data);
2984 2992
2985 if (event->flags & (EVENT_FL_ISFUNCENT | EVENT_FL_ISFUNCRET)) 2993 if (event->flags & (EVENT_FL_ISFUNCENT | EVENT_FL_ISFUNCRET))
2986 return pretty_print_func_graph(data, size, event, cpu, 2994 return pretty_print_func_graph(data, size, event, cpu,