]>
Commit | Line | Data |
---|---|---|
1762d96d CV |
1 | /* Target-dependent code for Cygwin running on i386's, for GDB. |
2 | Copyright 2003 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, Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | #include "defs.h" | |
21 | ||
22 | #include "gdb_string.h" | |
f870b49b | 23 | #include "gdbcore.h" |
1762d96d CV |
24 | #include "i386-tdep.h" |
25 | #include "osabi.h" | |
f870b49b CV |
26 | #include "frame.h" |
27 | #include "dummy-frame.h" | |
28 | ||
29 | static int | |
30 | i386_cygwin_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe) | |
31 | { | |
32 | /* In the context where this is used, we get the saved PC before we've | |
33 | successfully unwound far enough to be sure what we've got (it may | |
34 | be a signal handler caller). If we're dealing with a signal | |
35 | handler caller, this will return valid, which is fine. If not, | |
36 | it'll make the correct test. */ | |
37 | return ((get_frame_type (thisframe) == SIGTRAMP_FRAME) || chain != 0); | |
38 | } | |
39 | /* Return the chain-pointer for FRAME. In the case of the i386, the | |
40 | frame's nominal address is the address of a 4-byte word containing | |
41 | the calling frame's address. */ | |
42 | static CORE_ADDR | |
43 | i386_cygwin_frame_chain (struct frame_info *frame) | |
44 | { | |
45 | if (pc_in_dummy_frame (get_frame_pc (frame))) | |
46 | return get_frame_base (frame); | |
47 | ||
48 | if (get_frame_type (frame) == SIGTRAMP_FRAME | |
49 | || i386_frameless_signal_p (frame)) | |
50 | return get_frame_base (frame); | |
51 | ||
52 | return read_memory_unsigned_integer (get_frame_base (frame), 4); | |
53 | } | |
1762d96d CV |
54 | |
55 | static void | |
56 | i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
57 | { | |
58 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
59 | ||
60 | tdep->struct_return = reg_struct_return; | |
f870b49b CV |
61 | set_gdbarch_deprecated_frame_chain (gdbarch, i386_cygwin_frame_chain); |
62 | set_gdbarch_deprecated_frame_chain_valid (gdbarch, i386_cygwin_frame_chain_valid); | |
1762d96d CV |
63 | } |
64 | ||
65 | static enum gdb_osabi | |
66 | i386_cygwin_osabi_sniffer (bfd * abfd) | |
67 | { | |
68 | char *target_name = bfd_get_target (abfd); | |
69 | ||
70 | /* Interix also uses pei-i386. | |
71 | We need a way to distinguish between the two. */ | |
72 | if (strcmp (target_name, "pei-i386") == 0) | |
73 | return GDB_OSABI_CYGWIN; | |
74 | ||
75 | return GDB_OSABI_UNKNOWN; | |
76 | } | |
77 | ||
78 | void | |
79 | _initialize_i386_cygwin_tdep (void) | |
80 | { | |
81 | gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour, | |
82 | i386_cygwin_osabi_sniffer); | |
83 | ||
84 | gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_CYGWIN, | |
85 | i386_cygwin_init_abi); | |
86 | } |