OSDN Git Service

import gdb-1999-11-01 snapshot
[pf3gnuchains/pf3gnuchains3x.git] / gdb / config / i386 / tm-linux.h
1 /* Definitions to target GDB to GNU/Linux on 386.
2    Copyright 1992, 1993 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., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20
21 #ifndef TM_LINUX_H
22 #define TM_LINUX_H
23
24 #define I386_GNULINUX_TARGET
25 #define HAVE_I387_REGS
26 #ifdef HAVE_PTRACE_GETXFPREGS
27 #define HAVE_SSE_REGS
28 #endif
29
30 #include "i386/tm-i386.h"
31
32 /* Size of sigcontext, from <asm/sigcontext.h>.  */
33 #define LINUX_SIGCONTEXT_SIZE (88)
34
35 /* Offset to saved PC in sigcontext, from <asm/sigcontext.h>.  */
36 #define LINUX_SIGCONTEXT_PC_OFFSET (56)
37
38 /* Offset to saved SP in sigcontext, from <asm/sigcontext.h>.  */
39 #define LINUX_SIGCONTEXT_SP_OFFSET (28)
40
41 /* We need this file for the SOLIB_TRAMPOLINE stuff. */
42
43 #include "tm-sysv4.h"
44
45 #define LOW_RETURN_REGNUM 0     /* holds low four bytes of result */
46 #define HIGH_RETURN_REGNUM 2    /* holds high four bytes of result */
47
48 /* This should probably move to tm-i386.h.  */
49 #define TARGET_LONG_DOUBLE_BIT 80
50
51 #if defined(HAVE_LONG_DOUBLE) && defined(HOST_I386)
52 /* The host and target are i386 machines and the compiler supports
53    long doubles. Long doubles on the host therefore have the same
54    layout as a 387 FPU stack register. */
55 #define LD_I387
56
57 extern int i387_extract_floating (PTR addr, int len, long double *dretptr);
58 extern int i387_store_floating   (PTR addr, int len, long double val);
59
60 #define TARGET_EXTRACT_FLOATING i387_extract_floating
61 #define TARGET_STORE_FLOATING   i387_store_floating
62
63 #define TARGET_ANALYZE_FLOATING                                 \
64   do                                                            \
65     {                                                           \
66       unsigned expon;                                           \
67                                                                 \
68       low = extract_unsigned_integer (valaddr, 4);              \
69       high = extract_unsigned_integer (valaddr + 4, 4);         \
70       expon = extract_unsigned_integer (valaddr + 8, 2);        \
71                                                                 \
72       nonnegative = ((expon & 0x8000) == 0);                    \
73       is_nan = ((expon & 0x7fff) == 0x7fff)                     \
74         && ((high & 0x80000000) == 0x80000000)                  \
75         && (((high & 0x7fffffff) | low) != 0);                  \
76     }                                                           \
77   while (0)
78
79 #undef REGISTER_CONVERT_TO_VIRTUAL
80 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO)        \
81 {                                                               \
82   long double val = *((long double *)FROM);                     \
83   store_floating ((TO), TYPE_LENGTH (TYPE), val);               \
84 }
85
86 #undef REGISTER_CONVERT_TO_RAW
87 #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO)                    \
88 {                                                                       \
89   long double val = extract_floating ((FROM), TYPE_LENGTH (TYPE));      \
90   *((long double *)TO) = val;                                           \
91 }
92
93 /* Return the GDB type object for the "standard" data type
94    of data in register N.  */
95 #undef REGISTER_VIRTUAL_TYPE
96 #define REGISTER_VIRTUAL_TYPE(N)                                \
97   (((N) == PC_REGNUM || (N) == FP_REGNUM || (N) == SP_REGNUM)   \
98    ? lookup_pointer_type (builtin_type_void)                    \
99    : IS_FP_REGNUM(N) ? builtin_type_long_double                 \
100    : IS_SSE_REGNUM(N) ? builtin_type_v4sf                       \
101    : builtin_type_int)
102
103 #endif
104
105 /* The following works around a problem with /usr/include/sys/procfs.h  */
106 #define sys_quotactl 1
107
108 /* When the i386 Linux kernel calls a signal handler, the return
109    address points to a bit of code on the stack.  These definitions
110    are used to identify this bit of code as a signal trampoline in
111    order to support backtracing through calls to signal handlers.  */
112
113 #define I386_LINUX_SIGTRAMP
114 #define IN_SIGTRAMP(pc, name) ((name) == NULL && i386_linux_sigtramp (pc))
115
116 extern int i386_linux_sigtramp PARAMS ((CORE_ADDR));
117
118 /* We need our own version of sigtramp_saved_pc to get the saved PC in
119    a sigtramp routine.  */
120
121 #define sigtramp_saved_pc i386_linux_sigtramp_saved_pc
122 extern CORE_ADDR i386_linux_sigtramp_saved_pc PARAMS ((struct frame_info *));
123
124 /* Signal trampolines don't have a meaningful frame.  As in tm-i386.h,
125    the frame pointer value we use is actually the frame pointer of the
126    calling frame--that is, the frame which was in progress when the
127    signal trampoline was entered.  gdb mostly treats this frame
128    pointer value as a magic cookie.  We detect the case of a signal
129    trampoline by looking at the SIGNAL_HANDLER_CALLER field, which is
130    set based on IN_SIGTRAMP.
131
132    When a signal trampoline is invoked from a frameless function, we
133    essentially have two frameless functions in a row.  In this case,
134    we use the same magic cookie for three frames in a row.  We detect
135    this case by seeing whether the next frame has
136    SIGNAL_HANDLER_CALLER set, and, if it does, checking whether the
137    current frame is actually frameless.  In this case, we need to get
138    the PC by looking at the SP register value stored in the signal
139    context.
140
141    This should work in most cases except in horrible situations where
142    a signal occurs just as we enter a function but before the frame
143    has been set up.  */
144
145 #define FRAMELESS_SIGNAL(FRAME)                                 \
146   ((FRAME)->next != NULL                                        \
147    && (FRAME)->next->signal_handler_caller                      \
148    && frameless_look_for_prologue (FRAME))
149
150 #undef FRAME_CHAIN
151 #define FRAME_CHAIN(FRAME)                                      \
152   ((FRAME)->signal_handler_caller                               \
153    ? (FRAME)->frame                                             \
154     : (FRAMELESS_SIGNAL (FRAME)                                 \
155        ? (FRAME)->frame                                         \
156        : (!inside_entry_file ((FRAME)->pc)                      \
157           ? read_memory_integer ((FRAME)->frame, 4)             \
158           : 0)))
159
160 #undef FRAME_SAVED_PC
161 #define FRAME_SAVED_PC(FRAME)                                   \
162   ((FRAME)->signal_handler_caller                               \
163    ? sigtramp_saved_pc (FRAME)                                  \
164    : (FRAMELESS_SIGNAL (FRAME)                                  \
165       ? read_memory_integer (i386_linux_sigtramp_saved_sp ((FRAME)->next), 4) \
166       : read_memory_integer ((FRAME)->frame + 4, 4)))
167
168 extern CORE_ADDR i386_linux_sigtramp_saved_sp PARAMS ((struct frame_info *));
169
170 /* Some versions of Linux have real-time signal support in the C library, and
171    some don't.  We have to include this file to find out.  */
172 #include <signal.h>
173
174 #ifdef __SIGRTMIN
175 #define REALTIME_LO __SIGRTMIN
176 #define REALTIME_HI (__SIGRTMAX + 1)
177 #else
178 #define REALTIME_LO 32
179 #define REALTIME_HI 64
180 #endif
181
182 /* When we call a function in a shared library, and the PLT sends us
183    into the dynamic linker to find the function's real address, we
184    need to skip over the dynamic linker call.  This function decides
185    when to skip, and where to skip to.  See the comments for
186    SKIP_SOLIB_RESOLVER at the top of infrun.c.  */
187 #define SKIP_SOLIB_RESOLVER i386_linux_skip_solib_resolver
188 extern CORE_ADDR i386_linux_skip_solib_resolver (CORE_ADDR pc);
189
190 /* N_FUN symbols in shared libaries have 0 for their values and need
191    to be relocated. */
192 #define SOFUN_ADDRESS_MAYBE_MISSING
193
194 #endif /* #ifndef TM_LINUX_H */