30 #include <linux/bitmap.h> 31 #include <linux/compiler.h> 32 #include <linux/time64.h> 34 #include "../../perf.h" 36 #include "../callchain.h" 40 #include "../thread.h" 42 #include "../machine.h" 43 #include "../db-export.h" 44 #include "../thread-stack.h" 45 #include "../trace-event.h" 46 #include "../call-path.h" 53 #if PY_MAJOR_VERSION < 3 54 #define _PyUnicode_FromString(arg) \ 55 PyString_FromString(arg) 56 #define _PyUnicode_FromStringAndSize(arg1, arg2) \ 57 PyString_FromStringAndSize((arg1), (arg2)) 58 #define _PyBytes_FromStringAndSize(arg1, arg2) \ 59 PyString_FromStringAndSize((arg1), (arg2)) 60 #define _PyLong_FromLong(arg) \ 62 #define _PyLong_AsLong(arg) \ 64 #define _PyCapsule_New(arg1, arg2, arg3) \ 65 PyCObject_FromVoidPtr((arg1), (arg2)) 69 #define _PyUnicode_FromString(arg) \ 70 PyUnicode_FromString(arg) 71 #define _PyUnicode_FromStringAndSize(arg1, arg2) \ 72 PyUnicode_FromStringAndSize((arg1), (arg2)) 73 #define _PyBytes_FromStringAndSize(arg1, arg2) \ 74 PyBytes_FromStringAndSize((arg1), (arg2)) 75 #define _PyLong_FromLong(arg) \ 77 #define _PyLong_AsLong(arg) \ 79 #define _PyCapsule_New(arg1, arg2, arg3) \ 80 PyCapsule_New((arg1), (arg2), (arg3)) 82 PyMODINIT_FUNC PyInit_perf_trace_context(
void);
85 #define TRACE_EVENT_TYPE_MAX \ 86 ((1 << (sizeof(unsigned short) * 8)) - 1) 91 #define N_COMMON_FIELDS 7 122 Py_FatalError(
"problem in Python trace event handler");
135 PyDict_SetItemString(dict, key, val);
143 handler = PyDict_GetItemString(
main_dict, handler_name);
144 if (handler && !PyCallable_Check(handler))
157 PyObject *code_obj = PyObject_GetAttrString(handler,
159 if (PyErr_Occurred()) {
161 code_obj = PyObject_GetAttrString(handler,
166 PyObject *arg_count_obj = PyObject_GetAttrString(code_obj,
170 Py_DECREF(arg_count_obj);
181 retval = PyObject_CallObject(handler, args);
198 const char *field_name,
199 const char *field_value,
200 const char *field_str)
202 const char *handler_name =
"define_flag_value";
204 unsigned long long value;
207 if (field_type == PRINT_SYMBOL)
208 handler_name =
"define_symbolic_value";
212 Py_FatalError(
"couldn't create Python tuple");
227 struct print_flag_sym *
field,
229 const char *field_name)
231 define_value(field_type, ev_name, field_name, field->value,
240 const char *field_name,
243 const char *handler_name =
"define_flag_field";
247 if (field_type == PRINT_SYMBOL)
248 handler_name =
"define_symbolic_field";
250 if (field_type == PRINT_FLAGS)
255 Py_FatalError(
"couldn't create Python tuple");
259 if (field_type == PRINT_FLAGS)
269 struct print_arg *
args)
274 switch (args->type) {
304 case PRINT_INT_ARRAY:
315 if (strcmp(args->op.op,
":") == 0)
323 case PRINT_DYNAMIC_ARRAY:
324 case PRINT_DYNAMIC_ARRAY_LEN:
338 bool is_array = field->flags & FIELD_IS_ARRAY;
339 PyObject *obj = NULL, *list = NULL;
340 unsigned long long val;
341 unsigned int item_size, n_items, i;
344 list = PyList_New(field->arraylen);
345 item_size = field->size / field->arraylen;
346 n_items = field->arraylen;
348 item_size = field->size;
352 for (i = 0; i < n_items; i++) {
354 val =
read_size(event, data + field->offset + i * item_size,
356 if (field->flags & FIELD_IS_SIGNED) {
357 if ((
long long)val >= LONG_MIN &&
358 (
long long)val <= LONG_MAX)
361 obj = PyLong_FromLongLong(val);
366 obj = PyLong_FromUnsignedLongLong(val);
369 PyList_SET_ITEM(list, i, obj);
378 const char *dsoname =
"[unknown]";
380 if (map && map->
dso) {
396 pylist = PyList_New(0);
398 Py_FatalError(
"couldn't create Python list");
406 pr_err(
"Failed to resolve callchain. Skipping\n");
419 pyelem = PyDict_New();
421 Py_FatalError(
"couldn't create Python dictionary");
425 PyLong_FromUnsignedLongLong(node->
ip));
428 PyObject *pysym = PyDict_New();
430 Py_FatalError(
"couldn't create Python dictionary");
432 PyLong_FromUnsignedLongLong(node->
sym->
start));
434 PyLong_FromUnsignedLongLong(node->
sym->
end));
451 PyList_Append(pylist, pyelem);
466 pylist = PyList_New(0);
468 Py_FatalError(
"couldn't create Python list");
473 for (i = 0; i < br->
nr; i++) {
478 pyelem = PyDict_New();
480 Py_FatalError(
"couldn't create Python dictionary");
485 PyLong_FromUnsignedLongLong(br->
entries[i].
to));
509 PyList_Append(pylist, pyelem);
519 unsigned long offset;
530 bool print_off,
char *bf,
int size)
532 unsigned long offset;
534 if (!sym || !sym->
name[0])
535 return scnprintf(bf, size,
"%s",
"[unknown]");
538 return scnprintf(bf, size,
"%s", sym->
name);
542 return scnprintf(bf, size,
"%s+0x%x", sym->
name, offset);
548 return scnprintf(bf, size,
"%s",
"-");
551 return scnprintf(bf, size,
"%s",
"M");
553 return scnprintf(bf, size,
"%s",
"P");
565 pylist = PyList_New(0);
567 Py_FatalError(
"couldn't create Python list");
572 for (i = 0; i < br->
nr; i++) {
575 pyelem = PyDict_New();
577 Py_FatalError(
"couldn't create Python dictionary");
611 PyList_Append(pylist, pyelem);
625 Py_FatalError(
"couldn't create Python tuple");
626 PyTuple_SetItem(t, 0, PyLong_FromUnsignedLongLong(value->
id));
627 PyTuple_SetItem(t, 1, PyLong_FromUnsignedLongLong(value->
value));
635 u64 read_format = evsel->
attr.read_format;
639 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
644 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
649 if (read_format & PERF_FORMAT_GROUP)
650 values = PyList_New(sample->
read.
group.nr);
652 values = PyList_New(1);
655 Py_FatalError(
"couldn't create Python list");
657 if (read_format & PERF_FORMAT_GROUP) {
658 for (i = 0; i < sample->
read.
group.nr; i++) {
660 PyList_SET_ITEM(values, i, t);
664 PyList_SET_ITEM(values, 0, t);
676 PyLong_FromUnsignedLongLong(sample->
data_src));
686 unsigned int i = 0, r;
691 for_each_set_bit(r, (
unsigned long *) &mask,
sizeof(mask) * 8) {
692 u64 val = regs->
regs[i++];
694 printed += scnprintf(bf + printed, size - printed,
695 "%5s:0x%" PRIx64
" ",
706 struct perf_event_attr *
attr = &evsel->
attr;
725 PyObject *dict, *dict_sample, *brstack, *brstacksym;
729 Py_FatalError(
"couldn't create Python dictionary");
731 dict_sample = PyDict_New();
733 Py_FatalError(
"couldn't create Python dictionary");
737 (
const char *)&evsel->
attr,
sizeof(evsel->
attr)));
746 PyLong_FromUnsignedLongLong(sample->
ip));
748 PyLong_FromUnsignedLongLong(sample->
time));
750 PyLong_FromUnsignedLongLong(sample->
period));
752 PyLong_FromUnsignedLongLong(sample->
phys_addr));
754 PyLong_FromUnsignedLongLong(sample->
addr));
757 PyLong_FromUnsignedLongLong(sample->
weight));
793 struct event_format *
event = evsel->
tp_format;
794 PyObject *handler, *context, *t, *obj = NULL, *callchain;
795 PyObject *dict = NULL, *all_entries_dict = NULL;
796 static char handler_name[256];
797 struct format_field *
field;
801 int cpu = sample->
cpu;
805 const char *default_handler_name =
"trace_unhandled";
808 snprintf(handler_name,
sizeof(handler_name),
809 "ug! no event found for type %" PRIu64, (u64)evsel->
attr.config);
810 Py_FatalError(handler_name);
815 sprintf(handler_name,
"%s__%s",
event->system,
event->name);
817 if (!test_and_set_bit(
event->id, events_defined))
827 Py_FatalError(
"couldn't create Python dict");
832 Py_FatalError(
"couldn't create Python tuple");
844 PyTuple_SetItem(t, n++, context);
849 Py_INCREF(callchain);
857 PyTuple_SetItem(t, n++, callchain);
866 for (field =
event->format.fields; field; field = field->next) {
867 unsigned int offset, len;
868 unsigned long long val;
870 if (field->flags & FIELD_IS_ARRAY) {
871 offset = field->offset;
873 if (field->flags & FIELD_IS_DYNAMIC) {
874 val = pevent_read_number(scripting_context->
pevent,
880 if (field->flags & FIELD_IS_STRING &&
884 obj = PyByteArray_FromStringAndSize((
const char *) data + offset, len);
885 field->flags &= ~FIELD_IS_STRING;
891 PyTuple_SetItem(t, n++, obj);
898 PyTuple_SetItem(t, n++, dict);
903 PyTuple_SetItem(t, n++, all_entries_dict);
905 Py_DECREF(callchain);
908 if (_PyTuple_Resize(&t, n) == -1)
909 Py_FatalError(
"error resizing Python tuple");
918 Py_XDECREF(all_entries_dict);
928 Py_FatalError(
"couldn't create Python tuple");
934 #if BITS_PER_LONG == 64 937 #if BITS_PER_LONG == 32 938 return PyTuple_SetItem(t, pos, PyLong_FromLongLong(val));
954 struct tables *
tables = container_of(dbe,
struct tables, dbe);
972 struct tables *
tables = container_of(dbe,
struct tables, dbe);
991 struct tables *
tables = container_of(dbe,
struct tables, dbe);
1011 struct tables *
tables = container_of(dbe,
struct tables, dbe);
1029 struct tables *
tables = container_of(dbe,
struct tables, dbe);
1048 struct tables *
tables = container_of(dbe,
struct tables, dbe);
1072 struct tables *
tables = container_of(dbe,
struct tables, dbe);
1095 struct tables *
tables = container_of(dbe,
struct tables, dbe);
1113 struct tables *
tables = container_of(dbe,
struct tables, dbe);
1150 struct tables *
tables = container_of(dbe,
struct tables, dbe);
1152 u64 parent_db_id, sym_db_id;
1174 struct tables *
tables = container_of(dbe,
struct tables, dbe);
1210 PyObject *handler, *t, *dict, *callchain;
1211 static char handler_name[64];
1214 snprintf(handler_name,
sizeof(handler_name),
"%s",
"process_event");
1226 Py_FatalError(
"couldn't create Python tuple");
1232 PyTuple_SetItem(t, n++, dict);
1233 if (_PyTuple_Resize(&t, n) == -1)
1234 Py_FatalError(
"error resizing Python tuple");
1249 switch (evsel->
attr.type) {
1250 case PERF_TYPE_TRACEPOINT:
1269 while ((p = strchr(p,
':'))) {
1279 PyObject *handler, *t;
1280 static char handler_name[256];
1285 Py_FatalError(
"couldn't create Python tuple");
1292 pr_debug(
"can't find python handler %s\n", handler_name);
1304 if (_PyTuple_Resize(&t, n) == -1)
1305 Py_FatalError(
"error resizing Python tuple");
1325 for (thread = 0; thread < threads->
nr; thread++) {
1326 for (cpu = 0; cpu < cpus->
nr; cpu++) {
1336 PyObject *handler, *t;
1337 static const char handler_name[] =
"stat__interval";
1342 Py_FatalError(
"couldn't create Python tuple");
1346 pr_debug(
"can't find python handler %s\n", handler_name);
1352 if (_PyTuple_Resize(&t, n) == -1)
1353 Py_FatalError(
"error resizing Python tuple");
1382 #define SET_TABLE_HANDLER_(name, handler_name, table_name) do { \ 1383 tables->handler_name = get_handler(#table_name); \ 1384 if (tables->handler_name) \ 1385 tables->dbe.export_ ## name = python_export_ ## name; \ 1388 #define SET_TABLE_HANDLER(name) \ 1389 SET_TABLE_HANDLER_(name, name ## _handler, name ## _table) 1396 PyObject *
db_export_mode, *db_export_calls, *db_export_callchains;
1397 bool export_calls =
false;
1398 bool export_callchains =
false;
1401 memset(tables, 0,
sizeof(
struct tables));
1403 Py_FatalError(
"failed to initialize export");
1405 db_export_mode = PyDict_GetItemString(
main_dict, perf_db_export_mode);
1406 if (!db_export_mode)
1409 ret = PyObject_IsTrue(db_export_mode);
1417 db_export_calls = PyDict_GetItemString(
main_dict, perf_db_export_calls);
1418 if (db_export_calls) {
1419 ret = PyObject_IsTrue(db_export_calls);
1422 export_calls = !!ret;
1430 Py_FatalError(
"failed to create calls processor");
1435 db_export_callchains = PyDict_GetItemString(
main_dict,
1436 perf_db_export_callchains);
1437 if (db_export_callchains) {
1438 ret = PyObject_IsTrue(db_export_callchains);
1441 export_callchains = !!ret;
1444 if (export_callchains) {
1457 Py_FatalError(
"failed to create call path root");
1479 #if PY_MAJOR_VERSION < 3 1488 for (i = 0; i < num; i++)
1489 PyMem_RawFree(command_line[i]);
1501 #if PY_MAJOR_VERSION < 3 1502 const char **command_line;
1504 wchar_t **command_line;
1510 #if PY_MAJOR_VERSION < 3 1511 command_line =
malloc((argc + 1) *
sizeof(
const char *));
1512 command_line[0] = script;
1513 for (i = 1; i < argc + 1; i++)
1514 command_line[i] = argv[i - 1];
1516 command_line =
malloc((argc + 1) *
sizeof(
wchar_t *));
1517 command_line[0] = Py_DecodeLocale(script, NULL);
1518 for (i = 1; i < argc + 1; i++)
1519 command_line[i] = Py_DecodeLocale(argv[i - 1], NULL);
1524 #if PY_MAJOR_VERSION < 3 1526 PySys_SetArgv(argc + 1, (
char **)command_line);
1528 PyInit_perf_trace_context();
1529 PySys_SetArgv(argc + 1, command_line);
1532 fp = fopen(script,
"r");
1534 sprintf(buf,
"Can't open python script \"%s\"", script);
1540 err = PyRun_SimpleFile(fp, script);
1542 fprintf(stderr,
"Error running python script %s\n", script);
1548 fprintf(stderr,
"Error starting python script %s\n", script);
1597 struct event_format *
event = NULL;
1598 struct format_field *
f;
1600 int not_first, count;
1603 sprintf(fname,
"%s.py", outfile);
1604 ofp = fopen(fname,
"w");
1606 fprintf(stderr,
"couldn't open %s\n", fname);
1609 fprintf(ofp,
"# perf script event handlers, " 1610 "generated by perf script -g python\n");
1612 fprintf(ofp,
"# Licensed under the terms of the GNU GPL" 1613 " License version 2\n\n");
1615 fprintf(ofp,
"# The common_* event handler fields are the most useful " 1616 "fields common to\n");
1618 fprintf(ofp,
"# all events. They don't necessarily correspond to " 1619 "the 'common_*' fields\n");
1621 fprintf(ofp,
"# in the format files. Those fields not available as " 1622 "handler params can\n");
1624 fprintf(ofp,
"# be retrieved using Python functions of the form " 1625 "common_*(context).\n");
1627 fprintf(ofp,
"# See the perf-script-python Documentation for the list " 1628 "of available functions.\n\n");
1630 fprintf(ofp,
"import os\n");
1631 fprintf(ofp,
"import sys\n\n");
1633 fprintf(ofp,
"sys.path.append(os.environ['PERF_EXEC_PATH'] + \\\n");
1634 fprintf(ofp,
"\t'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')\n");
1635 fprintf(ofp,
"\nfrom perf_trace_context import *\n");
1636 fprintf(ofp,
"from Core import *\n\n\n");
1638 fprintf(ofp,
"def trace_begin():\n");
1639 fprintf(ofp,
"\tprint \"in trace_begin\"\n\n");
1641 fprintf(ofp,
"def trace_end():\n");
1642 fprintf(ofp,
"\tprint \"in trace_end\"\n\n");
1645 fprintf(ofp,
"def %s__%s(",
event->system,
event->name);
1646 fprintf(ofp,
"event_name, ");
1647 fprintf(ofp,
"context, ");
1648 fprintf(ofp,
"common_cpu,\n");
1649 fprintf(ofp,
"\tcommon_secs, ");
1650 fprintf(ofp,
"common_nsecs, ");
1651 fprintf(ofp,
"common_pid, ");
1652 fprintf(ofp,
"common_comm,\n\t");
1653 fprintf(ofp,
"common_callchain, ");
1658 for (f =
event->format.fields; f; f = f->next) {
1661 if (++count % 5 == 0)
1662 fprintf(ofp,
"\n\t");
1664 fprintf(ofp,
"%s", f->name);
1668 if (++count % 5 == 0)
1669 fprintf(ofp,
"\n\t\t");
1670 fprintf(ofp,
"perf_sample_dict");
1672 fprintf(ofp,
"):\n");
1674 fprintf(ofp,
"\t\tprint_header(event_name, common_cpu, " 1675 "common_secs, common_nsecs,\n\t\t\t" 1676 "common_pid, common_comm)\n\n");
1678 fprintf(ofp,
"\t\tprint \"");
1683 for (f =
event->format.fields; f; f = f->next) {
1686 if (count && count % 3 == 0) {
1687 fprintf(ofp,
"\" \\\n\t\t\"");
1691 fprintf(ofp,
"%s=", f->name);
1692 if (f->flags & FIELD_IS_STRING ||
1693 f->flags & FIELD_IS_FLAG ||
1694 f->flags & FIELD_IS_ARRAY ||
1695 f->flags & FIELD_IS_SYMBOLIC)
1696 fprintf(ofp,
"%%s");
1697 else if (f->flags & FIELD_IS_SIGNED)
1698 fprintf(ofp,
"%%d");
1700 fprintf(ofp,
"%%u");
1703 fprintf(ofp,
"\" %% \\\n\t\t(");
1708 for (f =
event->format.fields; f; f = f->next) {
1712 if (++count % 5 == 0)
1713 fprintf(ofp,
"\n\t\t");
1715 if (f->flags & FIELD_IS_FLAG) {
1716 if ((count - 1) % 5 != 0) {
1717 fprintf(ofp,
"\n\t\t");
1720 fprintf(ofp,
"flag_str(\"");
1721 fprintf(ofp,
"%s__%s\", ",
event->system,
1723 fprintf(ofp,
"\"%s\", %s)", f->name,
1725 }
else if (f->flags & FIELD_IS_SYMBOLIC) {
1726 if ((count - 1) % 5 != 0) {
1727 fprintf(ofp,
"\n\t\t");
1730 fprintf(ofp,
"symbol_str(\"");
1731 fprintf(ofp,
"%s__%s\", ",
event->system,
1733 fprintf(ofp,
"\"%s\", %s)", f->name,
1736 fprintf(ofp,
"%s", f->name);
1739 fprintf(ofp,
")\n\n");
1741 fprintf(ofp,
"\t\tprint 'Sample: {'+" 1742 "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n");
1744 fprintf(ofp,
"\t\tfor node in common_callchain:");
1745 fprintf(ofp,
"\n\t\t\tif 'sym' in node:");
1746 fprintf(ofp,
"\n\t\t\t\tprint \"\\t[%%x] %%s\" %% (node['ip'], node['sym']['name'])");
1747 fprintf(ofp,
"\n\t\t\telse:");
1748 fprintf(ofp,
"\n\t\t\t\tprint \"\t[%%x]\" %% (node['ip'])\n\n");
1749 fprintf(ofp,
"\t\tprint \"\\n\"\n\n");
1753 fprintf(ofp,
"def trace_unhandled(event_name, context, " 1754 "event_fields_dict, perf_sample_dict):\n");
1756 fprintf(ofp,
"\t\tprint get_dict_as_string(event_fields_dict)\n");
1757 fprintf(ofp,
"\t\tprint 'Sample: {'+" 1758 "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n");
1760 fprintf(ofp,
"def print_header(" 1761 "event_name, cpu, secs, nsecs, pid, comm):\n" 1762 "\tprint \"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t" 1763 "(event_name, cpu, secs, nsecs, pid, comm),\n\n");
1765 fprintf(ofp,
"def get_dict_as_string(a_dict, delimiter=' '):\n" 1766 "\treturn delimiter.join" 1767 "(['%%s=%%s'%%(k,str(v))for k,v in sorted(a_dict.items())])\n");
1771 fprintf(stderr,
"generated Python script: %s\n", fname);
static int python_export_comm(struct db_export *dbe, struct comm *comm)
static void python_process_stat(struct perf_stat_config *config, struct perf_evsel *counter, u64 tstamp)
struct event_format * trace_find_next_event(struct pevent *pevent, struct event_format *event)
struct addr_location * al
static void handler_call_die(const char *handler_name) __noreturn
static PyObject * python_process_brstack(struct perf_sample *sample, struct thread *thread)
static int tuple_set_s32(PyObject *t, unsigned int pos, s32 val)
static int get_argument_count(PyObject *handler)
struct call_return_processor * call_return_processor__new(int(*process)(struct call_return *cr, void *data), void *data)
static PyObject * get_handler(const char *handler_name)
static void python_process_tracepoint(struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al)
static void set_table_handlers(struct tables *tables)
static int regs_map(struct regs_dump *regs, uint64_t mask, char *bf, int size)
static int python_export_call_path(struct db_export *dbe, struct call_path *cp)
int db_export__sample(struct db_export *dbe, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al)
struct ip_callchain * callchain
struct map * thread__find_map(struct thread *thread, u8 cpumode, u64 addr, struct addr_location *al)
static unsigned long get_offset(struct symbol *sym, struct addr_location *al)
static int zero_flag_atom
static int python_export_dso(struct db_export *dbe, struct dso *dso, struct machine *machine)
static int python_stop_script(void)
static void _free_command_line(const char **command_line, int num)
static PyObject * main_dict
static void python_process_stat_interval(u64 tstamp)
static PyObject * get_sample_value_as_tuple(struct sample_read_value *value)
static void callchain_cursor_commit(struct callchain_cursor *cursor)
static const char * perf_reg_name(int id)
int db_export__init(struct db_export *dbe)
static void call_object(PyObject *handler, PyObject *args, const char *die_msg)
#define _PyLong_FromLong(arg)
static PyObject * get_field_numeric_entry(struct event_format *event, struct format_field *field, void *data)
static PyObject * main_module
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
struct sample_read::@79::@81 group
struct sample_read_value one
int db_export__branch_types(struct db_export *dbe)
struct perf_sample * sample
PyObject * branch_type_handler
struct branch_entry entries[0]
struct call_path_root * cpr
static int python_export_evsel(struct db_export *dbe, struct perf_evsel *evsel)
struct call_path * parent
static int python_export_sample(struct db_export *dbe, struct export_sample *es)
struct scripting_ops python_scripting_ops
unsigned long long eval_flag(const char *flag)
unsigned int scripting_max_stack
bool perf_db_export_callchains
#define _PyCapsule_New(arg1, arg2, arg3)
const char * thread__comm_str(const struct thread *thread)
PyObject * call_path_handler
static int get_br_mspred(struct branch_flags *flags, char *bf, int size)
#define _PyLong_AsLong(arg)
struct call_return_processor * crp
static void set_sample_read_in_dict(PyObject *dict_sample, struct perf_sample *sample, struct perf_evsel *evsel)
#define pr_debug(fmt,...)
unsigned long long read_size(struct event_format *event, void *ptr, int size)
static int python_generate_script(struct pevent *pevent, const char *outfile)
static void callchain_cursor_advance(struct callchain_cursor *cursor)
static void set_regs_in_dict(PyObject *dict, struct perf_sample *sample, struct perf_evsel *evsel)
void db_export__exit(struct db_export *dbe)
#define _PyUnicode_FromString(arg)
static void pydict_set_item_string_decref(PyObject *dict, const char *key, PyObject *val)
static char * cur_field_name
struct regs_dump user_regs
#define _PyBytes_FromStringAndSize(arg1, arg2)
struct perf_counts_values aggr
struct event_format * tp_format
static DECLARE_BITMAP(events_defined, TRACE_EVENT_TYPE_MAX)
struct call_path_root * cpr
static int tuple_set_u64(PyObject *t, unsigned int pos, u64 val)
static int str(yyscan_t scanner, int token)
PyObject * sample_handler
PyObject * call_return_handler
const char * comm__str(const struct comm *comm)
union perf_mem_data_src data_src
static void define_field(enum print_arg_type field_type, const char *ev_name, const char *field_name, const char *delim)
struct regs_dump intr_regs
struct perf_counts * counts
struct branch_stack * branch_stack
struct scripting_context * scripting_context
static int run_start_sub(void)
#define TRACE_EVENT_TYPE_MAX
struct thread_map * threads
PyObject * thread_handler
static int python_export_thread(struct db_export *dbe, struct thread *thread, u64 main_thread_db_id, struct machine *machine)
int db_export__call_return(struct db_export *dbe, struct call_return *cr)
static int python_export_branch_type(struct db_export *dbe, u32 branch_type, const char *name)
int perf_script__meminfo_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
#define _PyUnicode_FromStringAndSize(arg1, arg2)
static int get_symoff(struct symbol *sym, struct addr_location *al, bool print_off, char *bf, int size)
static void try_call_object(const char *handler_name, PyObject *args)
const char * perf_evsel__name(struct perf_evsel *evsel)
bool perf_db_export_calls
static int python_flush_script(void)
static int python_start_script(const char *script, int argc, const char **argv)
static PyObject * python_process_brstacksym(struct perf_sample *sample, struct thread *thread)
static void define_value(enum print_arg_type field_type, const char *ev_name, const char *field_name, const char *field_value, const char *field_str)
static int python_export_symbol(struct db_export *dbe, struct symbol *sym, struct dso *dso)
PyObject * symbol_handler
u8 build_id[BUILD_ID_SIZE]
static int sym(yyscan_t scanner, int type, int config)
int build_id__sprintf(const u8 *build_id, int len, char *bf)
struct perf_evsel * evsel
struct symbol * thread__find_symbol(struct thread *thread, u8 cpumode, u64 addr, struct addr_location *al)
static void python_process_general_event(struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al)
static void define_event_symbols(struct event_format *event, const char *ev_name, struct print_arg *args)
static unsigned int nsecs
static struct tables tables_global
static PyObject * get_perf_sample_dict(struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al, PyObject *callchain)
static pid_t thread_map__pid(struct thread_map *map, int thread)
static int python_export_machine(struct db_export *dbe, struct machine *machine)
static struct perf_counts_values * perf_counts(struct perf_counts *counts, int cpu, int thread)
int thread__resolve_callchain(struct thread *thread, struct callchain_cursor *cursor, struct perf_evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, int max_stack)
static int python_export_comm_thread(struct db_export *dbe, u64 db_id, struct comm *comm, struct thread *thread)
int is_printable_array(char *p, unsigned int len)
static const char * get_dsoname(struct map *map)
#define SET_TABLE_HANDLER(name)
struct call_path_root * call_path_root__new(void)
static void python_process_event(union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al)
PyMODINIT_FUNC initperf_trace_context(void)
static PyObject * python_process_callchain(struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al)
static PyObject * tuple_new(unsigned int sz)
int db_export__flush(struct db_export *dbe)
static void * symbol__priv(struct symbol *sym)
PyObject * comm_thread_handler
static void process_stat(struct perf_evsel *counter, int cpu, int thread, u64 tstamp, struct perf_counts_values *count)
static int python_process_call_return(struct call_return *cr, void *data)
static void get_handler_name(char *str, size_t size, struct perf_evsel *evsel)
struct perf_event_attr attr
static int tuple_set_string(PyObject *t, unsigned int pos, const char *s)
struct branch_flags flags
static void set_sample_datasrc_in_dict(PyObject *dict, struct perf_sample *sample)
unsigned long long raw_field_value(struct event_format *event, const char *name, void *data)
static struct callchain_cursor_node * callchain_cursor_current(struct callchain_cursor *cursor)
static int python_export_call_return(struct db_export *dbe, struct call_return *cr)
PyObject * machine_handler
static void define_values(enum print_arg_type field_type, struct print_flag_sym *field, const char *ev_name, const char *field_name)