diff --git a/gdb/.Sanitize b/gdb/.Sanitize index f9d330abc4..01777302a0 100644 --- a/gdb/.Sanitize +++ b/gdb/.Sanitize @@ -159,6 +159,7 @@ hp300ux-nat.c hppa-tdep.c hppab-nat.c hppah-nat.c +hppam3-nat.c hpread.c i386-stub.c i386-tdep.c diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c1462814ec..c0ab295b5c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +Thu May 11 19:01:37 1995 Jeff Law (law@snake.cs.utah.edu) + + * Support debugging using native MACH primitives on hppa*-*-osf*. + * configure.in: hppa*-*-osf* != hppa*-*-bsd* anymore. + * config/pa/hppaosf.mh: New file. + * config/pa/nm-hppao.h: Likewise. + * hppam3-nat.c: Likewise. + * config/pa/tm-hppao.h (PSW_SS): Define for single-stepping. + (MACHINE_CPROC_*_OFFSET): Define. + (TRACE_*): Define. + (START_INFERIOR_TRAPS_EXPECTED): Delete definition. + Wed May 10 18:59:26 1995 Stu Grossman (grossman@andros.cygnus.com) * hppa-tdep.c (read_unwind_info): Cosmetic cleanup. diff --git a/gdb/config/pa/.Sanitize b/gdb/config/pa/.Sanitize index d7045c4aa0..edef1a91aa 100644 --- a/gdb/config/pa/.Sanitize +++ b/gdb/config/pa/.Sanitize @@ -25,10 +25,12 @@ hppabsd.mh hppabsd.mt hppahpux.mh hppahpux.mt +hppaosf.mh hppaosf.mt hppapro.mt nm-hppab.h nm-hppah.h +nm-hppao.h tm-hppa.h tm-hppab.h tm-hppah.h diff --git a/gdb/config/pa/hppaosf.mh b/gdb/config/pa/hppaosf.mh new file mode 100644 index 0000000000..53a022c33d --- /dev/null +++ b/gdb/config/pa/hppaosf.mh @@ -0,0 +1,6 @@ +# Host: Hewlett-Packard PA-RISC machine, running BSD +XDEPFILES= +XM_FILE= xm-hppab.h +NAT_FILE= nm-hppao.h +NATDEPFILES= fork-child.o m3-nat.o hppam3-nat.o somread.o hpread.o somsolib.o +NAT_CLIBS= -lmachid -lnetname -lmach diff --git a/gdb/config/pa/nm-hppao.h b/gdb/config/pa/nm-hppao.h new file mode 100644 index 0000000000..ca85adf96e --- /dev/null +++ b/gdb/config/pa/nm-hppao.h @@ -0,0 +1,56 @@ +/* HPPA PA-RISC machine native support for Lites, for GDB. + Copyright 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "nm-m3.h" +#define U_REGS_OFFSET 0 + +#define KERNEL_U_ADDR 0 + +/* What a coincidence! */ +#define REGISTER_U_ADDR(addr, blockend, regno) \ +{ addr = (int)(blockend) + REGISTER_BYTE (regno);} + +/* This macro defines the register numbers (from REGISTER_NAMES) that + are effectively unavailable to the user through ptrace(). It allows + us to include the whole register set in REGISTER_NAMES (inorder to + better support remote debugging). If it is used in + fetch/store_inferior_registers() gdb will not complain about I/O errors + on fetching these registers. If all registers in REGISTER_NAMES + are available, then return false (0). */ + +#define CANNOT_STORE_REGISTER(regno) \ + ((regno) == 0) || \ + ((regno) == PCSQ_HEAD_REGNUM) || \ + ((regno) >= PCSQ_TAIL_REGNUM && (regno) < IPSW_REGNUM) || \ + ((regno) > IPSW_REGNUM && (regno) < FP4_REGNUM) + +/* fetch_inferior_registers is in hppab-nat.c. */ +#define FETCH_INFERIOR_REGISTERS + +/* attach/detach works to some extent under BSD and HPUX. So long + as the process you're attaching to isn't blocked waiting on io, + blocked waiting on a signal, or in a system call things work + fine. (The problems in those cases are related to the fact that + the kernel can't provide complete register information for the + target process... Which really pisses off GDB.) */ + +#define ATTACH_DETACH + +#define EMULATOR_BASE 0x90100000 +#define EMULATOR_END 0x90200000 diff --git a/gdb/config/pa/tm-hppao.h b/gdb/config/pa/tm-hppao.h index e34201f7d7..aab7274276 100644 --- a/gdb/config/pa/tm-hppao.h +++ b/gdb/config/pa/tm-hppao.h @@ -2,6 +2,28 @@ Contributed by the Center for Software Science at the University of Utah (pa-gdb-bugs@cs.utah.edu). */ +/* Define offsets to access CPROC stack when it does not have + * a kernel thread. + */ +#define MACHINE_CPROC_SP_OFFSET 20 +#define MACHINE_CPROC_PC_OFFSET 16 +#define MACHINE_CPROC_FP_OFFSET 12 + +/* + * Software defined PSW masks. + */ +#define PSW_SS 0x10000000 /* Kernel managed single step */ + +/* Thread flavors used in re-setting the T bit. + * @@ this is also bad for cross debugging. + */ +#define TRACE_FLAVOR HP800_THREAD_STATE +#define TRACE_FLAVOR_SIZE HP800_THREAD_STATE_COUNT +#define TRACE_SET(x,state) \ + ((struct hp800_thread_state *)state)->cr22 |= PSW_SS +#define TRACE_CLEAR(x,state) \ + ((((struct hp800_thread_state *)state)->cr22 &= ~PSW_SS), 1) + /* For OSF1 (Should be close if not identical to BSD, but I haven't tested it yet): @@ -44,9 +66,6 @@ } \ } -/* OSF1 needs an extra trap. I assume for the emulator startup (?!?) */ -#define START_INFERIOR_TRAPS_EXPECTED 3 - /* OSF1 does not need the pc space queue restored. */ #define NO_PC_SPACE_QUEUE_RESTORE diff --git a/gdb/configure.in b/gdb/configure.in index 7d50351481..bb9d332ae4 100644 --- a/gdb/configure.in +++ b/gdb/configure.in @@ -43,7 +43,7 @@ c[12]-*-*) gdb_host=convex ;; hppa*-*-bsd*) gdb_host=hppabsd ;; hppa*-*-hiux*) gdb_host=hppahpux ;; hppa*-*-hpux*) gdb_host=hppahpux ;; -hppa*-*-osf*) gdb_host=hppabsd ;; +hppa*-*-osf*) gdb_host=hppaosf ;; i[345]86-ncr-*) gdb_host=ncr3000 ;; i[345]86-sequent-bsd*) gdb_host=symmetry ;; # dynix diff --git a/gdb/hppam3-nat.c b/gdb/hppam3-nat.c new file mode 100644 index 0000000000..237782272e --- /dev/null +++ b/gdb/hppam3-nat.c @@ -0,0 +1,141 @@ +/* Low level interface to HP800 running mach 4.0. + Copyright (C) 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "defs.h" +#include "inferior.h" +#include "floatformat.h" + +#include + +#include +#include +#include +#include + +#include + +/* + * Fetch inferiors registers for gdb. + * REGNO specifies which (as gdb views it) register, -1 for all. + */ + +void +fetch_inferior_registers (regno) + int regno; +{ + kern_return_t ret; + thread_state_data_t state; + unsigned int stateCnt = HP800_THREAD_STATE_COUNT; + int index; + + if (! MACH_PORT_VALID (current_thread)) + error ("fetch inferior registers: Invalid thread"); + + if (must_suspend_thread) + setup_thread (current_thread, 1); + + ret = thread_get_state (current_thread, + HP800_THREAD_STATE, + state, + &stateCnt); + + if (ret != KERN_SUCCESS) + warning ("fetch_inferior_registers: %s ", + mach_error_string (ret)); + else + { + for (index = 0; index < NUM_REGS; index++) + supply_register (index,&state[index]); + } + + if (must_suspend_thread) + setup_thread (current_thread, 0); +} + +/* Store our register values back into the inferior. + * If REGNO is -1, do this for all registers. + * Otherwise, REGNO specifies which register + * + * On mach3 all registers are always saved in one call. + */ +void +store_inferior_registers (regno) + int regno; +{ + kern_return_t ret; + thread_state_data_t state; + unsigned int stateCnt = HP800_THREAD_STATE_COUNT; + register int index; + + if (! MACH_PORT_VALID (current_thread)) + error ("store inferior registers: Invalid thread"); + + if (must_suspend_thread) + setup_thread (current_thread, 1); + + /* Fetch the state of the current thread */ + ret = thread_get_state (current_thread, + HP800_THREAD_STATE, + state, + &stateCnt); + + if (ret != KERN_SUCCESS) + { + warning ("store_inferior_registers (get): %s", + mach_error_string (ret)); + if (must_suspend_thread) + setup_thread (current_thread, 0); + return; + } + + + /* move gdb's registers to thread's state + * + * Since we save all registers anyway, save the ones + * that gdb thinks are valid (e.g. ignore the regno + * parameter) + */ + if (regno > 0 && regno < NUM_REGS ) + { + memcpy(&state[regno], ®isters[REGISTER_BYTE (regno)], + REGISTER_RAW_SIZE(regno)); + } + else + { + for (index = 0; index < NUM_REGS; index++) + memcpy(&state[index], ®isters[REGISTER_BYTE (index)], + REGISTER_RAW_SIZE(index)); +/* state[index] = registers[REGISTER_BYTE (index)];*/ + + } + + /* Write gdb's current view of register to the thread + */ + ret = thread_set_state (current_thread, + HP800_THREAD_STATE, + state, + HP800_THREAD_STATE_COUNT); + + if (ret != KERN_SUCCESS) + warning ("store_inferior_registers (set): %s", + mach_error_string (ret)); + + if (must_suspend_thread) + setup_thread (current_thread, 0); +}