Breakpoints work, run works. Fixed "monitor" command.

This commit is contained in:
Rob Savoye 1994-10-12 03:34:08 +00:00
parent 87fa4c38c2
commit 7804e5bc7c
4 changed files with 120 additions and 66 deletions

View File

@ -128,8 +128,9 @@ printf_monitor(va_alist)
fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
}
/* Read a character from the remote system, doing all the fancy
timeout stuff. */
/* readchar -- read a character from the remote system, doing all the fancy
* timeout stuff.
*/
static int
readchar(timeout)
int timeout;
@ -138,7 +139,7 @@ readchar(timeout)
c = SERIAL_READCHAR(monitor_desc, timeout);
if (sr_get_debug())
if (sr_get_debug() > 5)
putchar(c & 0x7f);
#ifdef LOG_FILE
@ -149,20 +150,19 @@ readchar(timeout)
if (c >= 0)
return c & 0x7f;
if (c == SERIAL_TIMEOUT)
{
if (timeout == 0)
return c; /* Polls shouldn't generate timeout errors */
error("Timeout reading from remote system.");
}
if (c == SERIAL_TIMEOUT) {
if (timeout == 0)
return c; /* Polls shouldn't generate timeout errors */
error("Timeout reading from remote system.");
}
perror_with_name("remote-monitor");
}
/* Scan input from the remote system, until STRING is found. If DISCARD is
non-zero, then discard non-matching input, else print it out.
Let the user break out immediately. */
/*
* expect -- scan input from the remote system, until STRING is found.
* If DISCARD is non-zero, then discard non-matching input, else print
* it out. Let the user break out immediately.
*/
static void
expect (string, discard)
char *string;
@ -363,9 +363,10 @@ monitor_create_inferior (execfile, args, env)
proceed ((CORE_ADDR)entry_pt, TARGET_SIGNAL_DEFAULT, 0);
}
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
/*
* monitor_open -- open a connection to a remote debugger.
* NAME is the filename used for communication.
*/
static int baudrate = 9600;
static char dev_name[100];
@ -421,7 +422,8 @@ monitor_open(args, name, from_tty)
}
/*
* _close -- Close out all files and local state before this target loses control.
* monitor_close -- Close out all files and local state before this
* target loses control.
*/
void
@ -431,6 +433,9 @@ monitor_close (quitting)
SERIAL_CLOSE(monitor_desc);
monitor_desc = NULL;
if (sr_get_debug() > 4)
puts ("\nmonitor_close ()");
#if defined (LOG_FILE)
if (log_file) {
if (ferror(log_file))
@ -441,20 +446,49 @@ monitor_close (quitting)
#endif
}
/* Terminate the open connection to the remote debugger.
Use this when you want to detach and do something else
with your gdb. */
/*
* monitor_detach -- terminate the open connection to the remote
* debugger. Use this when you want to detach and do something
* else with your gdb.
*/
void
monitor_detach (from_tty)
int from_tty;
{
#ifdef LOG_FILE
fprintf (log_file, "\nmonitor_detach ()\n");
#endif
pop_target(); /* calls monitor_close to do the real work */
if (from_tty)
printf ("Ending remote %s debugging\n", target_shortname);
}
/*
* _resume -- Tell the remote machine to resume.
* monitor_attach -- attach GDB to the target.
*/
void
monitor_attach (args, from_tty)
char *args;
int from_tty;
{
if (from_tty)
printf ("Starting remote %s debugging\n", target_shortname);
#ifdef LOG_FILE
fprintf (log_file, "\nmonitor_attach (args=%s)\n", args);
#endif
if (sr_get_debug() > 4)
printf ("\nmonitor_attach (args=%s)\n", args);
printf_monitor (GO_CMD);
/* swallow the echo. */
expect (GO_CMD, 1);
}
/*
* monitor_resume -- Tell the remote machine to resume.
*/
void
monitor_resume (pid, step, sig)
@ -462,21 +496,21 @@ monitor_resume (pid, step, sig)
enum target_signal sig;
{
#ifdef LOG_FILE
fprintf (log_file, "\nIn Resume (step=%d, sig=%d)\n", step, sig);
fprintf (log_file, "\nmonitor_resume (step=%d, sig=%d)\n", step, sig);
#endif
if (step)
{
printf_monitor (STEP_CMD);
/* wait for the echo. */
expect (STEP_CMD, 1);
}
else
{
printf_monitor (GO_CMD);
/* swallow the echo. */
expect (GO_CMD, 1);
}
if (sr_get_debug() > 4)
printf ("\nmonitor_resume (step=%d, sig=%d)\n", step, sig);
if (step) {
printf_monitor (STEP_CMD);
/* wait for the echo. */
expect (STEP_CMD, 1);
} else {
printf_monitor (CONT_CMD);
/* swallow the echo. */
expect (CONT_CMD, 1);
}
}
/*
@ -879,19 +913,22 @@ monitor_remove_breakpoint (addr, shadow)
#ifdef LOG_FILE
fprintf (log_file, "\nIn Remove_breakpoint (addr=%x)\n", addr);
#endif
for (i = 0; i < MAX_MONITOR_BREAKPOINTS; i++)
if (breakaddr[i] == addr)
{
breakaddr[i] = 0;
/* some monitors remove breakpoints based on the address */
if (strcasecmp (target_shortname, "bug") == 0)
printf_monitor(CLR_BREAK_CMD, addr);
else
printf_monitor(CLR_BREAK_CMD, i);
expect_prompt(1);
return 0;
}
if (sr_get_debug() > 4)
printf ("remove_breakpoint (addr=%x)\n", addr);
for (i = 0; i < MAX_MONITOR_BREAKPOINTS; i++) {
if (breakaddr[i] == addr) {
breakaddr[i] = 0;
/* some monitors remove breakpoints based on the address */
if (CLR_BREAK_ADDR)
printf_monitor(CLR_BREAK_CMD, addr);
else
printf_monitor(CLR_BREAK_CMD, i);
expect_prompt(1);
return 0;
}
}
fprintf(stderr, "Can't find breakpoint associated with 0x%x\n", addr);
return 1;
}
@ -953,24 +990,36 @@ monitor_load (arg)
fclose (download);
}
/* Put a command string, in args, out to MONITOR. Output from MONITOR is placed
on the users terminal until the prompt is seen. */
/*
* monitor_command -- put a command string, in args, out to MONITOR.
* Output from MONITOR is placed on the users terminal until the
* prompt is seen. FIXME: We read the charcters ourseleves here
* cause of a nasty echo.
*/
void
monitor_command (args, fromtty)
char *args;
int fromtty;
{
char *p;
char c, cp;
p = PROMPT;
#ifdef LOG_FILE
fprintf (log_file, "\nIn command (args=%s)\n", args);
fprintf (log_file, "\nmonitor_command (args=%s)\n", args);
#endif
if (monitor_desc == NULL)
error("monitor target not open.");
if (!args)
error("Missing command.");
printf_monitor("%s\r", args);
if (sr_get_debug() > 4)
printf ("monitor_command (args=%s)\n", args);
printf_monitor ("%s\n", args);
expect_prompt(0);
}

View File

@ -36,6 +36,7 @@ struct monitor_ops {
char *step; /* single step */
char *set_break; /* set a breakpoint */
char *clr_break; /* clear a breakpoint */
int clr_type; /* number or address for clearing */
struct rom_cmd_data setmem; /* set memory to a value */
struct rom_cmd_data getmem; /* display memory */
struct rom_cmd_data regset; /* set a register */
@ -59,6 +60,7 @@ extern struct monitor_ops *current_monitor;
#define STEP_CMD (current_monitor->step)
#define SET_BREAK_CMD (current_monitor->set_break)
#define CLR_BREAK_CMD (current_monitor->clr_break)
#define CLR_BREAK_ADDR (current_monitor->clr_type)
#define SET_MEM (current_monitor->setmem)
#define GET_MEM (current_monitor->getmem)
#define LOAD_CMD (current_monitor->load)
@ -79,6 +81,7 @@ extern struct monitor_ops *current_monitor;
extern void monitor_open();
extern void monitor_close();
extern void monitor_detach();
extern void monitor_attach();
extern void monitor_resume();
extern int monitor_wait();
extern void monitor_fetch_register();

View File

@ -20,7 +20,7 @@ static char *op50n_regnames[] = {
"r7_s11 ", "r8_s10 ", "r9_s9 ", "r10_s8 ", "r11_s7 ", "r12_s6 ", "r13_s5 ",
"r14_s4 ", "r15_s3 ", "r16_s2 ", "r17_s1 ", "r18_s0 ", "r19_t4 ", "r20_t3 ",
"r21_t2 ", "r22_t1 ", "r23_a3 ", "r24_a2 ", "r25_a1 ", "r26_a0 ", "r27_dp ",
"r28_v0 ", "r29_v1 ", "r30_sp ", "r31_t5 ", "", "", "",
"r28_v0 ", "r29_v1 ", "r30_sp ", "r31_t5 ", "", "p", "",
"", "", "", "", "", "", "",
"", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
@ -88,11 +88,12 @@ Specify the serial device it is connected to (e.g. /dev/ttya).",
struct monitor_ops op50n_cmds = {
1, /* 1 for ASCII, 0 for binary */
".\n", /* monitor init string */
"", /* execute or usually GO command */
"g %x", /* execute or usually GO command */
"", /* continue command */
"", /* single step */
"", /* set a breakpoint */
"b %x\n", /* set a breakpoint */
"", /* clear a breakpoint */
1, /* 0 for number, 1 for address */
{
"sx %x %x;.\n", /* set memory */
"", /* delimiter */

View File

@ -18,7 +18,7 @@ static char *w89k_regnames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
"r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
"r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29",
"r30", "r31", "sar", "", "", "", "",
"r30", "r31", "sar", "pc", "", "", "",
"eiem", "iir", "iva", "ior", "ipsw","", "", "", "", "",
"", "", "", "", "", "", "", "ccr", "", "",
"tr0", "tr1", "", "", "", "", "",
@ -45,7 +45,7 @@ struct target_ops w89k_ops = {
Specify the serial device it is connected to (e.g. /dev/ttya).",
w89k_open,
monitor_close,
0,
monitor_attach,
monitor_detach,
monitor_resume,
monitor_wait,
@ -82,12 +82,13 @@ Specify the serial device it is connected to (e.g. /dev/ttya).",
struct monitor_ops w89k_cmds = {
1, /* 1 for ASCII, 0 for binary */
"\r", /* monitor init string */
"G = 100000\r", /* execute or usually GO command */
"G\r", /* continue command */
"T\r", /* single step */
"BP %x\r", /* set a breakpoint */
"BC %x\r", /* clear a breakpoint */
"\n", /* monitor init string */
"g = %x\n", /* execute or usually GO command */
"g\n", /* continue command */
"t\n", /* single step */
"bp %x\n", /* set a breakpoint */
"bc %x\n", /* clear a breakpoint */
0, /* 0 for number, 1 for address */
{
"e %x %x\n", /* set memory */
"", /* delimiter */
@ -111,7 +112,7 @@ struct monitor_ops w89k_cmds = {
"U\r", /* download command */
"ROM>", /* monitor command prompt */
"", /* end-of-command delimitor */
"", /* optional command terminator */
"", /* optional command terminator */
&w89k_ops, /* target operations */
"xmodem-srec,xmodem-som", /* load types */
w89k_regnames /* registers names */