aboutsummaryrefslogtreecommitdiffstats
path: root/trace-ftrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'trace-ftrace.c')
-rw-r--r--trace-ftrace.c65
1 files changed, 22 insertions, 43 deletions
diff --git a/trace-ftrace.c b/trace-ftrace.c
index 181a00f..f12b221 100644
--- a/trace-ftrace.c
+++ b/trace-ftrace.c
@@ -29,35 +29,14 @@ static struct event_format *fgraph_ret_event;
29static int fgraph_ret_id; 29static int fgraph_ret_id;
30static int long_size; 30static int long_size;
31 31
32static int get_field_val(struct trace_seq *s, void *data,
33 struct event_format *event, const char *name,
34 unsigned long long *val)
35{
36 struct format_field *field;
37
38 field = pevent_find_any_field(event, name);
39 if (!field) {
40 trace_seq_printf(s, "<CANT FIND FIELD %s>", name);
41 return -1;
42 }
43
44 if (pevent_read_number_field(field, data, val)) {
45 trace_seq_printf(s, " %s=INVALID", name);
46 return -1;
47 }
48
49 return 0;
50}
51
52static int function_handler(struct trace_seq *s, struct record *record, 32static int function_handler(struct trace_seq *s, struct record *record,
53 struct event_format *event, void *context) 33 struct event_format *event, void *context)
54{ 34{
55 struct pevent *pevent = event->pevent; 35 struct pevent *pevent = event->pevent;
56 unsigned long long function; 36 unsigned long long function;
57 const char *func; 37 const char *func;
58 void *data = record->data;
59 38
60 if (get_field_val(s, data, event, "ip", &function)) 39 if (pevent_get_field_val(s, event, "ip", record, &function, 1))
61 return trace_seq_putc(s, '!'); 40 return trace_seq_putc(s, '!');
62 41
63 func = pevent_find_function(pevent, function); 42 func = pevent_find_function(pevent, function);
@@ -66,7 +45,7 @@ static int function_handler(struct trace_seq *s, struct record *record,
66 else 45 else
67 trace_seq_printf(s, "0x%llx", function); 46 trace_seq_printf(s, "0x%llx", function);
68 47
69 if (get_field_val(s, data, event, "parent_ip", &function)) 48 if (pevent_get_field_val(s, event, "parent_ip", record, &function, 1))
70 return trace_seq_putc(s, '!'); 49 return trace_seq_putc(s, '!');
71 50
72 func = pevent_find_function(pevent, function); 51 func = pevent_find_function(pevent, function);
@@ -89,20 +68,20 @@ get_return_for_leaf(struct trace_seq *s, int cpu, int cur_pid,
89 unsigned long long pid; 68 unsigned long long pid;
90 69
91 /* Searching a common field, can use any event */ 70 /* Searching a common field, can use any event */
92 if (get_field_val(s, next->data, fgraph_ret_event, "common_type", &type)) 71 if (pevent_get_common_field_val(s, fgraph_ret_event, "common_type", next, &type, 1))
93 return NULL; 72 return NULL;
94 73
95 if (type != fgraph_ret_id) 74 if (type != fgraph_ret_id)
96 return NULL; 75 return NULL;
97 76
98 if (get_field_val(s, next->data, fgraph_ret_event, "common_pid", &pid)) 77 if (pevent_get_common_field_val(s, fgraph_ret_event, "common_pid", next, &pid, 1))
99 return NULL; 78 return NULL;
100 79
101 if (cur_pid != pid) 80 if (cur_pid != pid)
102 return NULL; 81 return NULL;
103 82
104 /* We aleady know this is a funcgraph_ret_event */ 83 /* We aleady know this is a funcgraph_ret_event */
105 if (get_field_val(s, next->data, fgraph_ret_event, "func", &val)) 84 if (pevent_get_field_val(s, fgraph_ret_event, "func", next, &val, 1))
106 return NULL; 85 return NULL;
107 86
108 if (cur_func != val) 87 if (cur_func != val)
@@ -166,7 +145,8 @@ static void print_graph_duration(struct trace_seq *s, unsigned long long duratio
166 145
167static int 146static int
168print_graph_entry_leaf(struct trace_seq *s, 147print_graph_entry_leaf(struct trace_seq *s,
169 struct event_format *event, void *data, struct record *ret_rec) 148 struct event_format *event,
149 struct record *record, struct record *ret_rec)
170{ 150{
171 struct pevent *pevent = event->pevent; 151 struct pevent *pevent = event->pevent;
172 unsigned long long rettime, calltime; 152 unsigned long long rettime, calltime;
@@ -176,10 +156,10 @@ print_graph_entry_leaf(struct trace_seq *s,
176 int i; 156 int i;
177 157
178 158
179 if (get_field_val(s, ret_rec->data, fgraph_ret_event, "rettime", &rettime)) 159 if (pevent_get_field_val(s, fgraph_ret_event, "rettime", ret_rec, &rettime, 1))
180 return trace_seq_putc(s, '!'); 160 return trace_seq_putc(s, '!');
181 161
182 if (get_field_val(s, ret_rec->data, fgraph_ret_event, "calltime", &calltime)) 162 if (pevent_get_field_val(s, fgraph_ret_event, "calltime", ret_rec, &calltime, 1))
183 return trace_seq_putc(s, '!'); 163 return trace_seq_putc(s, '!');
184 164
185 duration = rettime - calltime; 165 duration = rettime - calltime;
@@ -190,14 +170,14 @@ print_graph_entry_leaf(struct trace_seq *s,
190 /* Duration */ 170 /* Duration */
191 print_graph_duration(s, duration); 171 print_graph_duration(s, duration);
192 172
193 if (get_field_val(s, data, event, "depth", &depth)) 173 if (pevent_get_field_val(s, event, "depth", record, &depth, 1))
194 return trace_seq_putc(s, '!'); 174 return trace_seq_putc(s, '!');
195 175
196 /* Function */ 176 /* Function */
197 for (i = 0; i < (int)(depth * TRACE_GRAPH_INDENT); i++) 177 for (i = 0; i < (int)(depth * TRACE_GRAPH_INDENT); i++)
198 trace_seq_putc(s, ' '); 178 trace_seq_putc(s, ' ');
199 179
200 if (get_field_val(s, data, event, "func", &val)) 180 if (pevent_get_field_val(s, event, "func", record, &val, 1))
201 return trace_seq_putc(s, '!'); 181 return trace_seq_putc(s, '!');
202 func = pevent_find_function(pevent, val); 182 func = pevent_find_function(pevent, val);
203 183
@@ -208,7 +188,8 @@ print_graph_entry_leaf(struct trace_seq *s,
208} 188}
209 189
210static int print_graph_nested(struct trace_seq *s, 190static int print_graph_nested(struct trace_seq *s,
211 struct event_format *event, void *data) 191 struct event_format *event,
192 struct record *record)
212{ 193{
213 struct pevent *pevent = event->pevent; 194 struct pevent *pevent = event->pevent;
214 unsigned long long depth; 195 unsigned long long depth;
@@ -222,14 +203,14 @@ static int print_graph_nested(struct trace_seq *s,
222 /* No time */ 203 /* No time */
223 trace_seq_puts(s, " | "); 204 trace_seq_puts(s, " | ");
224 205
225 if (get_field_val(s, data, event, "depth", &depth)) 206 if (pevent_get_field_val(s, event, "depth", record, &depth, 1))
226 return trace_seq_putc(s, '!'); 207 return trace_seq_putc(s, '!');
227 208
228 /* Function */ 209 /* Function */
229 for (i = 0; i < (int)(depth * TRACE_GRAPH_INDENT); i++) 210 for (i = 0; i < (int)(depth * TRACE_GRAPH_INDENT); i++)
230 trace_seq_putc(s, ' '); 211 trace_seq_putc(s, ' ');
231 212
232 if (get_field_val(s, data, event, "func", &val)) 213 if (pevent_get_field_val(s, event, "func", record, &val, 1))
233 return trace_seq_putc(s, '!'); 214 return trace_seq_putc(s, '!');
234 215
235 func = pevent_find_function(pevent, val); 216 func = pevent_find_function(pevent, val);
@@ -246,13 +227,12 @@ fgraph_ent_handler(struct trace_seq *s, struct record *record,
246{ 227{
247 struct record *rec; 228 struct record *rec;
248 unsigned long long val, pid; 229 unsigned long long val, pid;
249 void *data = record->data;
250 int cpu = record->cpu; 230 int cpu = record->cpu;
251 231
252 if (get_field_val(s, data, event, "common_pid", &pid)) 232 if (pevent_get_common_field_val(s, event, "common_pid", record, &pid, 1))
253 return trace_seq_putc(s, '!'); 233 return trace_seq_putc(s, '!');
254 234
255 if (get_field_val(s, data, event, "func", &val)) 235 if (pevent_get_field_val(s, event, "func", record, &val, 1))
256 return trace_seq_putc(s, '!'); 236 return trace_seq_putc(s, '!');
257 237
258 rec = tracecmd_peek_data(tracecmd_curr_thread_handle, cpu); 238 rec = tracecmd_peek_data(tracecmd_curr_thread_handle, cpu);
@@ -264,10 +244,10 @@ fgraph_ent_handler(struct trace_seq *s, struct record *record,
264 * If this is a leaf function, then get_return_for_leaf 244 * If this is a leaf function, then get_return_for_leaf
265 * returns the return of the function 245 * returns the return of the function
266 */ 246 */
267 print_graph_entry_leaf(s, event, data, rec); 247 print_graph_entry_leaf(s, event, record, rec);
268 free_record(rec); 248 free_record(rec);
269 } else 249 } else
270 print_graph_nested(s, event, data); 250 print_graph_nested(s, event, record);
271 251
272 return 0; 252 return 0;
273} 253}
@@ -278,13 +258,12 @@ fgraph_ret_handler(struct trace_seq *s, struct record *record,
278{ 258{
279 unsigned long long rettime, calltime; 259 unsigned long long rettime, calltime;
280 unsigned long long duration, depth; 260 unsigned long long duration, depth;
281 void *data = record->data;
282 int i; 261 int i;
283 262
284 if (get_field_val(s, data, event, "rettime", &rettime)) 263 if (pevent_get_field_val(s, event, "rettime", record, &rettime, 1))
285 return trace_seq_putc(s, '!'); 264 return trace_seq_putc(s, '!');
286 265
287 if (get_field_val(s, data, event, "calltime", &calltime)) 266 if (pevent_get_field_val(s, event, "calltime", record, &calltime, 1))
288 return trace_seq_putc(s, '!'); 267 return trace_seq_putc(s, '!');
289 268
290 duration = rettime - calltime; 269 duration = rettime - calltime;
@@ -295,7 +274,7 @@ fgraph_ret_handler(struct trace_seq *s, struct record *record,
295 /* Duration */ 274 /* Duration */
296 print_graph_duration(s, duration); 275 print_graph_duration(s, duration);
297 276
298 if (get_field_val(s, data, event, "depth", &depth)) 277 if (pevent_get_field_val(s, event, "depth", record, &depth, 1))
299 return trace_seq_putc(s, '!'); 278 return trace_seq_putc(s, '!');
300 279
301 /* Function */ 280 /* Function */