gdb/shnbsd-tdep.c - gdb

Global variables defined

Functions defined

Macros defined

Source code

  1. /* Target-dependent code for NetBSD/sh.

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

  3.    Contributed by Wasabi Systems, Inc.

  4.    This file is part of GDB.

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

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

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

  15. #include "defs.h"
  16. #include "gdbcore.h"
  17. #include "regset.h"
  18. #include "value.h"
  19. #include "osabi.h"

  20. #include "sh-tdep.h"
  21. #include "solib-svr4.h"

  22. /* Convert a register number into an offset into a ptrace
  23.    register structure.  */
  24. static const struct sh_corefile_regmap regmap[] =
  25. {
  26.   {R0_REGNUM,      20 * 4},
  27.   {R0_REGNUM + 119 * 4},
  28.   {R0_REGNUM + 218 * 4},
  29.   {R0_REGNUM + 317 * 4},
  30.   {R0_REGNUM + 416 * 4},
  31.   {R0_REGNUM + 515 * 4},
  32.   {R0_REGNUM + 614 * 4},
  33.   {R0_REGNUM + 713 * 4},
  34.   {R0_REGNUM + 812 * 4},
  35.   {R0_REGNUM + 911 * 4},
  36.   {R0_REGNUM + 10, 10 * 4},
  37.   {R0_REGNUM + 119 * 4},
  38.   {R0_REGNUM + 128 * 4},
  39.   {R0_REGNUM + 137 * 4},
  40.   {R0_REGNUM + 146 * 4},
  41.   {R0_REGNUM + 155 * 4},
  42.   {PC_REGNUM,       0 * 4},
  43.   {SR_REGNUM,       1 * 4},
  44.   {PR_REGNUM,            2 * 4},
  45.   {MACH_REGNUM,            3 * 4},
  46.   {MACL_REGNUM,            4 * 4},
  47.   {-1 /* Terminator.  */, 0}
  48. };


  49. static void
  50. shnbsd_init_abi (struct gdbarch_info info,
  51.                   struct gdbarch *gdbarch)
  52. {
  53.   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

  54.   tdep->core_gregmap = (struct sh_corefile_regmap *)regmap;
  55.   tdep->sizeof_gregset = 84;

  56.   set_solib_svr4_fetch_link_map_offsets
  57.     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
  58. }


  59. /* OpenBSD uses uses the traditional NetBSD core file format, even for
  60.    ports that use ELF.  */
  61. #define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF

  62. static enum gdb_osabi
  63. shnbsd_core_osabi_sniffer (bfd *abfd)
  64. {
  65.   if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
  66.     return GDB_OSABI_NETBSD_CORE;

  67.   return GDB_OSABI_UNKNOWN;
  68. }

  69. /* Provide a prototype to silence -Wmissing-prototypes.  */
  70. extern initialize_file_ftype _initialize_shnbsd_tdep;

  71. void
  72. _initialize_shnbsd_tdep (void)
  73. {
  74.   /* BFD doesn't set a flavour for NetBSD style a.out core files.  */
  75.   gdbarch_register_osabi_sniffer (bfd_arch_sh, bfd_target_unknown_flavour,
  76.                                   shnbsd_core_osabi_sniffer);

  77.   gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_NETBSD_ELF,
  78.                           shnbsd_init_abi);
  79.   gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_OPENBSD_ELF,
  80.                           shnbsd_init_abi);
  81. }