aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/monitor.c116
-rw-r--r--gdb/sh3-rom.c17
3 files changed, 112 insertions, 29 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8038a68..be7a49a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
Tue Oct 24 12:26:14 1995 Stu Grossman (grossman@cygnus.com)
+ * monitor.c (monitor_expect_regexp): Same as monitor_expect, but
+ with the obvious extension. (monitor_read_memory_single): Use
+ regexp for getmem.resp_delim because of parsing ambiguities caused
+ by certain monitors. (monitor_read_memory): Use new regexp stuff
+ to parse getmem.resp_delim.
+ * sh3-rom.c: Finish off table. Use new regexp capability for
+ getmem commands.
+
* infrun.c (wait_for_inferior): Disable questionable code near
the step range test. Replace call detection test with much
simpler (and more efficient) test that doesn't require prologue
diff --git a/gdb/monitor.c b/gdb/monitor.c
index 782f8bc..5b83ddb 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -106,13 +106,10 @@ static serial_t monitor_desc = NULL;
/* Pointer to regexp pattern matching data */
static struct re_pattern_buffer register_pattern;
+static char register_fastmap[256];
-/* Element 0 points to start of register name, and element 1 points to the
- start of the register value. */
-
-static struct re_registers register_strings;
-
-static char fastmap[256];
+static struct re_pattern_buffer getmem_resp_delim_pattern;
+static char getmem_resp_delim_fastmap[256];
static int dump_reg_flag; /* Non-zero means do a dump_registers cmd when
monitor_wait wakes up. */
@@ -275,6 +272,8 @@ monitor_expect (string, buf, buflen)
}
c = readchar (timeout);
+ if (c == '\000')
+ continue;
*buf++ = c;
buflen--;
}
@@ -305,6 +304,48 @@ monitor_expect (string, buf, buflen)
}
}
+/* Search for a regexp. */
+
+int
+monitor_expect_regexp (pat, buf, buflen)
+ struct re_pattern_buffer *pat;
+ char *buf;
+ int buflen;
+{
+ char *mybuf;
+ char *p;
+
+ if (buf)
+ mybuf = buf;
+ else
+ {
+ mybuf = alloca (1024);
+ buflen = 1024;
+ }
+
+ p = mybuf;
+ while (1)
+ {
+ int retval;
+
+ if (p - mybuf >= buflen)
+ { /* Buffer about to overflow */
+
+/* On overflow, we copy the upper half of the buffer to the lower half. Not
+ great, but it usually works... */
+
+ memcpy (mybuf, mybuf + buflen / 2, buflen / 2);
+ p = mybuf + buflen / 2;
+ }
+
+ *p++ = readchar (timeout);
+
+ retval = re_search (pat, mybuf, p - mybuf, 0, p - mybuf, NULL);
+ if (retval >= 0)
+ return 1;
+ }
+}
+
/* Keep discarding input until we see the MONITOR prompt.
The convention for dealing with the prompt is that you
@@ -355,6 +396,30 @@ get_hex_word ()
return val;
}
+static void
+compile_pattern (pattern, compiled_pattern, fastmap)
+ char *pattern;
+ struct re_pattern_buffer *compiled_pattern;
+ char *fastmap;
+{
+ int tmp;
+ char *val;
+
+ compiled_pattern->fastmap = fastmap;
+
+ tmp = re_set_syntax (RE_SYNTAX_EMACS);
+ val = re_compile_pattern (pattern,
+ strlen (pattern),
+ compiled_pattern);
+ re_set_syntax (tmp);
+
+ if (val)
+ error ("compile_pattern: Can't compile pattern string `%s': %s!", pattern, val);
+
+ if (fastmap)
+ re_compile_fastmap (compiled_pattern);
+}
+
/* Open a connection to a remote debugger. NAME is the filename used
for communication. */
@@ -386,20 +451,12 @@ monitor_open (args, mon_ops, from_tty)
/* Setup pattern for register dump */
if (mon_ops->register_pattern)
- {
- int tmp;
- char *val;
-
- register_pattern.fastmap = fastmap;
- tmp = re_set_syntax (RE_SYNTAX_EMACS);
- val = re_compile_pattern (mon_ops->register_pattern,
- strlen (mon_ops->register_pattern),
- &register_pattern);
- re_set_syntax (tmp);
- if (val)
- error ("Can't compiler register pattern string: %s!", val);
- re_compile_fastmap (&register_pattern);
- }
+ compile_pattern (mon_ops->register_pattern, &register_pattern,
+ register_fastmap);
+
+ if (mon_ops->getmem.resp_delim)
+ compile_pattern (mon_ops->getmem.resp_delim, &getmem_resp_delim_pattern,
+ getmem_resp_delim_fastmap);
unpush_target (targ_ops);
@@ -556,6 +613,9 @@ parse_register_dump (buf, len)
{
int regnamelen, vallen;
char *regname, *val;
+/* Element 0 points to start of register name, and element 1 points to the
+ start of the register value. */
+ struct re_registers register_strings;
if (re_search (&register_pattern, buf, len, 0, len,
&register_strings) == -1)
@@ -963,7 +1023,7 @@ monitor_read_memory_single (memaddr, myaddr, len)
the buf. */
if (current_monitor->getmem.resp_delim)
- monitor_expect (current_monitor->getmem.resp_delim, NULL, 0);
+ monitor_expect_regexp (getmem_resp_delim_pattern, NULL, 0);
/* Now, read the appropriate number of hex digits for this loc, skipping
spaces. */
@@ -1084,11 +1144,25 @@ monitor_read_memory (memaddr, myaddr, len)
if (current_monitor->getmem.resp_delim)
{
+ int retval, tmp;
+ struct re_registers resp_strings;
+
+ tmp = strlen (p);
+ retval = re_search (&getmem_resp_delim_pattern, p, tmp, 0, tmp,
+ &resp_strings);
+
+ if (retval < 0)
+ error ("monitor_read_memory (0x%x): bad response from monitor: %.*s.",
+ memaddr, resp_len, buf);
+
+ p += resp_strings.end[0];
+#if 0
p = strstr (p, current_monitor->getmem.resp_delim);
if (!p)
error ("monitor_read_memory (0x%x): bad response from monitor: %.*s.",
memaddr, resp_len, buf);
p += strlen (current_monitor->getmem.resp_delim);
+#endif
}
for (i = len; i > 0; i--)
diff --git a/gdb/sh3-rom.c b/gdb/sh3-rom.c
index 2fc3ae1..b52fa5e 100644
--- a/gdb/sh3-rom.c
+++ b/gdb/sh3-rom.c
@@ -123,7 +123,8 @@ static char *sh3_inits[] = {"\003", NULL}; /* Exits sub-command mode & download
static struct monitor_ops sh3_cmds =
{
- 0, /* flags */
+ MO_CLR_BREAK_USES_ADDR
+ | MO_GETMEM_READ_SINGLE, /* flags */
sh3_inits, /* monitor init string */
"g\r", /* continue command */
"s\r", /* single step */
@@ -142,13 +143,13 @@ static struct monitor_ops sh3_cmds =
NULL, /* setreg.term_cmd */
},
{
- "d %x@%x;b\r", /* getmem.cmdb (addr, len) */
- "d %x@%x;w\r", /* getmem.cmdw (addr, len) */
- "d %x@%x;l\r", /* getmem.cmdl (addr, len) */
+ "m %x\r", /* getmem.cmdb (addr, len) */
+ "m %x;w\r", /* getmem.cmdw (addr, len) */
+ "m %x;l\r", /* getmem.cmdl (addr, len) */
NULL, /* getmem.cmdll (addr, len) */
- "^[0-9A-F]+ ", /* getmem.resp_delim */
- NULL, /* getmem.term */
- NULL, /* getmem.term_cmd */
+ "^ [0-9A-F]+ ", /* getmem.resp_delim */
+ "? ", /* getmem.term */
+ ".\r", /* getmem.term_cmd */
},
{
".%s %x\r", /* setreg.cmd (name, value) */
@@ -167,7 +168,7 @@ static struct monitor_ops sh3_cmds =
"\\(\\w+\\)=\\([0-9a-fA-F]+\\( +[0-9a-fA-F]+\\b\\)*\\)",
sh3_supply_register, /* supply_register */
NULL, /* load_routine (defaults to SRECs) */
- "l\r", /* download command */
+ "il;s:x\r\006", /* download command */
NULL, /* Load response */
"\n:", /* monitor command prompt */
"\r", /* end-of-line terminator */