diff options
Diffstat (limited to 'testsuite/systemtap.exelib/uprobes_lib.c')
-rw-r--r-- | testsuite/systemtap.exelib/uprobes_lib.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/systemtap.exelib/uprobes_lib.c b/testsuite/systemtap.exelib/uprobes_lib.c new file mode 100644 index 00000000..e3416d17 --- /dev/null +++ b/testsuite/systemtap.exelib/uprobes_lib.c @@ -0,0 +1,33 @@ +/* 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. + */ + +#include "sdt.h" /* Really <sys/sdt.h>, but pick current source version. */ + +// 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) +{ + asm (""); + STAP_PROBE1(test, func_count, bar); + if (bar - foo > 0) + foo = lib_func (bar - foo); + return foo; +} + +void +lib_main () +{ + foo = 1; + foo = lib_func (3); +} |