/* Remote debugging interface for Am290*0 running MiniMON monitor, for GDB.
- Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
+ 2001 Free Software Foundation, Inc.
Originally written by Daniel Mann at AMD.
This file is part of GDB.
#include "defs.h"
#include "inferior.h"
-#include "wait.h"
#include "value.h"
#include <ctype.h>
#include <fcntl.h>
#include "terminal.h"
#include "minimon.h"
#include "target.h"
+#include "regcache.h"
/* Offset of member MEMBER in a struct of type TYPE. */
#define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
extern int stop_soon_quietly; /* for wait_for_inferior */
-static void mm_resume ();
+static void mm_resume (ptid_t ptid, int step, enum target_signal sig)
static void mm_fetch_registers ();
static int fetch_register ();
static void mm_store_registers ();
/* Called when SIGALRM signal sent due to alarm() timeout. */
#ifndef HAVE_TERMIO
-#ifndef __STDC__
-#ifndef volatile
-#define volatile
-/**/
-# endif
-#endif
volatile int n_alarms;
static void
-mm_timer ()
+mm_timer (void)
{
#if 0
if (kiodebug)
/* This is called not only when we first attach, but also when the
user types "run" after having attached. */
static void
-mm_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
+mm_create_inferior (char *execfile, char *args, char **env)
{
#define MAX_TOKENS 25
#define BUFFER_SIZE 256
}
/**************************************************** REMOTE_MOURN_INFERIOR */
static void
-mm_mourn ()
+mm_mourn (void)
{
pop_target (); /* Pop back to no-child state */
generic_mourn_inferior ();
};
static int
-damn_b (rate)
- int rate;
+damn_b (int rate)
{
int i;
static char *dev_name;
int baudrate = 9600;
static void
-mm_open (name, from_tty)
- char *name;
- int from_tty;
+mm_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));
Use this when you want to detach and do something else
with your gdb. */
static void
-mm_close (quitting) /*FIXME: how is quitting used */
- int quitting;
+mm_close ( /*FIXME: how is quitting used */
+ int quitting)
{
if (mm_desc < 0)
error ("Can't close remote connection: not debugging remotely.");
* Upon exiting the process's execution is stopped.
*/
static void
-mm_attach (args, from_tty)
- char *args;
- int from_tty;
+mm_attach (char *args, int from_tty)
{
if (!mm_stream)
Use this when you want to detach and do something else
with your gdb. Leave remote process running (with no breakpoints set). */
static void
-mm_detach (args, from_tty)
- char *args;
- int from_tty;
+mm_detach (char *args, int from_tty)
{
remove_breakpoints (); /* Just in case there were any left in */
out_msg_buf->go_msg.code = GO;
** Tell the remote machine to resume. */
static void
-mm_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
+mm_resume (ptid_t ptid, int step, enum target_signal sig)
{
if (sig != TARGET_SIGNAL_0)
warning ("Can't send signals to a remote MiniMon system.");
** Wait until the remote machine stops, then return,
storing status in STATUS just as `wait' would. */
-static int
-mm_wait (status)
- struct target_waitstatus *status;
+static ptid_t
+mm_wait (ptid_t ptid, struct target_waitstatus *status)
{
int i, result;
int old_timeout = timeout;
timeout = old_timeout; /* Restore original timeout value */
immediate_quit = old_immediate_quit;
- return 0;
+ return inferior_ptid;
}
/******************************************************* REMOTE_FETCH_REGISTERS
* If regno==-1 then read all the registers.
*/
static void
-mm_fetch_registers (regno)
- int regno;
+mm_fetch_registers (int regno)
{
INT32 *data_p;
*/
static void
-mm_store_registers (regno)
- int regno;
+mm_store_registers (int regno)
{
int result;
debugged. */
static void
-mm_prepare_to_store ()
+mm_prepare_to_store (void)
{
/* Do nothing, since we can store individual regs */
}
/******************************************************* REMOTE_XFER_MEMORY */
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 */
/******************************************************* REMOTE_FILES_INFO */
static void
-mm_files_info ()
+mm_files_info (void)
{
printf ("\tAttached to %s at %d baud and running program %s.\n",
dev_name, baudrate, prog_name);
/************************************************* REMOTE_INSERT_BREAKPOINT */
static int
-mm_insert_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
+mm_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
{
out_msg_buf->bkpt_set_msg.code = BKPT_SET;
out_msg_buf->bkpt_set_msg.length = 4 * 4;
/************************************************* REMOTE_DELETE_BREAKPOINT */
static int
-mm_remove_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
+mm_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
{
out_msg_buf->bkpt_rm_msg.code = BKPT_RM;
out_msg_buf->bkpt_rm_msg.length = 4 * 3;
/******************************************************* REMOTE_KILL */
static void
-mm_kill (arg, from_tty)
- char *arg;
- int from_tty;
+mm_kill (char *arg, int from_tty)
{
char buf[4];
* Load a program into the target.
*/
static void
-mm_load (arg_string, from_tty)
- char *arg_string;
- int from_tty;
+mm_load (char *arg_string, int from_tty)
{
dont_repeat ();
error ("The load command takes a file name");
arg_string = tilde_expand (arg_string);
- make_cleanup (free, arg_string);
+ make_cleanup (xfree, arg_string);
QUIT;
immediate_quit++;
error ("File loading is not yet supported for MiniMon.");
** Copy LEN bytes of data from debugger memory at MYADDR
to inferior's memory at MEMADDR. Returns number of bytes written. */
static int
-mm_write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
+mm_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
int i, nwritten;
** Read LEN bytes from inferior memory at MEMADDR. Put the result
at debugger address MYADDR. Returns number of bytes read. */
static int
-mm_read_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
+mm_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
int i, nread;
/* FIXME! Merge these two. */
static int
-mm_xfer_inferior_memory (memaddr, myaddr, len, write)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
+mm_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);
*/
int
-msg_send_serial (msg_ptr)
- union msg_t *msg_ptr;
+msg_send_serial (union msg_t *msg_ptr)
{
INT32 message_size;
int byte_count;
*/
int
-msg_recv_serial (msg_ptr)
- union msg_t *msg_ptr;
+msg_recv_serial (union msg_t *msg_ptr)
{
static INT32 length = 0;
static INT32 byte_count = 0;
TERMINAL kbd_tbuf;
int
-kbd_raw ()
+kbd_raw (void)
{
int result;
TERMINAL tbuf;
*/
int
-kbd_restore ()
+kbd_restore (void)
{
int result;
* Returns 0/-1 on success/failure.
*/
static int
-fetch_register (regno)
- int regno;
+fetch_register (int regno)
{
int result;
out_msg_buf->read_req_msg.code = READ_REQ;
* Returns 0/-1 on success/failure.
*/
static int
-store_register (regno)
- int regno;
+store_register (int regno)
{
int result;
* Convert a gdb special register number to a 29000 special register number.
*/
static int
-regnum_to_srnum (regno)
- int regno;
+regnum_to_srnum (int regno)
{
switch (regno)
{
* Initialize the target debugger (minimon only).
*/
static void
-init_target_mm (tstart, tend, dstart, dend, entry, ms_size, rs_size, arg_start)
- ADDR32 tstart, tend, dstart, dend, entry;
- INT32 ms_size, rs_size;
- ADDR32 arg_start;
+init_target_mm (ADDR32 tstart, ADDR32 tend, ADDR32 dstart, ADDR32 dend,
+ ADDR32 entry, INT32 ms_size, INT32 rs_size, ADDR32 arg_start)
{
out_msg_buf->init_msg.code = INIT;
out_msg_buf->init_msg.length = sizeof (struct init_msg_t) - 2 * sizeof (INT32);
* to be called with.
*/
static char *
-msg_str (code)
- INT32 code;
+msg_str (INT32 code)
{
static char cbuf[32];
* Selected (not all of them) error codes that we might get.
*/
static char *
-error_msg_str (code)
- INT32 code;
+error_msg_str (INT32 code)
{
static char cbuf[50];
return (cbuf);
}
/****************************************************************************/
-/*
- * Receive a message and expect it to be of type msgcode.
- * Returns 0/1 on failure/success.
- */
+
+/* Receive a message, placing it in MSG_BUF, and expect it to be of
+ type MSGCODE. If an error occurs, a non-zero FROM_TTY indicates
+ that the message should be printed.
+
+ Return 0 for failure, 1 for success. */
+
static int
-expect_msg (msgcode, msg_buf, from_tty)
- INT32 msgcode; /* Msg code we expect */
- union msg_t *msg_buf; /* Where to put the message received */
- int from_tty; /* Print message on error if non-zero */
+expect_msg (INT32 msgcode, union msg_t *msg_buf, int from_tty)
{
int retries = 0;
while (msg_recv_serial (msg_buf) && (retries++ < MAX_RETRIES));
* FIXME: Doesn't know anything about I_CACHE/D_CACHE.
*/
static int
-mm_memory_space (addr)
- CORE_ADDR *addr;
+mm_memory_space (CORE_ADDR *addr)
{
ADDR32 tstart = target_config.I_mem_start;
ADDR32 tend = tstart + target_config.I_mem_size;
mm_ops.to_thread_alive = 0;
mm_ops.to_stop = 0;
mm_ops.to_pid_to_exec_file = NULL;
- mm_ops.to_core_file_to_sym_file = NULL;
mm_ops.to_stratum = process_stratum;
mm_ops.DONT_USE = 0;
mm_ops.to_has_all_memory = 1;
};
void
-_initialize_remote_mm ()
+_initialize_remote_mm (void)
{
init_mm_ops ();
add_target (&mm_ops);
}
#ifdef NO_HIF_SUPPORT
-service_HIF (msg)
- union msg_t *msg;
+service_HIF (union msg_t *msg)
{
return (0); /* Emulate a failure */
}