diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2024-07-15 14:03:44 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2024-07-15 14:03:44 -0700 | 
| commit | a23e1966932464e1c5226cb9ac4ce1d5fc10ba22 (patch) | |
| tree | bf5f1b57faa01ca31656bfc48c7d6b6f0bc39189 /tools/perf/util/scripting-engines/trace-event-python.c | |
| parent | 7c7b1be19b228b450c2945ec379d7fc6bfef9852 (diff) | |
| parent | f3efefb6fdcce604413135bd8d4c5568e53a1f13 (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.11 merge window.
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-python.c')
| -rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 25 | 
1 files changed, 22 insertions, 3 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 94312741443a..b4f0f60e60a6 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -353,6 +353,8 @@ static PyObject *get_field_numeric_entry(struct tep_event *event,  	if (is_array) {  		list = PyList_New(field->arraylen); +		if (!list) +			Py_FatalError("couldn't create Python list");  		item_size = field->size / field->arraylen;  		n_items = field->arraylen;  	} else { @@ -754,7 +756,7 @@ static void regs_map(struct regs_dump *regs, uint64_t mask, const char *arch, ch  	}  } -static void set_regs_in_dict(PyObject *dict, +static int set_regs_in_dict(PyObject *dict,  			     struct perf_sample *sample,  			     struct evsel *evsel)  { @@ -770,6 +772,8 @@ static void set_regs_in_dict(PyObject *dict,  	 */  	int size = __sw_hweight64(attr->sample_regs_intr) * 28;  	char *bf = malloc(size); +	if (!bf) +		return -1;  	regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, size); @@ -781,6 +785,8 @@ static void set_regs_in_dict(PyObject *dict,  	pydict_set_item_string_decref(dict, "uregs",  			_PyUnicode_FromString(bf));  	free(bf); + +	return 0;  }  static void set_sym_in_dict(PyObject *dict, struct addr_location *al, @@ -852,6 +858,10 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,  	pydict_set_item_string_decref(dict, "ev_name", _PyUnicode_FromString(evsel__name(evsel)));  	pydict_set_item_string_decref(dict, "attr", _PyBytes_FromStringAndSize((const char *)&evsel->core.attr, sizeof(evsel->core.attr))); +	pydict_set_item_string_decref(dict_sample, "id", +			PyLong_FromUnsignedLongLong(sample->id)); +	pydict_set_item_string_decref(dict_sample, "stream_id", +			PyLong_FromUnsignedLongLong(sample->stream_id));  	pydict_set_item_string_decref(dict_sample, "pid",  			_PyLong_FromLong(sample->pid));  	pydict_set_item_string_decref(dict_sample, "tid", @@ -920,7 +930,8 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,  			PyLong_FromUnsignedLongLong(sample->cyc_cnt));  	} -	set_regs_in_dict(dict, sample, evsel); +	if (set_regs_in_dict(dict, sample, evsel)) +		Py_FatalError("Failed to setting regs in dict");  	return dict;  } @@ -1299,7 +1310,7 @@ static void python_export_sample_table(struct db_export *dbe,  	struct tables *tables = container_of(dbe, struct tables, dbe);  	PyObject *t; -	t = tuple_new(25); +	t = tuple_new(27);  	tuple_set_d64(t, 0, es->db_id);  	tuple_set_d64(t, 1, es->evsel->db_id); @@ -1326,6 +1337,8 @@ static void python_export_sample_table(struct db_export *dbe,  	tuple_set_d64(t, 22, es->sample->insn_cnt);  	tuple_set_d64(t, 23, es->sample->cyc_cnt);  	tuple_set_s32(t, 24, es->sample->flags); +	tuple_set_d64(t, 25, es->sample->id); +	tuple_set_d64(t, 26, es->sample->stream_id);  	call_object(tables->sample_handler, t, "sample_table"); @@ -1918,12 +1931,18 @@ static int python_start_script(const char *script, int argc, const char **argv,  	scripting_context->session = session;  #if PY_MAJOR_VERSION < 3  	command_line = malloc((argc + 1) * sizeof(const char *)); +	if (!command_line) +		return -1; +  	command_line[0] = script;  	for (i = 1; i < argc + 1; i++)  		command_line[i] = argv[i - 1];  	PyImport_AppendInittab(name, initperf_trace_context);  #else  	command_line = malloc((argc + 1) * sizeof(wchar_t *)); +	if (!command_line) +		return -1; +  	command_line[0] = Py_DecodeLocale(script, NULL);  	for (i = 1; i < argc + 1; i++)  		command_line[i] = Py_DecodeLocale(argv[i - 1], NULL);  | 
