Commit | Line | Data |
---|---|---|
82a2edfb JK |
1 | /* Sequent Symmetry target interface, for GDB. |
2 | Copyright (C) 1986, 1987, 1989, 1991, 1994 Free Software Foundation, Inc. | |
07d021a6 JG |
3 | |
4 | This file is part of GDB. | |
5 | ||
99a7de40 | 6 | This program is free software; you can redistribute it and/or modify |
07d021a6 | 7 | it under the terms of the GNU General Public License as published by |
99a7de40 JG |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | |
07d021a6 | 10 | |
99a7de40 | 11 | This program is distributed in the hope that it will be useful, |
07d021a6 JG |
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 | |
99a7de40 JG |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
07d021a6 JG |
19 | |
20 | /* many 387-specific items of use taken from i386-dep.c */ | |
21 | ||
07d021a6 | 22 | #include "defs.h" |
07d021a6 JG |
23 | #include "frame.h" |
24 | #include "inferior.h" | |
25 | #include "symtab.h" | |
26 | ||
27 | #include <signal.h> | |
28 | #include <sys/param.h> | |
29 | #include <sys/user.h> | |
30 | #include <sys/dir.h> | |
31 | #include <sys/ioctl.h> | |
32 | #include <sys/stat.h> | |
33 | #include "gdbcore.h" | |
34 | #include <fcntl.h> | |
35 | ||
07d021a6 JG |
36 | /* |
37 | * Following macro translates i386 opcode register numbers to Symmetry | |
38 | * register numbers. This is used by FRAME_FIND_SAVED_REGS. | |
39 | * | |
40 | * %eax %ecx %edx %ebx %esp %ebp %esi %edi | |
41 | * i386 0 1 2 3 4 5 6 7 | |
42 | * Symmetry 0 2 1 5 14 15 6 7 | |
43 | * | |
44 | */ | |
45 | #define I386_REGNO_TO_SYMMETRY(n) \ | |
46 | ((n)==0?0 :(n)==1?2 :(n)==2?1 :(n)==3?5 :(n)==4?14 :(n)==5?15 :(n)) | |
47 | ||
56eec3c7 | 48 | void |
07d021a6 JG |
49 | symmetry_extract_return_value(type, regbuf, valbuf) |
50 | struct type *type; | |
51 | char *regbuf; | |
52 | char *valbuf; | |
53 | { | |
54 | union { | |
55 | double d; | |
56 | int l[2]; | |
57 | } xd; | |
1ab3bf1b | 58 | struct minimal_symbol *msymbol; |
07d021a6 JG |
59 | float f; |
60 | ||
61 | if (TYPE_CODE_FLT == TYPE_CODE(type)) { | |
1ab3bf1b JG |
62 | msymbol = lookup_minimal_symbol ("1167_flt", (struct objfile *) NULL); |
63 | if (msymbol != NULL) { | |
07d021a6 JG |
64 | /* found "1167_flt" means 1167, %fp2-%fp3 */ |
65 | /* float & double; 19= %fp2, 20= %fp3 */ | |
66 | /* no single precision on 1167 */ | |
67 | xd.l[1] = *((int *)®buf[REGISTER_BYTE(19)]); | |
68 | xd.l[0] = *((int *)®buf[REGISTER_BYTE(20)]); | |
69 | switch (TYPE_LENGTH(type)) { | |
70 | case 4: | |
56eec3c7 | 71 | /* FIXME: broken for cross-debugging. */ |
07d021a6 | 72 | f = (float) xd.d; |
56eec3c7 | 73 | memcpy (valbuf, &f, TYPE_LENGTH(type)); |
07d021a6 JG |
74 | break; |
75 | case 8: | |
56eec3c7 JK |
76 | /* FIXME: broken for cross-debugging. */ |
77 | memcpy (valbuf, &xd.d, TYPE_LENGTH(type)); | |
07d021a6 JG |
78 | break; |
79 | default: | |
80 | error("Unknown floating point size"); | |
81 | break; | |
82 | } | |
83 | } else { | |
84 | /* 387 %st(0), gcc uses this */ | |
85 | i387_to_double(((int *)®buf[REGISTER_BYTE(3)]), | |
86 | &xd.d); | |
87 | switch (TYPE_LENGTH(type)) { | |
88 | case 4: /* float */ | |
89 | f = (float) xd.d; | |
56eec3c7 JK |
90 | /* FIXME: broken for cross-debugging. */ |
91 | memcpy (valbuf, &f, 4); | |
07d021a6 JG |
92 | break; |
93 | case 8: /* double */ | |
56eec3c7 JK |
94 | /* FIXME: broken for cross-debugging. */ |
95 | memcpy (valbuf, &xd.d, 8); | |
07d021a6 JG |
96 | break; |
97 | default: | |
98 | error("Unknown floating point size"); | |
99 | break; | |
100 | } | |
101 | } | |
56eec3c7 JK |
102 | } else { |
103 | memcpy (valbuf, regbuf, TYPE_LENGTH (type)); | |
104 | } | |
105 | } |