Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 1 | /* |
| 2 | * trace-event-python. Feed trace events to an embedded Python interpreter. |
| 3 | * |
| 4 | * Copyright (C) 2010 Tom Zanussi <tzanussi@gmail.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <Python.h> |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 27 | #include <errno.h> |
| 28 | |
| 29 | #include "../../perf.h" |
Arnaldo Carvalho de Melo | fcf65bf | 2012-08-07 09:58:03 -0300 | [diff] [blame] | 30 | #include "../evsel.h" |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 31 | #include "../util.h" |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 32 | #include "../event.h" |
| 33 | #include "../thread.h" |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 34 | #include "../trace-event.h" |
| 35 | |
| 36 | PyMODINIT_FUNC initperf_trace_context(void); |
| 37 | |
| 38 | #define FTRACE_MAX_EVENT \ |
| 39 | ((1 << (sizeof(unsigned short) * 8)) - 1) |
| 40 | |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 41 | struct event_format *events[FTRACE_MAX_EVENT]; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 42 | |
| 43 | #define MAX_FIELDS 64 |
| 44 | #define N_COMMON_FIELDS 7 |
| 45 | |
| 46 | extern struct scripting_context *scripting_context; |
| 47 | |
| 48 | static char *cur_field_name; |
| 49 | static int zero_flag_atom; |
| 50 | |
| 51 | static PyObject *main_module, *main_dict; |
| 52 | |
Joseph Schuchart | 05f832e | 2014-07-09 16:16:31 +0200 | [diff] [blame^] | 53 | static void handler_call_die(const char *handler_name) NORETURN; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 54 | static void handler_call_die(const char *handler_name) |
| 55 | { |
| 56 | PyErr_Print(); |
| 57 | Py_FatalError("problem in Python trace event handler"); |
Joseph Schuchart | 05f832e | 2014-07-09 16:16:31 +0200 | [diff] [blame^] | 58 | // Py_FatalError does not return |
| 59 | // but we have to make the compiler happy |
| 60 | abort(); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 61 | } |
| 62 | |
Joseph Schuchart | c0268e8 | 2013-10-24 10:10:51 -0300 | [diff] [blame] | 63 | /* |
| 64 | * Insert val into into the dictionary and decrement the reference counter. |
| 65 | * This is necessary for dictionaries since PyDict_SetItemString() does not |
| 66 | * steal a reference, as opposed to PyTuple_SetItem(). |
| 67 | */ |
| 68 | static void pydict_set_item_string_decref(PyObject *dict, const char *key, PyObject *val) |
| 69 | { |
| 70 | PyDict_SetItemString(dict, key, val); |
| 71 | Py_DECREF(val); |
| 72 | } |
| 73 | |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 74 | static void define_value(enum print_arg_type field_type, |
| 75 | const char *ev_name, |
| 76 | const char *field_name, |
| 77 | const char *field_value, |
| 78 | const char *field_str) |
| 79 | { |
| 80 | const char *handler_name = "define_flag_value"; |
| 81 | PyObject *handler, *t, *retval; |
| 82 | unsigned long long value; |
| 83 | unsigned n = 0; |
| 84 | |
| 85 | if (field_type == PRINT_SYMBOL) |
| 86 | handler_name = "define_symbolic_value"; |
| 87 | |
Tom Zanussi | 44ad9cd | 2010-02-22 01:12:59 -0600 | [diff] [blame] | 88 | t = PyTuple_New(4); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 89 | if (!t) |
| 90 | Py_FatalError("couldn't create Python tuple"); |
| 91 | |
| 92 | value = eval_flag(field_value); |
| 93 | |
| 94 | PyTuple_SetItem(t, n++, PyString_FromString(ev_name)); |
| 95 | PyTuple_SetItem(t, n++, PyString_FromString(field_name)); |
| 96 | PyTuple_SetItem(t, n++, PyInt_FromLong(value)); |
| 97 | PyTuple_SetItem(t, n++, PyString_FromString(field_str)); |
| 98 | |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 99 | handler = PyDict_GetItemString(main_dict, handler_name); |
| 100 | if (handler && PyCallable_Check(handler)) { |
| 101 | retval = PyObject_CallObject(handler, t); |
| 102 | if (retval == NULL) |
| 103 | handler_call_die(handler_name); |
Joseph Schuchart | 05f832e | 2014-07-09 16:16:31 +0200 | [diff] [blame^] | 104 | Py_DECREF(retval); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | Py_DECREF(t); |
| 108 | } |
| 109 | |
| 110 | static void define_values(enum print_arg_type field_type, |
| 111 | struct print_flag_sym *field, |
| 112 | const char *ev_name, |
| 113 | const char *field_name) |
| 114 | { |
| 115 | define_value(field_type, ev_name, field_name, field->value, |
| 116 | field->str); |
| 117 | |
| 118 | if (field->next) |
| 119 | define_values(field_type, field->next, ev_name, field_name); |
| 120 | } |
| 121 | |
| 122 | static void define_field(enum print_arg_type field_type, |
| 123 | const char *ev_name, |
| 124 | const char *field_name, |
| 125 | const char *delim) |
| 126 | { |
| 127 | const char *handler_name = "define_flag_field"; |
| 128 | PyObject *handler, *t, *retval; |
| 129 | unsigned n = 0; |
| 130 | |
| 131 | if (field_type == PRINT_SYMBOL) |
| 132 | handler_name = "define_symbolic_field"; |
| 133 | |
Tom Zanussi | 44ad9cd | 2010-02-22 01:12:59 -0600 | [diff] [blame] | 134 | if (field_type == PRINT_FLAGS) |
| 135 | t = PyTuple_New(3); |
| 136 | else |
| 137 | t = PyTuple_New(2); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 138 | if (!t) |
| 139 | Py_FatalError("couldn't create Python tuple"); |
| 140 | |
| 141 | PyTuple_SetItem(t, n++, PyString_FromString(ev_name)); |
| 142 | PyTuple_SetItem(t, n++, PyString_FromString(field_name)); |
| 143 | if (field_type == PRINT_FLAGS) |
| 144 | PyTuple_SetItem(t, n++, PyString_FromString(delim)); |
| 145 | |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 146 | handler = PyDict_GetItemString(main_dict, handler_name); |
| 147 | if (handler && PyCallable_Check(handler)) { |
| 148 | retval = PyObject_CallObject(handler, t); |
| 149 | if (retval == NULL) |
| 150 | handler_call_die(handler_name); |
Joseph Schuchart | 05f832e | 2014-07-09 16:16:31 +0200 | [diff] [blame^] | 151 | Py_DECREF(retval); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | Py_DECREF(t); |
| 155 | } |
| 156 | |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 157 | static void define_event_symbols(struct event_format *event, |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 158 | const char *ev_name, |
| 159 | struct print_arg *args) |
| 160 | { |
| 161 | switch (args->type) { |
| 162 | case PRINT_NULL: |
| 163 | break; |
| 164 | case PRINT_ATOM: |
| 165 | define_value(PRINT_FLAGS, ev_name, cur_field_name, "0", |
| 166 | args->atom.atom); |
| 167 | zero_flag_atom = 0; |
| 168 | break; |
| 169 | case PRINT_FIELD: |
Arnaldo Carvalho de Melo | f538565 | 2013-12-26 15:54:57 -0300 | [diff] [blame] | 170 | free(cur_field_name); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 171 | cur_field_name = strdup(args->field.name); |
| 172 | break; |
| 173 | case PRINT_FLAGS: |
| 174 | define_event_symbols(event, ev_name, args->flags.field); |
| 175 | define_field(PRINT_FLAGS, ev_name, cur_field_name, |
| 176 | args->flags.delim); |
| 177 | define_values(PRINT_FLAGS, args->flags.flags, ev_name, |
| 178 | cur_field_name); |
| 179 | break; |
| 180 | case PRINT_SYMBOL: |
| 181 | define_event_symbols(event, ev_name, args->symbol.field); |
| 182 | define_field(PRINT_SYMBOL, ev_name, cur_field_name, NULL); |
| 183 | define_values(PRINT_SYMBOL, args->symbol.symbols, ev_name, |
| 184 | cur_field_name); |
| 185 | break; |
Namhyung Kim | e080e6f | 2012-06-27 09:41:41 +0900 | [diff] [blame] | 186 | case PRINT_HEX: |
| 187 | define_event_symbols(event, ev_name, args->hex.field); |
| 188 | define_event_symbols(event, ev_name, args->hex.size); |
| 189 | break; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 190 | case PRINT_STRING: |
| 191 | break; |
| 192 | case PRINT_TYPE: |
| 193 | define_event_symbols(event, ev_name, args->typecast.item); |
| 194 | break; |
| 195 | case PRINT_OP: |
| 196 | if (strcmp(args->op.op, ":") == 0) |
| 197 | zero_flag_atom = 1; |
| 198 | define_event_symbols(event, ev_name, args->op.left); |
| 199 | define_event_symbols(event, ev_name, args->op.right); |
| 200 | break; |
| 201 | default: |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 202 | /* gcc warns for these? */ |
| 203 | case PRINT_BSTRING: |
| 204 | case PRINT_DYNAMIC_ARRAY: |
| 205 | case PRINT_FUNC: |
Steven Rostedt (Red Hat) | 473a778 | 2014-06-02 23:20:16 -0400 | [diff] [blame] | 206 | case PRINT_BITMASK: |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 207 | /* we should warn... */ |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | if (args->next) |
| 212 | define_event_symbols(event, ev_name, args->next); |
| 213 | } |
| 214 | |
Arnaldo Carvalho de Melo | fcf65bf | 2012-08-07 09:58:03 -0300 | [diff] [blame] | 215 | static inline struct event_format *find_cache_event(struct perf_evsel *evsel) |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 216 | { |
| 217 | static char ev_name[256]; |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 218 | struct event_format *event; |
Arnaldo Carvalho de Melo | fcf65bf | 2012-08-07 09:58:03 -0300 | [diff] [blame] | 219 | int type = evsel->attr.config; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 220 | |
Arnaldo Carvalho de Melo | fcf65bf | 2012-08-07 09:58:03 -0300 | [diff] [blame] | 221 | /* |
| 222 | * XXX: Do we really need to cache this since now we have evsel->tp_format |
| 223 | * cached already? Need to re-read this "cache" routine that as well calls |
| 224 | * define_event_symbols() :-\ |
| 225 | */ |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 226 | if (events[type]) |
| 227 | return events[type]; |
| 228 | |
Arnaldo Carvalho de Melo | fcf65bf | 2012-08-07 09:58:03 -0300 | [diff] [blame] | 229 | events[type] = event = evsel->tp_format; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 230 | if (!event) |
| 231 | return NULL; |
| 232 | |
| 233 | sprintf(ev_name, "%s__%s", event->system, event->name); |
| 234 | |
| 235 | define_event_symbols(event, ev_name, event->print_fmt.args); |
| 236 | |
| 237 | return event; |
| 238 | } |
| 239 | |
Sebastian Andrzej Siewior | 33058b9 | 2014-05-27 18:14:33 +0200 | [diff] [blame] | 240 | static PyObject *get_field_numeric_entry(struct event_format *event, |
| 241 | struct format_field *field, void *data) |
| 242 | { |
Sebastian Andrzej Siewior | 8ac631c | 2014-05-27 18:14:34 +0200 | [diff] [blame] | 243 | bool is_array = field->flags & FIELD_IS_ARRAY; |
| 244 | PyObject *obj, *list = NULL; |
Sebastian Andrzej Siewior | 33058b9 | 2014-05-27 18:14:33 +0200 | [diff] [blame] | 245 | unsigned long long val; |
Sebastian Andrzej Siewior | 8ac631c | 2014-05-27 18:14:34 +0200 | [diff] [blame] | 246 | unsigned int item_size, n_items, i; |
Sebastian Andrzej Siewior | 33058b9 | 2014-05-27 18:14:33 +0200 | [diff] [blame] | 247 | |
Sebastian Andrzej Siewior | 8ac631c | 2014-05-27 18:14:34 +0200 | [diff] [blame] | 248 | if (is_array) { |
| 249 | list = PyList_New(field->arraylen); |
| 250 | item_size = field->size / field->arraylen; |
| 251 | n_items = field->arraylen; |
Sebastian Andrzej Siewior | 33058b9 | 2014-05-27 18:14:33 +0200 | [diff] [blame] | 252 | } else { |
Sebastian Andrzej Siewior | 8ac631c | 2014-05-27 18:14:34 +0200 | [diff] [blame] | 253 | item_size = field->size; |
| 254 | n_items = 1; |
Sebastian Andrzej Siewior | 33058b9 | 2014-05-27 18:14:33 +0200 | [diff] [blame] | 255 | } |
Sebastian Andrzej Siewior | 8ac631c | 2014-05-27 18:14:34 +0200 | [diff] [blame] | 256 | |
| 257 | for (i = 0; i < n_items; i++) { |
| 258 | |
| 259 | val = read_size(event, data + field->offset + i * item_size, |
| 260 | item_size); |
| 261 | if (field->flags & FIELD_IS_SIGNED) { |
| 262 | if ((long long)val >= LONG_MIN && |
| 263 | (long long)val <= LONG_MAX) |
| 264 | obj = PyInt_FromLong(val); |
| 265 | else |
| 266 | obj = PyLong_FromLongLong(val); |
| 267 | } else { |
| 268 | if (val <= LONG_MAX) |
| 269 | obj = PyInt_FromLong(val); |
| 270 | else |
| 271 | obj = PyLong_FromUnsignedLongLong(val); |
| 272 | } |
| 273 | if (is_array) |
| 274 | PyList_SET_ITEM(list, i, obj); |
| 275 | } |
| 276 | if (is_array) |
| 277 | obj = list; |
Sebastian Andrzej Siewior | 33058b9 | 2014-05-27 18:14:33 +0200 | [diff] [blame] | 278 | return obj; |
| 279 | } |
| 280 | |
Arnaldo Carvalho de Melo | b7fff6b5 | 2013-12-19 16:34:52 -0300 | [diff] [blame] | 281 | static void python_process_tracepoint(struct perf_sample *sample, |
| 282 | struct perf_evsel *evsel, |
| 283 | struct thread *thread, |
| 284 | struct addr_location *al) |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 285 | { |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 286 | PyObject *handler, *retval, *context, *t, *obj, *dict = NULL; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 287 | static char handler_name[256]; |
| 288 | struct format_field *field; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 289 | unsigned long s, ns; |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 290 | struct event_format *event; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 291 | unsigned n = 0; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 292 | int pid; |
David Ahern | be6d842 | 2011-03-09 22:23:23 -0700 | [diff] [blame] | 293 | int cpu = sample->cpu; |
| 294 | void *data = sample->raw_data; |
| 295 | unsigned long long nsecs = sample->time; |
Frederic Weisbecker | b9c5143 | 2013-09-11 14:46:56 +0200 | [diff] [blame] | 296 | const char *comm = thread__comm_str(thread); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 297 | |
| 298 | t = PyTuple_New(MAX_FIELDS); |
| 299 | if (!t) |
| 300 | Py_FatalError("couldn't create Python tuple"); |
| 301 | |
Arnaldo Carvalho de Melo | fcf65bf | 2012-08-07 09:58:03 -0300 | [diff] [blame] | 302 | event = find_cache_event(evsel); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 303 | if (!event) |
Arnaldo Carvalho de Melo | fcf65bf | 2012-08-07 09:58:03 -0300 | [diff] [blame] | 304 | die("ug! no event found for type %d", (int)evsel->attr.config); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 305 | |
Arnaldo Carvalho de Melo | 9782243 | 2012-08-07 23:50:21 -0300 | [diff] [blame] | 306 | pid = raw_field_value(event, "common_pid", data); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 307 | |
| 308 | sprintf(handler_name, "%s__%s", event->system, event->name); |
| 309 | |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 310 | handler = PyDict_GetItemString(main_dict, handler_name); |
| 311 | if (handler && !PyCallable_Check(handler)) |
| 312 | handler = NULL; |
| 313 | if (!handler) { |
| 314 | dict = PyDict_New(); |
| 315 | if (!dict) |
| 316 | Py_FatalError("couldn't create Python dict"); |
| 317 | } |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 318 | s = nsecs / NSECS_PER_SEC; |
| 319 | ns = nsecs - s * NSECS_PER_SEC; |
| 320 | |
| 321 | scripting_context->event_data = data; |
Tom Zanussi | 2de9533 | 2013-01-18 13:51:27 -0600 | [diff] [blame] | 322 | scripting_context->pevent = evsel->tp_format->pevent; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 323 | |
| 324 | context = PyCObject_FromVoidPtr(scripting_context, NULL); |
| 325 | |
| 326 | PyTuple_SetItem(t, n++, PyString_FromString(handler_name)); |
Kyle McMartin | fb7d0b3 | 2011-01-24 11:13:04 -0500 | [diff] [blame] | 327 | PyTuple_SetItem(t, n++, context); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 328 | |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 329 | if (handler) { |
| 330 | PyTuple_SetItem(t, n++, PyInt_FromLong(cpu)); |
| 331 | PyTuple_SetItem(t, n++, PyInt_FromLong(s)); |
| 332 | PyTuple_SetItem(t, n++, PyInt_FromLong(ns)); |
| 333 | PyTuple_SetItem(t, n++, PyInt_FromLong(pid)); |
| 334 | PyTuple_SetItem(t, n++, PyString_FromString(comm)); |
| 335 | } else { |
Joseph Schuchart | c0268e8 | 2013-10-24 10:10:51 -0300 | [diff] [blame] | 336 | pydict_set_item_string_decref(dict, "common_cpu", PyInt_FromLong(cpu)); |
| 337 | pydict_set_item_string_decref(dict, "common_s", PyInt_FromLong(s)); |
| 338 | pydict_set_item_string_decref(dict, "common_ns", PyInt_FromLong(ns)); |
| 339 | pydict_set_item_string_decref(dict, "common_pid", PyInt_FromLong(pid)); |
| 340 | pydict_set_item_string_decref(dict, "common_comm", PyString_FromString(comm)); |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 341 | } |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 342 | for (field = event->format.fields; field; field = field->next) { |
| 343 | if (field->flags & FIELD_IS_STRING) { |
| 344 | int offset; |
| 345 | if (field->flags & FIELD_IS_DYNAMIC) { |
| 346 | offset = *(int *)(data + field->offset); |
| 347 | offset &= 0xffff; |
| 348 | } else |
| 349 | offset = field->offset; |
Tom Zanussi | b1dcc03 | 2010-04-01 23:58:25 -0500 | [diff] [blame] | 350 | obj = PyString_FromString((char *)data + offset); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 351 | } else { /* FIELD_IS_NUMERIC */ |
Sebastian Andrzej Siewior | 33058b9 | 2014-05-27 18:14:33 +0200 | [diff] [blame] | 352 | obj = get_field_numeric_entry(event, field, data); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 353 | } |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 354 | if (handler) |
| 355 | PyTuple_SetItem(t, n++, obj); |
| 356 | else |
Joseph Schuchart | c0268e8 | 2013-10-24 10:10:51 -0300 | [diff] [blame] | 357 | pydict_set_item_string_decref(dict, field->name, obj); |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 358 | |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 359 | } |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 360 | if (!handler) |
| 361 | PyTuple_SetItem(t, n++, dict); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 362 | |
| 363 | if (_PyTuple_Resize(&t, n) == -1) |
| 364 | Py_FatalError("error resizing Python tuple"); |
| 365 | |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 366 | if (handler) { |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 367 | retval = PyObject_CallObject(handler, t); |
| 368 | if (retval == NULL) |
| 369 | handler_call_die(handler_name); |
Joseph Schuchart | 05f832e | 2014-07-09 16:16:31 +0200 | [diff] [blame^] | 370 | Py_DECREF(retval); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 371 | } else { |
| 372 | handler = PyDict_GetItemString(main_dict, "trace_unhandled"); |
| 373 | if (handler && PyCallable_Check(handler)) { |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 374 | |
| 375 | retval = PyObject_CallObject(handler, t); |
| 376 | if (retval == NULL) |
| 377 | handler_call_die("trace_unhandled"); |
Joseph Schuchart | 05f832e | 2014-07-09 16:16:31 +0200 | [diff] [blame^] | 378 | Py_DECREF(retval); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 379 | } |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 380 | Py_DECREF(dict); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | Py_DECREF(t); |
| 384 | } |
| 385 | |
Arnaldo Carvalho de Melo | b7fff6b5 | 2013-12-19 16:34:52 -0300 | [diff] [blame] | 386 | static void python_process_general_event(struct perf_sample *sample, |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 387 | struct perf_evsel *evsel, |
David Ahern | 2eaa1b4 | 2013-07-18 16:06:15 -0600 | [diff] [blame] | 388 | struct thread *thread, |
Feng Tang | 87b6a3a | 2012-08-09 13:46:13 +0800 | [diff] [blame] | 389 | struct addr_location *al) |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 390 | { |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 391 | PyObject *handler, *retval, *t, *dict; |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 392 | static char handler_name[64]; |
| 393 | unsigned n = 0; |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 394 | |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 395 | /* |
| 396 | * Use the MAX_FIELDS to make the function expandable, though |
Feng Tang | 87b6a3a | 2012-08-09 13:46:13 +0800 | [diff] [blame] | 397 | * currently there is only one item for the tuple. |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 398 | */ |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 399 | t = PyTuple_New(MAX_FIELDS); |
| 400 | if (!t) |
| 401 | Py_FatalError("couldn't create Python tuple"); |
| 402 | |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 403 | dict = PyDict_New(); |
| 404 | if (!dict) |
| 405 | Py_FatalError("couldn't create Python dictionary"); |
| 406 | |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 407 | snprintf(handler_name, sizeof(handler_name), "%s", "process_event"); |
| 408 | |
| 409 | handler = PyDict_GetItemString(main_dict, handler_name); |
Feng Tang | 87b6a3a | 2012-08-09 13:46:13 +0800 | [diff] [blame] | 410 | if (!handler || !PyCallable_Check(handler)) |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 411 | goto exit; |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 412 | |
Joseph Schuchart | c0268e8 | 2013-10-24 10:10:51 -0300 | [diff] [blame] | 413 | pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel))); |
| 414 | pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize( |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 415 | (const char *)&evsel->attr, sizeof(evsel->attr))); |
Joseph Schuchart | c0268e8 | 2013-10-24 10:10:51 -0300 | [diff] [blame] | 416 | pydict_set_item_string_decref(dict, "sample", PyString_FromStringAndSize( |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 417 | (const char *)sample, sizeof(*sample))); |
Joseph Schuchart | c0268e8 | 2013-10-24 10:10:51 -0300 | [diff] [blame] | 418 | pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize( |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 419 | (const char *)sample->raw_data, sample->raw_size)); |
Joseph Schuchart | c0268e8 | 2013-10-24 10:10:51 -0300 | [diff] [blame] | 420 | pydict_set_item_string_decref(dict, "comm", |
Frederic Weisbecker | b9c5143 | 2013-09-11 14:46:56 +0200 | [diff] [blame] | 421 | PyString_FromString(thread__comm_str(thread))); |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 422 | if (al->map) { |
Joseph Schuchart | c0268e8 | 2013-10-24 10:10:51 -0300 | [diff] [blame] | 423 | pydict_set_item_string_decref(dict, "dso", |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 424 | PyString_FromString(al->map->dso->name)); |
| 425 | } |
| 426 | if (al->sym) { |
Joseph Schuchart | c0268e8 | 2013-10-24 10:10:51 -0300 | [diff] [blame] | 427 | pydict_set_item_string_decref(dict, "symbol", |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 428 | PyString_FromString(al->sym->name)); |
| 429 | } |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 430 | |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 431 | PyTuple_SetItem(t, n++, dict); |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 432 | if (_PyTuple_Resize(&t, n) == -1) |
| 433 | Py_FatalError("error resizing Python tuple"); |
| 434 | |
| 435 | retval = PyObject_CallObject(handler, t); |
| 436 | if (retval == NULL) |
| 437 | handler_call_die(handler_name); |
Joseph Schuchart | 05f832e | 2014-07-09 16:16:31 +0200 | [diff] [blame^] | 438 | Py_DECREF(retval); |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 439 | exit: |
Feng Tang | fd6b858 | 2012-08-08 17:57:53 +0800 | [diff] [blame] | 440 | Py_DECREF(dict); |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 441 | Py_DECREF(t); |
| 442 | } |
| 443 | |
Arnaldo Carvalho de Melo | b7fff6b5 | 2013-12-19 16:34:52 -0300 | [diff] [blame] | 444 | static void python_process_event(union perf_event *event __maybe_unused, |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 445 | struct perf_sample *sample, |
| 446 | struct perf_evsel *evsel, |
David Ahern | 2eaa1b4 | 2013-07-18 16:06:15 -0600 | [diff] [blame] | 447 | struct thread *thread, |
Feng Tang | 73994dc | 2012-08-08 17:57:52 +0800 | [diff] [blame] | 448 | struct addr_location *al) |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 449 | { |
| 450 | switch (evsel->attr.type) { |
| 451 | case PERF_TYPE_TRACEPOINT: |
Arnaldo Carvalho de Melo | b7fff6b5 | 2013-12-19 16:34:52 -0300 | [diff] [blame] | 452 | python_process_tracepoint(sample, evsel, thread, al); |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 453 | break; |
| 454 | /* Reserve for future process_hw/sw/raw APIs */ |
| 455 | default: |
Arnaldo Carvalho de Melo | b7fff6b5 | 2013-12-19 16:34:52 -0300 | [diff] [blame] | 456 | python_process_general_event(sample, evsel, thread, al); |
Feng Tang | 6a6daec | 2012-08-08 17:57:51 +0800 | [diff] [blame] | 457 | } |
| 458 | } |
| 459 | |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 460 | static int run_start_sub(void) |
| 461 | { |
| 462 | PyObject *handler, *retval; |
| 463 | int err = 0; |
| 464 | |
| 465 | main_module = PyImport_AddModule("__main__"); |
| 466 | if (main_module == NULL) |
| 467 | return -1; |
| 468 | Py_INCREF(main_module); |
| 469 | |
| 470 | main_dict = PyModule_GetDict(main_module); |
| 471 | if (main_dict == NULL) { |
| 472 | err = -1; |
| 473 | goto error; |
| 474 | } |
| 475 | Py_INCREF(main_dict); |
| 476 | |
| 477 | handler = PyDict_GetItemString(main_dict, "trace_begin"); |
| 478 | if (handler == NULL || !PyCallable_Check(handler)) |
| 479 | goto out; |
| 480 | |
| 481 | retval = PyObject_CallObject(handler, NULL); |
| 482 | if (retval == NULL) |
| 483 | handler_call_die("trace_begin"); |
| 484 | |
| 485 | Py_DECREF(retval); |
| 486 | return err; |
| 487 | error: |
| 488 | Py_XDECREF(main_dict); |
| 489 | Py_XDECREF(main_module); |
| 490 | out: |
| 491 | return err; |
| 492 | } |
| 493 | |
| 494 | /* |
| 495 | * Start trace script |
| 496 | */ |
| 497 | static int python_start_script(const char *script, int argc, const char **argv) |
| 498 | { |
| 499 | const char **command_line; |
| 500 | char buf[PATH_MAX]; |
| 501 | int i, err = 0; |
| 502 | FILE *fp; |
| 503 | |
| 504 | command_line = malloc((argc + 1) * sizeof(const char *)); |
| 505 | command_line[0] = script; |
| 506 | for (i = 1; i < argc + 1; i++) |
| 507 | command_line[i] = argv[i - 1]; |
| 508 | |
| 509 | Py_Initialize(); |
| 510 | |
| 511 | initperf_trace_context(); |
| 512 | |
| 513 | PySys_SetArgv(argc + 1, (char **)command_line); |
| 514 | |
| 515 | fp = fopen(script, "r"); |
| 516 | if (!fp) { |
| 517 | sprintf(buf, "Can't open python script \"%s\"", script); |
| 518 | perror(buf); |
| 519 | err = -1; |
| 520 | goto error; |
| 521 | } |
| 522 | |
| 523 | err = PyRun_SimpleFile(fp, script); |
| 524 | if (err) { |
| 525 | fprintf(stderr, "Error running python script %s\n", script); |
| 526 | goto error; |
| 527 | } |
| 528 | |
| 529 | err = run_start_sub(); |
| 530 | if (err) { |
| 531 | fprintf(stderr, "Error starting python script %s\n", script); |
| 532 | goto error; |
| 533 | } |
| 534 | |
| 535 | free(command_line); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 536 | |
| 537 | return err; |
| 538 | error: |
| 539 | Py_Finalize(); |
| 540 | free(command_line); |
| 541 | |
| 542 | return err; |
| 543 | } |
| 544 | |
| 545 | /* |
| 546 | * Stop trace script |
| 547 | */ |
| 548 | static int python_stop_script(void) |
| 549 | { |
| 550 | PyObject *handler, *retval; |
| 551 | int err = 0; |
| 552 | |
| 553 | handler = PyDict_GetItemString(main_dict, "trace_end"); |
| 554 | if (handler == NULL || !PyCallable_Check(handler)) |
| 555 | goto out; |
| 556 | |
| 557 | retval = PyObject_CallObject(handler, NULL); |
| 558 | if (retval == NULL) |
| 559 | handler_call_die("trace_end"); |
Joseph Schuchart | 05f832e | 2014-07-09 16:16:31 +0200 | [diff] [blame^] | 560 | Py_DECREF(retval); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 561 | out: |
| 562 | Py_XDECREF(main_dict); |
| 563 | Py_XDECREF(main_module); |
| 564 | Py_Finalize(); |
| 565 | |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 566 | return err; |
| 567 | } |
| 568 | |
Arnaldo Carvalho de Melo | da37896 | 2012-06-27 13:08:42 -0300 | [diff] [blame] | 569 | static int python_generate_script(struct pevent *pevent, const char *outfile) |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 570 | { |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 571 | struct event_format *event = NULL; |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 572 | struct format_field *f; |
| 573 | char fname[PATH_MAX]; |
| 574 | int not_first, count; |
| 575 | FILE *ofp; |
| 576 | |
| 577 | sprintf(fname, "%s.py", outfile); |
| 578 | ofp = fopen(fname, "w"); |
| 579 | if (ofp == NULL) { |
| 580 | fprintf(stderr, "couldn't open %s\n", fname); |
| 581 | return -1; |
| 582 | } |
Ingo Molnar | 133dc4c | 2010-11-16 18:45:39 +0100 | [diff] [blame] | 583 | fprintf(ofp, "# perf script event handlers, " |
| 584 | "generated by perf script -g python\n"); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 585 | |
| 586 | fprintf(ofp, "# Licensed under the terms of the GNU GPL" |
| 587 | " License version 2\n\n"); |
| 588 | |
| 589 | fprintf(ofp, "# The common_* event handler fields are the most useful " |
| 590 | "fields common to\n"); |
| 591 | |
| 592 | fprintf(ofp, "# all events. They don't necessarily correspond to " |
| 593 | "the 'common_*' fields\n"); |
| 594 | |
| 595 | fprintf(ofp, "# in the format files. Those fields not available as " |
| 596 | "handler params can\n"); |
| 597 | |
| 598 | fprintf(ofp, "# be retrieved using Python functions of the form " |
| 599 | "common_*(context).\n"); |
| 600 | |
| 601 | fprintf(ofp, "# See the perf-trace-python Documentation for the list " |
| 602 | "of available functions.\n\n"); |
| 603 | |
| 604 | fprintf(ofp, "import os\n"); |
| 605 | fprintf(ofp, "import sys\n\n"); |
| 606 | |
| 607 | fprintf(ofp, "sys.path.append(os.environ['PERF_EXEC_PATH'] + \\\n"); |
| 608 | fprintf(ofp, "\t'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')\n"); |
| 609 | fprintf(ofp, "\nfrom perf_trace_context import *\n"); |
| 610 | fprintf(ofp, "from Core import *\n\n\n"); |
| 611 | |
| 612 | fprintf(ofp, "def trace_begin():\n"); |
| 613 | fprintf(ofp, "\tprint \"in trace_begin\"\n\n"); |
| 614 | |
| 615 | fprintf(ofp, "def trace_end():\n"); |
| 616 | fprintf(ofp, "\tprint \"in trace_end\"\n\n"); |
| 617 | |
Arnaldo Carvalho de Melo | da37896 | 2012-06-27 13:08:42 -0300 | [diff] [blame] | 618 | while ((event = trace_find_next_event(pevent, event))) { |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 619 | fprintf(ofp, "def %s__%s(", event->system, event->name); |
| 620 | fprintf(ofp, "event_name, "); |
| 621 | fprintf(ofp, "context, "); |
| 622 | fprintf(ofp, "common_cpu,\n"); |
| 623 | fprintf(ofp, "\tcommon_secs, "); |
| 624 | fprintf(ofp, "common_nsecs, "); |
| 625 | fprintf(ofp, "common_pid, "); |
| 626 | fprintf(ofp, "common_comm,\n\t"); |
| 627 | |
| 628 | not_first = 0; |
| 629 | count = 0; |
| 630 | |
| 631 | for (f = event->format.fields; f; f = f->next) { |
| 632 | if (not_first++) |
| 633 | fprintf(ofp, ", "); |
| 634 | if (++count % 5 == 0) |
| 635 | fprintf(ofp, "\n\t"); |
| 636 | |
| 637 | fprintf(ofp, "%s", f->name); |
| 638 | } |
| 639 | fprintf(ofp, "):\n"); |
| 640 | |
| 641 | fprintf(ofp, "\t\tprint_header(event_name, common_cpu, " |
| 642 | "common_secs, common_nsecs,\n\t\t\t" |
| 643 | "common_pid, common_comm)\n\n"); |
| 644 | |
| 645 | fprintf(ofp, "\t\tprint \""); |
| 646 | |
| 647 | not_first = 0; |
| 648 | count = 0; |
| 649 | |
| 650 | for (f = event->format.fields; f; f = f->next) { |
| 651 | if (not_first++) |
| 652 | fprintf(ofp, ", "); |
| 653 | if (count && count % 3 == 0) { |
| 654 | fprintf(ofp, "\" \\\n\t\t\""); |
| 655 | } |
| 656 | count++; |
| 657 | |
| 658 | fprintf(ofp, "%s=", f->name); |
| 659 | if (f->flags & FIELD_IS_STRING || |
| 660 | f->flags & FIELD_IS_FLAG || |
Namhyung Kim | e646fe7 | 2014-05-29 13:44:55 +0900 | [diff] [blame] | 661 | f->flags & FIELD_IS_ARRAY || |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 662 | f->flags & FIELD_IS_SYMBOLIC) |
| 663 | fprintf(ofp, "%%s"); |
| 664 | else if (f->flags & FIELD_IS_SIGNED) |
| 665 | fprintf(ofp, "%%d"); |
| 666 | else |
| 667 | fprintf(ofp, "%%u"); |
| 668 | } |
| 669 | |
| 670 | fprintf(ofp, "\\n\" %% \\\n\t\t("); |
| 671 | |
| 672 | not_first = 0; |
| 673 | count = 0; |
| 674 | |
| 675 | for (f = event->format.fields; f; f = f->next) { |
| 676 | if (not_first++) |
| 677 | fprintf(ofp, ", "); |
| 678 | |
| 679 | if (++count % 5 == 0) |
| 680 | fprintf(ofp, "\n\t\t"); |
| 681 | |
| 682 | if (f->flags & FIELD_IS_FLAG) { |
| 683 | if ((count - 1) % 5 != 0) { |
| 684 | fprintf(ofp, "\n\t\t"); |
| 685 | count = 4; |
| 686 | } |
| 687 | fprintf(ofp, "flag_str(\""); |
| 688 | fprintf(ofp, "%s__%s\", ", event->system, |
| 689 | event->name); |
| 690 | fprintf(ofp, "\"%s\", %s)", f->name, |
| 691 | f->name); |
| 692 | } else if (f->flags & FIELD_IS_SYMBOLIC) { |
| 693 | if ((count - 1) % 5 != 0) { |
| 694 | fprintf(ofp, "\n\t\t"); |
| 695 | count = 4; |
| 696 | } |
| 697 | fprintf(ofp, "symbol_str(\""); |
| 698 | fprintf(ofp, "%s__%s\", ", event->system, |
| 699 | event->name); |
| 700 | fprintf(ofp, "\"%s\", %s)", f->name, |
| 701 | f->name); |
| 702 | } else |
| 703 | fprintf(ofp, "%s", f->name); |
| 704 | } |
| 705 | |
| 706 | fprintf(ofp, "),\n\n"); |
| 707 | } |
| 708 | |
| 709 | fprintf(ofp, "def trace_unhandled(event_name, context, " |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 710 | "event_fields_dict):\n"); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 711 | |
Pierre Tardy | c025148 | 2010-05-31 23:12:09 +0200 | [diff] [blame] | 712 | fprintf(ofp, "\t\tprint ' '.join(['%%s=%%s'%%(k,str(v))" |
| 713 | "for k,v in sorted(event_fields_dict.items())])\n\n"); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 714 | |
| 715 | fprintf(ofp, "def print_header(" |
| 716 | "event_name, cpu, secs, nsecs, pid, comm):\n" |
| 717 | "\tprint \"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t" |
| 718 | "(event_name, cpu, secs, nsecs, pid, comm),\n"); |
| 719 | |
| 720 | fclose(ofp); |
| 721 | |
| 722 | fprintf(stderr, "generated Python script: %s\n", fname); |
| 723 | |
| 724 | return 0; |
| 725 | } |
| 726 | |
| 727 | struct scripting_ops python_scripting_ops = { |
| 728 | .name = "Python", |
| 729 | .start_script = python_start_script, |
| 730 | .stop_script = python_stop_script, |
| 731 | .process_event = python_process_event, |
| 732 | .generate_script = python_generate_script, |
| 733 | }; |