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

Global variables defined

Functions defined

Macros defined

Source code

  1. /* GNU/Linux/CRIS 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. #include <sys/ptrace.h>

  17. /* Defined in auto-generated file reg-cris.c.  */
  18. void init_registers_cris (void);
  19. extern const struct target_desc *tdesc_cris;

  20. /* CRISv10 */
  21. #define cris_num_regs 32

  22. /* Locations need to match <include/asm/arch/ptrace.h>.  */
  23. static int cris_regmap[] = {
  24.   15*4, 14*4, 13*4, 12*4,
  25.   11*4, 10*4, 9*4, 8*4,
  26.   7*4, 6*4, 5*4, 4*4,
  27.   3*4, 2*4, 23*4, 19*4,

  28.   -1, -1, -1, -1,
  29.   -1, 17*4, -1, 16*4,
  30.   -1, -1, -1, 18*4,
  31.   -1, 17*4, -1, -1

  32. };

  33. static int
  34. cris_cannot_store_register (int regno)
  35. {
  36.   if (cris_regmap[regno] == -1)
  37.     return 1;

  38.   return (regno >= cris_num_regs);
  39. }

  40. static int
  41. cris_cannot_fetch_register (int regno)
  42. {
  43.   if (cris_regmap[regno] == -1)
  44.     return 1;

  45.   return (regno >= cris_num_regs);
  46. }

  47. extern int debug_threads;

  48. static CORE_ADDR
  49. cris_get_pc (struct regcache *regcache, void)
  50. {
  51.   unsigned long pc;
  52.   collect_register_by_name (regcache, "pc", &pc);
  53.   if (debug_threads)
  54.     debug_printf ("stop pc is %08lx\n", pc);
  55.   return pc;
  56. }

  57. static void
  58. cris_set_pc (struct regcache *regcache, CORE_ADDR pc)
  59. {
  60.   unsigned long newpc = pc;
  61.   supply_register_by_name (regcache, "pc", &newpc);
  62. }

  63. static const unsigned short cris_breakpoint = 0xe938;
  64. #define cris_breakpoint_len 2

  65. static int
  66. cris_breakpoint_at (CORE_ADDR where)
  67. {
  68.   unsigned short insn;

  69.   (*the_target->read_memory) (where, (unsigned char *) &insn,
  70.                               cris_breakpoint_len);
  71.   if (insn == cris_breakpoint)
  72.     return 1;

  73.   /* If necessary, recognize more trap instructions here.  GDB only uses the
  74.      one.  */
  75.   return 0;
  76. }

  77. /* We only place breakpoints in empty marker functions, and thread locking
  78.    is outside of the function.  So rather than importing software single-step,
  79.    we can just run until exit.  */
  80. static CORE_ADDR
  81. cris_reinsert_addr (void)
  82. {
  83.   struct regcache *regcache = get_thread_regcache (current_thread, 1);
  84.   unsigned long pc;
  85.   collect_register_by_name (regcache, "srp", &pc);
  86.   return pc;
  87. }

  88. static void
  89. cris_arch_setup (void)
  90. {
  91.   current_process ()->tdesc = tdesc_cris;
  92. }

  93. static struct usrregs_info cris_usrregs_info =
  94.   {
  95.     cris_num_regs,
  96.     cris_regmap,
  97.   };

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

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

  108. struct linux_target_ops the_low_target = {
  109.   cris_arch_setup,
  110.   cris_regs_info,
  111.   cris_cannot_fetch_register,
  112.   cris_cannot_store_register,
  113.   NULL, /* fetch_register */
  114.   cris_get_pc,
  115.   cris_set_pc,
  116.   (const unsigned char *) &cris_breakpoint,
  117.   cris_breakpoint_len,
  118.   cris_reinsert_addr,
  119.   0,
  120.   cris_breakpoint_at,
  121.   0,
  122.   0,
  123.   0,
  124.   0,
  125. };

  126. void
  127. initialize_low_arch (void)
  128. {
  129.   init_registers_cris ();
  130. }