.. | .. |
---|
34 | 34 | #include <EXTERN.h> |
---|
35 | 35 | #include <perl.h> |
---|
36 | 36 | |
---|
37 | | -#include "../../perf.h" |
---|
38 | 37 | #include "../callchain.h" |
---|
| 38 | +#include "../dso.h" |
---|
39 | 39 | #include "../machine.h" |
---|
| 40 | +#include "../map.h" |
---|
| 41 | +#include "../symbol.h" |
---|
40 | 42 | #include "../thread.h" |
---|
41 | 43 | #include "../event.h" |
---|
42 | 44 | #include "../trace-event.h" |
---|
.. | .. |
---|
99 | 101 | LEAVE; |
---|
100 | 102 | } |
---|
101 | 103 | |
---|
102 | | -static void define_symbolic_values(struct print_flag_sym *field, |
---|
| 104 | +static void define_symbolic_values(struct tep_print_flag_sym *field, |
---|
103 | 105 | const char *ev_name, |
---|
104 | 106 | const char *field_name) |
---|
105 | 107 | { |
---|
.. | .. |
---|
157 | 159 | LEAVE; |
---|
158 | 160 | } |
---|
159 | 161 | |
---|
160 | | -static void define_flag_values(struct print_flag_sym *field, |
---|
| 162 | +static void define_flag_values(struct tep_print_flag_sym *field, |
---|
161 | 163 | const char *ev_name, |
---|
162 | 164 | const char *field_name) |
---|
163 | 165 | { |
---|
.. | .. |
---|
189 | 191 | LEAVE; |
---|
190 | 192 | } |
---|
191 | 193 | |
---|
192 | | -static void define_event_symbols(struct event_format *event, |
---|
| 194 | +static void define_event_symbols(struct tep_event *event, |
---|
193 | 195 | const char *ev_name, |
---|
194 | | - struct print_arg *args) |
---|
| 196 | + struct tep_print_arg *args) |
---|
195 | 197 | { |
---|
196 | 198 | if (args == NULL) |
---|
197 | 199 | return; |
---|
198 | 200 | |
---|
199 | 201 | switch (args->type) { |
---|
200 | | - case PRINT_NULL: |
---|
| 202 | + case TEP_PRINT_NULL: |
---|
201 | 203 | break; |
---|
202 | | - case PRINT_ATOM: |
---|
| 204 | + case TEP_PRINT_ATOM: |
---|
203 | 205 | define_flag_value(ev_name, cur_field_name, "0", |
---|
204 | 206 | args->atom.atom); |
---|
205 | 207 | zero_flag_atom = 0; |
---|
206 | 208 | break; |
---|
207 | | - case PRINT_FIELD: |
---|
| 209 | + case TEP_PRINT_FIELD: |
---|
208 | 210 | free(cur_field_name); |
---|
209 | 211 | cur_field_name = strdup(args->field.name); |
---|
210 | 212 | break; |
---|
211 | | - case PRINT_FLAGS: |
---|
| 213 | + case TEP_PRINT_FLAGS: |
---|
212 | 214 | define_event_symbols(event, ev_name, args->flags.field); |
---|
213 | 215 | define_flag_field(ev_name, cur_field_name, args->flags.delim); |
---|
214 | 216 | define_flag_values(args->flags.flags, ev_name, cur_field_name); |
---|
215 | 217 | break; |
---|
216 | | - case PRINT_SYMBOL: |
---|
| 218 | + case TEP_PRINT_SYMBOL: |
---|
217 | 219 | define_event_symbols(event, ev_name, args->symbol.field); |
---|
218 | 220 | define_symbolic_field(ev_name, cur_field_name); |
---|
219 | 221 | define_symbolic_values(args->symbol.symbols, ev_name, |
---|
220 | 222 | cur_field_name); |
---|
221 | 223 | break; |
---|
222 | | - case PRINT_HEX: |
---|
223 | | - case PRINT_HEX_STR: |
---|
| 224 | + case TEP_PRINT_HEX: |
---|
| 225 | + case TEP_PRINT_HEX_STR: |
---|
224 | 226 | define_event_symbols(event, ev_name, args->hex.field); |
---|
225 | 227 | define_event_symbols(event, ev_name, args->hex.size); |
---|
226 | 228 | break; |
---|
227 | | - case PRINT_INT_ARRAY: |
---|
| 229 | + case TEP_PRINT_INT_ARRAY: |
---|
228 | 230 | define_event_symbols(event, ev_name, args->int_array.field); |
---|
229 | 231 | define_event_symbols(event, ev_name, args->int_array.count); |
---|
230 | 232 | define_event_symbols(event, ev_name, args->int_array.el_size); |
---|
231 | 233 | break; |
---|
232 | | - case PRINT_BSTRING: |
---|
233 | | - case PRINT_DYNAMIC_ARRAY: |
---|
234 | | - case PRINT_DYNAMIC_ARRAY_LEN: |
---|
235 | | - case PRINT_STRING: |
---|
236 | | - case PRINT_BITMASK: |
---|
| 234 | + case TEP_PRINT_BSTRING: |
---|
| 235 | + case TEP_PRINT_DYNAMIC_ARRAY: |
---|
| 236 | + case TEP_PRINT_DYNAMIC_ARRAY_LEN: |
---|
| 237 | + case TEP_PRINT_STRING: |
---|
| 238 | + case TEP_PRINT_BITMASK: |
---|
237 | 239 | break; |
---|
238 | | - case PRINT_TYPE: |
---|
| 240 | + case TEP_PRINT_TYPE: |
---|
239 | 241 | define_event_symbols(event, ev_name, args->typecast.item); |
---|
240 | 242 | break; |
---|
241 | | - case PRINT_OP: |
---|
| 243 | + case TEP_PRINT_OP: |
---|
242 | 244 | if (strcmp(args->op.op, ":") == 0) |
---|
243 | 245 | zero_flag_atom = 1; |
---|
244 | 246 | define_event_symbols(event, ev_name, args->op.left); |
---|
245 | 247 | define_event_symbols(event, ev_name, args->op.right); |
---|
246 | 248 | break; |
---|
247 | | - case PRINT_FUNC: |
---|
| 249 | + case TEP_PRINT_FUNC: |
---|
248 | 250 | default: |
---|
249 | 251 | pr_err("Unsupported print arg type\n"); |
---|
250 | 252 | /* we should warn... */ |
---|
.. | .. |
---|
256 | 258 | } |
---|
257 | 259 | |
---|
258 | 260 | static SV *perl_process_callchain(struct perf_sample *sample, |
---|
259 | | - struct perf_evsel *evsel, |
---|
| 261 | + struct evsel *evsel, |
---|
260 | 262 | struct addr_location *al) |
---|
261 | 263 | { |
---|
262 | 264 | AV *list; |
---|
.. | .. |
---|
292 | 294 | goto exit; |
---|
293 | 295 | } |
---|
294 | 296 | |
---|
295 | | - if (node->sym) { |
---|
| 297 | + if (node->ms.sym) { |
---|
296 | 298 | HV *sym = newHV(); |
---|
297 | 299 | if (!sym) { |
---|
298 | 300 | hv_undef(elem); |
---|
299 | 301 | goto exit; |
---|
300 | 302 | } |
---|
301 | | - if (!hv_stores(sym, "start", newSVuv(node->sym->start)) || |
---|
302 | | - !hv_stores(sym, "end", newSVuv(node->sym->end)) || |
---|
303 | | - !hv_stores(sym, "binding", newSVuv(node->sym->binding)) || |
---|
304 | | - !hv_stores(sym, "name", newSVpvn(node->sym->name, |
---|
305 | | - node->sym->namelen)) || |
---|
| 303 | + if (!hv_stores(sym, "start", newSVuv(node->ms.sym->start)) || |
---|
| 304 | + !hv_stores(sym, "end", newSVuv(node->ms.sym->end)) || |
---|
| 305 | + !hv_stores(sym, "binding", newSVuv(node->ms.sym->binding)) || |
---|
| 306 | + !hv_stores(sym, "name", newSVpvn(node->ms.sym->name, |
---|
| 307 | + node->ms.sym->namelen)) || |
---|
306 | 308 | !hv_stores(elem, "sym", newRV_noinc((SV*)sym))) { |
---|
307 | 309 | hv_undef(sym); |
---|
308 | 310 | hv_undef(elem); |
---|
.. | .. |
---|
310 | 312 | } |
---|
311 | 313 | } |
---|
312 | 314 | |
---|
313 | | - if (node->map) { |
---|
314 | | - struct map *map = node->map; |
---|
| 315 | + if (node->ms.map) { |
---|
| 316 | + struct map *map = node->ms.map; |
---|
315 | 317 | const char *dsoname = "[unknown]"; |
---|
316 | 318 | if (map && map->dso) { |
---|
317 | 319 | if (symbol_conf.show_kernel_path && map->dso->long_name) |
---|
.. | .. |
---|
334 | 336 | } |
---|
335 | 337 | |
---|
336 | 338 | static void perl_process_tracepoint(struct perf_sample *sample, |
---|
337 | | - struct perf_evsel *evsel, |
---|
| 339 | + struct evsel *evsel, |
---|
338 | 340 | struct addr_location *al) |
---|
339 | 341 | { |
---|
340 | 342 | struct thread *thread = al->thread; |
---|
341 | | - struct event_format *event = evsel->tp_format; |
---|
342 | | - struct format_field *field; |
---|
| 343 | + struct tep_event *event = evsel->tp_format; |
---|
| 344 | + struct tep_format_field *field; |
---|
343 | 345 | static char handler[256]; |
---|
344 | 346 | unsigned long long val; |
---|
345 | 347 | unsigned long s, ns; |
---|
.. | .. |
---|
351 | 353 | |
---|
352 | 354 | dSP; |
---|
353 | 355 | |
---|
354 | | - if (evsel->attr.type != PERF_TYPE_TRACEPOINT) |
---|
| 356 | + if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) |
---|
355 | 357 | return; |
---|
356 | 358 | |
---|
357 | 359 | if (!event) { |
---|
358 | | - pr_debug("ug! no event found for type %" PRIu64, (u64)evsel->attr.config); |
---|
| 360 | + pr_debug("ug! no event found for type %" PRIu64, (u64)evsel->core.attr.config); |
---|
359 | 361 | return; |
---|
360 | 362 | } |
---|
361 | 363 | |
---|
.. | .. |
---|
370 | 372 | ns = nsecs - s * NSEC_PER_SEC; |
---|
371 | 373 | |
---|
372 | 374 | scripting_context->event_data = data; |
---|
373 | | - scripting_context->pevent = evsel->tp_format->pevent; |
---|
| 375 | + scripting_context->pevent = evsel->tp_format->tep; |
---|
374 | 376 | |
---|
375 | 377 | ENTER; |
---|
376 | 378 | SAVETMPS; |
---|
.. | .. |
---|
388 | 390 | /* common fields other than pid can be accessed via xsub fns */ |
---|
389 | 391 | |
---|
390 | 392 | for (field = event->format.fields; field; field = field->next) { |
---|
391 | | - if (field->flags & FIELD_IS_STRING) { |
---|
| 393 | + if (field->flags & TEP_FIELD_IS_STRING) { |
---|
392 | 394 | int offset; |
---|
393 | | - if (field->flags & FIELD_IS_DYNAMIC) { |
---|
| 395 | + if (field->flags & TEP_FIELD_IS_DYNAMIC) { |
---|
394 | 396 | offset = *(int *)(data + field->offset); |
---|
395 | 397 | offset &= 0xffff; |
---|
396 | 398 | } else |
---|
.. | .. |
---|
399 | 401 | } else { /* FIELD_IS_NUMERIC */ |
---|
400 | 402 | val = read_size(event, data + field->offset, |
---|
401 | 403 | field->size); |
---|
402 | | - if (field->flags & FIELD_IS_SIGNED) { |
---|
| 404 | + if (field->flags & TEP_FIELD_IS_SIGNED) { |
---|
403 | 405 | XPUSHs(sv_2mortal(newSViv(val))); |
---|
404 | 406 | } else { |
---|
405 | 407 | XPUSHs(sv_2mortal(newSVuv(val))); |
---|
.. | .. |
---|
429 | 431 | |
---|
430 | 432 | static void perl_process_event_generic(union perf_event *event, |
---|
431 | 433 | struct perf_sample *sample, |
---|
432 | | - struct perf_evsel *evsel) |
---|
| 434 | + struct evsel *evsel) |
---|
433 | 435 | { |
---|
434 | 436 | dSP; |
---|
435 | 437 | |
---|
.. | .. |
---|
440 | 442 | SAVETMPS; |
---|
441 | 443 | PUSHMARK(SP); |
---|
442 | 444 | XPUSHs(sv_2mortal(newSVpvn((const char *)event, event->header.size))); |
---|
443 | | - XPUSHs(sv_2mortal(newSVpvn((const char *)&evsel->attr, sizeof(evsel->attr)))); |
---|
| 445 | + XPUSHs(sv_2mortal(newSVpvn((const char *)&evsel->core.attr, sizeof(evsel->core.attr)))); |
---|
444 | 446 | XPUSHs(sv_2mortal(newSVpvn((const char *)sample, sizeof(*sample)))); |
---|
445 | 447 | XPUSHs(sv_2mortal(newSVpvn((const char *)sample->raw_data, sample->raw_size))); |
---|
446 | 448 | PUTBACK; |
---|
.. | .. |
---|
453 | 455 | |
---|
454 | 456 | static void perl_process_event(union perf_event *event, |
---|
455 | 457 | struct perf_sample *sample, |
---|
456 | | - struct perf_evsel *evsel, |
---|
| 458 | + struct evsel *evsel, |
---|
457 | 459 | struct addr_location *al) |
---|
458 | 460 | { |
---|
459 | 461 | perl_process_tracepoint(sample, evsel, al); |
---|
.. | .. |
---|
537 | 539 | |
---|
538 | 540 | static int perl_generate_script(struct tep_handle *pevent, const char *outfile) |
---|
539 | 541 | { |
---|
540 | | - struct event_format *event = NULL; |
---|
541 | | - struct format_field *f; |
---|
| 542 | + int i, not_first, count, nr_events; |
---|
| 543 | + struct tep_event **all_events; |
---|
| 544 | + struct tep_event *event = NULL; |
---|
| 545 | + struct tep_format_field *f; |
---|
542 | 546 | char fname[PATH_MAX]; |
---|
543 | | - int not_first, count; |
---|
544 | 547 | FILE *ofp; |
---|
545 | 548 | |
---|
546 | 549 | sprintf(fname, "%s.pl", outfile); |
---|
.. | .. |
---|
601 | 604 | }\n\n\ |
---|
602 | 605 | "); |
---|
603 | 606 | |
---|
| 607 | + nr_events = tep_get_events_count(pevent); |
---|
| 608 | + all_events = tep_list_events(pevent, TEP_EVENT_SORT_ID); |
---|
604 | 609 | |
---|
605 | | - while ((event = trace_find_next_event(pevent, event))) { |
---|
| 610 | + for (i = 0; all_events && i < nr_events; i++) { |
---|
| 611 | + event = all_events[i]; |
---|
606 | 612 | fprintf(ofp, "sub %s::%s\n{\n", event->system, event->name); |
---|
607 | 613 | fprintf(ofp, "\tmy ("); |
---|
608 | 614 | |
---|
.. | .. |
---|
646 | 652 | count++; |
---|
647 | 653 | |
---|
648 | 654 | fprintf(ofp, "%s=", f->name); |
---|
649 | | - if (f->flags & FIELD_IS_STRING || |
---|
650 | | - f->flags & FIELD_IS_FLAG || |
---|
651 | | - f->flags & FIELD_IS_SYMBOLIC) |
---|
| 655 | + if (f->flags & TEP_FIELD_IS_STRING || |
---|
| 656 | + f->flags & TEP_FIELD_IS_FLAG || |
---|
| 657 | + f->flags & TEP_FIELD_IS_SYMBOLIC) |
---|
652 | 658 | fprintf(ofp, "%%s"); |
---|
653 | | - else if (f->flags & FIELD_IS_SIGNED) |
---|
| 659 | + else if (f->flags & TEP_FIELD_IS_SIGNED) |
---|
654 | 660 | fprintf(ofp, "%%d"); |
---|
655 | 661 | else |
---|
656 | 662 | fprintf(ofp, "%%u"); |
---|
.. | .. |
---|
668 | 674 | if (++count % 5 == 0) |
---|
669 | 675 | fprintf(ofp, "\n\t "); |
---|
670 | 676 | |
---|
671 | | - if (f->flags & FIELD_IS_FLAG) { |
---|
| 677 | + if (f->flags & TEP_FIELD_IS_FLAG) { |
---|
672 | 678 | if ((count - 1) % 5 != 0) { |
---|
673 | 679 | fprintf(ofp, "\n\t "); |
---|
674 | 680 | count = 4; |
---|
.. | .. |
---|
678 | 684 | event->name); |
---|
679 | 685 | fprintf(ofp, "\"%s\", $%s)", f->name, |
---|
680 | 686 | f->name); |
---|
681 | | - } else if (f->flags & FIELD_IS_SYMBOLIC) { |
---|
| 687 | + } else if (f->flags & TEP_FIELD_IS_SYMBOLIC) { |
---|
682 | 688 | if ((count - 1) % 5 != 0) { |
---|
683 | 689 | fprintf(ofp, "\n\t "); |
---|
684 | 690 | count = 4; |
---|