GDBserver
|
00001 /* GNU/Linux/m32r specific low level interface, for the remote server for GDB. 00002 Copyright (C) 2005-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 00022 #ifdef HAVE_SYS_REG_H 00023 #include <sys/reg.h> 00024 #endif 00025 00026 /* Defined in auto-generated file reg-m32r.c. */ 00027 void init_registers_m32r (void); 00028 extern const struct target_desc *tdesc_m32r; 00029 00030 #define m32r_num_regs 25 00031 00032 static int m32r_regmap[] = { 00033 #ifdef PT_R0 00034 PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7, 00035 PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_FP, PT_LR, PT_SPU, 00036 PT_PSW, PT_CBR, PT_SPI, PT_SPU, PT_BPC, PT_PC, PT_ACCL, PT_ACCH, PT_EVB 00037 #else 00038 4 * 4, 4 * 5, 4 * 6, 4 * 7, 4 * 0, 4 * 1, 4 * 2, 4 * 8, 00039 4 * 9, 4 * 10, 4 * 11, 4 * 12, 4 * 13, 4 * 24, 4 * 25, 4 * 23, 00040 4 * 19, 4 * 31, 4 * 26, 4 * 23, 4 * 20, 4 * 30, 4 * 16, 4 * 15, 4 * 32 00041 #endif 00042 }; 00043 00044 static int 00045 m32r_cannot_store_register (int regno) 00046 { 00047 return (regno >= m32r_num_regs); 00048 } 00049 00050 static int 00051 m32r_cannot_fetch_register (int regno) 00052 { 00053 return (regno >= m32r_num_regs); 00054 } 00055 00056 static CORE_ADDR 00057 m32r_get_pc (struct regcache *regcache) 00058 { 00059 unsigned long pc; 00060 collect_register_by_name (regcache, "pc", &pc); 00061 if (debug_threads) 00062 fprintf (stderr, "stop pc is %08lx\n", pc); 00063 return pc; 00064 } 00065 00066 static void 00067 m32r_set_pc (struct regcache *regcache, CORE_ADDR pc) 00068 { 00069 unsigned long newpc = pc; 00070 supply_register_by_name (regcache, "pc", &newpc); 00071 } 00072 00073 static const unsigned short m32r_breakpoint = 0x10f1; 00074 #define m32r_breakpoint_len 2 00075 00076 static int 00077 m32r_breakpoint_at (CORE_ADDR where) 00078 { 00079 unsigned short insn; 00080 00081 (*the_target->read_memory) (where, (unsigned char *) &insn, 00082 m32r_breakpoint_len); 00083 if (insn == m32r_breakpoint) 00084 return 1; 00085 00086 /* If necessary, recognize more trap instructions here. GDB only uses the 00087 one. */ 00088 return 0; 00089 } 00090 00091 static void 00092 m32r_arch_setup (void) 00093 { 00094 current_process ()->tdesc = tdesc_m32r; 00095 } 00096 00097 static struct usrregs_info m32r_usrregs_info = 00098 { 00099 m32r_num_regs, 00100 m32r_regmap, 00101 }; 00102 00103 static struct regs_info regs_info = 00104 { 00105 NULL, /* regset_bitmap */ 00106 &m32r_usrregs_info, 00107 }; 00108 00109 static const struct regs_info * 00110 m32r_regs_info (void) 00111 { 00112 return ®s_info; 00113 } 00114 00115 struct linux_target_ops the_low_target = { 00116 m32r_arch_setup, 00117 m32r_regs_info, 00118 m32r_cannot_fetch_register, 00119 m32r_cannot_store_register, 00120 NULL, /* fetch_register */ 00121 m32r_get_pc, 00122 m32r_set_pc, 00123 (const unsigned char *) &m32r_breakpoint, 00124 m32r_breakpoint_len, 00125 NULL, 00126 0, 00127 m32r_breakpoint_at, 00128 }; 00129 00130 void 00131 initialize_low_arch (void) 00132 { 00133 init_registers_m32r (); 00134 }