diff options
Diffstat (limited to 'tools/perf/util/python.c')
| -rw-r--r-- | tools/perf/util/python.c | 33 | 
1 files changed, 31 insertions, 2 deletions
| diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index cbc8f215d4b..9dd47a4f259 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -623,7 +623,11 @@ static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel,  		cpus = ((struct pyrf_cpu_map *)pcpus)->cpus;  	evsel->attr.inherit = inherit; -	if (perf_evsel__open(evsel, cpus, threads, group) < 0) { +	/* +	 * This will group just the fds for this single evsel, to group +	 * multiple events, use evlist.open(). +	 */ +	if (perf_evsel__open(evsel, cpus, threads, group, NULL) < 0) {  		PyErr_SetFromErrno(PyExc_OSError);  		return NULL;  	} @@ -803,7 +807,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,  		first = list_entry(evlist->entries.next, struct perf_evsel, node);  		err = perf_event__parse_sample(event, first->attr.sample_type,  					       perf_evsel__sample_size(first), -					       sample_id_all, &pevent->sample); +					       sample_id_all, &pevent->sample, false);  		if (err)  			return PyErr_Format(PyExc_OSError,  					    "perf: can't parse sample, err=%d", err); @@ -814,6 +818,25 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,  	return Py_None;  } +static PyObject *pyrf_evlist__open(struct pyrf_evlist *pevlist, +				   PyObject *args, PyObject *kwargs) +{ +	struct perf_evlist *evlist = &pevlist->evlist; +	int group = 0; +	static char *kwlist[] = { "group", NULL }; + +	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOii", kwlist, &group)) +		return NULL; + +	if (perf_evlist__open(evlist, group) < 0) { +		PyErr_SetFromErrno(PyExc_OSError); +		return NULL; +	} + +	Py_INCREF(Py_None); +	return Py_None; +} +  static PyMethodDef pyrf_evlist__methods[] = {  	{  		.ml_name  = "mmap", @@ -822,6 +845,12 @@ static PyMethodDef pyrf_evlist__methods[] = {  		.ml_doc	  = PyDoc_STR("mmap the file descriptor table.")  	},  	{ +		.ml_name  = "open", +		.ml_meth  = (PyCFunction)pyrf_evlist__open, +		.ml_flags = METH_VARARGS | METH_KEYWORDS, +		.ml_doc	  = PyDoc_STR("open the file descriptors.") +	}, +	{  		.ml_name  = "poll",  		.ml_meth  = (PyCFunction)pyrf_evlist__poll,  		.ml_flags = METH_VARARGS | METH_KEYWORDS, | 
