gdb/armbsd-tdep.c - gdb

Global variables defined

Functions defined

Macros defined

Source code

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

  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 "regcache.h"
  17. #include "regset.h"

  18. #include "arm-tdep.h"

  19. /* Core file support.  */

  20. /* Sizeof `struct reg' in <machine/reg.h>.  */
  21. #define ARMBSD_SIZEOF_GREGS        (17 * 4)

  22. /* Sizeof `struct fpreg' in <machine/reg.h.  */
  23. #define ARMBSD_SIZEOF_FPREGS        ((1 + (8 * 3)) * 4)

  24. static int
  25. armbsd_fpreg_offset (int regnum)
  26. {
  27.   if (regnum == ARM_FPS_REGNUM)
  28.     return 0;

  29.   return 4 + (regnum - ARM_F0_REGNUM) * 12;
  30. }

  31. /* Supply register REGNUM from the buffer specified by FPREGS and LEN
  32.    in the floating-point register set REGSET to register cache
  33.    REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */

  34. static void
  35. armbsd_supply_fpregset (const struct regset *regset,
  36.                         struct regcache *regcache,
  37.                         int regnum, const void *fpregs, size_t len)
  38. {
  39.   const gdb_byte *regs = fpregs;
  40.   int i;

  41.   gdb_assert (len >= ARMBSD_SIZEOF_FPREGS);

  42.   for (i = ARM_F0_REGNUM; i <= ARM_FPS_REGNUM; i++)
  43.     {
  44.       if (regnum == i || regnum == -1)
  45.         regcache_raw_supply (regcache, i, regs + armbsd_fpreg_offset (i));
  46.     }
  47. }

  48. /* Supply register REGNUM from the buffer specified by GREGS and LEN
  49.    in the general-purpose register set REGSET to register cache
  50.    REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */

  51. static void
  52. armbsd_supply_gregset (const struct regset *regset,
  53.                        struct regcache *regcache,
  54.                        int regnum, const void *gregs, size_t len)
  55. {
  56.   const gdb_byte *regs = gregs;
  57.   int i;

  58.   gdb_assert (len >= ARMBSD_SIZEOF_GREGS);

  59.   for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
  60.     {
  61.       if (regnum == i || regnum == -1)
  62.         regcache_raw_supply (regcache, i, regs + i * 4);
  63.     }

  64.   if (regnum == ARM_PS_REGNUM || regnum == -1)
  65.     regcache_raw_supply (regcache, i, regs + 16 * 4);

  66.   if (len >= ARMBSD_SIZEOF_GREGS + ARMBSD_SIZEOF_FPREGS)
  67.     {
  68.       regs += ARMBSD_SIZEOF_GREGS;
  69.       len -= ARMBSD_SIZEOF_GREGS;
  70.       armbsd_supply_fpregset (regset, regcache, regnum, regs, len);
  71.     }
  72. }

  73. /* ARM register sets.  */

  74. static const struct regset armbsd_gregset =
  75. {
  76.   NULL,
  77.   armbsd_supply_gregset
  78. };

  79. static const struct regset armbsd_fpregset =
  80. {
  81.   NULL,
  82.   armbsd_supply_fpregset
  83. };

  84. /* Iterate over supported core file register note sections. */

  85. void
  86. armbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
  87.                                      iterate_over_regset_sections_cb *cb,
  88.                                      void *cb_data,
  89.                                      const struct regcache *regcache)
  90. {
  91.   cb (".reg", ARMBSD_SIZEOF_GREGS, &armbsd_gregset, NULL, cb_data);
  92.   cb (".reg2", ARMBSD_SIZEOF_FPREGS, &armbsd_fpregset, NULL, cb_data);
  93. }