| 1 |
1181 |
sfurman |
/* Target-dependent code for OpenBSD/i386.
|
| 2 |
|
|
Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001, 2002
|
| 3 |
|
|
Free Software Foundation, Inc.
|
| 4 |
|
|
|
| 5 |
|
|
This file is part of GDB.
|
| 6 |
|
|
|
| 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.
|
| 11 |
|
|
|
| 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.
|
| 16 |
|
|
|
| 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. */
|
| 21 |
|
|
|
| 22 |
|
|
#include "defs.h"
|
| 23 |
|
|
#include "arch-utils.h"
|
| 24 |
|
|
#include "gdbcore.h"
|
| 25 |
|
|
#include "regcache.h"
|
| 26 |
|
|
|
| 27 |
|
|
#include "i386-tdep.h"
|
| 28 |
|
|
#include "i387-tdep.h"
|
| 29 |
|
|
|
| 30 |
|
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
| 31 |
|
|
void _initialize_i386obsd_tdep (void);
|
| 32 |
|
|
|
| 33 |
|
|
#define SIZEOF_STRUCT_REG (16 * 4)
|
| 34 |
|
|
|
| 35 |
|
|
static void
|
| 36 |
|
|
i386obsd_supply_reg (char *regs, int regno)
|
| 37 |
|
|
{
|
| 38 |
|
|
int i;
|
| 39 |
|
|
|
| 40 |
|
|
for (i = 0; i <= 15; i++)
|
| 41 |
|
|
if (regno == i || regno == -1)
|
| 42 |
|
|
supply_register (i, regs + i * 4);
|
| 43 |
|
|
}
|
| 44 |
|
|
|
| 45 |
|
|
static void
|
| 46 |
|
|
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
|
| 47 |
|
|
CORE_ADDR ignore)
|
| 48 |
|
|
{
|
| 49 |
|
|
char *regs, *fsave;
|
| 50 |
|
|
|
| 51 |
|
|
/* We get everything from one section. */
|
| 52 |
|
|
if (which != 0)
|
| 53 |
|
|
return;
|
| 54 |
|
|
|
| 55 |
|
|
if (core_reg_size < (SIZEOF_STRUCT_REG + 108))
|
| 56 |
|
|
{
|
| 57 |
|
|
warning ("Wrong size register set in core file.");
|
| 58 |
|
|
return;
|
| 59 |
|
|
}
|
| 60 |
|
|
|
| 61 |
|
|
regs = core_reg_sect;
|
| 62 |
|
|
fsave = core_reg_sect + SIZEOF_STRUCT_REG;
|
| 63 |
|
|
|
| 64 |
|
|
/* Integer registers. */
|
| 65 |
|
|
i386obsd_supply_reg (regs, -1);
|
| 66 |
|
|
|
| 67 |
|
|
/* Floating point registers. */
|
| 68 |
|
|
i387_supply_fsave (fsave);
|
| 69 |
|
|
}
|
| 70 |
|
|
|
| 71 |
|
|
static struct core_fns i386obsd_core_fns =
|
| 72 |
|
|
{
|
| 73 |
|
|
bfd_target_unknown_flavour, /* core_flavour */
|
| 74 |
|
|
default_check_format, /* check_format */
|
| 75 |
|
|
default_core_sniffer, /* core_sniffer */
|
| 76 |
|
|
fetch_core_registers, /* core_read_registers */
|
| 77 |
|
|
NULL /* next */
|
| 78 |
|
|
};
|
| 79 |
|
|
|
| 80 |
|
|
|
| 81 |
|
|
CORE_ADDR i386obsd_sigtramp_start = 0xbfbfdf20;
|
| 82 |
|
|
CORE_ADDR i386obsd_sigtramp_end = 0xbfbfdff0;
|
| 83 |
|
|
|
| 84 |
|
|
/* From <machine/signal.h>. */
|
| 85 |
|
|
int i386obsd_sc_pc_offset = 44;
|
| 86 |
|
|
int i386obsd_sc_sp_offset = 56;
|
| 87 |
|
|
|
| 88 |
|
|
static void
|
| 89 |
|
|
i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
| 90 |
|
|
{
|
| 91 |
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
| 92 |
|
|
|
| 93 |
|
|
/* Obviously OpenBSD is BSD-based. */
|
| 94 |
|
|
i386bsd_init_abi (info, gdbarch);
|
| 95 |
|
|
|
| 96 |
|
|
/* OpenBSD uses -freg-struct-return by default. */
|
| 97 |
|
|
tdep->struct_return = reg_struct_return;
|
| 98 |
|
|
|
| 99 |
|
|
/* OpenBSD uses a different memory layout. */
|
| 100 |
|
|
tdep->sigtramp_start = i386obsd_sigtramp_start;
|
| 101 |
|
|
tdep->sigtramp_end = i386obsd_sigtramp_end;
|
| 102 |
|
|
|
| 103 |
|
|
/* OpenBSD has a `struct sigcontext' that's different from the
|
| 104 |
|
|
origional 4.3 BSD. */
|
| 105 |
|
|
tdep->sc_pc_offset = i386obsd_sc_pc_offset;
|
| 106 |
|
|
tdep->sc_sp_offset = i386obsd_sc_sp_offset;
|
| 107 |
|
|
}
|
| 108 |
|
|
|
| 109 |
|
|
void
|
| 110 |
|
|
_initialize_i386obsd_tdep (void)
|
| 111 |
|
|
{
|
| 112 |
|
|
add_core_fns (&i386obsd_core_fns);
|
| 113 |
|
|
|
| 114 |
|
|
/* FIXME: kettenis/20021020: Since OpenBSD/i386 binaries are
|
| 115 |
|
|
indistingushable from NetBSD/i386 a.out binaries, building a GDB
|
| 116 |
|
|
that should support both these targets will probably not work as
|
| 117 |
|
|
expected. */
|
| 118 |
|
|
#define GDB_OSABI_OPENBSD_AOUT GDB_OSABI_NETBSD_AOUT
|
| 119 |
|
|
|
| 120 |
|
|
gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_OPENBSD_AOUT,
|
| 121 |
|
|
i386obsd_init_abi);
|
| 122 |
|
|
}
|