gdb-6.6-bfin-gdbserver.patch 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. --- gdb-6.6/gdb/gdbserver/configure.srv
  2. +++ gdb-6.6/gdb/gdbserver/configure.srv
  3. @@ -23,6 +23,11 @@ case "${target}" in
  4. srv_linux_usrregs=yes
  5. srv_linux_thread_db=yes
  6. ;;
  7. + bfin-*-*) srv_regobj=reg-bfin.o
  8. + srv_tgtobj="linux-low.o linux-bfin-low.o"
  9. + srv_linux_usrregs=yes
  10. + srv_linux_thread_db=yes
  11. + ;;
  12. crisv32-*-linux*) srv_regobj=reg-crisv32.o
  13. srv_tgtobj="linux-low.o linux-crisv32-low.o"
  14. srv_linux_regsets=yes
  15. --- gdb-6.6/gdb/gdbserver/linux-bfin-low.c
  16. +++ gdb-6.6/gdb/gdbserver/linux-bfin-low.c
  17. @@ -0,0 +1,101 @@
  18. +/* GNU/Linux/BFIN specific low level interface, for the remote server for GDB.
  19. +
  20. + Copyright (C) 2005 Free Software Foundation, Inc.
  21. + Contributed by Analog Devices.
  22. +
  23. + This file is part of GDB.
  24. +
  25. + This program is free software; you can redistribute it and/or modify
  26. + it under the terms of the GNU General Public License as published by
  27. + the Free Software Foundation; either version 2 of the License, or
  28. + (at your option) any later version.
  29. +
  30. + This program is distributed in the hope that it will be useful,
  31. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. + GNU General Public License for more details.
  34. +
  35. + You should have received a copy of the GNU General Public License
  36. + along with this program; if not, write to the Free Software
  37. + Foundation, Inc., 51 Franklin Street, Fifth Floor,
  38. + Boston, MA 02110-1301, USA. */
  39. +
  40. +#include "server.h"
  41. +#include "linux-low.h"
  42. +#include <asm/ptrace.h>
  43. +
  44. +static int bfin_regmap[] =
  45. +{
  46. + PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
  47. + PT_P0, PT_P1, PT_P2, PT_P3, PT_P4, PT_P5, PT_USP, PT_FP,
  48. + PT_I0, PT_I1, PT_I2, PT_I3, PT_M0, PT_M1, PT_M2, PT_M3,
  49. + PT_B0, PT_B1, PT_B2, PT_B3, PT_L0, PT_L1, PT_L2, PT_L3,
  50. + PT_A0X, PT_A0W, PT_A1X, PT_A1W, PT_ASTAT, PT_RETS,
  51. + PT_LC0, PT_LT0, PT_LB0, PT_LC1, PT_LT1, PT_LB1,
  52. + -1 /* PT_CYCLES */, -1 /* PT_CYCLES2 */,
  53. + -1 /* PT_USP */, PT_SEQSTAT, PT_SYSCFG, PT_PC, PT_RETX, PT_RETN, PT_RETE,
  54. + PT_PC, -1 /* PT_CC */, PT_TEXT_ADDR, PT_TEXT_END_ADDR, PT_DATA_ADDR,
  55. + PT_FDPIC_EXEC, PT_FDPIC_INTERP,
  56. + PT_IPEND
  57. +};
  58. +
  59. +#define bfin_num_regs (sizeof(bfin_regmap) / sizeof(bfin_regmap[0]))
  60. +
  61. +static int
  62. +bfin_cannot_store_register (int regno)
  63. +{
  64. + return (regno >= bfin_num_regs);
  65. +}
  66. +
  67. +static int
  68. +bfin_cannot_fetch_register (int regno)
  69. +{
  70. + return (regno >= bfin_num_regs);
  71. +}
  72. +
  73. +static CORE_ADDR
  74. +bfin_get_pc ()
  75. +{
  76. + unsigned long pc;
  77. + collect_register_by_name ("pc", &pc);
  78. + return pc;
  79. +}
  80. +
  81. +static void
  82. +bfin_set_pc (CORE_ADDR pc)
  83. +{
  84. + unsigned long newpc = pc;
  85. + supply_register_by_name ("pc", &newpc);
  86. +}
  87. +
  88. +#define bfin_breakpoint_len 2
  89. +static const unsigned char bfin_breakpoint[bfin_breakpoint_len]={0xa1, 0x00};
  90. +
  91. +static int
  92. +bfin_breakpoint_at (CORE_ADDR where)
  93. +{
  94. + unsigned char insn[bfin_breakpoint_len];
  95. +
  96. + read_inferior_memory(where, insn, bfin_breakpoint_len);
  97. + if (insn[0] == bfin_breakpoint[0]
  98. + && insn[1] == bfin_breakpoint[1])
  99. + return 1;
  100. +
  101. + /* If necessary, recognize more trap instructions here. GDB only uses the
  102. + one. */
  103. + return 0;
  104. +}
  105. +
  106. +struct linux_target_ops the_low_target = {
  107. + bfin_num_regs,
  108. + bfin_regmap,
  109. + bfin_cannot_fetch_register,
  110. + bfin_cannot_store_register,
  111. + bfin_get_pc,
  112. + bfin_set_pc,
  113. + bfin_breakpoint,
  114. + bfin_breakpoint_len,
  115. + 0,
  116. + 2,
  117. + bfin_breakpoint_at,
  118. +};
  119. --- gdb-6.6/gdb/gdbserver/linux-low.c
  120. +++ gdb-6.6/gdb/gdbserver/linux-low.c
  121. @@ -1592,6 +1592,10 @@ linux_stopped_data_address (void)
  122. #define PT_TEXT_ADDR 49*4
  123. #define PT_DATA_ADDR 50*4
  124. #define PT_TEXT_END_ADDR 51*4
  125. +#elif defined(BFIN)
  126. +#define PT_TEXT_ADDR 220
  127. +#define PT_TEXT_END_ADDR 224
  128. +#define PT_DATA_ADDR 228
  129. #endif
  130. /* Under uClinux, programs are loaded at non-zero offsets, which we need
  131. --- gdb-6.6/gdb/gdbserver/Makefile.in
  132. +++ gdb-6.6/gdb/gdbserver/Makefile.in
  133. @@ -119,9 +119,9 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/
  134. $(srcdir)/mem-break.c $(srcdir)/proc-service.c $(srcdir)/regcache.c \
  135. $(srcdir)/remote-utils.c $(srcdir)/server.c $(srcdir)/target.c \
  136. $(srcdir)/thread-db.c $(srcdir)/utils.c \
  137. - $(srcdir)/linux-arm-low.c $(srcdir)/linux-cris-low.c \
  138. - $(srcdir)/linux-crisv32-low.c $(srcdir)/linux-i386-low.c \
  139. - $(srcdir)/i387-fp.c \
  140. + $(srcdir)/linux-arm-low.c $(srcdir)/linux-bfin-low.c \
  141. + $(srcdir)/linux-cris-low.c $(srcdir)/linux-crisv32-low.c \
  142. + $(srcdir)/linux-i386-low.c $(srcdir)/i387-fp.c \
  143. $(srcdir)/linux-ia64-low.c $(srcdir)/linux-low.c \
  144. $(srcdir)/linux-m32r-low.c \
  145. $(srcdir)/linux-m68k-low.c $(srcdir)/linux-mips-low.c \
  146. @@ -207,6 +207,7 @@ clean:
  147. rm -f reg-arm.c reg-i386.c reg-ia64.c reg-m32r.c reg-m68k.c reg-mips.c
  148. rm -f reg-ppc.c reg-sh.c reg-spu.c reg-x86-64.c reg-i386-linux.c
  149. rm -f reg-cris.c reg-crisv32.c reg-x86-64-linux.c
  150. + rm -f reg-bfin.c
  151. maintainer-clean realclean distclean: clean
  152. rm -f nm.h tm.h xm.h config.status config.h stamp-h config.log
  153. @@ -272,6 +273,7 @@ linux-low.o: linux-low.c $(linux_low_h)
  154. linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h) \
  155. $(gdb_proc_service_h)
  156. +linux-bfin-low.o: linux-bfin-low.c $(linux_low_h) $(server_h)
  157. linux-cris-low.o: linux-cris-low.c $(linux_low_h) $(server_h)
  158. linux-crisv32-low.o: linux-crisv32-low.c $(linux_low_h) $(server_h)
  159. linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h) \
  160. @@ -294,6 +297,9 @@ spu-low.o: spu-low.c $(server_h)
  161. reg-arm.o : reg-arm.c $(regdef_h)
  162. reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
  163. sh $(regdat_sh) $(srcdir)/../regformats/reg-arm.dat reg-arm.c
  164. +reg-bfin.o : reg-bfin.c $(regdef_h)
  165. +reg-bfin.c : $(srcdir)/../regformats/reg-bfin.dat $(regdat_sh)
  166. + sh $(regdat_sh) $(srcdir)/../regformats/reg-bfin.dat reg-bfin.c
  167. reg-cris.o : reg-cris.c $(regdef_h)
  168. reg-cris.c : $(srcdir)/../regformats/reg-cris.dat $(regdat_sh)
  169. sh $(regdat_sh) $(srcdir)/../regformats/reg-cris.dat reg-cris.c
  170. --- gdb-6.6/gdb/regformats/reg-bfin.dat
  171. +++ gdb-6.6/gdb/regformats/reg-bfin.dat
  172. @@ -0,0 +1,63 @@
  173. +name:bfin
  174. +expedite:pc,sp,fp
  175. +32:r0
  176. +32:r1
  177. +32:r2
  178. +32:r3
  179. +32:r4
  180. +32:r5
  181. +32:r6
  182. +32:r7
  183. +32:p0
  184. +32:p1
  185. +32:p2
  186. +32:p3
  187. +32:p4
  188. +32:p5
  189. +32:sp
  190. +32:fp
  191. +32:i0
  192. +32:i1
  193. +32:i2
  194. +32:i3
  195. +32:m0
  196. +32:m1
  197. +32:m2
  198. +32:m3
  199. +32:b0
  200. +32:b1
  201. +32:b2
  202. +32:b3
  203. +32:l0
  204. +32:l1
  205. +32:l2
  206. +32:l3
  207. +32:a0x
  208. +32:a0w
  209. +32:a1x
  210. +32:a1w
  211. +32:astat
  212. +32:rets
  213. +32:lc0
  214. +32:lt0
  215. +32:lb0
  216. +32:lc1
  217. +32:lt1
  218. +32:lb1
  219. +32:cycles
  220. +32:cycles2
  221. +32:usp
  222. +32:seqstat
  223. +32:syscfg
  224. +32:reti
  225. +32:retx
  226. +32:retn
  227. +32:rete
  228. +32:pc
  229. +32:cc
  230. +32:text_addr
  231. +32:text_end_addr
  232. +32:data_addr
  233. +32:fdpic_exec
  234. +32:fdpic_interp
  235. +32:ipend