home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
gnu
/
gdb-4.12-src.lha
/
GNU
/
src
/
amiga
/
gdb-4.12
/
gdb
/
irix5-nat.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-03
|
29KB
|
1,073 lines
/* Native support for the SGI Iris running IRIX version 5, for GDB.
Copyright 1988, 1989, 1990, 1991, 1992, 1993 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.
Modified for Irix 5.x by Ian Lance Taylor.
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 "gdbcore.h"
#include "target.h"
#include <sys/time.h>
#include <sys/procfs.h>
#include <setjmp.h> /* For JB_XXX. */
/* Size of elements in jmpbuf */
#define JB_ELEMENT_SIZE 4
/*
* See the comment in m68k-tdep.c regarding the utility of these functions.
*
* These definitions are from the MIPS SVR4 ABI, so they may work for
* any MIPS SVR4 target.
*/
void
supply_gregset (gregsetp)
gregset_t *gregsetp;
{
register int regi;
register greg_t *regp = &(*gregsetp)[0];
for(regi = 0; regi <= CTX_RA; regi++)
supply_register (regi, (char *)(regp + regi));
supply_register (PC_REGNUM, (char *)(regp + CTX_EPC));
supply_register (HI_REGNUM, (char *)(regp + CTX_MDHI));
supply_register (LO_REGNUM, (char *)(regp + CTX_MDLO));
supply_register (CAUSE_REGNUM, (char *)(regp + CTX_CAUSE));
}
void
fill_gregset (gregsetp, regno)
gregset_t *gregsetp;
int regno;
{
int regi;
register greg_t *regp = &(*gregsetp)[0];
for (regi = 0; regi <= CTX_RA; regi++)
if ((regno == -1) || (regno == regi))
*(regp + regi) = *(greg_t *) ®isters[REGISTER_BYTE (regi)];
if ((regno == -1) || (regno == PC_REGNUM))
*(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)];
if ((regno == -1) || (regno == HI_REGNUM))
*(regp + CTX_MDHI) = *(greg_t *) ®isters[REGISTER_BYTE (HI_REGNUM)];
if ((regno == -1) || (regno == LO_REGNUM))
*(regp + CTX_MDLO) = *(greg_t *) ®isters[REGISTER_BYTE (LO_REGNUM)];
}
/*
* Now we do the same thing for floating-point registers.
* We don't bother to condition on FP0_REGNUM since any
* reasonable MIPS configuration has an R3010 in it.
*
* Again, see the comments in m68k-tdep.c.
*/
void
supply_fpregset (fpregsetp)
fpregset_t *fpregsetp;
{
register int regi;
for (regi = 0; regi < 32; regi++)
supply_register (FP0_REGNUM + regi,
(char *)&fpregsetp->fp_r.fp_regs[regi]);
supply_register (FCRCS_REGNUM, (char *)&fpregsetp->fp_csr);
/* FIXME: how can we supply FCRIR_REGNUM? SGI doesn't tell us. */
}
void
fill_fpregset (fpregsetp, regno)
fpregset_t *fpregsetp;
int regno;
{
int regi;
char *from, *to;
for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++)
{
if ((regno == -1) || (regno == regi))
{
from = (char *) ®isters[REGISTER_BYTE (regi)];
to = (char *) &(fpregsetp->fp_r.fp_regs[regi - FP0_REGNUM]);
memcpy(to, from, REGISTER_RAW_SIZE (regi));
}
}
if ((regno == -1) || (regno == FCRCS_REGNUM))
fpregsetp->fp_csr = *(unsigned *) ®isters[REGISTER_BYTE(FCRCS_REGNUM)];
}
/* Figure out where the longjmp will land.
We expect the first arg to be a pointer to the jmp_buf structure from which
we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
This routine returns true on success. */
int
get_longjmp_target (pc)
CORE_ADDR *pc;
{
char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT];
CORE_ADDR jb_addr;
jb_addr = read_register (A0_REGNUM);
if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, buf,
TARGET_PTR_BIT / TARGET_CHAR_BIT))
return 0;
*pc = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
return 1;
}
void
fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
char *core_reg_sect;
unsigned core_reg_size;
int which; /* Unused */
unsigned int reg_addr; /* Unused */
{
if (core_reg_size != REGISTER_BYTES)
{
warning ("wrong size gregset struct in core file");
return;
}
memcpy ((char *)registers, core_reg_sect, core_reg_size);
}
/* Irix 5 uses what appears to be a unique form of shared library
support. This is a copy of solib.c modified for Irix 5. */
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <sys/param.h>
#include <fcntl.h>
/* <obj.h> includes <sym.h> and <symconst.h>, which causes conflicts
with our versions of those files included by tm-mips.h. Prevent
<obj.h> from including them with some appropriate defines. */
#define __SYM_H__
#define __SYMCONST_H__
#include <obj.h>
#include "symtab.h"
#include "bfd.h"
#include "symfile.h"
#include "objfiles.h"
#include "command.h"
#include "frame.h"
#include "regex.h"
#include "inferior.h"
#include "language.h"
/* We need to set a breakpoint at a point when we know that the
mapping of shared libraries is complete. dbx simply breaks at main
(or, for FORTRAN, MAIN__), so we do the same. We can not break at
the very beginning of main, because the startup code will jump into
main after the GP initialization instructions. SOLIB_BKPT_OFFSET
is used to skip those instructions. */
#define SOLIB_BKPT_OFFSET 12
static char *bkpt_names[] = {
"main",
"MAIN__",
NULL
};
/* The symbol which starts off the list of shared libraries. */
#define DEBUG_BASE "__rld_obj_head"
/* How to get the loaded address of a shared library. */
#define LM_ADDR(so) ((so)->lm.o_base_address)
char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
extern CORE_ADDR sigtramp_address, sigtramp_end;
struct so_list {
struct so_list *next; /* next structure in linked list */
struct obj_list ll;
struct obj lm; /* copy of link map from inferior */
struct obj_list *lladdr; /* addr in inferior lm was read from */
CORE_ADDR lmend; /* upper addr bound of mapped object */
char symbols_loaded; /* flag: symbols read in yet? */
char from_tty; /* flag: print msgs? */
struct objfile *objfile; /* objfile for loaded lib */
struct section_table *sections;
struct section_table *sections_end;
struct section_table *textsection;
bfd *abfd;
};
static struct so_list *so_list_head; /* List of known shared objects */
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
/* Local function prototypes */
static void
sharedlibrary_command PARAMS ((char *, int));
static int
enable_break PARAMS ((void));
static int
disable_break PARAMS ((void));
static void
info_sharedlibrary_command PARAMS ((char *, int));
static int
symbol_add_stub PARAMS ((char *));
static struct so_list *
find_solib PARAMS ((struct so_list *));
static struct obj_list *
first_link_map_member PARAMS ((void));
static CORE_ADDR
locate_base PARAMS ((void));
static void
solib_map_sections PARAMS ((struct so_list *));
/*
LOCAL FUNCTION
solib_map_sections -- open bfd and build sections for shared lib
SYNOPSIS
static void solib_map_sections (struct so_list *so)
DESCRIPTION
Given a pointer to one of the shared objects in our list
of mapped objects, use the recorded name to open a bfd
descriptor for the object, build a section table, and then
relocate all the section addresses by the base address at
which the shared object was mapped.
FIXMES
In most (all?) cases the shared object file name recorded in the
dynamic linkage tables will be a fully qualified pathname. For
cases where it i