old-cross-binutils/gdb/mips-xdep.c

153 lines
3.8 KiB
C
Raw Normal View History

1991-03-28 16:28:29 +00:00
/* Low level MIPS interface to ptrace, for GDB when running under Unix.
Copyright 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
1991-03-28 16:28:29 +00:00
Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
1991-03-28 16:28:29 +00:00
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.
1991-03-28 16:28:29 +00:00
This program is distributed in the hope that it will be useful,
1991-03-28 16:28:29 +00:00
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. */
1991-03-28 16:28:29 +00:00
#include "defs.h"
1991-03-28 16:28:29 +00:00
#include "inferior.h"
#include "gdbcore.h"
/* For now we stub this out; sgi core format is super-hairy (and completely
different in the new release).
For most mips systems, this function is defined in coredep.c. */
1991-08-31 00:31:30 +00:00
#if defined(sgi)
1991-08-31 00:31:30 +00:00
void
fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
char *core_reg_sect;
unsigned core_reg_size;
int which;
unsigned int reg_addr;
1991-08-31 00:31:30 +00:00
{
return;
}
#endif
/* Access to the inferior is only good for native systems, not cross.
I am not sure why this is stubbed out on SGI... --gnu@cygnus.com */
#if defined(sgi) || !defined(GDB_TARGET_IS_MIPS)
1991-08-31 00:31:30 +00:00
/* ARGSUSED */
1991-08-31 00:31:30 +00:00
void
fetch_inferior_registers (regno)
int regno;
1991-08-31 00:31:30 +00:00
{
return;
}
/* ARGSUSED */
void
1991-08-31 00:31:30 +00:00
store_inferior_registers (regno)
int regno;
{
return;
}
#else
* infrun.c: Fixed typo in comment. * utils.c: All the v*fprintf emulation is now in libiberty, so we can get rid of some junk. * xm-sun3os4.h, xm-sun4os4.h, xconfig/decstation, xconfig/i386sco, xconfig/sun3os4, xconfig/sun4os4: Don`t need HAVE_STRSTR any more. * m68k-pinsn.c (print_insn_arg): Support BB/BW/BL type operands, as used by branch instructions. * gmalloc.c: Fix prototype of memcpy. * elfread.c: Comment out register_addr, since it conflicts with the one in coredep.c. * buildsym.h: Remove extern declarations of two functions that are really static in buildsym.c. * tm-mips.h: Add symbolic names for more registers. * mips-xdep.c (store_inferior_registers): Use new register names. * xm-mips.h: Simplify REGISTER_U_ADDR, since it is now only used for core files, not ptrace. Therefore, the KERNEL_U_ADDR hack is no longer needed. The mapping to ptrace number is now in in mips-xdep.c. * mips-xdep.c: Define REGISTER_PTRACE_ADDR (using the mapping from the old REGISTER_U_ADDR), and use it in {fetch,store}_inferior_registers. * mipsread.c: Rename #include ecoff.h to new name coff-mips.h. * mips-tdep.c (mips_push_dummy_frame, mips_pop_frame): Save/restore FP regs correctly (?). * dbxread.c: Remove duplicate define_symbol and type_synonym_name (these had been previously moved to buildsym.c). Hence, define_symbol becomes extern instead of static. * buildsym.c (read_struct_type): Comment out bogus handling of C++ operator methods. Minor hacking of reading of class contexts. Make define_symbol non-static, so dbxread.c can call it.
1991-11-04 23:15:31 +00:00
/* Map gdb internal register number to ptrace address. */
#define REGISTER_PTRACE_ADDR(regno) \
(regno < 32 ? regno \
: regno == PC_REGNUM ? 96 \
: regno == CAUSE_REGNUM ? 97 \
: regno == HI_REGNUM ? 98 \
: regno == LO_REGNUM ? 99 \
: regno == FCRCS_REGNUM ? 100 \
: regno == FCRIR_REGNUM ? 101 \
: regno >= FP0_REGNUM ? regno - (FP0_REGNUM-32)\
: 0)
1991-03-28 16:28:29 +00:00
/* Get all registers from the inferior */
void
fetch_inferior_registers (regno)
int regno;
1991-03-28 16:28:29 +00:00
{
register unsigned int regaddr;
char buf[MAX_REGISTER_RAW_SIZE];
register int i;
registers_fetched ();
for (regno = 1; regno < NUM_REGS; regno++)
{
* infrun.c: Fixed typo in comment. * utils.c: All the v*fprintf emulation is now in libiberty, so we can get rid of some junk. * xm-sun3os4.h, xm-sun4os4.h, xconfig/decstation, xconfig/i386sco, xconfig/sun3os4, xconfig/sun4os4: Don`t need HAVE_STRSTR any more. * m68k-pinsn.c (print_insn_arg): Support BB/BW/BL type operands, as used by branch instructions. * gmalloc.c: Fix prototype of memcpy. * elfread.c: Comment out register_addr, since it conflicts with the one in coredep.c. * buildsym.h: Remove extern declarations of two functions that are really static in buildsym.c. * tm-mips.h: Add symbolic names for more registers. * mips-xdep.c (store_inferior_registers): Use new register names. * xm-mips.h: Simplify REGISTER_U_ADDR, since it is now only used for core files, not ptrace. Therefore, the KERNEL_U_ADDR hack is no longer needed. The mapping to ptrace number is now in in mips-xdep.c. * mips-xdep.c: Define REGISTER_PTRACE_ADDR (using the mapping from the old REGISTER_U_ADDR), and use it in {fetch,store}_inferior_registers. * mipsread.c: Rename #include ecoff.h to new name coff-mips.h. * mips-tdep.c (mips_push_dummy_frame, mips_pop_frame): Save/restore FP regs correctly (?). * dbxread.c: Remove duplicate define_symbol and type_synonym_name (these had been previously moved to buildsym.c). Hence, define_symbol becomes extern instead of static. * buildsym.c (read_struct_type): Comment out bogus handling of C++ operator methods. Minor hacking of reading of class contexts. Make define_symbol non-static, so dbxread.c can call it.
1991-11-04 23:15:31 +00:00
regaddr = REGISTER_PTRACE_ADDR (regno);
1991-03-28 16:28:29 +00:00
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
*(int *) &buf[i] = ptrace (3, inferior_pid,
(PTRACE_ARG3_TYPE) regaddr, 0);
1991-03-28 16:28:29 +00:00
regaddr += sizeof (int);
}
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). */
1991-08-31 00:31:30 +00:00
void
1991-03-28 16:28:29 +00:00
store_inferior_registers (regno)
int regno;
1991-08-31 00:31:30 +00:00
{
1991-03-28 16:28:29 +00:00
register unsigned int regaddr;
char buf[80];
if (regno == 0)
return;
if (regno > 0)
{
* infrun.c: Fixed typo in comment. * utils.c: All the v*fprintf emulation is now in libiberty, so we can get rid of some junk. * xm-sun3os4.h, xm-sun4os4.h, xconfig/decstation, xconfig/i386sco, xconfig/sun3os4, xconfig/sun4os4: Don`t need HAVE_STRSTR any more. * m68k-pinsn.c (print_insn_arg): Support BB/BW/BL type operands, as used by branch instructions. * gmalloc.c: Fix prototype of memcpy. * elfread.c: Comment out register_addr, since it conflicts with the one in coredep.c. * buildsym.h: Remove extern declarations of two functions that are really static in buildsym.c. * tm-mips.h: Add symbolic names for more registers. * mips-xdep.c (store_inferior_registers): Use new register names. * xm-mips.h: Simplify REGISTER_U_ADDR, since it is now only used for core files, not ptrace. Therefore, the KERNEL_U_ADDR hack is no longer needed. The mapping to ptrace number is now in in mips-xdep.c. * mips-xdep.c: Define REGISTER_PTRACE_ADDR (using the mapping from the old REGISTER_U_ADDR), and use it in {fetch,store}_inferior_registers. * mipsread.c: Rename #include ecoff.h to new name coff-mips.h. * mips-tdep.c (mips_push_dummy_frame, mips_pop_frame): Save/restore FP regs correctly (?). * dbxread.c: Remove duplicate define_symbol and type_synonym_name (these had been previously moved to buildsym.c). Hence, define_symbol becomes extern instead of static. * buildsym.c (read_struct_type): Comment out bogus handling of C++ operator methods. Minor hacking of reading of class contexts. Make define_symbol non-static, so dbxread.c can call it.
1991-11-04 23:15:31 +00:00
regaddr = REGISTER_PTRACE_ADDR (regno);
1991-03-28 16:28:29 +00:00
errno = 0;
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
read_register (regno));
1991-03-28 16:28:29 +00:00
if (errno != 0)
{
sprintf (buf, "writing register number %d", regno);
perror_with_name (buf);
}
}
else
{
* infrun.c: Fixed typo in comment. * utils.c: All the v*fprintf emulation is now in libiberty, so we can get rid of some junk. * xm-sun3os4.h, xm-sun4os4.h, xconfig/decstation, xconfig/i386sco, xconfig/sun3os4, xconfig/sun4os4: Don`t need HAVE_STRSTR any more. * m68k-pinsn.c (print_insn_arg): Support BB/BW/BL type operands, as used by branch instructions. * gmalloc.c: Fix prototype of memcpy. * elfread.c: Comment out register_addr, since it conflicts with the one in coredep.c. * buildsym.h: Remove extern declarations of two functions that are really static in buildsym.c. * tm-mips.h: Add symbolic names for more registers. * mips-xdep.c (store_inferior_registers): Use new register names. * xm-mips.h: Simplify REGISTER_U_ADDR, since it is now only used for core files, not ptrace. Therefore, the KERNEL_U_ADDR hack is no longer needed. The mapping to ptrace number is now in in mips-xdep.c. * mips-xdep.c: Define REGISTER_PTRACE_ADDR (using the mapping from the old REGISTER_U_ADDR), and use it in {fetch,store}_inferior_registers. * mipsread.c: Rename #include ecoff.h to new name coff-mips.h. * mips-tdep.c (mips_push_dummy_frame, mips_pop_frame): Save/restore FP regs correctly (?). * dbxread.c: Remove duplicate define_symbol and type_synonym_name (these had been previously moved to buildsym.c). Hence, define_symbol becomes extern instead of static. * buildsym.c (read_struct_type): Comment out bogus handling of C++ operator methods. Minor hacking of reading of class contexts. Make define_symbol non-static, so dbxread.c can call it.
1991-11-04 23:15:31 +00:00
for (regno = 0; regno < NUM_REGS; regno++)
1991-03-28 16:28:29 +00:00
{
* infrun.c: Fixed typo in comment. * utils.c: All the v*fprintf emulation is now in libiberty, so we can get rid of some junk. * xm-sun3os4.h, xm-sun4os4.h, xconfig/decstation, xconfig/i386sco, xconfig/sun3os4, xconfig/sun4os4: Don`t need HAVE_STRSTR any more. * m68k-pinsn.c (print_insn_arg): Support BB/BW/BL type operands, as used by branch instructions. * gmalloc.c: Fix prototype of memcpy. * elfread.c: Comment out register_addr, since it conflicts with the one in coredep.c. * buildsym.h: Remove extern declarations of two functions that are really static in buildsym.c. * tm-mips.h: Add symbolic names for more registers. * mips-xdep.c (store_inferior_registers): Use new register names. * xm-mips.h: Simplify REGISTER_U_ADDR, since it is now only used for core files, not ptrace. Therefore, the KERNEL_U_ADDR hack is no longer needed. The mapping to ptrace number is now in in mips-xdep.c. * mips-xdep.c: Define REGISTER_PTRACE_ADDR (using the mapping from the old REGISTER_U_ADDR), and use it in {fetch,store}_inferior_registers. * mipsread.c: Rename #include ecoff.h to new name coff-mips.h. * mips-tdep.c (mips_push_dummy_frame, mips_pop_frame): Save/restore FP regs correctly (?). * dbxread.c: Remove duplicate define_symbol and type_synonym_name (these had been previously moved to buildsym.c). Hence, define_symbol becomes extern instead of static. * buildsym.c (read_struct_type): Comment out bogus handling of C++ operator methods. Minor hacking of reading of class contexts. Make define_symbol non-static, so dbxread.c can call it.
1991-11-04 23:15:31 +00:00
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))
1991-03-28 16:28:29 +00:00
continue;
regaddr = register_addr (regno, 1);
errno = 0;
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
read_register (regno));
1991-03-28 16:28:29 +00:00
if (errno != 0)
{
sprintf (buf, "writing all regs, number %d", regno);
perror_with_name (buf);
}
}
}
}
1991-08-31 00:31:30 +00:00
#endif /* sgi */