/* Remote debugging interface for AMD 290*0 Adapt Monitor Version 2.1d18.
- Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 2001 Free Software Foundation, Inc.
Contributed by David Wood at New York University (wood@lab.ultra.nyu.edu).
Adapted from work done at Cygnus Support in remote-eb.c.
#include "defs.h"
#include "gdb_string.h"
#include "inferior.h"
-#include "wait.h"
+#include "gdb_wait.h"
#include "value.h"
#include <ctype.h>
#include <fcntl.h>
#define ON 1
#define OFF 0
static void
-rawmode (desc, turnon)
- int desc;
- int turnon;
+rawmode (int desc, int turnon)
{
TERMINAL sg;
}
/* Suck up all the input from the adapt */
-slurp_input ()
+slurp_input (void)
{
char buf[8];
/* Read a character from the remote system, doing all the fancy
timeout stuff. */
static int
-readchar ()
+readchar (void)
{
char buf;
/* Keep discarding input from the remote system, until STRING is found.
Let the user break out immediately. */
static void
-expect (string)
- char *string;
+expect (char *string)
{
char *p = string;
fflush (adapt_stream);
- immediate_quit = 1;
+ immediate_quit++;
while (1)
{
if (readchar () == *p)
p++;
if (*p == '\0')
{
- immediate_quit = 0;
+ immediate_quit--;
return;
}
}
necessary to prevent getting into states from which we can't
recover. */
static void
-expect_prompt ()
+expect_prompt (void)
{
#if defined (LOG_FILE)
/* This is a convenient place to do this. The idea is to do it often
/* Get a hex digit from the remote system & return its value.
If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */
static int
-get_hex_digit (ignore_space)
- int ignore_space;
+get_hex_digit (int ignore_space)
{
int ch;
while (1)
/* Get a byte from adapt_desc and put it in *BYT. Accept any number
leading spaces. */
static void
-get_hex_byte (byt)
- char *byt;
+get_hex_byte (char *byt)
{
int val;
/* Read a 32-bit hex word from the adapt, preceded by a space */
static long
-get_hex_word ()
+get_hex_word (void)
{
long val;
int j;
/* Get N 32-bit hex words from remote, each preceded by a space
and put them in registers starting at REGNO. */
static void
-get_hex_regs (n, regno)
- int n;
- int regno;
+get_hex_regs (int n, int regno)
{
long val;
while (n--)
volatile int n_alarms;
void
-adapt_timer ()
+adapt_timer (void)
{
#if 0
if (kiodebug)
static int need_artificial_trap = 0;
void
-adapt_kill (arg, from_tty)
- char *arg;
- int from_tty;
+adapt_kill (char *arg, int from_tty)
{
fprintf (adapt_stream, "K");
fprintf (adapt_stream, "\r");
* FIXME: Assumes the file to download is a binary coff file.
*/
static void
-adapt_load (args, fromtty)
- char *args;
- int fromtty;
+adapt_load (char *args, int fromtty)
{
FILE *fp;
int n;
/* This is called not only when we first attach, but also when the
user types "run" after having attached. */
void
-adapt_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
+adapt_create_inferior (char *execfile, char *args, char **env)
{
int entry_pt;
};
static int
-damn_b (rate)
- int rate;
+damn_b (int rate)
{
int i;
static int baudrate = 9600;
static void
-adapt_open (name, from_tty)
- char *name;
- int from_tty;
+adapt_open (char *name, int from_tty)
{
TERMINAL sg;
unsigned int prl;
/*EMPTY */ ;
if (prog_name != NULL)
- free (prog_name);
+ xfree (prog_name);
prog_name = savestring (p, strlen (p));
adapt_close (0);
/* Close out all files and local state before this target loses control. */
static void
-adapt_close (quitting)
- int quitting;
+adapt_close (int quitting)
{
/* Clear any break points */
/* Attach to the target that is already loaded and possibly running */
static void
-adapt_attach (args, from_tty)
- char *args;
- int from_tty;
+adapt_attach (char *args, int from_tty)
{
if (from_tty)
Use this when you want to detach and do something else
with your gdb. */
void
-adapt_detach (args, from_tty)
- char *args;
- int from_tty;
+adapt_detach (char *args, int from_tty)
{
if (adapt_stream)
/* Tell the remote machine to resume. */
void
-adapt_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
+adapt_resume (int pid, int step, enum target_signal sig)
{
if (step)
{
storing status in STATUS just as `wait' would. */
int
-adapt_wait (status)
- struct target_waitstatus *status;
+adapt_wait (struct target_waitstatus *status)
{
/* Strings to look for. '?' means match any single character.
Note that with the algorithm we use, the initial character
Returns a pointer to a static buffer containing the answer. */
static char *
-get_reg_name (regno)
- int regno;
+get_reg_name (int regno)
{
static char buf[80];
if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
/* Read the remote registers. */
static void
-adapt_fetch_registers ()
+adapt_fetch_registers (void)
{
int reg_index;
int regnum_index;
/* Fetch register REGNO, or all registers if REGNO is -1.
*/
static void
-adapt_fetch_register (regno)
- int regno;
+adapt_fetch_register (int regno)
{
if (regno == -1)
adapt_fetch_registers ();
/* Store the remote registers from the contents of the block REGS. */
static void
-adapt_store_registers ()
+adapt_store_registers (void)
{
int i, j;
/* Store register REGNO, or all if REGNO == -1.
Return errno value. */
void
-adapt_store_register (regno)
- int regno;
+adapt_store_register (int regno)
{
/* printf("adapt_store_register() called.\n"); fflush(stdout); /* */
if (regno == -1)
debugged. */
void
-adapt_prepare_to_store ()
+adapt_prepare_to_store (void)
{
/* Do nothing, since we can store individual regs */
}
static CORE_ADDR
-translate_addr (addr)
- CORE_ADDR addr;
+translate_addr (CORE_ADDR addr)
{
#if defined(KERNEL_DEBUGGING)
/* Check for a virtual address in the kernel */
/* FIXME! Merge these two. */
int
-adapt_xfer_inferior_memory (memaddr, myaddr, len, write)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
+adapt_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib ATTRIBUTE_UNUSED,
+ struct target_ops *target ATTRIBUTE_UNUSED)
{
memaddr = translate_addr (memaddr);
}
void
-adapt_files_info ()
+adapt_files_info (void)
{
printf_filtered ("\tAttached to %s at %d baud and running program %s\n",
dev_name, baudrate, prog_name);
* sb/sh instructions don't work on unaligned addresses, when TU=1.
*/
int
-adapt_write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
+adapt_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
int i;
unsigned int cps;
/* Read LEN bytes from inferior memory at MEMADDR. Put the result
at debugger address MYADDR. Returns errno value. */
int
-adapt_read_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
+adapt_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
int i;
#define MAX_BREAKS 8
static int num_brkpts = 0;
+
+/* Insert a breakpoint at ADDR. SAVE is normally the address of the
+ pattern buffer where the instruction that the breakpoint overwrites
+ is saved. It is unused here since the Adapt Monitor is responsible
+ for saving/restoring the original instruction. */
+
static int
-adapt_insert_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save; /* Throw away, let adapt save instructions */
+adapt_insert_breakpoint (CORE_ADDR addr, char *save)
{
if (num_brkpts < MAX_BREAKS)
{
}
}
+
+/* Remove a breakpoint at ADDR. SAVE is normally the previously
+ saved pattern, but is unused here as the Adapt Monitor is
+ responsible for saving/restoring instructions. */
+
static int
-adapt_remove_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save; /* Throw away, let adapt save instructions */
+adapt_remove_breakpoint (CORE_ADDR addr, char *save)
{
if (num_brkpts > 0)
{
/* Clear the adapts notion of what the break points are */
static int
-adapt_clear_breakpoints ()
+adapt_clear_breakpoints (void)
{
if (adapt_stream)
{
num_brkpts = 0;
}
static void
-adapt_mourn ()
+adapt_mourn (void)
{
adapt_clear_breakpoints ();
pop_target (); /* Pop back to no-child state */
* specified string
*/
static int
-display_until (str)
- char *str;
+display_until (char *str)
{
int i = 0, j, c;
FIXME: Can't handle commands that take input. */
void
-adapt_com (args, fromtty)
- char *args;
- int fromtty;
+adapt_com (char *args, int fromtty)
{
if (!adapt_stream)
{
} /* init_adapt_ops */
void
-_initialize_remote_adapt ()
+_initialize_remote_adapt (void)
{
init_adapt_ops ();
add_target (&adapt_ops);