i386ly-tdep.c revision 130812
1227569Sphilip/* Target-dependent code for Intel 386 running LynxOS. 2283514Sarybchik Copyright 1993, 1996, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 3283514Sarybchik 4227569Sphilip This file is part of GDB. 5227569Sphilip 6283514Sarybchik This program is free software; you can redistribute it and/or modify 7227569Sphilip it under the terms of the GNU General Public License as published by 8283514Sarybchik the Free Software Foundation; either version 2 of the License, or 9283514Sarybchik (at your option) any later version. 10283514Sarybchik 11283514Sarybchik This program is distributed in the hope that it will be useful, 12283514Sarybchik but WITHOUT ANY WARRANTY; without even the implied warranty of 13283514Sarybchik MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14283514Sarybchik GNU General Public License for more details. 15283514Sarybchik 16283514Sarybchik You should have received a copy of the GNU General Public License 17283514Sarybchik along with this program; if not, write to the Free Software 18283514Sarybchik Foundation, Inc., 59 Temple Place - Suite 330, 19283514Sarybchik Boston, MA 02111-1307, USA. */ 20283514Sarybchik 21283514Sarybchik#include "defs.h" 22283514Sarybchik#include "gdbcore.h" 23283514Sarybchik#include "inferior.h" 24283514Sarybchik#include "regcache.h" 25283514Sarybchik#include "target.h" 26283514Sarybchik#include "osabi.h" 27283514Sarybchik 28283514Sarybchik#include "i386-tdep.h" 29227569Sphilip 30227569Sphilip/* Return the PC of the caller from the call frame. Assumes the subr 31228078Sphilip prologue has already been executed, and the frame pointer setup. 32228078Sphilip If this is the outermost frame, we check to see if we are in a 33228078Sphilip system call by examining the previous instruction. If so, then the 34227569Sphilip return PC is actually at SP+4 because system calls use a different 35227569Sphilip calling sequence. */ 36227569Sphilip 37227569Sphilipstatic CORE_ADDR 38227569Sphilipi386lynx_saved_pc_after_call (struct frame_info *frame) 39227569Sphilip{ 40227569Sphilip char opcode[7]; 41227569Sphilip static const unsigned char call_inst[] = 42227569Sphilip { 0x9a, 0, 0, 0, 0, 8, 0 }; /* lcall 0x8,0x0 */ 43227569Sphilip 44227569Sphilip read_memory_nobpt (frame->pc - 7, opcode, 7); 45227569Sphilip if (memcmp (opcode, call_inst, 7) == 0) 46227569Sphilip return read_memory_unsigned_integer (read_register (SP_REGNUM) + 4, 4); 47227569Sphilip 48227569Sphilip return read_memory_unsigned_integer (read_register (SP_REGNUM), 4); 49227569Sphilip} 50227569Sphilip 51227569Sphilip 52227569Sphilip/* LynxOS. */ 53227569Sphilipstatic void 54227569Sphilipi386lynx_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) 55227569Sphilip{ 56227569Sphilip set_gdbarch_deprecated_saved_pc_after_call (gdbarch, i386lynx_saved_pc_after_call); 57227569Sphilip} 58227569Sphilip 59227569Sphilip 60227569Sphilipstatic enum gdb_osabi 61227569Sphilipi386lynx_coff_osabi_sniffer (bfd *abfd) 62283514Sarybchik{ 63227569Sphilip if (strcmp (bfd_get_target (abfd), "coff-i386-lynx") == 0) 64227569Sphilip return GDB_OSABI_LYNXOS; 65227569Sphilip 66227569Sphilip return GDB_OSABI_UNKNOWN; 67227569Sphilip} 68227569Sphilip 69227569Sphilip 70227569Sphilip/* Provide a prototype to silence -Wmissing-prototypes. */ 71227569Sphilipvoid _initialize_i386lynx_tdep (void); 72227569Sphilip 73227569Sphilipvoid 74227569Sphilip_initialize_i386lynx_tdep (void) 75227569Sphilip{ 76227569Sphilip gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour, 77227569Sphilip i386lynx_coff_osabi_sniffer); 78227569Sphilip 79283514Sarybchik gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LYNXOS, 80227569Sphilip i386lynx_init_abi); 81227569Sphilip} 82227569Sphilip