diff options
author | Jiri Olsa <jolsa@redhat.com> | 2013-12-03 08:09:39 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-04 13:37:24 -0500 |
commit | 39956e78010645ee9d121e6a6eb6d9892e3fc92e (patch) | |
tree | a5a18b4974c82f16995be2e9ab873ab594f51c16 /tools/lib/traceevent/plugin_function.c | |
parent | b32cea650a16092a654baa2095c78fa917bad4da (diff) |
tools lib traceevent: Several cleanups for function plugin
Several cleanups suggested by Namhyung:
* Remove index field from struct func_stack as it's not needed.
* Rename get_index into add_and_get_index.
* Use '%*X' format string capability instead of the loop
Suggested-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1386076182-14484-26-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/traceevent/plugin_function.c')
-rw-r--r-- | tools/lib/traceevent/plugin_function.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c index 8deb22e69361..87acf9c77948 100644 --- a/tools/lib/traceevent/plugin_function.c +++ b/tools/lib/traceevent/plugin_function.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include "event-utils.h" | 25 | #include "event-utils.h" |
26 | 26 | ||
27 | static struct func_stack { | 27 | static struct func_stack { |
28 | int index; | ||
29 | int size; | 28 | int size; |
30 | char **stack; | 29 | char **stack; |
31 | } *fstack; | 30 | } *fstack; |
@@ -57,7 +56,7 @@ static void add_child(struct func_stack *stack, const char *child, int pos) | |||
57 | stack->stack[pos] = strdup(child); | 56 | stack->stack[pos] = strdup(child); |
58 | } | 57 | } |
59 | 58 | ||
60 | static int get_index(const char *parent, const char *child, int cpu) | 59 | static int add_and_get_index(const char *parent, const char *child, int cpu) |
61 | { | 60 | { |
62 | int i; | 61 | int i; |
63 | 62 | ||
@@ -97,7 +96,7 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record, | |||
97 | unsigned long long pfunction; | 96 | unsigned long long pfunction; |
98 | const char *func; | 97 | const char *func; |
99 | const char *parent; | 98 | const char *parent; |
100 | int i, index; | 99 | int index; |
101 | 100 | ||
102 | if (pevent_get_field_val(s, event, "ip", record, &function, 1)) | 101 | if (pevent_get_field_val(s, event, "ip", record, &function, 1)) |
103 | return trace_seq_putc(s, '!'); | 102 | return trace_seq_putc(s, '!'); |
@@ -109,10 +108,9 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record, | |||
109 | 108 | ||
110 | parent = pevent_find_function(pevent, pfunction); | 109 | parent = pevent_find_function(pevent, pfunction); |
111 | 110 | ||
112 | index = get_index(parent, func, record->cpu); | 111 | index = add_and_get_index(parent, func, record->cpu); |
113 | 112 | ||
114 | for (i = 0; i < index; i++) | 113 | trace_seq_printf(s, "%*s", index*3, ""); |
115 | trace_seq_printf(s, " "); | ||
116 | 114 | ||
117 | if (func) | 115 | if (func) |
118 | trace_seq_printf(s, "%s", func); | 116 | trace_seq_printf(s, "%s", func); |