/* Remote debugging interface for Array Tech RAID controller..
- Copyright 90, 91, 92, 93, 94, 1995, 1998 Free Software Foundation, Inc.
+ Copyright 90, 91, 92, 93, 94, 1995, 1998, 2001 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by Rob Savoye for Cygnus.
This module talks to a debug monitor called 'MONITOR', which
#include "defs.h"
#include "gdbcore.h"
#include "target.h"
-#include "wait.h"
#include <ctype.h>
-#include <signal.h>
#include <sys/types.h>
#include "gdb_string.h"
#include "command.h"
#include "serial.h"
#include "monitor.h"
#include "remote-utils.h"
+#include "inferior.h"
+#include "version.h"
+#include "regcache.h"
extern int baud_rate;
} \
while (0)
-static void debuglogs PARAMS ((int, char *,...));
+static void debuglogs (int, char *, ...);
static void array_open ();
static void array_close ();
static void array_detach ();
static unsigned long ascii2hexword ();
static void hexword2ascii ();
-extern char *version;
-
#define LOG_FILE "monitor.log"
#if defined (LOG_FILE)
FILE *log_file;
* write_monitor -- send raw data to monitor.
*/
static void
-write_monitor (data, len)
- char data[];
- int len;
+write_monitor (char data[], int len)
{
if (SERIAL_WRITE (array_desc, data, len))
fprintf (stderr, "SERIAL_WRITE failed: %s\n", safe_strerror (errno));
* timeout stuff.
*/
static int
-readchar (timeout)
- int timeout;
+readchar (int timeout)
{
int c;
* it out. Let the user break out immediately.
*/
static void
-expect (string, discard)
- char *string;
- int discard;
+expect (char *string, int discard)
{
char *p = string;
int c;
debuglogs (1, "Expecting \"%s\".", string);
- immediate_quit = 1;
+ immediate_quit++;
while (1)
{
c = readchar (timeout);
{
if (*p == '\0')
{
- immediate_quit = 0;
+ immediate_quit--;
debuglogs (4, "Matched");
return;
}
necessary to prevent getting into states from which we can't
recover. */
static void
-expect_prompt (discard)
- int discard;
+expect_prompt (int discard)
{
expect (ARRAY_PROMPT, discard);
}
* junk -- ignore junk characters. Returns a 1 if junk, 0 otherwise
*/
static int
-junk (ch)
- char ch;
+junk (char ch)
{
switch (ch)
{
* If ignore is nonzero, ignore spaces, newline & tabs.
*/
static int
-get_hex_digit (ignore)
- int ignore;
+get_hex_digit (int ignore)
{
static int ch;
while (1)
* Accept any number leading spaces.
*/
static void
-get_hex_byte (byt)
- char *byt;
+get_hex_byte (char *byt)
{
int val;
* and put them in registers starting at REGNO.
*/
static int
-get_hex_word ()
+get_hex_word (void)
{
long val, newval;
int i;
/* This is called not only when we first attach, but also when the
user types "run" after having attached. */
static void
-array_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
+array_create_inferior (char *execfile, char *args, char **env)
{
int entry_pt;
static char dev_name[100];
static void
-array_open (args, name, from_tty)
- char *args;
- char *name;
- int from_tty;
+array_open (char *args, char *name, int from_tty)
{
char packet[PBUFSIZ];
log_file = fopen (LOG_FILE, "w");
if (log_file == NULL)
perror_with_name (LOG_FILE);
- fprintf (log_file, "GDB %s (%s", version);
+ fprintf (log_file, "GDB %s (%s", version, host_name);
fprintf (log_file, " --target %s)\n", array_ops.to_shortname);
fprintf (log_file, "Remote target %s connected to %s\n\n", array_ops.to_shortname, dev_name);
#endif
*/
static void
-array_close (quitting)
- int quitting;
+array_close (int quitting)
{
SERIAL_CLOSE (array_desc);
array_desc = NULL;
* else with your gdb.
*/
static void
-array_detach (from_tty)
- int from_tty;
+array_detach (int from_tty)
{
debuglogs (1, "array_detach ()");
* array_attach -- attach GDB to the target.
*/
static void
-array_attach (args, from_tty)
- char *args;
- int from_tty;
+array_attach (char *args, int from_tty)
{
if (from_tty)
printf ("Starting remote %s debugging\n", target_shortname);
* array_resume -- Tell the remote machine to resume.
*/
static void
-array_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
+array_resume (int pid, int step, enum target_signal sig)
{
debuglogs (1, "array_resume (step=%d, sig=%d)", step, sig);
* storing status in status just as `wait' would.
*/
static int
-array_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
+array_wait (int pid, struct target_waitstatus *status)
{
int old_timeout = timeout;
int result, i;
* block regs.
*/
static void
-array_fetch_registers (ignored)
- int ignored;
+array_fetch_registers (int ignored)
{
int regno, i;
char *p;
* protocol based on GDB's remote protocol.
*/
static void
-array_fetch_register (ignored)
- int ignored;
+array_fetch_register (int ignored)
{
- array_fetch_registers ();
+ array_fetch_registers (0 /* ignored */);
}
/*
* Get all the registers from the targets. They come back in a large array.
*/
static void
-array_store_registers (ignored)
- int ignored;
+array_store_registers (int ignored)
{
int regno;
unsigned long i;
* protocol based on GDB's remote protocol.
*/
static void
-array_store_register (ignored)
- int ignored;
+array_store_register (int ignored)
{
- array_store_registers ();
+ array_store_registers (0 /* ignored */);
}
/* Get ready to modify the registers array. On machines which store
debugged. */
static void
-array_prepare_to_store ()
+array_prepare_to_store (void)
{
/* Do nothing, since we can store individual regs */
}
static void
-array_files_info ()
+array_files_info (void)
{
printf ("\tAttached to %s at %d baud.\n",
dev_name, baudrate);
* memory at MYADDR to inferior's memory at MEMADDR. Returns length moved.
*/
static int
-array_write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
+array_write_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
{
unsigned long i;
int j;
* length moved.
*/
static int
-array_read_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
+array_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
int j;
char buf[20];
/* Fetch the bytes */
debuglogs (3, "read %d bytes from inferior address %x", len_this_pass,
startaddr);
- sprintf (buf, "m%08x,%04x", startaddr, len_this_pass);
+ sprintf (buf, "m%08lx,%04x", startaddr, len_this_pass);
make_gdb_packet (packet, buf);
if (array_send_packet (packet) == 0)
{
return (count);
}
-/* FIXME-someday! merge these two. */
+/* Transfer LEN bytes between GDB address MYADDR and target address
+ MEMADDR. If WRITE is non-zero, transfer them to the target,
+ otherwise transfer them from the target. TARGET is unused.
+
+ Returns the number of bytes transferred. */
+
static int
-array_xfer_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* ignored */
+array_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib ATTRIBUTE_UNUSED,
+ struct target_ops *target ATTRIBUTE_UNUSED)
{
if (write)
return array_write_inferior_memory (memaddr, myaddr, len);
}
static void
-array_kill (args, from_tty)
- char *args;
- int from_tty;
+array_kill (char *args, int from_tty)
{
return; /* ignore attempts to kill target system */
}
instructions. */
static void
-array_mourn_inferior ()
+array_mourn_inferior (void)
{
remove_breakpoints ();
generic_mourn_inferior (); /* Do all the proper things now */
* array_insert_breakpoint -- add a breakpoint
*/
static int
-array_insert_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
+array_insert_breakpoint (CORE_ADDR addr, char *shadow)
{
int i;
int bp_size = 0;
{
breakaddr[i] = addr;
if (sr_get_debug () > 4)
- printf ("Breakpoint at %x\n", addr);
+ printf ("Breakpoint at %s\n", paddr_nz (addr));
array_read_inferior_memory (bp_addr, shadow, bp_size);
printf_monitor ("b 0x%x\n", addr);
expect_prompt (1);
* _remove_breakpoint -- Tell the monitor to remove a breakpoint
*/
static int
-array_remove_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
+array_remove_breakpoint (CORE_ADDR addr, char *shadow)
{
int i;
return 0;
}
}
- fprintf (stderr, "Can't find breakpoint associated with 0x%x\n", addr);
+ fprintf (stderr, "Can't find breakpoint associated with 0x%s\n",
+ paddr_nz (addr));
return 1;
}
static void
-array_stop ()
+array_stop (void)
{
debuglogs (1, "array_stop()");
printf_monitor ("\003");
* expect_prompt is seen. FIXME
*/
static void
-monitor_command (args, fromtty)
- char *args;
- int fromtty;
+monitor_command (char *args, int fromtty)
{
debuglogs (1, "monitor_command (args=%s)", args);
*
*/
static void
-make_gdb_packet (buf, data)
- char *buf, *data;
+make_gdb_packet (char *buf, char *data)
{
int i;
unsigned char csum = 0;
* successful transmition, or a 0 for a failure.
*/
static int
-array_send_packet (packet)
- char *packet;
+array_send_packet (char *packet)
{
int c, retries, i;
char junk[PBUFSIZ];
* packet, or a 0 it the packet wasn't transmitted correctly.
*/
static int
-array_get_packet (packet)
- char *packet;
+array_get_packet (char *packet)
{
int c;
int retries;
* ascii2hexword -- convert an ascii number represented by 8 digits to a hex value.
*/
static unsigned long
-ascii2hexword (mem)
- unsigned char *mem;
+ascii2hexword (unsigned char *mem)
{
unsigned long val;
int i;
* digits.
*/
static void
-hexword2ascii (mem, num)
- unsigned char *mem;
- unsigned long num;
+hexword2ascii (unsigned char *mem, unsigned long num)
{
int i;
unsigned char ch;
/* Convert hex digit A to a number. */
static int
-from_hex (a)
- int a;
+from_hex (int a)
{
if (a == 0)
return 0;
/* Convert number NIB to a hex digit. */
static int
-tohex (nib)
- int nib;
+tohex (int nib)
{
if (nib < 10)
return '0' + nib;
* are usually only used by monitors.
*/
void
-_initialize_remote_monitors ()
+_initialize_remote_monitors (void)
{
/* generic monitor command */
add_com ("monitor", class_obscure, monitor_command,
* _initialize_array -- do any special init stuff for the target.
*/
void
-_initialize_array ()
+_initialize_array (void)
{
init_array_ops ();
add_target (&array_ops);