aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-03-18 16:48:37 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-03-18 16:48:37 -0400
commit3e8b5b82568a325b6e2e218cd8f18e62ea3fa814 (patch)
tree4673dc842392a807591b97b7b740192674586724
parent9b66956cb4660bd49983482c3529ca069fa97b3e (diff)
trace-cmd: Add ftrace options with fgraph tailprint option
Added internal options for ftrace, and included a fgraph:tailprint option that will print the function names at the function exit. When the option is set, instead of just '}' the name will be added '} /* func_name */' Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-cmd.h2
-rw-r--r--trace-ftrace.c25
-rw-r--r--trace-input.c3
-rw-r--r--trace-util.c50
4 files changed, 66 insertions, 14 deletions
diff --git a/trace-cmd.h b/trace-cmd.h
index b8137b5..cec0072 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -207,6 +207,8 @@ void tracecmd_stop_recording(struct tracecmd_recorder *recorder);
207void tracecmd_stat_cpu(struct trace_seq *s, int cpu); 207void tracecmd_stat_cpu(struct trace_seq *s, int cpu);
208 208
209/* --- Plugin handling --- */ 209/* --- Plugin handling --- */
210extern struct plugin_option trace_ftrace_options[];
211
210void trace_util_add_option(const char *name, const char *val); 212void trace_util_add_option(const char *name, const char *val);
211void trace_util_load_plugins(struct pevent *pevent, const char *suffix, 213void trace_util_load_plugins(struct pevent *pevent, const char *suffix,
212 void (*load_plugin)(struct pevent *pevent, 214 void (*load_plugin)(struct pevent *pevent,
diff --git a/trace-ftrace.c b/trace-ftrace.c
index 193e85d..76aef5b 100644
--- a/trace-ftrace.c
+++ b/trace-ftrace.c
@@ -25,6 +25,20 @@
25 25
26#include "trace-cmd.h" 26#include "trace-cmd.h"
27 27
28struct plugin_option trace_ftrace_options[] = {
29 {
30 .name = "tailprint",
31 .plugin_alias = "fgraph",
32 .description =
33 "Print function name at function exit in function graph",
34 },
35 {
36 .name = NULL,
37 }
38};
39
40static struct plugin_option *fgraph_tail = &trace_ftrace_options[0];
41
28static void find_long_size(struct tracecmd_ftrace *finfo) 42static void find_long_size(struct tracecmd_ftrace *finfo)
29{ 43{
30 finfo->long_size = tracecmd_long_size(finfo->handle); 44 finfo->long_size = tracecmd_long_size(finfo->handle);
@@ -290,6 +304,8 @@ fgraph_ret_handler(struct trace_seq *s, struct record *record,
290 struct tracecmd_ftrace *finfo = context; 304 struct tracecmd_ftrace *finfo = context;
291 unsigned long long rettime, calltime; 305 unsigned long long rettime, calltime;
292 unsigned long long duration, depth; 306 unsigned long long duration, depth;
307 unsigned long long val;
308 const char *func;
293 int i; 309 int i;
294 310
295 ret_event_check(finfo, event->pevent); 311 ret_event_check(finfo, event->pevent);
@@ -317,6 +333,15 @@ fgraph_ret_handler(struct trace_seq *s, struct record *record,
317 333
318 trace_seq_putc(s, '}'); 334 trace_seq_putc(s, '}');
319 335
336 if (fgraph_tail->set) {
337 if (pevent_get_field_val(s, event, "func", record, &val, 0))
338 return 0;
339 func = pevent_find_function(event->pevent, val);
340 if (!func)
341 return 0;
342 trace_seq_printf(s, " /* %s */", func);
343 }
344
320 return 0; 345 return 0;
321} 346}
322 347
diff --git a/trace-input.c b/trace-input.c
index c3b58b1..97459eb 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -2173,6 +2173,9 @@ struct tracecmd_input *tracecmd_alloc_fd(int fd)
2173 /* register default ftrace functions first */ 2173 /* register default ftrace functions first */
2174 tracecmd_ftrace_overrides(handle, &handle->finfo); 2174 tracecmd_ftrace_overrides(handle, &handle->finfo);
2175 2175
2176 /* Add the ftrace options */
2177 trace_util_ftrace_options();
2178
2176 handle->plugin_list = tracecmd_load_plugins(handle->pevent); 2179 handle->plugin_list = tracecmd_load_plugins(handle->pevent);
2177 2180
2178 handle->pevent->file_bigendian = buf[0]; 2181 handle->pevent->file_bigendian = buf[0];
diff --git a/trace-util.c b/trace-util.c
index 04cb087..de59a3f 100644
--- a/trace-util.c
+++ b/trace-util.c
@@ -61,6 +61,18 @@ struct plugin_list {
61 void *handle; 61 void *handle;
62}; 62};
63 63
64static void update_option(const char *file, struct plugin_option *option);
65
66void trace_util_ftrace_options(void)
67{
68 struct plugin_option *options = trace_ftrace_options;
69
70 while (options->name) {
71 update_option("ftrace", options);
72 options++;
73 }
74}
75
64void trace_util_add_option(const char *name, const char *val) 76void trace_util_add_option(const char *name, const char *val)
65{ 77{
66 struct trace_plugin_options *option; 78 struct trace_plugin_options *option;
@@ -909,12 +921,28 @@ struct plugin_option_read {
909 struct plugin_option *options; 921 struct plugin_option *options;
910}; 922};
911 923
924static void append_option(struct plugin_option_read *options,
925 struct plugin_option *option,
926 const char *alias, void *handle)
927{
928 struct plugin_option *op;
929
930 while (option->name) {
931 op = malloc_or_die(sizeof(*op));
932 *op = *option;
933 op->next = options->options;
934 options->options = op;
935 op->file = strdup(alias);
936 op->handle = handle;
937 option++;
938 }
939}
940
912static void read_options(struct pevent *pevent, const char *path, 941static void read_options(struct pevent *pevent, const char *path,
913 const char *file, void *data) 942 const char *file, void *data)
914{ 943{
915 struct plugin_option_read *option = data; 944 struct plugin_option_read *options = data;
916 struct plugin_option *options; 945 struct plugin_option *option;
917 struct plugin_option *op;
918 const char *alias; 946 const char *alias;
919 int unload = 0; 947 int unload = 0;
920 char *plugin; 948 char *plugin;
@@ -937,21 +965,13 @@ static void read_options(struct pevent *pevent, const char *path,
937 if (!alias) 965 if (!alias)
938 alias = file; 966 alias = file;
939 967
940 options = dlsym(handle, PEVENT_PLUGIN_OPTIONS_NAME); 968 option = dlsym(handle, PEVENT_PLUGIN_OPTIONS_NAME);
941 if (!options) { 969 if (!option) {
942 unload = 1; 970 unload = 1;
943 goto out_unload; 971 goto out_unload;
944 } 972 }
945 973
946 while (options->name) { 974 append_option(options, option, alias, handle);
947 op = malloc_or_die(sizeof(*op));
948 *op = *options;
949 op->next = option->options;
950 option->options = op;
951 op->file = strdup(alias);
952 op->handle = handle;
953 options++;
954 }
955 975
956 out_unload: 976 out_unload:
957 if (unload) 977 if (unload)
@@ -966,6 +986,8 @@ struct plugin_option *trace_util_read_plugin_options(void)
966 .options = NULL, 986 .options = NULL,
967 }; 987 };
968 988
989 append_option(&option, trace_ftrace_options, "ftrace", NULL);
990
969 trace_util_load_plugins(NULL, ".so", read_options, &option); 991 trace_util_load_plugins(NULL, ".so", read_options, &option);
970 992
971 return option.options; 993 return option.options;