summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.exelib/uprobes_exe.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.exelib/uprobes_exe.c')
-rw-r--r--testsuite/systemtap.exelib/uprobes_exe.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/testsuite/systemtap.exelib/uprobes_exe.c b/testsuite/systemtap.exelib/uprobes_exe.c
new file mode 100644
index 00000000..da65efa7
--- /dev/null
+++ b/testsuite/systemtap.exelib/uprobes_exe.c
@@ -0,0 +1,39 @@
+/* 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 "sdt.h" /* Really <sys/sdt.h>, but pick current source version. */
+
+// function from our library
+int lib_main (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)
+{
+ asm ("");
+ STAP_PROBE1(test, main_count, foo);
+ if (foo - bar > 0)
+ bar = main_func (foo - bar);
+ else
+ lib_main();
+ return bar;
+}
+
+int
+main (int argc, char *argv[], char *envp[])
+{
+ bar = 1;
+ bar = main_func (3);
+ return 0;
+}