GDBserver
|
00001 /* GNU/Linux/CRIS specific low level interface, for the remote server for GDB. 00002 Copyright (C) 1995-2013 Free Software Foundation, Inc. 00003 00004 This file is part of GDB. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00018 00019 #include "server.h" 00020 #include "linux-low.h" 00021 #include <sys/ptrace.h> 00022 00023 /* Defined in auto-generated file reg-cris.c. */ 00024 void init_registers_cris (void); 00025 extern const struct target_desc *tdesc_cris; 00026 00027 /* CRISv10 */ 00028 #define cris_num_regs 32 00029 00030 /* Locations need to match <include/asm/arch/ptrace.h>. */ 00031 static int cris_regmap[] = { 00032 15*4, 14*4, 13*4, 12*4, 00033 11*4, 10*4, 9*4, 8*4, 00034 7*4, 6*4, 5*4, 4*4, 00035 3*4, 2*4, 23*4, 19*4, 00036 00037 -1, -1, -1, -1, 00038 -1, 17*4, -1, 16*4, 00039 -1, -1, -1, 18*4, 00040 -1, 17*4, -1, -1 00041 00042 }; 00043 00044 static int 00045 cris_cannot_store_register (int regno) 00046 { 00047 if (cris_regmap[regno] == -1) 00048 return 1; 00049 00050 return (regno >= cris_num_regs); 00051 } 00052 00053 static int 00054 cris_cannot_fetch_register (int regno) 00055 { 00056 if (cris_regmap[regno] == -1) 00057 return 1; 00058 00059 return (regno >= cris_num_regs); 00060 } 00061 00062 extern int debug_threads; 00063 00064 static CORE_ADDR 00065 cris_get_pc (struct regcache *regcache, void) 00066 { 00067 unsigned long pc; 00068 collect_register_by_name (regcache, "pc", &pc); 00069 if (debug_threads) 00070 fprintf (stderr, "stop pc is %08lx\n", pc); 00071 return pc; 00072 } 00073 00074 static void 00075 cris_set_pc (struct regcache *regcache, CORE_ADDR pc) 00076 { 00077 unsigned long newpc = pc; 00078 supply_register_by_name (regcache, "pc", &newpc); 00079 } 00080 00081 static const unsigned short cris_breakpoint = 0xe938; 00082 #define cris_breakpoint_len 2 00083 00084 static int 00085 cris_breakpoint_at (CORE_ADDR where) 00086 { 00087 unsigned short insn; 00088 00089 (*the_target->read_memory) (where, (unsigned char *) &insn, 00090 cris_breakpoint_len); 00091 if (insn == cris_breakpoint) 00092 return 1; 00093 00094 /* If necessary, recognize more trap instructions here. GDB only uses the 00095 one. */ 00096 return 0; 00097 } 00098 00099 /* We only place breakpoints in empty marker functions, and thread locking 00100 is outside of the function. So rather than importing software single-step, 00101 we can just run until exit. */ 00102 static CORE_ADDR 00103 cris_reinsert_addr (void) 00104 { 00105 struct regcache *regcache = get_thread_regcache (current_inferior, 1); 00106 unsigned long pc; 00107 collect_register_by_name (regcache, "srp", &pc); 00108 return pc; 00109 } 00110 00111 static void 00112 cris_arch_setup (void) 00113 { 00114 current_process ()->tdesc = tdesc_cris; 00115 } 00116 00117 static struct usrregs_info cris_usrregs_info = 00118 { 00119 cris_num_regs, 00120 cris_regmap, 00121 }; 00122 00123 static struct regs_info regs_info = 00124 { 00125 NULL, /* regset_bitmap */ 00126 &cris_usrregs_info, 00127 }; 00128 00129 static const struct regs_info * 00130 cris_regs_info (void) 00131 { 00132 return ®s_info; 00133 } 00134 00135 struct linux_target_ops the_low_target = { 00136 cris_arch_setup, 00137 cris_regs_info, 00138 cris_cannot_fetch_register, 00139 cris_cannot_store_register, 00140 NULL, /* fetch_register */ 00141 cris_get_pc, 00142 cris_set_pc, 00143 (const unsigned char *) &cris_breakpoint, 00144 cris_breakpoint_len, 00145 cris_reinsert_addr, 00146 0, 00147 cris_breakpoint_at, 00148 0, 00149 0, 00150 0, 00151 0, 00152 }; 00153 00154 void 00155 initialize_low_arch (void) 00156 { 00157 init_registers_cris (); 00158 }