Debian Codegraph @

testsuite/systemtap.exelib/uprobes_exe.c

raw
1 /* uprobes_lib test case
2 * Copyright (C) 2009, Red Hat Inc.
3 *
4 * This file is part of systemtap, and is free software. You can
5 * redistribute it and/or modify it under the terms of the GNU General
6 * Public License (GPL); either version 2, or (at your option) any
7 * later version.
8 */
9
10 #include "sys/sdt.h"
11
12 // function from our library
13 int lib_main (void);
14
15 // volatile static variable to prevent folding of main_func
16 static volatile int bar;
17
18 // Marked noinline and has an empty asm statement to prevent inlining
19 // or optimizing away totally.
20 int
21 __attribute__((noinline))
22 main_func (int foo)
23 {
24 asm ("");
25 STAP_PROBE1(test, main_count, foo);
26 if (foo - bar > 0)
27 bar = main_func (foo - bar);
28 else
29 lib_main();
30 return bar;
31 }
32
33 int
34 main (int argc, char *argv[], char *envp[])
35 {
36 bar = 1;
37 bar = main_func (3);
38 return 0;
39 }