File: implicitptr.c

package info (click to toggle)
systemtap 3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,860 kB
  • ctags: 12,513
  • sloc: cpp: 58,610; ansic: 58,189; exp: 37,322; sh: 10,633; xml: 7,771; perl: 2,252; python: 2,066; tcl: 1,305; makefile: 969; lisp: 105; java: 100; awk: 94; asm: 91; sed: 16
file content (65 lines) | stat: -rw-r--r-- 894 bytes parent folder | download | duplicates (4)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <sys/sdt.h>

#define MARK(name) STAP_PROBE(implicitptr, name)

int z;

static int
foo (int i)
{
  int *j = &i;
  int **k = &j;
  int ***l = &k;
 l1: MARK (foo_l1);
  z++;		      /* side effect helps the probe placement hit right */
  i++;
  return i;
}

struct S
{
  int *x, y;
};

int u[6];

static inline int
add (struct S *a, struct S *b, int c)
{
  *a->x += *b->x;
  a->y += b->y;
 l1: MARK (add_l1);
  u[c + 0]++;
  a = (struct S *) 0;
  u[c + 1]++;
  a = b;
 l2: MARK (add_l2);
  u[c + 2]++;
  return *a->x + *b->x + a->y + b->y;
}

static int
bar (int i)
{
  int j = i;
  int k;
  struct S p[2] = { { &i, i * 2 }, { &j, j * 2 } };
 l1: MARK (bar_l1);
  k = add (&p[0], &p[1], 0);
 l2: MARK (bar_l2);
  p[0].x = &j;
  p[1].x = &i;
  k += add (&p[0], &p[1], 3);
 l3: MARK (bar_l3);
  return i + j + k;
}

int x = 22;

int
main (void)
{
  x = foo (x);
  x = bar (x);
  return 0;
}