diff options
author | Jim Blandy <jimb@codesourcery.com> | 2004-02-18 03:42:51 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2004-02-18 03:42:51 +0000 |
commit | 267be6a2d9c481b5e7cde35f050a3719a207f446 (patch) | |
tree | 93ce04104216ba776409d904d873c11dfd2ebd94 /gdb/s390-nat.c | |
parent | b05fd937bb60e224c1d3335a0e4f2c91254a2b63 (diff) | |
download | gdb-267be6a2d9c481b5e7cde35f050a3719a207f446.tar.gz |
2004-02-17 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Committed by Jim Blandy <jimb@redhat.com>.
* config/s390/nm-linux.h: Update comments. Do not include "solib.h".
(KERNEL_U_ADDR, REGISTER_U_ADDR, U_REGS_OFFSET): Remove.
(FETCH_INFERIOR_REGISTERS): Define.
* config/s390/s390.mh (NATDEPFILES): Remove core-aout.o and
core-regset.o.
* config/s390/s390x.mt: Remove.
* config/s390/tm-s390.h: Remove.
* config/s390/tm-linux.h: Do not include "s390/tm-s390.h".
(TARGET_ELF64): Remove.
(SKIP_TRAMPOLINE_CODE): Do not undefine.
* configure.tgt [s390-*-*, s390x-*-*]: Merge into single
s390*-*-* case; always set gdb_target to s390.
* regformats/reg-s390.dat: Remove control registers.
* regformats/reg-s390x.dat: Likewise.
* s390-tdep.h: New file.
* s390-nat.c: Do not include <asm/processor.h> or <value.h>.
Include "inferior.h" and "s390-tdep.h".
Remove private definition of offsetof.
(s390_register_u_addr): Remove.
(regmap_gregset, regmap_fpregset): Define.
(supply_gregset, fill_gregset): Reimplement.
(supply_fpregset, fill_fpregset): Likewise.
(s390_inferior_tid): New function.
(fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise.
(fetch_inferior_registers, store_inferior_registers): Likewise.
* s390-tdep.c: Do not define S390_TDEP. Include "defs.h" instead
of <defs.h>. Include "reggroups.h", "regset.h", and "s390-tdep.h".
Global replace of S390_GP0_REGNUM by S390_R0_REGNUM.
Global replace of S390_FP0_REGNUM by S390_F0_REGNUM.
(struct gdbarch_tdep): Define.
(struct s390_register_info): Define.
(s390_register_info): New variable.
(s390_register_name): Reimplement.
(s390_register_type): New function.
(s390_register_raw_size, s390x_register_raw_size): Remove.
(s390_cannot_fetch_register): Remove.
(s390_register_byte): Remove.
(s390_register_virtual_type, s390x_register_virtual_type): Remove.
(s390_dwarf_regmap): New variable.
(s390_dwarf_reg_to_regnum): New function.
(s390_stab_reg_to_regnum): Remove.
(s390_pseudo_register_read, s390_pseudo_register_write): New functions.
(s390x_pseudo_register_read, s390x_pseudo_register_write): Likewise.
(s390_convert_register_p): Likewise.
(s390_register_to_value, s390_value_to_register): Likewise.
(s390_register_reggroup_p): Likewise.
(s390_regmap_gregset, s390x_regmap_gregset, s390_regmap_fpregset,
s390_gregset, s390x_gregset, s390_fpregset): New variables.
(s390_supply_regset, s390_regset_from_core_section): New functions.
(GDB_TARGET_IS_ESAME): Move here from tm-s390.h.
(S390_FPR_SIZE): Likewise.
(S390_GPR_SIZE): Likewise. Redefine in terms of GDB_TARGET_IS_ESAME.
Global replace of DEPRECATED_REGISTER_SIZE by S390_GPR_SIZE.
(S390_NUM_GPRS): Move here from tm-s390.h.
(S390_NUM_FPRS): Likewise.
(s390_in_function_epilogue_p): New function.
(s390_is_sigreturn): Replace S390_PSW_ADDR_SIZE by S390_GPR_SIZE.
Replace S390_PC_REGNUM by S390_PSWA_REGNUM.
(s390_gdbarch_init): Allocate and set up gdbarch_tdep structure.
Replace s390_stab_reg_to_regnum by s390_dwarf_reg_to_regnum.
Replace S390_FP_REGNUM by S390_SP_REGNUM.
Remove calls to:
set_gdbarch_deprecated_max_register_raw_size,
set_gdbarch_deprecated_max_register_virtual_size,
set_gdbarch_deprecated_register_byte,
set_gdbarch_cannot_fetch_register,
set_gdbarch_cannot_store_register,
set_gdbarch_deprecated_register_size,
set_gdbarch_deprecated_register_raw_size,
set_gdbarch_deprecated_register_virtual_size,
set_gdbarch_deprecated_register_virtual_type,
set_gdbarch_deprecated_register_bytes.
Add calls to:
set_gdbarch_num_pseudo_regs,
set_gdbarch_register_type,
set_gdbarch_convert_register_p,
set_gdbarch_register_to_value,
set_gdbarch_value_to_register,
set_gdbarch_register_reggroup_p,
set_gdbarch_regset_from_core_section,
set_gdbarch_pseudo_register_read,
set_gdbarch_pseudo_register_write,
set_gdbarch_in_function_epilogue_p.
* Makefile.in (s390-nat.o, s390-tdep.o): Update dependencies.
(s390_tdep_h): New variable.
Diffstat (limited to 'gdb/s390-nat.c')
-rw-r--r-- | gdb/s390-nat.c | 345 |
1 files changed, 186 insertions, 159 deletions
diff --git a/gdb/s390-nat.c b/gdb/s390-nat.c index 732cf94451a..ed6c4088b10 100644 --- a/gdb/s390-nat.c +++ b/gdb/s390-nat.c @@ -1,7 +1,9 @@ /* S390 native-dependent code for GDB, the GNU debugger. - Copyright 2001 Free Software Foundation, Inc + Copyright 2001, 2003 Free Software Foundation, Inc + Contributed by D.J. Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) for IBM Deutschland Entwicklung GmbH, IBM Corporation. + This file is part of GDB. This program is free software; you can redistribute it and/or modify @@ -22,52 +24,201 @@ #include "defs.h" #include "tm.h" #include "regcache.h" +#include "inferior.h" + +#include "s390-tdep.h" + #include <asm/ptrace.h> #include <sys/ptrace.h> -#include <asm/processor.h> #include <asm/types.h> #include <sys/procfs.h> #include <sys/user.h> -#include <value.h> #include <sys/ucontext.h> -#ifndef offsetof -#define offsetof(type,member) ((size_t) &((type *)0)->member) -#endif -int -s390_register_u_addr (int blockend, int regnum) -{ - int retval; - - if (regnum >= S390_GP0_REGNUM && regnum <= S390_GP_LAST_REGNUM) - retval = PT_GPR0 + ((regnum - S390_GP0_REGNUM) * S390_GPR_SIZE); - else if (regnum >= S390_PSWM_REGNUM && regnum <= S390_PC_REGNUM) - retval = PT_PSWMASK + ((regnum - S390_PSWM_REGNUM) * S390_PSW_MASK_SIZE); - else if (regnum == S390_FPC_REGNUM) - retval = PT_FPC; - else if (regnum >= S390_FP0_REGNUM && regnum <= S390_FPLAST_REGNUM) - retval = -#if CONFIG_ARCH_S390X - PT_FPR0 +/* Map registers to gregset/ptrace offsets. + These arrays are defined in s390-tdep.c. */ + +#ifdef __s390x__ +#define regmap_gregset s390x_regmap_gregset #else - PT_FPR0_HI +#define regmap_gregset s390_regmap_gregset #endif - + ((regnum - S390_FP0_REGNUM) * S390_FPR_SIZE); - else if (regnum >= S390_FIRST_ACR && regnum <= S390_LAST_ACR) - retval = PT_ACR0 + ((regnum - S390_FIRST_ACR) * S390_ACR_SIZE); - else if (regnum >= (S390_FIRST_CR + 9) && regnum <= (S390_FIRST_CR + 11)) - retval = PT_CR_9 + ((regnum - (S390_FIRST_CR + 9)) * S390_CR_SIZE); - else - { - internal_error (__FILE__, __LINE__, - "s390_register_u_addr invalid regnum regnum=%d", - regnum); - retval = 0; - } - return retval + blockend; + +#define regmap_fpregset s390_regmap_fpregset + + +/* Fill GDB's register array with the general-purpose register values + in *REGP. */ +void +supply_gregset (gregset_t *regp) +{ + int i; + for (i = 0; i < S390_NUM_REGS; i++) + if (regmap_gregset[i] != -1) + regcache_raw_supply (current_regcache, i, + (char *)regp + regmap_gregset[i]); +} + +/* Fill register REGNO (if it is a general-purpose register) in + *REGP with the value in GDB's register array. If REGNO is -1, + do this for all registers. */ +void +fill_gregset (gregset_t *regp, int regno) +{ + int i; + for (i = 0; i < S390_NUM_REGS; i++) + if (regmap_gregset[i] != -1) + if (regno == -1 || regno == i) + regcache_raw_collect (current_regcache, i, + (char *)regp + regmap_gregset[i]); +} + +/* Fill GDB's register array with the floating-point register values + in *REGP. */ +void +supply_fpregset (fpregset_t *regp) +{ + int i; + for (i = 0; i < S390_NUM_REGS; i++) + if (regmap_fpregset[i] != -1) + regcache_raw_supply (current_regcache, i, + ((char *)regp) + regmap_fpregset[i]); +} + +/* Fill register REGNO (if it is a general-purpose register) in + *REGP with the value in GDB's register array. If REGNO is -1, + do this for all registers. */ +void +fill_fpregset (fpregset_t *regp, int regno) +{ + int i; + for (i = 0; i < S390_NUM_REGS; i++) + if (regmap_fpregset[i] != -1) + if (regno == -1 || regno == i) + regcache_raw_collect (current_regcache, i, + ((char *)regp) + regmap_fpregset[i]); +} + +/* Find the TID for the current inferior thread to use with ptrace. */ +static int +s390_inferior_tid (void) +{ + /* GNU/Linux LWP ID's are process ID's. */ + int tid = TIDGET (inferior_ptid); + if (tid == 0) + tid = PIDGET (inferior_ptid); /* Not a threaded program. */ + + return tid; +} + +/* Fetch all general-purpose registers from process/thread TID and + store their values in GDB's register cache. */ +static void +fetch_regs (int tid) +{ + gregset_t regs; + ptrace_area parea; + + parea.len = sizeof (regs); + parea.process_addr = (addr_t) ®s; + parea.kernel_addr = offsetof (struct user_regs_struct, psw); + if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0) + perror_with_name ("Couldn't get registers"); + + supply_gregset (®s); +} + +/* Store all valid general-purpose registers in GDB's register cache + into the process/thread specified by TID. */ +static void +store_regs (int tid, int regnum) +{ + gregset_t regs; + ptrace_area parea; + + parea.len = sizeof (regs); + parea.process_addr = (addr_t) ®s; + parea.kernel_addr = offsetof (struct user_regs_struct, psw); + if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0) + perror_with_name ("Couldn't get registers"); + + fill_gregset (®s, regnum); + + if (ptrace (PTRACE_POKEUSR_AREA, tid, (long) &parea) < 0) + perror_with_name ("Couldn't write registers"); +} + +/* Fetch all floating-point registers from process/thread TID and store + their values in GDB's register cache. */ +static void +fetch_fpregs (int tid) +{ + fpregset_t fpregs; + ptrace_area parea; + + parea.len = sizeof (fpregs); + parea.process_addr = (addr_t) &fpregs; + parea.kernel_addr = offsetof (struct user_regs_struct, fp_regs); + if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0) + perror_with_name ("Couldn't get floating point status"); + + supply_fpregset (&fpregs); +} + +/* Store all valid floating-point registers in GDB's register cache + into the process/thread specified by TID. */ +static void +store_fpregs (int tid, int regnum) +{ + fpregset_t fpregs; + ptrace_area parea; + + parea.len = sizeof (fpregs); + parea.process_addr = (addr_t) &fpregs; + parea.kernel_addr = offsetof (struct user_regs_struct, fp_regs); + if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0) + perror_with_name ("Couldn't get floating point status"); + + fill_fpregset (&fpregs, regnum); + + if (ptrace (PTRACE_POKEUSR_AREA, tid, (long) &parea) < 0) + perror_with_name ("Couldn't write floating point status"); +} + +/* Fetch register REGNUM from the child process. If REGNUM is -1, do + this for all registers. */ +void +fetch_inferior_registers (int regnum) +{ + int tid = s390_inferior_tid (); + + if (regnum == -1 + || (regnum < S390_NUM_REGS && regmap_gregset[regnum] != -1)) + fetch_regs (tid); + + if (regnum == -1 + || (regnum < S390_NUM_REGS && regmap_fpregset[regnum] != -1)) + fetch_fpregs (tid); +} + +/* Store register REGNUM back into the child process. If REGNUM is + -1, do this for all registers. */ +void +store_inferior_registers (int regnum) +{ + int tid = s390_inferior_tid (); + + if (regnum == -1 + || (regnum < S390_NUM_REGS && regmap_gregset[regnum] != -1)) + store_regs (tid, regnum); + + if (regnum == -1 + || (regnum < S390_NUM_REGS && regmap_fpregset[regnum] != -1)) + store_fpregs (tid, regnum); } + /* watch_areas are required if you put 2 or more watchpoints on the same address or overlapping areas gdb will call us to delete the watchpoint more than once when we try to delete them. @@ -232,127 +383,3 @@ kernel_u_size (void) return sizeof (struct user); } - -#if (defined (S390_FP0_REGNUM) && defined (HAVE_FPREGSET_T) && defined(HAVE_SYS_PROCFS_H) && defined (HAVE_GREGSET_T)) -void -supply_gregset (gregset_t * gregsetp) -{ - int regi; - greg_t *gregp = (greg_t *) gregsetp; - - supply_register (S390_PSWM_REGNUM, (char *) &gregp[S390_PSWM_REGNUM]); - supply_register (S390_PC_REGNUM, (char *) &gregp[S390_PC_REGNUM]); - for (regi = 0; regi < S390_NUM_GPRS; regi++) - supply_register (S390_GP0_REGNUM + regi, - (char *) &gregp[S390_GP0_REGNUM + regi]); - -#if defined (CONFIG_ARCH_S390X) - /* On the s390x, each element of gregset_t is 8 bytes long, but - each access register is still only 32 bits long. So they're - packed two per element. It's apparently traditional that - gregset_t must be an array, so when the registers it provides - have different sizes, something has to get strange - somewhere. */ - { - unsigned int *acrs = (unsigned int *) &gregp[S390_FIRST_ACR]; - - for (regi = 0; regi < S390_NUM_ACRS; regi++) - supply_register (S390_FIRST_ACR + regi, (char *) &acrs[regi]); - } -#else - for (regi = 0; regi < S390_NUM_ACRS; regi++) - supply_register (S390_FIRST_ACR + regi, - (char *) &gregp[S390_FIRST_ACR + regi]); -#endif - - /* unfortunately this isn't in gregsetp */ - for (regi = 0; regi < S390_NUM_CRS; regi++) - supply_register (S390_FIRST_CR + regi, NULL); -} - - -void -supply_fpregset (fpregset_t * fpregsetp) -{ - int regi; - - supply_register (S390_FPC_REGNUM, (char *) &fpregsetp->fpc); - for (regi = 0; regi < S390_NUM_FPRS; regi++) - supply_register (S390_FP0_REGNUM + regi, (char *) &fpregsetp->fprs[regi]); - -} - -void -fill_gregset (gregset_t * gregsetp, int regno) -{ - int regi; - greg_t *gregp = (greg_t *) gregsetp; - - if (regno < 0) - { - regcache_collect (S390_PSWM_REGNUM, &gregp[S390_PSWM_REGNUM]); - regcache_collect (S390_PC_REGNUM, &gregp[S390_PC_REGNUM]); - for (regi = 0; regi < S390_NUM_GPRS; regi++) - regcache_collect (S390_GP0_REGNUM + regi, - &gregp[S390_GP0_REGNUM + regi]); -#if defined (CONFIG_ARCH_S390X) - /* See the comments about the access registers in - supply_gregset, above. */ - { - unsigned int *acrs = (unsigned int *) &gregp[S390_FIRST_ACR]; - - for (regi = 0; regi < S390_NUM_ACRS; regi++) - regcache_collect (S390_FIRST_ACR + regi, &acrs[regi]); - } -#else - for (regi = 0; regi < S390_NUM_ACRS; regi++) - regcache_collect (S390_FIRST_ACR + regi, - &gregp[S390_FIRST_ACR + regi]); -#endif - } - else if (regno >= S390_PSWM_REGNUM && regno < S390_FIRST_ACR) - regcache_collect (regno, &gregp[regno]); - else if (regno >= S390_FIRST_ACR && regno <= S390_LAST_ACR) - { -#if defined (CONFIG_ARCH_S390X) - /* See the comments about the access registers in - supply_gregset, above. */ - unsigned int *acrs = (unsigned int *) &gregp[S390_FIRST_ACR]; - - regcache_collect (regno, &acrs[regno - S390_FIRST_ACR]); -#else - regcache_collect (regno, &gregp[regno]); -#endif - } -} - -/* Given a pointer to a floating point register set in /proc format - (fpregset_t *), update the register specified by REGNO from gdb's idea - of the current floating point register set. If REGNO is -1, update - them all. */ - -void -fill_fpregset (fpregset_t * fpregsetp, int regno) -{ - int regi; - - if (regno < 0) - { - regcache_collect (S390_FPC_REGNUM, &fpregsetp->fpc); - for (regi = 0; regi < S390_NUM_FPRS; regi++) - regcache_collect (S390_FP0_REGNUM + regi, &fpregsetp->fprs[regi]); - } - else if (regno == S390_FPC_REGNUM) - regcache_collect (S390_FPC_REGNUM, &fpregsetp->fpc); - else if (regno >= S390_FP0_REGNUM && regno <= S390_FPLAST_REGNUM) - regcache_collect (regno, &fpregsetp->fprs[regno - S390_FP0_REGNUM]); -} - - -#else -#error "There are a few possibilities here" -#error "1) You aren't compiling for linux & don't need a core dumps to work." -#error "2) The header files sys/elf.h sys/user.h sys/ptrace.h & sys/procfs.h" -#error "libc files are inconsistent with linux/include/asm-s390/" -#error "3) you didn't do a completely clean build & delete config.cache." -#endif |