/* Offset of member MEMBER in a struct of type TYPE. */
#define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
-/* #define DEBUG 1 /* */
-#ifdef DEBUG
-# define DENTER(NAME) (printf("Entering %s\n",NAME), fflush(stdout))
-# define DEXIT(NAME) (printf("Exiting %s\n",NAME), fflush(stdout))
-#else
-# define DENTER(NAME)
-# define DEXIT(NAME)
-#endif
-
#define DRAIN_INPUT() (msg_recv_serial((union msg_t*)0))
extern int stop_soon_quietly; /* for wait_for_inferior */
static void mm_resume();
static void mm_fetch_registers ();
static int fetch_register ();
-static int mm_store_registers ();
+static void mm_store_registers ();
static int store_register ();
static int regnum_to_srnum();
static void mm_close ();
static void init_target_mm();
static int mm_memory_space();
-/*
- * Processor types.
- */
-#define TYPE_UNKNOWN 0
-#define TYPE_A29000 1
-#define TYPE_A29030 2
-#define TYPE_A29050 3
-static char *processor_name[] = { "Unknown", "A29000", "A29030", "A29050" };
-static int processor_type=TYPE_UNKNOWN;
#define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400)
-#define USE_SHADOW_PC ((processor_type == TYPE_A29050) && FREEZE_MODE)
+#define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
+/* FIXME: Replace with `set remotedebug'. */
#define LLOG_FILE "minimon.log"
#if defined (LOG_FILE)
FILE *log_file;
char *token[MAX_TOKENS];
char cmd_line[BUFFER_SIZE];
- DENTER("mm_create_inferior()");
-
if (args && *args)
error ("Can't pass arguments to remote mm process (yet).");
Assuming you are at NYU debuging a kernel, i.e., no need to download.\n\n");
/* We will get a task spawn event immediately. */
-#ifdef NOTDEF /* start_remote() now does a wait without a resume
- so don't use it*/
- start_remote ();
-#else
init_wait_for_inferior ();
clear_proceed_status ();
stop_soon_quietly = 1;
- proceed(-1,-1,0);
+ proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
normal_stop ();
-#endif
- DEXIT("mm_create_inferior()");
}
/**************************************************** REMOTE_MOURN_INFERIOR */
static void
mm_mourn()
{
- DENTER("mm_mourn()");
pop_target (); /* Pop back to no-child state */
generic_mourn_inferior ();
- DEXIT("mm_mourn()");
}
/********************************************************************** damn_b
unsigned int prl;
char *p;
- DENTER("mm_open()");
-
/* Find the first whitespace character, it separates dev_name from
prog_name. */
for (p = name;
expect_msg(CONFIG,in_msg_buf,1);
- /* Determine the processor revision level */
- /* FIXME: this code is the same as in remote-adapt.c */
- prl = (unsigned int)read_register(CFG_REGNUM) >> 24;
- if (prl == 0x03) {
- processor_type = TYPE_A29000;
- } else if ((prl&0xf0) == 0x40) { /* 29030 = 0x4* */
- processor_type = TYPE_A29030;
- fprintf_filtered(stderr,"WARNING: debugging of A29030 not tested.\n");
- } else if ((prl&0xf0) == 0x20) { /* 29050 = 0x2* */
- processor_type = TYPE_A29050;
- fprintf_filtered(stderr,"WARNING: debugging of A29050 not tested.\n");
- } else {
- processor_type = TYPE_UNKNOWN;
- fprintf_filtered(stderr,"WARNING: processor type unknown.\n");
- }
+ a29k_get_processor_type ();
/* Print out some stuff, letting the user now what's going on */
- printf_filtered("Remote debugging on an %s connect to MiniMon via %s.\n",
- processor_name[processor_type],dev_name);
+ printf_filtered("Connected to MiniMon via %s.\n", dev_name);
/* FIXME: can this restriction be removed? */
printf_filtered("Remote debugging using virtual addresses works only\n");
printf_filtered("\twhen virtual addresses map 1:1 to physical addresses.\n")
;
- if (processor_type != TYPE_A29050) {
+ if (processor_type != a29k_freeze_mode) {
fprintf_filtered(stderr,
"Freeze-mode debugging not available, and can only be done on an A29050.\n");
}
out_msg_buf->go_msg.length = 0;
msg_send_serial(out_msg_buf);
/* No message to expect after a GO */
-
- DEXIT("mm_open()");
}
/**************************************************************** REMOTE_CLOSE
mm_close (quitting) /*FIXME: how is quitting used */
int quitting;
{
- DENTER("mm_close()");
-
if (mm_desc < 0)
error ("Can't close remote connection: not debugging remotely.");
#endif
printf ("Ending remote debugging\n");
-
- DEXIT("mm_close()");
-
}
/************************************************************* REMOTE_ATACH */
int from_tty;
{
- DENTER("mm_attach()");
-
if (!mm_stream)
- printf ("MiniMon not opened yet, use the 'target minimon' command.\n");
+ error ("MiniMon not opened yet, use the 'target minimon' command.\n");
- dont_repeat();
-
if (from_tty)
printf ("Attaching to remote program %s...\n", prog_name);
-
/* Make sure the target is currently running, it is supposed to be. */
/* FIXME: is it ok to send MiniMon a BREAK if it is already stopped in
* the dbg core. If so, we don't need to send this GO.
out_msg_buf->break_msg.code = BREAK;
out_msg_buf->break_msg.length = 0;
msg_send_serial(out_msg_buf);
-
- mark_breakpoints_out ();
- init_wait_for_inferior ();
- clear_proceed_status ();
- stop_soon_quietly = 1;
- wait_for_inferior ();
- stop_soon_quietly = 0;
- normal_stop ();
-
- DEXIT("mm_attach()");
}
/********************************************************** REMOTE_DETACH */
/* Terminate the open connection to the remote debugger.
char *args;
int from_tty;
{
- DENTER("mm_dettach()");
remove_breakpoints(); /* Just in case there were any left in */
out_msg_buf->go_msg.code = GO;
out_msg_buf->go_msg.length = 0;
msg_send_serial(out_msg_buf);
pop_target(); /* calls mm_close to do the real work */
- DEXIT("mm_dettach()");
}
** Tell the remote machine to resume. */
static void
-mm_resume (step, sig)
- int step, sig;
+mm_resume (pid, step, sig)
+ int pid, step;
+ enum target_signal sig;
{
- DENTER("mm_resume()");
-
- if (sig)
- error ("Can't send signals to a remote MiniMon system.");
+ if (sig != TARGET_SIGNAL_0)
+ warning ("Can't send signals to a remote MiniMon system.");
if (step) {
out_msg_buf->step_msg.code= STEP;
out_msg_buf->go_msg.length = 0;
msg_send_serial(out_msg_buf);
}
-
- DEXIT("mm_resume()");
}
/***************************************************************** REMOTE_WAIT
static int
mm_wait (status)
- WAITTYPE *status;
+ struct target_waitstatus *status;
{
int i, result;
int old_timeout = timeout;
int old_immediate_quit = immediate_quit;
- DENTER("mm_wait()");
- WSETEXIT ((*status), 0);
-
+ status->kind = TARGET_WAITKIND_EXITED;
+ status->value.integer = 0;
/* wait for message to arrive. It should be:
- A HIF service request.
i=in_msg_buf->channel1_msg.length;
in_msg_buf->channel1_msg.data[i] = '\0';
printf("%s", in_msg_buf->channel1_msg.data);
- fflush(stdout);
+ gdb_flush(stdout);
/* Send CHANNEL1_ACK message */
out_msg_buf->channel1_ack_msg.code = CHANNEL1_ACK;
out_msg_buf->channel1_ack_msg.length = 0;
if (in_msg_buf->halt_msg.trap_number== 0)
{ printf("Am290*0 received vector number %d (break point)\n",
in_msg_buf->halt_msg.trap_number);
- WSETSTOP ((*status), SIGTRAP);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_TRAP;
}
else if (in_msg_buf->halt_msg.trap_number== 1)
- { printf("Am290*0 received vector number %d\n",
- in_msg_buf->halt_msg.trap_number);
- WSETSTOP ((*status), SIGBUS);
- }
+ {
+ printf("Am290*0 received vector number %d\n",
+ in_msg_buf->halt_msg.trap_number);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_BUS;
+ }
else if (in_msg_buf->halt_msg.trap_number== 3
|| in_msg_buf->halt_msg.trap_number== 4)
{ printf("Am290*0 received vector number %d\n",
in_msg_buf->halt_msg.trap_number);
- WSETSTOP ((*status), SIGFPE);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_FPE;
}
else if (in_msg_buf->halt_msg.trap_number== 5)
{ printf("Am290*0 received vector number %d\n",
in_msg_buf->halt_msg.trap_number);
- WSETSTOP ((*status), SIGILL);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_ILL;
}
else if (in_msg_buf->halt_msg.trap_number >= 6
&& in_msg_buf->halt_msg.trap_number <= 11)
{ printf("Am290*0 received vector number %d\n",
in_msg_buf->halt_msg.trap_number);
- WSETSTOP ((*status), SIGSEGV);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_SEGV;
}
else if (in_msg_buf->halt_msg.trap_number== 12
|| in_msg_buf->halt_msg.trap_number== 13)
{ printf("Am290*0 received vector number %d\n",
in_msg_buf->halt_msg.trap_number);
- WSETSTOP ((*status), SIGILL);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_ILL;
}
else if (in_msg_buf->halt_msg.trap_number== 14)
{ printf("Am290*0 received vector number %d\n",
in_msg_buf->halt_msg.trap_number);
- WSETSTOP ((*status), SIGALRM);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_ALRM;
}
else if (in_msg_buf->halt_msg.trap_number== 15)
- WSETSTOP ((*status), SIGTRAP);
+ {
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_TRAP;
+ }
else if (in_msg_buf->halt_msg.trap_number >= 16
&& in_msg_buf->halt_msg.trap_number <= 21)
{ printf("Am290*0 received vector number %d\n",
in_msg_buf->halt_msg.trap_number);
- WSETSTOP ((*status), SIGINT);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_INT;
}
else if (in_msg_buf->halt_msg.trap_number== 22)
{ printf("Am290*0 received vector number %d\n",
in_msg_buf->halt_msg.trap_number);
- WSETSTOP ((*status), SIGILL);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_ILL;
} /* BREAK message was sent */
else if (in_msg_buf->halt_msg.trap_number== 75)
- WSETSTOP ((*status), SIGTRAP);
+ {
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_TRAP;
+ }
else
exit:
- WSETEXIT ((*status), 0);
+ {
+ status->kind = TARGET_WAITKIND_EXITED;
+ status->value.integer = 0;
+ }
timeout = old_timeout; /* Restore original timeout value */
immediate_quit = old_immediate_quit;
- DEXIT("mm_wait()");
return 0;
}
return;
}
- DENTER("mm_fetch_registers()");
-
/* Gr1/rsp */
out_msg_buf->read_req_msg.byte_count = 4*1;
out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
{
int val = -1;
supply_register (FPE_REGNUM, &val);
- supply_register (INT_REGNUM, &val);
+ supply_register (INTE_REGNUM, &val);
supply_register (FPS_REGNUM, &val);
supply_register (EXO_REGNUM, &val);
}
-
- DEXIT("mm_fetch_registerS()");
}
* Result is 0 for success, -1 for failure.
*/
-static int
+static void
mm_store_registers (regno)
int regno;
{
int result;
- if (regno >= 0)
- return(store_register(regno));
+ if (regno >= 0) {
+ store_register(regno);
+ return;
+ }
- DENTER("mm_store_registers()");
result = 0;
out_msg_buf->write_r_msg.code= WRITE_REQ;
}
registers_changed ();
- DEXIT("mm_store_registers()");
- return result;
}
/*************************************************** REMOTE_PREPARE_TO_STORE */
CORE_ADDR addr;
char *contents_cache;
{
- DENTER("mm_insert_breakpoint()");
out_msg_buf->bkpt_set_msg.code = BKPT_SET;
out_msg_buf->bkpt_set_msg.length = 4*4;
out_msg_buf->bkpt_set_msg.memory_space = I_MEM;
out_msg_buf->bkpt_set_msg.bkpt_type = -1; /* use illop for 29000 */
msg_send_serial( out_msg_buf);
if (expect_msg(BKPT_SET_ACK,in_msg_buf,1)) {
- DEXIT("mm_insert_breakpoint() success");
return 0; /* Success */
} else {
- DEXIT("mm_insert_breakpoint() failure");
return 1; /* Failure */
}
}
CORE_ADDR addr;
char *contents_cache;
{
- DENTER("mm_remove_breakpoint()");
out_msg_buf->bkpt_rm_msg.code = BKPT_RM;
out_msg_buf->bkpt_rm_msg.length = 4*3;
out_msg_buf->bkpt_rm_msg.memory_space = I_MEM;
out_msg_buf->bkpt_rm_msg.bkpt_addr = (ADDR32) addr;
msg_send_serial( out_msg_buf);
if (expect_msg(BKPT_RM_ACK,in_msg_buf,1)) {
- DEXIT("mm_remove_breakpoint()");
return 0; /* Success */
} else {
- DEXIT("mm_remove_breakpoint()");
return 1; /* Failure */
}
}
{
char buf[4];
- DENTER("mm_kill()");
#if defined(KERNEL_DEBUGGING)
/* We don't ever kill the kernel */
if (from_tty) {
}
pop_target();
#endif
- DEXIT("mm_kill()");
}
/* You may need to do an init_target_mm() */
/* init_target_mm(?,?,?,?,?,?,?,?); */
immediate_quit--;
- /* (void) symbol_file_add (arg_string, from_tty, text_addr, 0, 0); */
+ /* symbol_file_add (arg_string, from_tty, text_addr, 0, 0); */
#endif
}
{
int i,nwritten;
- /* DENTER("mm_write_inferior_memory()"); */
out_msg_buf->write_req_msg.code= WRITE_REQ;
out_msg_buf->write_req_msg.memory_space = mm_memory_space(memaddr);
break;
}
}
- /* DEXIT("mm_write_inferior_memory()"); */
return(nwritten);
}
{
int i,nread;
- /* DENTER("mm_read_inferior_memory()"); */
out_msg_buf->read_req_msg.code= READ_REQ;
out_msg_buf->read_req_msg.memory_space = mm_memory_space(memaddr);
int regno;
{
int result;
- DENTER("mm_fetch_register()");
out_msg_buf->read_req_msg.code= READ_REQ;
out_msg_buf->read_req_msg.length = 4*3;
out_msg_buf->read_req_msg.byte_count = 4;
} else {
result = -1;
}
- DEXIT("mm_fetch_register()");
return result;
}
/*****************************************************************************/
{
int result;
- DENTER("store_register()");
out_msg_buf->write_req_msg.code= WRITE_REQ;
out_msg_buf->write_req_msg.length = 4*4;
out_msg_buf->write_req_msg.byte_count = 4;
} else {
result = -1;
}
- DEXIT("store_register()");
return result;
}
/****************************************************************************/
case FC_REGNUM: return(134);
case CR_REGNUM: return(135);
case FPE_REGNUM: return(160);
- case INT_REGNUM: return(161);
+ case INTE_REGNUM: return(161);
case FPS_REGNUM: return(162);
case EXO_REGNUM:return(164);
default:
union msg_t *msg_buf; /* Where to put the message received */
int from_tty; /* Print message on error if non-zero */
{
- /* DENTER("expect_msg()"); */
int retries=0;
while(msg_recv_serial(msg_buf) && (retries++<MAX_RETRIES));
if (retries >= MAX_RETRIES) {
printf("Expected msg %s, ",msg_str(msgcode));
printf("no message received!\n");
- /* DEXIT("expect_msg() failure"); */
return(0); /* Failure */
}
if (msg_buf->generic_msg.code == ERROR)
printf("%s\n",error_msg_str(msg_buf->error_msg.error_code));
}
- /* DEXIT("expect_msg() failure"); */
return(0); /* Failure */
}
- /* DEXIT("expect_msg() success"); */
return(1); /* Success */
}
/****************************************************************************/
mm_open, mm_close,
mm_attach, mm_detach, mm_resume, mm_wait,
mm_fetch_registers, mm_store_registers,
- mm_prepare_to_store, 0, 0, /* conv_to, conv_from */
+ mm_prepare_to_store,
mm_xfer_inferior_memory,
mm_files_info,
mm_insert_breakpoint, mm_remove_breakpoint, /* Breakpoints */
0, /* lookup_symbol */
mm_create_inferior, /* create_inferior */
mm_mourn, /* mourn_inferior FIXME */
+ 0, /* can_run */
+ 0, /* notice_signals */
+ 0, /* to_stop */
process_stratum, 0, /* next */
1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
0,0, /* sections, sections_end */