2004-04-17 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / gdb / i386ly-tdep.c
CommitLineData
c906108c 1/* Target-dependent code for Intel 386 running LynxOS.
4be87837 2 Copyright 1993, 1996, 2000, 2001, 2002, 2003 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#include "defs.h"
c906108c 22#include "gdbcore.h"
82b47e62 23#include "inferior.h"
4e052eda 24#include "regcache.h"
82b47e62 25#include "target.h"
4be87837 26#include "osabi.h"
82b47e62
MK
27
28#include "i386-tdep.h"
c906108c 29
82b47e62
MK
30/* Return the PC of the caller from the call frame. Assumes the subr
31 prologue has already been executed, and the frame pointer setup.
32 If this is the outermost frame, we check to see if we are in a
33 system call by examining the previous instruction. If so, then the
34 return PC is actually at SP+4 because system calls use a different
35 calling sequence. */
c906108c 36
82b47e62 37static CORE_ADDR
fba45db2 38i386lynx_saved_pc_after_call (struct frame_info *frame)
c906108c
SS
39{
40 char opcode[7];
c5aa993b 41 static const unsigned char call_inst[] =
82b47e62 42 { 0x9a, 0, 0, 0, 0, 8, 0 }; /* lcall 0x8,0x0 */
c906108c 43
82b47e62 44 read_memory_nobpt (frame->pc - 7, opcode, 7);
c906108c 45 if (memcmp (opcode, call_inst, 7) == 0)
82b47e62
MK
46 return read_memory_unsigned_integer (read_register (SP_REGNUM) + 4, 4);
47
48 return read_memory_unsigned_integer (read_register (SP_REGNUM), 4);
49}
50\f
51
52/* LynxOS. */
53static void
54i386lynx_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
55{
6913c89a 56 set_gdbarch_deprecated_saved_pc_after_call (gdbarch, i386lynx_saved_pc_after_call);
82b47e62
MK
57}
58\f
59
60static enum gdb_osabi
61i386lynx_coff_osabi_sniffer (bfd *abfd)
62{
63 if (strcmp (bfd_get_target (abfd), "coff-i386-lynx") == 0)
64 return GDB_OSABI_LYNXOS;
65
66 return GDB_OSABI_UNKNOWN;
67}
68
69\f
70/* Provide a prototype to silence -Wmissing-prototypes. */
71void _initialize_i386lynx_tdep (void);
72
73void
05816f70 74_initialize_i386lynx_tdep (void)
82b47e62
MK
75{
76 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour,
77 i386lynx_coff_osabi_sniffer);
c906108c 78
05816f70 79 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LYNXOS,
82b47e62 80 i386lynx_init_abi);
c906108c 81}
This page took 0.397273 seconds and 4 git commands to generate.