From 3f403f6ab3ffae874065b27c87d8ba52b7c820be Mon Sep 17 00:00:00 2001 From: Peter Schauer Date: Tue, 28 Mar 1995 06:57:39 +0000 Subject: [PATCH] * alpha-nat.c, irix4-nat.c, irix5-nat.c, mipsv4-nat.c, sparc-tdep.c (supply_gregset, supply_fpregset): Fill inaccessible registers with zero to handle recent read_register_bytes change. * irix4-nat.c, irix5-nat.c, mipsv4-nat.c (supply_gregset, fill_gregset): Fix handling of CAUSE_REGNUM. * mips-nat.c (store_inferior_registers): Handle unwritable registers when storing a single register. * config/mips/tm-irix3.h (CAUSE_REGNUM, BADVADDR_REGNUM): Fix definitions. * mdebugread.c (parse_symbol, psymtab_to_symtab_1): Clear allocated mips_extra_func_info, if the debug info is corrupt, the PDR to fill it in might be missing. --- gdb/ChangeLog | 16 ++++++++++++++++ gdb/alpha-nat.c | 5 +++++ gdb/irix4-nat.c | 15 +++++++++++---- gdb/irix5-nat.c | 10 ++++++++-- gdb/mdebugread.c | 3 +++ gdb/mips-nat.c | 27 +++++++-------------------- gdb/mipsv4-nat.c | 16 +++++++++++++--- 7 files changed, 63 insertions(+), 29 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 073df065fa4..287b6fbd42f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +Mon Mar 27 22:51:54 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * alpha-nat.c, irix4-nat.c, irix5-nat.c, mipsv4-nat.c, + sparc-tdep.c (supply_gregset, supply_fpregset): Fill inaccessible + registers with zero to handle recent read_register_bytes change. + * irix4-nat.c, irix5-nat.c, mipsv4-nat.c (supply_gregset, + fill_gregset): Fix handling of CAUSE_REGNUM. + * mips-nat.c (store_inferior_registers): Handle unwritable + registers when storing a single register. + * config/mips/tm-irix3.h (CAUSE_REGNUM, BADVADDR_REGNUM): + Fix definitions. + + * mdebugread.c (parse_symbol, psymtab_to_symtab_1): Clear + allocated mips_extra_func_info, if the debug info is corrupt, + the PDR to fill it in might be missing. + Mon Mar 27 14:43:00 1995 Kung Hsu * vx-share/regPacket.h: a new file interfacing with vxworks. diff --git a/gdb/alpha-nat.c b/gdb/alpha-nat.c index 4d91fe8d3d3..4c48892d28b 100644 --- a/gdb/alpha-nat.c +++ b/gdb/alpha-nat.c @@ -156,11 +156,16 @@ supply_gregset (gregsetp) { register int regi; register long *regp = gregsetp->regs; + static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0}; for (regi = 0; regi < 31; regi++) supply_register (regi, (char *)(regp + regi)); supply_register (PC_REGNUM, (char *)(regp + 31)); + + /* Fill inaccessible registers with zero. */ + supply_register (ZERO_REGNUM, zerobuf); + supply_register (FP_REGNUM, zerobuf); } void diff --git a/gdb/irix4-nat.c b/gdb/irix4-nat.c index e2a1ff29e61..9501f353c90 100644 --- a/gdb/irix4-nat.c +++ b/gdb/irix4-nat.c @@ -1,5 +1,6 @@ /* Native support for the SGI Iris running IRIX version 4, for GDB. - Copyright 1988, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1995 + Free Software Foundation, Inc. Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin. Implemented for Irix 4.x by Garrett A. Wollman. @@ -43,6 +44,7 @@ supply_gregset (gregsetp) { register int regi; register greg_t *regp = (greg_t *)(gregsetp->gp_regs); + static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0}; /* FIXME: somewhere, there should be a #define for the meaning of this magic number 32; we should use that. */ @@ -52,7 +54,10 @@ supply_gregset (gregsetp) supply_register (PC_REGNUM, (char *)&(gregsetp->gp_pc)); supply_register (HI_REGNUM, (char *)&(gregsetp->gp_mdhi)); supply_register (LO_REGNUM, (char *)&(gregsetp->gp_mdlo)); - supply_register (PS_REGNUM, (char *)&(gregsetp->gp_cause)); + supply_register (CAUSE_REGNUM, (char *)&(gregsetp->gp_cause)); + + /* Fill inaccessible registers with zero. */ + supply_register (BADVADDR_REGNUM, zerobuf); } void @@ -71,8 +76,8 @@ fill_gregset (gregsetp, regno) if ((regno == -1) || (regno == PC_REGNUM)) gregsetp->gp_pc = *(greg_t *) ®isters[REGISTER_BYTE (PC_REGNUM)]; - if ((regno == -1) || (regno == PS_REGNUM)) - gregsetp->gp_cause = *(greg_t *) ®isters[REGISTER_BYTE (PS_REGNUM)]; + if ((regno == -1) || (regno == CAUSE_REGNUM)) + gregsetp->gp_cause = *(greg_t *) ®isters[REGISTER_BYTE (CAUSE_REGNUM)]; if ((regno == -1) || (regno == HI_REGNUM)) gregsetp->gp_mdhi = *(greg_t *) ®isters[REGISTER_BYTE (HI_REGNUM)]; @@ -94,6 +99,7 @@ supply_fpregset (fpregsetp) fpregset_t *fpregsetp; { register int regi; + static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0}; for (regi = 0; regi < 32; regi++) supply_register (FP0_REGNUM + regi, @@ -102,6 +108,7 @@ supply_fpregset (fpregsetp) supply_register (FCRCS_REGNUM, (char *)&fpregsetp->fp_csr); /* FIXME: how can we supply FCRIR_REGNUM? SGI doesn't tell us. */ + supply_register (FCRIR_REGNUM, zerobuf); } void diff --git a/gdb/irix5-nat.c b/gdb/irix5-nat.c index e2707b62ba2..c6c8c5233ed 100644 --- a/gdb/irix5-nat.c +++ b/gdb/irix5-nat.c @@ -1,5 +1,5 @@ /* Native support for the SGI Iris running IRIX version 5, for GDB. - Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994 + Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin. @@ -49,6 +49,7 @@ supply_gregset (gregsetp) { register int regi; register greg_t *regp = &(*gregsetp)[0]; + static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0}; for(regi = 0; regi <= CTX_RA; regi++) supply_register (regi, (char *)(regp + regi)); @@ -57,6 +58,9 @@ supply_gregset (gregsetp) supply_register (HI_REGNUM, (char *)(regp + CTX_MDHI)); supply_register (LO_REGNUM, (char *)(regp + CTX_MDLO)); supply_register (CAUSE_REGNUM, (char *)(regp + CTX_CAUSE)); + + /* Fill inaccessible registers with zero. */ + supply_register (BADVADDR_REGNUM, zerobuf); } void @@ -75,7 +79,7 @@ fill_gregset (gregsetp, regno) *(regp + CTX_EPC) = *(greg_t *) ®isters[REGISTER_BYTE (PC_REGNUM)]; if ((regno == -1) || (regno == CAUSE_REGNUM)) - *(regp + CTX_CAUSE) = *(greg_t *) ®isters[REGISTER_BYTE (PS_REGNUM)]; + *(regp + CTX_CAUSE) = *(greg_t *) ®isters[REGISTER_BYTE (CAUSE_REGNUM)]; if ((regno == -1) || (regno == HI_REGNUM)) *(regp + CTX_MDHI) = *(greg_t *) ®isters[REGISTER_BYTE (HI_REGNUM)]; @@ -97,6 +101,7 @@ supply_fpregset (fpregsetp) fpregset_t *fpregsetp; { register int regi; + static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0}; for (regi = 0; regi < 32; regi++) supply_register (FP0_REGNUM + regi, @@ -105,6 +110,7 @@ supply_fpregset (fpregsetp) supply_register (FCRCS_REGNUM, (char *)&fpregsetp->fp_csr); /* FIXME: how can we supply FCRIR_REGNUM? SGI doesn't tell us. */ + supply_register (FCRIR_REGNUM, zerobuf); } void diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 4313b480346..5cabe8db6d9 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1150,6 +1150,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) e = ((struct mips_extra_func_info *) obstack_alloc (¤t_objfile->symbol_obstack, sizeof (struct mips_extra_func_info))); + memset ((PTR) e, 0, sizeof (struct mips_extra_func_info)); SYMBOL_VALUE (s) = (long) e; e->numargs = top_stack->numargs; e->pdr.framereg = -1; @@ -3119,6 +3120,8 @@ psymtab_to_symtab_1 (pst, filename) obstack_alloc (¤t_objfile->symbol_obstack, sizeof (struct mips_extra_func_info))); struct symbol *s = new_symbol (MIPS_EFI_SYMBOL_NAME); + + memset ((PTR) e, 0, sizeof (struct mips_extra_func_info)); SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE; SYMBOL_CLASS (s) = LOC_CONST; SYMBOL_TYPE (s) = builtin_type_void; diff --git a/gdb/mips-nat.c b/gdb/mips-nat.c index 5e34f920a11..4d1b4a00c45 100644 --- a/gdb/mips-nat.c +++ b/gdb/mips-nat.c @@ -1,5 +1,5 @@ /* Low level DECstation interface to ptrace, for GDB when running native. - Copyright 1988, 1989, 1991, 1992 Free Software Foundation, Inc. + Copyright 1988, 1989, 1991, 1992, 1995 Free Software Foundation, Inc. Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin. @@ -101,11 +101,13 @@ store_inferior_registers (regno) register unsigned int regaddr; char buf[80]; - if (regno == 0) - return; - if (regno > 0) { + if (regno == ZERO_REGNUM || regno == PS_REGNUM + || regno == BADVADDR_REGNUM || regno == CAUSE_REGNUM + || regno == FCRIR_REGNUM || regno == FP_REGNUM + || (regno >= FIRST_EMBED_REGNUM && regno <= LAST_EMBED_REGNUM)) + return; regaddr = REGISTER_PTRACE_ADDR (regno); errno = 0; ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, @@ -119,22 +121,7 @@ store_inferior_registers (regno) else { for (regno = 0; regno < NUM_REGS; regno++) - { - if (regno == ZERO_REGNUM || regno == PS_REGNUM - || regno == BADVADDR_REGNUM || regno == CAUSE_REGNUM - || regno == FCRIR_REGNUM || regno == FP_REGNUM - || (regno >= FIRST_EMBED_REGNUM && regno <= LAST_EMBED_REGNUM)) - continue; - regaddr = REGISTER_PTRACE_ADDR (regno); - errno = 0; - ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, - read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing all regs, number %d", regno); - perror_with_name (buf); - } - } + store_inferior_registers (regno); } } diff --git a/gdb/mipsv4-nat.c b/gdb/mipsv4-nat.c index b9c06929ed6..717119cc85f 100644 --- a/gdb/mipsv4-nat.c +++ b/gdb/mipsv4-nat.c @@ -1,5 +1,5 @@ /* Native support for MIPS running SVR4, for GDB. - Copyright 1994 Free Software Foundation, Inc. + Copyright 1994, 1995 Free Software Foundation, Inc. This file is part of GDB. @@ -43,14 +43,22 @@ supply_gregset (gregsetp) { register int regi; register greg_t *regp = &(*gregsetp)[0]; + static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0}; - for(regi = 0; regi <= CXT_RA; regi++) + for (regi = 0; regi <= CXT_RA; regi++) supply_register (regi, (char *)(regp + regi)); supply_register (PC_REGNUM, (char *)(regp + CXT_EPC)); supply_register (HI_REGNUM, (char *)(regp + CXT_MDHI)); supply_register (LO_REGNUM, (char *)(regp + CXT_MDLO)); supply_register (CAUSE_REGNUM, (char *)(regp + CXT_CAUSE)); + + /* Fill inaccessible registers with zero. */ + supply_register (PS_REGNUM, zerobuf); + supply_register (BADVADDR_REGNUM, zerobuf); + supply_register (FP_REGNUM, zerobuf); + for (regi = FIRST_EMBED_REGNUM; regi <= LAST_EMBED_REGNUM; regi++) + supply_register (regi, zerobuf); } void @@ -69,7 +77,7 @@ fill_gregset (gregsetp, regno) *(regp + CXT_EPC) = *(greg_t *) ®isters[REGISTER_BYTE (PC_REGNUM)]; if ((regno == -1) || (regno == CAUSE_REGNUM)) - *(regp + CXT_CAUSE) = *(greg_t *) ®isters[REGISTER_BYTE (PS_REGNUM)]; + *(regp + CXT_CAUSE) = *(greg_t *) ®isters[REGISTER_BYTE (CAUSE_REGNUM)]; if ((regno == -1) || (regno == HI_REGNUM)) *(regp + CXT_MDHI) = *(greg_t *) ®isters[REGISTER_BYTE (HI_REGNUM)]; @@ -91,6 +99,7 @@ supply_fpregset (fpregsetp) fpregset_t *fpregsetp; { register int regi; + static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0}; for (regi = 0; regi < 32; regi++) supply_register (FP0_REGNUM + regi, @@ -99,6 +108,7 @@ supply_fpregset (fpregsetp) supply_register (FCRCS_REGNUM, (char *)&fpregsetp->fp_csr); /* FIXME: how can we supply FCRIR_REGNUM? The ABI doesn't tell us. */ + supply_register (FCRIR_REGNUM, zerobuf); } void -- 2.30.2