gdb/gdbserver/linux-sh-low.c - gdb

Global variables defined

Functions defined

Macros defined

Source code

  1. /* GNU/Linux/SH specific low level interface, for the remote server for GDB.
  2.    Copyright (C) 1995-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 "server.h"
  15. #include "linux-low.h"

  16. /* Defined in auto-generated file reg-sh.c.  */
  17. void init_registers_sh (void);
  18. extern const struct target_desc *tdesc_sh;

  19. #ifdef HAVE_SYS_REG_H
  20. #include <sys/reg.h>
  21. #endif

  22. #include <asm/ptrace.h>

  23. #define sh_num_regs 41

  24. /* Currently, don't check/send MQ.  */
  25. static int sh_regmap[] = {
  26. 0,        4,        8,        12,        16,        20,        24,        28,
  27. 32,        36,        40,        44,        48,        52,        56,        60,

  28. REG_PC*4,   REG_PR*4,   REG_GBR*4,  -1,
  29. REG_MACH*4, REG_MACL*4, REG_SR*4,
  30. REG_FPUL*4, REG_FPSCR*4,

  31. REG_FPREG0*4+0,   REG_FPREG0*4+4,   REG_FPREG0*4+8,   REG_FPREG0*4+12,
  32. REG_FPREG0*4+16,  REG_FPREG0*4+20,  REG_FPREG0*4+24,  REG_FPREG0*4+28,
  33. REG_FPREG0*4+32,  REG_FPREG0*4+36,  REG_FPREG0*4+40,  REG_FPREG0*4+44,
  34. REG_FPREG0*4+48,  REG_FPREG0*4+52,  REG_FPREG0*4+56,  REG_FPREG0*4+60,
  35. };

  36. static int
  37. sh_cannot_store_register (int regno)
  38. {
  39.   return 0;
  40. }

  41. static int
  42. sh_cannot_fetch_register (int regno)
  43. {
  44.   return 0;
  45. }

  46. static CORE_ADDR
  47. sh_get_pc (struct regcache *regcache)
  48. {
  49.   unsigned long pc;
  50.   collect_register_by_name (regcache, "pc", &pc);
  51.   return pc;
  52. }

  53. static void
  54. sh_set_pc (struct regcache *regcache, CORE_ADDR pc)
  55. {
  56.   unsigned long newpc = pc;
  57.   supply_register_by_name (regcache, "pc", &newpc);
  58. }

  59. /* Correct in either endianness, obviously.  */
  60. static const unsigned short sh_breakpoint = 0xc3c3;
  61. #define sh_breakpoint_len 2

  62. static int
  63. sh_breakpoint_at (CORE_ADDR where)
  64. {
  65.   unsigned short insn;

  66.   (*the_target->read_memory) (where, (unsigned char *) &insn, 2);
  67.   if (insn == sh_breakpoint)
  68.     return 1;

  69.   /* If necessary, recognize more trap instructions here.  GDB only uses the
  70.      one.  */
  71.   return 0;
  72. }

  73. /* Provide only a fill function for the general register setps_lgetregs
  74.    will use this for NPTL support.  */

  75. static void sh_fill_gregset (struct regcache *regcache, void *buf)
  76. {
  77.   int i;

  78.   for (i = 0; i < 23; i++)
  79.     if (sh_regmap[i] != -1)
  80.       collect_register (regcache, i, (char *) buf + sh_regmap[i]);
  81. }

  82. static struct regset_info sh_regsets[] = {
  83.   { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL },
  84.   { 0, 0, 0, -1, -1, NULL, NULL }
  85. };

  86. static struct regsets_info sh_regsets_info =
  87.   {
  88.     sh_regsets, /* regsets */
  89.     0, /* num_regsets */
  90.     NULL, /* disabled_regsets */
  91.   };

  92. static struct usrregs_info sh_usrregs_info =
  93.   {
  94.     sh_num_regs,
  95.     sh_regmap,
  96.   };

  97. static struct regs_info regs_info =
  98.   {
  99.     NULL, /* regset_bitmap */
  100.     &sh_usrregs_info,
  101.     &sh_regsets_info
  102.   };

  103. static const struct regs_info *
  104. sh_regs_info (void)
  105. {
  106.   return &regs_info;
  107. }

  108. static void
  109. sh_arch_setup (void)
  110. {
  111.   current_process ()->tdesc = tdesc_sh;
  112. }

  113. struct linux_target_ops the_low_target = {
  114.   sh_arch_setup,
  115.   sh_regs_info,
  116.   sh_cannot_fetch_register,
  117.   sh_cannot_store_register,
  118.   NULL, /* fetch_register */
  119.   sh_get_pc,
  120.   sh_set_pc,
  121.   (const unsigned char *) &sh_breakpoint,
  122.   sh_breakpoint_len,
  123.   NULL,
  124.   0,
  125.   sh_breakpoint_at,
  126. };

  127. void
  128. initialize_low_arch (void)
  129. {
  130.   init_registers_sh ();

  131.   initialize_regsets_info (&sh_regsets_info);
  132. }