public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* SystemTap for Android - patchset
       [not found] <f01a1f27-3cdb-61a4-cbdb-7bffd1032c8e@tu-dortmund.de>
@ 2016-07-01 16:15 ` Alexander Lochmann
  2016-07-01 16:56   ` David Smith
  2016-07-01 17:47   ` Josh Stone
  0 siblings, 2 replies; 20+ messages in thread
From: Alexander Lochmann @ 2016-07-01 16:15 UTC (permalink / raw)
  To: systemtap


[-- Attachment #1.1: Type: text/plain, Size: 1522 bytes --]


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ät 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: stap-android.patch --]
[-- Type: text/x-patch; name="stap-android.patch", Size: 39758 bytes --]

diff --git a/Makefile.in b/Makefile.in
index 41d5cb7..c1b6d28 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -537,6 +537,7 @@ prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python = @python@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 selinux_CFLAGS = @selinux_CFLAGS@
 selinux_LIBS = @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="/data/data/com.systemtap.android/stap/"
+OUTPUT_DIR="android_binaries"
+STAPIO_BIN="staprun/stapio"
+STAPRUN_BIN="staprun/staprun"
+COMPILER_PREFIX_LIST=("arm-none-linux-gnueabi" "arm-unknown-linux-gnueabi")
+
+
+function checkCompiler()
+{
+	for cur_compiler_prefix in ${COMPILER_PREFIX_LIST[@]}
+	do
+		RET=`${cur_compiler_prefix}-gcc --version 2>&1`
+		if [ $? -eq 0 ];
+		then
+			COMPILER_PREFIX=${cur_compiler_prefix}
+			return
+		fi
+	done;
+
+	echo "No suitable compiler found. Check your PATH" >&2
+	exit 1
+}
+
+checkCompiler
+
+ac_cv_with_java=no ac_cv_prog_have_jar=no ac_cv_prog_have_javac=no ac_cv_with_java=no ac_cv_file__usr_include_avahi_common=no ac_cv_file__usr_include_avahi_client=no ac_cv_file__usr_include_nspr=no ac_cv_file__usr_include_nspr4=no ac_cv_file__usr_include_nss=no ac_cv_file__usr_include_nss3=no ac_cv_func_malloc_0_nonnull=yes ./configure --prefix=$BUILD_PREFIX --host=$COMPILER_PREFIX --disable-translator --disable-docs --disable-refdocs  --disable-grapher --without-rpm --without-nss --with-android 
+
+if [ $? -ne 0 ]; then
+	echo "Error configuring the workspace" >&2
+	exit 1
+fi
+
+make 
+
+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");
+  
+  if (!s.pid_file.empty())
+    {
+	staprun_cmd.push_back("-M");
+	staprun_cmd.push_back(s.pid_file);
+    }
 
   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 {
 
 // 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:"
 
 extern struct option stap_long_options[];
 
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
 
+/* Define to 1 if you compile for Android. */
+#undef HAVE_ANDROID
+
 /* Define to 1 if you have the avahi libraries. */
 #undef HAVE_AVAHI
 
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='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1195,6 +1200,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -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=\$$ac_var
   # Remove trailing slashes.
@@ -1485,6 +1499,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     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=DIRECTORY
                           find elfutils source code in DIRECTORY
   --with-dyninst=DIRECTORY
@@ -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 == 721
 		       && LARGE_OFF_T % 2147483647 == 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 == 721
 		       && LARGE_OFF_T % 2147483647 == 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 == 721
 		       && LARGE_OFF_T % 2147483647 == 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 == 721
 		       && LARGE_OFF_T % 2147483647 == 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 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -10527,6 +10543,29 @@ else
 
 fi
 
+
+# Check whether --with-android was given.
+if test "${with_android+set}" = set; then :
+  withval=$with_android;
+fi
+
+if test "x$with_android" = "xyes"; then :
+  have_android=yes
+
+$as_echo "#define HAVE_ANDROID 1" >>confdefs.h
+
+else
+  have_android=no
+fi
+ if test "${have_android}" == "yes"; then
+  HAVE_ANDROID_TRUE=
+  HAVE_ANDROID_FALSE='#'
+else
+  HAVE_ANDROID_TRUE='#'
+  HAVE_ANDROID_FALSE=
+fi
+
+
 build_elfutils=no
 
 # 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 = no; then
   save_LIBS="$LIBS"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_getshdrstrndx in -lelf" >&5
+    if test "${have_android}" == "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
 
   LIBS="-lelf $LIBS"
 
+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=$LIBS
+LIBS="-lelf  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-    { { $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=yes
+else
+  ac_cv_lib_elf_elf_getshdrstrndx=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf_getshdrstrndx" >&5
+$as_echo "$ac_cv_lib_elf_elf_getshdrstrndx" >&6; }
+if test "x$ac_cv_lib_elf_elf_getshdrstrndx" = xyes; then :
+  staprun_LIBS="$staprun_LIBS -lelf"
+	     LIBS="$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
 
-  staprun_LIBS="$staprun_LIBS -lelf"
-  LIBS="$save_LIBS"
+  fi
 else
   # We built our own and staprun_LDFLAGS points at the install.
   staprun_LIBS="$staprun_LIBS -lelf"
@@ -11507,6 +11588,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 				--exec-prefix="$exec_prefix" \
 				--prefix="$prefix" \
 				--enable-dwz \
+				--host=${host_alias} \
 				${need_maintainer_option} \
 				CFLAGS="${CFLAGS/-Wall/} $gnu89_inline_flag -fexceptions" \
 				LDFLAGS="$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" = "xyes"],
       [AC_SUBST(python,[python3])],
       [AC_SUBST(python,[python])])
-      
+
+AC_ARG_WITH([android],
+  AS_HELP_STRING([--with-android],[]))
+AS_IF([test "x$with_android" = "xyes"],
+      [have_android=yes
+	AC_DEFINE([HAVE_ANDROID], [1], [Define to 1 if you compile for Android.])],
+      [have_android=no])
+AM_CONDITIONAL([HAVE_ANDROID], [test "${have_android}" == "yes"])
+
 dnl Handle elfutils.  If '--with-elfutils=DIR' wasn't specified, used
 dnl the system's elfutils.
 build_elfutils=no
@@ -471,10 +479,15 @@ AC_MSG_NOTICE([stap will link $stap_LIBS])
 if test $build_elfutils = no; then
   save_LIBS="$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="$staprun_LIBS -lelf"
-  LIBS="$save_LIBS"
+  if test "${have_android}" == "yes"; then
+	 AC_CHECK_LIB(elf,elf_getshdrstrndx,[],[])
+
+  else
+	  AC_CHECK_LIB(elf,elf_getshdrstrndx,
+	    [staprun_LIBS="$staprun_LIBS -lelf"
+	     LIBS="$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="$staprun_LIBS -lelf"
@@ -643,6 +656,7 @@ if test $build_elfutils = yes -a $enable_translator = yes; then
 				--exec-prefix="$exec_prefix" \
 				--prefix="$prefix" \
 				--enable-dwz \
+				--host=${host_alias} \
 				${need_maintainer_option} \
 				CFLAGS="${CFLAGS/-Wall/} $gnu89_inline_flag -fexceptions" \
 				LDFLAGS="$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 = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python = @python@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 selinux_CFLAGS = @selinux_CFLAGS@
 selinux_LIBS = @selinux_LIBS@
diff --git a/doc/SystemTap_Tapset_Reference/Makefile.in b/doc/SystemTap_Tapset_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 = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python = @python@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 selinux_CFLAGS = @selinux_CFLAGS@
 selinux_LIBS = @selinux_LIBS@
diff --git a/doc/SystemTap_Tapset_Reference/tapsets.pdf b/doc/SystemTap_Tapset_Reference/tapsets.pdf
deleted file mode 100644
index 9649e6d..0000000
Binary files a/doc/SystemTap_Tapset_Reference/tapsets.pdf and /dev/null differ
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 = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python = @python@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 selinux_CFLAGS = @selinux_CFLAGS@
 selinux_LIBS = @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
 
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 = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python = @python@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 selinux_CFLAGS = @selinux_CFLAGS@
 selinux_LIBS = @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
 
 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 = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python = @python@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 selinux_CFLAGS = @selinux_CFLAGS@
 selinux_LIBS = @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 = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python = @python@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 selinux_CFLAGS = @selinux_CFLAGS@
 selinux_LIBS = @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 <linux/version.h>
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
+#include <asm/unistd.h>
+#include <linux/sched.h>
+#include <asm-generic/syscall.h>
+#else
 #include <asm/syscall.h>
-
+#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
 
+#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_
 
@@ -110,7 +109,14 @@
 #ifdef STAPCONF_ASM_SYSCALL_H
 
 /* If the system has asm/syscall.h, use defines from it. */
+#include <linux/version.h>
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
+#include <asm/unistd.h>
+#include <linux/sched.h>
+#include <asm-generic/syscall.h>
+#else
 #include <asm/syscall.h>
+#endif
 
 #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 = 5;
   module_name = "stap_" + lex_cast(getpid());
   stapconf_name = "stapconf_" + lex_cast(getpid()) + ".h";
+  pid_file = "";
   output_file = ""; // -o FILE
   tmpdir_opt_set = false;
   monitor = false;
@@ -165,6 +166,7 @@ systemtap_session::systemtap_session ():
   try_server_status = try_server_unset;
   use_remote_prefix = false;
   systemtap_v_check = false;
+  excl_include_path = false;
   download_dbinfo = 0;
   suppress_handler_errors = false;
   native_build = true; // presumed
@@ -319,6 +321,7 @@ systemtap_session::systemtap_session (const systemtap_session& other,
   last_pass = other.last_pass;
   module_name = other.module_name;
   stapconf_name = other.stapconf_name;
+  pid_file = other.pid_file;
   output_file = other.output_file; // XXX how should multiple remotes work?
   tmpdir_opt_set = false;
   monitor = other.monitor;
@@ -568,7 +571,8 @@ systemtap_session::usage (int exitcode)
   for (unsigned i=0; i<include_path.size(); i++)
     cout << "              " << include_path[i].c_str() << endl;
   cout
-    << _F("   -D NM=VAL  emit macro definition into generated C code\n"
+	<< "   -K DIR     look *only* in DIR for .stp script files - the default directories or any other ones given by -I are ignored" << (excl_include_path ? " [set]" : "") << endl;    
+  cout << _F("   -D NM=VAL  emit macro definition into generated C code\n"
     "   -B NM=VAL  pass option to kbuild make\n"
     "   --modinfo NM=VAL\n"
     "              include a MODULE_INFO(NM,VAL) in the generated C code\n"
@@ -582,6 +586,7 @@ systemtap_session::usage (int exitcode)
     "   -a ARCH    cross-compile to given architecture, instead of %s\n"
     "   -m MODULE  set probe module name, instead of \n"
     "              %s\n"
+    "   -U PIDFILE Create a pid file while running\n"
     "   -o FILE    send script output to file, instead of stdout. This supports\n" 
     "              strftime(3) formats for FILE\n"
     "   -E SCRIPT  run the SCRIPT in addition to the main script specified\n"
@@ -687,6 +692,7 @@ systemtap_session::usage (int exitcode)
 int
 systemtap_session::parse_cmdline (int argc, char * const argv [])
 {
+  bool excl_executed = false;
   client_options_disallowed_for_unprivileged = "";
   struct rlimit our_rlimit;
   while (true)
@@ -746,6 +752,12 @@ systemtap_session::parse_cmdline (int argc, char * const argv [])
 	  server_args.push_back (string ("-") + (char)grc + optarg);
           break;
 
+	 case 'K':
+	  if (excl_executed)
+	    break;
+	  include_path.clear();
+	  excl_include_path = true;
+
         case 'I':
           assert(optarg);
 	  if (client_options)
@@ -753,6 +765,8 @@ systemtap_session::parse_cmdline (int argc, char * const argv [])
 	  if (include_arg_start == -1)
 	    include_arg_start = include_path.size ();
           include_path.push_back (string (optarg));
+	  if (excl_include_path)
+	    excl_executed = true;
           break;
 
         case 'd':
@@ -786,6 +800,11 @@ systemtap_session::parse_cmdline (int argc, char * const argv [])
           have_script = true;
           break;
 
+	case 'M':
+	  server_args.push_back(string("-") + (char)grc + optarg);
+	  pid_file = string (optarg);
+	  break;
+
         case 'E':
           assert(optarg);
           server_args.push_back (string("-") + (char)grc + optarg);
@@ -1502,6 +1521,10 @@ systemtap_session::parse_cmdline (int argc, char * const argv [])
           break;
         }
     }
+  /* for debug purpose
+  clog << "Includepath:" << endl;
+  for (unsigned i=0; i<include_path.size(); i++)
+	    clog << "              " << include_path[i] << endl;*/
 
   return 0;
 }
diff --git a/session.h b/session.h
index 8c8eb4c..ef8994d 100644
--- a/session.h
+++ b/session.h
@@ -185,6 +185,7 @@ public:
   std::string module_name;
   const std::string module_filename() const;
   std::string stapconf_name;
+  std::string pid_file;
   std::string output_file;
   std::string size_option;
   std::string cmd;
@@ -216,6 +217,7 @@ public:
   privilege_t privilege;
   bool privilege_set;
   bool systemtap_v_check;
+  bool excl_include_path;
   bool tmpdir_opt_set;
   bool monitor;
   int monitor_interval;
diff --git a/stapdyn/Makefile.in b/stapdyn/Makefile.in
index 76cbb23..6350767 100644
--- a/stapdyn/Makefile.in
+++ b/stapdyn/Makefile.in
@@ -373,6 +373,7 @@ prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python = @python@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 selinux_CFLAGS = @selinux_CFLAGS@
 selinux_LIBS = @selinux_LIBS@
diff --git a/staprun/Makefile.am b/staprun/Makefile.am
index 63d4088..c1addd0 100644
--- a/staprun/Makefile.am
+++ b/staprun/Makefile.am
@@ -29,6 +29,9 @@ staprun_CXXFLAGS = $(AM_CXXFLAGS) -DSINGLE_THREADED
 staprun_CPPFLAGS = $(AM_CPPFLAGS)
 staprun_LDADD = libstrfloctime.a $(staprun_LIBS)
 staprun_LDFLAGS =  $(AM_LDFLAGS)
+if HAVE_ANDROID
+staprun_LDFLAGS += -static
+endif
 if BUILD_ELFUTILS
 staprun_CPPFLAGS += -I../include-elfutils
 staprun_LDFLAGS += -L../lib-elfutils -Wl,-rpath-link,lib-elfutils \
@@ -47,6 +50,9 @@ AM_CFLAGS += $(jsonc_LIBS) $(ncurses_LIBS)
 endif
 
 stapio_SOURCES = stapio.c mainloop.c common.c ctl.c relay.c relay_old.c monitor.c
+if HAVE_ANDROID
+stapio_LDFLAGS = -static
+endif
 stapio_LDADD = libstrfloctime.a -lpthread
 
 man_MANS = staprun.8
@@ -54,11 +60,17 @@ man_MANS = staprun.8
 stap_merge_SOURCES = stap_merge.c
 stap_merge_CFLAGS = $(AM_CFLAGS)
 stap_merge_LDFLAGS = $(AM_LDFLAGS)
+if HAVE_ANDROID
+stap_merge_LDFLAGS += -static
+endif
 stap_merge_LDADD =
 
 stapsh_SOURCES = stapsh.c
 stapsh_CFLAGS = $(AM_CFLAGS)
 stapsh_LDFLAGS = $(AM_LDFLAGS)
+if HAVE_ANDROID
+stapsh_LDFLAGS += -static
+endif
 stapsh_LDADD =
 
 BUILT_SOURCES =
diff --git a/staprun/Makefile.in b/staprun/Makefile.in
index 313948c..ea5ffd7 100644
--- a/staprun/Makefile.in
+++ b/staprun/Makefile.in
@@ -94,15 +94,18 @@ host_triplet = @host@
 target_triplet = @target@
 bin_PROGRAMS = staprun$(EXEEXT) stap-merge$(EXEEXT) stapsh$(EXEEXT)
 pkglibexec_PROGRAMS = stapio$(EXEEXT)
-@BUILD_ELFUTILS_TRUE@am__append_1 = -I../include-elfutils
-@BUILD_ELFUTILS_TRUE@am__append_2 = -L../lib-elfutils -Wl,-rpath-link,lib-elfutils \
+@HAVE_ANDROID_TRUE@am__append_1 = -static
+@BUILD_ELFUTILS_TRUE@am__append_2 = -I../include-elfutils
+@BUILD_ELFUTILS_TRUE@am__append_3 = -L../lib-elfutils -Wl,-rpath-link,lib-elfutils \
 @BUILD_ELFUTILS_TRUE@		-Wl,--enable-new-dtags,-rpath,$(pkglibdir)
 
-@HAVE_NSS_TRUE@am__append_3 = modverify.c ../nsscommon.cxx
-@HAVE_NSS_TRUE@am__append_4 = $(nss_CFLAGS)
+@HAVE_NSS_TRUE@am__append_4 = modverify.c ../nsscommon.cxx
 @HAVE_NSS_TRUE@am__append_5 = $(nss_CFLAGS)
-@HAVE_NSS_TRUE@am__append_6 = $(nss_LIBS)
-@HAVE_MONITOR_LIBS_TRUE@am__append_7 = $(jsonc_LIBS) $(ncurses_LIBS)
+@HAVE_NSS_TRUE@am__append_6 = $(nss_CFLAGS)
+@HAVE_NSS_TRUE@am__append_7 = $(nss_LIBS)
+@HAVE_MONITOR_LIBS_TRUE@am__append_8 = $(jsonc_LIBS) $(ncurses_LIBS)
+@HAVE_ANDROID_TRUE@am__append_9 = -static
+@HAVE_ANDROID_TRUE@am__append_10 = -static
 subdir = staprun
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
@@ -142,6 +145,8 @@ am_stapio_OBJECTS = stapio.$(OBJEXT) mainloop.$(OBJEXT) \
 	relay_old.$(OBJEXT) monitor.$(OBJEXT)
 stapio_OBJECTS = $(am_stapio_OBJECTS)
 stapio_DEPENDENCIES = libstrfloctime.a
+stapio_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(stapio_LDFLAGS) \
+	$(LDFLAGS) -o $@
 am__dirstamp = $(am__leading_dot)dirstamp
 @HAVE_NSS_TRUE@am__objects_1 = staprun-modverify.$(OBJEXT) \
 @HAVE_NSS_TRUE@	../staprun-nsscommon.$(OBJEXT)
@@ -413,6 +418,7 @@ prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python = @python@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 selinux_CFLAGS = @selinux_CFLAGS@
 selinux_LIBS = @selinux_LIBS@
@@ -435,7 +441,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = subdir-objects
 AM_CFLAGS = -Wall -Wextra -Werror -Wunused -W -Wformat=2 @PIECFLAGS@ \
-	$(am__append_7)
+	$(am__append_8)
 AM_CXXFLAGS = -Wall -Wextra -Werror -Wunused -W -Wformat=2 \
 	@PIECXXFLAGS@ $(am__empty)
 AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir)/../includes \
@@ -451,22 +457,23 @@ noinst_LIBRARIES = libstrfloctime.a
 libstrfloctime_a_SOURCES = strfloctime.c
 libstrfloctime_a_CFLAGS = $(AM_CFLAGS) -Wno-format-nonliteral
 staprun_SOURCES = staprun.c staprun_funcs.c ctl.c common.c \
-	../privilege.cxx ../util.cxx $(am__append_3)
-staprun_CFLAGS = $(AM_CFLAGS) -DSINGLE_THREADED $(am__append_4)
-staprun_CXXFLAGS = $(AM_CXXFLAGS) -DSINGLE_THREADED $(am__append_5)
-staprun_CPPFLAGS = $(AM_CPPFLAGS) $(am__append_1)
-staprun_LDADD = libstrfloctime.a $(staprun_LIBS) $(am__append_6)
-staprun_LDFLAGS = $(AM_LDFLAGS) $(am__append_2)
+	../privilege.cxx ../util.cxx $(am__append_4)
+staprun_CFLAGS = $(AM_CFLAGS) -DSINGLE_THREADED $(am__append_5)
+staprun_CXXFLAGS = $(AM_CXXFLAGS) -DSINGLE_THREADED $(am__append_6)
+staprun_CPPFLAGS = $(AM_CPPFLAGS) $(am__append_2)
+staprun_LDADD = libstrfloctime.a $(staprun_LIBS) $(am__append_7)
+staprun_LDFLAGS = $(AM_LDFLAGS) $(am__append_1) $(am__append_3)
 stapio_SOURCES = stapio.c mainloop.c common.c ctl.c relay.c relay_old.c monitor.c
+@HAVE_ANDROID_TRUE@stapio_LDFLAGS = -static
 stapio_LDADD = libstrfloctime.a -lpthread
 man_MANS = staprun.8
 stap_merge_SOURCES = stap_merge.c
 stap_merge_CFLAGS = $(AM_CFLAGS)
-stap_merge_LDFLAGS = $(AM_LDFLAGS)
+stap_merge_LDFLAGS = $(AM_LDFLAGS) $(am__append_9)
 stap_merge_LDADD = 
 stapsh_SOURCES = stapsh.c
 stapsh_CFLAGS = $(AM_CFLAGS)
-stapsh_LDFLAGS = $(AM_LDFLAGS)
+stapsh_LDFLAGS = $(AM_LDFLAGS) $(am__append_10)
 stapsh_LDADD = 
 
 # Arrange for the top-level git_version.h to be regenerated at every "make".
@@ -607,7 +614,7 @@ stap-merge$(EXEEXT): $(stap_merge_OBJECTS) $(stap_merge_DEPENDENCIES) $(EXTRA_st
 
 stapio$(EXEEXT): $(stapio_OBJECTS) $(stapio_DEPENDENCIES) $(EXTRA_stapio_DEPENDENCIES) 
 	@rm -f stapio$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(stapio_OBJECTS) $(stapio_LDADD) $(LIBS)
+	$(AM_V_CCLD)$(stapio_LINK) $(stapio_OBJECTS) $(stapio_LDADD) $(LIBS)
 ../$(am__dirstamp):
 	@$(MKDIR_P) ..
 	@: > ../$(am__dirstamp)
diff --git a/staprun/common.c b/staprun/common.c
index f16e56a..7fbfa30 100644
--- a/staprun/common.c
+++ b/staprun/common.c
@@ -35,6 +35,7 @@ int target_namespaces_pid;
 unsigned int buffer_size;
 unsigned int reader_timeout_ms;
 char *target_cmd;
+char *pidfile_name;
 char *outfile_name;
 int rename_mod;
 int attach_mod;
@@ -120,6 +121,7 @@ void parse_args(int argc, char **argv)
 	buffer_size = 0;
         reader_timeout_ms = 0;
 	target_cmd = NULL;
+	pidfile_name = NULL;
 	outfile_name = NULL;
 	rename_mod = 0;
 	attach_mod = 0;
@@ -138,7 +140,7 @@ void parse_args(int argc, char **argv)
         color_errors = isatty(STDERR_FILENO)
                 && strcmp(getenv("TERM") ?: "notdumb", "dumb");
 
-	while ((c = getopt(argc, argv, "ALu::vhb:t:dc:o:x:N:S:DwRr:VT:C:M:"
+	while ((c = getopt(argc, argv, "ALu::vhb:t:dc:o:x:N:S:DwRr:VT:M:C:U:"
 #ifdef HAVE_OPENAT
                            "F:"
 #endif
@@ -181,6 +183,9 @@ void parse_args(int argc, char **argv)
 		case 'c':
 			target_cmd = optarg;
 			break;
+		case 'U':
+			pidfile_name = optarg;
+			break;
 		case 'o':
 			outfile_name = optarg;
 			break;
@@ -340,7 +345,7 @@ void parse_args(int argc, char **argv)
 void usage(char *prog, int rc)
 {
 	printf(_("\n%s [-v] [-w] [-V] [-h] [-u] [-c cmd ] [-x pid] [-u user] [-A|-L|-d] [-C WHEN]\n"
-                "\t[-b bufsize] [-R] [-r N:URI] [-o FILE [-D] [-S size[,N]]] MODULE [module-options]\n"), prog);
+                "\t[-b bufsize] [-R] [-r N:URI] [-o FILE [-D] [-S size[,N]]] [-U PID_FILE] MODULE [module-options]\n"), prog);
 	printf(_("-v              Increase verbosity.\n"
 	"-V              Print version number and exit.\n"
 	"-h              Print this help text and exit.\n"
@@ -350,7 +355,8 @@ void usage(char *prog, int rc)
 	"                exit when it does.  The '_stp_target' variable\n"
 	"                will contain the pid for the command.\n"
 	"-x pid          Sets the '_stp_target' variable to pid.\n"
-  "-N pid          Sets the '_stp_namespaces_pid' variable to pid.\n"
+	"-U PIDFILE	 Create a pid file while running\n"
+  	"-N pid          Sets the '_stp_namespaces_pid' variable to pid.\n"
 	"-o FILE         Send output to FILE. This supports strftime(3)\n"
 	"                formats for FILE.\n"
 	"-b buffer size  The systemtap module specifies a buffer size.\n"
@@ -751,6 +757,37 @@ char *parse_stap_color(const char *type)
 	return NULL; /* key not found */
 }
 
+void create_pidfile(const char *pidfile_name)
+{
+	int fd = 0, printed = 0;
+	char pid_text[15];
+	pid_t pid = getpid();
+	
+	fd = open(pidfile_name,O_CREAT|O_WRONLY|O_TRUNC,0644);
+	if (fd < 0)
+	{
+		err("Could not open pidfile:%s\n",strerror(errno));
+		exit(1);
+		return;
+	}
+
+	printed = sprintf((char*)&pid_text,"%d\n",pid);
+	if (write(fd,&pid_text,printed) < 0)
+	{
+		err("Could not write pid to pidfile:%s\n",strerror(errno));
+		exit(1);
+	}
+	close(fd);
+}
+
+void delete_pidfile(const char *pidfile_name)
+{
+	if (unlink(pidfile_name) < 0)
+	{
+		err("Could not delete pidfile:%s\n",strerror(errno));
+	}
+}
+
 void
 closefrom(int lowfd)
 {
diff --git a/staprun/mainloop.c b/staprun/mainloop.c
index 82c0c74..006783f 100644
--- a/staprun/mainloop.c
+++ b/staprun/mainloop.c
@@ -20,6 +20,12 @@
 
 #define WORKAROUND_BZ467568 1  /* PR 6964; XXX: autoconf when able */
 
+#ifdef HAVE_ANDROID
+#define SYSTEM_SHELL "/system/bin/sh"
+#else
+#define SYSTEM_SHELL "sh"
+#endif
+
 
 /* globals */
 int ncpus;
@@ -548,6 +554,9 @@ void cleanup_and_exit(int detach, int rc)
   sa.sa_handler = SIG_DFL;
   sigaction(SIGCHLD, &sa, NULL);
 
+  if (pidfile_name)
+     delete_pidfile(pidfile_name);
+
   pid = fork();
   if (pid < 0) {
           _perr("fork");
@@ -564,7 +573,7 @@ void cleanup_and_exit(int detach, int rc)
                               : color_mode == color_auto ? "auto" : "never",
                             modname);
           if (rc >= 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);
 
+	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);
 	}
 
+	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();
 
 		if (insert_stap_module(& user_credentials) < 0) {
+#ifdef HAVE_ANDROID
 			if(!rename_mod && errno == EEXIST)
 				err("Rerun with staprun option '-R' to rename this module.\n");
+#endif
 			return -1;
 		}
 		rc = 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 <pwd.h>
 #include <assert.h>
 
+#ifndef HAVE_ANDROID
 /* The module-renaming facility only works with new enough
    elfutils: 0.142+. */
 #include <libelf.h>
 #include <gelf.h>
+#endif
 
 #include <math.h>
 
@@ -198,6 +200,7 @@ int insert_module(
 	return 0;
 }
 
+#ifndef HAVE_ANDROID
 static Elf_Scn *
 find_section_in_module(const void* module_file, const __off_t st_size, const 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 */
 
 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; 
+#endif /* HAVE_ANDROID */
 }
 
 
@@ -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 required to run this
+     module. However, we know that it has been correctly signed (we only check privilege
+     credentials for correctly signed modules). It is therefore either
+       a) a dual-privilege-level era module compiled with stapusr privileges 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 against the user's
+     actual privilege level.
+  */
+  if (verbose >= 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 = 0;
   Elf_Data *data = 0;
   GElf_Shdr shdr;
@@ -658,6 +687,7 @@ static privilege_t get_module_required_credentials (
 
   /* ALl is ok. Return the extracted privilege data. */
   return privilege;
+#endif /* HAVE_ANDROID */
 }
 
 /*
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 <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE >= 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), 1000ULL)
 #endif
+#endif
 
 /* Kernels before 2.6.37 have cputime_to_msecs, but not usecs. */
 #elif defined(cputime_to_msecs)


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-01 16:15 ` SystemTap for Android - patchset Alexander Lochmann
@ 2016-07-01 16:56   ` David Smith
  2016-07-01 17:47   ` Josh Stone
  1 sibling, 0 replies; 20+ messages in thread
From: David Smith @ 2016-07-01 16:56 UTC (permalink / raw)
  To: Alexander Lochmann, systemtap

On 07/01/2016 11:15 AM, Alexander Lochmann wrote:
> 
> 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.

Alex,

Thanks for working on this and sending us the patch. Is there any way to
separate out the changes into one logical change per patch? Combining
all the changes into one patch makes things quite hard to review.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-01 16:15 ` SystemTap for Android - patchset Alexander Lochmann
  2016-07-01 16:56   ` David Smith
@ 2016-07-01 17:47   ` Josh Stone
  2016-07-06 12:29     ` Alexander Lochmann
  1 sibling, 1 reply; 20+ messages in thread
From: Josh Stone @ 2016-07-01 17:47 UTC (permalink / raw)
  To: Alexander Lochmann, systemtap

On 07/01/2016 09:15 AM, Alexander Lochmann wrote:
> 
> 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

Can you explain why you need this?

One can already override the primary tapset directory with the
environment SYSTEMTAP_TAPSET.  Ignoring -I options also seems
questionable, especially since this depends on the order -- it looks
like -I specified after -K will still be used, while those before will
be ignored.

> - Support for a pid file in staprun, parameter is -U

And you added -M on stap itself.  I don't understand either of those
letter choices.

The functionality itself is not too controversial, but I'd still like to
see your justification in the commit log, and some examples how this is
used in Android.

> 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.

That commit is "man stap: fixed typos".  Did you mean something else?

> The patch contains two bugfixes for the SystemTap as well.
> Unfortunately, I failed to extract those fixes properly. :(

As David said, it would help us a lot if you separated each of these
changes into distinct commits.  If you have the changes in a working git
directory, "git add -p" can help you mark specific changes to be
committed.  "git-gui" is also pretty good for selecting hunks.  Feel
free to ask for help on #systemtap if you still have trouble.

> 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ät 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
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-01 17:47   ` Josh Stone
@ 2016-07-06 12:29     ` Alexander Lochmann
  2016-07-06 16:42       ` Frank Ch. Eigler
                         ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Alexander Lochmann @ 2016-07-06 12:29 UTC (permalink / raw)
  To: Josh Stone, systemtap


[-- Attachment #1.1.1: Type: text/plain, Size: 4182 bytes --]

So. Let me start.
First of all, I extracted the patches properly, and attached the files.
(Btw, I found a third bug. :) )
FYI, I just fixed the bugs for the kernel versions I'm dealing with,
because I don't know which other versions are affected as well.

On 01.07.2016 19:46, Josh Stone wrote:
> On 07/01/2016 09:15 AM, Alexander Lochmann wrote:
>>
>> 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
> 
> Can you explain why you need this?
> 
> One can already override the primary tapset directory with the
> environment SYSTEMTAP_TAPSET.  Ignoring -I options also seems
> questionable, especially since this depends on the order -- it looks
> like -I specified after -K will still be used, while those before will
> be ignored.
> 
Honestly? I don't know. :D I had some trouble with SystemTap looking for
tapsets systemwide, which made me write that patch/fix. It's been a long
time since I wrote it. Anyway, I tried your proposed solution, and it
works. I'll adapt my build script to use the enviroment variable.
You can skip that part of the patch if you want.
>> - Support for a pid file in staprun, parameter is -U
> 
> And you added -M on stap itself.  I don't understand either of those
> letter choices.
Did I? It might be possible that I want be able to pass the argument to
staprun.

I chose the letters randomly. For me, it doesn't matter. I just need an
argument to tell staprun to create a pid file. :)
> 
> The functionality itself is not too controversial, but I'd still like to
> see your justification in the commit log, and some examples how this is
> used in Android.
Yeah, sure. Since I run stap on Android, I have a background service,
which periodically checks if every single stap instance is still
running. Yes, it might be possible having more than one stap script
running. :)
Moreover, if I start it more than once, I want to be able to kill
specific instance. For that I need its process id.

- Alex
> 
>> 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.
> 
> That commit is "man stap: fixed typos".  Did you mean something else?
> 
>> The patch contains two bugfixes for the SystemTap as well.
>> Unfortunately, I failed to extract those fixes properly. :(
> 
> As David said, it would help us a lot if you separated each of these
> changes into distinct commits.  If you have the changes in a working git
> directory, "git add -p" can help you mark specific changes to be
> committed.  "git-gui" is also pretty good for selecting hunks.  Feel
> free to ask for help on #systemtap if you still have trouble.
> 
>> 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ät 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
>>
> 


-- 
Technische Universität 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-Definition-of-cputime_to_usecs-in-Linux-kernel-3.0-i.patch --]
[-- Type: text/x-patch; name="0001-Definition-of-cputime_to_usecs-in-Linux-kernel-3.0-i.patch", Size: 1237 bytes --]

From f0ca40f9aaa5ba9c39ffcefc39e450443603db44 Mon Sep 17 00:00:00 2001
From: Alexander Lochmann <alexander.lochmann@tu-dortmund.de>
Date: Wed, 6 Jul 2016 13:55:07 +0200
Subject: [PATCH 1/3] Definition of cputime_to_usecs in Linux kernel 3.0 is
 broken

The above macro is definined with a semicolon at the end. Using it as
a function argument leads to a compiler error. Hence, the necessary braces
have been added.
---
 tapset/linux/task_time.stp | 4 ++++
 1 file changed, 4 insertions(+)

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 <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE >= 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), 1000ULL)
 #endif
+#endif
 
 /* Kernels before 2.6.37 have cputime_to_msecs, but not usecs. */
 #elif defined(cputime_to_msecs)
-- 
2.7.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.3: 0002-The-syscall-defines-were-not-compatible-with-older-k.patch --]
[-- Type: text/x-patch; name="0002-The-syscall-defines-were-not-compatible-with-older-k.patch", Size: 2599 bytes --]

From 8f3817586f87cb65bc3b8b320ad8252a6a11f7e5 Mon Sep 17 00:00:00 2001
From: Alexander Lochmann <alexander.lochmann@tu-dortmund.de>
Date: Wed, 6 Jul 2016 13:59:23 +0200
Subject: [PATCH 2/3] The syscall defines were not compatible with older
 kernels, namely 3.0.x

Older kernels, at least the 3.0.x, define their syscalls in different files.
The stap runtime has to include those file properly. Moreover, for pre-uprobe kernels
no syscall file has been included at all. This job is normally done by task_finder.c.
The task_finder_stubs.c has been extended by the needed include directive.
---
 runtime/linux/autoconf-asm-syscall.c | 8 +++++++-
 runtime/linux/task_finder_stubs.c    | 1 +
 runtime/syscall.h                    | 8 +++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

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 <linux/version.h>
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
+#include <asm/unistd.h>
+#include <linux/sched.h>
+#include <asm-generic/syscall.h>
+#else
 #include <asm/syscall.h>
-
+#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
 
+#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_
 
@@ -110,7 +109,14 @@
 #ifdef STAPCONF_ASM_SYSCALL_H
 
 /* If the system has asm/syscall.h, use defines from it. */
+#include <linux/version.h>
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
+#include <asm/unistd.h>
+#include <linux/sched.h>
+#include <asm-generic/syscall.h>
+#else
 #include <asm/syscall.h>
+#endif
 
 #if defined(__arm__)
 /* The syscall_get_nr() function on 3.17.1-302.fc21.armv7hl always
-- 
2.7.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.4: 0003-Linux-kernel-3.4-does-not-define-PR_SET_MM_ARG_START.patch --]
[-- Type: text/x-patch; name="0003-Linux-kernel-3.4-does-not-define-PR_SET_MM_ARG_START.patch", Size: 1067 bytes --]

From 4c6cb3c2d2ce969a16fe91b2a06ed78d68b33644 Mon Sep 17 00:00:00 2001
From: Alexander Lochmann <alexander.lochmann@tu-dortmund.de>
Date: Tue, 5 Jul 2016 19:05:06 +0200
Subject: [PATCH 3/3] Linux kernel 3.4 does not define PR_SET_MM_ARG_START.
 Used KERNEL_VERSION to permit compilatioon of those macros

---
 tapset/linux/aux_syscalls.stp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tapset/linux/aux_syscalls.stp b/tapset/linux/aux_syscalls.stp
index bec71c5..88db0b7 100644
--- a/tapset/linux/aux_syscalls.stp
+++ b/tapset/linux/aux_syscalls.stp
@@ -4599,12 +4599,14 @@ static const _stp_val_array const _stp_prctl_mm_option_list[] = {
 	V(PR_SET_MM_START_STACK),
 	V(PR_SET_MM_START_BRK),
 	V(PR_SET_MM_BRK),
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,200) && LINUX_VERSION_CODE <= KERNEL_VERSION(3,4,0)
 	V(PR_SET_MM_ARG_START),
 	V(PR_SET_MM_ARG_END),
 	V(PR_SET_MM_ENV_START),
 	V(PR_SET_MM_ENV_END),
 	V(PR_SET_MM_AUXV),
 	V(PR_SET_MM_EXE_FILE),
+#endif
 #ifdef PR_SET_MM_MAP
 	V(PR_SET_MM_MAP),
 #endif
-- 
2.7.4


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-06 12:29     ` Alexander Lochmann
@ 2016-07-06 16:42       ` Frank Ch. Eigler
  2016-07-06 20:05         ` Alexander Lochmann
  2016-07-07 16:00       ` David Smith
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 20+ messages in thread
From: Frank Ch. Eigler @ 2016-07-06 16:42 UTC (permalink / raw)
  To: Alexander Lochmann; +Cc: Josh Stone, systemtap

Alexander Lochmann <alexander.lochmann@tu-dortmund.de> writes:

> [...]
> I chose the letters randomly. For me, it doesn't matter. I just need an
> argument to tell staprun to create a pid file. :)

Would it be enough for staprun to have that pid option?
That would mean the stap script would have to be compiled
through to -p4 only, then staprun invoked manually.

> Yeah, sure. Since I run stap on Android, I have a background service,
> which periodically checks if every single stap instance is still
> running. Yes, it might be possible having more than one stap script
> running. :) [...]

Since your background service is already custom, maybe a custom shell
script wrapper like this could serve your purposes without having to
change staprun/stap at all:

% cat pidwrapper
#! /bin/sh
pidfile="$1"; shift
program="$1"; shift
echo $$ > $pidfile
exec $program ${1+$@}  # exec to preserve $$ pid

and then you invoke staprun via:

% sh pidwrapper /path/to/this.pid staprun foo bar baz


- FChE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-06 16:42       ` Frank Ch. Eigler
@ 2016-07-06 20:05         ` Alexander Lochmann
  2016-07-06 20:15           ` Frank Ch. Eigler
  0 siblings, 1 reply; 20+ messages in thread
From: Alexander Lochmann @ 2016-07-06 20:05 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: Josh Stone, systemtap


[-- Attachment #1.1: Type: text/plain, Size: 1725 bytes --]

On 06.07.2016 18:42, Frank Ch. Eigler wrote:
> Alexander Lochmann <alexander.lochmann@tu-dortmund.de> writes:
> 
>> [...]
>> I chose the letters randomly. For me, it doesn't matter. I just need an
>> argument to tell staprun to create a pid file. :)
> 
> Would it be enough for staprun to have that pid option?
> That would mean the stap script would have to be compiled
> through to -p4 only, then staprun invoked manually.
> 
Yes, that should do.
>> Yeah, sure. Since I run stap on Android, I have a background service,
>> which periodically checks if every single stap instance is still
>> running. Yes, it might be possible having more than one stap script
>> running. :) [...]
> 
> Since your background service is already custom, maybe a custom shell
> script wrapper like this could serve your purposes without having to
> change staprun/stap at all:
> 
> % cat pidwrapper
> #! /bin/sh
> pidfile="$1"; shift
> program="$1"; shift
> echo $$ > $pidfile
> exec $program ${1+$@}  # exec to preserve $$ pid
> 
> and then you invoke staprun via:
> 
> % sh pidwrapper /path/to/this.pid staprun foo bar baz
> 
> 
That would be a nice workaround. I went through the source code. The
commandline option is used by stapio. Stapio creates the pidfile. If I
send a SIGKILL (or was it a SIGTERM? what so ever) to staprun, stap and
the module won't be shutdown properly. Hence, I have to send the signal
to stapio.

- Alex
> - FChE
> 


-- 
Technische Universität 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-06 20:05         ` Alexander Lochmann
@ 2016-07-06 20:15           ` Frank Ch. Eigler
  2016-07-06 20:27             ` Alexander Lochmann
  0 siblings, 1 reply; 20+ messages in thread
From: Frank Ch. Eigler @ 2016-07-06 20:15 UTC (permalink / raw)
  To: Alexander Lochmann; +Cc: Josh Stone, systemtap

Hi -

On Wed, Jul 06, 2016 at 10:05:23PM +0200, Alexander Lochmann wrote:
> [...]
> > % sh pidwrapper /path/to/this.pid staprun foo bar baz
> > 
> That would be a nice workaround. I went through the source code. The
> commandline option is used by stapio. Stapio creates the pidfile. If I
> send a SIGKILL (or was it a SIGTERM? what so ever) to staprun, stap and
> the module won't be shutdown properly. Hence, I have to send the signal
> to stapio.

Since staprun exec's stapio, the latter will also share the same pid.
So this wrapper would work, whichever process happens to be running at
the moment.  (Send SIGTERM or SIGINT for a clean shutdown.)


- FChE

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-06 20:15           ` Frank Ch. Eigler
@ 2016-07-06 20:27             ` Alexander Lochmann
  0 siblings, 0 replies; 20+ messages in thread
From: Alexander Lochmann @ 2016-07-06 20:27 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: Josh Stone, systemtap


[-- Attachment #1.1: Type: text/plain, Size: 1435 bytes --]

On 06.07.2016 22:15, Frank Ch. Eigler wrote:
> Hi -
> 
> On Wed, Jul 06, 2016 at 10:05:23PM +0200, Alexander Lochmann wrote:
>> [...]
>>> % sh pidwrapper /path/to/this.pid staprun foo bar baz
>>>
>> That would be a nice workaround. I went through the source code. The
>> commandline option is used by stapio. Stapio creates the pidfile. If I
>> send a SIGKILL (or was it a SIGTERM? what so ever) to staprun, stap and
>> the module won't be shutdown properly. Hence, I have to send the signal
>> to stapio.
> 
> Since staprun exec's stapio, the latter will also share the same pid.
> So this wrapper would work, whichever process happens to be running at
> the moment.  (Send SIGTERM or SIGINT for a clean shutdown.)
> 
Indeed... strange. If I remember it correctly, I would say that wasn't
the case in that past. But git blame says something different.
Thus, I suppose it was my "fault". I thing I simply misinterpreted my
observations with "ps aux" back in that days. Anyway, I'll try your bash
wrapper. :-)

Do you have any concerns about the rest of my Android patch?
Namely the build script and those ifdefs in staprun.c.

- Alex
> 
> - FChE
> 


-- 
Technische Universität 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-06 12:29     ` Alexander Lochmann
  2016-07-06 16:42       ` Frank Ch. Eigler
@ 2016-07-07 16:00       ` David Smith
  2016-07-07 16:06       ` David Smith
  2016-07-07 18:47       ` David Smith
  3 siblings, 0 replies; 20+ messages in thread
From: David Smith @ 2016-07-07 16:00 UTC (permalink / raw)
  To: Alexander Lochmann, Josh Stone, systemtap

On 07/06/2016 07:29 AM, Alexander Lochmann wrote:
> So. Let me start.
> First of all, I extracted the patches properly, and attached the files.
> (Btw, I found a third bug. :) )
> FYI, I just fixed the bugs for the kernel versions I'm dealing with,
> because I don't know which other versions are affected as well.

I checked in a tweaked version of your "[PATCH 3/3] Linux kernel 3.4
does not define PR_SET_MM_ARG_START" patch as commit 0920f8c. Instead of
checking for kernel version, I checked to see if those defines were
actually defined.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-06 12:29     ` Alexander Lochmann
  2016-07-06 16:42       ` Frank Ch. Eigler
  2016-07-07 16:00       ` David Smith
@ 2016-07-07 16:06       ` David Smith
  2016-07-07 16:23         ` Alexander Lochmann
  2016-07-07 18:47       ` David Smith
  3 siblings, 1 reply; 20+ messages in thread
From: David Smith @ 2016-07-07 16:06 UTC (permalink / raw)
  To: Alexander Lochmann, Josh Stone, systemtap

On 07/06/2016 07:29 AM, Alexander Lochmann wrote:
> So. Let me start.
> First of all, I extracted the patches properly, and attached the files.
> (Btw, I found a third bug. :) )
> FYI, I just fixed the bugs for the kernel versions I'm dealing with,
> because I don't know which other versions are affected as well.

Looking at your 2nd patch, '[PATCH 2/3] The syscall defines were not
compatible with older kernels, namely 3.0.x', this bit doesn't seem
correct at all:

====
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 <linux/version.h>
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE
>= KERNEL_VERSION(3,0,0)
+#include <asm/unistd.h>
+#include <linux/sched.h>
+#include <asm-generic/syscall.h>
+#else
 #include <asm/syscall.h>
-
+#endif
====

Including <asm-generic/syscall.h> is highly suspicious. Did you try to
include <asm/syscall.h> and get errors? If so, we can work to fix those
errors. Not including your arch's real syscall.h file will cause errors
down the road.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-07 16:06       ` David Smith
@ 2016-07-07 16:23         ` Alexander Lochmann
  2016-07-07 17:39           ` David Smith
  0 siblings, 1 reply; 20+ messages in thread
From: Alexander Lochmann @ 2016-07-07 16:23 UTC (permalink / raw)
  To: David Smith, Josh Stone, systemtap


[-- Attachment #1.1: Type: text/plain, Size: 1798 bytes --]

On 07.07.2016 18:06, David Smith wrote:
> On 07/06/2016 07:29 AM, Alexander Lochmann wrote:
>> So. Let me start.
>> First of all, I extracted the patches properly, and attached the files.
>> (Btw, I found a third bug. :) )
>> FYI, I just fixed the bugs for the kernel versions I'm dealing with,
>> because I don't know which other versions are affected as well.
> 
> Looking at your 2nd patch, '[PATCH 2/3] The syscall defines were not
> compatible with older kernels, namely 3.0.x', this bit doesn't seem
> correct at all:
> 
> ====
> 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 <linux/version.h>
> +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE
>> = KERNEL_VERSION(3,0,0)
> +#include <asm/unistd.h>
> +#include <linux/sched.h>
> +#include <asm-generic/syscall.h>
> +#else
>  #include <asm/syscall.h>
> -
> +#endif
> ====
> 
> Including <asm-generic/syscall.h> is highly suspicious. Did you try to
> include <asm/syscall.h> and get errors? If so, we can work to fix those
> errors. Not including your arch's real syscall.h file will cause errors
> down the road.
> 
An arch-specific syscall.h does not exist for arm. :(
The kernel tree for both the Galaxy Nexus (maguro) and the Nexus 4 do
not have a syscall.h (path: arch/arm/include/asm/syscall.h does not exist).

- Alex


-- 
Technische Universität 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-07 16:23         ` Alexander Lochmann
@ 2016-07-07 17:39           ` David Smith
  2016-07-07 20:51             ` Alexander Lochmann
  0 siblings, 1 reply; 20+ messages in thread
From: David Smith @ 2016-07-07 17:39 UTC (permalink / raw)
  To: Alexander Lochmann, Josh Stone, systemtap

On 07/07/2016 11:22 AM, Alexander Lochmann wrote:
> On 07.07.2016 18:06, David Smith wrote:
>> On 07/06/2016 07:29 AM, Alexander Lochmann wrote:
>>> So. Let me start.
>>> First of all, I extracted the patches properly, and attached the files.
>>> (Btw, I found a third bug. :) )
>>> FYI, I just fixed the bugs for the kernel versions I'm dealing with,
>>> because I don't know which other versions are affected as well.
>>
>> Looking at your 2nd patch, '[PATCH 2/3] The syscall defines were not
>> compatible with older kernels, namely 3.0.x', this bit doesn't seem
>> correct at all:
>>
>> ====
>> 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 <linux/version.h>
>> +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE
>>> = KERNEL_VERSION(3,0,0)
>> +#include <asm/unistd.h>
>> +#include <linux/sched.h>
>> +#include <asm-generic/syscall.h>
>> +#else
>>  #include <asm/syscall.h>
>> -
>> +#endif
>> ====
>>
>> Including <asm-generic/syscall.h> is highly suspicious. Did you try to
>> include <asm/syscall.h> and get errors? If so, we can work to fix those
>> errors. Not including your arch's real syscall.h file will cause errors
>> down the road.
>>
> An arch-specific syscall.h does not exist for arm. :(
> The kernel tree for both the Galaxy Nexus (maguro) and the Nexus 4 do
> not have a syscall.h (path: arch/arm/include/asm/syscall.h does not exist).

OK, I'll believe you. However, your fix above still isn't correct. The
whole point of autoconf-asm-syscall.c is to test if asm/syscall.h exists
and is usable. If so, STAPCONF_ASM_SYSCALL_H will get defined. If
autoconf-asm-syscall.c doesn't compile correctly, then
STAPCONF_ASM_SYSCALL_H won't be defined.

What needs to happen next here is for you to back out this change,
recompile systemtap, then try to compile a few systemtap scripts. We'll
need to see the errors to know what to fix. I'd guess we'll need to test
STAPCONF_ASM_SYSCALL_H in some more places.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-06 12:29     ` Alexander Lochmann
                         ` (2 preceding siblings ...)
  2016-07-07 16:06       ` David Smith
@ 2016-07-07 18:47       ` David Smith
  2016-07-07 19:01         ` Alexander Lochmann
  3 siblings, 1 reply; 20+ messages in thread
From: David Smith @ 2016-07-07 18:47 UTC (permalink / raw)
  To: Alexander Lochmann, Josh Stone, systemtap

On 07/06/2016 07:29 AM, Alexander Lochmann wrote:
> So. Let me start.
> First of all, I extracted the patches properly, and attached the files.
> (Btw, I found a third bug. :) )
> FYI, I just fixed the bugs for the kernel versions I'm dealing with,
> because I don't know which other versions are affected as well.

The problem you are trying to fix in your patch "[PATCH 1/3] Definition
of cputime_to_usecs in Linux kernel 3.0 is broken" is interesting. I
don't think you've got quite the right solution. Testing for a kernel
version here works for you, but really isn't a general solution -
depending on arch there could be a kernel in that range with a
reasonable cputime_to_usecs().

====
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 <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE
>= 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), 1000ULL)
 #endif
+#endif

 /* Kernels before 2.6.37 have cputime_to_msecs, but not usecs. */
 #elif defined(cputime_to_msecs)
====

I've got a couple of thoughts here:

- I wonder if we just couldn't always use your workaround (along with a
comment about why we're doing that).

- Here's an untested workaround idea that might work for all kernels:

#define cputime_to_msecs(__ct)	 		 		\
	({							\
		unsigned long __usecs = cputime_to_usecs(__ct);	\
		_stp_div64(NULL, __usecs, 1000ULL);		\
	})

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-07 18:47       ` David Smith
@ 2016-07-07 19:01         ` Alexander Lochmann
  2016-07-07 19:24           ` David Smith
  0 siblings, 1 reply; 20+ messages in thread
From: Alexander Lochmann @ 2016-07-07 19:01 UTC (permalink / raw)
  To: David Smith, Josh Stone, systemtap


[-- Attachment #1.1: Type: text/plain, Size: 2552 bytes --]

On 07.07.2016 20:47, David Smith wrote:
> On 07/06/2016 07:29 AM, Alexander Lochmann wrote:
>> So. Let me start.
>> First of all, I extracted the patches properly, and attached the files.
>> (Btw, I found a third bug. :) )
>> FYI, I just fixed the bugs for the kernel versions I'm dealing with,
>> because I don't know which other versions are affected as well.
> 
> The problem you are trying to fix in your patch "[PATCH 1/3] Definition
> of cputime_to_usecs in Linux kernel 3.0 is broken" is interesting. I
> don't think you've got quite the right solution. Testing for a kernel
> version here works for you, but really isn't a general solution -
> depending on arch there could be a kernel in that range with a
> reasonable cputime_to_usecs().
I see. :-/ Lesson learned.
> 
> ====
> 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 <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE
>> = 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), 1000ULL)
>  #endif
> +#endif
> 
>  /* Kernels before 2.6.37 have cputime_to_msecs, but not usecs. */
>  #elif defined(cputime_to_msecs)
> ====
> 
> I've got a couple of thoughts here:
> 
> - I wonder if we just couldn't always use your workaround (along with a
> comment about why we're doing that).
Why not? :) Since the kernel and every module of course is compiled with
-O3 (or -O2?),  it shouldn't make any difference in the resulting
assembler code.
> 
> - Here's an untested workaround idea that might work for all kernels:
> 
> #define cputime_to_msecs(__ct)	 		 		\
> 	({							\
> 		unsigned long __usecs = cputime_to_usecs(__ct);	\
> 		_stp_div64(NULL, __usecs, 1000ULL);		\
> 	})
> 
And so does this version. The compiler should be smart enough to
recognize __usecs is a local variable, and thus could be stored in a
register.

- Alex

-- 
Technische Universität 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-07 19:01         ` Alexander Lochmann
@ 2016-07-07 19:24           ` David Smith
  2016-07-07 19:32             ` Alexander Lochmann
  0 siblings, 1 reply; 20+ messages in thread
From: David Smith @ 2016-07-07 19:24 UTC (permalink / raw)
  To: Alexander Lochmann, Josh Stone, systemtap

On 07/07/2016 02:01 PM, Alexander Lochmann wrote:
> On 07.07.2016 20:47, David Smith wrote:
>> On 07/06/2016 07:29 AM, Alexander Lochmann wrote:
>>> So. Let me start.
>>> First of all, I extracted the patches properly, and attached the files.
>>> (Btw, I found a third bug. :) )
>>> FYI, I just fixed the bugs for the kernel versions I'm dealing with,
>>> because I don't know which other versions are affected as well.
>>
>> The problem you are trying to fix in your patch "[PATCH 1/3] Definition
>> of cputime_to_usecs in Linux kernel 3.0 is broken" is interesting. I
>> don't think you've got quite the right solution. Testing for a kernel
>> version here works for you, but really isn't a general solution -
>> depending on arch there could be a kernel in that range with a
>> reasonable cputime_to_usecs().
> I see. :-/ Lesson learned.
>>
>> ====
>> 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 <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE
>>> = 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), 1000ULL)
>>  #endif
>> +#endif
>>
>>  /* Kernels before 2.6.37 have cputime_to_msecs, but not usecs. */
>>  #elif defined(cputime_to_msecs)
>> ====
>>
>> I've got a couple of thoughts here:
>>
>> - I wonder if we just couldn't always use your workaround (along with a
>> comment about why we're doing that).
> Why not? :) Since the kernel and every module of course is compiled with
> -O3 (or -O2?),  it shouldn't make any difference in the resulting
> assembler code.

Right. So, I checked in your fix as commit 2cc20af.

Thanks.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-07 19:24           ` David Smith
@ 2016-07-07 19:32             ` Alexander Lochmann
  0 siblings, 0 replies; 20+ messages in thread
From: Alexander Lochmann @ 2016-07-07 19:32 UTC (permalink / raw)
  To: David Smith, Josh Stone, systemtap


[-- Attachment #1.1: Type: text/plain, Size: 2425 bytes --]

On 07.07.2016 21:24, David Smith wrote:
> On 07/07/2016 02:01 PM, Alexander Lochmann wrote:
>> On 07.07.2016 20:47, David Smith wrote:
>>> On 07/06/2016 07:29 AM, Alexander Lochmann wrote:
>>>> So. Let me start.
>>>> First of all, I extracted the patches properly, and attached the files.
>>>> (Btw, I found a third bug. :) )
>>>> FYI, I just fixed the bugs for the kernel versions I'm dealing with,
>>>> because I don't know which other versions are affected as well.
>>>
>>> The problem you are trying to fix in your patch "[PATCH 1/3] Definition
>>> of cputime_to_usecs in Linux kernel 3.0 is broken" is interesting. I
>>> don't think you've got quite the right solution. Testing for a kernel
>>> version here works for you, but really isn't a general solution -
>>> depending on arch there could be a kernel in that range with a
>>> reasonable cputime_to_usecs().
>> I see. :-/ Lesson learned.
>>>
>>> ====
>>> 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 <= KERNEL_VERSION(3,0,200) && LINUX_VERSION_CODE
>>>> = 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), 1000ULL)
>>>  #endif
>>> +#endif
>>>
>>>  /* Kernels before 2.6.37 have cputime_to_msecs, but not usecs. */
>>>  #elif defined(cputime_to_msecs)
>>> ====
>>>
>>> I've got a couple of thoughts here:
>>>
>>> - I wonder if we just couldn't always use your workaround (along with a
>>> comment about why we're doing that).
>> Why not? :) Since the kernel and every module of course is compiled with
>> -O3 (or -O2?),  it shouldn't make any difference in the resulting
>> assembler code.
> 
> Right. So, I checked in your fix as commit 2cc20af.
> 
Thanks. :)
> Thanks.
> 


-- 
Technische Universität 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-07 17:39           ` David Smith
@ 2016-07-07 20:51             ` Alexander Lochmann
  2016-07-07 21:14               ` David Smith
  0 siblings, 1 reply; 20+ messages in thread
From: Alexander Lochmann @ 2016-07-07 20:51 UTC (permalink / raw)
  To: David Smith, Josh Stone, systemtap

On 07.07.2016 19:39, David Smith wrote:
> OK, I'll believe you. However, your fix above still isn't correct. The
> whole point of autoconf-asm-syscall.c is to test if asm/syscall.h exists
> and is usable. If so, STAPCONF_ASM_SYSCALL_H will get defined. If
> autoconf-asm-syscall.c doesn't compile correctly, then
> STAPCONF_ASM_SYSCALL_H won't be defined.
>
> What needs to happen next here is for you to back out this change,
> recompile systemtap, then try to compile a few systemtap scripts. We'll
> need to see the errors to know what to fix. I'd guess we'll need to test
> STAPCONF_ASM_SYSCALL_H in some more places.
Ok. Here is the error message I get:
/tmp/stapE7HrAi/alexv9_src.c: In function 
'function___global__stp_syscall_nr__overload_0':
/tmp/stapE7HrAi/alexv9_src.c:7975:2: error: implicit declaration of 
function '_stp_syscall_get_nr'

I tested three scripts so far. All of them do not compile due to the 
above error.
Do you need one of the scripts?

- Alex

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-07 20:51             ` Alexander Lochmann
@ 2016-07-07 21:14               ` David Smith
  2016-07-08  5:38                 ` Alexander Lochmann
  0 siblings, 1 reply; 20+ messages in thread
From: David Smith @ 2016-07-07 21:14 UTC (permalink / raw)
  To: Alexander Lochmann, Josh Stone, systemtap

On 07/07/2016 03:52 PM, Alexander Lochmann wrote:
> On 07.07.2016 19:39, David Smith wrote:
>> OK, I'll believe you. However, your fix above still isn't correct. The
>> whole point of autoconf-asm-syscall.c is to test if asm/syscall.h exists
>> and is usable. If so, STAPCONF_ASM_SYSCALL_H will get defined. If
>> autoconf-asm-syscall.c doesn't compile correctly, then
>> STAPCONF_ASM_SYSCALL_H won't be defined.
>>
>> What needs to happen next here is for you to back out this change,
>> recompile systemtap, then try to compile a few systemtap scripts. We'll
>> need to see the errors to know what to fix. I'd guess we'll need to test
>> STAPCONF_ASM_SYSCALL_H in some more places.
> Ok. Here is the error message I get:
> /tmp/stapE7HrAi/alexv9_src.c: In function
> 'function___global__stp_syscall_nr__overload_0':
> /tmp/stapE7HrAi/alexv9_src.c:7975:2: error: implicit declaration of
> function '_stp_syscall_get_nr'
> 
> I tested three scripts so far. All of them do not compile due to the
> above error.
> Do you need one of the scripts?

Nope.

One of the reasons we include <asm/syscall.h> is to get the kernel's
syscall_get_nr() macros. If the kernel doesn't have a <asm/syscall.h>,
we define our own versions of syscall_get_nr() in runtime/syscall.h. The
arm platform already has our custom version of that macro in
runtime/syscall.h.

I'd guess we aren't including systemtap's runtime/syscall.h in the
proper place.  Here's a patch that might work:

====
diff --git a/tapset/linux/aux_syscalls.stp b/tapset/linux/aux_syscalls.stp
index 110e6e9..2cc3cea 100644
--- a/tapset/linux/aux_syscalls.stp
+++ b/tapset/linux/aux_syscalls.stp
@@ -43,6 +43,8 @@
 // Get _stp_val_array and _stp_lookup_* definitions.
 #include "linux/syscalls-common.h"

+#include "syscall.h"
+
 static void
 _stp_lookup_str2(const _stp_val_array * const array, long val, char *ptr,
 		 int len, int base)
====

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-07 21:14               ` David Smith
@ 2016-07-08  5:38                 ` Alexander Lochmann
  2016-07-08 15:31                   ` David Smith
  0 siblings, 1 reply; 20+ messages in thread
From: Alexander Lochmann @ 2016-07-08  5:38 UTC (permalink / raw)
  To: David Smith, Josh Stone, systemtap


[-- Attachment #1.1: Type: text/plain, Size: 2381 bytes --]

On 07.07.2016 23:14, David Smith wrote:
> On 07/07/2016 03:52 PM, Alexander Lochmann wrote:
>> On 07.07.2016 19:39, David Smith wrote:
>>> OK, I'll believe you. However, your fix above still isn't correct. The
>>> whole point of autoconf-asm-syscall.c is to test if asm/syscall.h exists
>>> and is usable. If so, STAPCONF_ASM_SYSCALL_H will get defined. If
>>> autoconf-asm-syscall.c doesn't compile correctly, then
>>> STAPCONF_ASM_SYSCALL_H won't be defined.
>>>
>>> What needs to happen next here is for you to back out this change,
>>> recompile systemtap, then try to compile a few systemtap scripts. We'll
>>> need to see the errors to know what to fix. I'd guess we'll need to test
>>> STAPCONF_ASM_SYSCALL_H in some more places.
>> Ok. Here is the error message I get:
>> /tmp/stapE7HrAi/alexv9_src.c: In function
>> 'function___global__stp_syscall_nr__overload_0':
>> /tmp/stapE7HrAi/alexv9_src.c:7975:2: error: implicit declaration of
>> function '_stp_syscall_get_nr'
>>
>> I tested three scripts so far. All of them do not compile due to the
>> above error.
>> Do you need one of the scripts?
> 
> Nope.
> 
> One of the reasons we include <asm/syscall.h> is to get the kernel's
> syscall_get_nr() macros. If the kernel doesn't have a <asm/syscall.h>,
> we define our own versions of syscall_get_nr() in runtime/syscall.h. The
> arm platform already has our custom version of that macro in
> runtime/syscall.h.
> 
> I'd guess we aren't including systemtap's runtime/syscall.h in the
> proper place.  Here's a patch that might work:
> 
> ====
> diff --git a/tapset/linux/aux_syscalls.stp b/tapset/linux/aux_syscalls.stp
> index 110e6e9..2cc3cea 100644
> --- a/tapset/linux/aux_syscalls.stp
> +++ b/tapset/linux/aux_syscalls.stp
> @@ -43,6 +43,8 @@
>  // Get _stp_val_array and _stp_lookup_* definitions.
>  #include "linux/syscalls-common.h"
> 
> +#include "syscall.h"
> +
>  static void
>  _stp_lookup_str2(const _stp_val_array * const array, long val, char *ptr,
>  		 int len, int base)
> ====
> 
Yes. Works. :) At least for the four scripts I tested.

- Alex

-- 
Technische Universität 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: SystemTap for Android - patchset
  2016-07-08  5:38                 ` Alexander Lochmann
@ 2016-07-08 15:31                   ` David Smith
  0 siblings, 0 replies; 20+ messages in thread
From: David Smith @ 2016-07-08 15:31 UTC (permalink / raw)
  To: Alexander Lochmann, Josh Stone, systemtap

On 07/08/2016 12:38 AM, Alexander Lochmann wrote:
> On 07.07.2016 23:14, David Smith wrote:
>> On 07/07/2016 03:52 PM, Alexander Lochmann wrote:
>>> On 07.07.2016 19:39, David Smith wrote:
>>>> OK, I'll believe you. However, your fix above still isn't correct. The
>>>> whole point of autoconf-asm-syscall.c is to test if asm/syscall.h exists
>>>> and is usable. If so, STAPCONF_ASM_SYSCALL_H will get defined. If
>>>> autoconf-asm-syscall.c doesn't compile correctly, then
>>>> STAPCONF_ASM_SYSCALL_H won't be defined.
>>>>
>>>> What needs to happen next here is for you to back out this change,
>>>> recompile systemtap, then try to compile a few systemtap scripts. We'll
>>>> need to see the errors to know what to fix. I'd guess we'll need to test
>>>> STAPCONF_ASM_SYSCALL_H in some more places.
>>> Ok. Here is the error message I get:
>>> /tmp/stapE7HrAi/alexv9_src.c: In function
>>> 'function___global__stp_syscall_nr__overload_0':
>>> /tmp/stapE7HrAi/alexv9_src.c:7975:2: error: implicit declaration of
>>> function '_stp_syscall_get_nr'
>>>
>>> I tested three scripts so far. All of them do not compile due to the
>>> above error.
>>> Do you need one of the scripts?
>>
>> Nope.
>>
>> One of the reasons we include <asm/syscall.h> is to get the kernel's
>> syscall_get_nr() macros. If the kernel doesn't have a <asm/syscall.h>,
>> we define our own versions of syscall_get_nr() in runtime/syscall.h. The
>> arm platform already has our custom version of that macro in
>> runtime/syscall.h.
>>
>> I'd guess we aren't including systemtap's runtime/syscall.h in the
>> proper place.  Here's a patch that might work:
>>
>> ====
>> diff --git a/tapset/linux/aux_syscalls.stp b/tapset/linux/aux_syscalls.stp
>> index 110e6e9..2cc3cea 100644
>> --- a/tapset/linux/aux_syscalls.stp
>> +++ b/tapset/linux/aux_syscalls.stp
>> @@ -43,6 +43,8 @@
>>  // Get _stp_val_array and _stp_lookup_* definitions.
>>  #include "linux/syscalls-common.h"
>>
>> +#include "syscall.h"
>> +
>>  static void
>>  _stp_lookup_str2(const _stp_val_array * const array, long val, char *ptr,
>>  		 int len, int base)
>> ====
>>
> Yes. Works. :) At least for the four scripts I tested.

Great. Checked in as commit bf6ec87.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-07-08 15:31 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <f01a1f27-3cdb-61a4-cbdb-7bffd1032c8e@tu-dortmund.de>
2016-07-01 16:15 ` SystemTap for Android - patchset Alexander Lochmann
2016-07-01 16:56   ` David Smith
2016-07-01 17:47   ` Josh Stone
2016-07-06 12:29     ` Alexander Lochmann
2016-07-06 16:42       ` Frank Ch. Eigler
2016-07-06 20:05         ` Alexander Lochmann
2016-07-06 20:15           ` Frank Ch. Eigler
2016-07-06 20:27             ` Alexander Lochmann
2016-07-07 16:00       ` David Smith
2016-07-07 16:06       ` David Smith
2016-07-07 16:23         ` Alexander Lochmann
2016-07-07 17:39           ` David Smith
2016-07-07 20:51             ` Alexander Lochmann
2016-07-07 21:14               ` David Smith
2016-07-08  5:38                 ` Alexander Lochmann
2016-07-08 15:31                   ` David Smith
2016-07-07 18:47       ` David Smith
2016-07-07 19:01         ` Alexander Lochmann
2016-07-07 19:24           ` David Smith
2016-07-07 19:32             ` Alexander Lochmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).