OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.misc-tests/] [gcov-7.c] - Blame information for rev 193

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Check that gcov correctly reports line counts, branch percentages,
2
 * and call return percentages for functions that call longjmp. */
3
 
4
/* { dg-options "-fprofile-arcs -ftest-coverage" } */
5
/* { dg-do run { target native } } */
6
 
7
#include <setjmp.h>
8
 
9
extern void abort (void);
10
extern void exit (int);
11
 
12
jmp_buf env;
13
int val;
14
int longjmp_taken;
15
int bar_enter, bar_exit;
16
int foo_enter, foo_exit;
17
 
18
void bar (int i)
19
{
20
  bar_enter++;                          /* count(3) */
21
                                        /* branch(67) */
22
  if (i == 0) {
23
                                        /* branch(end) */
24
      longjmp_taken++;                  /* count(1) */
25
      longjmp (env, 1);
26
    }
27
  val += i+1;
28
  bar_exit++;                           /* count(2) */
29
}
30
 
31
void foo (int i)
32
{
33
  foo_enter++;                          /* count(3) */
34
                                        /* branch(67) */
35
  if (i == 1) {
36
                                        /* branch(end) */
37
      longjmp_taken++;                  /* count(1) */
38
      longjmp (env, 2);
39
    }
40
                                        /* returns(50) */
41
  bar (i);                              /* count(2) */
42
                                        /* returns(100) */
43
  bar (7);                              /* count(1) */
44
                                        /* returns(end) */
45
  val += 16;
46
  foo_exit++;                           /* count(1) */
47
}
48
 
49
int
50
passed ()
51
{
52
  return (val == 31 &&
53
          longjmp_taken == 2 &&
54
          foo_enter == 3 &&
55
          foo_exit == 1 &&
56
          bar_enter == 3 &&
57
          bar_exit == 2);
58
 
59
}
60
 
61
void
62
leave (int i)
63
{
64
  if (i == 0) {
65
      abort ();
66
    }
67
  exit (0);
68
}
69
 
70
int
71
main()
72
{
73
  int retval;
74
 
75
                                        /* branch(33) */
76
  if ((retval = setjmp (env))) {
77
                                        /* branch(end) */
78
      val += retval;                    /* count(2) */
79
    }
80
                                        /* returns(33) */
81
  foo (val);                            /* count(3) */
82
                                        /* returns(0) */
83
  leave (passed());                     /* count(1) */
84
                                        /* returns(end) */
85
}
86
 
87
/* { dg-final { run-gcov calls branches { -b gcov-7.c } } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.