gdb/alphafbsd-tdep.c - gdb

Global variables defined

Functions defined

Source code

  1. /* Target-dependent code for FreeBSD/alpha.

  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 "value.h"
  16. #include "osabi.h"

  17. #include "alpha-tdep.h"
  18. #include "solib-svr4.h"

  19. static int
  20. alphafbsd_return_in_memory (struct type *type)
  21. {
  22.   enum type_code code;
  23.   int i;

  24.   /* All aggregate types that won't fit in a register must be returned
  25.      in memory.  */
  26.   if (TYPE_LENGTH (type) > ALPHA_REGISTER_SIZE)
  27.     return 1;

  28.   /* The only aggregate types that can be returned in a register are
  29.      structs and unions.  Arrays must be returned in memory.  */
  30.   code = TYPE_CODE (type);
  31.   if (code != TYPE_CODE_STRUCT && code != TYPE_CODE_UNION)
  32.     return 1;

  33.   /* We need to check if this struct/union is "integer" like.  For
  34.      this to be true, the offset of each adressable subfield must be
  35.      zero.  Note that bit fields are not addressable.  */
  36.   for (i = 0; i < TYPE_NFIELDS (type); i++)
  37.     {
  38.       /* If the field bitsize is non-zero, it isn't adressable.  */
  39.       if (TYPE_FIELD_BITPOS (type, i) != 0
  40.           && TYPE_FIELD_BITSIZE (type, i) == 0)
  41.         return 1;
  42.     }

  43.   return 0;
  44. }


  45. /* Support for signal handlers.  */

  46. /* Return whether PC is in a BSD sigtramp routine.  */

  47. CORE_ADDR alphafbsd_sigtramp_start = 0x11ffff68;
  48. CORE_ADDR alphafbsd_sigtramp_end = 0x11ffffe0;

  49. static int
  50. alphafbsd_pc_in_sigtramp (struct gdbarch *gdbarch,
  51.                           CORE_ADDR pc, const char *func_name)
  52. {
  53.   return (pc >= alphafbsd_sigtramp_start && pc < alphafbsd_sigtramp_end);
  54. }

  55. static LONGEST
  56. alphafbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
  57. {
  58.   return pc - alphafbsd_sigtramp_start;
  59. }

  60. /* Assuming THIS_FRAME is the frame of a BSD sigtramp routine,
  61.    return the address of the associated sigcontext structure.  */

  62. static CORE_ADDR
  63. alphafbsd_sigcontext_addr (struct frame_info *this_frame)
  64. {
  65.   return get_frame_register_unsigned (this_frame, ALPHA_SP_REGNUM) + 24;
  66. }

  67. /* FreeBSD 5.0-RELEASE or later.  */

  68. static void
  69. alphafbsd_init_abi (struct gdbarch_info info,
  70.                     struct gdbarch *gdbarch)
  71. {
  72.   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

  73.   /* FIXME: Should activate generic FreeBSD support here with
  74.      fbsd_init_abi(), but this requires a valid
  75.      'iterate_over_regset_sections' gdbarch method and
  76.      'collect_regset' functions for each regset.  */

  77.   /* Hook into the DWARF CFI frame unwinder.  */
  78.   alpha_dwarf2_init_abi (info, gdbarch);

  79.   /* Hook into the MDEBUG frame unwinder.  */
  80.   alpha_mdebug_init_abi (info, gdbarch);

  81.   /* FreeBSD/alpha has SVR4-style shared libraries.  */
  82.   set_solib_svr4_fetch_link_map_offsets
  83.     (gdbarch, svr4_lp64_fetch_link_map_offsets);

  84.   tdep->dynamic_sigtramp_offset = alphafbsd_sigtramp_offset;
  85.   tdep->sigcontext_addr = alphafbsd_sigcontext_addr;
  86.   tdep->pc_in_sigtramp = alphafbsd_pc_in_sigtramp;
  87.   tdep->return_in_memory = alphafbsd_return_in_memory;
  88.   tdep->sc_pc_offset = 288;
  89.   tdep->sc_regs_offset = 24;
  90.   tdep->sc_fpregs_offset = 320;

  91.   tdep->jb_pc = 2;
  92.   tdep->jb_elt_size = 8;
  93. }


  94. /* Provide a prototype to silence -Wmissing-prototypes.  */
  95. void _initialize_alphafbsd_tdep (void);

  96. void
  97. _initialize_alphafbsd_tdep (void)
  98. {
  99.   gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_FREEBSD_ELF,
  100.                           alphafbsd_init_abi);
  101. }