/* Remote debugging interface for Motorola's MVME187BUG monitor, an embedded
monitor for the m88k.
- Copyright 1992, 1993 Free Software Foundation, Inc.
+ Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+ 2002 Free Software Foundation, Inc.
+
Contributed by Cygnus Support. Written by K. Richard Pixley.
This file is part of GDB.
#include "defs.h"
#include "inferior.h"
-#include "wait.h"
-
#include "gdb_string.h"
+#include "regcache.h"
#include <ctype.h>
#include <fcntl.h>
-#include <signal.h>
#include <setjmp.h>
#include <errno.h>
#include "gdbcore.h"
#include "gdbcmd.h"
+#include "serial.h"
#include "remote-utils.h"
-
-extern int sleep ();
-
/* External data declarations */
extern int stop_soon_quietly; /* for wait_for_inferior */
extern struct target_ops bug_ops; /* Forward declaration */
/* Forward function declarations */
-static int bug_clear_breakpoints PARAMS ((void));
+static int bug_clear_breakpoints (void);
-static int bug_read_memory PARAMS ((CORE_ADDR memaddr,
- unsigned char *myaddr,
- int len));
+static int bug_read_memory (CORE_ADDR memaddr,
+ unsigned char *myaddr, int len);
-static int bug_write_memory PARAMS ((CORE_ADDR memaddr,
- unsigned char *myaddr,
- int len));
+static int bug_write_memory (CORE_ADDR memaddr,
+ unsigned char *myaddr, int len);
/* This variable is somewhat arbitrary. It's here so that it can be
set from within a running gdb. */
*/
static void
-bug_load (args, fromtty)
- char *args;
- int fromtty;
+bug_load (char *args, int fromtty)
{
bfd *abfd;
asection *s;
sr_check_open ();
- dcache_flush (gr_get_dcache ());
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
abfd = bfd_openr (args, 0);
if (!abfd)
{
char *buffer = xmalloc (srec_frame);
- printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma, s->vma + s->_raw_size);
+ printf_filtered ("%s\t: 0x%4lx .. 0x%4lx ", s->name, s->vma, s->vma + s->_raw_size);
gdb_flush (gdb_stdout);
for (i = 0; i < s->_raw_size; i += srec_frame)
{
gdb_flush (gdb_stdout);
}
printf_filtered ("\n");
- free (buffer);
+ xfree (buffer);
}
s = s->next;
}
#if 0
static char *
-get_word (p)
- char **p;
+get_word (char **p)
{
char *s = *p;
char *word;
static struct gr_settings bug_settings =
{
- NULL, /* dcache */
"Bug>", /* prompt */
&bug_ops, /* ops */
bug_clear_breakpoints, /* clear_all_breakpoints */
- bug_read_memory, /* readfunc */
- bug_write_memory, /* writefunc */
gr_generic_checkin, /* checkin */
};
};
static void
-bug_open (args, from_tty)
- char *args;
- int from_tty;
+bug_open (char *args, int from_tty)
{
if (args == NULL)
args = "";
target_is_m88110 = 1;
break;
default:
- abort ();
+ internal_error (__FILE__, __LINE__, "failed internal consistency check");
}
}
/* Tell the remote machine to resume. */
void
-bug_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
+bug_resume (ptid_t ptid, int step, enum target_signal sig)
{
- dcache_flush (gr_get_dcache ());
-
if (step)
{
sr_write_cr ("t");
NULL,
};
-int
-bug_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
+ptid_t
+bug_wait (ptid_t ptid, struct target_waitstatus *status)
{
int old_timeout = sr_get_timeout ();
int old_immediate_quit = immediate_quit;
sr_set_timeout (old_timeout);
immediate_quit = old_immediate_quit;
- return 0;
+ return inferior_ptid;
}
/* Return the name of register number REGNO
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 *rn[] =
{
success, -1 on failure. */
static int
-bug_scan (s)
- char *s;
+bug_scan (char *s)
{
int c;
#endif /* never */
static int
-bug_srec_write_cr (s)
- char *s;
+bug_srec_write_cr (char *s)
{
char *p = s;
printf ("%c", *p);
do
- SERIAL_WRITE (sr_get_desc (), p, 1);
+ serial_write (sr_get_desc (), p, 1);
while (sr_pollchar () != *p);
}
else
/* Store register REGNO, or all if REGNO == -1. */
static void
-bug_fetch_register (regno)
- int regno;
+bug_fetch_register (int regno)
{
sr_check_open ();
/* Store register REGNO, or all if REGNO == -1. */
static void
-bug_store_register (regno)
- int regno;
+bug_store_register (int regno)
{
char buffer[1024];
sr_check_open ();
if (target_is_m88110 && regno == SFIP_REGNUM)
return;
else if (regno < XFP_REGNUM)
- sprintf (buffer, "rs %s %08x",
+ sprintf (buffer, "rs %s %08lx",
regname,
- read_register (regno));
+ (long) read_register (regno));
else
{
unsigned char *fpreg_buf =
return;
}
-int
-bug_xfer_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* ignored */
-{
- register int i;
-
- /* Round starting address down to longword boundary. */
- register CORE_ADDR addr;
+/* 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.
- /* Round ending address up; get number of longwords that makes. */
- register int count;
+ Returns the number of bytes transferred. */
- /* Allocate buffer of that many longwords. */
- register int *buffer;
-
- addr = memaddr & -sizeof (int);
- count = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
+int
+bug_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib, struct target_ops *target)
+{
+ int res;
- buffer = (int *) alloca (count * sizeof (int));
+ if (len <= 0)
+ return 0;
if (write)
- {
- /* Fill start and end extra bytes of buffer with existing memory data. */
-
- if (addr != memaddr || len < (int) sizeof (int))
- {
- /* Need part of initial word -- fetch it. */
- buffer[0] = gr_fetch_word (addr);
- }
-
- if (count > 1) /* FIXME, avoid if even boundary */
- {
- buffer[count - 1]
- = gr_fetch_word (addr + (count - 1) * sizeof (int));
- }
-
- /* Copy data to be written over corresponding part of buffer */
-
- memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
-
- /* Write the entire buffer. */
-
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- errno = 0;
- gr_store_word (addr, buffer[i]);
- if (errno)
- {
-
- return 0;
- }
-
- }
- }
+ res = bug_write_memory (memaddr, myaddr, len);
else
- {
- /* Read all the longwords */
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- errno = 0;
- buffer[i] = gr_fetch_word (addr);
- if (errno)
- {
- return 0;
- }
- QUIT;
- }
-
- /* Copy appropriate bytes out of the buffer. */
- memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
- }
+ res = bug_read_memory (memaddr, myaddr, len);
- return len;
+ return res;
}
static void
-start_load ()
+start_load (void)
{
char *command;
};
static int
-bug_write_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
+bug_write_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
{
int done;
int checksum;
thisgo = srec_bytes;
address = memaddr + done;
- sprintf (buf, "S3%02X%08X", thisgo + 4 + 1, address);
+ sprintf (buf, "S3%02X%08lX", thisgo + 4 + 1, (long) address);
buf += 12;
checksum += (thisgo + 4 + 1
/* Read LEN bytes from inferior memory at MEMADDR. Put the result
at debugger address MYADDR. Returns errno value. */
static int
-bug_read_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
+bug_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
{
char request[100];
char *buffer;
unsigned int inaddr;
unsigned int checksum;
- sprintf (request, "du 0 %x:&%d", memaddr, len);
+ sprintf (request, "du 0 %lx:&%d", (long) memaddr, len);
sr_write_cr (request);
p = buffer = alloca (len);
#define MAX_BREAKS 16
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 bug is responsible for
+ saving/restoring the original instruction. */
+
static int
-bug_insert_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save; /* Throw away, let bug save instructions */
+bug_insert_breakpoint (CORE_ADDR addr, char *save)
{
sr_check_open ();
char buffer[100];
num_brkpts++;
- sprintf (buffer, "br %x", addr);
+ sprintf (buffer, "br %lx", (long) addr);
sr_write_cr (buffer);
gr_expect_prompt ();
return (0);
}
}
+
+/* Remove a breakpoint at ADDR. SAVE is normally the previously
+ saved pattern, but is unused here since the bug is responsible
+ for saving/restoring instructions. */
+
static int
-bug_remove_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save; /* Throw away, let bug save instructions */
+bug_remove_breakpoint (CORE_ADDR addr, char *save)
{
if (num_brkpts > 0)
{
char buffer[100];
num_brkpts--;
- sprintf (buffer, "nobr %x", addr);
+ sprintf (buffer, "nobr %lx", (long) addr);
sr_write_cr (buffer);
gr_expect_prompt ();
/* Clear the bugs notion of what the break points are */
static int
-bug_clear_breakpoints ()
+bug_clear_breakpoints (void)
{
if (sr_is_open ())
bug_ops.to_thread_alive = 0;
bug_ops.to_stop = 0;
bug_ops.to_pid_to_exec_file = NULL;
- bug_ops.to_core_file_to_sym_file = NULL;
bug_ops.to_stratum = process_stratum;
bug_ops.DONT_USE = 0;
bug_ops.to_has_all_memory = 1;
} /* init_bug_ops */
void
-_initialize_remote_bug ()
+_initialize_remote_bug (void)
{
init_bug_ops ();
add_target (&bug_ops);