summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.exelib/uprobes_exe.c
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2009-06-15 11:57:03 -0400
committerDave Brolley <brolley@redhat.com>2009-06-15 11:57:03 -0400
commit148b5d924e05124eae22a27ef670c480de76553a (patch)
tree894d71a8cc22f2c37cc1313154db9a8d1abb8b15 /testsuite/systemtap.exelib/uprobes_exe.c
parentc3a47b9b2c204849646eda60e6fff9ea7625f122 (diff)
parentd438dd9bc070216016e02f4958fe9dea571712c9 (diff)
downloadsystemtap-steved-148b5d924e05124eae22a27ef670c480de76553a.tar.gz
systemtap-steved-148b5d924e05124eae22a27ef670c480de76553a.tar.xz
systemtap-steved-148b5d924e05124eae22a27ef670c480de76553a.zip
Merge branch 'master' of git://sources.redhat.com/git/systemtap
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;
+}