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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.reverse/] [finish-reverse.c] - Blame information for rev 387

Go to most recent revision | 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 2008, 2009, 2010 Free Software Foundation, Inc.
4
 
5
   This program is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 3 of the License, or
8
   (at your option) any later version.
9
 
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14
 
15
   You should have received a copy of the GNU General Public License
16
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
 
18
/* Test gdb's "return" command in reverse.  */
19
 
20
int void_test = 0;
21
int main_test = 0;
22
 
23
char      char_returnval      = '1';
24
short     short_returnval     = 1;
25
int       int_returnval       = 1;
26
long      long_returnval      = 1;
27
long long long_long_returnval = 1;
28
float     float_returnval     = 1;
29
double    double_returnval    = 1;
30
 
31
union {
32
  char      char_testval;
33
  short     short_testval;
34
  int       int_testval;
35
  long      long_testval;
36
  long long long_long_testval;
37
  float     float_testval;
38
  double    double_testval;
39
  char      ffff[80];
40
} testval;
41
 
42
void void_func ()
43
{
44
  void_test = 1;                /* VOID FUNC */
45
}
46
 
47
char char_func ()
48
{
49
  return char_returnval;        /* CHAR FUNC */
50
}
51
 
52
short short_func ()
53
{
54
  return short_returnval;       /* SHORT FUNC */
55
}
56
 
57
int int_func ()
58
{
59
  return int_returnval;         /* INT FUNC */
60
}
61
 
62
long long_func ()
63
{
64
  return long_returnval;        /* LONG FUNC */
65
}
66
 
67
long long long_long_func ()
68
{
69
  return long_long_returnval;   /* LONG LONG FUNC */
70
}
71
 
72
float float_func ()
73
{
74
  return float_returnval;       /* FLOAT FUNC */
75
}
76
 
77
double double_func ()
78
{
79
  return double_returnval;      /* DOUBLE FUNC */
80
}
81
 
82
int main (int argc, char **argv)
83
{
84
  char char_resultval;
85
  short short_resultval;
86
  int int_resultval;
87
  long long_resultval;
88
  long long long_long_resultval;
89
  float float_resultval;
90
  double double_resultval;
91
  int i;
92
 
93
  /* A "test load" that will insure that the function really returns
94
     a ${type} (as opposed to just a truncated or part of a ${type}).  */
95
  for (i = 0; i < sizeof (testval.ffff); i++)
96
    testval.ffff[i] = 0xff;
97
 
98
  void_func ();                                 /* call to void_func */
99
  char_resultval      = char_func ();           /* void_checkpoint */
100
  short_resultval     = short_func ();          /* char_checkpoint */
101
  int_resultval       = int_func ();            /* short_checkpoint */
102
  long_resultval      = long_func ();           /* int_checkpoint */
103
  long_long_resultval = long_long_func ();      /* long_checkpoint */
104
 
105
  /* On machines using IEEE floating point, the test pattern of all
106
     1-bits established above turns out to be a floating-point NaN
107
     ("Not a Number").  According to the IEEE rules, NaN's aren't even
108
     equal to themselves.  This can lead to stupid conversations with
109
     GDB like:
110
 
111
       (gdb) p testval.float_testval == testval.float_testval
112
       $7 = 0
113
       (gdb)
114
 
115
     This is the correct answer, but it's not the sort of thing
116
     return2.exp wants to see.  So to make things work the way they
117
     ought, we'll set aside the `union' cleverness and initialize the
118
     test values explicitly here.  These values have interesting bits
119
     throughout the value, so we'll still detect truncated values.  */
120
 
121
  testval.float_testval = 2.7182818284590452354;/* long_long_checkpoint */
122
  float_resultval     = float_func ();
123
  testval.double_testval = 3.14159265358979323846; /* float_checkpoint */
124
  double_resultval    = double_func ();
125
  main_test = 1;                                /* double_checkpoint */
126
  return 0;
127
} /* end of main */
128
 

powered by: WebSVN 2.1.0

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