* TODO: Add suggestions for x/s tests.
[deliverable/binutils-gdb.git] / gdb / symm-tdep.c
1 /* Sequent Symmetry target interface, for GDB.
2 Copyright (C) 1986, 1987, 1989, 1991, 1994 Free Software Foundation, Inc.
3
4 This file is part of GDB.
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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 /* many 387-specific items of use taken from i386-dep.c */
21
22 #include "defs.h"
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
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
48 void
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;
58 struct minimal_symbol *msymbol;
59 float f;
60
61 if (TYPE_CODE_FLT == TYPE_CODE(type)) {
62 msymbol = lookup_minimal_symbol ("1167_flt", (struct objfile *) NULL);
63 if (msymbol != NULL) {
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 *)&regbuf[REGISTER_BYTE(19)]);
68 xd.l[0] = *((int *)&regbuf[REGISTER_BYTE(20)]);
69 switch (TYPE_LENGTH(type)) {
70 case 4:
71 /* FIXME: broken for cross-debugging. */
72 f = (float) xd.d;
73 memcpy (valbuf, &f, TYPE_LENGTH(type));
74 break;
75 case 8:
76 /* FIXME: broken for cross-debugging. */
77 memcpy (valbuf, &xd.d, TYPE_LENGTH(type));
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 *)&regbuf[REGISTER_BYTE(3)]),
86 &xd.d);
87 switch (TYPE_LENGTH(type)) {
88 case 4: /* float */
89 f = (float) xd.d;
90 /* FIXME: broken for cross-debugging. */
91 memcpy (valbuf, &f, 4);
92 break;
93 case 8: /* double */
94 /* FIXME: broken for cross-debugging. */
95 memcpy (valbuf, &xd.d, 8);
96 break;
97 default:
98 error("Unknown floating point size");
99 break;
100 }
101 }
102 } else {
103 memcpy (valbuf, regbuf, TYPE_LENGTH (type));
104 }
105 }
This page took 0.031503 seconds and 4 git commands to generate.