Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* Sequent Symmetry target interface, for GDB. |
2 | Copyright (C) 1986, 1987, 1989, 1991, 1994 Free Software Foundation, Inc. | |
3 | ||
c5aa993b | 4 | This file is part of GDB. |
c906108c | 5 | |
c5aa993b JM |
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 2 of the License, or | |
9 | (at your option) any later version. | |
c906108c | 10 | |
c5aa993b JM |
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. | |
c906108c | 15 | |
c5aa993b JM |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
20 | |
21 | /* many 387-specific items of use taken from i386-dep.c */ | |
22 | ||
23 | #include "defs.h" | |
24 | #include "frame.h" | |
25 | #include "inferior.h" | |
26 | #include "symtab.h" | |
27 | ||
28 | #include <signal.h> | |
29 | #include <sys/param.h> | |
30 | #include <sys/user.h> | |
31 | #include <sys/dir.h> | |
32 | #include <sys/ioctl.h> | |
33 | #include "gdb_stat.h" | |
34 | #include "gdbcore.h" | |
35 | #include <fcntl.h> | |
36 | ||
37 | void | |
fba45db2 | 38 | symmetry_extract_return_value (struct type *type, char *regbuf, char *valbuf) |
c906108c | 39 | { |
c5aa993b JM |
40 | union |
41 | { | |
42 | double d; | |
43 | int l[2]; | |
44 | } | |
45 | xd; | |
c906108c SS |
46 | struct minimal_symbol *msymbol; |
47 | float f; | |
48 | ||
c5aa993b JM |
49 | if (TYPE_CODE_FLT == TYPE_CODE (type)) |
50 | { | |
51 | msymbol = lookup_minimal_symbol ("1167_flt", NULL, NULL); | |
52 | if (msymbol != NULL) | |
53 | { | |
54 | /* found "1167_flt" means 1167, %fp2-%fp3 */ | |
55 | /* float & double; 19= %fp2, 20= %fp3 */ | |
56 | /* no single precision on 1167 */ | |
57 | xd.l[1] = *((int *) ®buf[REGISTER_BYTE (19)]); | |
58 | xd.l[0] = *((int *) ®buf[REGISTER_BYTE (20)]); | |
59 | switch (TYPE_LENGTH (type)) | |
60 | { | |
61 | case 4: | |
62 | /* FIXME: broken for cross-debugging. */ | |
63 | f = (float) xd.d; | |
64 | memcpy (valbuf, &f, TYPE_LENGTH (type)); | |
65 | break; | |
66 | case 8: | |
67 | /* FIXME: broken for cross-debugging. */ | |
68 | memcpy (valbuf, &xd.d, TYPE_LENGTH (type)); | |
69 | break; | |
70 | default: | |
71 | error ("Unknown floating point size"); | |
72 | break; | |
73 | } | |
74 | } | |
75 | else | |
76 | { | |
77 | /* 387 %st(0), gcc uses this */ | |
78 | i387_to_double (((int *) ®buf[REGISTER_BYTE (3)]), | |
79 | &xd.d); | |
80 | switch (TYPE_LENGTH (type)) | |
81 | { | |
82 | case 4: /* float */ | |
83 | f = (float) xd.d; | |
84 | /* FIXME: broken for cross-debugging. */ | |
85 | memcpy (valbuf, &f, 4); | |
86 | break; | |
87 | case 8: /* double */ | |
88 | /* FIXME: broken for cross-debugging. */ | |
89 | memcpy (valbuf, &xd.d, 8); | |
90 | break; | |
91 | default: | |
92 | error ("Unknown floating point size"); | |
93 | break; | |
94 | } | |
95 | } | |
96 | } | |
97 | else | |
98 | { | |
99 | memcpy (valbuf, regbuf, TYPE_LENGTH (type)); | |
c906108c | 100 | } |
c906108c | 101 | } |