1 /* Target-dependent code for Cygwin running on i386's, for GDB.
2 Copyright 2003 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
22 #include "gdb_string.h"
24 #include "i386-tdep.h"
27 #include "dummy-frame.h"
30 i386_cygwin_frame_chain_valid (CORE_ADDR chain
, struct frame_info
*thisframe
)
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);
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. */
43 i386_cygwin_frame_chain (struct frame_info
*frame
)
45 if (pc_in_dummy_frame (get_frame_pc (frame
)))
46 return get_frame_base (frame
);
48 if (get_frame_type (frame
) == SIGTRAMP_FRAME
49 || i386_frameless_signal_p (frame
))
50 return get_frame_base (frame
);
52 return read_memory_unsigned_integer (get_frame_base (frame
), 4);
56 i386_cygwin_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
58 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
60 tdep
->struct_return
= reg_struct_return
;
61 set_gdbarch_deprecated_frame_chain (gdbarch
, i386_cygwin_frame_chain
);
62 set_gdbarch_deprecated_frame_chain_valid (gdbarch
, i386_cygwin_frame_chain_valid
);
66 i386_cygwin_osabi_sniffer (bfd
* abfd
)
68 char *target_name
= bfd_get_target (abfd
);
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
;
75 return GDB_OSABI_UNKNOWN
;
79 _initialize_i386_cygwin_tdep (void)
81 gdbarch_register_osabi_sniffer (bfd_arch_i386
, bfd_target_coff_flavour
,
82 i386_cygwin_osabi_sniffer
);
84 gdbarch_register_osabi (bfd_arch_i386
, 0, GDB_OSABI_CYGWIN
,
85 i386_cygwin_init_abi
);