From patchwork Fri Jul 19 22:46:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11050673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E17F14DB for ; Fri, 19 Jul 2019 22:50:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D885287B6 for ; Fri, 19 Jul 2019 22:50:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51B4E289C9; Fri, 19 Jul 2019 22:50:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4049289CA for ; Fri, 19 Jul 2019 22:50:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732346AbfGSWuc (ORCPT ); Fri, 19 Jul 2019 18:50:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:41062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732337AbfGSWuc (ORCPT ); Fri, 19 Jul 2019 18:50:32 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 36E4F20873; Fri, 19 Jul 2019 22:50:31 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.92) (envelope-from ) id 1hobhu-0000M0-9j; Fri, 19 Jul 2019 18:50:30 -0400 Message-Id: <20190719225030.187908166@goodmis.org> User-Agent: quilt/0.65 Date: Fri, 19 Jul 2019 18:46:14 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: Johannes Berg , Josef Bacik , Darren Hart , troyengel@gmail.com Subject: [PATCH 1/3] trace-cmd: Replace PySting_FromString() with PyUnicode_FromString() References: <20190719224613.207069107@goodmis.org> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Steven Rostedt (VMware)" Python 3 has deprecated PyString_FromString(), but both Python 2 and Python 3 have PyUnicode_FromString() which should be equivalent (at least according to google). As Python 2 is going to be EOL soon, we need to support Python 3. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204231 Reported-by: Troy Engel Signed-off-by: Steven Rostedt (VMware) Reviewed-by: Johannes Berg --- python/ctracecmd.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/ctracecmd.i b/python/ctracecmd.i index 65a3d5144b88..09d1d6414fc1 100644 --- a/python/ctracecmd.i +++ b/python/ctracecmd.i @@ -108,7 +108,7 @@ static PyObject *py_field_get_stack(struct tep_handle *pevent, ((int)addr == -1)) break; func = tep_find_function(event->tep, addr); - if (PyList_Append(list, PyString_FromString(func))) { + if (PyList_Append(list, PyUnicode_FromString(func))) { Py_DECREF(list); return NULL; } @@ -162,10 +162,10 @@ static PyObject *py_field_get_str(struct tep_format_field *f, struct tep_record */ offset = val & 0xffff; - return PyString_FromString((char *)r->data + offset); + return PyUnicode_FromString((char *)r->data + offset); } - return PyString_FromStringAndSize((char *)r->data + f->offset, + return PyUnicode_FromStringAndSize((char *)r->data + f->offset, strnlen((char *)r->data + f->offset, f->size)); } @@ -177,7 +177,7 @@ static PyObject *py_format_get_keys(struct tep_event *ef) list = PyList_New(0); for (f = ef->format.fields; f; f = f->next) { - if (PyList_Append(list, PyString_FromString(f->name))) { + if (PyList_Append(list, PyUnicode_FromString(f->name))) { Py_DECREF(list); return NULL; } From patchwork Fri Jul 19 22:46:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11050675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11AA91510 for ; Fri, 19 Jul 2019 22:50:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0105C287B6 for ; Fri, 19 Jul 2019 22:50:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8AFE289C9; Fri, 19 Jul 2019 22:50:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD305289CB for ; Fri, 19 Jul 2019 22:50:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732337AbfGSWuc (ORCPT ); Fri, 19 Jul 2019 18:50:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:41074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732341AbfGSWuc (ORCPT ); Fri, 19 Jul 2019 18:50:32 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 593C32187F; Fri, 19 Jul 2019 22:50:31 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.92) (envelope-from ) id 1hobhu-0000Mb-Eo; Fri, 19 Jul 2019 18:50:30 -0400 Message-Id: <20190719225030.345100829@goodmis.org> User-Agent: quilt/0.65 Date: Fri, 19 Jul 2019 18:46:15 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: Johannes Berg , Josef Bacik , Darren Hart , troyengel@gmail.com Subject: [PATCH 2/3] trace-cmd: Use PyMemoryView_FromMemory() for Python 3 References: <20190719224613.207069107@goodmis.org> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Steven Rostedt (VMware)" Python 3 has deprecated PyBuffer_FromMemory() and instead has PyMemoryView_FromMemory(). Add a helper function that uses the latter if Python 3 is detected. As Python 2 is going to be EOL soon, we need to support Python 3. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204231 Reported-by: Troy Engel Signed-off-by: Steven Rostedt (VMware) Reviewed-by: Johannes Berg --- python/ctracecmd.i | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/python/ctracecmd.i b/python/ctracecmd.i index 09d1d6414fc1..63e5dcb813f1 100644 --- a/python/ctracecmd.i +++ b/python/ctracecmd.i @@ -117,6 +117,15 @@ static PyObject *py_field_get_stack(struct tep_handle *pevent, return list; } +static PyObject *fromMemory(void *buf, size_t len) +{ +#if PY_MAJOR_VERSION >= 3 + return PyMemoryView_FromMemory(buf, len, PyBUF_READ); +#else + return PyBuffer_FromMemory(buf, len); +#endif +} + static PyObject *py_field_get_data(struct tep_format_field *f, struct tep_record *r) { if (!strncmp(f->type, "__data_loc ", 11)) { @@ -137,10 +146,10 @@ static PyObject *py_field_get_data(struct tep_format_field *f, struct tep_record offset = val & 0xffff; len = val >> 16; - return PyBuffer_FromMemory((char *)r->data + offset, len); + return fromMemory(r->data + offset, len); } - return PyBuffer_FromMemory((char *)r->data + f->offset, f->size); + return fromMemory(r->data + f->offset, f->size); } static PyObject *py_field_get_str(struct tep_format_field *f, struct tep_record *r) From patchwork Fri Jul 19 22:46:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11050671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B3FC1510 for ; Fri, 19 Jul 2019 22:50:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36E22287B6 for ; Fri, 19 Jul 2019 22:50:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AD84289D1; Fri, 19 Jul 2019 22:50:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AA23289C9 for ; Fri, 19 Jul 2019 22:50:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727344AbfGSWuc (ORCPT ); Fri, 19 Jul 2019 18:50:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:41092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732346AbfGSWub (ORCPT ); Fri, 19 Jul 2019 18:50:31 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8035D21880; Fri, 19 Jul 2019 22:50:31 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.92) (envelope-from ) id 1hobhu-0000N5-K7; Fri, 19 Jul 2019 18:50:30 -0400 Message-Id: <20190719225030.507227790@goodmis.org> User-Agent: quilt/0.65 Date: Fri, 19 Jul 2019 18:46:16 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: Johannes Berg , Josef Bacik , Darren Hart , troyengel@gmail.com Subject: [PATCH 3/3] trace-cmd: Use PyLong_AsLong() for Python 3 References: <20190719224613.207069107@goodmis.org> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Steven Rostedt (VMware)" Python 3 has deprecated PyInt_AS_LONG. Add code to use PyLong_AsLong() if Python 3 is detected. As Python 2 is going to be EOL soon, we need to support Python 3. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204231 Reported-by: Troy Engel Signed-off-by: Steven Rostedt (VMware) Reviewed-by: Johannes Berg --- python/ctracecmd.i | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python/ctracecmd.i b/python/ctracecmd.i index 63e5dcb813f1..2601d39a76be 100644 --- a/python/ctracecmd.i +++ b/python/ctracecmd.i @@ -117,14 +117,21 @@ static PyObject *py_field_get_stack(struct tep_handle *pevent, return list; } +#if PY_MAJOR_VERSION >= 3 static PyObject *fromMemory(void *buf, size_t len) { -#if PY_MAJOR_VERSION >= 3 return PyMemoryView_FromMemory(buf, len, PyBUF_READ); +} +#define PY_INT_AS_LONG PyLong_AsLong #else +static PyObject *fromMemory(void *buf, size_t len) +{ return PyBuffer_FromMemory(buf, len); -#endif } +#define PY_INT_AS_LONG PyInt_AS_LONG +#endif + + static PyObject *py_field_get_data(struct tep_format_field *f, struct tep_record *r) { @@ -226,7 +233,7 @@ static int python_callback(struct trace_seq *s, Py_XDECREF(result); return 0; } - r = PyInt_AS_LONG(result); + r = PY_INT_AS_LONG(result); } else if (result == Py_None) r = 0; else