gdb/i386bsd-tdep.c - gdb

Global variables defined

Functions defined

Source code

  1. /* Target-dependent code for i386 BSD's.

  2.    Copyright (C) 2001-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "arch-utils.h"
  16. #include "frame.h"
  17. #include "gdbcore.h"
  18. #include "regcache.h"
  19. #include "osabi.h"

  20. #include "i386-tdep.h"

  21. /* Support for signal handlers.  */

  22. /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
  23.    address of the associated sigcontext structure.  */

  24. static CORE_ADDR
  25. i386bsd_sigcontext_addr (struct frame_info *this_frame)
  26. {
  27.   struct gdbarch *gdbarch = get_frame_arch (this_frame);
  28.   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  29.   gdb_byte buf[4];
  30.   CORE_ADDR sp;

  31.   get_frame_register (this_frame, I386_ESP_REGNUM, buf);
  32.   sp = extract_unsigned_integer (buf, 4, byte_order);

  33.   return read_memory_unsigned_integer (sp + 8, 4, byte_order);
  34. }


  35. /* Support for shared libraries.  */

  36. /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD).  */

  37. /* From <machine/signal.h>.  */
  38. int i386bsd_sc_reg_offset[] =
  39. {
  40.   -1,                                /* %eax */
  41.   -1,                                /* %ecx */
  42.   -1,                                /* %edx */
  43.   -1,                                /* %ebx */
  44.   8 + 0 * 4,                        /* %esp */
  45.   8 + 1 * 4,                        /* %ebp */
  46.   -1,                                /* %esi */
  47.   -1,                                /* %edi */
  48.   8 + 3 * 4,                        /* %eip */
  49.   8 + 4 * 4,                        /* %eflags */
  50.   -1,                                /* %cs */
  51.   -1,                                /* %ss */
  52.   -1,                                /* %ds */
  53.   -1,                                /* %es */
  54.   -1,                                /* %fs */
  55.   -1                                /* %gs */
  56. };

  57. void
  58. i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  59. {
  60.   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

  61.   tdep->jb_pc_offset = 0;

  62.   tdep->sigtramp_start = 0xfdbfdfc0;
  63.   tdep->sigtramp_end = 0xfdbfe000;
  64.   tdep->sigcontext_addr = i386bsd_sigcontext_addr;
  65.   tdep->sc_reg_offset = i386bsd_sc_reg_offset;
  66.   tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset);
  67. }


  68. static enum gdb_osabi
  69. i386bsd_aout_osabi_sniffer (bfd *abfd)
  70. {
  71.   if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0)
  72.     return GDB_OSABI_NETBSD_AOUT;

  73.   if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0)
  74.     return GDB_OSABI_FREEBSD_AOUT;

  75.   return GDB_OSABI_UNKNOWN;
  76. }

  77. static enum gdb_osabi
  78. i386bsd_core_osabi_sniffer (bfd *abfd)
  79. {
  80.   if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
  81.     return GDB_OSABI_NETBSD_AOUT;

  82.   return GDB_OSABI_UNKNOWN;
  83. }


  84. /* Provide a prototype to silence -Wmissing-prototypes.  */
  85. void _initialize_i386bsd_tdep (void);

  86. void
  87. _initialize_i386bsd_tdep (void)
  88. {
  89.   gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
  90.                                   i386bsd_aout_osabi_sniffer);

  91.   /* BFD doesn't set a flavour for NetBSD style a.out core files.  */
  92.   gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_unknown_flavour,
  93.                                   i386bsd_core_osabi_sniffer);
  94. }