/* 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. */
}
c = readchar (timeout);
+ if (c == '\000')
+ continue;
*buf++ = c;
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
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. */
/* 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),
- ®ister_pattern);
- re_set_syntax (tmp);
- if (val)
- error ("Can't compiler register pattern string: %s!", val);
- re_compile_fastmap (®ister_pattern);
- }
+ compile_pattern (mon_ops->register_pattern, ®ister_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);
{
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 (®ister_pattern, buf, len, 0, len,
®ister_strings) == -1)
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. */
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--)
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 */
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) */
"\\(\\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 */