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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [sepdebug.c] - Blame information for rev 178

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

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

powered by: WebSVN 2.1.0

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