* support for ARM GNU/Linux
@ 1999-04-12 12:26 Philip Blundell
1999-04-12 13:19 ` Scott Bambrough
1999-04-12 20:18 ` Jim Blandy
0 siblings, 2 replies; 13+ messages in thread
From: Philip Blundell @ 1999-04-12 12:26 UTC (permalink / raw)
To: gdb-patches
This patch adds support for GNU/Linux running on ARM systems.
p.
1999-04-12 Philip Blundell <philb@gnu.org>
Scott Bambrough <scottb@corelcomputer.com>
Support for ARM GNU/Linux:
* configure.tgt: Recognize arm*-*-linux* configuration. Set
cpu name to `arm' for any `arm*-*-*' configuration name.
* configure.host: Likewise.
* config/arm/linux.mh, config/arm/linux.mt: New files.
* config/arm/tm-linux.h, config-arm/xm-linux.h,
config/arm/nm-linux.h: Likewise.
* armlnx-tdep.c, armlnx-xdep.c, armlnx-nat.c: Likewise.
* arm-tdep.c (ARM_LE_BREAKPOINT, ARM_BE_BREAKPOINT,
THUMB_LE_BREAKPOINT, THUMB_BE_BREAKPOINT, LOWEST_PC,
LITTLE_BREAKPOINT, BIG_BREAKPOINT): Move
definitions to...
* config/arm/tm-arm.h: ... here.
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/arm-tdep.c gdb/arm-tdep.c
--- /home/phil/gdb/clean/gdb-4.17/gdb/arm-tdep.c Sun Apr 11 21:56:56 1999
+++ gdb/arm-tdep.c Sun Apr 11 19:06:08 1999
@@ -61,7 +61,6 @@
CORE_ADDR chain;
struct frame_info *thisframe;
{
-#define LOWEST_PC 0x20 /* the first 0x20 bytes are the trap vectors. */
return (chain != 0 && (FRAME_SAVED_PC (thisframe) >= LOWEST_PC));
}
@@ -1487,17 +1486,6 @@
else
return print_insn_little_arm (memaddr, info);
}
-
-/* Sequence of bytes for breakpoint instruction. */
-#define ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7} /* Recognized illegal opcodes */
-#define ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE}
-#define THUMB_LE_BREAKPOINT {0xfe,0xdf}
-#define THUMB_BE_BREAKPOINT {0xdf,0xfe}
-
-/* The following has been superseded by BREAKPOINT_FOR_PC, but
- is defined merely to keep mem-break.c happy. */
-#define LITTLE_BREAKPOINT ARM_LE_BREAKPOINT
-#define BIG_BREAKPOINT ARM_BE_BREAKPOINT
/* This function implements the BREAKPOINT_FROM_PC macro. It uses the program
counter value to determine whether a 16- or 32-bit breakpoint should be
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/armlnx-nat.c gdb/armlnx-nat.c
--- /home/phil/gdb/clean/gdb-4.17/gdb/armlnx-nat.c Thu Jan 1 01:00:00 1970
+++ gdb/armlnx-nat.c Sun Apr 11 19:11:51 1999
@@ -0,0 +1,148 @@
+/* ARM native support for SYSV systems (pre-SVR4).
+ Copyright (C) 1988, 89, 91, 92, 94, 96, 99 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"
+#include "inferior.h"
+#include <sys/ptrace.h>
+#include "gdbcore.h"
+#include <sys/user.h> /* After a.out.h */
+
+int
+arm_register_u_addr(blockend, regnum)
+ int blockend;
+ int regnum;
+{
+ return blockend + REGISTER_BYTE(regnum);
+}
+
+int
+kernel_u_size()
+{
+ return (sizeof (struct user));
+}
+
+#ifdef HAVE_GREGSET_T
+#include <sys/procfs.h>
+
+/* Given a pointer to a general register set in /proc format
+ (gregset_t *), unpack the register contents and supply them as
+ gdb's idea of the current register values. */
+
+void
+supply_gregset (gregsetp)
+ gregset_t *gregsetp;
+{
+ int i;
+
+ for (i = 0; i < 26; i++)
+ supply_register(i, (char *) (*gregsetp + i));
+}
+
+#endif
+
+void
+fetch_inferior_registers (regno)
+ int regno; /* Original value discarded */
+{
+ register int i;
+ register unsigned int regaddr;
+ char buf[MAX_REGISTER_RAW_SIZE];
+
+ struct user u;
+ unsigned int offset = (char*)&u.u_ar0 - (char*)&u;
+ offset = ptrace(PT_READ_U,inferior_pid,
+ (PTRACE_ARG3_TYPE)offset,0) - KERNEL_U_ADDR;
+
+ registers_fetched();
+
+ for (regno = 0; regno < NUM_GREGS; regno++)
+ {
+ regaddr = offset + regno * sizeof(long);
+ *(int*)&buf[0] = ptrace(PT_READ_U,inferior_pid,
+ (PTRACE_ARG3_TYPE)regaddr,0);
+ if (regno == PC_REGNUM)
+ *(int*)&buf[0] = GET_PC_PART(*(int*)&buf[0]);
+ supply_register(regno,buf);
+ }
+
+ *(int*)&buf[0] = ptrace(PT_READ_U,inferior_pid,
+ (PTRACE_ARG3_TYPE)(offset + PC_REGNUM*sizeof(long)),
+ 0);
+ supply_register (PS_REGNUM,buf); /* set virtual register ps same as pc */
+
+ /* read the floating point registers */
+ offset = (char*)&u.u_fp0 - (char *)&u;
+ *(int*)buf = ptrace(PT_READ_U,inferior_pid,(PTRACE_ARG3_TYPE)offset,0);
+ supply_register(FPS_REGNUM,buf);
+
+ for (regno = 16; regno < 24; regno++) {
+ regaddr = offset /* + 4 */ + 12 * (regno - 16);
+ for (i = 0; i < 12; i += sizeof(int))
+ *(int*) &buf[i] = ptrace(PT_READ_U, inferior_pid,
+ (PTRACE_ARG3_TYPE)(regaddr + i), 0);
+ supply_register(regno,buf);
+ }
+}
+
+/* Store our register values back into the inferior.
+ If REGNO is -1, do this for all registers.
+ Otherwise, REGNO specifies which register (so we can save time). */
+
+void
+store_inferior_registers (regno)
+ int regno;
+{
+ register unsigned int regaddr;
+ char buf[80];
+
+ struct user u;
+ unsigned long value;
+ unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
+ offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0)
+ - KERNEL_U_ADDR;
+
+ if (regno >= 0) {
+ if (regno >= 16) return;
+ regaddr = offset + 4 * regno;
+ errno = 0;
+ value = read_register(regno);
+ if (regno == PC_REGNUM)
+ value = SET_PC_PART(read_register (PS_REGNUM), value);
+ ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value);
+ if (errno != 0)
+ {
+ sprintf (buf, "writing register number %d", regno);
+ perror_with_name (buf);
+ }
+ }
+ else for (regno = 0; regno < 15; regno++)
+ {
+ regaddr = offset + regno * 4;
+ errno = 0;
+ value = read_register(regno);
+ if (regno == PC_REGNUM)
+ value = SET_PC_PART(read_register (PS_REGNUM), value);
+ ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value);
+ if (errno != 0)
+ {
+ sprintf (buf, "writing all regs, number %d", regno);
+ perror_with_name (buf);
+ }
+ }
+}
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/armlnx-tdep.c gdb/armlnx-tdep.c
--- /home/phil/gdb/clean/gdb-4.17/gdb/armlnx-tdep.c Thu Jan 1 01:00:00 1970
+++ gdb/armlnx-tdep.c Sun Apr 11 14:12:18 1999
@@ -0,0 +1,65 @@
+/* Target-dependent code for the ArmLinux, for GDB, the GNU Debugger.
+ Copyright 1988, 1989, 1991, 1992, 1993, 1995 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"
+#include "frame.h"
+#include "inferior.h"
+
+/* APCS (ARM procedure call standard) defines the following prologue:
+
+ mov ip, sp
+ [stmfd sp!, {a1,a2,a3,a4}]
+ stmfd sp!, {...,fp,ip,lr,pc}
+ [stfe f7, [sp, #-12]!]
+ [stfe f6, [sp, #-12]!]
+ [stfe f5, [sp, #-12]!]
+ [stfe f4, [sp, #-12]!]
+ sub fp, ip, #nn // nn == 20 or 4 depending on second ins
+*/
+
+void
+arm_extract_return_value(type, regbuf, valbuf)
+ struct type *type;
+ char regbuf[];
+ void *valbuf;
+{
+ if (TYPE_CODE_FLT == TYPE_CODE(type))
+ convert_from_extended(regbuf + REGISTER_BYTE(F0_REGNUM), valbuf);
+ else
+ memcpy(valbuf, regbuf, TYPE_LENGTH(type));
+}
+
+/* not in generic code, macro in tm-arm.h */
+void
+arm_store_return_value(type, valbuf)
+ struct type *type;
+ void *valbuf;
+{
+ if (TYPE_CODE_FLT == TYPE_CODE(type)) {
+ char _buf[MAX_REGISTER_RAW_SIZE];
+ convert_to_extended(valbuf, _buf);
+ write_register_bytes(REGISTER_BYTE(F0_REGNUM), _buf, MAX_REGISTER_RAW_SIZE);
+ } else
+ write_register_bytes(0, valbuf, TYPE_LENGTH(type));
+}
+
+void
+_initialize_linux_tdep(void)
+{
+}
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/linux.mh gdb/config/arm/linux.mh
--- /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/linux.mh Thu Jan 1 01:00:00 1970
+++ gdb/config/arm/linux.mh Sun Apr 11 16:38:20 1999
@@ -0,0 +1,8 @@
+# Host: ARM running GNU/Linux
+
+XM_FILE= xm-linux.h
+XDEPFILES= ser-tcp.o
+
+NAT_FILE= nm-linux.h
+NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o corelow.o core-aout.o core-regset.o armlnx-nat.o
+GDBSERVER_DEPFILES= low-linux.o
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/linux.mt gdb/config/arm/linux.mt
--- /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/linux.mt Thu Jan 1 01:00:00 1970
+++ gdb/config/arm/linux.mt Sun Apr 11 15:47:57 1999
@@ -0,0 +1,6 @@
+# Target: ARM running GNU/Linux with a.out and ELF
+
+TDEPFILES= armlnx-tdep.o arm-tdep.o
+TM_FILE= tm-linux.h
+
+GDBSERVER_DEPFILES= low-linux.o
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/nm-linux.h gdb/config/arm/nm-linux.h
--- /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/nm-linux.h Thu Jan 1 01:00:00 1970
+++ gdb/config/arm/nm-linux.h Sun Apr 11 19:46:55 1999
@@ -0,0 +1,45 @@
+/* Native machine definitions for GDB on ARM running GNU/Linux
+ Copyright (C) 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_LINUX_H
+#define NM_LINUX_H
+
+/* Tell gdb that we can attach and detach other processes */
+#define ATTACH_DETACH
+
+/* We define this if link.h is available, because with ELF we use SVR4 style
+ shared libraries. */
+#ifdef HAVE_LINK_H
+#define SVR4_SHARED_LIBS
+#include "solib.h" /* Support for shared libraries. */
+#endif
+
+/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */
+#define FETCH_INFERIOR_REGISTERS
+
+#define REGISTER_U_ADDR(addr, blockend, regno) \
+ (addr) = arm_register_u_addr ((blockend),(regno));
+
+#ifdef __ARMEB__
+#define HOST_BYTE_ORDER BIG_ENDIAN
+#else
+#define HOST_BYTE_ORDER LITTLE_ENDIAN
+#endif
+
+#endif /* NM_LINUX_H */
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/tm-arm.h gdb/config/arm/tm-arm.h
--- /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/tm-arm.h Sun Apr 11 21:56:59 1999
+++ gdb/config/arm/tm-arm.h Sun Apr 11 19:12:27 1999
@@ -118,6 +120,7 @@
that I can clear the status bits from pc (register 15) */
#define NUM_REGS 26
+#define NUM_GREGS 16
/* An array of names of registers. */
@@ -451,3 +454,16 @@
#undef IN_SIGTRAMP
#define IN_SIGTRAMP(pc, name) 0
+
+/* Sequence of bytes for breakpoint instruction. */
+#define ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7} /* Recognized illegal opcodes */
+#define ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE}
+#define THUMB_LE_BREAKPOINT {0xfe,0xdf}
+#define THUMB_BE_BREAKPOINT {0xdf,0xfe}
+
+/* The following has been superseded by BREAKPOINT_FOR_PC, but
+ is defined merely to keep mem-break.c happy. */
+#define LITTLE_BREAKPOINT ARM_LE_BREAKPOINT
+#define BIG_BREAKPOINT ARM_BE_BREAKPOINT
+
+#define LOWEST_PC 0x20 /* the first 0x20 bytes are the trap vectors. */
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/tm-linux.h gdb/config/arm/tm-linux.h
--- /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/tm-linux.h Thu Jan 1 01:00:00 1970
+++ gdb/config/arm/tm-linux.h Sun Apr 11 17:37:22 1999
@@ -0,0 +1,93 @@
+/* Definitions to target GDB to ARM GNU/Linux
+ Copyright 1992, 1993, 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_LINUX_H__
+#define __TM_LINUX_H__
+
+/* Scott: SHLIBLEN from bfd/riscix.c. */
+#define SHLIBLEN 60
+
+/* Offset to saved PC in sigcontext, from <linux/signal.h>. */
+#define SIGCONTEXT_PC_OFFSET (sizeof(unsigned long) + sizeof(long) * 15)
+
+/* Number of traps that happen between exec'ing the shell to run an
+ inferior, and when we finally get to the inferior code. This is 2
+ on most implementations. */
+#define START_INFERIOR_TRAPS_EXPECTED 2
+
+/* The following is used in the macro CALL_DUMMY in tm-arm.h. */
+#define OS_BKPT_SWI 0xef9f0001
+
+/* Add command to set APCS_32 debugger variable. Used to determine if
+ 32 bit or 26 bit program counter is being used. Set to 1 to add the
+ command to the debugger. */
+#define ADD_SET_APCS_COMMAND 0
+
+/* It is unknown which, if any, SVR4 assemblers do not accept dollar signs
+ in identifiers. The default in G++ is to use dots instead, for all SVR4
+ systems, so we make that our default also. FIXME: There should be some
+ way to get G++ to tell us what CPLUS_MARKER it is using, perhaps by
+ stashing it in the debugging information as part of the name of an
+ invented symbol ("gcc_cplus_marker$" for example). */
+
+#undef CPLUS_MARKER
+#define CPLUS_MARKER '.'
+
+/* Include the generic ARM target header. */
+#include "arm/tm-arm.h"
+
+/* The following are used in arm_breakpoint_from_pc() in arm-tdep.c */
+#undef ARM_LE_BREAKPOINT
+#define ARM_LE_BREAKPOINT {0x01,0x00,0x9f,0xef} /* swi 0x9f0001 */
+#undef ARM_BE_BREAKPOINT
+#define ARM_BE_BREAKPOINT {0xef,0x9f,0x00,0x01}
+
+/* This is used in the macro FRAME_CHAIN_VALID in tm-arm.h. */
+#undef LOWEST_PC
+#define LOWEST_PC 0x8000 /* the first page is not writable in ARM Linux. */
+
+/* For SVR4 shared libraries, each call to a library routine goes through
+ a small piece of trampoline code in the ".plt" section.
+ The horribly ugly wait_for_inferior() routine uses this macro to detect
+ when we have stepped into one of these fragments.
+ We do not use lookup_solib_trampoline_symbol_by_pc, because
+ we cannot always find the shared library trampoline symbols
+ (e.g. on Irix5). */
+extern int in_plt_section PARAMS ((CORE_ADDR, char *));
+
+/* If PC is in a shared library trampoline code, return the PC
+ where the function itself actually starts. If not, return 0. */
+#undef SKIP_TRAMPOLINE_CODE
+#define SKIP_TRAMPOLINE_CODE(pc) \
+ ((in_plt_section((pc), NULL) ? find_solib_trampoline_target (pc) \
+ : arm_skip_stub (pc)))
+
+#undef IN_SOLIB_CALL_TRAMPOLINE
+#define IN_SOLIB_CALL_TRAMPOLINE(pc, name) (in_plt_section((pc), (name)) \
+ || arm_in_call_stub (pc, name))
+
+#ifndef GET_PC_PART
+#define GET_PC_PART(addr) ADDR_BITS_REMOVE(addr)
+#endif
+
+#ifndef SET_PC_PART
+#define SET_PC_PART(old,new) new
+#endif
+
+#endif /* #ifndef TM_LINUX_H */
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/xm-linux.h gdb/config/arm/xm-linux.h
--- /home/phil/gdb/clean/gdb-4.17/gdb/config/arm/xm-linux.h Thu Jan 1 01:00:00 1970
+++ gdb/config/arm/xm-linux.h Sun Apr 11 14:52:44 1999
@@ -0,0 +1,36 @@
+/* Native support for Linux, for GDB, the GNU debugger.
+ Copyright (C) 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 __XM_LINUX_H__
+#define __XM_LINUX_H__
+
+#include "arm/xm-arm.h"
+
+#define HAVE_TERMIOS
+
+/* This is the amount to subtract from u.u_ar0
+ to get the offset in the core file of the register values. */
+#define KERNEL_U_ADDR 0x0
+
+#define NEED_POSIX_SETPGID
+
+/* Need R_OK etc, but USG isn't defined. */
+#include <unistd.h>
+
+#endif /* __XM_LINUX_H__ */
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/configure.host gdb/configure.host
--- /home/phil/gdb/clean/gdb-4.17/gdb/configure.host Sun Apr 11 21:57:06 1999
+++ gdb/configure.host Sun Apr 11 15:13:31 1999
@@ -11,6 +11,7 @@
case "${host_cpu}" in
alpha*) gdb_host_cpu=alpha ;;
+arm*) gdb_host_cpu=arm ;;
c[12]) gdb_host_cpu=convex ;;
hppa*) gdb_host_cpu=pa ;;
i[3456]86*) gdb_host_cpu=i386 ;;
@@ -35,6 +36,7 @@
alpha*-*-osf[3456789]*) gdb_host=alpha-osf3 ;;
alpha*-*-linux*) gdb_host=alpha-linux ;;
+arm*-*-linux*) gdb_host=linux ;;
arm-*-*) gdb_host=arm ;;
c[12]-*-*) gdb_host=convex ;;
diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/configure.tgt gdb/configure.tgt
--- /home/phil/gdb/clean/gdb-4.17/gdb/configure.tgt Sun Apr 11 21:57:07 1999
+++ gdb/configure.tgt Sun Apr 11 15:19:26 1999
@@ -13,6 +13,7 @@
case "${target_cpu}" in
alpha*) gdb_target_cpu=alpha ;;
+arm*) gdb_target_cpu=arm ;;
c[12]) gdb_target_cpu=convex ;;
hppa*) gdb_target_cpu=pa ;;
i[3456]86*) gdb_target_cpu=i386 ;;
@@ -50,6 +51,8 @@
arc-*-*) gdb_target=arc ;;
+arm*-*-linux*) gdb_target=linux
+ configdirs="${configdirs} gdbserver" ;;
arm-*-* | thumb-*-* | strongarm-*-*) gdb_target=arm
# rdi doesn't work for wingdb yet
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: support for ARM GNU/Linux
1999-04-12 12:26 support for ARM GNU/Linux Philip Blundell
@ 1999-04-12 13:19 ` Scott Bambrough
1999-04-12 14:12 ` Scott Bambrough
1999-04-12 14:27 ` Philip Blundell
1999-04-12 20:18 ` Jim Blandy
1 sibling, 2 replies; 13+ messages in thread
From: Scott Bambrough @ 1999-04-12 13:19 UTC (permalink / raw)
To: gdb-patches
Philip Blundell wrote:
>
> This patch adds support for GNU/Linux running on ARM systems.
>
> p.
>
> 1999-04-12 Philip Blundell <philb@gnu.org>
> Scott Bambrough <scottb@corelcomputer.com>
>
> Support for ARM GNU/Linux:
> * configure.tgt: Recognize arm*-*-linux* configuration. Set
> cpu name to `arm' for any `arm*-*-*' configuration name.
> * configure.host: Likewise.
> * config/arm/linux.mh, config/arm/linux.mt: New files.
> * config/arm/tm-linux.h, config-arm/xm-linux.h,
> config/arm/nm-linux.h: Likewise.
> * armlnx-tdep.c, armlnx-xdep.c, armlnx-nat.c: Likewise.
>
> * arm-tdep.c (ARM_LE_BREAKPOINT, ARM_BE_BREAKPOINT,
> THUMB_LE_BREAKPOINT, THUMB_BE_BREAKPOINT, LOWEST_PC,
> LITTLE_BREAKPOINT, BIG_BREAKPOINT): Move
> definitions to...
> * config/arm/tm-arm.h: ... here.
>
I don't believe the bfd support in the GDB snapshots will support this target
ATM, that's why I haven't submitted my changes for inclusion in GDB. Be
forewarned.
Scott
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: support for ARM GNU/Linux
1999-04-12 13:19 ` Scott Bambrough
@ 1999-04-12 14:12 ` Scott Bambrough
1999-04-12 14:27 ` Philip Blundell
1 sibling, 0 replies; 13+ messages in thread
From: Scott Bambrough @ 1999-04-12 14:12 UTC (permalink / raw)
To: gdb-patches
Philip Blundell wrote:
>
> This patch adds support for GNU/Linux running on ARM systems.
>
> p.
>
> 1999-04-12 Philip Blundell <philb@gnu.org>
> Scott Bambrough <scottb@corelcomputer.com>
>
> Support for ARM GNU/Linux:
> * configure.tgt: Recognize arm*-*-linux* configuration. Set
> cpu name to `arm' for any `arm*-*-*' configuration name.
> * configure.host: Likewise.
> * config/arm/linux.mh, config/arm/linux.mt: New files.
> * config/arm/tm-linux.h, config-arm/xm-linux.h,
> config/arm/nm-linux.h: Likewise.
> * armlnx-tdep.c, armlnx-xdep.c, armlnx-nat.c: Likewise.
>
> * arm-tdep.c (ARM_LE_BREAKPOINT, ARM_BE_BREAKPOINT,
> THUMB_LE_BREAKPOINT, THUMB_BE_BREAKPOINT, LOWEST_PC,
> LITTLE_BREAKPOINT, BIG_BREAKPOINT): Move
> definitions to...
> * config/arm/tm-arm.h: ... here.
>
I don't believe the bfd support in the GDB snapshots will support this target
ATM, that's why I haven't submitted my changes for inclusion in GDB. Be
forewarned.
Scott
From philb@gnu.org Mon Apr 12 15:42:00 1999
From: Philip Blundell <philb@gnu.org>
To: scottb@corelcomputer.com
Cc: gdb-patches@cygnus.com
Subject: Re: support for ARM GNU/Linux
Date: Mon, 12 Apr 1999 15:42:00 -0000
Message-id: <E10WoEr-0006c8-00@kings-cross.london.uk.eu.org>
References: <371258E5.512C0F84@corelcomputer.com>
X-SW-Source: 1999-04/msg00013.html
Content-length: 373
>I don't believe the bfd support in the GDB snapshots will support this target
>ATM, that's why I haven't submitted my changes for inclusion in GDB. Be
>forewarned.
There are possibly a few changes that need pulling over from gas2, but broadly
speaking I think it ought to work. I must admit I was actually using the bfd
from gas when I tested the patch though.
p.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: support for ARM GNU/Linux
1999-04-12 13:19 ` Scott Bambrough
1999-04-12 14:12 ` Scott Bambrough
@ 1999-04-12 14:27 ` Philip Blundell
1 sibling, 0 replies; 13+ messages in thread
From: Philip Blundell @ 1999-04-12 14:27 UTC (permalink / raw)
To: scottb; +Cc: gdb-patches
>I don't believe the bfd support in the GDB snapshots will support this target
>ATM, that's why I haven't submitted my changes for inclusion in GDB. Be
>forewarned.
There are possibly a few changes that need pulling over from gas2, but broadly
speaking I think it ought to work. I must admit I was actually using the bfd
from gas when I tested the patch though.
p.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: support for ARM GNU/Linux
1999-04-12 12:26 support for ARM GNU/Linux Philip Blundell
1999-04-12 13:19 ` Scott Bambrough
@ 1999-04-12 20:18 ` Jim Blandy
1999-04-13 6:45 ` Philip Blundell
` (2 more replies)
1 sibling, 3 replies; 13+ messages in thread
From: Jim Blandy @ 1999-04-12 20:18 UTC (permalink / raw)
To: Philip Blundell; +Cc: gdb-patches
> This patch adds support for GNU/Linux running on ARM systems.
Cool! Some initial comments:
Could you adapt your patches to 4.18? If I try to do it and anything
non-trivial comes up, I'd almost certainly screw them up.
Could you rename the native file armlinux-nat.c? "lnx" looks like
"lynx", which is something else entirely... :)
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: support for ARM GNU/Linux
1999-04-12 20:18 ` Jim Blandy
@ 1999-04-13 6:45 ` Philip Blundell
[not found] ` <E10X3Uv-0003Kd-00.cygnus.patches.gdb@fountain.nexus.co.uk>
[not found] ` <37142B16.B43B5200.cygnus.patches.gdb@cygnus.com>
2 siblings, 0 replies; 13+ messages in thread
From: Philip Blundell @ 1999-04-13 6:45 UTC (permalink / raw)
To: gdb-patches
In message < np90bx1a3v.fsf@zwingli.cygnus.com >, Jim Blandy writes:
>Could you adapt your patches to 4.18? If I try to do it and anything
>non-trivial comes up, I'd almost certainly screw them up.
>
>Could you rename the native file armlinux-nat.c? "lnx" looks like
>"lynx", which is something else entirely... :)
Sure. I've appended here a new patch incorporating those changes. It's
against the 19990412 snapshot.
p.
1999-04-13 Philip Blundell <philb@gnu.org>
Scott Bambrough <scottb@corelcomputer.com>
Support for ARM GNU/Linux:
* configure.tgt: Recognize arm*-*-linux* configuration. Set
cpu name to `arm' for any `arm*-*-*' configuration name.
* configure.host: Likewise.
* config/arm/linux.mh, config/arm/linux.mt: New files.
* config/arm/tm-linux.h, config-arm/xm-linux.h,
config/arm/nm-linux.h: Likewise.
* armlinux-tdep.c, armlinux-nat.c: Likewise.
* arm-tdep.c (ARM_LE_BREAKPOINT, ARM_BE_BREAKPOINT,
THUMB_LE_BREAKPOINT, THUMB_BE_BREAKPOINT, LOWEST_PC,
LITTLE_BREAKPOINT, BIG_BREAKPOINT): Move
definitions to...
* config/arm/tm-arm.h: ... here.
diff -u --recursive --new-file clean/gdb-19990412/gdb/arm-tdep.c gdb-19990412/gdb/arm-tdep.c
--- clean/gdb-19990412/gdb/arm-tdep.c Fri Apr 2 20:33:38 1999
+++ gdb-19990412/gdb/arm-tdep.c Tue Apr 13 10:39:36 1999
@@ -61,7 +61,6 @@
CORE_ADDR chain;
struct frame_info *thisframe;
{
-#define LOWEST_PC 0x20 /* the first 0x20 bytes are the trap vectors. */
return (chain != 0 && (FRAME_SAVED_PC (thisframe) >= LOWEST_PC));
}
@@ -1487,17 +1486,6 @@
else
return print_insn_little_arm (memaddr, info);
}
-
-/* Sequence of bytes for breakpoint instruction. */
-#define ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7} /* Recognized illegal opcodes */
-#define ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE}
-#define THUMB_LE_BREAKPOINT {0xfe,0xdf}
-#define THUMB_BE_BREAKPOINT {0xdf,0xfe}
-
-/* The following has been superseded by BREAKPOINT_FOR_PC, but
- is defined merely to keep mem-break.c happy. */
-#define LITTLE_BREAKPOINT ARM_LE_BREAKPOINT
-#define BIG_BREAKPOINT ARM_BE_BREAKPOINT
/* This function implements the BREAKPOINT_FROM_PC macro. It uses the program
counter value to determine whether a 16- or 32-bit breakpoint should be
diff -u --recursive --new-file clean/gdb-19990412/gdb/armlinux-nat.c gdb-19990412/gdb/armlinux-nat.c
--- clean/gdb-19990412/gdb/armlinux-nat.c Thu Jan 1 01:00:00 1970
+++ gdb-19990412/gdb/armlinux-nat.c Tue Apr 13 12:33:12 1999
@@ -0,0 +1,148 @@
+/* ARM native support for SYSV systems (pre-SVR4).
+ Copyright (C) 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"
+#include "inferior.h"
+#include <sys/ptrace.h>
+#include "gdbcore.h"
+#include <sys/user.h> /* After a.out.h */
+
+int
+arm_register_u_addr(blockend, regnum)
+ int blockend;
+ int regnum;
+{
+ return blockend + REGISTER_BYTE(regnum);
+}
+
+int
+kernel_u_size()
+{
+ return (sizeof (struct user));
+}
+
+#ifdef HAVE_GREGSET_T
+#include <sys/procfs.h>
+
+/* Given a pointer to a general register set in /proc format
+ (gregset_t *), unpack the register contents and supply them as
+ gdb's idea of the current register values. */
+
+void
+supply_gregset (gregsetp)
+ gregset_t *gregsetp;
+{
+ int i;
+
+ for (i = 0; i < 26; i++)
+ supply_register (i, (char *) (*gregsetp + i));
+}
+
+#endif
+
+void
+fetch_inferior_registers (regno)
+ int regno; /* Original value discarded */
+{
+ register int i;
+ register unsigned int regaddr;
+ char buf[MAX_REGISTER_RAW_SIZE];
+
+ struct user u;
+ unsigned int offset = (char*)&u.u_ar0 - (char*)&u;
+ offset = ptrace (PT_READ_U, inferior_pid,
+ (PTRACE_ARG3_TYPE)offset, 0) - KERNEL_U_ADDR;
+
+ registers_fetched ();
+
+ for (regno = 0; regno < NUM_GREGS; regno++)
+ {
+ regaddr = offset + regno * sizeof(long);
+ *(int*)&buf[0] = ptrace (PT_READ_U, inferior_pid,
+ (PTRACE_ARG3_TYPE)regaddr, 0);
+ if (regno == PC_REGNUM)
+ *(int*)&buf[0] = GET_PC_PART (*(int*)&buf[0]);
+ supply_register (regno,buf);
+ }
+
+ *(int*)&buf[0] = ptrace (PT_READ_U, inferior_pid,
+ (PTRACE_ARG3_TYPE)(offset + PC_REGNUM*sizeof(long)),
+ 0);
+ supply_register (PS_REGNUM,buf); /* set virtual register ps same as pc */
+
+ /* read the floating point registers */
+ offset = (char*)&u.u_fp0 - (char *)&u;
+ *(int*)buf = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE)offset, 0);
+ supply_register (FPS_REGNUM,buf);
+
+ for (regno = 16; regno < 24; regno++) {
+ regaddr = offset /* + 4 */ + 12 * (regno - 16);
+ for (i = 0; i < 12; i += sizeof(int))
+ *(int*) &buf[i] = ptrace (PT_READ_U, inferior_pid,
+ (PTRACE_ARG3_TYPE)(regaddr + i), 0);
+ supply_register (regno,buf);
+ }
+}
+
+/* Store our register values back into the inferior.
+ If REGNO is -1, do this for all registers.
+ Otherwise, REGNO specifies which register (so we can save time). */
+
+void
+store_inferior_registers (regno)
+ int regno;
+{
+ register unsigned int regaddr;
+ char buf[80];
+
+ struct user u;
+ unsigned long value;
+ unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
+ offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0)
+ - KERNEL_U_ADDR;
+
+ if (regno >= 0) {
+ if (regno >= 16) return;
+ regaddr = offset + 4 * regno;
+ errno = 0;
+ value = read_register (regno);
+ if (regno == PC_REGNUM)
+ value = SET_PC_PART (read_register (PS_REGNUM), value);
+ ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value);
+ if (errno != 0)
+ {
+ sprintf (buf, "writing register number %d", regno);
+ perror_with_name (buf);
+ }
+ }
+ else for (regno = 0; regno < 15; regno++)
+ {
+ regaddr = offset + regno * 4;
+ errno = 0;
+ value = read_register (regno);
+ if (regno == PC_REGNUM)
+ value = SET_PC_PART (read_register (PS_REGNUM), value);
+ ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value);
+ if (errno != 0)
+ {
+ sprintf (buf, "writing all regs, number %d", regno);
+ perror_with_name (buf);
+ }
+ }
+}
diff -u --recursive --new-file clean/gdb-19990412/gdb/armlinux-tdep.c gdb-19990412/gdb/armlinux-tdep.c
--- clean/gdb-19990412/gdb/armlinux-tdep.c Thu Jan 1 01:00:00 1970
+++ gdb-19990412/gdb/armlinux-tdep.c Tue Apr 13 10:39:36 1999
@@ -0,0 +1,65 @@
+/* Target-dependent code for the ArmLinux, for GDB, the GNU Debugger.
+ Copyright 1988, 1989, 1991, 1992, 1993, 1995 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"
+#include "frame.h"
+#include "inferior.h"
+
+/* APCS (ARM procedure call standard) defines the following prologue:
+
+ mov ip, sp
+ [stmfd sp!, {a1,a2,a3,a4}]
+ stmfd sp!, {...,fp,ip,lr,pc}
+ [stfe f7, [sp, #-12]!]
+ [stfe f6, [sp, #-12]!]
+ [stfe f5, [sp, #-12]!]
+ [stfe f4, [sp, #-12]!]
+ sub fp, ip, #nn // nn == 20 or 4 depending on second ins
+*/
+
+void
+arm_extract_return_value(type, regbuf, valbuf)
+ struct type *type;
+ char regbuf[];
+ void *valbuf;
+{
+ if (TYPE_CODE_FLT == TYPE_CODE(type))
+ convert_from_extended(regbuf + REGISTER_BYTE(F0_REGNUM), valbuf);
+ else
+ memcpy(valbuf, regbuf, TYPE_LENGTH(type));
+}
+
+/* not in generic code, macro in tm-arm.h */
+void
+arm_store_return_value(type, valbuf)
+ struct type *type;
+ void *valbuf;
+{
+ if (TYPE_CODE_FLT == TYPE_CODE(type)) {
+ char _buf[MAX_REGISTER_RAW_SIZE];
+ convert_to_extended(valbuf, _buf);
+ write_register_bytes(REGISTER_BYTE(F0_REGNUM), _buf, MAX_REGISTER_RAW_SIZE);
+ } else
+ write_register_bytes(0, valbuf, TYPE_LENGTH(type));
+}
+
+void
+_initialize_linux_tdep(void)
+{
+}
diff -u --recursive --new-file clean/gdb-19990412/gdb/config/arm/linux.mh gdb-19990412/gdb/config/arm/linux.mh
--- clean/gdb-19990412/gdb/config/arm/linux.mh Thu Jan 1 01:00:00 1970
+++ gdb-19990412/gdb/config/arm/linux.mh Tue Apr 13 11:24:09 1999
@@ -0,0 +1,8 @@
+# Host: ARM running GNU/Linux
+
+XM_FILE= xm-linux.h
+XDEPFILES= ser-tcp.o
+
+NAT_FILE= nm-linux.h
+NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o corelow.o core-aout.o core-regset.o armlinux-nat.o
+GDBSERVER_DEPFILES= low-linux.o
diff -u --recursive --new-file clean/gdb-19990412/gdb/config/arm/linux.mt gdb-19990412/gdb/config/arm/linux.mt
--- clean/gdb-19990412/gdb/config/arm/linux.mt Thu Jan 1 01:00:00 1970
+++ gdb-19990412/gdb/config/arm/linux.mt Tue Apr 13 11:24:01 1999
@@ -0,0 +1,6 @@
+# Target: ARM running GNU/Linux with a.out and ELF
+
+TDEPFILES= armlinux-tdep.o arm-tdep.o
+TM_FILE= tm-linux.h
+
+GDBSERVER_DEPFILES= low-linux.o
diff -u --recursive --new-file clean/gdb-19990412/gdb/config/arm/nm-linux.h gdb-19990412/gdb/config/arm/nm-linux.h
--- clean/gdb-19990412/gdb/config/arm/nm-linux.h Thu Jan 1 01:00:00 1970
+++ gdb-19990412/gdb/config/arm/nm-linux.h Tue Apr 13 12:20:35 1999
@@ -0,0 +1,43 @@
+/* Native machine definitions for GDB on ARM running GNU/Linux
+ Copyright (C) 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_LINUX_H
+#define NM_LINUX_H
+
+/* Get generic SVR4 definitions. */
+#include "nm-sysv4.h"
+
+/* Here we differ from SVR4. */
+#undef USE_PROC_FS
+
+/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */
+#define FETCH_INFERIOR_REGISTERS
+
+#define REGISTER_U_ADDR(addr, blockend, regno) \
+ (addr) = arm_register_u_addr ((blockend),(regno));
+
+/* Since this is a native build, we just use whatever byte order the
+ compiler has selected. */
+#ifdef __ARMEB__
+#define HOST_BYTE_ORDER BIG_ENDIAN
+#else
+#define HOST_BYTE_ORDER LITTLE_ENDIAN
+#endif
+
+#endif /* NM_LINUX_H */
diff -u --recursive --new-file clean/gdb-19990412/gdb/config/arm/tm-arm.h gdb-19990412/gdb/config/arm/tm-arm.h
--- clean/gdb-19990412/gdb/config/arm/tm-arm.h Fri Apr 2 20:33:39 1999
+++ gdb-19990412/gdb/config/arm/tm-arm.h Tue Apr 13 10:39:37 1999
@@ -22,6 +22,8 @@
struct value;
#endif
+#define TARGET_ARM
+
#define TARGET_BYTE_ORDER_SELECTABLE
/* IEEE format floating point */
@@ -118,6 +120,7 @@
that I can clear the status bits from pc (register 15) */
#define NUM_REGS 26
+#define NUM_GREGS 16
/* An array of names of registers. */
@@ -452,3 +455,16 @@
#undef IN_SIGTRAMP
#define IN_SIGTRAMP(pc, name) 0
+
+/* Sequence of bytes for breakpoint instruction. */
+#define ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7} /* Recognized illegal opcodes */
+#define ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE}
+#define THUMB_LE_BREAKPOINT {0xfe,0xdf}
+#define THUMB_BE_BREAKPOINT {0xdf,0xfe}
+
+/* The following has been superseded by BREAKPOINT_FOR_PC, but
+ is defined merely to keep mem-break.c happy. */
+#define LITTLE_BREAKPOINT ARM_LE_BREAKPOINT
+#define BIG_BREAKPOINT ARM_BE_BREAKPOINT
+
+#define LOWEST_PC 0x20 /* the first 0x20 bytes are the trap vectors. */
diff -u --recursive --new-file clean/gdb-19990412/gdb/config/arm/tm-linux.h gdb-19990412/gdb/config/arm/tm-linux.h
--- clean/gdb-19990412/gdb/config/arm/tm-linux.h Thu Jan 1 01:00:00 1970
+++ gdb-19990412/gdb/config/arm/tm-linux.h Tue Apr 13 13:08:40 1999
@@ -0,0 +1,94 @@
+/* Definitions to target GDB to ARM GNU/Linux
+ Copyright 1992, 1993, 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_LINUX_H__
+#define __TM_LINUX_H__
+
+/* Scott: SHLIBLEN from bfd/riscix.c. */
+#define SHLIBLEN 60
+
+/* Offset to saved PC in sigcontext, from <linux/signal.h>. */
+#define SIGCONTEXT_PC_OFFSET (sizeof(unsigned long) + sizeof(long) * 15)
+
+/* Number of traps that happen between exec'ing the shell to run an
+ inferior, and when we finally get to the inferior code. This is 2
+ on most implementations. */
+#define START_INFERIOR_TRAPS_EXPECTED 2
+
+/* The following is used in the macro CALL_DUMMY in tm-arm.h. */
+#define OS_BKPT_SWI 0xef9f0001
+
+/* Add command to set APCS_32 debugger variable. Used to determine if
+ 32 bit or 26 bit program counter is being used. Set to 1 to add the
+ command to the debugger. */
+#define ADD_SET_APCS_COMMAND 0
+
+/* It is unknown which, if any, SVR4 assemblers do not accept dollar signs
+ in identifiers. The default in G++ is to use dots instead, for all SVR4
+ systems, so we make that our default also. FIXME: There should be some
+ way to get G++ to tell us what CPLUS_MARKER it is using, perhaps by
+ stashing it in the debugging information as part of the name of an
+ invented symbol ("gcc_cplus_marker$" for example). */
+
+#undef CPLUS_MARKER
+#define CPLUS_MARKER '.'
+
+/* Include the generic ARM target header. */
+#include "arm/tm-arm.h"
+
+/* The following are used in arm_breakpoint_from_pc() in arm-tdep.c */
+#undef ARM_LE_BREAKPOINT
+#define ARM_LE_BREAKPOINT {0x01,0x00,0x9f,0xef} /* swi 0x9f0001 */
+#undef ARM_BE_BREAKPOINT
+#define ARM_BE_BREAKPOINT {0xef,0x9f,0x00,0x01}
+
+/* This is used in the macro FRAME_CHAIN_VALID in tm-arm.h. */
+#undef LOWEST_PC
+#define LOWEST_PC 0x8000 /* the first page is not writable in ARM Linux. */
+
+/* For SVR4 shared libraries, each call to a library routine goes through
+ a small piece of trampoline code in the ".plt" section.
+ The horribly ugly wait_for_inferior() routine uses this macro to detect
+ when we have stepped into one of these fragments.
+ We do not use lookup_solib_trampoline_symbol_by_pc, because
+ we cannot always find the shared library trampoline symbols
+ (e.g. on Irix5). */
+extern int in_plt_section PARAMS ((CORE_ADDR, char *));
+
+/* If PC is in a shared library trampoline code, return the PC
+ where the function itself actually starts. If not, return 0. */
+#undef SKIP_TRAMPOLINE_CODE
+#define SKIP_TRAMPOLINE_CODE(pc) \
+ ((in_plt_section((pc), NULL) ? find_solib_trampoline_target (pc) \
+ : arm_skip_stub (pc)))
+
+#undef IN_SOLIB_CALL_TRAMPOLINE
+#define IN_SOLIB_CALL_TRAMPOLINE(pc, name) (in_plt_section((pc), (name)) \
+ || arm_in_call_stub (pc, name))
+
+#ifndef GET_PC_PART
+#define GET_PC_PART(addr) ADDR_BITS_REMOVE(addr)
+#endif
+
+/* This probably needs fixing to support APCS-26. */
+#ifndef SET_PC_PART
+#define SET_PC_PART(old,new) new
+#endif
+
+#endif /* #ifndef TM_LINUX_H */
diff -u --recursive --new-file clean/gdb-19990412/gdb/config/arm/xm-linux.h gdb-19990412/gdb/config/arm/xm-linux.h
--- clean/gdb-19990412/gdb/config/arm/xm-linux.h Thu Jan 1 01:00:00 1970
+++ gdb-19990412/gdb/config/arm/xm-linux.h Tue Apr 13 10:55:56 1999
@@ -0,0 +1,36 @@
+/* Native support for Linux, for GDB, the GNU debugger.
+ Copyright (C) 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 __XM_LINUX_H__
+#define __XM_LINUX_H__
+
+#include "arm/xm-arm.h"
+
+#define HAVE_TERMIOS
+
+/* This is the amount to subtract from u.u_ar0
+ to get the offset in the core file of the register values. */
+#define KERNEL_U_ADDR 0x0
+
+#define NEED_POSIX_SETPGID
+
+/* Need R_OK etc, but USG isn't defined. */
+#include <unistd.h>
+
+#endif /* __XM_LINUX_H__ */
diff -u --recursive --new-file clean/gdb-19990412/gdb/configure.host gdb-19990412/gdb/configure.host
--- clean/gdb-19990412/gdb/configure.host Thu Mar 25 01:27:49 1999
+++ gdb-19990412/gdb/configure.host Tue Apr 13 10:39:37 1999
@@ -11,6 +11,7 @@
case "${host_cpu}" in
alpha*) gdb_host_cpu=alpha ;;
+arm*) gdb_host_cpu=arm ;;
c[12]) gdb_host_cpu=convex ;;
hppa*) gdb_host_cpu=pa ;;
i[3456]86*) gdb_host_cpu=i386 ;;
@@ -35,6 +36,7 @@
alpha*-*-osf[3456789]*) gdb_host=alpha-osf3 ;;
alpha*-*-linux*) gdb_host=alpha-linux ;;
+arm*-*-linux*) gdb_host=linux ;;
arm-*-*) gdb_host=arm ;;
c[12]-*-*) gdb_host=convex ;;
diff -u --recursive --new-file clean/gdb-19990412/gdb/configure.tgt gdb-19990412/gdb/configure.tgt
--- clean/gdb-19990412/gdb/configure.tgt Tue Apr 13 01:49:52 1999
+++ gdb-19990412/gdb/configure.tgt Tue Apr 13 10:39:37 1999
@@ -13,6 +13,7 @@
case "${target_cpu}" in
alpha*) gdb_target_cpu=alpha ;;
+arm*) gdb_target_cpu=arm ;;
c[12]) gdb_target_cpu=convex ;;
hppa*) gdb_target_cpu=pa ;;
i[3456]86*) gdb_target_cpu=i386 ;;
@@ -50,6 +51,8 @@
arc-*-*) gdb_target=arc ;;
+arm*-*-linux*) gdb_target=linux
+ configdirs="${configdirs} gdbserver" ;;
arm-*-* | thumb-*-* | strongarm-*-*) gdb_target=arm
# rdi doesn't work for wingdb yet
^ permalink raw reply [flat|nested] 13+ messages in thread[parent not found: <E10X3Uv-0003Kd-00.cygnus.patches.gdb@fountain.nexus.co.uk>]
* Re: support for ARM GNU/Linux
[not found] ` <E10X3Uv-0003Kd-00.cygnus.patches.gdb@fountain.nexus.co.uk>
@ 1999-04-13 22:44 ` Andrew Cagney
1999-04-14 2:21 ` Philip Blundell
1999-04-14 3:36 ` Richard Earnshaw
0 siblings, 2 replies; 13+ messages in thread
From: Andrew Cagney @ 1999-04-13 22:44 UTC (permalink / raw)
To: gdb-patches, Stan Shebs
Philip Blundell wrote:
>
> In message < np90bx1a3v.fsf@zwingli.cygnus.com >, Jim Blandy writes:
> >Could you adapt your patches to 4.18? If I try to do it and anything
> >non-trivial comes up, I'd almost certainly screw them up.
> >
> >Could you rename the native file armlinux-nat.c? "lnx" looks like
> >"lynx", which is something else entirely... :)
>
> Sure. I've appended here a new patch incorporating those changes. It's
> against the 19990412 snapshot.
Hello,
I'm afraid that you've drawn the short straw - the way targets are
implemented is changing. In fact, one change I refer to below won't be
visible until the *next* snapshot.
The unfortunate consequence is that there is going to need to be more
work before this change can be integrated into GDB proper. On the
bright side, if you bare with me, we will have greatly simplified the
task of evolving the ARM GDB into a debugger that can support several
different architectures.
--
The file gdb/armlinux-tdep.c will need tidying. Check the Gnu
Programming Standars document -
http://www.fsf.org/prep/standards_toc.html . It would be good to get
any new files correctly formatted from day one (even if all the old ones
are still a mess :-).
--
You've used the *_BREAKPOINT macro's. In the process, the change:
Tue Nov 24 14:13:10 1998 Andrew Cagney <cagney@chook>
* config/arm/tm-arm.h ({BIG,LITTLE}_BREAKPOINT): Delete macros.
({ARM,THUMB}_{BE,LE}_BREAKPOINT): Move macros from here.
* arm-tdep.c: To here.
was reversed. The use of the *_BREAKPOINT macros is going to be
discouraged. Instead you are encouraged to use a function, called via
the macro BREAKPOINT_FROM_PC() (ref gdbint.texinfo). In the case of the
ARM, BREAKPOINT_FROM_PC() maps onto the function
arm_breakpoint_from_pc(). That function should be coded so that it can
determine the required breakpoint without having to revert to compile
time CPP directives such as #undef, #define or #if.
If you feal that a new implementation of the breakpoint_from_pc()
function (armlinux_breakpoint_from_pc() say) is needed, I would suggest
defining BREAKPOINT_FROM_PC as a global function pointer and initialize
that pointer in __initialize_arm_tdep(). The existing
arm_breakpoint_from_pc() function should not be #ifdef'd out.
In the future that global can be be made part of an architecture object
(``struct gdbarch'' say).
--
The file gdb/config/arm/tm-linux.h #defines OS_BKPT_SWI. That is in
turn used by the ARM version of CALL_DUMMY. CALL_DUMMY has just been
replaced with CALL_DUMMY_WORDS and SIZEOF_CALL_DUMMY_WORDS (see
gdb/doc/gdbint.texi in the *next* snapshot). Rather than define
OS_BKPT_SWI could I strongly encourage you to instead use these new
macros. Like for BREAKPOINT_FROM_PC, I would suggest using a global
initialized from __initialize_arm_tdep().
--
I'm slightly curious about what is going on with all these different
breakpoints (I should hasten to point out that I'm _not_ the ARM
expert/maintainer :-). Stan Shebs recently commited the change:
1999-03-02 Stan Shebs <shebs@andros.cygnus.com>
From Gary Thomas <gthomas@cygnus.co.uk>:
* arm-tdep.c (ARM_LE_BREAKPOINT, ARM_BE_BREAKPOINT,
THUMB_LE_BREAKPOINT, THUMB_BE_BREAKPOINT): Use illegal instruction
instead of SWI 24.
* config/arm/tm-arm.h (CALL_DUMMY): Ditto.
(IN_SIGTRAMP): Define.
Originally they were:
ARM_LE_BREAKPOINT {0x00,0x00,0x18,0xef} /* BKPT_SWI from <sys/ptrace.h
*/
ARM_BE_BREAKPOINT {0xef,0x18,0x00,0x00} /* BKPT_SWI from <sys/ptrace.h
*/
While Stan changed them to:
ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7} /* Recognized illegal opcodes
*/
ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE}
And now, in your patch there is:
ARM_LE_BREAKPOINT {0x01,0x00,0x9f,0xef} /* swi 0x9f0001
*/
ARM_BE_BREAKPOINT {0xef,0x9f,0x00,0x01}
I'm just kind of wondering which/any are needed :-) There must be a
standard somewhere ;-)
Could I suggest including a comment explaining where your breakpoint
instructions come from. If it is part of the LINUX/ARM environment then
make a reference to that.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: support for ARM GNU/Linux
1999-04-13 22:44 ` Andrew Cagney
@ 1999-04-14 2:21 ` Philip Blundell
1999-04-14 3:36 ` Richard Earnshaw
1 sibling, 0 replies; 13+ messages in thread
From: Philip Blundell @ 1999-04-14 2:21 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
>I'm slightly curious about what is going on with all these different
>breakpoints (I should hasten to point out that I'm _not_ the ARM
>expert/maintainer :-). Stan Shebs recently commited the change:
Under Linux/ARM (and I think RISC iX, which is probably where the original
breakpoint definitions came from) the traditional way to perform a breakpoint
is to execute a particular SWI. The kernel will then stop the inferior
process with SIGTRAP and wake the debugger. For systems where there is no
explicit OS support for breakpoints, the set of opcodes that Stan put in
will provoke a CPU "undefined instruction" exception which again stops the
process. Plus of course there's an equivalent set for Thumb.
I think all of these are needed for their respective target systems. The RISC
iX support probably wants splitting out into its own file anyway; at the
moment it's hiding away in various files that are named as if they contain
only ARM generic code.
>Could I suggest including a comment explaining where your breakpoint
>instructions come from. If it is part of the LINUX/ARM environment then
>make a reference to that.
OK.
p.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: support for ARM GNU/Linux
1999-04-13 22:44 ` Andrew Cagney
1999-04-14 2:21 ` Philip Blundell
@ 1999-04-14 3:36 ` Richard Earnshaw
1999-04-14 2:52 ` Richard Earnshaw
1999-04-14 11:34 ` Stan Shebs
1 sibling, 2 replies; 13+ messages in thread
From: Richard Earnshaw @ 1999-04-14 3:36 UTC (permalink / raw)
To: gdb-patches; +Cc: richard.earnshaw
ac131313@cygnus.com said:
> I'm slightly curious about what is going on with all these different
> breakpoints (I should hasten to point out that I'm _not_ the ARM
> expert/maintainer :-). Stan Shebs recently commited the change:
> 1999-03-02 Stan Shebs <shebs@andros.cygnus.com>
> From Gary Thomas <gthomas@cygnus.co.uk>:
> * arm-tdep.c (ARM_LE_BREAKPOINT, ARM_BE_BREAKPOINT,
> THUMB_LE_BREAKPOINT, THUMB_BE_BREAKPOINT): Use illegal instruction
> instead of SWI 24.
> * config/arm/tm-arm.h (CALL_DUMMY): Ditto.
> (IN_SIGTRAMP): Define.
A bit of history. SWI 24 was the breakpoint swi in RISC iX, which the
kernel understood (in some way). I don't know if it was necessary to use
exactly that SWI if you were using gdb or if the same effect could be
achieved with other illegal instructions.
A side-note, before ARM Architecture v4 many "undefined" instruction
formats aren't guaranteed to take the undefined instruction trap. Also
note that, in this respect, the ARM7TDMI is NOT fully ARM v4 compliant.
I don't know if anyone cares about RISC iX support any more (though gcc
still supports it).
Richard.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: support for ARM GNU/Linux
1999-04-14 3:36 ` Richard Earnshaw
@ 1999-04-14 2:52 ` Richard Earnshaw
1999-04-14 11:34 ` Stan Shebs
1 sibling, 0 replies; 13+ messages in thread
From: Richard Earnshaw @ 1999-04-14 2:52 UTC (permalink / raw)
To: gdb-patches; +Cc: richard.earnshaw
ac131313@cygnus.com said:
> I'm slightly curious about what is going on with all these different
> breakpoints (I should hasten to point out that I'm _not_ the ARM
> expert/maintainer :-). Stan Shebs recently commited the change:
> 1999-03-02 Stan Shebs <shebs@andros.cygnus.com>
> From Gary Thomas <gthomas@cygnus.co.uk>:
> * arm-tdep.c (ARM_LE_BREAKPOINT, ARM_BE_BREAKPOINT,
> THUMB_LE_BREAKPOINT, THUMB_BE_BREAKPOINT): Use illegal instruction
> instead of SWI 24.
> * config/arm/tm-arm.h (CALL_DUMMY): Ditto.
> (IN_SIGTRAMP): Define.
A bit of history. SWI 24 was the breakpoint swi in RISC iX, which the
kernel understood (in some way). I don't know if it was necessary to use
exactly that SWI if you were using gdb or if the same effect could be
achieved with other illegal instructions.
A side-note, before ARM Architecture v4 many "undefined" instruction
formats aren't guaranteed to take the undefined instruction trap. Also
note that, in this respect, the ARM7TDMI is NOT fully ARM v4 compliant.
I don't know if anyone cares about RISC iX support any more (though gcc
still supports it).
Richard.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: support for ARM GNU/Linux
1999-04-14 3:36 ` Richard Earnshaw
1999-04-14 2:52 ` Richard Earnshaw
@ 1999-04-14 11:34 ` Stan Shebs
1999-04-14 12:18 ` Richard Earnshaw
1 sibling, 1 reply; 13+ messages in thread
From: Stan Shebs @ 1999-04-14 11:34 UTC (permalink / raw)
To: richard.earnshaw; +Cc: gdb-patches
Date: Wed, 14 Apr 1999 10:52:15 +0100
From: Richard Earnshaw <rearnsha@arm.com>
A bit of history. SWI 24 was the breakpoint swi in RISC iX, which the
kernel understood (in some way). I don't know if it was necessary to use
exactly that SWI if you were using gdb or if the same effect could be
achieved with other illegal instructions.
Thanks for the info!
A side-note, before ARM Architecture v4 many "undefined" instruction
formats aren't guaranteed to take the undefined instruction trap. Also
note that, in this respect, the ARM7TDMI is NOT fully ARM v4 compliant.
I don't quite understand - I hope ARM7TDMI is guaranteed to take the trap,
since Angel monitors are depending on that.
I don't know if anyone cares about RISC iX support any more (though gcc
still supports it).
You'd be most likely to know if anyone would, methinks! Since we've
adopted a policy of marking and ultimately deleting obsolete code in
GDB, and RISC iX is one of the candidates, any information you could
provide would be helpful. Do you know if anybody is using a RISC iX
system nowadays, and if they would have any interest in a port of
current GDB?
Stan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: support for ARM GNU/Linux
1999-04-14 11:34 ` Stan Shebs
@ 1999-04-14 12:18 ` Richard Earnshaw
0 siblings, 0 replies; 13+ messages in thread
From: Richard Earnshaw @ 1999-04-14 12:18 UTC (permalink / raw)
To: Stan Shebs; +Cc: richard.earnshaw
shebs@cygnus.com said:
> A side-note, before ARM Architecture v4 many "undefined"
> instruction formats aren't guaranteed to take the undefined
> instruction trap. Also note that, in this respect, the ARM7TDMI
> is NOT fully ARM v4 compliant.
> I don't quite understand - I hope ARM7TDMI is guaranteed to take the
> trap, since Angel monitors are depending on that.
I should have been more precise with my wording. The words in the ARM ARM
say
that ARMv4 defines several new undefined instructions (ie instructions
that will take the undefined instruction trap). In fact, although the
7TDMI is nominally v4t (and hence includes all of v4) it does not in fact
add the new undefined instructions, though it implements the rest of the
v4 architecture. The new undefined instructions in v4 are all
instructions which had no defined behaviour in earlier chips (but for
which there was no guarantee that they would raise an exception); I
believe most of the instructions were NOPs but I could be wrong.
In practice, I think it is only safe to rely on instructions matching
3 2 2 2 2 2
1 8 7 6 5 4 5 4 3 0
C C C C 0 1 1 x x x x x x x x x x x x x x x x x x x x 1 x x x x
taking the undefined trap, and even then only when the condition predicate
is true.
> I don't know if anyone cares about RISC iX support any more (though
> gcc still supports it).
> You'd be most likely to know if anyone would, methinks! Since we've
> adopted a policy of marking and ultimately deleting obsolete code in
> GDB, and RISC iX is one of the candidates, any information you could
> provide would be helpful. Do you know if anybody is using a RISC iX
> system nowadays, and if they would have any interest in a port of
> current GDB?
Not necessarily, it was an Acorn Product not an ARM one. I do have one at
home, but it's slow by today's standards and makes a lot of noise, so it
isn't switched on very often (I really only keep it in case a problem gets
reported).
^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <37142B16.B43B5200.cygnus.patches.gdb@cygnus.com>]
* Re: support for ARM GNU/Linux
[not found] ` <37142B16.B43B5200.cygnus.patches.gdb@cygnus.com>
@ 1999-04-13 23:56 ` Andrew Cagney
0 siblings, 0 replies; 13+ messages in thread
From: Andrew Cagney @ 1999-04-13 23:56 UTC (permalink / raw)
To: gdb-patches
Andrew Cagney wrote:
> The file gdb/config/arm/tm-linux.h #defines OS_BKPT_SWI. That is in
> turn used by the ARM version of CALL_DUMMY. CALL_DUMMY has just been
> replaced with CALL_DUMMY_WORDS and SIZEOF_CALL_DUMMY_WORDS (see
> gdb/doc/gdbint.texi in the *next* snapshot). Rather than define
> OS_BKPT_SWI could I strongly encourage you to instead use these new
> macros. Like for BREAKPOINT_FROM_PC, I would suggest using a global
> initialized from __initialize_arm_tdep().
FYI,
Below is the relevant section of the internals manual.
Andrew
@item CALL_DUMMY_P
A C expresson that is non-zero when the target suports inferior function
calls.
@item CALL_DUMMY_WORDS
Pointer to an array of @var{LONGEST} words of data containing
host-byte-ordered @var{REGISTER_BYTES} sized values that partially
specify the sequence of instructions needed for an inferior function
call.
Should be deprecated in favour of a macro that uses target-byte-ordered
data.
@item SIZEOF_CALL_DUMMY_WORDS
The size of @var{CALL_DUMMY_WORDS}. When @var{CALL_DUMMY_P} this must
return a positive value. See also @var{CALL_DUMMY_LENGTH}.
@item CALL_DUMMY
A static initializer for @var{CALL_DUMMY_WORDS}. Deprecated.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~1999-04-14 12:18 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-12 12:26 support for ARM GNU/Linux Philip Blundell
1999-04-12 13:19 ` Scott Bambrough
1999-04-12 14:12 ` Scott Bambrough
1999-04-12 14:27 ` Philip Blundell
1999-04-12 20:18 ` Jim Blandy
1999-04-13 6:45 ` Philip Blundell
[not found] ` <E10X3Uv-0003Kd-00.cygnus.patches.gdb@fountain.nexus.co.uk>
1999-04-13 22:44 ` Andrew Cagney
1999-04-14 2:21 ` Philip Blundell
1999-04-14 3:36 ` Richard Earnshaw
1999-04-14 2:52 ` Richard Earnshaw
1999-04-14 11:34 ` Stan Shebs
1999-04-14 12:18 ` Richard Earnshaw
[not found] ` <37142B16.B43B5200.cygnus.patches.gdb@cygnus.com>
1999-04-13 23:56 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox