* Add linux-sparc gdbserver support
@ 2009-01-16 14:00 Aleksei Makhaloff
2009-01-16 14:45 ` Daniel Jacobowitz
0 siblings, 1 reply; 2+ messages in thread
From: Aleksei Makhaloff @ 2009-01-16 14:00 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 140 bytes --]
Hello.
This patch provide linux-sparc gdbserver support.
It was tested on Elbrus-90 (http://www.mcst.ru/hardware.shtml
/russian language/).
[-- Attachment #2: gdb-6.8_add_sparc_linux_gdbserver.patch --]
[-- Type: application/octet-stream, Size: 22109 bytes --]
diff -urN gdb-6.8_orig/gdb/gdbserver/ChangeLog gdb-6.8_new/gdb/gdbserver/ChangeLog
--- gdb-6.8_orig/gdb/gdbserver/ChangeLog 2008-02-20 00:36:54.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/ChangeLog 2009-01-16 16:41:38.000000000 +0300
@@ -1,3 +1,10 @@
+2008-04-08 Aleksei Makhaloff <makhaloff@gmail.com>
+
+ * configure.srv: Add target "sparc-*-linux".
+ * linux-sparc-low.c:
+ * linux-sparc-low.h: New files.
+ * regcache.c (regcache_valid): New.
+
2008-02-19 Pedro Alves <pedro@codesourcery.com>
* server.c (handle_v_requests): When handling the vRun and vAttach
diff -urN gdb-6.8_orig/gdb/gdbserver/configure.srv gdb-6.8_new/gdb/gdbserver/configure.srv
--- gdb-6.8_orig/gdb/gdbserver/configure.srv 2008-02-12 01:00:31.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/configure.srv 2008-04-08 09:42:40.000000000 +0400
@@ -157,6 +157,9 @@
srv_linux_regsets=yes
srv_linux_thread_db=yes
;;
+ sparc-*-linux*) srv_regobj=reg-sparc.o
+ srv_tgtobj="linux-low.o linux-sparc-low.o"
+ ;;
spu*-*-*) srv_regobj=reg-spu.o
srv_tgtobj="spu-low.o"
;;
ä×ÏÉÞÎÙÅ ÆÁÊÌÙ gdb-6.8_orig/gdb/gdbserver/gdbreplay É gdb-6.8_new/gdb/gdbserver/gdbreplay ÒÁÚÌÉÞÁÀÔÓÑ
ä×ÏÉÞÎÙÅ ÆÁÊÌÙ gdb-6.8_orig/gdb/gdbserver/gdbserver É gdb-6.8_new/gdb/gdbserver/gdbserver ÒÁÚÌÉÞÁÀÔÓÑ
diff -urN gdb-6.8_orig/gdb/gdbserver/hostio.c gdb-6.8_new/gdb/gdbserver/hostio.c
--- gdb-6.8_orig/gdb/gdbserver/hostio.c 2008-02-01 03:08:25.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/hostio.c 2008-04-08 10:04:19.000000000 +0400
@@ -24,7 +24,11 @@
#include "gdb/fileio.h"
#include <fcntl.h>
-#include <limits.h>
+#if defined(__sparc__)
+# include <linux/limits.h>
+#else
+# include <limits.h>
+#endif
#include <unistd.h>
extern int remote_debug;
diff -urN gdb-6.8_orig/gdb/gdbserver/linux-low.c gdb-6.8_new/gdb/gdbserver/linux-low.c
--- gdb-6.8_orig/gdb/gdbserver/linux-low.c 2008-02-01 03:08:25.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/linux-low.c 2008-04-08 10:32:00.000000000 +0400
@@ -84,6 +84,13 @@
#endif
#endif
+#if defined(__sparc__)
+#define PTRACE_CONT_ADDR 1
+#else
+#define PTRACE_CONT_ADDR 0
+#endif
+
+
/* ``all_threads'' is keyed by the LWP ID, which we use as the GDB protocol
representation of the thread ID.
@@ -129,11 +136,6 @@
static int use_regsets_p = 1;
#endif
-#define pid_of(proc) ((proc)->head.id)
-
-/* FIXME: Delete eventually. */
-#define inferior_pid (pid_of (get_thread_process (current_inferior)))
-
static void
handle_extended_wait (struct process_info *event_child, int wstat)
{
@@ -179,7 +181,7 @@
if (stopping_threads)
new_process->stopped = 1;
else
- ptrace (PTRACE_CONT, new_pid, 0, 0);
+ ptrace (PTRACE_CONT, new_pid, PTRACE_CONT_ADDR, 0);
}
else
{
@@ -193,7 +195,7 @@
else
/* Pass the signal on. This is what GDB does - except
shouldn't we really report it instead? */
- ptrace (PTRACE_CONT, new_pid, 0, WSTOPSIG (status));
+ ptrace (PTRACE_CONT, new_pid, PTRACE_CONT_ADDR, WSTOPSIG (status));
}
/* Always resume the current thread. If we are stopping
@@ -1169,7 +1171,7 @@
errno = 0;
process->stopped = 0;
process->stepping = step;
- ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, process->lwpid, 0, signal);
+ ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, process->lwpid, PTRACE_CONT_ADDR, signal);
current_inferior = saved_inferior;
if (errno)
@@ -1598,6 +1600,11 @@
void
linux_fetch_registers (int regno)
{
+#if defined(__sparc__)
+ extern void sparc_fetch_registers (int regno);
+ sparc_fetch_registers(regno);
+ return;
+#endif
#ifdef HAVE_LINUX_REGSETS
if (use_regsets_p)
{
@@ -1613,6 +1620,11 @@
void
linux_store_registers (int regno)
{
+#if defined(__sparc__)
+ extern void sparc_store_registers (int regno);
+ sparc_store_registers(regno);
+ return;
+#endif
#ifdef HAVE_LINUX_REGSETS
if (use_regsets_p)
{
@@ -1837,7 +1849,7 @@
return;
}
- ret = ptrace (PTRACE_CONT, child_pid, 0, 0);
+ ret = ptrace (PTRACE_CONT, child_pid, PTRACE_CONT_ADDR, 0);
if (ret != 0)
warning ("linux_test_for_tracefork: failed to resume child");
diff -urN gdb-6.8_orig/gdb/gdbserver/linux-low.h gdb-6.8_new/gdb/gdbserver/linux-low.h
--- gdb-6.8_orig/gdb/gdbserver/linux-low.h 2008-01-02 01:53:14.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/linux-low.h 2008-04-08 10:06:54.000000000 +0400
@@ -20,6 +20,11 @@
#include <thread_db.h>
#endif
+#define pid_of(proc) ((proc)->head.id)
+
+/* FIXME: Delete eventually. */
+#define inferior_pid (pid_of (get_thread_process (current_inferior)))
+
#ifdef HAVE_LINUX_REGSETS
typedef void (*regset_fill_func) (void *);
typedef void (*regset_store_func) (const void *);
diff -urN gdb-6.8_orig/gdb/gdbserver/linux-sparc-low.c gdb-6.8_new/gdb/gdbserver/linux-sparc-low.c
--- gdb-6.8_orig/gdb/gdbserver/linux-sparc-low.c 1970-01-01 03:00:00.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/linux-sparc-low.c 2008-04-08 11:57:26.000000000 +0400
@@ -0,0 +1,383 @@
+/* GNU/Linux/SPARC specific low level interface, for the remote server for GDB.
+
+ Copyright 2008 Aleksei Makhaloff (makhaloff@gmail.com)
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "server.h"
+#include "linux-low.h"
+#include "linux-sparc-low.h"
+#include <sys/ptrace.h>
+
+static CORE_ADDR
+sparc_get_pc ()
+{
+ unsigned long pc;
+ collect_register_by_name ("pc", &pc);
+ return pc;
+}
+
+static void
+sparc_set_pc (CORE_ADDR pc)
+{
+ unsigned long newpc = pc;
+ supply_register_by_name ("pc", &newpc);
+}
+
+static const unsigned long sparc_breakpoint = 0x91d02001;
+#define sparc_breakpoint_len 4
+
+static int
+sparc_breakpoint_at (CORE_ADDR where)
+{
+ unsigned long insn;
+
+ (*the_target->read_memory) (where, (char *) &insn, sparc_breakpoint_len);
+ if (insn == sparc_breakpoint)
+ return 1;
+
+ return 0;
+}
+
+struct linux_target_ops the_low_target = {
+ -1,
+ NULL,
+ NULL,
+ NULL,
+ sparc_get_pc,
+ sparc_set_pc,
+ (const unsigned char *)&sparc_breakpoint,
+ sparc_breakpoint_len,
+ NULL,
+ 0,
+ sparc_breakpoint_at,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ NULL
+};
+
+
+int
+sparc_gregset_supplies_p (int regnum)
+{
+ /* Integer registers. */
+ if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_G7_REGNUM)
+ || (regnum >= SPARC_O0_REGNUM && regnum <= SPARC_O7_REGNUM)
+ || (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_L7_REGNUM)
+ || (regnum >= SPARC_I0_REGNUM && regnum <= SPARC_I7_REGNUM))
+ return 1;
+
+ /* Control registers. */
+ if (regnum == SPARC32_PC_REGNUM
+ || regnum == SPARC32_NPC_REGNUM
+ || regnum == SPARC32_PSR_REGNUM
+ || regnum == SPARC32_Y_REGNUM)
+ return 1;
+
+ return 0;
+}
+
+/* Determine whether `fpregset_t' contains register REGNUM. */
+
+ int
+sparc_fpregset_supplies_p (int regnum)
+{
+ /* Floating-point registers. */
+ if (regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM)
+ return 1;
+
+ /* Control registers. */
+ if (regnum == SPARC32_FSR_REGNUM)
+ return 1;
+
+ return 0;
+}
+
+/* Helper functions for dealing with register windows. */
+
+void
+sparc_supply_rwindow (long sp, int regnum)
+{
+ char buf[4];
+ int i;
+
+ for (i = SPARC_L0_REGNUM; i <= SPARC_I7_REGNUM; i++)
+ {
+ if (regnum == i || regnum == -1)
+ {
+ (*the_target->read_memory) (sp + ((i - SPARC_L0_REGNUM) * 4),
+ buf, 4);
+#if 0
+ /* Handle StackGhost. */
+ if (i == SPARC_I7_REGNUM)
+ {
+ ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
+
+ store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
+ }
+#endif
+ supply_register(i, buf);
+
+ }
+ }
+}
+
+void
+sparc_collect_rwindow (long sp, int regnum)
+{
+ char buf[4];
+ int i;
+
+ for (i = SPARC_L0_REGNUM; i <= SPARC_I7_REGNUM; i++)
+ {
+ if (regnum == -1 || regnum == SPARC_SP_REGNUM || regnum == i)
+ {
+ collect_register (i, buf);
+#if 0
+ /* Handle StackGhost. */
+ if (i == SPARC_I7_REGNUM)
+ {
+ ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
+
+ store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
+ }
+#endif
+ (*the_target->write_memory) (sp + ((i - SPARC_L0_REGNUM) * 4),
+ buf, 4);
+ }
+ }
+}
+
+/* Helper functions for dealing with register sets. */
+
+void
+sparc_supply_gregset (int regnum, const struct pt_regs *regs)
+{
+ int i = 0;
+
+ if (regnum == SPARC32_PSR_REGNUM || regnum == -1)
+ supply_register(SPARC32_PSR_REGNUM, ®s->psr);
+
+ if (regnum == SPARC32_PC_REGNUM || regnum == -1)
+ supply_register(SPARC32_PC_REGNUM, ®s->pc);
+
+ if (regnum == SPARC32_NPC_REGNUM || regnum == -1)
+ supply_register(SPARC32_NPC_REGNUM, ®s->npc);
+
+ if (regnum == SPARC32_Y_REGNUM || regnum == -1)
+ supply_register(SPARC32_Y_REGNUM, ®s->y);
+
+ if (regnum == SPARC_G0_REGNUM || regnum == -1)
+ supply_register(SPARC_G0_REGNUM, &i);
+
+ if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1)
+ {
+ for (i = SPARC_G1_REGNUM; i <= SPARC_O7_REGNUM; i++)
+ {
+ if (regnum == i || regnum == -1)
+ supply_register(i, ®s->u_regs[i - SPARC_G1_REGNUM]);
+ }
+ }
+
+ if ((regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) || regnum == -1)
+ {
+ /* Not all of the register set variants include Locals and
+ Inputs. For those that don't, we read them off the stack. */
+ long sp;
+
+ if (regcache_valid())
+ collect_register(SPARC_SP_REGNUM, &sp);
+ else
+ sp = regs->u_regs[SPARC_SP_REGNUM - SPARC_G1_REGNUM];
+ sparc_supply_rwindow (sp, regnum);
+ }
+}
+
+void
+sparc_collect_gregset (int regnum, struct pt_regs *regs)
+{
+ int i;
+
+ if (regnum == SPARC32_PSR_REGNUM || regnum == -1)
+ collect_register (SPARC32_PSR_REGNUM, ®s->psr);
+
+ if (regnum == SPARC32_PC_REGNUM || regnum == -1)
+ collect_register (SPARC32_PC_REGNUM, ®s->pc);
+
+ if (regnum == SPARC32_NPC_REGNUM || regnum == -1)
+ collect_register (SPARC32_NPC_REGNUM, ®s->npc);
+
+ if (regnum == SPARC32_Y_REGNUM || regnum == -1)
+ collect_register (SPARC32_Y_REGNUM, ®s->y);
+
+ if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1)
+ {
+ /* %g0 is always zero. */
+ for (i = SPARC_G1_REGNUM; i <= SPARC_O7_REGNUM; i++)
+ {
+ if (regnum == i || regnum == -1)
+ collect_register (i, ®s->u_regs[i - SPARC_G1_REGNUM]);
+ }
+ }
+#if 0
+ if ((regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) || regnum == -1)
+ {
+ /* Not all of the register set variants include Locals and
+ Inputs. For those that don't, we read them off the stack. */
+ if (gregset->r_l0_offset != -1)
+ {
+ int offset = gregset->r_l0_offset;
+
+ for (i = SPARC_L0_REGNUM; i <= SPARC_I7_REGNUM; i++)
+ {
+ if (regnum == i || regnum == -1)
+ regcache_raw_collect (regcache, i, regs + offset);
+ offset += 4;
+ }
+ }
+ }
+#endif
+}
+
+void
+sparc_supply_fpregset (int regnum, const struct fps *fpregs)
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ {
+ if (regnum == (SPARC_F0_REGNUM + i) || regnum == -1)
+ supply_register (SPARC_F0_REGNUM + i, &fpregs->regs[i]);
+ }
+
+ if (regnum == SPARC32_FSR_REGNUM || regnum == -1)
+ supply_register (SPARC32_FSR_REGNUM, &fpregs->fsr);
+}
+
+void
+sparc_collect_fpregset (int regnum, struct fps *fpregs)
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ {
+ if (regnum == (SPARC_F0_REGNUM + i) || regnum == -1)
+ collect_register (SPARC_F0_REGNUM + i, &fpregs->regs[i]);
+ }
+
+ if (regnum == SPARC32_FSR_REGNUM || regnum == -1)
+ collect_register (SPARC32_FSR_REGNUM, &fpregs->fsr);
+}
+
+void
+sparc_fetch_registers (int regnum)
+{
+ if (regnum == SPARC_G0_REGNUM)
+ {
+ long g0 = 0;
+ supply_register(SPARC_G0_REGNUM, &g0);
+ return;
+ }
+
+ if (regnum == -1 || sparc_gregset_supplies_p (regnum))
+ {
+ struct pt_regs regs;
+
+ if (ptrace (PTRACE_GETREGS, inferior_pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name ("Couldn't get registers");
+
+ sparc_supply_gregset (-1, ®s);
+ if (regnum != -1)
+ return;
+ }
+
+ if (regnum == -1 || sparc_fpregset_supplies_p (regnum))
+ {
+ struct fps fpregs;
+
+ if (ptrace (PTRACE_GETFPREGS, inferior_pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name ("Couldn't get floating point status");
+
+ sparc_supply_fpregset (-1, &fpregs);
+ }
+}
+
+void
+sparc_store_registers (int regnum)
+{
+ /* NOTE: cagney/2002-12-02: See comment in fetch_inferior_registers
+ about threaded assumptions. */
+ if (regnum == -1 || sparc_gregset_supplies_p (regnum))
+ {
+ struct pt_regs regs;
+
+ if (ptrace (PTRACE_GETREGS, inferior_pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name ("Couldn't get registers");
+
+ sparc_collect_gregset (regnum, ®s);
+
+ if (ptrace (PTRACE_SETREGS, inferior_pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name ("Couldn't write registers");
+
+ /* Deal with the stack regs. */
+ if (regnum == -1 || regnum == SPARC_SP_REGNUM
+ || (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM))
+ {
+ long sp;
+
+ if (regcache_valid())
+ collect_register (SPARC_SP_REGNUM, &sp);
+ else
+ sp = regs.u_regs[SPARC_SP_REGNUM - SPARC_G1_REGNUM];
+ sparc_collect_rwindow (sp, regnum);
+ }
+
+ if (regnum != -1)
+ return;
+ }
+
+ if (regnum == -1 || sparc_fpregset_supplies_p (regnum))
+ {
+ struct fps fpregs, saved_fpregs;
+
+ if (ptrace (PTRACE_GETFPREGS, inferior_pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name ("Couldn't get floating-point registers");
+
+ memcpy (&saved_fpregs, &fpregs, sizeof (fpregs));
+ sparc_collect_fpregset (regnum, &fpregs);
+
+ /* Writing the floating-point registers will fail on NetBSD with
+ EINVAL if the inferior process doesn't have an FPU state
+ (i.e. if it didn't use the FPU yet). Therefore we don't try
+ to write the registers if nothing changed. */
+ if (memcmp (&saved_fpregs, &fpregs, sizeof (fpregs)) != 0)
+ {
+ if (ptrace (PTRACE_SETFPREGS, inferior_pid,
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name ("Couldn't write floating-point registers");
+ }
+
+ if (regnum != -1)
+ return;
+ }
+}
diff -urN gdb-6.8_orig/gdb/gdbserver/linux-sparc-low.h gdb-6.8_new/gdb/gdbserver/linux-sparc-low.h
--- gdb-6.8_orig/gdb/gdbserver/linux-sparc-low.h 1970-01-01 03:00:00.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/linux-sparc-low.h 2008-08-13 03:53:36.000000000 +0400
@@ -0,0 +1,107 @@
+/* GNU/Linux/SPARC specific low level header, for the remote server for GDB.
+
+ Copyright 2008 Aleksei Makhaloff (makhaloff@gmail.com)
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef LINUX_SPARC_LOW_H
+#define LINUX_SPARC_LOW_H 1
+
+/* Register numbers of various important registers. */
+
+enum sparc_regnum
+{
+ SPARC_G0_REGNUM, /* %g0 */
+ SPARC_G1_REGNUM,
+ SPARC_G2_REGNUM,
+ SPARC_G3_REGNUM,
+ SPARC_G4_REGNUM,
+ SPARC_G5_REGNUM,
+ SPARC_G6_REGNUM,
+ SPARC_G7_REGNUM, /* %g7 */
+ SPARC_O0_REGNUM, /* %o0 */
+ SPARC_O1_REGNUM,
+ SPARC_O2_REGNUM,
+ SPARC_O3_REGNUM,
+ SPARC_O4_REGNUM,
+ SPARC_O5_REGNUM,
+ SPARC_SP_REGNUM, /* %sp (%o6) */
+ SPARC_O7_REGNUM, /* %o7 */
+ SPARC_L0_REGNUM, /* %l0 */
+ SPARC_L1_REGNUM,
+ SPARC_L2_REGNUM,
+ SPARC_L3_REGNUM,
+ SPARC_L4_REGNUM,
+ SPARC_L5_REGNUM,
+ SPARC_L6_REGNUM,
+ SPARC_L7_REGNUM, /* %l7 */
+ SPARC_I0_REGNUM, /* %i0 */
+ SPARC_I1_REGNUM,
+ SPARC_I2_REGNUM,
+ SPARC_I3_REGNUM,
+ SPARC_I4_REGNUM,
+ SPARC_I5_REGNUM,
+ SPARC_FP_REGNUM, /* %fp (%i6) */
+ SPARC_I7_REGNUM, /* %i7 */
+ SPARC_F0_REGNUM, /* %f0 */
+ SPARC_F1_REGNUM,
+ SPARC_F31_REGNUM /* %f31 */
+ = SPARC_F0_REGNUM + 31
+};
+
+enum sparc32_regnum
+{
+ SPARC32_Y_REGNUM /* %y */
+ = SPARC_F31_REGNUM + 1,
+ SPARC32_PSR_REGNUM, /* %psr */
+ SPARC32_WIM_REGNUM, /* %wim */
+ SPARC32_TBR_REGNUM, /* %tbr */
+ SPARC32_PC_REGNUM, /* %pc */
+ SPARC32_NPC_REGNUM, /* %npc */
+ SPARC32_FSR_REGNUM, /* %fsr */
+ SPARC32_CSR_REGNUM, /* %csr */
+
+ /* Pseudo registers. */
+ SPARC32_D0_REGNUM, /* %d0 */
+ SPARC32_D30_REGNUM /* %d30 */
+ = SPARC32_D0_REGNUM + 15
+};
+
+#define PTRACE_TYPE_ARG3 long
+
+struct pt_regs {
+ unsigned long psr;
+ unsigned long pc;
+ unsigned long npc;
+ unsigned long y;
+ unsigned long u_regs[16];
+};
+
+struct fps {
+ unsigned long regs[32];
+ unsigned long fsr;
+ unsigned long flags;
+ unsigned long extra;
+ unsigned long fpqd;
+ struct fq /*{
+ unsigned long *insnaddr;
+ unsigned long insn;
+ }*/ fpq[16];
+};
+
+#endif /* linux-sparc-low.h */
diff -urN gdb-6.8_orig/gdb/gdbserver/Makefile.in gdb-6.8_new/gdb/gdbserver/Makefile.in
--- gdb-6.8_orig/gdb/gdbserver/Makefile.in 2008-02-12 01:00:31.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/Makefile.in 2008-04-08 09:48:14.000000000 +0400
@@ -127,7 +127,7 @@
$(srcdir)/linux-m32r-low.c \
$(srcdir)/linux-m68k-low.c $(srcdir)/linux-mips-low.c \
$(srcdir)/linux-ppc-low.c $(srcdir)/linux-ppc64-low.c \
- $(srcdir)/linux-s390-low.c \
+ $(srcdir)/linux-s390-low.c $(srcdir)/linux-sparc-low.c \
$(srcdir)/linux-sh-low.c $(srcdir)/linux-x86-64-low.c \
$(srcdir)/linux-xtensa-low.c \
$(srcdir)/win32-arm-low.c $(srcdir)/win32-i386-low.c \
@@ -221,7 +221,7 @@
rm -f reg-ppc.c reg-sh.c reg-spu.c reg-x86-64.c reg-i386-linux.c
rm -f reg-cris.c reg-crisv32.c reg-x86-64-linux.c reg-xtensa.c
rm -f arm-with-iwmmxt.c mips-linux.c mips64-linux.c
- rm -f powerpc-32.c powerpc-64.c powerpc-e500.c
+ rm -f powerpc-32.c powerpc-64.c powerpc-e500.c reg-sparc.c
rm -f xml-builtin.c stamp-xml target.xml
maintainer-clean realclean distclean: clean
@@ -315,6 +315,11 @@
linux-ppc64-low.o: linux-ppc64-low.c $(linux_low_h) $(server_h)
linux-s390-low.o: linux-s390-low.c $(linux_low_h) $(server_h)
linux-sh-low.o: linux-sh-low.c $(linux_low_h) $(server_h)
+
+linux_sparc_low_h = $(srcdir)/linux-sparc-low.h
+
+linux-sparc-low.o: linux-sparc-low.c $(linux_sparc_low_h) $(linux_low_h) \
+ $(server_h)
linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h) \
$(gdb_proc_service_h)
linux-xtensa-low.o: linux-xtensa-low.c xtensa-xtregs.c $(linux_low_h) $(server_h)
@@ -385,6 +390,9 @@
reg-sh.o : reg-sh.c $(regdef_h)
reg-sh.c : $(srcdir)/../regformats/reg-sh.dat $(regdat_sh)
$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-sh.dat reg-sh.c
+reg-sparc.o : reg-sparc.c $(regdef_h)
+reg-sparc.c : $(srcdir)/../regformats/reg-sparc.dat $(regdat_sh)
+ $(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-sparc.dat reg-sparc.c
reg-spu.o : reg-spu.c $(regdef_h)
reg-spu.c : $(srcdir)/../regformats/reg-spu.dat $(regdat_sh)
$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-spu.dat reg-spu.c
diff -urN gdb-6.8_orig/gdb/gdbserver/regcache.c gdb-6.8_new/gdb/gdbserver/regcache.c
--- gdb-6.8_orig/gdb/gdbserver/regcache.c 2008-01-02 01:53:14.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/regcache.c 2008-04-08 11:39:27.000000000 +0400
@@ -53,7 +53,7 @@
/* FIXME - fetch registers for INF */
if (fetch && regcache->registers_valid == 0)
{
- fetch_inferior_registers (0);
+ fetch_inferior_registers (-1);
regcache->registers_valid = 1;
}
@@ -86,6 +86,14 @@
for_each_inferior (&all_threads, regcache_invalidate_one);
}
+int regcache_valid(void)
+{
+ struct inferior_regcache_data *regcache;
+
+ regcache = (struct inferior_regcache_data *) inferior_regcache_data (current_inferior);
+ return regcache->registers_valid;
+}
+
int
registers_length (void)
{
diff -urN gdb-6.8_orig/gdb/gdbserver/regcache.h gdb-6.8_new/gdb/gdbserver/regcache.h
--- gdb-6.8_orig/gdb/gdbserver/regcache.h 2008-01-02 01:53:14.000000000 +0300
+++ gdb-6.8_new/gdb/gdbserver/regcache.h 2008-04-08 10:06:18.000000000 +0400
@@ -34,6 +34,10 @@
void regcache_invalidate_one (struct inferior_list_entry *);
void regcache_invalidate (void);
+/* Valid state of the register cache */
+
+int regcache_valid(void);
+
/* Convert all registers to a string in the currently specified remote
format. */
diff -urN gdb-6.8_orig/gdb/regformats/reg-sparc.dat gdb-6.8_new/gdb/regformats/reg-sparc.dat
--- gdb-6.8_orig/gdb/regformats/reg-sparc.dat 1970-01-01 03:00:00.000000000 +0300
+++ gdb-6.8_new/gdb/regformats/reg-sparc.dat 2008-04-08 01:32:54.000000000 +0400
@@ -0,0 +1,74 @@
+name:sparc
+expedite:pc
+32:g0
+32:g1
+32:g2
+32:g3
+32:g4
+32:g5
+32:g6
+32:g7
+32:o0
+32:o1
+32:o2
+32:o3
+32:o4
+32:o5
+32:sp
+32:o7
+32:l0
+32:l1
+32:l2
+32:l3
+32:l4
+32:l5
+32:l6
+32:l7
+32:i0
+32:i1
+32:i2
+32:i3
+32:i4
+32:i5
+32:fp
+32:i7
+32:f0
+32:f1
+32:f2
+32:f3
+32:f4
+32:f5
+32:f6
+32:f7
+32:f8
+32:f9
+32:f10
+32:f11
+32:f12
+32:f13
+32:f14
+32:f15
+32:f16
+32:f17
+32:f18
+32:f19
+32:f20
+32:f21
+32:f22
+32:f23
+32:f24
+32:f25
+32:f26
+32:f27
+32:f28
+32:f29
+32:f30
+32:f31
+32:y
+32:psr
+32:wim
+32:tbp
+32:pc
+32:npc
+32:fsr
+32:csr
[-- Attachment #3: ChangeLog --]
[-- Type: application/octet-stream, Size: 193 bytes --]
2008-04-08 Aleksei Makhaloff <makhaloff@gmail.com>
* configure.srv: Add target "sparc-*-linux".
* linux-sparc-low.c:
* linux-sparc-low.h: New files.
* regcache.c (regcache_valid): New.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Add linux-sparc gdbserver support
2009-01-16 14:00 Add linux-sparc gdbserver support Aleksei Makhaloff
@ 2009-01-16 14:45 ` Daniel Jacobowitz
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2009-01-16 14:45 UTC (permalink / raw)
To: Aleksei Makhaloff; +Cc: gdb-patches
On Fri, Jan 16, 2009 at 04:59:58PM +0300, Aleksei Makhaloff wrote:
> Hello.
> This patch provide linux-sparc gdbserver support.
> It was tested on Elbrus-90 (http://www.mcst.ru/hardware.shtml
> /russian language/).
Could you try a CVS snapshot, please? Daniel Gutson contributed SPARC
gdbserver support on 2008-11-04.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-16 14:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-16 14:00 Add linux-sparc gdbserver support Aleksei Makhaloff
2009-01-16 14:45 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox