summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gdb/gdb/renesas-sh-native-support.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gdb/gdb/renesas-sh-native-support.patch')
-rw-r--r--meta/recipes-devtools/gdb/gdb/renesas-sh-native-support.patch1379
1 files changed, 1379 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gdb/gdb/renesas-sh-native-support.patch b/meta/recipes-devtools/gdb/gdb/renesas-sh-native-support.patch
new file mode 100644
index 0000000000..15ff62013e
--- /dev/null
+++ b/meta/recipes-devtools/gdb/gdb/renesas-sh-native-support.patch
@@ -0,0 +1,1379 @@
1Description: Add Renesas SH (sh4) support
2 Add support for Renesas SH (sh4) architecture.
3 .
4 gdb (7.4-1~cvs20111117.2) experimental; urgency=low
5 .
6 * Add Renesas SH (sh4) support (Closes: #576242)
7 - Thanks Nobuhiro Iwamatsu, Takashi Yoshii.
8Author: Hector Oron <zumbi@debian.org>
9Bug-Debian: http://bugs.debian.org/576242
10
11---
12The information above should follow the Patch Tagging Guidelines, please
13checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
14are templates for supplementary fields that you might want to add:
15
16Forwarded: <no|not-needed|url proving that it has been forwarded>
17Last-Update: <2011-11-17>
18
19
20Upstream-Status: Pending
21Signed-off-by: Khem Raj <raj.khem@gmail.com>
22
23Index: gdb-7.5/gdb/configure.host
24===================================================================
25--- gdb-7.5.orig/gdb/configure.host 2012-05-30 12:41:34.000000000 -0700
26+++ gdb-7.5/gdb/configure.host 2012-09-19 14:40:42.974609772 -0700
27@@ -140,6 +140,7 @@
28
29 s390*-*-*) gdb_host=s390 ;;
30
31+sh*-*-linux*) gdb_host=linux ;;
32 sh*-*-netbsdelf* | sh*-*-knetbsd*-gnu)
33 gdb_host=nbsd ;;
34 sh*-*-openbsd*) gdb_host=nbsd ;;
35Index: gdb-7.5/gdb/Makefile.in
36===================================================================
37--- gdb-7.5.orig/gdb/Makefile.in 2012-07-02 08:29:33.000000000 -0700
38+++ gdb-7.5/gdb/Makefile.in 2012-09-19 14:40:42.974609772 -0700
39@@ -1493,6 +1493,7 @@
40 score-tdep.c \
41 ser-go32.c ser-pipe.c ser-tcp.c ser-mingw.c \
42 sh-tdep.c sh64-tdep.c shnbsd-tdep.c shnbsd-nat.c \
43+ sh-linux-tdep.c sh-linux-nat.c \
44 sol2-tdep.c \
45 solib-irix.c solib-svr4.c solib-sunos.c \
46 sparc-linux-nat.c sparc-linux-tdep.c \
47Index: gdb-7.5/gdb/sh-linux-tdep.c
48===================================================================
49--- gdb-7.5.orig/gdb/sh-linux-tdep.c 2012-05-07 06:17:29.000000000 -0700
50+++ gdb-7.5/gdb/sh-linux-tdep.c 2012-09-19 14:46:50.610623784 -0700
51@@ -18,14 +18,37 @@
52 along with this program. If not, see <http://www.gnu.org/licenses/>. */
53
54 #include "defs.h"
55+#include "gdbcore.h"
56+#include "frame.h"
57+#include "frame-base.h"
58+#include "frame-unwind.h"
59+#include "dwarf2-frame.h"
60+#include "value.h"
61+#include "regcache.h"
62+#include "inferior.h"
63 #include "osabi.h"
64
65+#include "reggroups.h"
66+#include "arch-utils.h"
67+#include "floatformat.h"
68 #include "solib-svr4.h"
69 #include "symtab.h"
70+#include "gdb_string.h"
71+#include "command.h"
72+#include "gdb_assert.h"
73
74 #include "trad-frame.h"
75 #include "tramp-frame.h"
76
77+#include <sys/ptrace.h>
78+#include <sys/types.h>
79+#include <sys/param.h>
80+#include <sys/user.h>
81+#include <sys/syscall.h>
82+
83+#include <asm/ptrace.h>
84+
85+#include "regset.h"
86 #include "glibc-tdep.h"
87 #include "sh-tdep.h"
88 #include "linux-tdep.h"
89@@ -180,9 +203,505 @@
90 sh_linux_rt_sigreturn_init
91 };
92
93+/* Recognizing signal handler frames. */
94+
95+/* GNU/Linux has two flavors of signals. Normal signal handlers, and
96+ "realtime" (RT) signals. The RT signals can provide additional
97+ information to the signal handler if the SA_SIGINFO flag is set
98+ when establishing a signal handler using `sigaction'. It is not
99+ unlikely that future versions of GNU/Linux will support SA_SIGINFO
100+ for normal signals too. */
101+
102+/* When the SH Linux kernel calls a signal handler and the
103+ SA_RESTORER flag isn't set, the return address points to a bit of
104+ code on the stack. This function returns whether the PC appears to
105+ be within this bit of code.
106+
107+ The instruction sequence for normal signals is
108+ mov.w 1f,r3
109+ trapa #16
110+ or r0, r0
111+ or r0, r0
112+ or r0, r0
113+ or r0, r0
114+ or r0, r0
115+ 1: .word __NR_sigreturn
116+ or 0x9305 0xc310 0x200b 0x200b 0x200b 0x200b 0x200b 0x0077.
117+
118+ Checking for the code sequence should be somewhat reliable, because
119+ the effect is to call the system call sigreturn. This is unlikely
120+ to occur anywhere other than a signal trampoline.
121+
122+ It kind of sucks that we have to read memory from the process in
123+ order to identify a signal trampoline, but there doesn't seem to be
124+ any other way. The PC_IN_SIGTRAMP macro in tm-linux.h arranges to
125+ only call us if no function name could be identified, which should
126+ be the case since the code is on the stack.
127+
128+ Detection of signal trampolines for handlers that set the
129+ SA_RESTORER flag is in general not possible. Unfortunately this is
130+ what the GNU C Library has been doing for quite some time now.
131+ However, as of version 2.1.2, the GNU C Library uses signal
132+ trampolines (named __restore and __restore_rt) that are identical
133+ to the ones used by the kernel. Therefore, these trampolines are
134+ supported too. */
135+
136+#define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */
137+#define TRAP16 0xc310 /* Syscall w/no args (NR in R3) */
138+#define OR_R0_R0 0x200b /* or r0,r0 (insert to avoid hardware bug) */
139+
140+#define LINUX_SIGTRAMP_INSN0 MOVW(7) /* Move mem word at PC+7 to R3 */
141+#define LINUX_SIGTRAMP_INSN1 TRAP16 /* Syscall w/no args (NR in R3) */
142+#define LINUX_SIGTRAMP_INSN2 OR_R0_R0 /* or r0,r0 (insert to avoid hardware bug) */
143+
144+static const unsigned short linux_sigtramp_code[] =
145+{
146+ LINUX_SIGTRAMP_INSN0,
147+ LINUX_SIGTRAMP_INSN1,
148+ LINUX_SIGTRAMP_INSN2,
149+ LINUX_SIGTRAMP_INSN2,
150+ LINUX_SIGTRAMP_INSN2,
151+ LINUX_SIGTRAMP_INSN2,
152+ LINUX_SIGTRAMP_INSN2,
153+ __NR_sigreturn
154+};
155+
156+#define LINUX_SIGTRAMP_LEN (sizeof linux_sigtramp_code)
157+
158+/* If PC is in a sigtramp routine, return the address of the start of
159+ the routine. Otherwise, return 0. */
160+
161+static CORE_ADDR
162+sh_linux_sigtramp_start (struct frame_info *next_frame)
163+{
164+ CORE_ADDR pc = get_frame_pc (next_frame);
165+ gdb_byte buf[LINUX_SIGTRAMP_LEN];
166+
167+ /* We only recognize a signal trampoline if PC is at the start of
168+ one of the three instructions. We optimize for finding the PC at
169+ the start, as will be the case when the trampoline is not the
170+ first frame on the stack. We assume that in the case where the
171+ PC is not at the start of the instruction sequence, there will be
172+ a few trailing readable bytes on the stack. */
173+
174+ if (!safe_frame_unwind_memory (next_frame, pc, buf, LINUX_SIGTRAMP_LEN))
175+ return 0;
176+
177+ if (buf[0] != LINUX_SIGTRAMP_INSN0)
178+ {
179+ if (buf[0] != LINUX_SIGTRAMP_INSN1)
180+ return 0;
181+
182+ pc -= 2;
183+
184+ if (!safe_frame_unwind_memory (next_frame, pc, buf, LINUX_SIGTRAMP_LEN))
185+ return 0;
186+ }
187+
188+ if (memcmp (buf, linux_sigtramp_code, LINUX_SIGTRAMP_LEN) != 0)
189+ return 0;
190+
191+ return pc;
192+}
193+
194+/* This function does the same for RT signals. Here the instruction
195+ sequence is
196+ mov.w 1f,r3
197+ trapa #16
198+ or r0, r0
199+ or r0, r0
200+ or r0, r0
201+ or r0, r0
202+ or r0, r0
203+ 1: .word __NR_rt_sigreturn
204+ or 0x9305 0xc310 0x200b 0x200b 0x200b 0x200b 0x200b 0x00ad.
205+
206+ The effect is to call the system call rt_sigreturn. */
207+
208+#define LINUX_RT_SIGTRAMP_INSN0 MOVW(7) /* Move mem word at PC+7 to R3 */
209+#define LINUX_RT_SIGTRAMP_INSN1 TRAP16 /* Syscall w/no args (NR in R3) */
210+#define LINUX_RT_SIGTRAMP_INSN2 OR_R0_R0 /* or r0,r0 (insert to avoid hardware bug) */
211+
212+static const unsigned short linux_rt_sigtramp_code[] =
213+{
214+ LINUX_RT_SIGTRAMP_INSN0,
215+ LINUX_RT_SIGTRAMP_INSN1,
216+ LINUX_RT_SIGTRAMP_INSN2,
217+ LINUX_RT_SIGTRAMP_INSN2,
218+ LINUX_RT_SIGTRAMP_INSN2,
219+ LINUX_RT_SIGTRAMP_INSN2,
220+ LINUX_RT_SIGTRAMP_INSN2,
221+ __NR_rt_sigreturn
222+};
223+
224+#define LINUX_RT_SIGTRAMP_LEN (sizeof linux_rt_sigtramp_code)
225+
226+/* If PC is in a RT sigtramp routine, return the address of the start
227+ of the routine. Otherwise, return 0. */
228+
229+static CORE_ADDR
230+sh_linux_rt_sigtramp_start (struct frame_info *next_frame)
231+{
232+ CORE_ADDR pc = get_frame_pc (next_frame);
233+ gdb_byte buf[LINUX_RT_SIGTRAMP_LEN];
234+
235+ /* We only recognize a signal trampoline if PC is at the start of
236+ one of the two instructions. We optimize for finding the PC at
237+ the start, as will be the case when the trampoline is not the
238+ first frame on the stack. We assume that in the case where the
239+ PC is not at the start of the instruction sequence, there will be
240+ a few trailing readable bytes on the stack. */
241+
242+ if (!safe_frame_unwind_memory (next_frame, pc, buf, LINUX_RT_SIGTRAMP_LEN))
243+ return 0;
244+
245+ if (buf[0] != LINUX_RT_SIGTRAMP_INSN0)
246+ {
247+ if (buf[0] != LINUX_RT_SIGTRAMP_INSN1)
248+ return 0;
249+
250+ pc -= 2;
251+
252+ if (!safe_frame_unwind_memory (next_frame, pc, buf,
253+ LINUX_RT_SIGTRAMP_LEN))
254+ return 0;
255+ }
256+
257+ if (memcmp (buf, linux_rt_sigtramp_code, LINUX_RT_SIGTRAMP_LEN) != 0)
258+ return 0;
259+
260+ return pc;
261+}
262+
263+/* Return whether PC is in a GNU/Linux sigtramp routine. */
264+
265+static int
266+sh_linux_sigtramp_p (struct frame_info *this_frame)
267+{
268+ CORE_ADDR pc = get_frame_pc (this_frame);
269+ char *name;
270+
271+ find_pc_partial_function (pc, &name, NULL, NULL);
272+
273+ /* If we have NAME, we can optimize the search. The trampolines are
274+ named __restore and __restore_rt. However, they aren't dynamically
275+ exported from the shared C library, so the trampoline may appear to
276+ be part of the preceding function. This should always be sigaction,
277+ __sigaction, or __libc_sigaction (all aliases to the same function). */
278+ if (name == NULL || strstr (name, "sigaction") != NULL)
279+ return (sh_linux_sigtramp_start (this_frame) != 0
280+ || sh_linux_rt_sigtramp_start (this_frame) != 0);
281+
282+ return (strcmp ("__restore", name) == 0
283+ || strcmp ("__restore_rt", name) == 0);
284+}
285+
286+/* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
287+#define SH_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 12
288+
289+
290+/* Assuming NEXT_FRAME is a frame following a GNU/Linux sigtramp
291+ routine, return the address of the associated sigcontext structure. */
292+
293+static CORE_ADDR
294+sh_linux_sigcontext_addr (struct frame_info *this_frame)
295+{
296+ CORE_ADDR pc;
297+ CORE_ADDR sp;
298+
299+ sp = get_frame_register_unsigned (this_frame, SP_REGNUM);
300+
301+ pc = sh_linux_sigtramp_start (this_frame);
302+ if (pc)
303+ {
304+ return sp;
305+ }
306+
307+ pc = sh_linux_rt_sigtramp_start (this_frame);
308+ if (pc)
309+ {
310+ CORE_ADDR ucontext_addr;
311+
312+ /* The sigcontext structure is part of the user context. A
313+ pointer to the user context is passed as the third argument
314+ to the signal handler. */
315+ ucontext_addr = get_frame_register_unsigned (this_frame, ARG0_REGNUM+2);
316+ return ucontext_addr + SH_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
317+ }
318+
319+ error ("Couldn't recognize signal trampoline.");
320+ return 0;
321+}
322+
323+/* Signal trampolines. */
324+extern struct sh_frame_cache *sh_alloc_frame_cache (void);
325+
326+static struct sh_frame_cache *
327+sh_linux_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
328+{
329+ struct sh_frame_cache *cache;
330+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_current_arch ());
331+ CORE_ADDR sigcontext_addr;
332+
333+ if (*this_cache)
334+ return *this_cache;
335+
336+ cache = sh_alloc_frame_cache ();
337+
338+ cache->base = get_frame_register_unsigned (this_frame, SP_REGNUM);
339+ sigcontext_addr = tdep->sigcontext_addr (this_frame);
340+ if (tdep->sc_reg_offset)
341+ {
342+ int i;
343+
344+ gdb_assert (tdep->sc_num_regs <= SH_NUM_REGS);
345+
346+ for (i = 0; i < tdep->sc_num_regs; i++)
347+ if (tdep->sc_reg_offset[i] != -1)
348+ cache->saved_regs[i] = sigcontext_addr + tdep->sc_reg_offset[i];
349+ }
350+
351+ *this_cache = cache;
352+ return cache;
353+}
354+
355+static void
356+sh_linux_sigtramp_frame_this_id (struct frame_info *this_frame, void **this_cache,
357+ struct frame_id *this_id)
358+{
359+ struct sh_frame_cache *cache =
360+ sh_linux_sigtramp_frame_cache (this_frame, this_cache);
361+
362+ (*this_id) = frame_id_build (cache->base + 64, cache->pc);
363+}
364+
365+extern struct value * sh_frame_prev_register ();
366+static struct value *
367+sh_linux_sigtramp_frame_prev_register (struct frame_info *this_frame,
368+ void **this_cache, int regnum)
369+{
370+ sh_linux_sigtramp_frame_cache (this_frame, this_cache);
371+
372+ return sh_frame_prev_register (this_frame, this_cache, regnum);
373+}
374+
375+static int
376+sh_linux_sigtramp_frame_sniffer (const struct frame_unwind *self,
377+ struct frame_info *this_frame,
378+ void **this_prologue_cache)
379+{
380+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
381+
382+ /* We shouldn't even bother if we don't have a sigcontext_addr
383+ handler. */
384+ if (tdep->sigcontext_addr == NULL)
385+ return 0;
386+
387+ if (tdep->sigtramp_p != NULL)
388+ {
389+ if (tdep->sigtramp_p (this_frame))
390+ return 1;
391+ }
392+
393+ return 0;
394+}
395+
396+static const struct frame_unwind sh_linux_sigtramp_frame_unwind =
397+{
398+ SIGTRAMP_FRAME,
399+ sh_linux_sigtramp_frame_this_id,
400+ sh_linux_sigtramp_frame_prev_register,
401+ NULL,
402+ sh_linux_sigtramp_frame_sniffer
403+};
404+
405+/* Supply register REGNUM from the buffer specified by GREGS and LEN
406+ in the general-purpose register set REGSET to register cache
407+ REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
408+
409+void
410+sh_supply_gregset (const struct regset *regset, struct regcache *regcache,
411+ int regnum, const void *gregs, size_t len)
412+{
413+ const struct gdbarch_tdep *tdep = gdbarch_tdep (regset->arch);
414+ const char *regs = gregs;
415+ int i;
416+
417+ gdb_assert (len == tdep->sizeof_gregset);
418+
419+ for (i = 0; i < tdep->gregset_num_regs; i++)
420+ {
421+ if ((regnum == i || regnum == -1)
422+ && tdep->gregset_reg_offset[i] != -1)
423+ regcache_raw_supply (regcache, i, regs + tdep->gregset_reg_offset[i]);
424+ }
425+}
426+
427+/* Collect register REGNUM from the register cache REGCACHE and store
428+ it in the buffer specified by GREGS and LEN as described by the
429+ general-purpose register set REGSET. If REGNUM is -1, do this for
430+ all registers in REGSET. */
431+
432+void
433+sh_collect_gregset (const struct regset *regset,
434+ const struct regcache *regcache,
435+ int regnum, void *gregs, size_t len)
436+{
437+ const struct gdbarch_tdep *tdep = gdbarch_tdep (regset->arch);
438+ char *regs = gregs;
439+ int i;
440+
441+ gdb_assert (len == tdep->sizeof_gregset);
442+
443+ for (i = 0; i < tdep->gregset_num_regs; i++)
444+ {
445+ if ((regnum == i || regnum == -1)
446+ && tdep->gregset_reg_offset[i] != -1)
447+ regcache_raw_collect (regcache, i, regs + tdep->gregset_reg_offset[i]);
448+ }
449+}
450+
451+/* Supply register REGNUM from the buffer specified by FPREGS and LEN
452+ in the floating-point register set REGSET to register cache
453+ REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
454+
455+static void
456+sh_supply_fpregset (const struct regset *regset, struct regcache *regcache,
457+ int regnum, const void *fpregs, size_t len)
458+{
459+ const struct gdbarch_tdep *tdep = gdbarch_tdep (regset->arch);
460+ const char *regs = fpregs;
461+ int i;
462+
463+ gdb_assert (len == tdep->sizeof_fpregset);
464+ for (i = 0; i < 16; i++)
465+ {
466+ if (regnum == i+25 || regnum == -1)
467+ regcache_raw_supply (regcache, i+25, regs + i*4);
468+ }
469+ if (regnum == FPSCR_REGNUM || regnum == -1)
470+ regcache_raw_supply (regcache, FPSCR_REGNUM, regs + 32*4);
471+ if (regnum == FPUL_REGNUM || regnum == -1)
472+ regcache_raw_supply (regcache, FPUL_REGNUM, regs + 33*4);
473+}
474+
475+/* Collect register REGNUM from the register cache REGCACHE and store
476+ it in the buffer specified by FPREGS and LEN as described by the
477+ floating-point register set REGSET. If REGNUM is -1, do this for
478+ all registers in REGSET. */
479+
480+static void
481+sh_collect_fpregset (const struct regset *regset,
482+ const struct regcache *regcache,
483+ int regnum, void *fpregs, size_t len)
484+{
485+ const struct gdbarch_tdep *tdep = gdbarch_tdep (regset->arch);
486+ char *regs = fpregs;
487+ int i;
488+
489+ gdb_assert (len == tdep->sizeof_fpregset);
490+ for (i = 0; i < 16; i++)
491+ {
492+ if (regnum == i+25 || regnum == -1)
493+ regcache_raw_collect (regcache, i+25, regs + i*4);
494+ }
495+ if (regnum == FPSCR_REGNUM || regnum == -1)
496+ regcache_raw_collect (regcache, FPSCR_REGNUM, regs + 32*4);
497+ if (regnum == FPUL_REGNUM || regnum == -1)
498+ regcache_raw_collect (regcache, FPUL_REGNUM, regs + 33*4);
499+}
500+
501+/* Return the appropriate register set for the core section identified
502+ by SECT_NAME and SECT_SIZE. */
503+
504+const struct regset *
505+sh_linux_regset_from_core_section (struct gdbarch *gdbarch,
506+ const char *sect_name, size_t sect_size)
507+{
508+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
509+
510+ if (strcmp (sect_name, ".reg") == 0 && sect_size == tdep->sizeof_gregset)
511+ {
512+ if (tdep->gregset == NULL)
513+ tdep->gregset = regset_alloc (gdbarch, sh_supply_gregset,
514+ sh_collect_gregset);
515+ return tdep->gregset;
516+ }
517+
518+ if ((strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset))
519+ {
520+ if (tdep->fpregset == NULL)
521+ tdep->fpregset = regset_alloc (gdbarch, sh_supply_fpregset,
522+ sh_collect_fpregset);
523+ return tdep->fpregset;
524+ }
525+
526+ return NULL;
527+}
528+
529+/* The register sets used in GNU/Linux ELF core-dumps are identical to
530+ the register sets in `struct user' that are used for a.out
531+ core-dumps. These are also used by ptrace(2). The corresponding
532+ types are `elf_gregset_t' for the general-purpose registers (with
533+ `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
534+ for the floating-point registers.
535+
536+ Those types used to be available under the names `gregset_t' and
537+ `fpregset_t' too, and GDB used those names in the past. But those
538+ names are now used for the register sets used in the `mcontext_t'
539+ type, which have a different size and layout. */
540+
541+/* Mapping between the general-purpose registers in `struct user'
542+ format and GDB's register cache layout. */
543+
544+/* From <sys/reg.h>. */
545+static int sh_linux_gregset_reg_offset[] =
546+{
547+ 0, 4, 8, 12, 16, 20, 24, 28,
548+ 32, 36, 40, 44, 48, 52, 56, 60,
549+
550+ REG_PC*4, REG_PR*4, REG_GBR*4, -1,
551+ REG_MACH*4, REG_MACL*4, REG_SR*4,
552+};
553+
554+/* Mapping between the general-purpose registers in `struct
555+ sigcontext' format and GDB's register cache layout. */
556+
557+/* From <asm/sigcontext.h>. */
558+static int sh_linux_sc_reg_offset[] =
559+{
560+ 4, 8, 12, 16, 20, 24, 28, 32,
561+ 36, 40, 44, 48, 52, 56, 60, 64,
562+ 68, 72, 80, -1,
563+ 84, 88, 76
564+};
565+
566 static void
567 sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
568 {
569+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
570+ bfd abfd;
571+
572+ tdep->gregset_reg_offset = sh_linux_gregset_reg_offset;
573+ tdep->gregset_num_regs = ARRAY_SIZE (sh_linux_gregset_reg_offset);
574+ tdep->sizeof_gregset = 23 * 4;
575+
576+ tdep->jb_pc_offset = 32; /* From <bits/setjmp.h>. */
577+
578+ tdep->sigtramp_p = sh_linux_sigtramp_p;
579+ tdep->sigcontext_addr = sh_linux_sigcontext_addr;
580+ tdep->sc_reg_offset = sh_linux_sc_reg_offset;
581+ tdep->sc_num_regs = ARRAY_SIZE (sh_linux_sc_reg_offset);
582+
583+ frame_unwind_append_unwinder(gdbarch, &sh_linux_sigtramp_frame_unwind);
584+
585+ /* If we have a register mapping, enable the generic core file
586+ support, unless it has already been enabled. */
587+ if (tdep->gregset_reg_offset
588+ && !gdbarch_regset_from_core_section_p (gdbarch))
589+ set_gdbarch_regset_from_core_section (gdbarch,
590+ sh_linux_regset_from_core_section);
591+
592 linux_init_abi (info, gdbarch);
593
594 /* GNU/Linux uses SVR4-style shared libraries. */
595Index: gdb-7.5/gdb/sh-tdep.h
596===================================================================
597--- gdb-7.5.orig/gdb/sh-tdep.h 2012-03-01 15:55:40.000000000 -0800
598+++ gdb-7.5/gdb/sh-tdep.h 2012-09-19 14:48:32.406627602 -0700
599@@ -21,6 +21,12 @@
600
601 /* Contributed by Steve Chamberlain sac@cygnus.com. */
602
603+struct frame_info;
604+struct gdbarch;
605+struct reggroup;
606+struct regset;
607+struct regcache;
608+
609 /* Registers for all SH variants. Used also by sh3-rom.c. */
610 enum
611 {
612@@ -29,6 +35,7 @@
613 ARG0_REGNUM = 4,
614 ARGLAST_REGNUM = 7,
615 FP_REGNUM = 14,
616+ SP_REGNUM = 15,
617 PC_REGNUM = 16,
618 PR_REGNUM = 17,
619 GBR_REGNUM = 18,
620@@ -81,6 +88,24 @@
621 FV0_REGNUM = 76,
622 FV_LAST_REGNUM = 79
623 };
624+#define SH_NUM_REGS 67
625+
626+struct sh_frame_cache
627+{
628+ /* Base address. */
629+ CORE_ADDR base;
630+ LONGEST sp_offset;
631+ CORE_ADDR pc;
632+
633+ /* Flag showing that a frame has been created in the prologue code. */
634+ int uses_fp;
635+
636+ /* Saved registers. */
637+ CORE_ADDR saved_regs[SH_NUM_REGS];
638+ CORE_ADDR saved_sp;
639+};
640+
641+extern struct sh_frame_cache *sh_frame_cache (struct frame_info *next_frame, void **this_cache);
642
643 /* This structure describes a register in a core-file. */
644 struct sh_corefile_regmap
645@@ -89,8 +114,32 @@
646 unsigned int offset;
647 };
648
649+/* sh architecture specific information. */
650 struct gdbarch_tdep
651 {
652+ /* General-purpose registers. */
653+ struct regset *gregset;
654+ int *gregset_reg_offset;
655+ int gregset_num_regs;
656+ size_t sizeof_gregset;
657+
658+ /* Floating-point registers. */
659+ struct regset *fpregset;
660+ size_t sizeof_fpregset;
661+
662+ /* Offset of saved PC in jmp_buf. */
663+ int jb_pc_offset;
664+
665+ /* Detect sigtramp. */
666+ int (*sigtramp_p) (struct frame_info *);
667+
668+ /* Get address of sigcontext for sigtramp. */
669+ CORE_ADDR (*sigcontext_addr) (struct frame_info *);
670+
671+ /* Offset of registers in `struct sigcontext'. */
672+ int *sc_reg_offset;
673+ int sc_num_regs;
674+
675 /* Non-NULL when debugging from a core file. Provides the offset
676 where each general-purpose register is stored inside the associated
677 core file section. */
678Index: gdb-7.5/gdb/sh-linux-nat.c
679===================================================================
680--- /dev/null 1970-01-01 00:00:00.000000000 +0000
681+++ gdb-7.5/gdb/sh-linux-nat.c 2012-09-19 14:40:42.978609771 -0700
682@@ -0,0 +1,269 @@
683+/* Low level SH interface to ptrace, for GDB when running native.
684+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
685+
686+This file is part of GDB.
687+
688+This program is free software; you can redistribute it and/or modify
689+it under the terms of the GNU General Public License as published by
690+the Free Software Foundation; either version 2 of the License, or
691+(at your option) any later version.
692+
693+This program is distributed in the hope that it will be useful,
694+but WITHOUT ANY WARRANTY; without even the implied warranty of
695+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
696+GNU General Public License for more details.
697+
698+You should have received a copy of the GNU General Public License
699+along with this program; if not, write to the Free Software
700+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
701+
702+#include "defs.h"
703+#include "inferior.h"
704+#include "gdbcore.h"
705+#include "regcache.h"
706+#include "linux-nat.h"
707+#include "target.h"
708+#include "arch-utils.h"
709+
710+#include "gdb_assert.h"
711+#include "gdb_string.h"
712+#include <sys/ptrace.h>
713+#include <sys/user.h>
714+#include <sys/procfs.h>
715+#include <asm/ptrace.h>
716+
717+/* Prototypes for supply_gregset etc. */
718+#include "gregset.h"
719+#include "sh-tdep.h"
720+
721+/* Defines ps_err_e, struct ps_prochandle. */
722+#include "gdb_proc_service.h"
723+
724+//#include <asm/elf.h>
725+
726+#define SH_LINUX_NUM_REGS 40
727+/* This table must line up with REGISTER_NAME in "sh-tdep.c". */
728+static const int regmap[] =
729+{
730+ /* general registers 0-15 */
731+ REG_REG0 , REG_REG0+1 , REG_REG0+2 , REG_REG0+3,
732+ REG_REG0+4 , REG_REG0+5 , REG_REG0+6 , REG_REG0+7,
733+ REG_REG0+8 , REG_REG0+9 , REG_REG0+10, REG_REG0+11,
734+ REG_REG0+12, REG_REG0+13, REG_REG0+14, REG_REG0+15,
735+ /* 16 - 22 */
736+ REG_PC, REG_PR, REG_GBR, -1, REG_MACH, REG_MACL, REG_SR,
737+ /* 23, 24 */
738+ REG_FPUL, REG_FPSCR,
739+ /* floating point registers 25 - 40 */
740+ REG_FPREG0 , REG_FPREG0+1 , REG_FPREG0+2 , REG_FPREG0+3 ,
741+ REG_FPREG0+4 , REG_FPREG0+5 , REG_FPREG0+6 , REG_FPREG0+7 ,
742+ REG_FPREG0+8 , REG_FPREG0+9 , REG_FPREG0+10, REG_FPREG0+11,
743+ REG_FPREG0+12, REG_FPREG0+13, REG_FPREG0+14, REG_FPREG0+15,
744+};
745+
746+CORE_ADDR
747+register_u_addr (CORE_ADDR blockend, int regnum)
748+{
749+ if (regnum < 0 || regnum >= sizeof regmap/sizeof regmap[0])
750+ return (CORE_ADDR)-1;
751+ return (blockend + 4 * regmap[regnum]);
752+}
753+
754+
755+/* Return the address in the core dump or inferior of register REGNO.
756+ BLOCKEND is the address of the end of the user structure. */
757+
758+CORE_ADDR
759+register_addr (int regno, CORE_ADDR blockend)
760+{
761+ CORE_ADDR addr;
762+
763+ if (regno < 0 || regno >= SH_LINUX_NUM_REGS) {
764+ internal_error (__FILE__, __LINE__,
765+ _("Got request for bad register number %d."), regno);
766+ }
767+
768+ REGISTER_U_ADDR (addr, blockend, regno);
769+
770+ return addr;
771+}
772+
773+/* Fetch one register. */
774+
775+static void
776+fetch_register (struct regcache *regcache, int tid, int regno)
777+{
778+ int val;
779+
780+ if (cannot_fetch_register (regno))
781+ {
782+ regcache_raw_supply (regcache, regno, NULL);
783+ return;
784+ }
785+
786+ errno = 0;
787+ val = ptrace (PTRACE_PEEKUSER, tid, register_addr (regno, 0), 0);
788+ if (errno != 0)
789+ perror_with_name (_("Couldn't get registers"));
790+
791+ regcache_raw_supply (regcache, regno, &val);
792+}
793+
794+/* Store one register. */
795+
796+static void
797+store_register (struct regcache *regcache, int tid, int regno)
798+{
799+ int val;
800+
801+ if (cannot_store_register (regno))
802+ return;
803+
804+ errno = 0;
805+ regcache_raw_collect (regcache, regno, &val);
806+ ptrace (PTRACE_POKEUSER, tid, register_addr (regno, 0), val);
807+ if (errno != 0)
808+ perror_with_name (_("Couldn't write registers"));
809+}
810+
811+/* Transfering the general-purpose registers between GDB, inferiors
812+ and core files. */
813+
814+/* Fill GDB's register array with the general-purpose register values
815+ in *GREGSETP. */
816+
817+void
818+supply_gregset (struct regcache *regcache, const elf_gregset_t *gregsetp)
819+{
820+ elf_greg_t *regp = (elf_greg_t *) gregsetp;
821+ int i;
822+
823+ for (i = 0; i < 23; i++)
824+ if (regmap[i] == -1)
825+ regcache_raw_supply (regcache, i, NULL);
826+ else
827+ regcache_raw_supply (regcache, i, (char *) (regp + regmap[i]));
828+}
829+
830+/* Fill register REGNO (if it is a general-purpose register) in
831+ *GREGSETPS with the value in GDB's register array. If REGNO is -1,
832+ do this for all registers. */
833+
834+void
835+fill_gregset (const struct regcache *regcache, elf_gregset_t *gregsetp, int regno)
836+{
837+ elf_greg_t *regp = (elf_greg_t *) gregsetp;
838+ int i;
839+
840+ for (i = 0; i < 23; i++)
841+ if (regmap[i] != -1 && (regno == -1 || regno == i))
842+ regcache_raw_collect (regcache, i, (char *) (regp + regmap[i]));
843+}
844+
845+/* Transfering floating-point registers between GDB, inferiors and cores. */
846+
847+/* Fill GDB's register array with the floating-point register values in
848+ *FPREGSETP. */
849+
850+void
851+supply_fpregset (struct regcache *regcache, const elf_fpregset_t *fpregsetp)
852+{
853+ int i;
854+ long *regp = (long *)fpregsetp;
855+
856+ for (i = 0; i < 16; i++)
857+ regcache_raw_supply (regcache, 25 + i, (char *) (regp + i));
858+ regcache_raw_supply (regcache, FPUL_REGNUM, (char *) (regp + REG_FPUL - REG_FPREG0));
859+ regcache_raw_supply (regcache, FPSCR_REGNUM, (char *) (regp + REG_FPSCR - REG_FPREG0));
860+}
861+
862+/* Fill register REGNO (if it is a floating-point register) in
863+ *FPREGSETP with the value in GDB's register array. If REGNO is -1,
864+ do this for all registers. */
865+
866+void
867+fill_fpregset (const struct regcache *regcache, elf_fpregset_t *fpregsetp, int regno)
868+{
869+ int i;
870+ long *regp = (long *)fpregsetp;
871+
872+ for (i = 0; i < 16; i++)
873+ if ((regno == -1) || (regno == i))
874+ regcache_raw_collect (regcache, 25 + i, (char *) (regp + i));
875+ if ((regno == -1) || regno == FPSCR_REGNUM)
876+ regcache_raw_collect (regcache, FPSCR_REGNUM, (char *) (regp + REG_FPSCR - REG_FPREG0));
877+ if ((regno == -1) || regno == FPUL_REGNUM)
878+ regcache_raw_collect (regcache, FPUL_REGNUM, (char *) (regp + REG_FPUL - REG_FPREG0));
879+}
880+
881+/* Transferring arbitrary registers between GDB and inferior. */
882+
883+/* Check if register REGNO in the child process is accessible.
884+ If we are accessing registers directly via the U area, only the
885+ general-purpose registers are available.
886+ All registers should be accessible if we have GETREGS support. */
887+
888+int
889+cannot_fetch_register (int regno)
890+{
891+ return (regno < 0 || regno >= sizeof regmap / sizeof regmap[0] || regmap[regno] == -1);
892+}
893+
894+int
895+cannot_store_register (int regno)
896+{
897+ return (regno < 0 || regno >= sizeof regmap / sizeof regmap[0] || regmap[regno] == -1);
898+}
899+
900+/* Fetch register values from the inferior.
901+ If REGNO is negative, do this for all registers.
902+ Otherwise, REGNO specifies which register (so we can save time). */
903+
904+static void
905+sh_linux_fetch_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regno)
906+{
907+ int i;
908+ int tid;
909+
910+ /* GNU/Linux LWP ID's are process ID's. */
911+ if ((tid = TIDGET (inferior_ptid)) == 0)
912+ tid = PIDGET (inferior_ptid); /* Not a threaded program. */
913+
914+ for (i = 0; i < SH_LINUX_NUM_REGS; i++)
915+ if (regno == -1 || regno == i)
916+ fetch_register (regcache, tid, i);
917+}
918+/* Store our register values back into the inferior.
919+ If REGNO is negative, do this for all registers.
920+ Otherwise, REGNO specifies which register (so we can save time). */
921+
922+static void
923+sh_linux_store_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regno)
924+{
925+ int i;
926+ int tid;
927+
928+ /* GNU/Linux LWP ID's are process ID's. */
929+ if ((tid = TIDGET (inferior_ptid)) == 0)
930+ tid = PIDGET (inferior_ptid); /* Not a threaded program. */
931+
932+ for (i = 0; i < SH_LINUX_NUM_REGS; i++)
933+ if (regno == -1 || regno == i)
934+ store_register (regcache, tid, i);
935+}
936+
937+void
938+_initialize_sh_linux_nat (void)
939+{
940+ struct target_ops *t;
941+
942+ /* Fill in the generic GNU/Linux methods. */
943+ t = linux_target ();
944+
945+ /* Add our register access methods. */
946+ t->to_fetch_registers = sh_linux_fetch_inferior_registers;
947+ t->to_store_registers = sh_linux_store_inferior_registers;
948+
949+ /* Register the target. */
950+ linux_nat_add_target (t);
951+}
952Index: gdb-7.5/gdb/sh-tdep.c
953===================================================================
954--- gdb-7.5.orig/gdb/sh-tdep.c 2012-06-08 07:24:57.000000000 -0700
955+++ gdb-7.5/gdb/sh-tdep.c 2012-09-19 14:45:09.770619943 -0700
956@@ -21,6 +21,9 @@
957 sac@cygnus.com. */
958
959 #include "defs.h"
960+#include "arch-utils.h"
961+#include "command.h"
962+#include "dummy-frame.h"
963 #include "frame.h"
964 #include "frame-base.h"
965 #include "frame-unwind.h"
966@@ -37,6 +40,7 @@
967 #include "arch-utils.h"
968 #include "floatformat.h"
969 #include "regcache.h"
970+#include "regset.h"
971 #include "doublest.h"
972 #include "osabi.h"
973 #include "reggroups.h"
974@@ -69,23 +73,6 @@
975
976 static const char *sh_active_calling_convention = sh_cc_gcc;
977
978-#define SH_NUM_REGS 67
979-
980-struct sh_frame_cache
981-{
982- /* Base address. */
983- CORE_ADDR base;
984- LONGEST sp_offset;
985- CORE_ADDR pc;
986-
987- /* Flag showing that a frame has been created in the prologue code. */
988- int uses_fp;
989-
990- /* Saved registers. */
991- CORE_ADDR saved_regs[SH_NUM_REGS];
992- CORE_ADDR saved_sp;
993-};
994-
995 static int
996 sh_is_renesas_calling_convention (struct type *func_type)
997 {
998@@ -1045,7 +1032,7 @@
999 return 0;
1000 /* Otherwise if the type of that member is float, the whole type is
1001 treated as float. */
1002- if (TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_FLT)
1003+ if (TYPE_CODE (check_typedef (TYPE_FIELD_TYPE (type, 0))) == TYPE_CODE_FLT)
1004 return 1;
1005 /* Otherwise it's not treated as float. */
1006 return 0;
1007@@ -1095,7 +1082,7 @@
1008 in four registers available. Loop thru args from first to last. */
1009 for (argnum = 0; argnum < nargs; argnum++)
1010 {
1011- type = value_type (args[argnum]);
1012+ type = check_typedef (value_type (args[argnum]));
1013 len = TYPE_LENGTH (type);
1014 val = sh_justify_value_in_reg (gdbarch, args[argnum], len);
1015
1016@@ -1809,7 +1796,7 @@
1017 reg->how = DWARF2_FRAME_REG_UNDEFINED;
1018 }
1019
1020-static struct sh_frame_cache *
1021+struct sh_frame_cache *
1022 sh_alloc_frame_cache (void)
1023 {
1024 struct sh_frame_cache *cache;
1025@@ -1836,7 +1823,7 @@
1026 return cache;
1027 }
1028
1029-static struct sh_frame_cache *
1030+struct sh_frame_cache *
1031 sh_frame_cache (struct frame_info *this_frame, void **this_cache)
1032 {
1033 struct gdbarch *gdbarch = get_frame_arch (this_frame);
1034@@ -1903,9 +1890,9 @@
1035 return cache;
1036 }
1037
1038-static struct value *
1039-sh_frame_prev_register (struct frame_info *this_frame,
1040- void **this_cache, int regnum)
1041+struct value *
1042+sh_frame_prev_register (struct frame_info *this_frame, void **this_cache,
1043+ int regnum)
1044 {
1045 struct gdbarch *gdbarch = get_frame_arch (this_frame);
1046 struct sh_frame_cache *cache = sh_frame_cache (this_frame, this_cache);
1047@@ -1919,7 +1906,7 @@
1048 the current frame. Frob regnum so that we pull the value from
1049 the correct place. */
1050 if (regnum == gdbarch_pc_regnum (gdbarch))
1051- regnum = PR_REGNUM;
1052+ regnum = PR_REGNUM; /* XXX: really? */
1053
1054 if (regnum < SH_NUM_REGS && cache->saved_regs[regnum] != -1)
1055 return frame_unwind_got_memory (this_frame, regnum,
1056@@ -2225,8 +2212,8 @@
1057 static struct gdbarch *
1058 sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1059 {
1060- struct gdbarch *gdbarch;
1061 struct gdbarch_tdep *tdep;
1062+ struct gdbarch *gdbarch;
1063
1064 /* SH5 is handled entirely in sh64-tdep.c. */
1065 if (info.bfd_arch_info->mach == bfd_mach_sh5)
1066@@ -2242,6 +2229,18 @@
1067 tdep = XZALLOC (struct gdbarch_tdep);
1068 gdbarch = gdbarch_alloc (&info, tdep);
1069
1070+ /* General-purpose registers. */
1071+ tdep->gregset = NULL;
1072+ tdep->gregset_reg_offset = NULL;
1073+ tdep->gregset_num_regs = 23;
1074+ tdep->sizeof_gregset = 0;
1075+
1076+ /* Floating-point registers. */
1077+ tdep->fpregset = NULL;
1078+ tdep->sizeof_fpregset = 34*4;
1079+
1080+ tdep->jb_pc_offset = -1;
1081+
1082 set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
1083 set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
1084 set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
1085@@ -2389,10 +2388,11 @@
1086 break;
1087 }
1088
1089+ dwarf2_append_unwinders (gdbarch);
1090+
1091 /* Hook in ABI-specific overrides, if they have been registered. */
1092 gdbarch_init_osabi (info, gdbarch);
1093
1094- dwarf2_append_unwinders (gdbarch);
1095 frame_unwind_append_unwinder (gdbarch, &sh_stub_unwind);
1096 frame_unwind_append_unwinder (gdbarch, &sh_frame_unwind);
1097
1098Index: gdb-7.5/gdb/testsuite/gdb.asm/sh-linux.inc
1099===================================================================
1100--- /dev/null 1970-01-01 00:00:00.000000000 +0000
1101+++ gdb-7.5/gdb/testsuite/gdb.asm/sh-linux.inc 2012-09-19 14:40:42.978609771 -0700
1102@@ -0,0 +1,78 @@
1103+# You'll find a bunch of nop opcodes in the below macros. They are
1104+# there to keep the code correctly aligned. Be careful to maintain
1105+# them when changing the code.
1106+
1107+ comment "subroutine declare"
1108+ .purgem gdbasm_declare
1109+ .macro gdbasm_declare name
1110+ .align 1
1111+ .global \name
1112+\name:
1113+ .endm
1114+
1115+ comment "subroutine prologue"
1116+ .macro gdbasm_enter
1117+ mov.l r14,@-r15
1118+ sts.l pr,@-r15
1119+ mov r15,r14
1120+ nop
1121+ .endm
1122+
1123+ comment "subroutine epilogue"
1124+ .macro gdbasm_leave
1125+ mov r14,r15
1126+ lds.l @r15+,pr
1127+ mov.l @r15+,r14
1128+ rts
1129+ nop
1130+ nop
1131+ .endm
1132+
1133+ comment "subroutine end"
1134+ .purgem gdbasm_end
1135+ .macro gdbasm_end name
1136+ .size \name, .-_foo1
1137+ .align 1
1138+ .endm
1139+
1140+ comment "subroutine call"
1141+ .macro gdbasm_call subr
1142+ mov.l .Lconst\@,r1
1143+ bra .Lafterconst\@
1144+ nop
1145+ .align 2
1146+.Lconst\@:
1147+ .long \subr
1148+.Lafterconst\@:
1149+ jsr @r1
1150+ nop
1151+ .endm
1152+
1153+ .macro gdbasm_several_nops
1154+ nop
1155+ nop
1156+ nop
1157+ nop
1158+ .endm
1159+
1160+ comment "exit (0)"
1161+ .macro gdbasm_exit0
1162+ sleep
1163+ nop
1164+ .endm
1165+
1166+ comment "crt0 startup"
1167+ .macro gdbasm_startup
1168+ mov #0,r14
1169+ .endm
1170+
1171+ comment "Declare a data variable"
1172+ .purgem gdbasm_datavar
1173+ .macro gdbasm_datavar name value
1174+ .data
1175+ .align 2
1176+ .type \name, @object
1177+ .size \name, 4
1178+\name:
1179+ .long \value
1180+ .endm
1181Index: gdb-7.5/gdb/testsuite/gdb.asm/sh.inc
1182===================================================================
1183--- gdb-7.5.orig/gdb/testsuite/gdb.asm/sh.inc 2012-04-16 01:02:09.000000000 -0700
1184+++ gdb-7.5/gdb/testsuite/gdb.asm/sh.inc 2012-09-19 14:40:42.978609771 -0700
1185@@ -40,9 +40,8 @@
1186 mov.l .Lconst\@,r1
1187 bra .Lafterconst\@
1188 nop
1189- nop
1190-.Lconst\@:
1191 .align 2
1192+.Lconst\@:
1193 .long \subr
1194 .align 1
1195 .Lafterconst\@:
1196Index: gdb-7.5/gdb/testsuite/gdb.asm/asm-source.exp
1197===================================================================
1198--- gdb-7.5.orig/gdb/testsuite/gdb.asm/asm-source.exp 2012-06-25 13:11:43.000000000 -0700
1199+++ gdb-7.5/gdb/testsuite/gdb.asm/asm-source.exp 2012-09-19 14:40:42.978609771 -0700
1200@@ -108,6 +108,11 @@
1201 append link-flags " -m elf32ppc"
1202 }
1203 }
1204+ "sh*-linux*" {
1205+ set asm-arch sh-linux
1206+ set asm-flags "-I${srcdir}/${subdir} -I${objdir}/${subdir}"
1207+ set debug-flags "-gdwarf-2"
1208+ }
1209 "sh*-*-*" {
1210 set asm-arch sh
1211 set debug-flags "-gdwarf-2"
1212Index: gdb-7.5/gdb/testsuite/gdb.base/sigall.c
1213===================================================================
1214--- gdb-7.5.orig/gdb/testsuite/gdb.base/sigall.c 2012-02-28 02:24:15.000000000 -0800
1215+++ gdb-7.5/gdb/testsuite/gdb.base/sigall.c 2012-09-19 14:42:02.202612808 -0700
1216@@ -5,6 +5,10 @@
1217 /* Signal handlers, we set breakpoints in them to make sure that the
1218 signals really get delivered. */
1219
1220+#ifdef __sh__
1221+#define signal(a,b) /* Signals not supported on this target - make them go away */
1222+#endif
1223+
1224 #ifdef PROTOTYPES
1225 void
1226 handle_ABRT (int sig)
1227Index: gdb-7.5/gdb/testsuite/gdb.base/signals.c
1228===================================================================
1229--- gdb-7.5.orig/gdb/testsuite/gdb.base/signals.c 2012-02-28 02:24:15.000000000 -0800
1230+++ gdb-7.5/gdb/testsuite/gdb.base/signals.c 2012-09-19 14:43:22.034615831 -0700
1231@@ -3,6 +3,10 @@
1232 #include <signal.h>
1233 #include <unistd.h>
1234
1235+#ifdef __sh__
1236+#define signal(a,b) /* Signals not supported on this target - make them go away */
1237+#define alarm(a) /* Ditto for alarm() */
1238+#endif
1239
1240 static int count = 0;
1241
1242Index: gdb-7.5/gdb/testsuite/gdb.base/annota1.c
1243===================================================================
1244--- gdb-7.5.orig/gdb/testsuite/gdb.base/annota1.c 2012-02-28 14:40:48.000000000 -0800
1245+++ gdb-7.5/gdb/testsuite/gdb.base/annota1.c 2012-09-19 14:42:42.074614308 -0700
1246@@ -1,6 +1,9 @@
1247 #include <stdio.h>
1248 #include <signal.h>
1249
1250+#ifdef __sh__
1251+#define signal(a,b) /* Signals not supported on this target - make them go away */
1252+#endif
1253
1254 #ifdef PROTOTYPES
1255 void
1256Index: gdb-7.5/gdb/testsuite/gdb.base/annota3.c
1257===================================================================
1258--- gdb-7.5.orig/gdb/testsuite/gdb.base/annota3.c 2012-02-28 14:40:48.000000000 -0800
1259+++ gdb-7.5/gdb/testsuite/gdb.base/annota3.c 2012-09-19 14:43:54.410617081 -0700
1260@@ -1,6 +1,10 @@
1261 #include <stdio.h>
1262 #include <signal.h>
1263
1264+#ifdef __sh__
1265+#define signal(a,b) /* Signals not supported on this target - make them go away */
1266+#endif
1267+
1268
1269 #ifdef PROTOTYPES
1270 void
1271Index: gdb-7.5/gdb/config/sh/xm-linux.h
1272===================================================================
1273--- /dev/null 1970-01-01 00:00:00.000000000 +0000
1274+++ gdb-7.5/gdb/config/sh/xm-linux.h 2012-09-19 14:40:42.994609807 -0700
1275@@ -0,0 +1,32 @@
1276+/* Native support for GNU/Linux, for GDB, the GNU debugger.
1277+ Copyright (C) 2000 Free Software Foundation, Inc.
1278+
1279+This file is part of GDB.
1280+
1281+This program is free software; you can redistribute it and/or modify
1282+it under the terms of the GNU General Public License as published by
1283+the Free Software Foundation; either version 2 of the License, or
1284+(at your option) any later version.
1285+
1286+This program is distributed in the hope that it will be useful,
1287+but WITHOUT ANY WARRANTY; without even the implied warranty of
1288+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1289+GNU General Public License for more details.
1290+
1291+You should have received a copy of the GNU General Public License
1292+along with this program; if not, write to the Free Software
1293+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
1294+
1295+#ifndef XM_LINUX_H
1296+#define XM_LINUX_H
1297+
1298+#define HOST_BYTE_ORDER LITTLE_ENDIAN
1299+
1300+#define HAVE_TERMIOS
1301+
1302+#define NEED_POSIX_SETPGID
1303+
1304+/* Need R_OK etc, but USG isn't defined. */
1305+#include <unistd.h>
1306+
1307+#endif /* #ifndef XM_LINUX_H */
1308Index: gdb-7.5/gdb/config/sh/nm-linux.h
1309===================================================================
1310--- /dev/null 1970-01-01 00:00:00.000000000 +0000
1311+++ gdb-7.5/gdb/config/sh/nm-linux.h 2012-09-19 14:40:42.994609807 -0700
1312@@ -0,0 +1,54 @@
1313+/* Native-dependent definitions for SuperH running Linux, for GDB.
1314+ Copyright 2004 Free Software Foundation, Inc.
1315+
1316+ This file is part of GDB.
1317+
1318+ This program is free software; you can redistribute it and/or modify
1319+ it under the terms of the GNU General Public License as published by
1320+ the Free Software Foundation; either version 2 of the License, or
1321+ (at your option) any later version.
1322+
1323+ This program is distributed in the hope that it will be useful,
1324+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1325+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1326+ GNU General Public License for more details.
1327+
1328+ You should have received a copy of the GNU General Public License
1329+ along with this program; if not, write to the Free Software
1330+ Foundation, Inc., 59 Temple Place - Suite 330,
1331+ Boston, MA 02111-1307, USA. */
1332+
1333+#ifndef NM_LINUX_H
1334+#define NM_LINUX_H
1335+
1336+/* Get generic Linux native definitions. */
1337+#include "config/nm-linux.h"
1338+/* Support for the user area. */
1339+
1340+/* Return the size of the user struct. */
1341+extern int kernel_u_size (void);
1342+#define KERNEL_U_SIZE kernel_u_size()
1343+
1344+/* This is the amount to substract from u.u_ar0 to get the offset in
1345+ the core file of the register values. */
1346+#define KERNEL_U_ADDR 0
1347+
1348+#define U_REGS_OFFSET 0
1349+
1350+extern CORE_ADDR register_u_addr (CORE_ADDR blockend, int regnum);
1351+#define REGISTER_U_ADDR(addr, blockend, regnum) \
1352+ (addr) = register_u_addr (blockend, regnum)
1353+
1354+/* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */
1355+#define FETCH_INFERIOR_REGISTERS
1356+
1357+/* Nevertheless, define CANNOT_{FETCH,STORE}_REGISTER, because we
1358+ might fall back on the code `infptrace.c' (well a copy of that code
1359+ in `sh-linux-nat.c' for now) and we can access only the
1360+ general-purpose registers in that way. */
1361+extern int cannot_fetch_register (int regno);
1362+extern int cannot_store_register (int regno);
1363+#define CANNOT_FETCH_REGISTER(regno) cannot_fetch_register (regno)
1364+#define CANNOT_STORE_REGISTER(regno) cannot_store_register (regno)
1365+
1366+#endif /* NM_LINUX_H */
1367Index: gdb-7.5/gdb/config/sh/linux.mh
1368===================================================================
1369--- /dev/null 1970-01-01 00:00:00.000000000 +0000
1370+++ gdb-7.5/gdb/config/sh/linux.mh 2012-09-19 14:40:42.994609807 -0700
1371@@ -0,0 +1,8 @@
1372+# Host: Renesas Super-H running GNU/Linux
1373+NAT_FILE= config/sh/nm-linux.h
1374+NATDEPFILES= inf-ptrace.o fork-child.o corelow.o sh-linux-nat.o \
1375+ proc-service.o linux-thread-db.o gcore.o \
1376+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
1377+
1378+NAT_CDEPS = $(srcdir)/proc-service.list
1379+LOADLIBES= -ldl $(RDYNAMIC)