Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Definitions to target GDB to GNU/Linux on 386. |
6ce2ac0b | 2 | Copyright 1992, 1993, 2000 Free Software Foundation, Inc. |
c906108c | 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 |
6ce2ac0b | 26 | #ifdef HAVE_PTRACE_GETFPXREGS |
5c44784c JM |
27 | #define HAVE_SSE_REGS |
28 | #endif | |
c906108c SS |
29 | |
30 | #include "i386/tm-i386.h" | |
c2d11a7d | 31 | #include "tm-linux.h" |
c906108c | 32 | |
1a8629c7 MS |
33 | /* Use target_specific function to define link map offsets. */ |
34 | extern struct link_map_offsets *i386_linux_svr4_fetch_link_map_offsets (void); | |
35 | #define SVR4_FETCH_LINK_MAP_OFFSETS() i386_linux_svr4_fetch_link_map_offsets () | |
36 | ||
ac27f131 MK |
37 | /* FIXME: kettenis/2000-03-26: We should get rid of this last piece of |
38 | Linux-specific `long double'-support code, probably by adding code | |
39 | to valprint.c:print_floating() to recognize various extended | |
40 | floating-point formats. */ | |
d4f3574e SS |
41 | |
42 | #if defined(HAVE_LONG_DOUBLE) && defined(HOST_I386) | |
43 | /* The host and target are i386 machines and the compiler supports | |
44 | long doubles. Long doubles on the host therefore have the same | |
45 | layout as a 387 FPU stack register. */ | |
d4f3574e SS |
46 | |
47 | #define TARGET_ANALYZE_FLOATING \ | |
48 | do \ | |
49 | { \ | |
50 | unsigned expon; \ | |
51 | \ | |
52 | low = extract_unsigned_integer (valaddr, 4); \ | |
53 | high = extract_unsigned_integer (valaddr + 4, 4); \ | |
54 | expon = extract_unsigned_integer (valaddr + 8, 2); \ | |
55 | \ | |
56 | nonnegative = ((expon & 0x8000) == 0); \ | |
57 | is_nan = ((expon & 0x7fff) == 0x7fff) \ | |
58 | && ((high & 0x80000000) == 0x80000000) \ | |
59 | && (((high & 0x7fffffff) | low) != 0); \ | |
60 | } \ | |
61 | while (0) | |
d4f3574e | 62 | |
d4f3574e SS |
63 | #endif |
64 | ||
c906108c SS |
65 | /* The following works around a problem with /usr/include/sys/procfs.h */ |
66 | #define sys_quotactl 1 | |
67 | ||
a0b3c4fd JM |
68 | /* When the i386 Linux kernel calls a signal handler, the return |
69 | address points to a bit of code on the stack. These definitions | |
70 | are used to identify this bit of code as a signal trampoline in | |
71 | order to support backtracing through calls to signal handlers. */ | |
72 | ||
45a816d9 MK |
73 | #define IN_SIGTRAMP(pc, name) i386_linux_in_sigtramp (pc, name) |
74 | extern int i386_linux_in_sigtramp (CORE_ADDR, char *); | |
a0b3c4fd JM |
75 | |
76 | /* We need our own version of sigtramp_saved_pc to get the saved PC in | |
77 | a sigtramp routine. */ | |
78 | ||
79 | #define sigtramp_saved_pc i386_linux_sigtramp_saved_pc | |
45a816d9 | 80 | extern CORE_ADDR i386_linux_sigtramp_saved_pc (struct frame_info *); |
a0b3c4fd JM |
81 | |
82 | /* Signal trampolines don't have a meaningful frame. As in tm-i386.h, | |
83 | the frame pointer value we use is actually the frame pointer of the | |
84 | calling frame--that is, the frame which was in progress when the | |
85 | signal trampoline was entered. gdb mostly treats this frame | |
86 | pointer value as a magic cookie. We detect the case of a signal | |
87 | trampoline by looking at the SIGNAL_HANDLER_CALLER field, which is | |
88 | set based on IN_SIGTRAMP. | |
89 | ||
90 | When a signal trampoline is invoked from a frameless function, we | |
91 | essentially have two frameless functions in a row. In this case, | |
92 | we use the same magic cookie for three frames in a row. We detect | |
93 | this case by seeing whether the next frame has | |
94 | SIGNAL_HANDLER_CALLER set, and, if it does, checking whether the | |
95 | current frame is actually frameless. In this case, we need to get | |
96 | the PC by looking at the SP register value stored in the signal | |
97 | context. | |
98 | ||
99 | This should work in most cases except in horrible situations where | |
100 | a signal occurs just as we enter a function but before the frame | |
101 | has been set up. */ | |
102 | ||
103 | #define FRAMELESS_SIGNAL(FRAME) \ | |
104 | ((FRAME)->next != NULL \ | |
105 | && (FRAME)->next->signal_handler_caller \ | |
106 | && frameless_look_for_prologue (FRAME)) | |
107 | ||
108 | #undef FRAME_CHAIN | |
109 | #define FRAME_CHAIN(FRAME) \ | |
110 | ((FRAME)->signal_handler_caller \ | |
111 | ? (FRAME)->frame \ | |
112 | : (FRAMELESS_SIGNAL (FRAME) \ | |
113 | ? (FRAME)->frame \ | |
114 | : (!inside_entry_file ((FRAME)->pc) \ | |
115 | ? read_memory_integer ((FRAME)->frame, 4) \ | |
116 | : 0))) | |
117 | ||
118 | #undef FRAME_SAVED_PC | |
119 | #define FRAME_SAVED_PC(FRAME) \ | |
120 | ((FRAME)->signal_handler_caller \ | |
121 | ? sigtramp_saved_pc (FRAME) \ | |
122 | : (FRAMELESS_SIGNAL (FRAME) \ | |
123 | ? read_memory_integer (i386_linux_sigtramp_saved_sp ((FRAME)->next), 4) \ | |
124 | : read_memory_integer ((FRAME)->frame + 4, 4))) | |
125 | ||
45a816d9 | 126 | extern CORE_ADDR i386_linux_sigtramp_saved_sp (struct frame_info *); |
a0b3c4fd | 127 | |
4cc24188 MK |
128 | #undef SAVED_PC_AFTER_CALL |
129 | #define SAVED_PC_AFTER_CALL(frame) i386_linux_saved_pc_after_call (frame) | |
130 | extern CORE_ADDR i386_linux_saved_pc_after_call (struct frame_info *); | |
131 | ||
d4f3574e SS |
132 | /* When we call a function in a shared library, and the PLT sends us |
133 | into the dynamic linker to find the function's real address, we | |
134 | need to skip over the dynamic linker call. This function decides | |
135 | when to skip, and where to skip to. See the comments for | |
136 | SKIP_SOLIB_RESOLVER at the top of infrun.c. */ | |
137 | #define SKIP_SOLIB_RESOLVER i386_linux_skip_solib_resolver | |
138 | extern CORE_ADDR i386_linux_skip_solib_resolver (CORE_ADDR pc); | |
139 | ||
140 | /* N_FUN symbols in shared libaries have 0 for their values and need | |
141 | to be relocated. */ | |
142 | #define SOFUN_ADDRESS_MAYBE_MISSING | |
f19ebbbc MK |
143 | \f |
144 | ||
145 | /* Support for longjmp. */ | |
146 | ||
147 | /* Details about jmp_buf. It's supposed to be an array of integers. */ | |
148 | ||
149 | #define JB_ELEMENT_SIZE 4 /* Size of elements in jmp_buf. */ | |
150 | #define JB_PC 5 /* Array index of saved PC. */ | |
151 | ||
152 | /* Figure out where the longjmp will land. Slurp the args out of the | |
153 | stack. We expect the first arg to be a pointer to the jmp_buf | |
154 | structure from which we extract the pc (JB_PC) that we will land | |
155 | at. The pc is copied into ADDR. This routine returns true on | |
156 | success. */ | |
157 | ||
158 | #define GET_LONGJMP_TARGET(addr) get_longjmp_target (addr) | |
159 | extern int get_longjmp_target (CORE_ADDR *addr); | |
d4f3574e | 160 | |
c5aa993b | 161 | #endif /* #ifndef TM_LINUX_H */ |