From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24408 invoked by alias); 12 Apr 2005 05:03:43 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24384 invoked from network); 12 Apr 2005 05:03:36 -0000 Received: from unknown (HELO mail02.idc.renesas.com) (202.234.163.13) by sourceware.org with SMTP; 12 Apr 2005 05:03:36 -0000 Received: (from root@localhost) by guardian01.idc.renesas.com with id j3C53X9f027414 for gdb-patches@sources.redhat.com; Tue, 12 Apr 2005 14:03:33 +0900 (JST) Received: from unknown [172.20.8.73] by guardian01.idc.renesas.com with SMTP id QAA27413 ; Tue, 12 Apr 2005 14:03:33 +0900 Received: from E5A02646 ([10.145.105.81]) by ims06.idc.renesas.com (Sendmail) with ESMTPA id <0IET007N4I1XPU@ims06.idc.renesas.com> for gdb-patches@sources.redhat.com; Tue, 12 Apr 2005 14:03:33 +0900 (JST) Date: Tue, 12 Apr 2005 05:03:00 -0000 From: Kei Sakamoto Subject: [RFC/m32r] Add gdbserver support to m32r-linux To: gdb-patches@sources.redhat.com Message-id: <016101c53f1d$67b40660$5169910a@E5A02646> MIME-version: 1.0 Content-type: multipart/mixed; boundary="----=_NextPart_000_015E_01C53F68.CB715CC0" X-SW-Source: 2005-04/txt/msg00090.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_015E_01C53F68.CB715CC0 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit Content-length: 868 Hello, The attached patch adds gdbserver support to m32r-linux target. It uses PTRACE_PEEKUSR instead of PTRCE_GETREGS. I posted the same patch last year and I was told that PTRACE_GETREGS was preferable. I tried to implement m32r-linux gdbserver with it. But somehow gdbserver with PTRACE_GETREGS does not work correctly and I'm afraid that it would take a long time to debug it. I'm going to commit the patch which uses PTRACE_PEEKUSR and replace it with one which uses PTRACE_GETREGS later. Any comments? Kei Sakamoto gdb/ChangeLog: 2005-05-05 Kei Sakamoto * regformats/reg-m32r.dat: New file. gdb/gdbserver/ChangeLog: 2005-05-05 Kei Sakamoto * Makefile.in: Add linux-m32r-low.o, reg-m32r.c and reg-m32r.o. * configure.srv: Add m32r*-*-linux*. * linux-m32r-low.c: New file. ------=_NextPart_000_015E_01C53F68.CB715CC0 Content-Type: application/octet-stream; name="gdbserver.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="gdbserver.patch" Content-length: 7609 Index: gdbserver/Makefile.in=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/gdbserver/Makefile.in,v=0A= retrieving revision 1.28=0A= diff -u -r1.28 Makefile.in=0A= --- gdbserver/Makefile.in 4 Mar 2005 18:16:25 -0000 1.28=0A= +++ gdbserver/Makefile.in 12 Apr 2005 04:27:26 -0000=0A= @@ -121,6 +121,7 @@=0A= $(srcdir)/linux-arm-low.c $(srcdir)/linux-i386-low.c \=0A= $(srcdir)/i387-fp.c \=0A= $(srcdir)/linux-ia64-low.c $(srcdir)/linux-low.c \=0A= + $(srcdir)/linux-m32r-low.c \=0A= $(srcdir)/linux-m68k-low.c $(srcdir)/linux-mips-low.c \=0A= $(srcdir)/linux-ppc-low.c $(srcdir)/linux-s390-low.c \=0A= $(srcdir)/linux-sh-low.c $(srcdir)/linux-x86-64-low.c=0A= @@ -198,7 +199,7 @@=0A= clean:=0A= rm -f *.o ${ADD_FILES} *~=0A= rm -f gdbserver gdbreplay core make.log=0A= - rm -f reg-arm.c reg-i386.c reg-ia64.c reg-m68k.c reg-mips.c=0A= + rm -f reg-arm.c reg-i386.c reg-ia64.c reg-m32r.c reg-m68k.c reg-mips.c=0A= rm -f reg-ppc.c reg-sh.c reg-x86-64.c reg-i386-linux.c=0A= =20=0A= maintainer-clean realclean distclean: clean=0A= @@ -263,6 +264,7 @@=0A= linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h)=0A= linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h)=0A= linux-ia64-low.o: linux-ia64-low.c $(linux_low_h) $(server_h)=0A= +linux-m32r-low.o: linux-m32r-low.c $(linux_low_h) $(server_h) ../m32r-tdep= .h=0A= linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h)=0A= linux-ppc-low.o: linux-ppc-low.c $(linux_low_h) $(server_h)=0A= linux-s390-low.o: linux-s390-low.c $(linux_low_h) $(server_h)=0A= @@ -281,6 +283,9 @@=0A= reg-ia64.o : reg-ia64.c $(regdef_h)=0A= reg-ia64.c : $(srcdir)/../regformats/reg-ia64.dat $(regdat_sh)=0A= sh $(regdat_sh) $(srcdir)/../regformats/reg-ia64.dat reg-ia64.c=0A= +reg-m32r.o : reg-m32r.c $(regdef_h)=0A= +reg-m32r.c : $(srcdir)/../regformats/reg-m32r.dat $(regdat_sh)=0A= + sh $(regdat_sh) $(srcdir)/../regformats/reg-m32r.dat reg-m32r.c=0A= reg-m68k.o : reg-m68k.c $(regdef_h)=0A= reg-m68k.c : $(srcdir)/../regformats/reg-m68k.dat $(regdat_sh)=0A= sh $(regdat_sh) $(srcdir)/../regformats/reg-m68k.dat reg-m68k.c=0A= Index: gdbserver/configure.srv=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/gdbserver/configure.srv,v=0A= retrieving revision 1.8=0A= diff -u -r1.8 configure.srv=0A= --- gdbserver/configure.srv 21 Nov 2004 03:09:39 -0000 1.8=0A= +++ gdbserver/configure.srv 12 Apr 2005 04:27:26 -0000=0A= @@ -33,6 +33,11 @@=0A= srv_tgtobj=3D"linux-low.o linux-ia64-low.o"=0A= srv_linux_usrregs=3Dyes=0A= ;;=0A= + m32r*-*-linux*) srv_regobj=3Dreg-m32r.o=0A= + srv_tgtobj=3D"linux-low.o linux-m32r-low.o"=0A= + srv_linux_usrregs=3Dyes=0A= + srv_linux_thread_db=3Dyes=0A= + ;;=0A= m68*-*-linux*) srv_regobj=3Dreg-m68k.o=0A= srv_tgtobj=3D"linux-low.o linux-m68k-low.o"=0A= srv_linux_usrregs=3Dyes=0A= Index: gdbserver/linux-m32r-low.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: gdbserver/linux-m32r-low.c=0A= diff -N gdbserver/linux-m32r-low.c=0A= --- /dev/null 1 Jan 1970 00:00:00 -0000=0A= +++ gdbserver/linux-m32r-low.c 12 Apr 2005 04:27:26 -0000=0A= @@ -0,0 +1,98 @@=0A= +/* GNU/Linux/m32r specific low level interface, for the remote server for = GDB.=0A= + Copyright 2005 Free Software Foundation, Inc.=0A= +=0A= + This file is part of GDB.=0A= +=0A= + This program is free software; you can redistribute it and/or modify=0A= + it under the terms of the GNU General Public License as published by=0A= + the Free Software Foundation; either version 2 of the License, or=0A= + (at your option) any later version.=0A= +=0A= + This program is distributed in the hope that it will be useful,=0A= + but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= + GNU General Public License for more details.=0A= +=0A= + You should have received a copy of the GNU General Public License=0A= + along with this program; if not, write to the Free Software=0A= + Foundation, Inc., 59 Temple Place - Suite 330,=0A= + Boston, MA 02111-1307, USA. */=0A= +=0A= +#include "server.h"=0A= +#include "linux-low.h"=0A= +=0A= +#ifdef HAVE_SYS_REG_H=0A= +#include =0A= +#endif=0A= +=0A= +#define m32r_num_regs 25=0A= +=0A= +static int m32r_regmap[] =3D {=0A= +#ifdef PT_R0=0A= + PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,=0A= + PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_FP, PT_LR, PT_SPU,=0A= + PT_PSW, PT_CBR, PT_SPI, PT_SPU, PT_BPC, PT_PC, PT_ACCL, PT_ACCH, PT_EVB= =0A= +#else=0A= + 4 * 4, 4 * 5, 4 * 6, 4 * 7, 4 * 0, 4 * 1, 4 * 2, 4 * 8,=0A= + 4 * 9, 4 * 10, 4 * 11, 4 * 12, 4 * 13, 4 * 24, 4 * 25, 4 * 23,=0A= + 4 * 19, 4 * 31, 4 * 26, 4 * 23, 4 * 20, 4 * 30, 4 * 16, 4 * 15, 4 * 32= =0A= +#endif=0A= +};=0A= +=0A= +static int=0A= +m32r_cannot_store_register (int regno)=0A= +{=0A= + return (regno >=3D m32r_num_regs);=0A= +}=0A= +=0A= +static int=0A= +m32r_cannot_fetch_register (int regno)=0A= +{=0A= + return (regno >=3D m32r_num_regs);=0A= +}=0A= +=0A= +static CORE_ADDR=0A= +m32r_get_pc ()=0A= +{=0A= + unsigned long pc;=0A= + collect_register_by_name ("pc", &pc);=0A= + return pc;=0A= +}=0A= +=0A= +static void=0A= +m32r_set_pc (CORE_ADDR pc)=0A= +{=0A= + unsigned long newpc =3D pc;=0A= + supply_register_by_name ("pc", &newpc);=0A= +}=0A= +=0A= +static const unsigned short m32r_breakpoint =3D 0x10f1;=0A= +#define m32r_breakpoint_len 2=0A= +=0A= +static int=0A= +m32r_breakpoint_at (CORE_ADDR where)=0A= +{=0A= + unsigned short insn;=0A= +=0A= + (*the_target->read_memory) (where, (char *) &insn, m32r_breakpoint_len);= =0A= + if (insn =3D=3D m32r_breakpoint)=0A= + return 1;=0A= +=0A= + /* If necessary, recognize more trap instructions here. GDB only uses t= he=0A= + one. */=0A= + return 0;=0A= +}=0A= +=0A= +struct linux_target_ops the_low_target =3D {=0A= + m32r_num_regs,=0A= + m32r_regmap,=0A= + m32r_cannot_fetch_register,=0A= + m32r_cannot_store_register,=0A= + m32r_get_pc,=0A= + m32r_set_pc,=0A= + (const char *) &m32r_breakpoint,=0A= + m32r_breakpoint_len,=0A= + NULL,=0A= + 0,=0A= + m32r_breakpoint_at,=0A= +};=0A= Index: regformats/reg-m32r.dat=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: regformats/reg-m32r.dat=0A= diff -N regformats/reg-m32r.dat=0A= --- /dev/null 1 Jan 1970 00:00:00 -0000=0A= +++ regformats/reg-m32r.dat 12 Apr 2005 04:27:26 -0000=0A= @@ -0,0 +1,45 @@=0A= +name:m32r=0A= +expedite:pc,lr,sp=0A= +32:r0=0A= +32:r1=0A= +32:r2=0A= +32:r3=0A= +32:r4=0A= +32:r5=0A= +32:r6=0A= +32:r7=0A= +32:r8=0A= +32:r9=0A= +32:r10=0A= +32:r11=0A= +32:r12=0A= +32:fp=0A= +32:lr=0A= +32:sp=0A= +32:psw=0A= +32:cbr=0A= +32:spi=0A= +32:spu=0A= +32:bpc=0A= +32:pc=0A= +32:accl=0A= +32:acch=0A= +=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= +32:=0A= ------=_NextPart_000_015E_01C53F68.CB715CC0--