Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Commit 522314c

Browse files
committed
Add python 3.7 support
1 parent d67c353 commit 522314c

File tree

8 files changed

+61
-3
lines changed

8 files changed

+61
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212
- PYVERSION=python3.4
1313
- PYVERSION=python3.5
1414
- PYVERSION=python3.6
15+
- PYVERSION=python3.7
1516

1617
addons:
1718
apt:

configure.ac

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ PKG_CHECK_MODULES([PY36], [python-3.6], [enable_py36="yes"], [AC_MSG_WARN([Build
111111
AM_CONDITIONAL([ENABLE_PY36], [test x"$enable_py36" = xyes])
112112
AM_COND_IF([ENABLE_PY36], [AC_DEFINE([ENABLE_PY36], [1], [Python 3.6 will be enabled])])
113113

114-
AS_IF([test x"$enable_py26" = xyes -o x"$enable_py34" = xyes -o x"$enable_py36" = xyes],
114+
enable_py37=no
115+
PKG_CHECK_MODULES([PY37], [python-3.7], [enable_py37="yes"], [AC_MSG_WARN([Building without Python 3.7 support])])
116+
AM_CONDITIONAL([ENABLE_PY37], [test x"$enable_py37" = xyes])
117+
AM_COND_IF([ENABLE_PY37], [AC_DEFINE([ENABLE_PY37], [1], [Python 3.7 will be enabled])])
118+
119+
AS_IF([test x"$enable_py26" = xyes -o x"$enable_py34" = xyes -o x"$enable_py36" = xyes -o x"$enable_py37" = xyes],
115120
[AC_MSG_NOTICE([Found at least one copy of Python.h])],
116121
[AC_MSG_ERROR([Failed to find a supported Python.h])]
117122
)
@@ -127,7 +132,8 @@ echo
127132
echo " with threads = $enable_threads"
128133
echo " with Python 2.6/7 = $enable_py26"
129134
echo " with Python 3.4/5 = $enable_py34"
130-
echo " with Python 3.6+ = $enable_py36"
135+
echo " with Python 3.6 = $enable_py36"
136+
echo " with Python 3.7+ = $enable_py37"
131137
echo
132138
echo " CXX = $CXX"
133139
echo " CXXFLAGS = $CXXFLAGS"

src/Makefile.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ libfrob36_la_CXXFLAGS = $(PY36_CFLAGS)
3434
noinst_LTLIBRARIES += libfrob36.la
3535
pyflame_LDADD += libfrob36.la
3636
endif
37+
38+
if ENABLE_PY37
39+
libfrob37_la_SOURCES = frob37.cc
40+
libfrob37_la_CXXFLAGS = $(PY37_CFLAGS)
41+
noinst_LTLIBRARIES += libfrob37.la
42+
pyflame_LDADD += libfrob37.la
43+
endif

src/frob.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ unsigned long ByteData(unsigned long addr) {
8989
return addr + offsetof(PyBytesObject, ob_sval);
9090
}
9191

92+
#elif PYFLAME_PY_VERSION == 37
93+
namespace py36 {
94+
std::string StringDataPython3(pid_t pid, unsigned long addr);
95+
96+
unsigned long StringSize(unsigned long addr) {
97+
return addr + offsetof(PyVarObject, ob_size);
98+
}
99+
100+
std::string StringData(pid_t pid, unsigned long addr) {
101+
return StringDataPython3(pid, addr);
102+
}
103+
104+
unsigned long ByteData(unsigned long addr) {
105+
return addr + offsetof(PyBytesObject, ob_sval);
106+
}
107+
92108
#else
93109
static_assert(false, "uh oh, bad PYFLAME_PY_VERSION");
94110
#endif

src/frob37.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2019 SUSE Linux GmbH
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// ABI for Python 3.7
16+
#define PYFLAME_PY_VERSION 37
17+
18+
#include "./frob.cc"

src/prober.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ static const int build_abis[] = {
7979
#ifdef ENABLE_PY36
8080
36,
8181
#endif
82+
#ifdef ENABLE_PY37
83+
37,
84+
#endif
8285
};
8386

8487
static_assert(sizeof(build_abis) > 0, "No Python ABIs detected!");

src/pyfrob.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ FROB_FUNCS
126126
}
127127
#endif
128128

129+
#ifdef ENABLE_PY37
130+
namespace py37 {
131+
FROB_FUNCS
132+
}
133+
#endif
134+
129135
// Fill the addrs_ member
130136
int PyFrob::set_addrs_(PyABI *abi) {
131137
Namespace ns(pid_);

src/symbol.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ enum class PyABI {
5353
Unknown = 0, // Unknown Python ABI
5454
Py26 = 26, // ABI for Python 2.6/2.7
5555
Py34 = 34, // ABI for Python 3.4/3.5
56-
Py36 = 36 // ABI for Python 3.6
56+
Py36 = 36, // ABI for Python 3.6
57+
Py37 = 37 // ABI for Python 3.7
5758
};
5859

5960
// Symbols

0 commit comments

Comments
 (0)