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_lib.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 testsuite/systemtap.exelib/uprobes_lib.c (limited to 'testsuite/systemtap.exelib/uprobes_lib.c') diff --git a/testsuite/systemtap.exelib/uprobes_lib.c b/testsuite/systemtap.exelib/uprobes_lib.c new file mode 100644 index 00000000..25297b6b --- /dev/null +++ b/testsuite/systemtap.exelib/uprobes_lib.c @@ -0,0 +1,21 @@ +/* uprobes_lib test case - library helper + * 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. + */ + +void +lib_func (int bar) +{ + if (bar > 1) + lib_func (bar - 1); +} + +void +lib_main () +{ + lib_func (3); +} -- 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_lib.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'testsuite/systemtap.exelib/uprobes_lib.c') diff --git a/testsuite/systemtap.exelib/uprobes_lib.c b/testsuite/systemtap.exelib/uprobes_lib.c index 25297b6b..072a1d61 100644 --- a/testsuite/systemtap.exelib/uprobes_lib.c +++ b/testsuite/systemtap.exelib/uprobes_lib.c @@ -7,15 +7,24 @@ * later version. */ -void +// volatile static variable to prevent folding of lib_func +static volatile int foo; + +// Marked noinline and has an empty asm statement to prevent inlining +// or optimizing away totally. +int +__attribute__((noinline)) lib_func (int bar) { - if (bar > 1) - lib_func (bar - 1); + asm (""); + if (bar - foo > 0) + foo = lib_func (bar - foo); + return foo; } void lib_main () { - lib_func (3); + foo = 1; + foo = lib_func (3); } -- 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_lib.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'testsuite/systemtap.exelib/uprobes_lib.c') diff --git a/testsuite/systemtap.exelib/uprobes_lib.c b/testsuite/systemtap.exelib/uprobes_lib.c index 072a1d61..e3416d17 100644 --- a/testsuite/systemtap.exelib/uprobes_lib.c +++ b/testsuite/systemtap.exelib/uprobes_lib.c @@ -7,6 +7,8 @@ * later version. */ +#include "sdt.h" /* Really , but pick current source version. */ + // volatile static variable to prevent folding of lib_func static volatile int foo; @@ -17,6 +19,7 @@ __attribute__((noinline)) lib_func (int bar) { asm (""); + STAP_PROBE1(test, func_count, bar); if (bar - foo > 0) foo = lib_func (bar - foo); return foo; -- cgit