gdb/armnbsd-tdep.c - gdb

Global variables defined

Functions defined

Macros defined

Source code

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

  2.    Copyright (C) 2002-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 "osabi.h"

  16. #include "arm-tdep.h"
  17. #include "solib-svr4.h"

  18. /* Description of the longjmp buffer.  */
  19. #define ARM_NBSD_JB_PC 24
  20. #define ARM_NBSD_JB_ELEMENT_SIZE INT_REGISTER_SIZE

  21. /* For compatibility with previous implemenations of GDB on arm/NetBSD,
  22.    override the default little-endian breakpoint.  */
  23. static const gdb_byte arm_nbsd_arm_le_breakpoint[] = {0x11, 0x00, 0x00, 0xe6};
  24. static const gdb_byte arm_nbsd_arm_be_breakpoint[] = {0xe6, 0x00, 0x00, 0x11};
  25. static const gdb_byte arm_nbsd_thumb_le_breakpoint[] = {0xfe, 0xde};
  26. static const gdb_byte arm_nbsd_thumb_be_breakpoint[] = {0xde, 0xfe};

  27. static void
  28. arm_netbsd_init_abi_common (struct gdbarch_info info,
  29.                             struct gdbarch *gdbarch)
  30. {
  31.   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

  32.   tdep->lowest_pc = 0x8000;
  33.   switch (info.byte_order)
  34.     {
  35.     case BFD_ENDIAN_LITTLE:
  36.       tdep->arm_breakpoint = arm_nbsd_arm_le_breakpoint;
  37.       tdep->thumb_breakpoint = arm_nbsd_thumb_le_breakpoint;
  38.       tdep->arm_breakpoint_size = sizeof (arm_nbsd_arm_le_breakpoint);
  39.       tdep->thumb_breakpoint_size = sizeof (arm_nbsd_thumb_le_breakpoint);
  40.       break;

  41.     case BFD_ENDIAN_BIG:
  42.       tdep->arm_breakpoint = arm_nbsd_arm_be_breakpoint;
  43.       tdep->thumb_breakpoint = arm_nbsd_thumb_be_breakpoint;
  44.       tdep->arm_breakpoint_size = sizeof (arm_nbsd_arm_be_breakpoint);
  45.       tdep->thumb_breakpoint_size = sizeof (arm_nbsd_thumb_be_breakpoint);
  46.       break;

  47.     default:
  48.       internal_error (__FILE__, __LINE__,
  49.                       _("arm_gdbarch_init: bad byte order for float format"));
  50.     }

  51.   tdep->jb_pc = ARM_NBSD_JB_PC;
  52.   tdep->jb_elt_size = ARM_NBSD_JB_ELEMENT_SIZE;

  53.   /* Single stepping.  */
  54.   set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
  55. }

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

  61.   arm_netbsd_init_abi_common (info, gdbarch);
  62.   if (tdep->fp_model == ARM_FLOAT_AUTO)
  63.     tdep->fp_model = ARM_FLOAT_SOFT_FPA;
  64. }

  65. static void
  66. arm_netbsd_elf_init_abi (struct gdbarch_info info,
  67.                          struct gdbarch *gdbarch)
  68. {
  69.   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

  70.   arm_netbsd_init_abi_common (info, gdbarch);
  71.   if (tdep->fp_model == ARM_FLOAT_AUTO)
  72.     tdep->fp_model = ARM_FLOAT_SOFT_VFP;

  73.   /* NetBSD ELF uses SVR4-style shared libraries.  */
  74.   set_solib_svr4_fetch_link_map_offsets
  75.     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
  76. }

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

  82.   return GDB_OSABI_UNKNOWN;
  83. }

  84. /* Provide a prototype to silence -Wmissing-prototypes.  */
  85. extern initialize_file_ftype _initialize_arm_netbsd_tdep;

  86. void
  87. _initialize_arm_netbsd_tdep (void)
  88. {
  89.   gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_aout_flavour,
  90.                                   arm_netbsd_aout_osabi_sniffer);

  91.   gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_NETBSD_AOUT,
  92.                           arm_netbsd_aout_init_abi);
  93.   gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_NETBSD_ELF,
  94.                           arm_netbsd_elf_init_abi);
  95. }