From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71218 invoked by alias); 1 Jul 2016 16:15:37 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 71198 invoked by uid 89); 1 Jul 2016 16:15:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Staff X-HELO: unimail.uni-dortmund.de Received: from mx1.HRZ.tu-dortmund.de (HELO unimail.uni-dortmund.de) (129.217.128.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 01 Jul 2016 16:15:26 +0000 Received: from [129.217.43.100] (ios.cs.uni-dortmund.de [129.217.43.100]) (authenticated bits=0) by unimail.uni-dortmund.de (8.16.0.16/8.16.0.16) with ESMTPSA id u61GFMKN010925 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Fri, 1 Jul 2016 18:15:22 +0200 (CEST) Subject: SystemTap for Android - patchset References: To: systemtap@sourceware.org From: Alexander Lochmann X-Forwarded-Message-Id: Message-ID: <56e0c7f4-d317-f76b-5156-3569a6097b62@tu-dortmund.de> Date: Fri, 01 Jul 2016 16:15:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="R08HcacMCU64NfuRCB1qLukhRBdS8cF31" X-IsSubscribed: yes X-SW-Source: 2016-q3/txt/msg00002.txt.bz2 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --R08HcacMCU64NfuRCB1qLukhRBdS8cF31 Content-Type: multipart/mixed; boundary="------------241F414D35217FADEB7D41C8" This is a multi-part message in MIME format. --------------241F414D35217FADEB7D41C8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 1491 Hi folks! Finally, I decided to submit my patch, which makes SystemTap work for Android. Moreover, it adds two new features: - Support for ignoring all available tapset directories, except the one that is provided by -K - Support for a pid file in staprun, parameter is -U I had to modify several source files of staprun. Those changes are mostly copied from the corresponding files contained in commit 2c10863bfe41b51272eff714a837f4977bdc257a. For some reasons, those ifdef parts have been removed. I readded them, and changed the macro, which activates them. The patch contains two bugfixes for the SystemTap as well. Unfortunately, I failed to extract those fixes properly. :( The first fix starts at line 510, and goes until line 555. Since an older kernel like 3.0 does not support uprobes, systemtap includes 'runtime/linux/task_finder_stubs.c'. That file itself does *not* include 'syscall.h', which declares several syscall-related functions. The second fix starts at line 1106. For some reasons in the Linux kernel 3.0 the macro cputime_to_usecs() has a semicolon at the end of its definition. Therefore, the defition of cputime_to_msecs() in ' tapset/linux/task_time.stp' must be modified to deal with that fact. Cheers, Alex --- Technische Universit=C3=A4t Dortmund Alexander Lochmann PGP key: 0xBC3EF6FD Otto-Hahn-Str. 16 phone: +49.231.7556141 D-44227 Dortmund fax: +49.231.7556116 http://ess.cs.tu-dortmund.de/Staff/al --------------241F414D35217FADEB7D41C8 Content-Type: text/x-patch; name="stap-android.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="stap-android.patch" Content-length: 39661 diff --git a/Makefile.in b/Makefile.in index 41d5cb7..c1b6d28 100644 --- a/Makefile.in +++ b/Makefile.in @@ -537,6 +537,7 @@ prefix =3D @prefix@ program_transform_name =3D @program_transform_name@ psdir =3D @psdir@ python =3D @python@ +runstatedir =3D @runstatedir@ sbindir =3D @sbindir@ selinux_CFLAGS =3D @selinux_CFLAGS@ selinux_LIBS =3D @selinux_LIBS@ diff --git a/build_android.sh b/build_android.sh new file mode 100755 index 0000000..877ee68 --- /dev/null +++ b/build_android.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +BUILD_PREFIX=3D"/data/data/com.systemtap.android/stap/" +OUTPUT_DIR=3D"android_binaries" +STAPIO_BIN=3D"staprun/stapio" +STAPRUN_BIN=3D"staprun/staprun" +COMPILER_PREFIX_LIST=3D("arm-none-linux-gnueabi" "arm-unknown-linux-gnueab= i") + + +function checkCompiler() +{ + for cur_compiler_prefix in ${COMPILER_PREFIX_LIST[@]} + do + RET=3D`${cur_compiler_prefix}-gcc --version 2>&1` + if [ $? -eq 0 ]; + then + COMPILER_PREFIX=3D${cur_compiler_prefix} + return + fi + done; + + echo "No suitable compiler found. Check your PATH" >&2 + exit 1 +} + +checkCompiler + +ac_cv_with_java=3Dno ac_cv_prog_have_jar=3Dno ac_cv_prog_have_javac=3Dno a= c_cv_with_java=3Dno ac_cv_file__usr_include_avahi_common=3Dno ac_cv_file__u= sr_include_avahi_client=3Dno ac_cv_file__usr_include_nspr=3Dno ac_cv_file__= usr_include_nspr4=3Dno ac_cv_file__usr_include_nss=3Dno ac_cv_file__usr_inc= lude_nss3=3Dno ac_cv_func_malloc_0_nonnull=3Dyes ./configure --prefix=3D$BU= ILD_PREFIX --host=3D$COMPILER_PREFIX --disable-translator --disable-docs --= disable-refdocs --disable-grapher --without-rpm --without-nss --with-andro= id=20 + +if [ $? -ne 0 ]; then + echo "Error configuring the workspace" >&2 + exit 1 +fi + +make=20 + +if [ $? -ne 0 ]; then + echo "Error building stap{run,io}" >&2 + exit 1 +fi + +if [ -e $STAPRUN_BIN ] && [ -e $STAPIO_RUN ]; then + if [ ! -d $OUTPUT_DIR ]; then + mkdir $OUTPUT_DIR + fi + cp $STAPRUN_BIN $OUTPUT_DIR + cp $STAPIO_BIN $OUTPUT_DIR +else + rm ${OUTPUT_DIR}/${STAPRUN_BIN} + rm ${OUTPUT_DIR}/${STAPIO_BIN} + echo "Some binaries were not created." + exit 1 +fi diff --git a/buildrun.cxx b/buildrun.cxx index 76139b4..ea5e273 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -780,6 +780,12 @@ make_run_command (systemtap_session& s, const string& = remotedir, staprun_cmd.push_back("-v"); if (s.suppress_warnings) staprun_cmd.push_back("-w"); +=20=20 + if (!s.pid_file.empty()) + { + staprun_cmd.push_back("-M"); + staprun_cmd.push_back(s.pid_file); + } =20 if (!s.output_file.empty()) { diff --git a/cmdline.h b/cmdline.h index c5d64f4..bc93058 100644 --- a/cmdline.h +++ b/cmdline.h @@ -66,7 +66,7 @@ enum { =20 // NB: when adding new options, consider very carefully whether they // should be restricted from stap clients (after --client-options)! -#define STAP_SHORT_OPTIONS "hVvtp:I:e:E:o:R:r:a:m:kgPc:x:D:bs:uqiwl:d:L:FS= :B:J:jWG:" +#define STAP_SHORT_OPTIONS "hVvtp:I:e:E:o:R:r:a:m:kgPc:x:D:bs:uqiwl:d:L:FS= :B:J:jWG:K:" =20 extern struct option stap_long_options[]; =20 diff --git a/config.in b/config.in index 9c50cf9..20d2b3f 100644 --- a/config.in +++ b/config.in @@ -13,6 +13,9 @@ /* Define to 1 to enable process.mark probes in stap, staprun, stapio. */ #undef ENABLE_SDT_PROBES =20 +/* Define to 1 if you compile for Android. */ +#undef HAVE_ANDROID + /* Define to 1 if you have the avahi libraries. */ #undef HAVE_AVAHI =20 diff --git a/configure b/configure index 51fe5fd..fbc1ccc 100755 --- a/configure +++ b/configure @@ -670,6 +670,8 @@ stap_LIBS elfutils_abs_srcdir BUILD_ELFUTILS_FALSE BUILD_ELFUTILS_TRUE +HAVE_ANDROID_FALSE +HAVE_ANDROID_TRUE python HAVE_LIBREADLINE_FALSE HAVE_LIBREADLINE_TRUE @@ -821,6 +823,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -868,6 +871,7 @@ enable_server with_avahi with_rpm with_python3 +with_android with_elfutils with_dyninst enable_virt @@ -943,6 +947,7 @@ datadir=3D'${datarootdir}' sysconfdir=3D'${prefix}/etc' sharedstatedir=3D'${prefix}/com' localstatedir=3D'${prefix}/var' +runstatedir=3D'${localstatedir}/run' includedir=3D'${prefix}/include' oldincludedir=3D'/usr/include' docdir=3D'${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1195,6 +1200,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=3Dyes ;; =20 + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=3Drunstatedir ;; + -runstatedir=3D* | --runstatedir=3D* | --runstatedi=3D* | --runstated=3D= * \ + | --runstate=3D* | --runstat=3D* | --runsta=3D* | --runst=3D* | --runs= =3D* \ + | --run=3D* | --ru=3D* | --r=3D*) + runstatedir=3D$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=3Dsbindir ;; -sbindir=3D* | --sbindir=3D* | --sbindi=3D* | --sbind=3D* | --sbin=3D* \ @@ -1332,7 +1346,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=3D\$$ac_var # Remove trailing slashes. @@ -1485,6 +1499,7 @@ Fine tuning of the installation directories: --sysconfdir=3DDIR read-only single-machine data [PREFIX/etc] --sharedstatedir=3DDIR modifiable architecture-independent data [PREF= IX/com] --localstatedir=3DDIR modifiable single-machine data [PREFIX/var] + --runstatedir=3DDIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=3DDIR object code libraries [EPREFIX/lib] --includedir=3DDIR C header files [PREFIX/include] --oldincludedir=3DDIR C header files for non-gcc [/usr/include] @@ -1570,6 +1585,7 @@ Optional Packages: --without-avahi Do not use Avahi even if present --with-rpm query rpm database for missing debuginfos --with-python3 prefer /usr/bin/python3 + --with-android --with-elfutils=3DDIRECTORY find elfutils source code in DIRECTORY --with-dyninst=3DDIRECTORY @@ -7044,7 +7060,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -7090,7 +7106,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -7114,7 +7130,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.= $ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -7159,7 +7175,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -7183,7 +7199,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.= $ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -10527,6 +10543,29 @@ else =20 fi =20 + +# Check whether --with-android was given. +if test "${with_android+set}" =3D set; then : + withval=3D$with_android; +fi + +if test "x$with_android" =3D "xyes"; then : + have_android=3Dyes + +$as_echo "#define HAVE_ANDROID 1" >>confdefs.h + +else + have_android=3Dno +fi + if test "${have_android}" =3D=3D "yes"; then + HAVE_ANDROID_TRUE=3D + HAVE_ANDROID_FALSE=3D'#' +else + HAVE_ANDROID_TRUE=3D'#' + HAVE_ANDROID_FALSE=3D +fi + + build_elfutils=3Dno =20 # Check whether --with-elfutils was given. @@ -10715,7 +10754,8 @@ $as_echo "$as_me: stap will link $stap_LIBS" >&6;} # staprun has more modest libelf needs if test $build_elfutils =3D no; then save_LIBS=3D"$LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_getshdrstrnd= x in -lelf" >&5 + if test "${have_android}" =3D=3D "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_getshdrstrndx = in -lelf" >&5 $as_echo_n "checking for elf_getshdrstrndx in -lelf... " >&6; } if ${ac_cv_lib_elf_elf_getshdrstrndx+:} false; then : $as_echo_n "(cached) " >&6 @@ -10758,16 +10798,57 @@ _ACEOF =20 LIBS=3D"-lelf $LIBS" =20 +fi + + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_getshdrstrndx= in -lelf" >&5 +$as_echo_n "checking for elf_getshdrstrndx in -lelf... " >&6; } +if ${ac_cv_lib_elf_elf_getshdrstrndx+:} false; then : + $as_echo_n "(cached) " >&6 else + ac_check_lib_save_LIBS=3D$LIBS +LIBS=3D"-lelf $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ =20 - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char elf_getshdrstrndx (); +int +main () +{ +return elf_getshdrstrndx (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_elf_elf_getshdrstrndx=3Dyes +else + ac_cv_lib_elf_elf_getshdrstrndx=3Dno +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=3D$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf_getshd= rstrndx" >&5 +$as_echo "$ac_cv_lib_elf_elf_getshdrstrndx" >&6; } +if test "x$ac_cv_lib_elf_elf_getshdrstrndx" =3D xyes; then : + staprun_LIBS=3D"$staprun_LIBS -lelf" + LIBS=3D"$save_LIBS" +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "libelf too old, need 0.142+ See \`config.log' for more details" "$LINENO" 5; } fi =20 - staprun_LIBS=3D"$staprun_LIBS -lelf" - LIBS=3D"$save_LIBS" + fi else # We built our own and staprun_LDFLAGS points at the install. staprun_LIBS=3D"$staprun_LIBS -lelf" @@ -11507,6 +11588,7 @@ rm -f core conftest.err conftest.$ac_objext conftes= t.$ac_ext --exec-prefix=3D"$exec_prefix" \ --prefix=3D"$prefix" \ --enable-dwz \ + --host=3D${host_alias} \ ${need_maintainer_option} \ CFLAGS=3D"${CFLAGS/-Wall/} $gnu89_inline_flag -fexceptions" \ LDFLAGS=3D"$LDFLAGS $elfutils_rpath" && @@ -12067,6 +12149,10 @@ if test -z "${HAVE_LIBREADLINE_TRUE}" && test -z "= ${HAVE_LIBREADLINE_FALSE}"; th as_fn_error $? "conditional \"HAVE_LIBREADLINE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_ANDROID_TRUE}" && test -z "${HAVE_ANDROID_FALSE}"; then + as_fn_error $? "conditional \"HAVE_ANDROID\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${BUILD_ELFUTILS_TRUE}" && test -z "${BUILD_ELFUTILS_FALSE}"; = then as_fn_error $? "conditional \"BUILD_ELFUTILS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index cd781a2..f32ad68 100644 --- a/configure.ac +++ b/configure.ac @@ -422,7 +422,15 @@ AC_ARG_WITH([python3], AS_IF([test "x$with_python3" =3D "xyes"], [AC_SUBST(python,[python3])], [AC_SUBST(python,[python])]) -=20=20=20=20=20=20 + +AC_ARG_WITH([android], + AS_HELP_STRING([--with-android],[])) +AS_IF([test "x$with_android" =3D "xyes"], + [have_android=3Dyes + AC_DEFINE([HAVE_ANDROID], [1], [Define to 1 if you compile for Android.])= ], + [have_android=3Dno]) +AM_CONDITIONAL([HAVE_ANDROID], [test "${have_android}" =3D=3D "yes"]) + dnl Handle elfutils. If '--with-elfutils=3DDIR' wasn't specified, used dnl the system's elfutils. build_elfutils=3Dno @@ -471,10 +479,15 @@ AC_MSG_NOTICE([stap will link $stap_LIBS]) if test $build_elfutils =3D no; then save_LIBS=3D"$LIBS" dnl this will only succeed with elfutils 0.142+ - AC_CHECK_LIB(elf,elf_getshdrstrndx,[],[ - AC_MSG_FAILURE([libelf too old, need 0.142+])]) - staprun_LIBS=3D"$staprun_LIBS -lelf" - LIBS=3D"$save_LIBS" + if test "${have_android}" =3D=3D "yes"; then + AC_CHECK_LIB(elf,elf_getshdrstrndx,[],[]) + + else + AC_CHECK_LIB(elf,elf_getshdrstrndx, + [staprun_LIBS=3D"$staprun_LIBS -lelf" + LIBS=3D"$save_LIBS"], + [AC_MSG_FAILURE([libelf too old, need 0.142+])]) + fi else # We built our own and staprun_LDFLAGS points at the install. staprun_LIBS=3D"$staprun_LIBS -lelf" @@ -643,6 +656,7 @@ if test $build_elfutils =3D yes -a $enable_translator = =3D yes; then --exec-prefix=3D"$exec_prefix" \ --prefix=3D"$prefix" \ --enable-dwz \ + --host=3D${host_alias} \ ${need_maintainer_option} \ CFLAGS=3D"${CFLAGS/-Wall/} $gnu89_inline_flag -fexceptions" \ LDFLAGS=3D"$LDFLAGS $elfutils_rpath" && diff --git a/doc/Makefile.in b/doc/Makefile.in index 1b4f10e..355dbc3 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -309,6 +309,7 @@ prefix =3D @prefix@ program_transform_name =3D @program_transform_name@ psdir =3D @psdir@ python =3D @python@ +runstatedir =3D @runstatedir@ sbindir =3D @sbindir@ selinux_CFLAGS =3D @selinux_CFLAGS@ selinux_LIBS =3D @selinux_LIBS@ diff --git a/doc/SystemTap_Tapset_Reference/Makefile.in b/doc/SystemTap_Tap= set_Reference/Makefile.in index 8426075..ecf46ec 100644 --- a/doc/SystemTap_Tapset_Reference/Makefile.in +++ b/doc/SystemTap_Tapset_Reference/Makefile.in @@ -316,6 +316,7 @@ prefix =3D @prefix@ program_transform_name =3D @program_transform_name@ psdir =3D @psdir@ python =3D @python@ +runstatedir =3D @runstatedir@ sbindir =3D @sbindir@ selinux_CFLAGS =3D @selinux_CFLAGS@ selinux_LIBS =3D @selinux_LIBS@ diff --git a/doc/SystemTap_Tapset_Reference/tapsets.pdf b/doc/SystemTap_Tap= set_Reference/tapsets.pdf deleted file mode 100644 index 9649e6d..0000000 Binary files a/doc/SystemTap_Tapset_Reference/tapsets.pdf and /dev/null dif= fer diff --git a/doc/beginners/Makefile.in b/doc/beginners/Makefile.in index e584f13..337e743 100644 --- a/doc/beginners/Makefile.in +++ b/doc/beginners/Makefile.in @@ -275,6 +275,7 @@ prefix =3D @prefix@ program_transform_name =3D @program_transform_name@ psdir =3D @psdir@ python =3D @python@ +runstatedir =3D @runstatedir@ sbindir =3D @sbindir@ selinux_CFLAGS =3D @selinux_CFLAGS@ selinux_LIBS =3D @selinux_LIBS@ @@ -370,8 +371,8 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -@BUILD_DOCS_FALSE@uninstall-local: @BUILD_DOCS_FALSE@clean-local: +@BUILD_DOCS_FALSE@uninstall-local: @BUILD_DOCS_FALSE@install-data-hook: clean: clean-am =20 diff --git a/java/Makefile.in b/java/Makefile.in index d878b4b..b3437f1 100644 --- a/java/Makefile.in +++ b/java/Makefile.in @@ -363,6 +363,7 @@ prefix =3D @prefix@ program_transform_name =3D @program_transform_name@ psdir =3D @psdir@ python =3D @python@ +runstatedir =3D @runstatedir@ sbindir =3D @sbindir@ selinux_CFLAGS =3D @selinux_CFLAGS@ selinux_LIBS =3D @selinux_LIBS@ @@ -640,9 +641,9 @@ maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +@HAVE_JAVA_FALSE@install-exec-local: @HAVE_JAVA_FALSE@uninstall-local: @HAVE_JAVA_FALSE@install-data-local: -@HAVE_JAVA_FALSE@install-exec-local: clean: clean-am =20 clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \ diff --git a/man/Makefile.in b/man/Makefile.in index e6bed42..2cc06b9 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -347,6 +347,7 @@ prefix =3D @prefix@ program_transform_name =3D @program_transform_name@ psdir =3D @psdir@ python =3D @python@ +runstatedir =3D @runstatedir@ sbindir =3D @sbindir@ selinux_CFLAGS =3D @selinux_CFLAGS@ selinux_LIBS =3D @selinux_LIBS@ diff --git a/man/cs/Makefile.in b/man/cs/Makefile.in index 3bedbf6..9036c6d 100644 --- a/man/cs/Makefile.in +++ b/man/cs/Makefile.in @@ -311,6 +311,7 @@ prefix =3D @prefix@ program_transform_name =3D @program_transform_name@ psdir =3D @psdir@ python =3D @python@ +runstatedir =3D @runstatedir@ sbindir =3D @sbindir@ selinux_CFLAGS =3D @selinux_CFLAGS@ selinux_LIBS =3D @selinux_LIBS@ diff --git a/runtime/linux/autoconf-asm-syscall.c b/runtime/linux/autoconf-= asm-syscall.c index bf7a273..6bfcd55 100644 --- a/runtime/linux/autoconf-asm-syscall.c +++ b/runtime/linux/autoconf-asm-syscall.c @@ -1,2 +1,8 @@ +#include +#if LINUX_VERSION_CODE <=3D KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE = >=3D KERNEL_VERSION(3,0,0) +#include +#include +#include +#else #include - +#endif diff --git a/runtime/linux/task_finder_stubs.c b/runtime/linux/task_finder_= stubs.c index 700bb3d..39f9ec2 100644 --- a/runtime/linux/task_finder_stubs.c +++ b/runtime/linux/task_finder_stubs.c @@ -1,6 +1,7 @@ #ifndef TASK_FINDER_STUBS_C #define TASK_FINDER_STUBS_C =20 +#include "syscall.h" /* Stubs of last resort for when utrace type functionality is not available. Nothing should actually work, but things compile properly, and silently return dummy data or noisily fail as diff --git a/runtime/syscall.h b/runtime/syscall.h index b959d46..b652946 100644 --- a/runtime/syscall.h +++ b/runtime/syscall.h @@ -7,7 +7,6 @@ * Public License (GPL); either version 2, or (at your option) any * later version. */ - #ifndef _SYSCALL_H_ /* -*- linux-c -*- */ #define _SYSCALL_H_ =20 @@ -110,7 +109,14 @@ #ifdef STAPCONF_ASM_SYSCALL_H =20 /* If the system has asm/syscall.h, use defines from it. */ +#include +#if LINUX_VERSION_CODE <=3D KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE = >=3D KERNEL_VERSION(3,0,0) +#include +#include +#include +#else #include +#endif =20 #if defined(__arm__) /* The syscall_get_nr() function on 3.17.1-302.fc21.armv7hl always diff --git a/session.cxx b/session.cxx index fd3d680..deb82aa 100644 --- a/session.cxx +++ b/session.cxx @@ -132,6 +132,7 @@ systemtap_session::systemtap_session (): last_pass =3D 5; module_name =3D "stap_" + lex_cast(getpid()); stapconf_name =3D "stapconf_" + lex_cast(getpid()) + ".h"; + pid_file =3D ""; output_file =3D ""; // -o FILE tmpdir_opt_set =3D false; monitor =3D false; @@ -165,6 +166,7 @@ systemtap_session::systemtap_session (): try_server_status =3D try_server_unset; use_remote_prefix =3D false; systemtap_v_check =3D false; + excl_include_path =3D false; download_dbinfo =3D 0; suppress_handler_errors =3D false; native_build =3D true; // presumed @@ -319,6 +321,7 @@ systemtap_session::systemtap_session (const systemtap_s= ession& other, last_pass =3D other.last_pass; module_name =3D other.module_name; stapconf_name =3D other.stapconf_name; + pid_file =3D other.pid_file; output_file =3D other.output_file; // XXX how should multiple remotes wo= rk? tmpdir_opt_set =3D false; monitor =3D other.monitor; @@ -568,7 +571,8 @@ systemtap_session::usage (int exitcode) for (unsigned i=3D0; i=3D 1) { - execlp("sh", "sh", "-c", cmd, NULL); + execlp(SYSTEM_SHELL, SYSTEM_SHELL, "-c", cmd, NULL); /* should not return */ perror(staprun); _exit(-1); diff --git a/staprun/stapio.c b/staprun/stapio.c index 664896d..d61d30e 100644 --- a/staprun/stapio.c +++ b/staprun/stapio.c @@ -70,10 +70,18 @@ int main(int argc, char **argv) if (init_stapio()) exit(1); =20 + if (pidfile_name) + create_pidfile(pidfile_name); + if (stp_main_loop()) { err(_("Couldn't enter main loop. Exiting.\n")); + if (pidfile_name) + delete_pidfile(pidfile_name); + exit(1); } =20 + if (pidfile_name) + delete_pidfile(pidfile_name); return 0; } diff --git a/staprun/staprun.c b/staprun/staprun.c index 89e6d8b..3159210 100644 --- a/staprun/staprun.c +++ b/staprun/staprun.c @@ -350,8 +350,10 @@ int init_staprun(void) disable_kprobes_optimization(); =20 if (insert_stap_module(& user_credentials) < 0) { +#ifdef HAVE_ANDROID if(!rename_mod && errno =3D=3D EEXIST) err("Rerun with staprun option '-R' to rename this module.\n"); +#endif return -1; } rc =3D init_ctl_channel (modname, 0); diff --git a/staprun/staprun.h b/staprun/staprun.h index 8e0c664..7df0969 100644 --- a/staprun/staprun.h +++ b/staprun/staprun.h @@ -220,6 +220,8 @@ void usage(char *prog, int rc); void parse_modpath(const char *); void setup_signals(void); int set_clexec(int fd); +void create_pidfile(const char *pidfile_name); +void delete_pidfile(const char *pidfile_name); int open_cloexec(const char *pathname, int flags, mode_t mode); #ifdef HAVE_OPENAT int openat_cloexec(int dirfd, const char *pathname, int flags, mode_t mode= ); @@ -258,6 +260,7 @@ extern char *modpath; extern char *modoptions[MAXMODOPTIONS]; extern int target_pid; extern char *target_cmd; +extern char *pidfile_name; extern int target_namespaces_pid; extern char *outfile_name; extern int rename_mod; diff --git a/staprun/staprun_funcs.c b/staprun/staprun_funcs.c index 16d3bed..c30d4d9 100644 --- a/staprun/staprun_funcs.c +++ b/staprun/staprun_funcs.c @@ -19,10 +19,12 @@ #include #include =20 +#ifndef HAVE_ANDROID /* The module-renaming facility only works with new enough elfutils: 0.142+. */ #include #include +#endif =20 #include =20 @@ -198,6 +200,7 @@ int insert_module( return 0; } =20 +#ifndef HAVE_ANDROID static Elf_Scn * find_section_in_module(const void* module_file, const __off_t st_size, con= st char *section_name) { @@ -236,10 +239,12 @@ find_section_in_module(const void* module_file, const= __off_t st_size, const cha } return scn; } +#endif /* HAVE_ANDROID */ =20 int rename_module(void* module_file, const __off_t st_size) { +#ifndef HAVE_ANDROID int length_to_replace; char newname[MODULE_NAME_LEN]; char *p; @@ -297,6 +302,14 @@ rename_module(void* module_file, const __off_t st_size) } _err("Could not find old name to replace!\n"); return -1; +#else + /* Old or no elfutils? Pretend to have renamed. This means a + greater likelihood for module-name collisions, but so be + it. */ + (void) module_file; + (void) st_size; + return 0;=20 +#endif /* HAVE_ANDROID */ } =20 =20 @@ -574,6 +587,22 @@ static privilege_t get_module_required_credentials ( const __off_t st_size __attribute__ ((unused)) ) { +#ifdef HAVE_ANDROID + /* Without the proper ELF support, we can't determine the credentials re= quired to run this + module. However, we know that it has been correctly signed (we only c= heck privilege + credentials for correctly signed modules). It is therefore either + a) a dual-privilege-level era module compiled with stapusr privileg= es enforced or, + b) a multi-privilege-level era module with built-in privilege level= checking. + In either case, we can load it for stapusr level users and above. In = case a, it requires + exactly that privilege level. In case b, the module will self check a= gainst the user's + actual privilege level. + */ + if (verbose >=3D 1) { + err ("Unable to determine the privilege level required for the module = %s. Assuming %s.\n", + module_path, pr_name (pr_stapusr)); + } + return pr_stapusr; +#else Elf_Scn *scn =3D 0; Elf_Data *data =3D 0; GElf_Shdr shdr; @@ -658,6 +687,7 @@ static privilege_t get_module_required_credentials ( =20 /* ALl is ok. Return the extracted privilege data. */ return privilege; +#endif /* HAVE_ANDROID */ } =20 /* diff --git a/tapset/linux/task_time.stp b/tapset/linux/task_time.stp index f86f984..f3c276c 100644 --- a/tapset/linux/task_time.stp +++ b/tapset/linux/task_time.stp @@ -27,8 +27,12 @@ * Yet note some kernels (RHEL6) may already have both... */ #if defined(cputime_to_usecs) #if !defined(cputime_to_msecs) +#if LINUX_VERSION_CODE <=3D KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE = >=3D KERNEL_VERSION(3,0,0) +#define cputime_to_msecs(__ct) _stp_div64(NULL, ({cputime_to_usecs(__ct)}= ), 1000ULL) +#else #define cputime_to_msecs(__ct) _stp_div64(NULL, cputime_to_usecs(__ct), 1= 000ULL) #endif +#endif =20 /* Kernels before 2.6.37 have cputime_to_msecs, but not usecs. */ #elif defined(cputime_to_msecs) --------------241F414D35217FADEB7D41C8-- --R08HcacMCU64NfuRCB1qLukhRBdS8cF31 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXdpcaAAoJEFk+7QW8Pvb9oQ0QANG5ZF+Sl50tH50v2RROW+Fz 6cgpuIa6H2CA1nA9amptvatpCMSZlTyH3cCk5zaeOxfWrBfzE7vhiYyAA+XDagf0 lqb/fCo9PNinAyNRTXucpvC1yOqjZwjeYpV48edhxHAR0gfau+oybnJb3/FCO5ab 30KQNMne6yqrxJi9j0ZORlTPcCIGCiJucLo0f9xiXHJMJvGFZErh8YMBJFP7OWCo Kc5H9FYMqAGOoRYLjA1qtZACE2kZ2CMTHaUWbSPxhswtkiC9bI7kqMYvJ2kPL1ny AB+vc27wtuhCoiRViwVKQsKLmc4l7+RPHM37yDBuyKnsB31EvvpZbod8c+hJe2Nh R/wolDxHItEwyafQ7zqb1YNLNiZ7olKDSTvP3jUuKeCBy7T5QWY2fmcv+njluhQ4 kq00cv16ofm4rYhCxQvZTTFEYfufac5l33Hvxla6RwV70/05up3W8W8bN/kM47wR HmLppDiXArhQC/D0TU7KZYNJcctNujeoC7B2JL34V2gVS9SCi8+vmus7nrzVTvoA TaCkTi9Egb/88RN8MbXRJ5/FKlWCrkejR5DCd8H6DXhcAcpLJ+7STtQp6QL93n2X l7G7oGjhKMxtCMi8CHJJ6UeNSN0ejOvhBFflcGOPJ9ngrjxt9g8TI6xBpLdvdcf4 zSY7GFN+vF3unp8+dRWs =TJSp -----END PGP SIGNATURE----- --R08HcacMCU64NfuRCB1qLukhRBdS8cF31--