From 6a7dc7d9c3df7d5d722f0702a0a0c8d55591006e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 12 Jun 2009 22:37:11 +0200 Subject: Add exelib uprobes test framework. Tests uprobes placed in executables and shared libraries on different arches (32-on-64 currently disabled), gcc/g++, optimizations (currently disabled), prelinked libs (currently disabled), seperate libs/exe debuginfo and pie executables. * testsuite/systemtap.base/uprobes_exe.c: Moved to... * testsuite/systemtap.exelib/uprobes_exe.c: From systemtap.base. * testsuite/systemtap.base/uprobes_lib.c: Moved to... * testsuite/systemtap.exelib/uprobes_lib.c: From systemtap.base. * testsuite/systemtap.base/uprobes_lib.exp: Rewritten as... * testsuite/systemtap.exelib/lib.tcl: From uprobes_lib.exp. * testsuite/systemtap.base/uprobes_lib.stp: Rewritten as... * testsuite/systemtap.exelib/lib.stp: From uprobes_lib.stp. * testsuite/systemtap.base/uprobes_uname.exp: Rewritten as... * testsuite/systemtap.exelib/uname.tcl: From uprobes_uname.exp. * testsuite/systemtap.base/uprobes_uname.stp: Rewritten as... * testsuite/systemtap.exelib/uname.stp: From uprobes_uname.stp. * testsuite/systemtap.base/uprobes_ustack.exp: Rewritten as... * testsuite/systemtap.exelib/ustack.tcl: From uprobes_ustack.exp. * testsuite/systemtap.base/uprobes_ustack.stp: Rewritten as... * testsuite/systemtap.exelib/ustack.stp: From uprobes_ustack.stp. * testsuite/systemtap.exelib/exelib.exp: New exelib uprobes framework. * testsuite/systemtap.exelib/cleanup.tcl: New file. --- testsuite/systemtap.exelib/uprobes_exe.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 testsuite/systemtap.exelib/uprobes_exe.c (limited to 'testsuite/systemtap.exelib/uprobes_exe.c') diff --git a/testsuite/systemtap.exelib/uprobes_exe.c b/testsuite/systemtap.exelib/uprobes_exe.c new file mode 100644 index 00000000..b4811335 --- /dev/null +++ b/testsuite/systemtap.exelib/uprobes_exe.c @@ -0,0 +1,29 @@ +/* uprobes_lib test case + * Copyright (C) 2009, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + */ + +#include + +// function from our library +int lib_main (void); + +void +main_func (int foo) +{ + if (foo > 1) + main_func (foo - 1); + else + lib_main(); +} + +int +main (int argc, char *argv[], char *envp[]) +{ + main_func (3); + return 0; +} -- cgit From 5e3d7f3a3aa8d11b67e74de0c3d9187c323cbff2 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 15 Jun 2009 13:37:39 +0200 Subject: PR10274 Fix exelib -O3 testcase. The testcase now uses noinline, an empty asm statement and a volatile variable to prevent the function getting inlined, being totally unrolled or the recursive call being replaced with an inner-iteration. This does defeat part of the testcase though, which was testing unwinding through an optimized recursive function. But it seems the best we can do. * testsuite/systemtap.exelib/exelib.exp: Add -O3 to the mix. * testsuite/systemtap.exelib/uprobes_exe.c: Use volatile bar and mark main_func noinline. * testsuite/systemtap.exelib/uprobes_lib.c: Use volatile foo and mark lib_func noinline. --- testsuite/systemtap.exelib/uprobes_exe.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'testsuite/systemtap.exelib/uprobes_exe.c') diff --git a/testsuite/systemtap.exelib/uprobes_exe.c b/testsuite/systemtap.exelib/uprobes_exe.c index b4811335..d2905637 100644 --- a/testsuite/systemtap.exelib/uprobes_exe.c +++ b/testsuite/systemtap.exelib/uprobes_exe.c @@ -12,18 +12,27 @@ // function from our library int lib_main (void); -void +// volatile static variable to prevent folding of main_func +static volatile int bar; + +// Marked noinline and has an empty asm statement to prevent inlining +// or optimizing away totally. +int +__attribute__((noinline)) main_func (int foo) { - if (foo > 1) - main_func (foo - 1); + asm (""); + if (foo - bar > 0) + bar = main_func (foo - bar); else lib_main(); + return bar; } int main (int argc, char *argv[], char *envp[]) { - main_func (3); + bar = 1; + bar = main_func (3); return 0; } -- cgit From cba30aa93a8836cd9f88b494c17bc991c997d5f2 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 15 Jun 2009 17:16:14 +0200 Subject: Add (disabled) testcase for stap probe marks to exelib. * testsuite/systemtap.exelib/exelib.exp: Compile against sdt.h. * testsuite/systemtap.exelib/uprobes_exe.c: Add main_count probe mark. * testsuite/systemtap.exelib/uprobes_lib.c: Add func_count probe mark. * testsuite/systemtap.exelib/mark.tcl: New test. * testsuite/systemtap.exelib/mark.stp: New test tapset. --- testsuite/systemtap.exelib/uprobes_exe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.exelib/uprobes_exe.c') diff --git a/testsuite/systemtap.exelib/uprobes_exe.c b/testsuite/systemtap.exelib/uprobes_exe.c index d2905637..da65efa7 100644 --- a/testsuite/systemtap.exelib/uprobes_exe.c +++ b/testsuite/systemtap.exelib/uprobes_exe.c @@ -7,7 +7,7 @@ * later version. */ -#include +#include "sdt.h" /* Really , but pick current source version. */ // function from our library int lib_main (void); @@ -22,6 +22,7 @@ __attribute__((noinline)) main_func (int foo) { asm (""); + STAP_PROBE1(test, main_count, foo); if (foo - bar > 0) bar = main_func (foo - bar); else -- cgit