From 31cbf41c94b6d213b95e88d2f6b353ff5f1e95eb Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Wed, 20 Feb 2019 10:35:44 +0100 Subject: [PATCH] Add python 3.7 support - Also switch the used PPA for travis. The PPA which contains recent python versions is ppa:deadsnakes/ppa [1] [1] https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa --- .travis.yml | 3 ++- configure.ac | 10 ++++++++-- src/Makefile.am | 7 +++++++ src/frob.cc | 16 ++++++++++++++++ src/frob37.cc | 18 ++++++++++++++++++ src/prober.cc | 3 +++ src/pyfrob.cc | 6 ++++++ src/symbol.h | 3 ++- 8 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 src/frob37.cc diff --git a/.travis.yml b/.travis.yml index 9cc00ec..a8303bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,11 +12,12 @@ env: - PYVERSION=python3.4 - PYVERSION=python3.5 - PYVERSION=python3.6 + - PYVERSION=python3.7 addons: apt: sources: - - sourceline: 'ppa:fkrull/deadsnakes' + - sourceline: 'ppa:deadsnakes/ppa' - autotools-dev - libtool - pkg-config diff --git a/configure.ac b/configure.ac index 0858fc3..5813882 100644 --- a/configure.ac +++ b/configure.ac @@ -111,7 +111,12 @@ PKG_CHECK_MODULES([PY36], [python-3.6], [enable_py36="yes"], [AC_MSG_WARN([Build AM_CONDITIONAL([ENABLE_PY36], [test x"$enable_py36" = xyes]) AM_COND_IF([ENABLE_PY36], [AC_DEFINE([ENABLE_PY36], [1], [Python 3.6 will be enabled])]) -AS_IF([test x"$enable_py26" = xyes -o x"$enable_py34" = xyes -o x"$enable_py36" = xyes], +enable_py37=no +PKG_CHECK_MODULES([PY37], [python-3.7], [enable_py37="yes"], [AC_MSG_WARN([Building without Python 3.7 support])]) +AM_CONDITIONAL([ENABLE_PY37], [test x"$enable_py37" = xyes]) +AM_COND_IF([ENABLE_PY37], [AC_DEFINE([ENABLE_PY37], [1], [Python 3.7 will be enabled])]) + +AS_IF([test x"$enable_py26" = xyes -o x"$enable_py34" = xyes -o x"$enable_py36" = xyes -o x"$enable_py37" = xyes], [AC_MSG_NOTICE([Found at least one copy of Python.h])], [AC_MSG_ERROR([Failed to find a supported Python.h])] ) @@ -127,7 +132,8 @@ echo echo " with threads = $enable_threads" echo " with Python 2.6/7 = $enable_py26" echo " with Python 3.4/5 = $enable_py34" -echo " with Python 3.6+ = $enable_py36" +echo " with Python 3.6 = $enable_py36" +echo " with Python 3.7+ = $enable_py37" echo echo " CXX = $CXX" echo " CXXFLAGS = $CXXFLAGS" diff --git a/src/Makefile.am b/src/Makefile.am index 11d8ab6..0e1a9ef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,3 +34,10 @@ libfrob36_la_CXXFLAGS = $(PY36_CFLAGS) noinst_LTLIBRARIES += libfrob36.la pyflame_LDADD += libfrob36.la endif + +if ENABLE_PY37 +libfrob37_la_SOURCES = frob37.cc +libfrob37_la_CXXFLAGS = $(PY37_CFLAGS) +noinst_LTLIBRARIES += libfrob37.la +pyflame_LDADD += libfrob37.la +endif diff --git a/src/frob.cc b/src/frob.cc index 6fcff39..d3802b8 100644 --- a/src/frob.cc +++ b/src/frob.cc @@ -89,6 +89,22 @@ unsigned long ByteData(unsigned long addr) { return addr + offsetof(PyBytesObject, ob_sval); } +#elif PYFLAME_PY_VERSION == 37 +namespace py36 { +std::string StringDataPython3(pid_t pid, unsigned long addr); + +unsigned long StringSize(unsigned long addr) { + return addr + offsetof(PyVarObject, ob_size); +} + +std::string StringData(pid_t pid, unsigned long addr) { + return StringDataPython3(pid, addr); +} + +unsigned long ByteData(unsigned long addr) { + return addr + offsetof(PyBytesObject, ob_sval); +} + #else static_assert(false, "uh oh, bad PYFLAME_PY_VERSION"); #endif diff --git a/src/frob37.cc b/src/frob37.cc new file mode 100644 index 0000000..d8942ab --- /dev/null +++ b/src/frob37.cc @@ -0,0 +1,18 @@ +// Copyright 2019 SUSE Linux GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// ABI for Python 3.7 +#define PYFLAME_PY_VERSION 37 + +#include "./frob.cc" diff --git a/src/prober.cc b/src/prober.cc index a691c83..5493015 100644 --- a/src/prober.cc +++ b/src/prober.cc @@ -79,6 +79,9 @@ static const int build_abis[] = { #ifdef ENABLE_PY36 36, #endif +#ifdef ENABLE_PY37 + 37, +#endif }; static_assert(sizeof(build_abis) > 0, "No Python ABIs detected!"); diff --git a/src/pyfrob.cc b/src/pyfrob.cc index 7c0588d..f3a9d52 100644 --- a/src/pyfrob.cc +++ b/src/pyfrob.cc @@ -126,6 +126,12 @@ FROB_FUNCS } #endif +#ifdef ENABLE_PY37 +namespace py37 { +FROB_FUNCS +} +#endif + // Fill the addrs_ member int PyFrob::set_addrs_(PyABI *abi) { Namespace ns(pid_); diff --git a/src/symbol.h b/src/symbol.h index bb92b9a..818424d 100644 --- a/src/symbol.h +++ b/src/symbol.h @@ -53,7 +53,8 @@ enum class PyABI { Unknown = 0, // Unknown Python ABI Py26 = 26, // ABI for Python 2.6/2.7 Py34 = 34, // ABI for Python 3.4/3.5 - Py36 = 36 // ABI for Python 3.6 + Py36 = 36, // ABI for Python 3.6 + Py37 = 37 // ABI for Python 3.7 }; // Symbols