summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.exelib/uprobes_exe.c
blob: 6aac2bf5c71477c5dc321ffe83645410048e6d29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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 "sys/sdt.h"

// 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;
}