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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [break.c] - Blame information for rev 842

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
/* This testcase is part of GDB, the GNU debugger.
2
 
3
   Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003, 2007, 2008, 2009, 2010
4
   Free Software Foundation, Inc.
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3 of the License, or
9
   (at your option) any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
 
19
#ifdef vxworks
20
 
21
#  include <stdio.h>
22
 
23
/* VxWorks does not supply atoi.  */
24
static int
25
atoi (z)
26
     char *z;
27
{
28
  int i = 0;
29
 
30
  while (*z >= '0' && *z <= '9')
31
    i = i * 10 + (*z++ - '0');
32
  return i;
33
}
34
 
35
/* I don't know of any way to pass an array to VxWorks.  This function
36
   can be called directly from gdb.  */
37
 
38
vxmain (arg)
39
char *arg;
40
{
41
  char *argv[2];
42
 
43
  argv[0] = "";
44
  argv[1] = arg;
45
  main (2, argv, (char **) 0);
46
}
47
 
48
#else /* ! vxworks */
49
#  include <stdio.h>
50
#  include <stdlib.h>
51
#endif /* ! vxworks */
52
 
53
#ifdef PROTOTYPES
54
extern int marker1 (void);
55
extern int marker2 (int a);
56
extern void marker3 (char *a, char *b);
57
extern void marker4 (long d);
58
#else
59
extern int marker1 ();
60
extern int marker2 ();
61
extern void marker3 ();
62
extern void marker4 ();
63
#endif
64
 
65
/* We're used by a test that requires malloc, so make sure it is in
66
   the executable.  */
67
void *need_malloc ()
68
{
69
  return malloc (1);
70
}
71
 
72
/*
73
 *      This simple classical example of recursion is useful for
74
 *      testing stack backtraces and such.
75
 */
76
 
77
#ifdef PROTOTYPES
78
int factorial(int);
79
 
80
int
81
main (int argc, char **argv, char **envp)
82
#else
83
int
84
main (argc, argv, envp)
85
int argc;
86
char *argv[], **envp;
87
#endif
88
{
89
#ifdef usestubs
90
    set_debug_traps();  /* set breakpoint 5 here */
91
    breakpoint();
92
#endif
93
    if (argc == 12345) {  /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
94
        fprintf (stderr, "usage:  factorial <number>\n");
95
        return 1;
96
    }
97
    printf ("%d\n", factorial (atoi ("6")));  /* set breakpoint 1 here */
98
    /* set breakpoint 12 here */
99
    marker1 ();  /* set breakpoint 11 here */
100
    marker2 (43); /* set breakpoint 20 here */
101
    marker3 ("stack", "trace"); /* set breakpoint 21 here */
102
    marker4 (177601976L);
103
    /* We're used by a test that requires malloc, so make sure it is
104
       in the executable.  */
105
    (void)malloc (1);
106
 
107
    argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
108
    return argc;  /* set breakpoint 10 here */
109
} /* set breakpoint 10a here */
110
 
111
#ifdef PROTOTYPES
112
int factorial (int value)
113
#else
114
int factorial (value)
115
int value;
116
#endif
117
{
118
  if (value > 1) {  /* set breakpoint 7 here */
119
        value *= factorial (value - 1);
120
    }
121
    return (value); /* set breakpoint 19 here */
122
}
123
 
124
#ifdef PROTOTYPES
125
int multi_line_if_conditional (int a, int b, int c)
126
#else
127
int multi_line_if_conditional (a, b, c)
128
  int a, b, c;
129
#endif
130
{
131
  if (a    /* set breakpoint 3 here */
132
      && b
133
      && c)
134
    return 0;
135
  else
136
    return 1;
137
}
138
 
139
#ifdef PROTOTYPES
140
int multi_line_while_conditional (int a, int b, int c)
141
#else
142
int multi_line_while_conditional (a, b, c)
143
  int a, b, c;
144
#endif
145
{
146
  while (a /* set breakpoint 4 here */
147
      && b
148
      && c)
149
    {
150
      a--, b--, c--;
151
    }
152
  return 0;
153
}

powered by: WebSVN 2.1.0

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