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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [gdb-5.3/] [gdb/] [testsuite/] [gdb.base/] [break.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
#ifdef vxworks
2
 
3
#  include <stdio.h>
4
 
5
/* VxWorks does not supply atoi.  */
6
static int
7
atoi (z)
8
     char *z;
9
{
10
  int i = 0;
11
 
12
  while (*z >= '0' && *z <= '9')
13
    i = i * 10 + (*z++ - '0');
14
  return i;
15
}
16
 
17
/* I don't know of any way to pass an array to VxWorks.  This function
18
   can be called directly from gdb.  */
19
 
20
vxmain (arg)
21
char *arg;
22
{
23
  char *argv[2];
24
 
25
  argv[0] = "";
26
  argv[1] = arg;
27
  main (2, argv, (char **) 0);
28
}
29
 
30
#else /* ! vxworks */
31
#  include <stdio.h>
32
#  include <stdlib.h>
33
#endif /* ! vxworks */
34
 
35
/*
36
 * The following functions do nothing useful.  They are included simply
37
 * as places to try setting breakpoints at.  They are explicitly
38
 * "one-line functions" to verify that this case works (some versions
39
 * of gcc have or have had problems with this).
40
 */
41
 
42
#ifdef PROTOTYPES
43
int marker1 (void) { return (0); }
44
int marker2 (int a) { return (1); }
45
void marker3 (char *a, char *b) {}
46
void marker4 (long d) {}
47
#else
48
int marker1 () { return (0); }
49
int marker2 (a) int a; { return (1); }
50
void marker3 (a, b) char *a, *b; {}
51
void marker4 (d) long d; {}
52
#endif
53
 
54
/*
55
 *      This simple classical example of recursion is useful for
56
 *      testing stack backtraces and such.
57
 */
58
 
59
#ifdef PROTOTYPES
60
int factorial(int);
61
 
62
int
63
main (int argc, char **argv, char **envp)
64
#else
65
int
66
main (argc, argv, envp)
67
int argc;
68
char *argv[], **envp;
69
#endif
70
{
71
#ifdef usestubs
72
    set_debug_traps();
73
    breakpoint();
74
#endif
75
    if (argc == 12345) {  /* an unlikely value < 2^16, in case uninited */
76
        fprintf (stderr, "usage:  factorial <number>\n");
77
        return 1;
78
    }
79
    printf ("%d\n", factorial (atoi ("6")));
80
 
81
    marker1 ();
82
    marker2 (43);
83
    marker3 ("stack", "trace");
84
    marker4 (177601976L);
85
    argc = (argc == 12345); /* This is silly, but we can step off of it */
86
    return argc;
87
}
88
 
89
#ifdef PROTOTYPES
90
int factorial (int value)
91
#else
92
int factorial (value)
93
int value;
94
#endif
95
{
96
    if (value > 1) {
97
        value *= factorial (value - 1);
98
    }
99
    return (value);
100
}
101
 
102
#ifdef PROTOTYPES
103
int multi_line_if_conditional (int a, int b, int c)
104
#else
105
int multi_line_if_conditional (a, b, c)
106
  int a, b, c;
107
#endif
108
{
109
  if (a
110
      && b
111
      && c)
112
    return 0;
113
  else
114
    return 1;
115
}
116
 
117
#ifdef PROTOTYPES
118
int multi_line_while_conditional (int a, int b, int c)
119
#else
120
int multi_line_while_conditional (a, b, c)
121
  int a, b, c;
122
#endif
123
{
124
  while (a
125
      && b
126
      && c)
127
    {
128
      a--, b--, c--;
129
    }
130
  return 0;
131
}

powered by: WebSVN 2.1.0

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