[lttng-dev] [PATCH babeltrace v4] Build Python bindings with distutils for consistent installs
v4: Fix DESTDIR behaviour on (un)install targets. This patch changes the build system used to compile and install the Python Bindings. Distutils is used to find the right install directory. When the install directory generated from the install prefix is not in the Python search path (PYTHONPATH), we print a warning explaining what can be done to include it. It uses Distutils which is part of the Python standard library. Signed-off-by: Francis Deslauriers --- .gitignore| 10 +++- bindings/python/Makefile.am | 58 +- bindings/python/babeltrace/Makefile.am| 30 ++ bindings/python/babeltrace/__init__.py.in | 25 bindings/python/setup.py.in | 84 +++ configure.ac | 14 +++-- m4/python_modules.m4 | 23 tests/bin/intersection/bt_python_helper.py.in | 8 +-- 8 files changed, 187 insertions(+), 65 deletions(-) create mode 100644 bindings/python/babeltrace/__init__.py.in create mode 100644 bindings/python/setup.py.in delete mode 100644 m4/python_modules.m4 diff --git a/.gitignore b/.gitignore index a7c9e3c..9259b6f 100644 --- a/.gitignore +++ b/.gitignore @@ -47,8 +47,12 @@ converter/babeltrace-log core formats/ctf/metadata/ctf-parser.output stamp-h1 -bindings/python/babeltrace.i -bindings/python/babeltrace.py -bindings/python/babeltrace_wrap.c +bindings/python/setup.py +bindings/python/installed_files.txt +bindings/python/build +bindings/python/babeltrace/__init__.py +bindings/python/babeltrace/babeltrace.i +bindings/python/babeltrace/babeltrace.py +bindings/python/babeltrace/babeltrace_wrap.c babeltrace.pc babeltrace-ctf.pc diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am index d6b3648..0009546 100644 --- a/bindings/python/Makefile.am +++ b/bindings/python/Makefile.am @@ -1,3 +1,59 @@ if USE_PYTHON -SUBDIRS = babeltrace +SUBDIRS = babeltrace . + +INSTALLED_FILES=$(builddir)/installed_files.txt + +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(srcdir)/babeltrace/ + +# Since the shared object used by the python bindings is not built with libtool +# we need to manually set the `rpath` during linkage +AM_LDFLAGS=-L$(top_builddir)/formats/ctf/.libs -L$(top_builddir)/lib/.libs -Wl,-rpath,$(prefix)/lib + +all-local: build-python-bindings.stamp + +$(builddir)/babeltrace/__init__.py: $(srcdir)/babeltrace/__init__.py.in + cd babeltrace && $(MAKE) __init__.py + +$(builddir)/babeltrace/babeltrace.i: $(srcdir)/babeltrace/babeltrace.i.in + cd babeltrace && $(MAKE) babeltrace.i + +BINDINGS_DEPS=setup.py \ + babeltrace/__init__.py \ + babeltrace/babeltrace.i \ + babeltrace/python-complements.c \ + babeltrace/python-complements.h + +BUILD_FLAGS=CC="$(CC)" \ + CFLAGS="$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(GLIB_CFLAGS) $(AM_CFLAGS)" \ + CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)" \ + LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS)" + +build-python-bindings.stamp: $(BINDINGS_DEPS) + $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build_ext + $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build + touch $@ + +install-exec-local: build-python-bindings.stamp + @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \ + if [ "$(DESTDIR)" != "" ]; then \ + opts="$$opts --root=$(DESTDIR)"; \ + fi; \ + $(PYTHON) $(builddir)/setup.py install $$opts; + +clean-local: + rm -rf $(builddir)/build + +# Distutils' setup.py does not include an uninstall target, we thus need to do +# it manually. We save the path of the files that were installed during the install target +# and delete them during the uninstallation. +uninstall-local: + if [ "$(DESTDIR)" != "" ]; then \ + $(SED) -i "s|^|$(DESTDIR)/|g" $(INSTALLED_FILES); \ + fi + cat $(INSTALLED_FILES) | xargs rm -rf || true + $(GREP) "__init__.py" $(INSTALLED_FILES) | xargs dirname | xargs rm -rf || true + rm -f $(INSTALLED_FILES) + +CLEANFILES = babeltrace/babeltrace_wrap.c babeltrace/babeltrace.py build-python-bindings.stamp +DISTCLEANFILES = setup.py endif diff --git a/bindings/python/babeltrace/Makefile.am b/bindings/python/babeltrace/Makefile.am index 11dcdf0..f612aa6 100644 --- a/bindings/python/babeltrace/Makefile.am +++ b/bindings/python/babeltrace/Makefile.am @@ -1,31 +1,9 @@ +if USE_PYTHON babeltrace.i: babeltrace.i.in sed "s/BABELTRACE_VERSION_STR/Babeltrace $(PACKAGE_VERSION)/g" < \ $(top_srcdir)/bindings/python/babeltrace/babeltrace.i.in > \ $(top_builddir)/bindings/python/babeltrace/babeltrace.i -AM_CFLAGS = $(PYTHON_INCLUDE) -I$(top_srcdir)/include/ \ - -I$(top_srcdir)/bindings/python/babeltrace - -EXTRA_DIST = babeltrace.i.in -nodist_pyth
Re: [lttng-dev] [PATCH] lttng-modules: Fixes for ARM and 32-bit systems
- On Mar 3, 2017, at 6:43 PM, Trent Piepho tpie...@kymetacorp.com wrote: Hi Trent, What lttng-modules branch is this for ? > Patch to fix recv() syscall missing in ARM syscall list. This was probably missing because the current ARM syscall instrumentation was generated from a 3.4.25 kernel that was missing SYSCALL macro description of those system calls. The proper route would be to regenerate the system call table by running a more recent kernel and following instrumentation/syscalls/README from lttng-modules. Those changes will go into master, but those are not fixes per se: they increase the instrumentation coverage. So those are not strictly considered as fixes, and should not be backported to stable lttng-modules versions. > > Patch from lttng mailing list that fixes kernel timestamps being off > by about ~2 seconds on 32-bit systems. Additional patch to fix > compilation bug on non-X86 introduced by previous patch. Why are you re-posting an old version of own patch which now merged into master, stable-2.9 and stable-2.8 branches of lttng-modules ? I don't understand the purpose of this email. Thanks, Mathieu > > Signed-off-by: Trent Piepho > --- > ...trumentation-Add-recv-to-ARM-syscall-tabl.patch | 54 ++ > ...0002-Fix-nmi-safe-clock-on-32-bit-systems.patch | 188 + > ...Fix-trace-clock-wrapper-to-compile-on-ARM.patch | 32 > 3 files changed, 274 insertions(+) > create mode 100644 > package/lttng-modules/0001-syscall-instrumentation-Add-recv-to-ARM-syscall-tabl.patch > create mode 100644 > package/lttng-modules/0002-Fix-nmi-safe-clock-on-32-bit-systems.patch > create mode 100644 > package/lttng-modules/0003-Fix-trace-clock-wrapper-to-compile-on-ARM.patch > > diff --git > a/package/lttng-modules/0001-syscall-instrumentation-Add-recv-to-ARM-syscall-tabl.patch > b/package/lttng-modules/0001-syscall-instrumentation-Add-recv-to-ARM-syscall-tabl.patch > new file mode 100644 > index 000..f65a5d4 > --- /dev/null > +++ > b/package/lttng-modules/0001-syscall-instrumentation-Add-recv-to-ARM-syscall-tabl.patch > @@ -0,0 +1,54 @@ > +From 318aba6e68e0338656909b207a96566c54becc85 Mon Sep 17 00:00:00 2001 > +From: Trent Piepho > +Date: Wed, 22 Feb 2017 12:56:08 -0800 > +Subject: [PATCH] syscall instrumentation: Add recv() to ARM syscall table > + > +This was missing for some reason. > +--- > + instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 | 1 + > + .../syscalls/headers/arm-32-syscalls-3.4.25_pointers.h | 10 > ++ > + 2 files changed, 11 insertions(+) > + > +diff --git a/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 > b/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 > +index 65c3973..c2e2429 100644 > +--- a/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 > b/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 > +@@ -221,6 +221,7 @@ syscall sys_getpeername nr 287 nbargs 3 types: (int, > struct > sockaddr *, int *) a > + syscall sys_socketpair nr 288 nbargs 4 types: (int, int, int, int *) args: > (family, type, protocol, usockvec) > + syscall sys_send nr 289 nbargs 4 types: (int, void *, size_t, unsigned) > args: > (fd, buff, len, flags) > + syscall sys_sendto nr 290 nbargs 6 types: (int, void *, size_t, unsigned, > struct sockaddr *, int) args: (fd, buff, len, flags, addr, addr_len) > ++syscall sys_recv nr 291 nbargs 4 types: (int, void *, size_t, unsigned int) > args: (fd, ubuf, size, flags) > + syscall sys_recvfrom nr 292 nbargs 6 types: (int, void *, size_t, unsigned, > struct sockaddr *, int *) args: (fd, ubuf, size, flags, addr, addr_len) > + syscall sys_shutdown nr 293 nbargs 2 types: (int, int) args: (fd, how) > + syscall sys_setsockopt nr 294 nbargs 5 types: (int, int, int, char *, int) > args: (fd, level, optname, optval, optlen) > +diff --git > a/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h > b/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h > +index 76aab1b..05aae76 100644 > +--- a/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h > b/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h > +@@ -1024,6 +1024,13 @@ SC_LTTNG_TRACEPOINT_EVENT(send, > + TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) > sc_inout(ctf_integer(int, fd, > fd)) sc_inout(ctf_integer(void *, buff, buff)) sc_inout(ctf_integer(size_t, > len, len)) sc_inout(ctf_integer(unsigned, flags, flags))) > + ) > + #endif > ++#ifndef OVERRIDE_32_recv > ++SC_LTTNG_TRACEPOINT_EVENT(recv, > ++TP_PROTO(sc_exit(long ret,) int fd, void * ubuf, size_t size, unsigned > int > flags), > ++TP_ARGS(sc_exit(ret,) fd, ubuf, size, flags), > ++TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) > sc_inout(ctf_integer(int, fd, > fd)) sc_inout(ctf_integer(void *, ubuf, ubuf)) sc_inout(ctf_integer(size_t, > size, size)) sc_inout(ctf_integer(unsigned int, flags, flags))) > ++) > ++#endif > + #ifndef OVERRIDE_32_msgsnd > + SC_LTTNG_TRACEPOINT_EVENT(msgsnd, > +
[lttng-dev] [PATCH] lttng-modules: Fixes for ARM and 32-bit systems
Patch to fix recv() syscall missing in ARM syscall list. Patch from lttng mailing list that fixes kernel timestamps being off by about ~2 seconds on 32-bit systems. Additional patch to fix compilation bug on non-X86 introduced by previous patch. Signed-off-by: Trent Piepho --- ...trumentation-Add-recv-to-ARM-syscall-tabl.patch | 54 ++ ...0002-Fix-nmi-safe-clock-on-32-bit-systems.patch | 188 + ...Fix-trace-clock-wrapper-to-compile-on-ARM.patch | 32 3 files changed, 274 insertions(+) create mode 100644 package/lttng-modules/0001-syscall-instrumentation-Add-recv-to-ARM-syscall-tabl.patch create mode 100644 package/lttng-modules/0002-Fix-nmi-safe-clock-on-32-bit-systems.patch create mode 100644 package/lttng-modules/0003-Fix-trace-clock-wrapper-to-compile-on-ARM.patch diff --git a/package/lttng-modules/0001-syscall-instrumentation-Add-recv-to-ARM-syscall-tabl.patch b/package/lttng-modules/0001-syscall-instrumentation-Add-recv-to-ARM-syscall-tabl.patch new file mode 100644 index 000..f65a5d4 --- /dev/null +++ b/package/lttng-modules/0001-syscall-instrumentation-Add-recv-to-ARM-syscall-tabl.patch @@ -0,0 +1,54 @@ +From 318aba6e68e0338656909b207a96566c54becc85 Mon Sep 17 00:00:00 2001 +From: Trent Piepho +Date: Wed, 22 Feb 2017 12:56:08 -0800 +Subject: [PATCH] syscall instrumentation: Add recv() to ARM syscall table + +This was missing for some reason. +--- + instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 | 1 + + .../syscalls/headers/arm-32-syscalls-3.4.25_pointers.h | 10 ++ + 2 files changed, 11 insertions(+) + +diff --git a/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 b/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 +index 65c3973..c2e2429 100644 +--- a/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 b/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 +@@ -221,6 +221,7 @@ syscall sys_getpeername nr 287 nbargs 3 types: (int, struct sockaddr *, int *) a + syscall sys_socketpair nr 288 nbargs 4 types: (int, int, int, int *) args: (family, type, protocol, usockvec) + syscall sys_send nr 289 nbargs 4 types: (int, void *, size_t, unsigned) args: (fd, buff, len, flags) + syscall sys_sendto nr 290 nbargs 6 types: (int, void *, size_t, unsigned, struct sockaddr *, int) args: (fd, buff, len, flags, addr, addr_len) ++syscall sys_recv nr 291 nbargs 4 types: (int, void *, size_t, unsigned int) args: (fd, ubuf, size, flags) + syscall sys_recvfrom nr 292 nbargs 6 types: (int, void *, size_t, unsigned, struct sockaddr *, int *) args: (fd, ubuf, size, flags, addr, addr_len) + syscall sys_shutdown nr 293 nbargs 2 types: (int, int) args: (fd, how) + syscall sys_setsockopt nr 294 nbargs 5 types: (int, int, int, char *, int) args: (fd, level, optname, optval, optlen) +diff --git a/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h b/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h +index 76aab1b..05aae76 100644 +--- a/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h b/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h +@@ -1024,6 +1024,13 @@ SC_LTTNG_TRACEPOINT_EVENT(send, + TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) sc_inout(ctf_integer(int, fd, fd)) sc_inout(ctf_integer(void *, buff, buff)) sc_inout(ctf_integer(size_t, len, len)) sc_inout(ctf_integer(unsigned, flags, flags))) + ) + #endif ++#ifndef OVERRIDE_32_recv ++SC_LTTNG_TRACEPOINT_EVENT(recv, ++ TP_PROTO(sc_exit(long ret,) int fd, void * ubuf, size_t size, unsigned int flags), ++ TP_ARGS(sc_exit(ret,) fd, ubuf, size, flags), ++ TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) sc_inout(ctf_integer(int, fd, fd)) sc_inout(ctf_integer(void *, ubuf, ubuf)) sc_inout(ctf_integer(size_t, size, size)) sc_inout(ctf_integer(unsigned int, flags, flags))) ++) ++#endif + #ifndef OVERRIDE_32_msgsnd + SC_LTTNG_TRACEPOINT_EVENT(msgsnd, + TP_PROTO(sc_exit(long ret,) int msqid, struct msgbuf * msgp, size_t msgsz, int msgflg), +@@ -1762,6 +1769,9 @@ TRACE_SYSCALL_TABLE(send, send, 289, 4) + #ifndef OVERRIDE_TABLE_32_sendto + TRACE_SYSCALL_TABLE(sendto, sendto, 290, 6) + #endif ++#ifndef OVERRIDE_TABLE_32_recv ++TRACE_SYSCALL_TABLE(recv, recv, 291, 4) ++#endif + #ifndef OVERRIDE_TABLE_32_recvfrom + TRACE_SYSCALL_TABLE(recvfrom, recvfrom, 292, 6) + #endif +-- +2.7.0.25.gfc10eb5.dirty + diff --git a/package/lttng-modules/0002-Fix-nmi-safe-clock-on-32-bit-systems.patch b/package/lttng-modules/0002-Fix-nmi-safe-clock-on-32-bit-systems.patch new file mode 100644 index 000..91296b8 --- /dev/null +++ b/package/lttng-modules/0002-Fix-nmi-safe-clock-on-32-bit-systems.patch @@ -0,0 +1,188 @@ +From 412bf9d51784b49c71b3ddabb3fc0e2b89a59a97 Mon Sep 17 00:00:00 2001 +From: Mathieu Desnoyers +Date: Thu, 9 Feb 2017 20:51:29 -0500 +Subject: [PATCH] Fix: nmi-safe clock on 32-bit systems + +On 32-bit systems, the current algorithm assume to have one clock read +per 3