gdb/armobsd-tdep.c - gdb

Global variables defined

Functions defined

Source code

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

  2.    Copyright (C) 2006-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 "trad-frame.h"
  17. #include "tramp-frame.h"

  18. #include "obsd-tdep.h"
  19. #include "arm-tdep.h"
  20. #include "solib-svr4.h"

  21. /* Signal trampolines.  */

  22. static void
  23. armobsd_sigframe_init (const struct tramp_frame *self,
  24.                        struct frame_info *this_frame,
  25.                        struct trad_frame_cache *cache,
  26.                        CORE_ADDR func)
  27. {
  28.   CORE_ADDR sp, sigcontext_addr, addr;
  29.   int regnum;

  30.   /* We find the appropriate instance of `struct sigcontext' at a
  31.      fixed offset in the signal frame.  */
  32.   sp = get_frame_register_signed (this_frame, ARM_SP_REGNUM);
  33.   sigcontext_addr = sp + 16;

  34.   /* PC.  */
  35.   trad_frame_set_reg_addr (cache, ARM_PC_REGNUM, sigcontext_addr + 76);

  36.   /* GPRs.  */
  37.   for (regnum = ARM_A1_REGNUM, addr = sigcontext_addr + 12;
  38.        regnum <= ARM_LR_REGNUM; regnum++, addr += 4)
  39.     trad_frame_set_reg_addr (cache, regnum, addr);

  40.   trad_frame_set_id (cache, frame_id_build (sp, func));
  41. }

  42. static const struct tramp_frame armobsd_sigframe =
  43. {
  44.   SIGTRAMP_FRAME,
  45.   4,
  46.   {
  47.     { 0xe28d0010, -1 },                /* add     r0, sp, #16 */
  48.     { 0xef000067, -1 },                /* swi     SYS_sigreturn */
  49.     { 0xef000001, -1 },                /* swi     SYS_exit */
  50.     { 0xeafffffc, -1 },                /* b       . - 8 */
  51.     { TRAMP_SENTINEL_INSN, -1 }
  52.   },
  53.   armobsd_sigframe_init
  54. };


  55. /* Override default thumb breakpoints.  */
  56. static const gdb_byte arm_obsd_thumb_le_breakpoint[] = {0xfe, 0xdf};
  57. static const gdb_byte arm_obsd_thumb_be_breakpoint[] = {0xdf, 0xfe};

  58. static void
  59. armobsd_init_abi (struct gdbarch_info info,
  60.                   struct gdbarch *gdbarch)
  61. {
  62.   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

  63.   if (tdep->fp_model == ARM_FLOAT_AUTO)
  64.     tdep->fp_model = ARM_FLOAT_SOFT_VFP;

  65.   tramp_frame_prepend_unwinder (gdbarch, &armobsd_sigframe);

  66.   /* OpenBSD/arm uses SVR4-style shared libraries.  */
  67.   set_solib_svr4_fetch_link_map_offsets
  68.     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
  69.   set_gdbarch_skip_solib_resolver (gdbarch, obsd_skip_solib_resolver);

  70.   tdep->jb_pc = 24;
  71.   tdep->jb_elt_size = 4;

  72.   set_gdbarch_iterate_over_regset_sections
  73.     (gdbarch, armbsd_iterate_over_regset_sections);

  74.   /* OpenBSD/arm uses -fpcc-struct-return by default.  */
  75.   tdep->struct_return = pcc_struct_return;

  76.   /* Single stepping.  */
  77.   set_gdbarch_software_single_step (gdbarch, arm_software_single_step);

  78.   /* Breakpoints.  */
  79.   switch (info.byte_order)
  80.     {
  81.     case BFD_ENDIAN_BIG:
  82.       tdep->thumb_breakpoint = arm_obsd_thumb_be_breakpoint;
  83.       tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_be_breakpoint);
  84.       break;

  85.     case BFD_ENDIAN_LITTLE:
  86.       tdep->thumb_breakpoint = arm_obsd_thumb_le_breakpoint;
  87.       tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_le_breakpoint);
  88.       break;
  89.     }
  90. }


  91. static enum gdb_osabi
  92. armobsd_core_osabi_sniffer (bfd *abfd)
  93. {
  94.   if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
  95.     return GDB_OSABI_OPENBSD_ELF;

  96.   return GDB_OSABI_UNKNOWN;
  97. }

  98. /* Provide a prototype to silence -Wmissing-prototypes.  */
  99. extern initialize_file_ftype _initialize_armobsd_tdep;

  100. void
  101. _initialize_armobsd_tdep (void)
  102. {
  103.   /* BFD doesn't set a flavour for NetBSD style a.out core files.  */
  104.   gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_unknown_flavour,
  105.                                   armobsd_core_osabi_sniffer);

  106.   gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_OPENBSD_ELF,
  107.                           armobsd_init_abi);
  108. }