This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: Fix stack backtraces on 26-bit ARM
- To: Andrew Cagney <ac131313 at cygnus dot com>
- Subject: Re: Fix stack backtraces on 26-bit ARM
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Mon, 22 Oct 2001 12:04:02 +0100
- cc: Ben Harris <bjh21 at netbsd dot org>, gdb-patches at sourceware dot cygnus dot com, Jim blandy <jimb at cygnus dot com>, Todd Vierling <tv at wasabisystems dot com>, Richard dot Earnshaw at arm dot com
- Organization: ARM Ltd.
- Reply-To: Richard dot Earnshaw at arm dot com
> Hmm, I have the bones of a completely clean NetBSD/arm port. It isn't
> complete, but it was written without reference to the existing NetBSD code.
>
Ok, attached is most of the code. There's one more patch, which I'll send
separately, that allows ARM targets to be single-stepped when there is no
kernel/hw support for single stepping.
R.
<date> Richard Earnshaw <rearnsha@arm.com>
* config/arm/nbsd.mh config/arm/nbsd.mt config/arm/tm-nbsd.h
config/arm/nm-nbsd.h config/arm/xm-nbsd.h: New files.
* armbsd-nat.c: New file.
* Makefile.in: Build it.
* configure.host configure.tgt: Support NetBSD/arm.
*** /dev/null Mon Oct 22 11:52:05 2001
--- config/arm/nbsd.mh Fri Feb 11 14:02:56 2000
***************
*** 0 ****
--- 1,5 ----
+ # Host ARM running NetBSD
+ XDEPFILES= ser-tcp.o
+ NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o armbsd-nat.o
+ XM_FILE=xm-nbsd.h
+ NAT_FILE=nm-nbsd.h
*** /dev/null Mon Oct 22 11:52:05 2001
--- config/arm/nbsd.mt Tue Nov 28 17:03:58 2000
***************
*** 0 ****
--- 1,3 ----
+ # Target: ARM running NetBSD
+ TDEPFILES= arm-tdep.o solib.o solib-svr4.o
+ TM_FILE= tm-nbsd.h
*** /dev/null Mon Oct 22 11:52:05 2001
--- config/arm/tm-nbsd.h Tue Feb 22 17:01:42 2000
***************
*** 0 ****
--- 1,60 ----
+ /* Macro definitions for ARM running under NetBSD.
+ Copyright 1994, 1999 Free Software Foundation, Inc.
+
+ 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 TM_NBSD_H
+ #define TM_NBSD_H
+
+ /* NetBSD doesn't have single stepping support in ptrace(). */
+ #define SOFTWARE_SINGLE_STEP_P 1
+
+ #include "arm/tm-arm.h"
+ #include "tm-nbsd.h"
+
+ #define JB_ELEMENT_SIZE sizeof(long) /* jmp_buf[_JBLEN] is array of ints */
+ #define JB_PC 24 /* Setjmp()'s return PC saved here */
+
+ /* The first page is not writeable in NetBSD. */
+ #undef LOWEST_PC
+ #define LOWEST_PC 0x8000
+
+ /* Return non-zero if inside a shared-library entry stub. */
+ #undef IN_SOLIB_CALL_TRAMPOLINE
+ #define IN_SOLIB_CALL_TRAMPOLINE(pc, name) \
+ STREQ ((name), "_PROCEDURE_LINKAGE_TABLE_")
+
+ /* Figure out where the longjmp will land. Slurp the args out of the stack.
+ We expect the first arg to be a pointer to the jmp_buf structure from which
+ we extract the pc (JB_PC) that we will land at. The pc is copied into ADDR.
+ This routine returns true on success */
+
+ extern int
+ get_longjmp_target PARAMS ((CORE_ADDR *));
+
+ #define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
+
+ /* For compatibility with previous implemenations of GDB on arm/NetBSD,
+ override the default little-endian breakpoint. */
+ #undef ARM_LE_BREAKPOINT
+ #define ARM_LE_BREAKPOINT {0x11, 0x00, 0x00, 0xe6}
+
+ /* By convention, NetBSD uses the "other" register names. */
+ #define DEFAULT_REGISTER_NAMES additional_register_names
+
+ #endif /* TM_NBSD_H */
*** /dev/null Mon Oct 22 11:52:05 2001
--- config/arm/xm-nbsd.h Fri Feb 11 14:02:21 2000
***************
*** 0 ****
--- 1,22 ----
+ /* Parameters for execution on an ARM running NetBSD, for GDB.
+ Copyright 1994 Free Software Foundation, Inc.
+
+ 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. */
+
+ /* Get generic NetBSD host definitions. */
+ #include "xm-nbsd.h"
*** /dev/null Mon Oct 22 11:52:05 2001
--- config/arm/nm-nbsd.h Fri Feb 11 14:02:21 2000
***************
*** 0 ****
--- 1,33 ----
+ /* Native-dependent definitions for ARM running NetBSD, for GDB.
+ Copyright 1986, 1987, 1989, 1992, 1994, 1999 Free Software Foundation, Inc.
+
+ 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 NM_NBSD_H
+ #define NM_NBSD_H
+
+ /* Get generic NetBSD native definitions. */
+ #include "nm-nbsd.h"
+
+ #define REGISTER_U_ADDR(addr, blockend, regno) \
+ (addr) = arm_register_u_addr ((blockend),(regno));
+
+ extern int
+ arm_register_u_addr PARAMS ((int, int));
+
+ #endif /* NM_NBSD_H */
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.121
diff -p -r1.121 Makefile.in
*** Makefile.in 2001/10/21 19:20:29 1.121
--- Makefile.in 2001/10/22 10:54:17
*************** unexport CHILLFLAGS CHILL_LIB CHILL_FOR_
*** 1170,1176 ****
ALLDEPFILES = 29k-share/udi/udip2soc.c 29k-share/udi/udr.c \
29k-share/udi/udi2go32.c \
a29k-tdep.c a68v-nat.c alpha-nat.c alpha-tdep.c \
! arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \
coff-solib.c \
core-sol2.c core-regset.c core-aout.c corelow.c \
dcache.c delta68-nat.c dpx2-nat.c dstread.c exec.c fork-child.c \
--- 1170,1176 ----
ALLDEPFILES = 29k-share/udi/udip2soc.c 29k-share/udi/udr.c \
29k-share/udi/udi2go32.c \
a29k-tdep.c a68v-nat.c alpha-nat.c alpha-tdep.c \
! arm-linux-nat.c arm-linux-tdep.c arm-tdep.c armbsd-nat.c \
coff-solib.c \
core-sol2.c core-regset.c core-aout.c corelow.c \
dcache.c delta68-nat.c dpx2-nat.c dstread.c exec.c fork-child.c \
*************** arm-linux-tdep.o: arm-linux-tdep.c $(def
*** 1245,1250 ****
--- 1245,1252 ----
arm-tdep.o: arm-tdep.c $(gdbcmd_h) $(gdbcore_h) $(inferior_h) $(defs_h) \
$(gdbcore_h) $(regcache_h) $(doublest_h) $(value_h)
+
+ armbsd-nat.o: armbsd-nat.c $(defs_h)
bcache.o: bcache.c $(bcache_h) $(defs_h)
*** /dev/null Mon Oct 22 11:52:05 2001
--- armbsd-nat.c Mon Feb 14 21:19:39 2000
***************
*** 0 ****
--- 1,96 ----
+ /* Native-dependent code for BSD Unix running on ARM's, for GDB.
+ Copyright 1988, 1989, 1991, 1992, 1994, 1996, 1999 Free Software Foundation, Inc.
+
+ 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 "defs.h"
+
+ #ifdef FETCH_INFERIOR_REGISTERS
+ #include <sys/types.h>
+ #include <sys/ptrace.h>
+ #include <machine/reg.h>
+ #include <machine/frame.h>
+ #include "inferior.h"
+
+ void
+ fetch_inferior_registers (regno)
+ int regno;
+ {
+ struct reg inferior_registers;
+ struct fpreg inferior_fpregisters;
+
+ ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &inferior_registers, 0);
+ memcpy (®isters[REGISTER_BYTE (0)], &inferior_registers,
+ 16 * sizeof (unsigned int));
+ memcpy (®isters[REGISTER_BYTE (PS_REGNUM)], &inferior_registers.r_cpsr,
+ sizeof (unsigned int));
+ ptrace (PT_GETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) &inferior_fpregisters,
+ 0);
+ memcpy (®isters[REGISTER_BYTE (F0_REGNUM)], &inferior_fpregisters.fpr[0],
+ 8 * sizeof (fp_reg_t));
+ memcpy (®isters[REGISTER_BYTE (FPS_REGNUM)],
+ &inferior_fpregisters.fpr_fpsr, sizeof (unsigned int));
+ registers_fetched ();
+ }
+
+ void
+ store_inferior_registers (regno)
+ int regno;
+ {
+ struct reg inferior_registers;
+
+ memcpy (&inferior_registers, ®isters[REGISTER_BYTE (0)],
+ 16 * sizeof (unsigned int));
+ memcpy (&inferior_registers.r_cpsr, ®isters[REGISTER_BYTE (PS_REGNUM)],
+ sizeof (unsigned int));
+ ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &inferior_registers, 0);
+
+ /* XXX Set FP regs. */
+ }
+
+ struct md_core
+ {
+ struct reg intreg;
+ struct fpreg freg;
+ };
+
+ void
+ fetch_core_registers (core_reg_sect, core_reg_size, which, ignore)
+ char *core_reg_sect;
+ unsigned core_reg_size;
+ int which;
+ CORE_ADDR ignore;
+ {
+ struct md_core *core_reg = (struct md_core *) core_reg_sect;
+
+ /* integer registers */
+ memcpy (®isters[REGISTER_BYTE (0)], &core_reg->intreg,
+ sizeof (struct reg));
+ /* floating point registers */
+ /* XXX */
+ }
+
+ #else
+ #error Not FETCH_INFERIOR_REGISTERS
+ #endif /* !FETCH_INFERIOR_REGISTERS */
+
+ int
+ get_longjmp_target (CORE_ADDR *addr)
+ {
+ return 0;
+ }
Index: configure.host
===================================================================
RCS file: /cvs/src/src/gdb/configure.host,v
retrieving revision 1.23
diff -p -r1.23 configure.host
*** configure.host 2001/07/10 20:41:54 1.23
--- configure.host 2001/10/22 10:56:44
*************** alpha*-*-linux*) gdb_host=alpha-linux ;;
*** 37,42 ****
--- 37,43 ----
alpha*-*-freebsd*) gdb_host=fbsd ;;
arm*-*-linux*) gdb_host=linux ;;
+ arm*-*-netbsd*) gdb_host=nbsd ;;
arm*-*-*) gdb_host=arm ;;
hppa*-*-bsd*) gdb_host=hppabsd ;;
Index: configure.tgt
===================================================================
RCS file: /cvs/src/src/gdb/configure.tgt,v
retrieving revision 1.35
diff -p -r1.35 configure.tgt
*** configure.tgt 2001/08/12 03:39:11 1.35
--- configure.tgt 2001/10/22 10:56:44
*************** arm*-wince-pe) gdb_target=wince ;;
*** 55,60 ****
--- 55,61 ----
arm*-*-linux*) gdb_target=linux
configdirs="$configdirs gdbserver"
;;
+ arm*-*-netbsd*) gdb_target=nbsd ;;
arm*-*-* | thumb*-*-* | strongarm*-*-*)
gdb_target=embed
configdirs="$configdirs rdi-share"