Debian Codegraph @

testsuite/systemtap.exelib/uprobes_lib.c

raw
1 /* uprobes_lib test case - library helper
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 // volatile static variable to prevent folding of lib_func
13 static volatile int foo;
14
15 // Marked noinline and has an empty asm statement to prevent inlining
16 // or optimizing away totally.
17 int
18 __attribute__((noinline))
19 lib_func (int bar)
20 {
21 asm ("");
22 STAP_PROBE1(test, func_count, bar);
23 if (bar - foo > 0)
24 foo = lib_func (bar - foo);
25 return foo;
26 }
27
28 void
29 lib_main ()
30 {
31 foo = 1;
32 foo = lib_func (3);
33 }