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