Breakpoints work, run works. Fixed "monitor" command.
This commit is contained in:
parent
87fa4c38c2
commit
7804e5bc7c
121
gdb/monitor.c
121
gdb/monitor.c
|
@ -128,8 +128,9 @@ printf_monitor(va_alist)
|
||||||
fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
|
fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read a character from the remote system, doing all the fancy
|
/* readchar -- read a character from the remote system, doing all the fancy
|
||||||
timeout stuff. */
|
* timeout stuff.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
readchar(timeout)
|
readchar(timeout)
|
||||||
int timeout;
|
int timeout;
|
||||||
|
@ -138,7 +139,7 @@ readchar(timeout)
|
||||||
|
|
||||||
c = SERIAL_READCHAR(monitor_desc, timeout);
|
c = SERIAL_READCHAR(monitor_desc, timeout);
|
||||||
|
|
||||||
if (sr_get_debug())
|
if (sr_get_debug() > 5)
|
||||||
putchar(c & 0x7f);
|
putchar(c & 0x7f);
|
||||||
|
|
||||||
#ifdef LOG_FILE
|
#ifdef LOG_FILE
|
||||||
|
@ -149,20 +150,19 @@ readchar(timeout)
|
||||||
if (c >= 0)
|
if (c >= 0)
|
||||||
return c & 0x7f;
|
return c & 0x7f;
|
||||||
|
|
||||||
if (c == SERIAL_TIMEOUT)
|
if (c == SERIAL_TIMEOUT) {
|
||||||
{
|
|
||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
return c; /* Polls shouldn't generate timeout errors */
|
return c; /* Polls shouldn't generate timeout errors */
|
||||||
|
|
||||||
error("Timeout reading from remote system.");
|
error("Timeout reading from remote system.");
|
||||||
}
|
}
|
||||||
|
|
||||||
perror_with_name("remote-monitor");
|
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.
|
* expect -- scan input from the remote system, until STRING is found.
|
||||||
Let the user break out immediately. */
|
* If DISCARD is non-zero, then discard non-matching input, else print
|
||||||
|
* it out. Let the user break out immediately.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
expect (string, discard)
|
expect (string, discard)
|
||||||
char *string;
|
char *string;
|
||||||
|
@ -363,9 +363,10 @@ monitor_create_inferior (execfile, args, env)
|
||||||
proceed ((CORE_ADDR)entry_pt, TARGET_SIGNAL_DEFAULT, 0);
|
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 int baudrate = 9600;
|
||||||
static char dev_name[100];
|
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
|
void
|
||||||
|
@ -431,6 +433,9 @@ monitor_close (quitting)
|
||||||
SERIAL_CLOSE(monitor_desc);
|
SERIAL_CLOSE(monitor_desc);
|
||||||
monitor_desc = NULL;
|
monitor_desc = NULL;
|
||||||
|
|
||||||
|
if (sr_get_debug() > 4)
|
||||||
|
puts ("\nmonitor_close ()");
|
||||||
|
|
||||||
#if defined (LOG_FILE)
|
#if defined (LOG_FILE)
|
||||||
if (log_file) {
|
if (log_file) {
|
||||||
if (ferror(log_file))
|
if (ferror(log_file))
|
||||||
|
@ -441,20 +446,49 @@ monitor_close (quitting)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the open connection to the remote debugger.
|
/*
|
||||||
Use this when you want to detach and do something else
|
* monitor_detach -- terminate the open connection to the remote
|
||||||
with your gdb. */
|
* debugger. Use this when you want to detach and do something
|
||||||
|
* else with your gdb.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
monitor_detach (from_tty)
|
monitor_detach (from_tty)
|
||||||
int 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 */
|
pop_target(); /* calls monitor_close to do the real work */
|
||||||
if (from_tty)
|
if (from_tty)
|
||||||
printf ("Ending remote %s debugging\n", target_shortname);
|
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
|
void
|
||||||
monitor_resume (pid, step, sig)
|
monitor_resume (pid, step, sig)
|
||||||
|
@ -462,20 +496,20 @@ monitor_resume (pid, step, sig)
|
||||||
enum target_signal sig;
|
enum target_signal sig;
|
||||||
{
|
{
|
||||||
#ifdef LOG_FILE
|
#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
|
#endif
|
||||||
|
|
||||||
if (step)
|
if (sr_get_debug() > 4)
|
||||||
{
|
printf ("\nmonitor_resume (step=%d, sig=%d)\n", step, sig);
|
||||||
|
|
||||||
|
if (step) {
|
||||||
printf_monitor (STEP_CMD);
|
printf_monitor (STEP_CMD);
|
||||||
/* wait for the echo. */
|
/* wait for the echo. */
|
||||||
expect (STEP_CMD, 1);
|
expect (STEP_CMD, 1);
|
||||||
}
|
} else {
|
||||||
else
|
printf_monitor (CONT_CMD);
|
||||||
{
|
|
||||||
printf_monitor (GO_CMD);
|
|
||||||
/* swallow the echo. */
|
/* swallow the echo. */
|
||||||
expect (GO_CMD, 1);
|
expect (CONT_CMD, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,19 +913,22 @@ monitor_remove_breakpoint (addr, shadow)
|
||||||
#ifdef LOG_FILE
|
#ifdef LOG_FILE
|
||||||
fprintf (log_file, "\nIn Remove_breakpoint (addr=%x)\n", addr);
|
fprintf (log_file, "\nIn Remove_breakpoint (addr=%x)\n", addr);
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < MAX_MONITOR_BREAKPOINTS; i++)
|
|
||||||
if (breakaddr[i] == addr)
|
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;
|
breakaddr[i] = 0;
|
||||||
/* some monitors remove breakpoints based on the address */
|
/* some monitors remove breakpoints based on the address */
|
||||||
if (strcasecmp (target_shortname, "bug") == 0)
|
if (CLR_BREAK_ADDR)
|
||||||
printf_monitor(CLR_BREAK_CMD, addr);
|
printf_monitor(CLR_BREAK_CMD, addr);
|
||||||
else
|
else
|
||||||
printf_monitor(CLR_BREAK_CMD, i);
|
printf_monitor(CLR_BREAK_CMD, i);
|
||||||
expect_prompt(1);
|
expect_prompt(1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fprintf(stderr, "Can't find breakpoint associated with 0x%x\n", addr);
|
fprintf(stderr, "Can't find breakpoint associated with 0x%x\n", addr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -953,16 +990,24 @@ monitor_load (arg)
|
||||||
fclose (download);
|
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
|
void
|
||||||
monitor_command (args, fromtty)
|
monitor_command (args, fromtty)
|
||||||
char *args;
|
char *args;
|
||||||
int fromtty;
|
int fromtty;
|
||||||
{
|
{
|
||||||
|
|
||||||
|
char *p;
|
||||||
|
char c, cp;
|
||||||
|
p = PROMPT;
|
||||||
|
|
||||||
#ifdef LOG_FILE
|
#ifdef LOG_FILE
|
||||||
fprintf (log_file, "\nIn command (args=%s)\n", args);
|
fprintf (log_file, "\nmonitor_command (args=%s)\n", args);
|
||||||
#endif
|
#endif
|
||||||
if (monitor_desc == NULL)
|
if (monitor_desc == NULL)
|
||||||
error("monitor target not open.");
|
error("monitor target not open.");
|
||||||
|
@ -970,7 +1015,11 @@ monitor_command (args, fromtty)
|
||||||
if (!args)
|
if (!args)
|
||||||
error("Missing command.");
|
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);
|
expect_prompt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ struct monitor_ops {
|
||||||
char *step; /* single step */
|
char *step; /* single step */
|
||||||
char *set_break; /* set a breakpoint */
|
char *set_break; /* set a breakpoint */
|
||||||
char *clr_break; /* clear 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 setmem; /* set memory to a value */
|
||||||
struct rom_cmd_data getmem; /* display memory */
|
struct rom_cmd_data getmem; /* display memory */
|
||||||
struct rom_cmd_data regset; /* set a register */
|
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 STEP_CMD (current_monitor->step)
|
||||||
#define SET_BREAK_CMD (current_monitor->set_break)
|
#define SET_BREAK_CMD (current_monitor->set_break)
|
||||||
#define CLR_BREAK_CMD (current_monitor->clr_break)
|
#define CLR_BREAK_CMD (current_monitor->clr_break)
|
||||||
|
#define CLR_BREAK_ADDR (current_monitor->clr_type)
|
||||||
#define SET_MEM (current_monitor->setmem)
|
#define SET_MEM (current_monitor->setmem)
|
||||||
#define GET_MEM (current_monitor->getmem)
|
#define GET_MEM (current_monitor->getmem)
|
||||||
#define LOAD_CMD (current_monitor->load)
|
#define LOAD_CMD (current_monitor->load)
|
||||||
|
@ -79,6 +81,7 @@ extern struct monitor_ops *current_monitor;
|
||||||
extern void monitor_open();
|
extern void monitor_open();
|
||||||
extern void monitor_close();
|
extern void monitor_close();
|
||||||
extern void monitor_detach();
|
extern void monitor_detach();
|
||||||
|
extern void monitor_attach();
|
||||||
extern void monitor_resume();
|
extern void monitor_resume();
|
||||||
extern int monitor_wait();
|
extern int monitor_wait();
|
||||||
extern void monitor_fetch_register();
|
extern void monitor_fetch_register();
|
||||||
|
|
|
@ -20,7 +20,7 @@ static char *op50n_regnames[] = {
|
||||||
"r7_s11 ", "r8_s10 ", "r9_s9 ", "r10_s8 ", "r11_s7 ", "r12_s6 ", "r13_s5 ",
|
"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 ",
|
"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 ",
|
"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 = {
|
struct monitor_ops op50n_cmds = {
|
||||||
1, /* 1 for ASCII, 0 for binary */
|
1, /* 1 for ASCII, 0 for binary */
|
||||||
".\n", /* monitor init string */
|
".\n", /* monitor init string */
|
||||||
"", /* execute or usually GO command */
|
"g %x", /* execute or usually GO command */
|
||||||
"", /* continue command */
|
"", /* continue command */
|
||||||
"", /* single step */
|
"", /* single step */
|
||||||
"", /* set a breakpoint */
|
"b %x\n", /* set a breakpoint */
|
||||||
"", /* clear a breakpoint */
|
"", /* clear a breakpoint */
|
||||||
|
1, /* 0 for number, 1 for address */
|
||||||
{
|
{
|
||||||
"sx %x %x;.\n", /* set memory */
|
"sx %x %x;.\n", /* set memory */
|
||||||
"", /* delimiter */
|
"", /* delimiter */
|
||||||
|
|
|
@ -18,7 +18,7 @@ static char *w89k_regnames[] = {
|
||||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
|
||||||
"r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
|
"r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
|
||||||
"r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29",
|
"r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29",
|
||||||
"r30", "r31", "sar", "", "", "", "",
|
"r30", "r31", "sar", "pc", "", "", "",
|
||||||
"eiem", "iir", "iva", "ior", "ipsw","", "", "", "", "",
|
"eiem", "iir", "iva", "ior", "ipsw","", "", "", "", "",
|
||||||
"", "", "", "", "", "", "", "ccr", "", "",
|
"", "", "", "", "", "", "", "ccr", "", "",
|
||||||
"tr0", "tr1", "", "", "", "", "",
|
"tr0", "tr1", "", "", "", "", "",
|
||||||
|
@ -45,7 +45,7 @@ struct target_ops w89k_ops = {
|
||||||
Specify the serial device it is connected to (e.g. /dev/ttya).",
|
Specify the serial device it is connected to (e.g. /dev/ttya).",
|
||||||
w89k_open,
|
w89k_open,
|
||||||
monitor_close,
|
monitor_close,
|
||||||
0,
|
monitor_attach,
|
||||||
monitor_detach,
|
monitor_detach,
|
||||||
monitor_resume,
|
monitor_resume,
|
||||||
monitor_wait,
|
monitor_wait,
|
||||||
|
@ -82,12 +82,13 @@ Specify the serial device it is connected to (e.g. /dev/ttya).",
|
||||||
|
|
||||||
struct monitor_ops w89k_cmds = {
|
struct monitor_ops w89k_cmds = {
|
||||||
1, /* 1 for ASCII, 0 for binary */
|
1, /* 1 for ASCII, 0 for binary */
|
||||||
"\r", /* monitor init string */
|
"\n", /* monitor init string */
|
||||||
"G = 100000\r", /* execute or usually GO command */
|
"g = %x\n", /* execute or usually GO command */
|
||||||
"G\r", /* continue command */
|
"g\n", /* continue command */
|
||||||
"T\r", /* single step */
|
"t\n", /* single step */
|
||||||
"BP %x\r", /* set a breakpoint */
|
"bp %x\n", /* set a breakpoint */
|
||||||
"BC %x\r", /* clear a breakpoint */
|
"bc %x\n", /* clear a breakpoint */
|
||||||
|
0, /* 0 for number, 1 for address */
|
||||||
{
|
{
|
||||||
"e %x %x\n", /* set memory */
|
"e %x %x\n", /* set memory */
|
||||||
"", /* delimiter */
|
"", /* delimiter */
|
||||||
|
|
Loading…
Reference in New Issue