perf: Fix python argument name list of read_on_cpu()
PATCH 1/2 perf: Fix python argument name list of read_on_cpu()
Mandatory arguments need to be present in the argument name list, as well as optional arguments, otherwise python barfs:
# ./python/twatch.py Traceback (most recent call last): File "./python/twatch.py", line 41, in <module> main() File "./python/twatch.py", line 32, in main event = evlist.read_on_cpu(cpu) RuntimeError: more argument specifiers than keyword list entries
Hence, add cpu to the name list.
--- tools/perf/util/python.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/python.c +1 -1
@@ -673,7 +673,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,struct perf_evlist *evlist = &pevlist->evlist;union perf_event *event;int sample_id_all =1 , cpu; -static char *kwlist[] = {"sample_id_all" ,NULL ,NULL }; +static char *kwlist[] = {"cpu" ,"sample_id_all" ,NULL ,NULL };if (!PyArg_ParseTupleAndKeywords (args, kwargs,"i|i" , kwlist, &cpu, &sample_id_all))
Signature · 1 line
1.7.3.2
PATCH 2/2 perf: Cleanup useless double NULL termination in python method arg names
The list of methods argument names only needs to be NULL terminated once. Remove the second ones.
--- tools/perf/util/python.c | 15 +++++++-------- 1 files changed, 7 insertions(+), 8 deletions(-)
tools/perf/util/python.c +7 -8
@@ -247,7 +247,7 @@ struct pyrf_cpu_map { static int pyrf_cpu_map__init(struct pyrf_cpu_map *pcpus, PyObject *args, PyObject *kwargs) { - static char *kwlist[] = { "cpustr", NULL, NULL, }; + static char *kwlist[] = { "cpustr", NULL}; char *cpustr = NULL; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s",
@@ -316,7 +316,7 @@ struct pyrf_thread_map { static int pyrf_thread_map__init(struct pyrf_thread_map *pthreads, PyObject *args, PyObject *kwargs) { - static char *kwlist[] = { "pid", "tid", NULL, NULL, }; + static char *kwlist[] = { "pid", "tid", NULL}; int pid = -1, tid = -1; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii",
@@ -418,7 +418,7 @@ static int pyrf_evsel__init(struct pyrf_evsel *pevsel,"wakeup_events" ,"bp_type" ,"bp_addr" , - "bp_len", NULL, NULL, }; + "bp_len", NULL};u64 sample_period =0 ;u32 disabled =0 , inherit = 0,
@@ -499,7 +499,7 @@ static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel,struct thread_map *threads =NULL ;PyObject *pcpus =NULL , *pthreads =NULL ;int group =0 , overwrite =0 ; -static char *kwlist[] = {"cpus" ,"threads" ,"group" ,"overwrite" ,NULL ,NULL }; +static char *kwlist[] = {"cpus" ,"threads" ,"group" ,"overwrite" ,NULL };if (!PyArg_ParseTupleAndKeywords (args, kwargs,"|OOii" , kwlist, &pcpus, &pthreads, &group, &overwrite))
@@ -581,8 +581,7 @@ static PyObject *pyrf_evlist__mmap(struct pyrf_evlist *pevlist, PyObject *args, PyObject *kwargs) { struct perf_evlist *evlist = &pevlist->evlist; -static char *kwlist[] = {"pages" ,"overwrite" , -NULL ,NULL }; +static char *kwlist[] = {"pages" ,"overwrite" ,NULL };int pages =128 , overwrite = false; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", kwlist,
@@ -602,7 +601,7 @@ static PyObject *pyrf_evlist__poll(struct pyrf_evlist *pevlist, PyObject *args, PyObject *kwargs) {struct perf_evlist *evlist = &pevlist->evlist; -static char *kwlist[] = {"timeout" ,NULL ,NULL }; +static char *kwlist[] = {"timeout" ,NULL };int timeout =-1 , n;if (!PyArg_ParseTupleAndKeywords (args, kwargs,"|i" , kwlist, &timeout))
@@ -673,7 +672,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,struct perf_evlist *evlist = &pevlist->evlist;union perf_event *event;int sample_id_all =1 , cpu; -static char *kwlist[] = {"cpu" ,"sample_id_all" ,NULL ,NULL }; +static char *kwlist[] = {"cpu" ,"sample_id_all" ,NULL };if (!PyArg_ParseTupleAndKeywords (args, kwargs,"i|i" , kwlist, &cpu, &sample_id_all))
Signature · 1 line
1.7.3.2
[tip:perf/core] perf python: Cleanup useless double NULL termination in method arg names
Commit-ID: 64348153c63b8c1f99f19f14a9c3cbd5df70c9d3 Gitweb: http://git.kernel.org/tip/64348153c63b8c1f99f19f14a9c3cbd5df70c9d3 Author: Frederic Weisbecker <[email protected]> AuthorDate: Thu, 31 Mar 2011 18:27:43 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 2 Jun 2011 13:21:26 -0300
perf python: Cleanup useless double NULL termination in method arg names
The list of methods argument names only needs to be NULL terminated once. Remove the second ones.
--- tools/perf/util/python.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
tools/perf/util/python.c +9 -8
@@ -247,7 +247,7 @@ struct pyrf_cpu_map { static int pyrf_cpu_map__init(struct pyrf_cpu_map *pcpus, PyObject *args, PyObject *kwargs) { - static char *kwlist[] = { "cpustr", NULL, NULL, }; + static char *kwlist[] = { "cpustr", NULL }; char *cpustr = NULL; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s",
@@ -316,7 +316,7 @@ struct pyrf_thread_map { static int pyrf_thread_map__init(struct pyrf_thread_map *pthreads, PyObject *args, PyObject *kwargs) { - static char *kwlist[] = { "pid", "tid", NULL, NULL, }; + static char *kwlist[] = { "pid", "tid", NULL }; int pid = -1, tid = -1; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii",
@@ -418,7 +418,9 @@ static int pyrf_evsel__init(struct pyrf_evsel *pevsel,"wakeup_events" ,"bp_type" ,"bp_addr" , - "bp_len", NULL, NULL, }; +"bp_len" , +NULL + };u64 sample_period =0 ;u32 disabled =0 , inherit = 0,
@@ -499,7 +501,7 @@ static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel,struct thread_map *threads =NULL ;PyObject *pcpus =NULL , *pthreads =NULL ;int group =0 , inherit =0 ; -static char *kwlist[] = {"cpus" ,"threads" ,"group" ,"inherit" ,NULL ,NULL }; +static char *kwlist[] = {"cpus" ,"threads" ,"group" ,"inherit" ,NULL };if (!PyArg_ParseTupleAndKeywords (args, kwargs,"|OOii" , kwlist, &pcpus, &pthreads, &group, &inherit))
@@ -582,8 +584,7 @@ static PyObject *pyrf_evlist__mmap(struct pyrf_evlist *pevlist, PyObject *args, PyObject *kwargs) { struct perf_evlist *evlist = &pevlist->evlist; -static char *kwlist[] = {"pages" ,"overwrite" , -NULL ,NULL }; +static char *kwlist[] = {"pages" ,"overwrite" ,NULL };int pages =128 , overwrite = false; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", kwlist,
@@ -603,7 +604,7 @@ static PyObject *pyrf_evlist__poll(struct pyrf_evlist *pevlist, PyObject *args, PyObject *kwargs) {struct perf_evlist *evlist = &pevlist->evlist; -static char *kwlist[] = {"timeout" ,NULL ,NULL }; +static char *kwlist[] = {"timeout" ,NULL };int timeout =-1 , n;if (!PyArg_ParseTupleAndKeywords (args, kwargs,"|i" , kwlist, &timeout))
@@ -674,7 +675,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,struct perf_evlist *evlist = &pevlist->evlist;union perf_event *event;int sample_id_all =1 , cpu; -static char *kwlist[] = {"cpu" ,"sample_id_all" ,NULL ,NULL }; +static char *kwlist[] = {"cpu" ,"sample_id_all" ,NULL };int err; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist,
[tip:perf/core] perf python: Fix argument name list of read_on_cpu()
In reply to Frederic WeisbeckerCommit-ID: e95cc02880947e9f77540b03e166470e8ac14cbc Gitweb: http://git.kernel.org/tip/e95cc02880947e9f77540b03e166470e8ac14cbc Author: Frederic Weisbecker <[email protected]> AuthorDate: Thu, 31 Mar 2011 18:27:42 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 2 Jun 2011 13:21:07 -0300
perf python: Fix argument name list of read_on_cpu()
Mandatory arguments need to be present in the argument name list, as well as optional arguments, otherwise python barfs:
# ./python/twatch.py Traceback (most recent call last): File "./python/twatch.py", line 41, in <module> main() File "./python/twatch.py", line 32, in main event = evlist.read_on_cpu(cpu) RuntimeError: more argument specifiers than keyword list entries
Hence, add cpu to the name list.
--- tools/perf/util/python.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/python.c +1 -1
@@ -674,7 +674,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,struct perf_evlist *evlist = &pevlist->evlist;union perf_event *event;int sample_id_all =1 , cpu; -static char *kwlist[] = {"sample_id_all" ,NULL ,NULL }; +static char *kwlist[] = {"cpu" ,"sample_id_all" ,NULL ,NULL };int err; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist,
[tip:perf/core] perf python: Fix argument name list of read_on_cpu()
In reply to Frederic WeisbeckerCommit-ID: b273fa9716aa1564bee88ceee62f9042981cdc81 Gitweb: http://git.kernel.org/tip/b273fa9716aa1564bee88ceee62f9042981cdc81 Author: Frederic Weisbecker <[email protected]> AuthorDate: Thu, 31 Mar 2011 18:27:42 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 3 Jun 2011 10:09:22 -0300
perf python: Fix argument name list of read_on_cpu()
Mandatory arguments need to be present in the argument name list, as well as optional arguments, otherwise python barfs:
# ./python/twatch.py Traceback (most recent call last): File "./python/twatch.py", line 41, in <module> main() File "./python/twatch.py", line 32, in main event = evlist.read_on_cpu(cpu) RuntimeError: more argument specifiers than keyword list entries
Hence, add cpu to the name list.
--- tools/perf/util/python.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/python.c +1 -1
@@ -674,7 +674,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,struct perf_evlist *evlist = &pevlist->evlist;union perf_event *event;int sample_id_all =1 , cpu; -static char *kwlist[] = {"sample_id_all" ,NULL ,NULL }; +static char *kwlist[] = {"cpu" ,"sample_id_all" ,NULL ,NULL };int err; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist,