1 /* Definitions to target GDB to GNU/Linux on 386.
2 Copyright 1992, 1993, 1995, 1996, 1998, 1999, 2000
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 #define I386_GNULINUX_TARGET
26 #define HAVE_I387_REGS
27 #ifdef HAVE_PTRACE_GETFPXREGS
31 #include "i386/tm-i386.h"
34 /* Use target_specific function to define link map offsets. */
35 extern struct link_map_offsets *i386_linux_svr4_fetch_link_map_offsets (void);
36 #define SVR4_FETCH_LINK_MAP_OFFSETS() i386_linux_svr4_fetch_link_map_offsets ()
38 /* FIXME: kettenis/2000-03-26: We should get rid of this last piece of
39 Linux-specific `long double'-support code, probably by adding code
40 to valprint.c:print_floating() to recognize various extended
41 floating-point formats. */
43 #if defined(HAVE_LONG_DOUBLE) && defined(HOST_I386)
44 /* The host and target are i386 machines and the compiler supports
45 long doubles. Long doubles on the host therefore have the same
46 layout as a 387 FPU stack register. */
48 #define TARGET_ANALYZE_FLOATING \
53 low = extract_unsigned_integer (valaddr, 4); \
54 high = extract_unsigned_integer (valaddr + 4, 4); \
55 expon = extract_unsigned_integer (valaddr + 8, 2); \
57 nonnegative = ((expon & 0x8000) == 0); \
58 is_nan = ((expon & 0x7fff) == 0x7fff) \
59 && ((high & 0x80000000) == 0x80000000) \
60 && (((high & 0x7fffffff) | low) != 0); \
66 /* The following works around a problem with /usr/include/sys/procfs.h */
67 #define sys_quotactl 1
69 /* When the i386 Linux kernel calls a signal handler, the return
70 address points to a bit of code on the stack. These definitions
71 are used to identify this bit of code as a signal trampoline in
72 order to support backtracing through calls to signal handlers. */
74 #define IN_SIGTRAMP(pc, name) i386_linux_in_sigtramp (pc, name)
75 extern int i386_linux_in_sigtramp (CORE_ADDR, char *);
77 /* We need our own version of sigtramp_saved_pc to get the saved PC in
78 a sigtramp routine. */
80 #define sigtramp_saved_pc i386_linux_sigtramp_saved_pc
81 extern CORE_ADDR i386_linux_sigtramp_saved_pc (struct frame_info *);
83 /* Signal trampolines don't have a meaningful frame. As in tm-i386.h,
84 the frame pointer value we use is actually the frame pointer of the
85 calling frame--that is, the frame which was in progress when the
86 signal trampoline was entered. gdb mostly treats this frame
87 pointer value as a magic cookie. We detect the case of a signal
88 trampoline by looking at the SIGNAL_HANDLER_CALLER field, which is
89 set based on IN_SIGTRAMP.
91 When a signal trampoline is invoked from a frameless function, we
92 essentially have two frameless functions in a row. In this case,
93 we use the same magic cookie for three frames in a row. We detect
94 this case by seeing whether the next frame has
95 SIGNAL_HANDLER_CALLER set, and, if it does, checking whether the
96 current frame is actually frameless. In this case, we need to get
97 the PC by looking at the SP register value stored in the signal
100 This should work in most cases except in horrible situations where
101 a signal occurs just as we enter a function but before the frame
104 #define FRAMELESS_SIGNAL(FRAME) \
105 ((FRAME)->next != NULL \
106 && (FRAME)->next->signal_handler_caller \
107 && frameless_look_for_prologue (FRAME))
110 #define FRAME_CHAIN(FRAME) \
111 ((FRAME)->signal_handler_caller \
113 : (FRAMELESS_SIGNAL (FRAME) \
115 : (!inside_entry_file ((FRAME)->pc) \
116 ? read_memory_integer ((FRAME)->frame, 4) \
119 #undef FRAME_SAVED_PC
120 #define FRAME_SAVED_PC(FRAME) \
121 ((FRAME)->signal_handler_caller \
122 ? sigtramp_saved_pc (FRAME) \
123 : (FRAMELESS_SIGNAL (FRAME) \
124 ? read_memory_integer (i386_linux_sigtramp_saved_sp ((FRAME)->next), 4) \
125 : read_memory_integer ((FRAME)->frame + 4, 4)))
127 extern CORE_ADDR i386_linux_sigtramp_saved_sp (struct frame_info *);
129 #undef SAVED_PC_AFTER_CALL
130 #define SAVED_PC_AFTER_CALL(frame) i386_linux_saved_pc_after_call (frame)
131 extern CORE_ADDR i386_linux_saved_pc_after_call (struct frame_info *);
133 /* When we call a function in a shared library, and the PLT sends us
134 into the dynamic linker to find the function's real address, we
135 need to skip over the dynamic linker call. This function decides
136 when to skip, and where to skip to. See the comments for
137 SKIP_SOLIB_RESOLVER at the top of infrun.c. */
138 #define SKIP_SOLIB_RESOLVER i386_linux_skip_solib_resolver
139 extern CORE_ADDR i386_linux_skip_solib_resolver (CORE_ADDR pc);
141 /* N_FUN symbols in shared libaries have 0 for their values and need
143 #define SOFUN_ADDRESS_MAYBE_MISSING
146 /* Support for longjmp. */
148 /* Details about jmp_buf. It's supposed to be an array of integers. */
150 #define JB_ELEMENT_SIZE 4 /* Size of elements in jmp_buf. */
151 #define JB_PC 5 /* Array index of saved PC. */
153 /* Figure out where the longjmp will land. Slurp the args out of the
154 stack. We expect the first arg to be a pointer to the jmp_buf
155 structure from which we extract the pc (JB_PC) that we will land
156 at. The pc is copied into ADDR. This routine returns true on
159 #define GET_LONGJMP_TARGET(addr) get_longjmp_target (addr)
160 extern int get_longjmp_target (CORE_ADDR *addr);
162 #endif /* #ifndef TM_LINUX_H */