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

Global variables defined

Functions defined

Macros defined

Source code

  1. /* GNU/Linux/m32r specific low level interface, for the remote server for GDB.
  2.    Copyright (C) 2005-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. #ifdef HAVE_SYS_REG_H
  17. #include <sys/reg.h>
  18. #endif

  19. /* Defined in auto-generated file reg-m32r.c.  */
  20. void init_registers_m32r (void);
  21. extern const struct target_desc *tdesc_m32r;

  22. #define m32r_num_regs 25

  23. static int m32r_regmap[] = {
  24. #ifdef PT_R0
  25.   PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
  26.   PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_FP, PT_LR, PT_SPU,
  27.   PT_PSW, PT_CBR, PT_SPI, PT_SPU, PT_BPC, PT_PC, PT_ACCL, PT_ACCH, PT_EVB
  28. #else
  29.   4 * 4, 4 * 5, 4 * 6, 4 * 7, 4 * 0, 4 * 1, 4 * 2, 4 * 8,
  30.   4 * 9, 4 * 10, 4 * 11, 4 * 12, 4 * 13, 4 * 24, 4 * 25, 4 * 23,
  31.   4 * 19, 4 * 31, 4 * 26, 4 * 23, 4 * 20, 4 * 30, 4 * 16, 4 * 15, 4 * 32
  32. #endif
  33. };

  34. static int
  35. m32r_cannot_store_register (int regno)
  36. {
  37.   return (regno >= m32r_num_regs);
  38. }

  39. static int
  40. m32r_cannot_fetch_register (int regno)
  41. {
  42.   return (regno >= m32r_num_regs);
  43. }

  44. static CORE_ADDR
  45. m32r_get_pc (struct regcache *regcache)
  46. {
  47.   unsigned long pc;
  48.   collect_register_by_name (regcache, "pc", &pc);
  49.   if (debug_threads)
  50.     debug_printf ("stop pc is %08lx\n", pc);
  51.   return pc;
  52. }

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

  59. static const unsigned short m32r_breakpoint = 0x10f1;
  60. #define m32r_breakpoint_len 2

  61. static int
  62. m32r_breakpoint_at (CORE_ADDR where)
  63. {
  64.   unsigned short insn;

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

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

  73. static void
  74. m32r_arch_setup (void)
  75. {
  76.   current_process ()->tdesc = tdesc_m32r;
  77. }

  78. static struct usrregs_info m32r_usrregs_info =
  79.   {
  80.     m32r_num_regs,
  81.     m32r_regmap,
  82.   };

  83. static struct regs_info regs_info =
  84.   {
  85.     NULL, /* regset_bitmap */
  86.     &m32r_usrregs_info,
  87.   };

  88. static const struct regs_info *
  89. m32r_regs_info (void)
  90. {
  91.   return &regs_info;
  92. }

  93. struct linux_target_ops the_low_target = {
  94.   m32r_arch_setup,
  95.   m32r_regs_info,
  96.   m32r_cannot_fetch_register,
  97.   m32r_cannot_store_register,
  98.   NULL, /* fetch_register */
  99.   m32r_get_pc,
  100.   m32r_set_pc,
  101.   (const unsigned char *) &m32r_breakpoint,
  102.   m32r_breakpoint_len,
  103.   NULL,
  104.   0,
  105.   m32r_breakpoint_at,
  106. };

  107. void
  108. initialize_low_arch (void)
  109. {
  110.   init_registers_m32r ();
  111. }