old-cross-binutils/gdb/sparc-nat.c

325 lines
10 KiB
C
Raw Normal View History

/* Functions specific to running gdb native on a SPARC running SunOS4.
Copyright 1989, 1992, 1993, 1994, 1996 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
1995-08-02 03:41:12 +00:00
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "inferior.h"
#include "target.h"
#include "gdbcore.h"
#include <signal.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <machine/reg.h>
#include <sys/user.h>
/* We don't store all registers immediately when requested, since they
get sent over in large chunks anyway. Instead, we accumulate most
of the changes and send them over once. "deferred_stores" keeps
track of which sets of registers we have locally-changed copies of,
so we only need send the groups that have changed. */
#define INT_REGS 1
#define STACK_REGS 2
#define FP_REGS 4
static void
fetch_core_registers PARAMS ((char *, unsigned int, int, CORE_ADDR));
/* Fetch one or more registers from the inferior. REGNO == -1 to get
them all. We actually fetch more than requested, when convenient,
marking them as valid so we won't fetch them again. */
void
fetch_inferior_registers (regno)
int regno;
{
struct regs inferior_registers;
struct fp_status inferior_fp_registers;
int i;
/* We should never be called with deferred stores, because a prerequisite
for writing regs is to have fetched them all (PREPARE_TO_STORE), sigh. */
if (deferred_stores) abort();
DO_DEFERRED_STORES;
/* Global and Out regs are fetched directly, as well as the control
registers. If we're getting one of the in or local regs,
and the stack pointer has not yet been fetched,
we have to do that first, since they're found in memory relative
to the stack pointer. */
if (regno < O7_REGNUM /* including -1 */
|| regno >= Y_REGNUM
|| (!register_valid[SP_REGNUM] && regno < I7_REGNUM))
{
if (0 != ptrace (PTRACE_GETREGS, inferior_pid,
(PTRACE_ARG3_TYPE) &inferior_registers, 0))
perror("ptrace_getregs");
registers[REGISTER_BYTE (0)] = 0;
memcpy (&registers[REGISTER_BYTE (1)], &inferior_registers.r_g1,
15 * REGISTER_RAW_SIZE (G0_REGNUM));
*(int *)&registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
*(int *)&registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
*(int *)&registers[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc;
*(int *)&registers[REGISTER_BYTE (Y_REGNUM)] = inferior_registers.r_y;
for (i = G0_REGNUM; i <= O7_REGNUM; i++)
register_valid[i] = 1;
register_valid[Y_REGNUM] = 1;
register_valid[PS_REGNUM] = 1;
register_valid[PC_REGNUM] = 1;
register_valid[NPC_REGNUM] = 1;
/* If we don't set these valid, read_register_bytes() rereads
all the regs every time it is called! FIXME. */
register_valid[WIM_REGNUM] = 1; /* Not true yet, FIXME */
register_valid[TBR_REGNUM] = 1; /* Not true yet, FIXME */
register_valid[CPS_REGNUM] = 1; /* Not true yet, FIXME */
}
/* Floating point registers */
if (regno == -1 ||
regno == FPS_REGNUM ||
(regno >= FP0_REGNUM && regno <= FP0_REGNUM + 31))
{
if (0 != ptrace (PTRACE_GETFPREGS, inferior_pid,
(PTRACE_ARG3_TYPE) &inferior_fp_registers,
0))
perror("ptrace_getfpregs");
memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
sizeof inferior_fp_registers.fpu_fr);
memcpy (&registers[REGISTER_BYTE (FPS_REGNUM)],
1993-09-01 20:37:15 +00:00
&inferior_fp_registers.Fpu_fsr,
sizeof (FPU_FSR_TYPE));
for (i = FP0_REGNUM; i <= FP0_REGNUM+31; i++)
register_valid[i] = 1;
register_valid[FPS_REGNUM] = 1;
}
/* These regs are saved on the stack by the kernel. Only read them
all (16 ptrace calls!) if we really need them. */
if (regno == -1)
{
* Makefile.in configure configure.in: Remove ENABLE_CLIBS, ENABLE_OBS, and THREAD_DB_OBS. These are consolidated into LIBS and CONFIG_OBS. * configure configure.in: Clean up test cases around thread support. start-sanitize-v850 * configure.tgt (v850-*-*): Include v850ice.o and v850.lib if host is Windows. end-sanitize-v850 * c-valprint.c ch-valprint.c cp-valprint.c eval.c expprint.c printcmd.c valops.c value.h values.c: Add bfd_section arg to value_at and value_at_lazy. * coffread.c dbxread.c elfread.c mdebugread.c minsyms.c symtab.h: Add bfd_section arg to prim_record_minimal_symbol_and_info. * corefile.c gdbcore.h printcmd.c valops.c: Use read_memory_section instead of read_memory. It takes a bfd_section arg. * coffread.c dbxread.c elfread.c gdb-stabs.h objfiles.h: Remove unnecessary cast for assignment of struct dbx_symfile_info. Struct objfile now uses a real pointer instead of PTR for this element. * dbxread.c (dbx_symfile_init): Stash bfd section pointers for text, data and bss into dbx_symfile_info. * exec.c (xfer_memory): Handle transfers for user-specified sections. * findvar.c (read_var_value locate_var_value): Copy bfd section from the symbol to the value. * gdb-stabs.h: Add section pointers for text, data and bss sections. * maint.c (translate address command): Add test code for overlay address translation. * printcmd.c (do_examine do_one_display): Now takes a bfd section arg. * (print_formatted x_command): Record current section along with current address for repeated commands. * sparc-nat.c (fetch_inferior_registers): Change target_xfer_memory to target_{read write}_memory to allow changes to target_xfer_memory interface for section info. * symmisc.c (dump_msymbols print_symbol): Print section assocaited with symbol. * symtab.c (fixup_symbol_section): New routine to add section info to symbols returned by lookup_symbol. * symtab.h (struct general_symbol_info): Add bfd section to symbols. * target.c target.h (target_xfer_memory): Add bfd section to args. * (target_read_memory_section): New routine to read data from a specific section. * (target_memory_bfd_section): New global variable to pass bfd section in to targets. * valarith.c (value_add value_addr value_array): Preserve bfd section when computing new value. * value.h (struct value): Add bfd section to values. * values.c (allocate_value value_copy): Initialize/preserve bfd section. * (unpack_double): Clean up _MSC_VER conditionals to remove duplicate code. start-sanitize-v850 * v850ice.c: New module to support communication with NEC's PC-based ICE. * config/v850/tm-v850.h (REGISTER_NAMES): Replace sp, gp, fp, and ep names with rxx names. sp and fp are renamed via a different mechanism. end-sanitize-v850
1997-01-04 00:33:01 +00:00
target_read_memory (*(CORE_ADDR*)&registers[REGISTER_BYTE (SP_REGNUM)],
&registers[REGISTER_BYTE (L0_REGNUM)],
* Makefile.in configure configure.in: Remove ENABLE_CLIBS, ENABLE_OBS, and THREAD_DB_OBS. These are consolidated into LIBS and CONFIG_OBS. * configure configure.in: Clean up test cases around thread support. start-sanitize-v850 * configure.tgt (v850-*-*): Include v850ice.o and v850.lib if host is Windows. end-sanitize-v850 * c-valprint.c ch-valprint.c cp-valprint.c eval.c expprint.c printcmd.c valops.c value.h values.c: Add bfd_section arg to value_at and value_at_lazy. * coffread.c dbxread.c elfread.c mdebugread.c minsyms.c symtab.h: Add bfd_section arg to prim_record_minimal_symbol_and_info. * corefile.c gdbcore.h printcmd.c valops.c: Use read_memory_section instead of read_memory. It takes a bfd_section arg. * coffread.c dbxread.c elfread.c gdb-stabs.h objfiles.h: Remove unnecessary cast for assignment of struct dbx_symfile_info. Struct objfile now uses a real pointer instead of PTR for this element. * dbxread.c (dbx_symfile_init): Stash bfd section pointers for text, data and bss into dbx_symfile_info. * exec.c (xfer_memory): Handle transfers for user-specified sections. * findvar.c (read_var_value locate_var_value): Copy bfd section from the symbol to the value. * gdb-stabs.h: Add section pointers for text, data and bss sections. * maint.c (translate address command): Add test code for overlay address translation. * printcmd.c (do_examine do_one_display): Now takes a bfd section arg. * (print_formatted x_command): Record current section along with current address for repeated commands. * sparc-nat.c (fetch_inferior_registers): Change target_xfer_memory to target_{read write}_memory to allow changes to target_xfer_memory interface for section info. * symmisc.c (dump_msymbols print_symbol): Print section assocaited with symbol. * symtab.c (fixup_symbol_section): New routine to add section info to symbols returned by lookup_symbol. * symtab.h (struct general_symbol_info): Add bfd section to symbols. * target.c target.h (target_xfer_memory): Add bfd section to args. * (target_read_memory_section): New routine to read data from a specific section. * (target_memory_bfd_section): New global variable to pass bfd section in to targets. * valarith.c (value_add value_addr value_array): Preserve bfd section when computing new value. * value.h (struct value): Add bfd section to values. * values.c (allocate_value value_copy): Initialize/preserve bfd section. * (unpack_double): Clean up _MSC_VER conditionals to remove duplicate code. start-sanitize-v850 * v850ice.c: New module to support communication with NEC's PC-based ICE. * config/v850/tm-v850.h (REGISTER_NAMES): Replace sp, gp, fp, and ep names with rxx names. sp and fp are renamed via a different mechanism. end-sanitize-v850
1997-01-04 00:33:01 +00:00
16*REGISTER_RAW_SIZE (L0_REGNUM));
for (i = L0_REGNUM; i <= I7_REGNUM; i++)
register_valid[i] = 1;
}
else if (regno >= L0_REGNUM && regno <= I7_REGNUM)
{
CORE_ADDR sp = *(CORE_ADDR*)&registers[REGISTER_BYTE (SP_REGNUM)];
i = REGISTER_BYTE (regno);
if (register_valid[regno])
printf_unfiltered("register %d valid and read\n", regno);
* Makefile.in configure configure.in: Remove ENABLE_CLIBS, ENABLE_OBS, and THREAD_DB_OBS. These are consolidated into LIBS and CONFIG_OBS. * configure configure.in: Clean up test cases around thread support. start-sanitize-v850 * configure.tgt (v850-*-*): Include v850ice.o and v850.lib if host is Windows. end-sanitize-v850 * c-valprint.c ch-valprint.c cp-valprint.c eval.c expprint.c printcmd.c valops.c value.h values.c: Add bfd_section arg to value_at and value_at_lazy. * coffread.c dbxread.c elfread.c mdebugread.c minsyms.c symtab.h: Add bfd_section arg to prim_record_minimal_symbol_and_info. * corefile.c gdbcore.h printcmd.c valops.c: Use read_memory_section instead of read_memory. It takes a bfd_section arg. * coffread.c dbxread.c elfread.c gdb-stabs.h objfiles.h: Remove unnecessary cast for assignment of struct dbx_symfile_info. Struct objfile now uses a real pointer instead of PTR for this element. * dbxread.c (dbx_symfile_init): Stash bfd section pointers for text, data and bss into dbx_symfile_info. * exec.c (xfer_memory): Handle transfers for user-specified sections. * findvar.c (read_var_value locate_var_value): Copy bfd section from the symbol to the value. * gdb-stabs.h: Add section pointers for text, data and bss sections. * maint.c (translate address command): Add test code for overlay address translation. * printcmd.c (do_examine do_one_display): Now takes a bfd section arg. * (print_formatted x_command): Record current section along with current address for repeated commands. * sparc-nat.c (fetch_inferior_registers): Change target_xfer_memory to target_{read write}_memory to allow changes to target_xfer_memory interface for section info. * symmisc.c (dump_msymbols print_symbol): Print section assocaited with symbol. * symtab.c (fixup_symbol_section): New routine to add section info to symbols returned by lookup_symbol. * symtab.h (struct general_symbol_info): Add bfd section to symbols. * target.c target.h (target_xfer_memory): Add bfd section to args. * (target_read_memory_section): New routine to read data from a specific section. * (target_memory_bfd_section): New global variable to pass bfd section in to targets. * valarith.c (value_add value_addr value_array): Preserve bfd section when computing new value. * value.h (struct value): Add bfd section to values. * values.c (allocate_value value_copy): Initialize/preserve bfd section. * (unpack_double): Clean up _MSC_VER conditionals to remove duplicate code. start-sanitize-v850 * v850ice.c: New module to support communication with NEC's PC-based ICE. * config/v850/tm-v850.h (REGISTER_NAMES): Replace sp, gp, fp, and ep names with rxx names. sp and fp are renamed via a different mechanism. end-sanitize-v850
1997-01-04 00:33:01 +00:00
target_read_memory (sp + i - REGISTER_BYTE (L0_REGNUM),
&registers[i], REGISTER_RAW_SIZE (regno));
register_valid[regno] = 1;
}
}
/* 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). */
void
store_inferior_registers (regno)
int regno;
{
struct regs inferior_registers;
struct fp_status inferior_fp_registers;
int wanna_store = INT_REGS + STACK_REGS + FP_REGS;
/* First decide which pieces of machine-state we need to modify.
Default for regno == -1 case is all pieces. */
if (regno >= 0)
if (FP0_REGNUM <= regno && regno < FP0_REGNUM + 32)
{
wanna_store = FP_REGS;
}
else
{
if (regno == SP_REGNUM)
wanna_store = INT_REGS + STACK_REGS;
else if (regno < L0_REGNUM || regno > I7_REGNUM)
wanna_store = INT_REGS;
else if (regno == FPS_REGNUM)
wanna_store = FP_REGS;
else
wanna_store = STACK_REGS;
}
/* See if we're forcing the stores to happen now, or deferring. */
if (regno == -2)
{
wanna_store = deferred_stores;
deferred_stores = 0;
}
else
{
if (wanna_store == STACK_REGS)
{
/* Fall through and just store one stack reg. If we deferred
it, we'd have to store them all, or remember more info. */
}
else
{
deferred_stores |= wanna_store;
return;
}
}
if (wanna_store & STACK_REGS)
{
CORE_ADDR sp = *(CORE_ADDR *)&registers[REGISTER_BYTE (SP_REGNUM)];
if (regno < 0 || regno == SP_REGNUM)
{
if (!register_valid[L0_REGNUM+5]) abort();
* Makefile.in configure configure.in: Remove ENABLE_CLIBS, ENABLE_OBS, and THREAD_DB_OBS. These are consolidated into LIBS and CONFIG_OBS. * configure configure.in: Clean up test cases around thread support. start-sanitize-v850 * configure.tgt (v850-*-*): Include v850ice.o and v850.lib if host is Windows. end-sanitize-v850 * c-valprint.c ch-valprint.c cp-valprint.c eval.c expprint.c printcmd.c valops.c value.h values.c: Add bfd_section arg to value_at and value_at_lazy. * coffread.c dbxread.c elfread.c mdebugread.c minsyms.c symtab.h: Add bfd_section arg to prim_record_minimal_symbol_and_info. * corefile.c gdbcore.h printcmd.c valops.c: Use read_memory_section instead of read_memory. It takes a bfd_section arg. * coffread.c dbxread.c elfread.c gdb-stabs.h objfiles.h: Remove unnecessary cast for assignment of struct dbx_symfile_info. Struct objfile now uses a real pointer instead of PTR for this element. * dbxread.c (dbx_symfile_init): Stash bfd section pointers for text, data and bss into dbx_symfile_info. * exec.c (xfer_memory): Handle transfers for user-specified sections. * findvar.c (read_var_value locate_var_value): Copy bfd section from the symbol to the value. * gdb-stabs.h: Add section pointers for text, data and bss sections. * maint.c (translate address command): Add test code for overlay address translation. * printcmd.c (do_examine do_one_display): Now takes a bfd section arg. * (print_formatted x_command): Record current section along with current address for repeated commands. * sparc-nat.c (fetch_inferior_registers): Change target_xfer_memory to target_{read write}_memory to allow changes to target_xfer_memory interface for section info. * symmisc.c (dump_msymbols print_symbol): Print section assocaited with symbol. * symtab.c (fixup_symbol_section): New routine to add section info to symbols returned by lookup_symbol. * symtab.h (struct general_symbol_info): Add bfd section to symbols. * target.c target.h (target_xfer_memory): Add bfd section to args. * (target_read_memory_section): New routine to read data from a specific section. * (target_memory_bfd_section): New global variable to pass bfd section in to targets. * valarith.c (value_add value_addr value_array): Preserve bfd section when computing new value. * value.h (struct value): Add bfd section to values. * values.c (allocate_value value_copy): Initialize/preserve bfd section. * (unpack_double): Clean up _MSC_VER conditionals to remove duplicate code. start-sanitize-v850 * v850ice.c: New module to support communication with NEC's PC-based ICE. * config/v850/tm-v850.h (REGISTER_NAMES): Replace sp, gp, fp, and ep names with rxx names. sp and fp are renamed via a different mechanism. end-sanitize-v850
1997-01-04 00:33:01 +00:00
target_write_memory (sp,
&registers[REGISTER_BYTE (L0_REGNUM)],
16*REGISTER_RAW_SIZE (L0_REGNUM));
}
else
{
if (!register_valid[regno]) abort();
* Makefile.in configure configure.in: Remove ENABLE_CLIBS, ENABLE_OBS, and THREAD_DB_OBS. These are consolidated into LIBS and CONFIG_OBS. * configure configure.in: Clean up test cases around thread support. start-sanitize-v850 * configure.tgt (v850-*-*): Include v850ice.o and v850.lib if host is Windows. end-sanitize-v850 * c-valprint.c ch-valprint.c cp-valprint.c eval.c expprint.c printcmd.c valops.c value.h values.c: Add bfd_section arg to value_at and value_at_lazy. * coffread.c dbxread.c elfread.c mdebugread.c minsyms.c symtab.h: Add bfd_section arg to prim_record_minimal_symbol_and_info. * corefile.c gdbcore.h printcmd.c valops.c: Use read_memory_section instead of read_memory. It takes a bfd_section arg. * coffread.c dbxread.c elfread.c gdb-stabs.h objfiles.h: Remove unnecessary cast for assignment of struct dbx_symfile_info. Struct objfile now uses a real pointer instead of PTR for this element. * dbxread.c (dbx_symfile_init): Stash bfd section pointers for text, data and bss into dbx_symfile_info. * exec.c (xfer_memory): Handle transfers for user-specified sections. * findvar.c (read_var_value locate_var_value): Copy bfd section from the symbol to the value. * gdb-stabs.h: Add section pointers for text, data and bss sections. * maint.c (translate address command): Add test code for overlay address translation. * printcmd.c (do_examine do_one_display): Now takes a bfd section arg. * (print_formatted x_command): Record current section along with current address for repeated commands. * sparc-nat.c (fetch_inferior_registers): Change target_xfer_memory to target_{read write}_memory to allow changes to target_xfer_memory interface for section info. * symmisc.c (dump_msymbols print_symbol): Print section assocaited with symbol. * symtab.c (fixup_symbol_section): New routine to add section info to symbols returned by lookup_symbol. * symtab.h (struct general_symbol_info): Add bfd section to symbols. * target.c target.h (target_xfer_memory): Add bfd section to args. * (target_read_memory_section): New routine to read data from a specific section. * (target_memory_bfd_section): New global variable to pass bfd section in to targets. * valarith.c (value_add value_addr value_array): Preserve bfd section when computing new value. * value.h (struct value): Add bfd section to values. * values.c (allocate_value value_copy): Initialize/preserve bfd section. * (unpack_double): Clean up _MSC_VER conditionals to remove duplicate code. start-sanitize-v850 * v850ice.c: New module to support communication with NEC's PC-based ICE. * config/v850/tm-v850.h (REGISTER_NAMES): Replace sp, gp, fp, and ep names with rxx names. sp and fp are renamed via a different mechanism. end-sanitize-v850
1997-01-04 00:33:01 +00:00
target_write_memory (sp + REGISTER_BYTE (regno) - REGISTER_BYTE (L0_REGNUM),
&registers[REGISTER_BYTE (regno)],
REGISTER_RAW_SIZE (regno));
}
}
if (wanna_store & INT_REGS)
{
if (!register_valid[G1_REGNUM]) abort();
memcpy (&inferior_registers.r_g1, &registers[REGISTER_BYTE (G1_REGNUM)],
15 * REGISTER_RAW_SIZE (G1_REGNUM));
inferior_registers.r_ps =
*(int *)&registers[REGISTER_BYTE (PS_REGNUM)];
inferior_registers.r_pc =
*(int *)&registers[REGISTER_BYTE (PC_REGNUM)];
inferior_registers.r_npc =
*(int *)&registers[REGISTER_BYTE (NPC_REGNUM)];
inferior_registers.r_y =
*(int *)&registers[REGISTER_BYTE (Y_REGNUM)];
if (0 != ptrace (PTRACE_SETREGS, inferior_pid,
(PTRACE_ARG3_TYPE) &inferior_registers, 0))
perror("ptrace_setregs");
}
if (wanna_store & FP_REGS)
{
if (!register_valid[FP0_REGNUM+9]) abort();
memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
sizeof inferior_fp_registers.fpu_fr);
memcpy (&inferior_fp_registers.Fpu_fsr,
&registers[REGISTER_BYTE (FPS_REGNUM)], sizeof (FPU_FSR_TYPE));
if (0 !=
ptrace (PTRACE_SETFPREGS, inferior_pid,
(PTRACE_ARG3_TYPE) &inferior_fp_registers, 0))
perror("ptrace_setfpregs");
}
}
* coredep.c: Renamed to core-aout.c * core-svr4.c: Renamed to core-regset.c * Makefile.in (ALLDEPFILES): Account for renamings. * corelow.c (core_file_fns): Add, points to chain of structs. (add_core_fns): New function to build chain of structs. (get_core_registers): Modify to search core functions chain and call appropriate fetch_core_registers function based on core file flavour. * gdbcore.h (fetch_core_registers): Remove declaration. (struct core_fns): Define struct for core function info. * i386m3-nat.c: Update comment for filename change (coredep->core-aout) * a68v-nat.c (fetch_core_registers): Remove stub, not needed now. * alpha-nat.c (fetch_core_registers): Make static. (alpha_core_fns, _initialize_core_alpha): New struct and func. * core-aout.c (fetch_core_registers): Make static (aout_core_fns, _initialize_core_aout): New struct and func. * core-regset.c (fetch_core_registers): Make static. (regset_core_fns, _initialize_core_regset): New struct and func. * core-sol2.c (fetch_core_registers): Make static. (solaris_core_fns, _initialize_core_solaris): New struct and func. * hp300ux-nat.c (fetch_core_registers): Make static. (hp300ux_core_fns, _initialize_core_hp300ux): New struct and func. * i386aix-nat.c (fetch_core_registers): Make static. (i386aix_core_fns, _initialize_core_i386aix): New struct and func. * i386mach-nat.c (fetch_core_registers: Make static. (i386mach_core_fns, _initialize_core_i386mach): New struct and func. * irix4-nat.c (fetch_core_registers): Make static. (irix4_core_fns, _initialize_core_irix4): New struct and func. * irix5-nat.c (fetch_core_registers): (irix5_core_fns, _initialize_core_irix5): New struct and func. * lynx-nat.c (fetch_core_registers): Make static. (lynx_core_fns, _initialize_core_lynx): New struct and func. * mips-nat.c (fetch_core_registers): Make static. (mips_core_fns, _initialize_core_mips): New struct and func. * ns32km3-nat.c (fetch_core_registers): Remove stub. * rs6000-nat.c (fetch_core_registers): Make static. (rs6000_core_fns, _initialize_core_rs6000): New struct and func. * sparc-nat.c (fetch_core_registers): Make static. (sparc_core_fns, _initialize_core_sparc): New struct and func. * sun3-nat.c (fetch_core_registers): (sun3_core_fns, _initialize_core_sun3): New struct and func. * sun386-nat.c (fetch_core_registers): Remove stub. * ultra3-nat.c (fetch_core_registers): Make static. (ultra3_core_fns, _initialize_core_ultra3): New struct and func. * config/gould/pn.mh (XDEPFILES), config/i386/fbsd.mh (NATDEPFILES), config/i386/i386bsd.mh (NATDEPFILES), config/i386/i386m3.mh (XDEPFILES), config/i386/i386sco.mh (NATDEPFILES), config/i386/i386sco4.mh (NATDEPFILES), config/i386/i386v.mh (NATDEPFILES), config/i386/i386v32.mh (NATDEPFILES), config/i386/nbsd.mh (NATDEPFILES), config/i386/ptx.mh (XDEPFILES), config/i386/ptx4.mh (XDEPFILES), config/i386/symmetry.mh (NATDEPFILES), config/m68k/3b1.mh (XDEPFILES), config/m68k/cisco.mt (TDEPFILES), config/m68k/delta68.mh (NATDEPFILES), config/m68k/dpx2.mh (NATDEPFILES), config/m68k/hp300bsd.mh (NATDEPFILES), config/m68k/hp300hpux.mh (NATDEPFILES), config/m68k/isi.mh (XDEPFILES), config/m68k/news.mh (NATDEPFILES), config/m68k/news1000.mh (XDEPFILES), config/m88k/cxux.mh (NATDEPFILES), config/m88k/delta88.mh (NATDEPFILES), config/mips/littlemips.mh (XDEPFILES), config/mips/mipsm3.mh (XDEPFILES), config/ns32k/merlin.mh (XDEPFILES), config/ns32k/nbsd.mh (NATDEPFILES), config/ns32k/ns32km3.mh (NATDEPFILES), config/pa/hppabsd.mh (NATDEPFILES), config/pa/hppahpux.mh (NATDEPFILES), config/romp/rtbsd.mh (XDEPFILES), config/tahoe/tahoe.mh (XDEPFILES), config/vax/vaxbsd.mh (XDEPFILES), config/vax/vaxult.mh (NATDEPFILES), config/vax/vaxult2.mh (NATDEPFILES), Account for coredep.o to core-aout.o name change. * config/i386/i386dgux (NATDEPFILES), config/i386/i386sol2.mh (NATDEPFILES), config/i386/i386v4.mh (NATDEPFILES), config/i386/linux.mh (NATDEPFILES), config/i386/ncr3000.mh (NATDEPFILES), config/m68k/m68kv4.mh (NATDEPFILES), config/m88k/delta88v4.mh (NATDEPFILES), config/mips/mipsv4.mh (NATDEPFILES), Account for core-svr4.o to core-regset.o name change.
1996-01-11 20:08:15 +00:00
static void
fetch_core_registers (core_reg_sect, core_reg_size, which, ignore)
char *core_reg_sect;
unsigned core_reg_size;
int which;
CORE_ADDR ignore; /* reg addr, unused in this version */
{
if (which == 0) {
/* Integer registers */
#define gregs ((struct regs *)core_reg_sect)
/* G0 *always* holds 0. */
*(int *)&registers[REGISTER_BYTE (0)] = 0;
/* The globals and output registers. */
memcpy (&registers[REGISTER_BYTE (G1_REGNUM)], &gregs->r_g1,
15 * REGISTER_RAW_SIZE (G1_REGNUM));
*(int *)&registers[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps;
*(int *)&registers[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc;
*(int *)&registers[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc;
*(int *)&registers[REGISTER_BYTE (Y_REGNUM)] = gregs->r_y;
/* My best guess at where to get the locals and input
registers is exactly where they usually are, right above
the stack pointer. If the core dump was caused by a bus error
from blowing away the stack pointer (as is possible) then this
won't work, but it's worth the try. */
{
int sp;
sp = *(int *)&registers[REGISTER_BYTE (SP_REGNUM)];
if (0 != target_read_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)],
16 * REGISTER_RAW_SIZE (L0_REGNUM)))
{
/* fprintf_unfiltered so user can still use gdb */
fprintf_unfiltered (gdb_stderr,
"Couldn't read input and local registers from core file\n");
}
}
} else if (which == 2) {
/* Floating point registers */
#define fpuregs ((struct fpu *) core_reg_sect)
if (core_reg_size >= sizeof (struct fpu))
{
memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], fpuregs->fpu_regs,
sizeof (fpuregs->fpu_regs));
memcpy (&registers[REGISTER_BYTE (FPS_REGNUM)], &fpuregs->fpu_fsr,
sizeof (FPU_FSR_TYPE));
}
else
fprintf_unfiltered (gdb_stderr, "Couldn't read float regs from core file\n");
}
}
int
kernel_u_size ()
{
return (sizeof (struct user));
}
* coredep.c: Renamed to core-aout.c * core-svr4.c: Renamed to core-regset.c * Makefile.in (ALLDEPFILES): Account for renamings. * corelow.c (core_file_fns): Add, points to chain of structs. (add_core_fns): New function to build chain of structs. (get_core_registers): Modify to search core functions chain and call appropriate fetch_core_registers function based on core file flavour. * gdbcore.h (fetch_core_registers): Remove declaration. (struct core_fns): Define struct for core function info. * i386m3-nat.c: Update comment for filename change (coredep->core-aout) * a68v-nat.c (fetch_core_registers): Remove stub, not needed now. * alpha-nat.c (fetch_core_registers): Make static. (alpha_core_fns, _initialize_core_alpha): New struct and func. * core-aout.c (fetch_core_registers): Make static (aout_core_fns, _initialize_core_aout): New struct and func. * core-regset.c (fetch_core_registers): Make static. (regset_core_fns, _initialize_core_regset): New struct and func. * core-sol2.c (fetch_core_registers): Make static. (solaris_core_fns, _initialize_core_solaris): New struct and func. * hp300ux-nat.c (fetch_core_registers): Make static. (hp300ux_core_fns, _initialize_core_hp300ux): New struct and func. * i386aix-nat.c (fetch_core_registers): Make static. (i386aix_core_fns, _initialize_core_i386aix): New struct and func. * i386mach-nat.c (fetch_core_registers: Make static. (i386mach_core_fns, _initialize_core_i386mach): New struct and func. * irix4-nat.c (fetch_core_registers): Make static. (irix4_core_fns, _initialize_core_irix4): New struct and func. * irix5-nat.c (fetch_core_registers): (irix5_core_fns, _initialize_core_irix5): New struct and func. * lynx-nat.c (fetch_core_registers): Make static. (lynx_core_fns, _initialize_core_lynx): New struct and func. * mips-nat.c (fetch_core_registers): Make static. (mips_core_fns, _initialize_core_mips): New struct and func. * ns32km3-nat.c (fetch_core_registers): Remove stub. * rs6000-nat.c (fetch_core_registers): Make static. (rs6000_core_fns, _initialize_core_rs6000): New struct and func. * sparc-nat.c (fetch_core_registers): Make static. (sparc_core_fns, _initialize_core_sparc): New struct and func. * sun3-nat.c (fetch_core_registers): (sun3_core_fns, _initialize_core_sun3): New struct and func. * sun386-nat.c (fetch_core_registers): Remove stub. * ultra3-nat.c (fetch_core_registers): Make static. (ultra3_core_fns, _initialize_core_ultra3): New struct and func. * config/gould/pn.mh (XDEPFILES), config/i386/fbsd.mh (NATDEPFILES), config/i386/i386bsd.mh (NATDEPFILES), config/i386/i386m3.mh (XDEPFILES), config/i386/i386sco.mh (NATDEPFILES), config/i386/i386sco4.mh (NATDEPFILES), config/i386/i386v.mh (NATDEPFILES), config/i386/i386v32.mh (NATDEPFILES), config/i386/nbsd.mh (NATDEPFILES), config/i386/ptx.mh (XDEPFILES), config/i386/ptx4.mh (XDEPFILES), config/i386/symmetry.mh (NATDEPFILES), config/m68k/3b1.mh (XDEPFILES), config/m68k/cisco.mt (TDEPFILES), config/m68k/delta68.mh (NATDEPFILES), config/m68k/dpx2.mh (NATDEPFILES), config/m68k/hp300bsd.mh (NATDEPFILES), config/m68k/hp300hpux.mh (NATDEPFILES), config/m68k/isi.mh (XDEPFILES), config/m68k/news.mh (NATDEPFILES), config/m68k/news1000.mh (XDEPFILES), config/m88k/cxux.mh (NATDEPFILES), config/m88k/delta88.mh (NATDEPFILES), config/mips/littlemips.mh (XDEPFILES), config/mips/mipsm3.mh (XDEPFILES), config/ns32k/merlin.mh (XDEPFILES), config/ns32k/nbsd.mh (NATDEPFILES), config/ns32k/ns32km3.mh (NATDEPFILES), config/pa/hppabsd.mh (NATDEPFILES), config/pa/hppahpux.mh (NATDEPFILES), config/romp/rtbsd.mh (XDEPFILES), config/tahoe/tahoe.mh (XDEPFILES), config/vax/vaxbsd.mh (XDEPFILES), config/vax/vaxult.mh (NATDEPFILES), config/vax/vaxult2.mh (NATDEPFILES), Account for coredep.o to core-aout.o name change. * config/i386/i386dgux (NATDEPFILES), config/i386/i386sol2.mh (NATDEPFILES), config/i386/i386v4.mh (NATDEPFILES), config/i386/linux.mh (NATDEPFILES), config/i386/ncr3000.mh (NATDEPFILES), config/m68k/m68kv4.mh (NATDEPFILES), config/m88k/delta88v4.mh (NATDEPFILES), config/mips/mipsv4.mh (NATDEPFILES), Account for core-svr4.o to core-regset.o name change.
1996-01-11 20:08:15 +00:00
/* Register that we are able to handle sparc core file formats.
FIXME: is this really bfd_target_unknown_flavour? */
static struct core_fns sparc_core_fns =
{
bfd_target_unknown_flavour,
fetch_core_registers,
NULL
};
void
_initialize_core_sparc ()
{
add_core_fns (&sparc_core_fns);
}