1999-04-16 03:35:26 +02:00
|
|
|
|
/* Interface to bare machine for GDB running as kernel debugger.
|
2003-09-15 00:35:33 +02:00
|
|
|
|
|
|
|
|
|
Copyright 1986, 1989, 1991, 1992, 1993, 1995, 1996, 2000, 2001,
|
|
|
|
|
2003 Free Software Foundation, Inc.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
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.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
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.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
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., 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include "gdb_stat.h"
|
|
|
|
|
|
|
|
|
|
#if defined (SIGTSTP) && defined (SIGIO)
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <sys/resource.h>
|
|
|
|
|
#endif /* SIGTSTP and SIGIO defined (must be 4.2) */
|
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
2001-02-06 05:17:03 +01:00
|
|
|
|
#include <signal.h>
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "frame.h"
|
|
|
|
|
#include "inferior.h"
|
2000-02-09 09:52:47 +01:00
|
|
|
|
#include "gdb_wait.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* Random system calls, mostly no-ops to prevent link problems */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
ioctl (int desc, int code, int arg)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
int (*signal ()) ()
|
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
kill (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
getpid (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
sigsetmask (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
chdir (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
getcwd (char *buf, unsigned int len)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
buf[0] = '/';
|
|
|
|
|
buf[1] = 0;
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Used to check for existence of .gdbinit. Say no. */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
access (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
exit (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
error ("Fatal error; restarting.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reading "files". The contents of some files are written into kdb's
|
|
|
|
|
data area before it is run. These files are used to contain the
|
|
|
|
|
symbol table for kdb to load, and the source files (in case the
|
|
|
|
|
kdb user wants to print them). The symbols are stored in a file
|
|
|
|
|
named "kdb-symbols" in a.out format (except that all the text and
|
|
|
|
|
data have been stripped to save room).
|
|
|
|
|
|
|
|
|
|
The files are stored in the following format:
|
|
|
|
|
int number of bytes of data for this file, including these four.
|
|
|
|
|
char[] name of the file, ending with a null.
|
|
|
|
|
padding to multiple of 4 boundary.
|
|
|
|
|
char[] file contents. The length can be deduced from what was
|
1999-07-07 22:19:36 +02:00
|
|
|
|
specified before. There is no terminating null here.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
If the int at the front is zero, it means there are no more files.
|
|
|
|
|
|
|
|
|
|
Opening a file in kdb returns a nonzero value to indicate success,
|
|
|
|
|
but the value does not matter. Only one file can be open, and only
|
|
|
|
|
for reading. All the primitives for input from the file know
|
|
|
|
|
which file is open and ignore what is specified for the descriptor
|
|
|
|
|
or for the stdio stream.
|
|
|
|
|
|
|
|
|
|
Input with fgetc can be done either on the file that is open
|
|
|
|
|
or on stdin (which reads from the terminal through tty_input () */
|
|
|
|
|
|
|
|
|
|
/* Address of data for the files stored in format described above. */
|
|
|
|
|
char *files_start;
|
|
|
|
|
|
|
|
|
|
/* The file stream currently open: */
|
|
|
|
|
|
|
|
|
|
char *sourcebeg; /* beginning of contents */
|
|
|
|
|
int sourcesize; /* size of contents */
|
|
|
|
|
char *sourceptr; /* current read pointer */
|
|
|
|
|
int sourceleft; /* number of bytes to eof */
|
|
|
|
|
|
|
|
|
|
/* "descriptor" for the file now open.
|
|
|
|
|
Incremented at each close.
|
|
|
|
|
If specified descriptor does not match this,
|
|
|
|
|
it means the program is trying to use a closed descriptor.
|
|
|
|
|
We report an error for that. */
|
|
|
|
|
|
|
|
|
|
int sourcedesc;
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
open (char *filename, int modes)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-14 18:32:14 +02:00
|
|
|
|
char *next;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (modes)
|
|
|
|
|
{
|
|
|
|
|
errno = EROFS;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sourceptr)
|
|
|
|
|
{
|
|
|
|
|
errno = EMFILE;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
for (next = files_start; *(int *) next; next += *(int *) next)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2001-01-19 09:01:47 +01:00
|
|
|
|
if (!strcmp (next + 4, filename))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
sourcebeg = next + 4 + strlen (next + 4) + 1;
|
|
|
|
|
sourcebeg = (char *) (((int) sourcebeg + 3) & (-4));
|
|
|
|
|
sourceptr = sourcebeg;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
sourcesize = next + *(int *) next - sourceptr;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
sourceleft = sourcesize;
|
|
|
|
|
return sourcedesc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
close (int desc)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
sourceptr = 0;
|
|
|
|
|
sourcedesc++;
|
|
|
|
|
/* Don't let sourcedesc get big enough to be confused with stdin. */
|
|
|
|
|
if (sourcedesc == 100)
|
|
|
|
|
sourcedesc = 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FILE *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fopen (char *filename, char *modes)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
return (FILE *) open (filename, *modes == 'w');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FILE *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fdopen (int desc)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
return (FILE *) desc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fclose (int desc)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
close (desc);
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fstat (int desc, struct stat *statbuf)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
if (desc != sourcedesc)
|
|
|
|
|
{
|
|
|
|
|
errno = EBADF;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
statbuf->st_size = sourcesize;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
myread (int desc, char *destptr, int size, char *filename)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
int len = min (sourceleft, size);
|
|
|
|
|
|
|
|
|
|
if (desc != sourcedesc)
|
|
|
|
|
{
|
|
|
|
|
errno = EBADF;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy (destptr, sourceptr, len);
|
|
|
|
|
sourceleft -= len;
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fread (int bufp, int numelts, int eltsize, int stream)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-14 18:32:14 +02:00
|
|
|
|
int elts = min (numelts, sourceleft / eltsize);
|
|
|
|
|
int len = elts * eltsize;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (stream != sourcedesc)
|
|
|
|
|
{
|
|
|
|
|
errno = EBADF;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy (bufp, sourceptr, len);
|
|
|
|
|
sourceleft -= len;
|
|
|
|
|
return elts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fgetc (int desc)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (desc == (int) stdin)
|
|
|
|
|
return tty_input ();
|
|
|
|
|
|
|
|
|
|
if (desc != sourcedesc)
|
|
|
|
|
{
|
|
|
|
|
errno = EBADF;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sourceleft-- <= 0)
|
|
|
|
|
return EOF;
|
|
|
|
|
return *sourceptr++;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
lseek (int desc, int pos)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (desc != sourcedesc)
|
|
|
|
|
{
|
|
|
|
|
errno = EBADF;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pos < 0 || pos > sourcesize)
|
|
|
|
|
{
|
|
|
|
|
errno = EINVAL;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sourceptr = sourcebeg + pos;
|
|
|
|
|
sourceleft = sourcesize - pos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Output in kdb can go only to the terminal, so the stream
|
|
|
|
|
specified may be ignored. */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
printf (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
char buffer[1024];
|
|
|
|
|
sprintf (buffer, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
|
|
|
display_string (buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fprintf (int ign, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
|
|
|
|
|
int a8, int a9)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
char buffer[1024];
|
|
|
|
|
sprintf (buffer, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
|
|
|
display_string (buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-16 Andrew Cagney <cagney@redhat.com>
* buildsym.c: Remove more occurances of "register".
* coffread.c, dbxread.c, dcache.c, dwarf2read.c: Ditto.
* environ.c, eval.c, f-valprint.c, findvar.c: Ditto.
* gdbtypes.c, gnu-v2-abi.c, h8300-tdep.c, hppa-tdep.c: Ditto.
* infcmd.c, mdebugread.c, minsyms.c, mips-tdep.c: Ditto.
* printcmd.c, remote-vx.c, sh-stub.c, sh-tdep.c: Ditto.
* sh64-tdep.c, source.c, stabsread.c, stack.c: Ditto.
* standalone.c, symfile.c, symmisc.c, symtab.c: Ditto.
* utils.c, valops.c, values.c, xcoffread.c: Ditto.
2003-09-16 20:56:35 +02:00
|
|
|
|
fwrite (char *buf, int numelts, int size, int stream)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-14 18:32:14 +02:00
|
|
|
|
int i = numelts * size;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
while (i-- > 0)
|
|
|
|
|
fputc (*buf++, stream);
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fputc (int c, int ign)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
char buf[2];
|
|
|
|
|
buf[0] = c;
|
|
|
|
|
buf[1] = 0;
|
|
|
|
|
display_string (buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sprintf refers to this, but loading this from the
|
|
|
|
|
library would cause fflush to be loaded from it too.
|
|
|
|
|
In fact there should be no need to call this (I hope). */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
_flsbuf (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
error ("_flsbuf was actually called.");
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fflush (int ign)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Entries into core and inflow, needed only to make things link ok. */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
exec_file_command (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
core_file_command (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
get_exec_file (int err)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
/* Makes one printout look reasonable; value does not matter otherwise. */
|
|
|
|
|
return "run";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Nonzero if there is a core file. */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
have_core_file_p (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
kill_command (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2001-05-04 06:15:33 +02:00
|
|
|
|
inferior_ptid = null_ptid;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
terminal_inferior (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
terminal_ours (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
terminal_init_inferior (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
write_inferior_register (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
read_inferior_register (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
read_memory (CORE_ADDR memaddr, char *myaddr, int len)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
memcpy (myaddr, memaddr, len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Always return 0 indicating success. */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
write_memory (CORE_ADDR memaddr, char *myaddr, int len)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
memcpy (memaddr, myaddr, len);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static REGISTER_TYPE saved_regs[NUM_REGS];
|
|
|
|
|
|
|
|
|
|
REGISTER_TYPE
|
2000-07-30 03:48:28 +02:00
|
|
|
|
read_register (int regno)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
if (regno < 0 || regno >= NUM_REGS)
|
|
|
|
|
error ("Register number %d out of range.", regno);
|
|
|
|
|
return saved_regs[regno];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2000-07-30 03:48:28 +02:00
|
|
|
|
write_register (int regno, REGISTER_TYPE value)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
if (regno < 0 || regno >= NUM_REGS)
|
|
|
|
|
error ("Register number %d out of range.", regno);
|
|
|
|
|
saved_regs[regno] = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* System calls needed in relation to running the "inferior". */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
vfork (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
/* Just appear to "succeed". Say the inferior's pid is 1. */
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* These are called by code that normally runs in the inferior
|
|
|
|
|
that has just been forked. That code never runs, when standalone,
|
|
|
|
|
and these definitions are so it will link without errors. */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
ptrace (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
setpgrp (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
execle (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
_exit (void)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
/* Malloc calls these. */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
malloc_warning (char *str)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
printf ("\n%s.\n\n", str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *next_free;
|
|
|
|
|
char *memory_limit;
|
|
|
|
|
|
|
|
|
|
char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
sbrk (int amount)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
if (next_free + amount > memory_limit)
|
|
|
|
|
return (char *) -1;
|
|
|
|
|
next_free += amount;
|
|
|
|
|
return next_free - amount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Various ways malloc might ask where end of memory is. */
|
|
|
|
|
|
|
|
|
|
char *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
ulimit (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
return memory_limit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
vlimit (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
return memory_limit - next_free;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
getrlimit (struct rlimit *addr)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
addr->rlim_cur = memory_limit - next_free;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Context switching to and from program being debugged. */
|
|
|
|
|
|
|
|
|
|
/* GDB calls here to run the user program.
|
|
|
|
|
The frame pointer for this function is saved in
|
|
|
|
|
gdb_stack by save_frame_pointer; then we restore
|
|
|
|
|
all of the user program's registers, including PC and PS. */
|
|
|
|
|
|
|
|
|
|
static int fault_code;
|
|
|
|
|
static REGISTER_TYPE gdb_stack;
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
resume (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
REGISTER_TYPE restore[NUM_REGS];
|
|
|
|
|
|
|
|
|
|
PUSH_FRAME_PTR;
|
|
|
|
|
save_frame_pointer ();
|
|
|
|
|
|
|
|
|
|
memcpy (restore, saved_regs, sizeof restore);
|
|
|
|
|
POP_REGISTERS;
|
|
|
|
|
/* Control does not drop through here! */
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
save_frame_pointer (CORE_ADDR val)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
gdb_stack = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Fault handlers call here, running in the user program stack.
|
|
|
|
|
They must first push a fault code,
|
|
|
|
|
old PC, old PS, and any other info about the fault.
|
|
|
|
|
The exact format is machine-dependent and is known only
|
|
|
|
|
in the definition of PUSH_REGISTERS. */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
fault (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
/* Transfer all registers and fault code to the stack
|
|
|
|
|
in canonical order: registers in order of GDB register number,
|
|
|
|
|
followed by fault code. */
|
|
|
|
|
PUSH_REGISTERS;
|
|
|
|
|
|
|
|
|
|
/* Transfer them to saved_regs and fault_code. */
|
|
|
|
|
save_registers ();
|
|
|
|
|
|
|
|
|
|
restore_gdb ();
|
|
|
|
|
/* Control does not reach here */
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
restore_gdb (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
CORE_ADDR new_fp = gdb_stack;
|
|
|
|
|
/* Switch to GDB's stack */
|
|
|
|
|
POP_FRAME_PTR;
|
|
|
|
|
/* Return from the function `resume'. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Assuming register contents and fault code have been pushed on the stack as
|
|
|
|
|
arguments to this function, copy them into the standard place
|
|
|
|
|
for the program's registers while GDB is running. */
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
save_registers (int firstreg)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
memcpy (saved_regs, &firstreg, sizeof saved_regs);
|
|
|
|
|
fault_code = (&firstreg)[NUM_REGS];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Store into the structure such as `wait' would return
|
|
|
|
|
the information on why the program faulted,
|
|
|
|
|
converted into a machine-independent signal number. */
|
|
|
|
|
|
|
|
|
|
static int fault_table[] = FAULT_TABLE;
|
|
|
|
|
|
|
|
|
|
int
|
2000-07-30 03:48:28 +02:00
|
|
|
|
wait (WAITTYPE *w)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
WSETSTOP (*w, fault_table[fault_code / FAULT_CODE_UNITS]);
|
2001-05-04 06:15:33 +02:00
|
|
|
|
return PIDGET (inferior_ptid);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate a big space in which files for kdb to read will be stored.
|
|
|
|
|
Whatever is left is where malloc can allocate storage.
|
|
|
|
|
|
|
|
|
|
Initialize it, so that there will be space in the executable file
|
|
|
|
|
for it. Then the files can be put into kdb by writing them into
|
|
|
|
|
kdb's executable file. */
|
|
|
|
|
|
|
|
|
|
/* The default size is as much space as we expect to be available
|
|
|
|
|
for kdb to use! */
|
|
|
|
|
|
|
|
|
|
#ifndef HEAP_SIZE
|
|
|
|
|
#define HEAP_SIZE 400000
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
char heap[HEAP_SIZE] =
|
|
|
|
|
{0};
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
#ifndef STACK_SIZE
|
|
|
|
|
#define STACK_SIZE 100000
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int kdb_stack_beg[STACK_SIZE / sizeof (int)];
|
|
|
|
|
int kdb_stack_end;
|
|
|
|
|
|
2000-07-30 03:48:28 +02:00
|
|
|
|
_initialize_standalone (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-14 18:32:14 +02:00
|
|
|
|
char *next;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
/* Find start of data on files. */
|
|
|
|
|
|
|
|
|
|
files_start = heap;
|
|
|
|
|
|
|
|
|
|
/* Find the end of the data on files. */
|
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
for (next = files_start; *(int *) next; next += *(int *) next)
|
|
|
|
|
{
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
/* That is where free storage starts for sbrk to give out. */
|
|
|
|
|
next_free = next;
|
|
|
|
|
|
|
|
|
|
memory_limit = heap + sizeof heap;
|
|
|
|
|
}
|