Index: alpha-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/alpha-tdep.c,v retrieving revision 1.11 diff -c -r1.11 alpha-tdep.c *** alpha-tdep.c 2001/08/01 18:39:22 1.11 --- alpha-tdep.c 2002/01/18 06:27:15 *************** *** 1,5 **** /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger. ! Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of GDB. --- 1,5 ---- /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger. ! Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GDB. *************** *** 1384,1389 **** --- 1384,1498 ---- return 0; else return SYMBOL_VALUE_ADDRESS (sym) + 4; + } + + /* alpha_software_single_step() is called just before we want to resume + the inferior, if we want to single-step it but there is no hardware + or kernel single-step support (NetBSD on Alpha, for example). We find + the target of the coming instruction and breakpoint it. + + single_step is also called just after the inferior stops. If we had + set up a simulated single-step, we undo our damage. */ + + static CORE_ADDR + alpha_next_pc (CORE_ADDR pc) + { + unsigned int insn; + unsigned int op; + int offset; + LONGEST rav; + + insn = read_memory_unsigned_integer (pc, sizeof (insn)); + + /* Opcode is top 6 bits. */ + op = (insn >> 26) & 0x3f; + + if (op == 0x1a) + { + /* Jump format: target PC is: + RB & ~3 */ + return (read_register ((insn >> 16) & 0x1f) & ~3); + } + + if ((op & 0x30) == 0x30) + { + /* Branch format: target PC is: + (new PC) + (4 * sext(displacement)) */ + if (op == 0x30 || /* BR */ + op == 0x34) /* BSR */ + { + branch_taken: + offset = (insn & 0x001fffff); + if (offset & 0x00100000) + offset |= 0xffe00000; + offset *= 4; + return (pc + 4 + offset); + } + + /* Need to determine if branch is taken; read RA. */ + rav = (LONGEST) read_register ((insn >> 21) & 0x1f); + switch (op) + { + case 0x38: /* BLBC */ + if ((rav & 1) == 0) + goto branch_taken; + break; + case 0x3c: /* BLBS */ + if (rav & 1) + goto branch_taken; + break; + case 0x39: /* BEQ */ + if (rav == 0) + goto branch_taken; + break; + case 0x3d: /* BNE */ + if (rav != 0) + goto branch_taken; + break; + case 0x3a: /* BLT */ + if (rav < 0) + goto branch_taken; + break; + case 0x3b: /* BLE */ + if (rav <= 0) + goto branch_taken; + break; + case 0x3f: /* BGT */ + if (rav > 0) + goto branch_taken; + break; + case 0x3e: /* BGE */ + if (rav >= 0) + goto branch_taken; + break; + } + } + + /* Not a branch or branch not taken; target PC is: + pc + 4 */ + return (pc + 4); + } + + void + alpha_software_single_step (enum target_signal sig, int insert_breakpoints_p) + { + static CORE_ADDR next_pc; + typedef char binsn_quantum[BREAKPOINT_MAX]; + static binsn_quantum break_mem; + CORE_ADDR pc; + + if (insert_breakpoints_p) + { + pc = read_pc (); + next_pc = alpha_next_pc (pc); + + target_insert_breakpoint (next_pc, break_mem); + } + else + { + target_remove_breakpoint (next_pc, break_mem); + write_pc (next_pc); + } } void Index: alphabsd-nat.c =================================================================== RCS file: /cvs/src/src/gdb/alphabsd-nat.c,v retrieving revision 1.5 diff -c -r1.5 alphabsd-nat.c *** alphabsd-nat.c 2001/05/04 04:15:24 1.5 --- alphabsd-nat.c 2002/01/18 06:27:15 *************** *** 1,5 **** /* Native-dependent code for Alpha BSD's. ! Copyright 2000, 2001 Free Software Foundation, Inc. This file is part of GDB. --- 1,5 ---- /* Native-dependent code for Alpha BSD's. ! Copyright 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GDB. *************** *** 45,50 **** --- 45,55 ---- /* Number of floating point registers. */ #define NUM_FPREGS 31 + + /* Determine if PT_GETREGS fetches this register. */ + #define GETREGS_SUPPLIES(regno) \ + (((regno) >= V0_REGNUM && (regno) <= ZERO_REGNUM) || \ + (regno) >= PC_REGNUM) /* Transfering the registers between GDB, inferiors and core files. */ *************** *** 80,92 **** for (i = 0; i < NUM_GREGS; i++) if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i)) ! memcpy (&gregsetp->r_regs[i], ®isters[REGISTER_BYTE (i)], ! REGISTER_RAW_SIZE (i)); /* The PC travels in the R_ZERO slot. */ if (regno == -1 || regno == PC_REGNUM) ! memcpy (&gregsetp->r_regs[R_ZERO], ®isters[REGISTER_BYTE (PC_REGNUM)], ! REGISTER_RAW_SIZE (PC_REGNUM)); } /* Fill GDB's register array with the floating-point register values --- 85,95 ---- for (i = 0; i < NUM_GREGS; i++) if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i)) ! regcache_collect (i, (char *) &gregsetp->r_regs[i]); /* The PC travels in the R_ZERO slot. */ if (regno == -1 || regno == PC_REGNUM) ! regcache_collect (PC_REGNUM, (char *) &gregsetp->r_regs[R_ZERO]); } /* Fill GDB's register array with the floating-point register values *************** *** 119,130 **** for (i = FP0_REGNUM; i < FP0_REGNUM + NUM_FPREGS; i++) if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i)) ! memcpy (&fpregsetp->fpr_regs[i - FP0_REGNUM], ! ®isters[REGISTER_BYTE (i)], REGISTER_RAW_SIZE (i)); if (regno == -1 || regno == FPCR_REGNUM) ! memcpy (&fpregsetp->fpr_cr, ®isters[REGISTER_BYTE (FPCR_REGNUM)], ! REGISTER_RAW_SIZE (FPCR_REGNUM)); } /* Fetch register REGNO from the inferior. If REGNO is -1, do this --- 122,131 ---- for (i = FP0_REGNUM; i < FP0_REGNUM + NUM_FPREGS; i++) if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i)) ! regcache_collect (i, (char *) &fpregsetp->fpr_regs[i - FP0_REGNUM]); if (regno == -1 || regno == FPCR_REGNUM) ! regcache_collect (FPCR_REGNUM, (char *) &fpregsetp->fpr_cr); } /* Fetch register REGNO from the inferior. If REGNO is -1, do this *************** *** 133,145 **** void fetch_inferior_registers (int regno) { - gregset_t gregs; ! if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), ! (PTRACE_ARG3_TYPE) &gregs, 0) == -1) ! perror_with_name ("Couldn't get registers"); ! supply_gregset (&gregs); if (regno == -1 || regno >= FP0_REGNUM) { --- 134,152 ---- void fetch_inferior_registers (int regno) { ! if (regno == -1 || GETREGS_SUPPLIES (regno)) ! { ! gregset_t gregs; ! if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), ! (PTRACE_ARG3_TYPE) &gregs, 0) == -1) ! perror_with_name ("Couldn't get registers"); ! ! supply_gregset (&gregs); ! if (regno != -1) ! return; ! } if (regno == -1 || regno >= FP0_REGNUM) { *************** *** 162,178 **** void store_inferior_registers (int regno) { - gregset_t gregs; ! if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), ! (PTRACE_ARG3_TYPE) &gregs, 0) == -1) ! perror_with_name ("Couldn't get registers"); ! ! fill_gregset (&gregs, regno); ! if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), ! (PTRACE_ARG3_TYPE) &gregs, 0) == -1) ! perror_with_name ("Couldn't write registers"); if (regno == -1 || regno >= FP0_REGNUM) { --- 169,191 ---- void store_inferior_registers (int regno) { ! if (regno == -1 || GETREGS_SUPPLIES (regno)) ! { ! gregset_t gregs; ! if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), ! (PTRACE_ARG3_TYPE) &gregs, 0) == -1) ! perror_with_name ("Couldn't get registers"); ! ! fill_gregset (&gregs, regno); ! ! if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), ! (PTRACE_ARG3_TYPE) &gregs, 0) == -1) ! perror_with_name ("Couldn't write registers"); ! if (regno != -1) ! return; ! } if (regno == -1 || regno >= FP0_REGNUM) { Index: alphanbsd-nat.c =================================================================== RCS file: alphanbsd-nat.c diff -N alphanbsd-nat.c *** /dev/null Tue May 5 13:32:27 1998 --- alphanbsd-nat.c Thu Jan 17 22:27:15 2002 *************** *** 0 **** --- 1,133 ---- + /* Native-dependent code for Alpha NetBSD. + Copyright 2002 Free Software Foundation, Inc. + Contributed by Wasabi Systems, 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 + #include + #include + #include + #include "gdbcore.h" + + #ifndef HAVE_GREGSET_T + typedef struct reg gregset_t; + #endif + + #ifndef HAVE_FPREGSET_T + typedef struct fpreg fpregset_t; + #endif + + #include "gregset.h" + + static void + fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, + CORE_ADDR ignore) + { + struct md_coredump *core_reg; + char *regs; + int regno; + + /* Table to map a gdb register number to a trapframe register index. */ + static const int regmap[] = + { + FRAME_V0, FRAME_T0, FRAME_T1, FRAME_T2, + FRAME_T3, FRAME_T4, FRAME_T5, FRAME_T6, + FRAME_T7, FRAME_S0, FRAME_S1, FRAME_S2, + FRAME_S3, FRAME_S4, FRAME_S5, FRAME_S6, + FRAME_A0, FRAME_A1, FRAME_A2, FRAME_A3, + FRAME_A4, FRAME_A5, FRAME_T8, FRAME_T9, + FRAME_T10, FRAME_T11, FRAME_RA, FRAME_T12, + FRAME_AT, FRAME_GP, FRAME_SP + }; + + /* We get everything from one section. */ + if (which != 0) + return; + + core_reg = (struct md_coredump *) core_reg_sect; + regs = (char *) &core_reg->md_tf; + + if (core_reg_size < sizeof (*core_reg)) + { + warning ("Wrong size register set in core file."); + return; + } + + /* Integer registers. */ + for (regno = 0; regno < ZERO_REGNUM; regno++) + supply_register (regno, regs + (regmap[regno] * 8)); + supply_register (ZERO_REGNUM, NULL); + supply_register (FP_REGNUM, NULL); + supply_register (PC_REGNUM, regs + (FRAME_PC * 8)); + + /* Floating point registers. */ + supply_fpregset (&core_reg->md_fpstate); + } + + static void + fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which, + CORE_ADDR ignore) + { + switch (which) + { + case 0: /* Integer registers. */ + if (core_reg_size != sizeof (struct reg)) + warning ("Wrong size register set in core file."); + else + supply_gregset ((gregset_t *) core_reg_sect); + break; + + case 2: /* Floating point registers. */ + if (core_reg_size != sizeof (struct fpreg)) + warning ("Wrong size FP register set in core file."); + else + supply_fpregset ((fpregset_t *) core_reg_sect); + break; + + default: + /* Don't know what kind of register request this is; just ignore it. */ + break; + } + } + + static struct core_fns alphanbsd_core_fns = + { + bfd_target_unknown_flavour, /* core_flavour */ + default_check_format, /* check_format */ + default_core_sniffer, /* core_sniffer */ + fetch_core_registers, /* core_read_registers */ + NULL /* next */ + }; + + static struct core_fns alphanbsd_elfcore_fns = + { + bfd_target_elf_flavour, /* core_flavour */ + default_check_format, /* check_format */ + default_core_sniffer, /* core_sniffer */ + fetch_elfcore_registers, /* core_read_registers */ + NULL /* next */ + }; + + void + _initialize_alphanbsd_nat (void) + { + add_core_fns (&alphanbsd_core_fns); + add_core_fns (&alphanbsd_elfcore_fns); + } Index: configure.host =================================================================== RCS file: /cvs/src/src/gdb/configure.host,v retrieving revision 1.31 diff -c -r1.31 configure.host *** configure.host 2001/12/17 16:23:02 1.31 --- configure.host 2002/01/18 06:27:16 *************** *** 33,38 **** --- 33,39 ---- alpha*-*-osf[3456789]*) gdb_host=alpha-osf3 ;; alpha*-*-linux*) gdb_host=alpha-linux ;; alpha*-*-freebsd*) gdb_host=fbsd ;; + alpha*-*-netbsd*) gdb_host=nbsd ;; arm*-*-linux*) gdb_host=linux ;; arm*-*-netbsd*) gdb_host=nbsd ;; Index: configure.tgt =================================================================== RCS file: /cvs/src/src/gdb/configure.tgt,v retrieving revision 1.49 diff -c -r1.49 configure.tgt *** configure.tgt 2002/01/15 01:52:37 1.49 --- configure.tgt 2002/01/18 06:27:16 *************** *** 47,52 **** --- 47,53 ---- alpha*-*-osf*) gdb_target=alpha-osf1 ;; alpha*-*-linux*) gdb_target=alpha-linux ;; alpha*-*-freebsd*) gdb_target=fbsd ;; + alpha*-*-netbsd*) gdb_target=nbsd ;; arc-*-*) gdb_target=arc ;; Index: config/nm-nbsd.h =================================================================== RCS file: /cvs/src/src/gdb/config/nm-nbsd.h,v retrieving revision 1.1.1.3 diff -c -r1.1.1.3 nm-nbsd.h *** nm-nbsd.h 1999/12/14 01:05:40 1.1.1.3 --- nm-nbsd.h 2002/01/18 06:27:16 *************** *** 18,30 **** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - - #include - - #define KERNEL_U_ADDR USRSTACK - #define PTRACE_ARG3_TYPE char* #define FETCH_INFERIOR_REGISTERS --- 18,23 ---- Index: config/alpha/nbsd.mh =================================================================== RCS file: nbsd.mh diff -N nbsd.mh *** /dev/null Tue May 5 13:32:27 1998 --- nbsd.mh Thu Jan 17 22:27:16 2002 *************** *** 0 **** --- 1,6 ---- + # Host: Alpha running NetBSD + XDEPFILES= + NAT_CLIBS= + NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o alphabsd-nat.o alphanbsd-nat.o solib.o solib-svr4.o solib-legacy.o + XM_FILE= xm-nbsd.h + NAT_FILE= nm-nbsd.h Index: config/alpha/nbsd.mt =================================================================== RCS file: nbsd.mt diff -N nbsd.mt *** /dev/null Tue May 5 13:32:27 1998 --- nbsd.mt Thu Jan 17 22:27:16 2002 *************** *** 0 **** --- 1,3 ---- + # Target: Alpha running NetBSD + TDEPFILES= alpha-tdep.o + TM_FILE= tm-nbsd.h Index: config/alpha/nm-nbsd.h =================================================================== RCS file: nm-nbsd.h diff -N nm-nbsd.h *** /dev/null Tue May 5 13:32:27 1998 --- nm-nbsd.h Thu Jan 17 22:27:16 2002 *************** *** 0 **** --- 1,36 ---- + /* Native-dependent definitions for Alpha running NetBSD, for GDB. + Copyright 2002 Free Software Foundation, Inc. + Contributed by Wasabi Systems, 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 + + #define SVR4_SHARED_LIBS + + /* Get generic NetBSD native definitions. */ + #include "config/nm-nbsd.h" + + /* The Alpha does not step over a breakpoint. */ + #define CANNOT_STEP_BREAKPOINT + + /* NetBSD/alpha has shared libraries. */ + #define GDB_TARGET_HAS_SHARED_LIBS + + #endif /* NM_NBSD_H */ Index: config/alpha/tm-alpha.h =================================================================== RCS file: /cvs/src/src/gdb/config/alpha/tm-alpha.h,v retrieving revision 1.7 diff -c -r1.7 tm-alpha.h *** tm-alpha.h 2001/12/15 16:53:23 1.7 --- tm-alpha.h 2002/01/18 06:27:17 *************** *** 474,477 **** --- 474,480 ---- extern CORE_ADDR alpha_osf_skip_sigtramp_frame (struct frame_info *, CORE_ADDR); + /* Single step based on where the current instruction will take us. */ + extern void alpha_software_single_step (enum target_signal, int); + #endif /* TM_ALPHA_H */ Index: config/alpha/tm-nbsd.h =================================================================== RCS file: tm-nbsd.h diff -N tm-nbsd.h *** /dev/null Tue May 5 13:32:27 1998 --- tm-nbsd.h Thu Jan 17 22:27:17 2002 *************** *** 0 **** --- 1,45 ---- + /* Macro definitions for Alpha running under NetBSD. + Copyright 2002 Free Software Foundation, Inc. + Contributed by Wasabi Systems, 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 + + #include "alpha/tm-alpha.h" + #include "config/tm-nbsd.h" + + /* NetBSD does not mark the outermost frame. Instead, we consider the + the entry point as the outermost frame. */ + #define FRAME_CHAIN_VALID(chain, thisframe) \ + func_frame_chain_valid(chain, thisframe) + + /* NetBSD/alpha does not provide single step support via ptrace(2); we + must use software single-stepping. */ + #define SOFTWARE_SINGLE_STEP_P() 1 + #define SOFTWARE_SINGLE_STEP(sig,bpt) alpha_software_single_step((sig), (bpt)) + + /* Use the default in inferior.h */ + #undef START_INFERIOR_TRAPS_EXPECTED + + /* NetBSD/alpha's userland entry point is __start. solib-svr4.c looks + for _start. */ + #define SOLIB_BKPT_NAME "__start" + + #endif /* TM_NBSD_H */ Index: config/alpha/xm-nbsd.h =================================================================== RCS file: xm-nbsd.h diff -N xm-nbsd.h *** /dev/null Tue May 5 13:32:27 1998 --- xm-nbsd.h Thu Jan 17 22:27:17 2002 *************** *** 0 **** --- 1,23 ---- + /* Parameters for execution on an Alpha running NetBSD, for GDB. + Copyright 2002 Free Software Foundation, Inc. + Contributed by Wasabi Systems, 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 "config/xm-nbsd.h"