Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf scripting: Add scripting_context__update()

Move scripting_context update to a separate function and add
the arguments of ->process_event() to it.

This prepares the way for adding more methods to the perf_trace_context
module, by providing the context information that they will need.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20210530192308.7382-4-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
cac30400 6337bd0c

+38 -7
+2 -4
tools/perf/util/scripting-engines/trace-event-perl.c
··· 371 371 s = nsecs / NSEC_PER_SEC; 372 372 ns = nsecs - s * NSEC_PER_SEC; 373 373 374 - scripting_context->event_data = data; 375 - scripting_context->pevent = evsel->tp_format->tep; 376 - 377 374 ENTER; 378 375 SAVETMPS; 379 376 PUSHMARK(SP); ··· 454 457 struct perf_sample *sample, 455 458 struct evsel *evsel, 456 459 struct addr_location *al, 457 - struct addr_location *addr_al __maybe_unused) 460 + struct addr_location *addr_al) 458 461 { 462 + scripting_context__update(scripting_context, event, sample, evsel, al, addr_al); 459 463 perl_process_tracepoint(sample, evsel, al); 460 464 perl_process_event_generic(event, sample, evsel); 461 465 }
+2 -3
tools/perf/util/scripting-engines/trace-event-python.c
··· 897 897 s = nsecs / NSEC_PER_SEC; 898 898 ns = nsecs - s * NSEC_PER_SEC; 899 899 900 - scripting_context->event_data = data; 901 - scripting_context->pevent = evsel->tp_format->tep; 902 - 903 900 context = _PyCapsule_New(scripting_context, NULL, NULL); 904 901 905 902 PyTuple_SetItem(t, n++, _PyUnicode_FromString(handler_name)); ··· 1399 1402 struct addr_location *addr_al) 1400 1403 { 1401 1404 struct tables *tables = &tables_global; 1405 + 1406 + scripting_context__update(scripting_context, event, sample, evsel, al, addr_al); 1402 1407 1403 1408 switch (evsel->core.attr.type) { 1404 1409 case PERF_TYPE_TRACEPOINT:
+21
tools/perf/util/trace-event-scripting.c
··· 12 12 13 13 #include "debug.h" 14 14 #include "trace-event.h" 15 + #include "event.h" 16 + #include "evsel.h" 15 17 #include <linux/zalloc.h> 16 18 17 19 struct scripting_context *scripting_context; 20 + 21 + void scripting_context__update(struct scripting_context *c, 22 + union perf_event *event, 23 + struct perf_sample *sample, 24 + struct evsel *evsel, 25 + struct addr_location *al, 26 + struct addr_location *addr_al) 27 + { 28 + c->event_data = sample->raw_data; 29 + if (evsel->tp_format) 30 + c->pevent = evsel->tp_format->tep; 31 + else 32 + c->pevent = NULL; 33 + c->event = event; 34 + c->sample = sample; 35 + c->evsel = evsel; 36 + c->al = al; 37 + c->addr_al = addr_al; 38 + } 18 39 19 40 static int flush_script_unsupported(void) 20 41 {
+13
tools/perf/util/trace-event.h
··· 11 11 struct perf_tool; 12 12 struct thread; 13 13 struct tep_plugin_list; 14 + struct evsel; 14 15 15 16 struct trace_event { 16 17 struct tep_handle *pevent; ··· 102 101 struct scripting_context { 103 102 struct tep_handle *pevent; 104 103 void *event_data; 104 + union perf_event *event; 105 + struct perf_sample *sample; 106 + struct evsel *evsel; 107 + struct addr_location *al; 108 + struct addr_location *addr_al; 105 109 }; 110 + 111 + void scripting_context__update(struct scripting_context *scripting_context, 112 + union perf_event *event, 113 + struct perf_sample *sample, 114 + struct evsel *evsel, 115 + struct addr_location *al, 116 + struct addr_location *addr_al); 106 117 107 118 int common_pc(struct scripting_context *context); 108 119 int common_flags(struct scripting_context *context);