dccbb60975
This commit includes gdb_assert.h in common-defs.h and removes all other inclusions. gdb/ 2014-08-07 Gary Benson <gbenson@redhat.com> * common/common-defs.h: Include gdb_assert.h. * aarch64-tdep.c: Do not include gdb_assert.h. * addrmap.c: Likewise. * aix-thread.c: Likewise. * alpha-linux-tdep.c: Likewise. * alpha-mdebug-tdep.c: Likewise. * alphanbsd-tdep.c: Likewise. * amd64-nat.c: Likewise. * amd64-tdep.c: Likewise. * amd64bsd-nat.c: Likewise. * amd64fbsd-nat.c: Likewise. * amd64fbsd-tdep.c: Likewise. * amd64nbsd-nat.c: Likewise. * amd64nbsd-tdep.c: Likewise. * amd64obsd-nat.c: Likewise. * amd64obsd-tdep.c: Likewise. * arch-utils.c: Likewise. * arm-tdep.c: Likewise. * armbsd-tdep.c: Likewise. * auxv.c: Likewise. * bcache.c: Likewise. * bfin-tdep.c: Likewise. * blockframe.c: Likewise. * breakpoint.c: Likewise. * bsd-kvm.c: Likewise. * bsd-uthread.c: Likewise. * buildsym.c: Likewise. * c-exp.y: Likewise. * c-lang.c: Likewise. * charset.c: Likewise. * cleanups.c: Likewise. * cli-out.c: Likewise. * cli/cli-decode.c: Likewise. * cli/cli-dump.c: Likewise. * cli/cli-logging.c: Likewise. * cli/cli-script.c: Likewise. * cli/cli-utils.c: Likewise. * coffread.c: Likewise. * common/common-utils.c: Likewise. * common/queue.h: Likewise. * common/signals.c: Likewise. * common/vec.h: Likewise. * complaints.c: Likewise. * completer.c: Likewise. * corelow.c: Likewise. * cp-abi.c: Likewise. * cp-name-parser.y: Likewise. * cp-namespace.c: Likewise. * cp-support.c: Likewise. * cris-tdep.c: Likewise. * dbxread.c: Likewise. * dictionary.c: Likewise. * doublest.c: Likewise. * dsrec.c: Likewise. * dummy-frame.c: Likewise. * dwarf2-frame-tailcall.c: Likewise. * dwarf2-frame.c: Likewise. * dwarf2expr.c: Likewise. * dwarf2loc.c: Likewise. * dwarf2read.c: Likewise. * eval.c: Likewise. * event-loop.c: Likewise. * exceptions.c: Likewise. * expprint.c: Likewise. * f-valprint.c: Likewise. * fbsd-nat.c: Likewise. * findvar.c: Likewise. * frame-unwind.c: Likewise. * frame.c: Likewise. * frv-tdep.c: Likewise. * gcore.c: Likewise. * gdb-dlfcn.c: Likewise. * gdb_bfd.c: Likewise. * gdbarch.c: Likewise. * gdbarch.sh: Likewise. * gdbtypes.c: Likewise. * gnu-nat.c: Likewise. * gnu-v3-abi.c: Likewise. * go-lang.c: Likewise. * guile/scm-exception.c: Likewise. * guile/scm-gsmob.c: Likewise. * guile/scm-lazy-string.c: Likewise. * guile/scm-math.c: Likewise. * guile/scm-pretty-print.c: Likewise. * guile/scm-safe-call.c: Likewise. * guile/scm-utils.c: Likewise. * guile/scm-value.c: Likewise. * h8300-tdep.c: Likewise. * hppa-hpux-nat.c: Likewise. * hppa-tdep.c: Likewise. * hppanbsd-tdep.c: Likewise. * hppaobsd-tdep.c: Likewise. * i386-darwin-nat.c: Likewise. * i386-darwin-tdep.c: Likewise. * i386-nto-tdep.c: Likewise. * i386-tdep.c: Likewise. * i386bsd-nat.c: Likewise. * i386fbsd-tdep.c: Likewise. * i386gnu-nat.c: Likewise. * i386nbsd-tdep.c: Likewise. * i386obsd-tdep.c: Likewise. * i387-tdep.c: Likewise. * ia64-libunwind-tdep.c: Likewise. * ia64-tdep.c: Likewise. * inf-ptrace.c: Likewise. * inf-ttrace.c: Likewise. * infcall.c: Likewise. * infcmd.c: Likewise. * infrun.c: Likewise. * inline-frame.c: Likewise. * interps.c: Likewise. * jv-lang.c: Likewise. * jv-typeprint.c: Likewise. * linux-fork.c: Likewise. * linux-nat.c: Likewise. * linux-thread-db.c: Likewise. * m32c-tdep.c: Likewise. * m32r-linux-nat.c: Likewise. * m32r-tdep.c: Likewise. * m68k-tdep.c: Likewise. * m68kbsd-nat.c: Likewise. * m68kbsd-tdep.c: Likewise. * m88k-tdep.c: Likewise. * machoread.c: Likewise. * macroexp.c: Likewise. * macrotab.c: Likewise. * maint.c: Likewise. * mdebugread.c: Likewise. * memory-map.c: Likewise. * mep-tdep.c: Likewise. * mi/mi-common.c: Likewise. * microblaze-tdep.c: Likewise. * mingw-hdep.c: Likewise. * mips-linux-nat.c: Likewise. * mips-linux-tdep.c: Likewise. * mips-tdep.c: Likewise. * mips64obsd-tdep.c: Likewise. * mipsnbsd-tdep.c: Likewise. * mn10300-linux-tdep.c: Likewise. * mn10300-tdep.c: Likewise. * moxie-tdep.c: Likewise. * mt-tdep.c: Likewise. * nat/linux-btrace.c: Likewise. * nat/linux-osdata.c: Likewise. * nat/linux-ptrace.c: Likewise. * nat/mips-linux-watch.c: Likewise. * nios2-linux-tdep.c: Likewise. * nios2-tdep.c: Likewise. * objc-lang.c: Likewise. * objfiles.c: Likewise. * obsd-nat.c: Likewise. * opencl-lang.c: Likewise. * osabi.c: Likewise. * parse.c: Likewise. * ppc-linux-nat.c: Likewise. * ppc-sysv-tdep.c: Likewise. * ppcfbsd-nat.c: Likewise. * ppcfbsd-tdep.c: Likewise. * ppcnbsd-nat.c: Likewise. * ppcnbsd-tdep.c: Likewise. * ppcobsd-nat.c: Likewise. * ppcobsd-tdep.c: Likewise. * printcmd.c: Likewise. * procfs.c: Likewise. * prologue-value.c: Likewise. * psymtab.c: Likewise. * python/py-lazy-string.c: Likewise. * python/py-value.c: Likewise. * regcache.c: Likewise. * reggroups.c: Likewise. * registry.c: Likewise. * remote-sim.c: Likewise. * remote.c: Likewise. * rs6000-aix-tdep.c: Likewise. * rs6000-tdep.c: Likewise. * s390-linux-tdep.c: Likewise. * score-tdep.c: Likewise. * ser-base.c: Likewise. * ser-mingw.c: Likewise. * sh-tdep.c: Likewise. * sh64-tdep.c: Likewise. * solib-darwin.c: Likewise. * solib-spu.c: Likewise. * solib-svr4.c: Likewise. * source.c: Likewise. * sparc-nat.c: Likewise. * sparc-sol2-tdep.c: Likewise. * sparc-tdep.c: Likewise. * sparc64-sol2-tdep.c: Likewise. * sparc64-tdep.c: Likewise. * sparc64fbsd-tdep.c: Likewise. * sparc64nbsd-tdep.c: Likewise. * sparc64obsd-tdep.c: Likewise. * sparcnbsd-tdep.c: Likewise. * sparcobsd-tdep.c: Likewise. * spu-multiarch.c: Likewise. * spu-tdep.c: Likewise. * stabsread.c: Likewise. * stack.c: Likewise. * symfile.c: Likewise. * symtab.c: Likewise. * target-descriptions.c: Likewise. * target-memory.c: Likewise. * target.c: Likewise. * tic6x-linux-tdep.c: Likewise. * tic6x-tdep.c: Likewise. * tilegx-linux-nat.c: Likewise. * tilegx-tdep.c: Likewise. * top.c: Likewise. * tramp-frame.c: Likewise. * tui/tui-out.c: Likewise. * tui/tui-winsource.c: Likewise. * ui-out.c: Likewise. * user-regs.c: Likewise. * utils.c: Likewise. * v850-tdep.c: Likewise. * valops.c: Likewise. * value.c: Likewise. * varobj.c: Likewise. * vax-nat.c: Likewise. * xml-syscall.c: Likewise. * xml-tdesc.c: Likewise. * xstormy16-tdep.c: Likewise. * xtensa-linux-nat.c: Likewise. * xtensa-tdep.c: Likewise. gdb/gdbserver/ 2014-08-07 Gary Benson <gbenson@redhat.com> * server.h: Do not include gdb_assert.h.
232 lines
6.5 KiB
C
232 lines
6.5 KiB
C
/* Target-dependent code for FreeBSD/i386.
|
||
|
||
Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
||
|
||
This file is part of GDB.
|
||
|
||
This program is free software; you can redistribute it and/or modify
|
||
it under the terms of the GNU General Public License as published by
|
||
the Free Software Foundation; either version 3 of the License, or
|
||
(at your option) any later version.
|
||
|
||
This program is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
GNU General Public License for more details.
|
||
|
||
You should have received a copy of the GNU General Public License
|
||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||
|
||
#include "defs.h"
|
||
#include "arch-utils.h"
|
||
#include "gdbcore.h"
|
||
#include "osabi.h"
|
||
#include "regcache.h"
|
||
|
||
#include "i386-tdep.h"
|
||
#include "i387-tdep.h"
|
||
#include "bsd-uthread.h"
|
||
#include "solib-svr4.h"
|
||
|
||
/* FreeBSD 3.0-RELEASE or later. */
|
||
|
||
/* From <machine/reg.h>. */
|
||
static int i386fbsd_r_reg_offset[] =
|
||
{
|
||
9 * 4, 8 * 4, 7 * 4, 6 * 4, /* %eax, %ecx, %edx, %ebx */
|
||
15 * 4, 4 * 4, /* %esp, %ebp */
|
||
3 * 4, 2 * 4, /* %esi, %edi */
|
||
12 * 4, 14 * 4, /* %eip, %eflags */
|
||
13 * 4, 16 * 4, /* %cs, %ss */
|
||
1 * 4, 0 * 4, -1, -1 /* %ds, %es, %fs, %gs */
|
||
};
|
||
|
||
/* Sigtramp routine location. */
|
||
CORE_ADDR i386fbsd_sigtramp_start_addr = 0xbfbfdf20;
|
||
CORE_ADDR i386fbsd_sigtramp_end_addr = 0xbfbfdff0;
|
||
|
||
/* From <machine/signal.h>. */
|
||
int i386fbsd_sc_reg_offset[] =
|
||
{
|
||
8 + 14 * 4, /* %eax */
|
||
8 + 13 * 4, /* %ecx */
|
||
8 + 12 * 4, /* %edx */
|
||
8 + 11 * 4, /* %ebx */
|
||
8 + 0 * 4, /* %esp */
|
||
8 + 1 * 4, /* %ebp */
|
||
8 + 10 * 4, /* %esi */
|
||
8 + 9 * 4, /* %edi */
|
||
8 + 3 * 4, /* %eip */
|
||
8 + 4 * 4, /* %eflags */
|
||
8 + 7 * 4, /* %cs */
|
||
8 + 8 * 4, /* %ss */
|
||
8 + 6 * 4, /* %ds */
|
||
8 + 5 * 4, /* %es */
|
||
8 + 15 * 4, /* %fs */
|
||
8 + 16 * 4 /* %gs */
|
||
};
|
||
|
||
/* From /usr/src/lib/libc/i386/gen/_setjmp.S. */
|
||
static int i386fbsd_jmp_buf_reg_offset[] =
|
||
{
|
||
-1, /* %eax */
|
||
-1, /* %ecx */
|
||
-1, /* %edx */
|
||
1 * 4, /* %ebx */
|
||
2 * 4, /* %esp */
|
||
3 * 4, /* %ebp */
|
||
4 * 4, /* %esi */
|
||
5 * 4, /* %edi */
|
||
0 * 4 /* %eip */
|
||
};
|
||
|
||
static void
|
||
i386fbsd_supply_uthread (struct regcache *regcache,
|
||
int regnum, CORE_ADDR addr)
|
||
{
|
||
gdb_byte buf[4];
|
||
int i;
|
||
|
||
gdb_assert (regnum >= -1);
|
||
|
||
for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++)
|
||
{
|
||
if (i386fbsd_jmp_buf_reg_offset[i] != -1
|
||
&& (regnum == -1 || regnum == i))
|
||
{
|
||
read_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4);
|
||
regcache_raw_supply (regcache, i, buf);
|
||
}
|
||
}
|
||
}
|
||
|
||
static void
|
||
i386fbsd_collect_uthread (const struct regcache *regcache,
|
||
int regnum, CORE_ADDR addr)
|
||
{
|
||
gdb_byte buf[4];
|
||
int i;
|
||
|
||
gdb_assert (regnum >= -1);
|
||
|
||
for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++)
|
||
{
|
||
if (i386fbsd_jmp_buf_reg_offset[i] != -1
|
||
&& (regnum == -1 || regnum == i))
|
||
{
|
||
regcache_raw_collect (regcache, i, buf);
|
||
write_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4);
|
||
}
|
||
}
|
||
}
|
||
|
||
static void
|
||
i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
||
{
|
||
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
||
|
||
/* Obviously FreeBSD is BSD-based. */
|
||
i386bsd_init_abi (info, gdbarch);
|
||
|
||
/* FreeBSD has a different `struct reg', and reserves some space for
|
||
its FPU emulator in `struct fpreg'. */
|
||
tdep->gregset_reg_offset = i386fbsd_r_reg_offset;
|
||
tdep->gregset_num_regs = ARRAY_SIZE (i386fbsd_r_reg_offset);
|
||
tdep->sizeof_gregset = 18 * 4;
|
||
tdep->sizeof_fpregset = 176;
|
||
|
||
/* FreeBSD uses -freg-struct-return by default. */
|
||
tdep->struct_return = reg_struct_return;
|
||
|
||
/* FreeBSD uses a different memory layout. */
|
||
tdep->sigtramp_start = i386fbsd_sigtramp_start_addr;
|
||
tdep->sigtramp_end = i386fbsd_sigtramp_end_addr;
|
||
|
||
/* FreeBSD has a more complete `struct sigcontext'. */
|
||
tdep->sc_reg_offset = i386fbsd_sc_reg_offset;
|
||
tdep->sc_num_regs = ARRAY_SIZE (i386fbsd_sc_reg_offset);
|
||
|
||
/* FreeBSD provides a user-level threads implementation. */
|
||
bsd_uthread_set_supply_uthread (gdbarch, i386fbsd_supply_uthread);
|
||
bsd_uthread_set_collect_uthread (gdbarch, i386fbsd_collect_uthread);
|
||
}
|
||
|
||
static void
|
||
i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
||
{
|
||
/* It's almost identical to FreeBSD a.out. */
|
||
i386fbsdaout_init_abi (info, gdbarch);
|
||
|
||
/* Except that it uses ELF. */
|
||
i386_elf_init_abi (info, gdbarch);
|
||
|
||
/* FreeBSD ELF uses SVR4-style shared libraries. */
|
||
set_solib_svr4_fetch_link_map_offsets
|
||
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
|
||
}
|
||
|
||
/* FreeBSD 4.0-RELEASE or later. */
|
||
|
||
/* From <machine/reg.h>. */
|
||
static int i386fbsd4_r_reg_offset[] =
|
||
{
|
||
10 * 4, 9 * 4, 8 * 4, 7 * 4, /* %eax, %ecx, %edx, %ebx */
|
||
16 * 4, 5 * 4, /* %esp, %ebp */
|
||
4 * 4, 3 * 4, /* %esi, %edi */
|
||
13 * 4, 15 * 4, /* %eip, %eflags */
|
||
14 * 4, 17 * 4, /* %cs, %ss */
|
||
2 * 4, 1 * 4, 0 * 4, 18 * 4 /* %ds, %es, %fs, %gs */
|
||
};
|
||
|
||
/* From <machine/signal.h>. */
|
||
int i386fbsd4_sc_reg_offset[] =
|
||
{
|
||
20 + 11 * 4, /* %eax */
|
||
20 + 10 * 4, /* %ecx */
|
||
20 + 9 * 4, /* %edx */
|
||
20 + 8 * 4, /* %ebx */
|
||
20 + 17 * 4, /* %esp */
|
||
20 + 6 * 4, /* %ebp */
|
||
20 + 5 * 4, /* %esi */
|
||
20 + 4 * 4, /* %edi */
|
||
20 + 14 * 4, /* %eip */
|
||
20 + 16 * 4, /* %eflags */
|
||
20 + 15 * 4, /* %cs */
|
||
20 + 18 * 4, /* %ss */
|
||
20 + 3 * 4, /* %ds */
|
||
20 + 2 * 4, /* %es */
|
||
20 + 1 * 4, /* %fs */
|
||
20 + 0 * 4 /* %gs */
|
||
};
|
||
|
||
static void
|
||
i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
||
{
|
||
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
||
|
||
/* Inherit stuff from older releases. We assume that FreeBSD
|
||
4.0-RELEASE always uses ELF. */
|
||
i386fbsd_init_abi (info, gdbarch);
|
||
|
||
/* FreeBSD 4.0 introduced a new `struct reg'. */
|
||
tdep->gregset_reg_offset = i386fbsd4_r_reg_offset;
|
||
tdep->gregset_num_regs = ARRAY_SIZE (i386fbsd4_r_reg_offset);
|
||
tdep->sizeof_gregset = 19 * 4;
|
||
|
||
/* FreeBSD 4.0 introduced a new `struct sigcontext'. */
|
||
tdep->sc_reg_offset = i386fbsd4_sc_reg_offset;
|
||
tdep->sc_num_regs = ARRAY_SIZE (i386fbsd4_sc_reg_offset);
|
||
}
|
||
|
||
|
||
/* Provide a prototype to silence -Wmissing-prototypes. */
|
||
void _initialize_i386fbsd_tdep (void);
|
||
|
||
void
|
||
_initialize_i386fbsd_tdep (void)
|
||
{
|
||
gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_FREEBSD_AOUT,
|
||
i386fbsdaout_init_abi);
|
||
gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_FREEBSD_ELF,
|
||
i386fbsd4_init_abi);
|
||
}
|