* 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.
This commit is contained in:
Stu Grossman 1995-10-24 21:31:07 +00:00
parent da533085e5
commit 283dc598b8
3 changed files with 111 additions and 28 deletions

View File

@ -1,5 +1,13 @@
Tue Oct 24 12:26:14 1995 Stu Grossman (grossman@cygnus.com) 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 * infrun.c (wait_for_inferior): Disable questionable code near
the step range test. Replace call detection test with much the step range test. Replace call detection test with much
simpler (and more efficient) test that doesn't require prologue simpler (and more efficient) test that doesn't require prologue

View File

@ -106,13 +106,10 @@ static serial_t monitor_desc = NULL;
/* Pointer to regexp pattern matching data */ /* Pointer to regexp pattern matching data */
static struct re_pattern_buffer register_pattern; 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 static struct re_pattern_buffer getmem_resp_delim_pattern;
start of the register value. */ static char getmem_resp_delim_fastmap[256];
static struct re_registers register_strings;
static char fastmap[256];
static int dump_reg_flag; /* Non-zero means do a dump_registers cmd when static int dump_reg_flag; /* Non-zero means do a dump_registers cmd when
monitor_wait wakes up. */ monitor_wait wakes up. */
@ -275,6 +272,8 @@ monitor_expect (string, buf, buflen)
} }
c = readchar (timeout); c = readchar (timeout);
if (c == '\000')
continue;
*buf++ = c; *buf++ = c;
buflen--; 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. /* Keep discarding input until we see the MONITOR prompt.
The convention for dealing with the prompt is that you The convention for dealing with the prompt is that you
@ -355,6 +396,30 @@ get_hex_word ()
return val; 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 /* Open a connection to a remote debugger. NAME is the filename used
for communication. */ for communication. */
@ -386,20 +451,12 @@ monitor_open (args, mon_ops, from_tty)
/* Setup pattern for register dump */ /* Setup pattern for register dump */
if (mon_ops->register_pattern) if (mon_ops->register_pattern)
{ compile_pattern (mon_ops->register_pattern, &register_pattern,
int tmp; register_fastmap);
char *val;
register_pattern.fastmap = fastmap; if (mon_ops->getmem.resp_delim)
tmp = re_set_syntax (RE_SYNTAX_EMACS); compile_pattern (mon_ops->getmem.resp_delim, &getmem_resp_delim_pattern,
val = re_compile_pattern (mon_ops->register_pattern, getmem_resp_delim_fastmap);
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);
}
unpush_target (targ_ops); unpush_target (targ_ops);
@ -556,6 +613,9 @@ parse_register_dump (buf, len)
{ {
int regnamelen, vallen; int regnamelen, vallen;
char *regname, *val; 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, if (re_search (&register_pattern, buf, len, 0, len,
&register_strings) == -1) &register_strings) == -1)
@ -963,7 +1023,7 @@ monitor_read_memory_single (memaddr, myaddr, len)
the buf. */ the buf. */
if (current_monitor->getmem.resp_delim) 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 /* Now, read the appropriate number of hex digits for this loc, skipping
spaces. */ spaces. */
@ -1084,11 +1144,25 @@ monitor_read_memory (memaddr, myaddr, len)
if (current_monitor->getmem.resp_delim) 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); p = strstr (p, current_monitor->getmem.resp_delim);
if (!p) if (!p)
error ("monitor_read_memory (0x%x): bad response from monitor: %.*s.", error ("monitor_read_memory (0x%x): bad response from monitor: %.*s.",
memaddr, resp_len, buf); memaddr, resp_len, buf);
p += strlen (current_monitor->getmem.resp_delim); p += strlen (current_monitor->getmem.resp_delim);
#endif
} }
for (i = len; i > 0; i--) for (i = len; i > 0; i--)

View File

@ -123,7 +123,8 @@ static char *sh3_inits[] = {"\003", NULL}; /* Exits sub-command mode & download
static struct monitor_ops sh3_cmds = static struct monitor_ops sh3_cmds =
{ {
0, /* flags */ MO_CLR_BREAK_USES_ADDR
| MO_GETMEM_READ_SINGLE, /* flags */
sh3_inits, /* monitor init string */ sh3_inits, /* monitor init string */
"g\r", /* continue command */ "g\r", /* continue command */
"s\r", /* single step */ "s\r", /* single step */
@ -142,13 +143,13 @@ static struct monitor_ops sh3_cmds =
NULL, /* setreg.term_cmd */ NULL, /* setreg.term_cmd */
}, },
{ {
"d %x@%x;b\r", /* getmem.cmdb (addr, len) */ "m %x\r", /* getmem.cmdb (addr, len) */
"d %x@%x;w\r", /* getmem.cmdw (addr, len) */ "m %x;w\r", /* getmem.cmdw (addr, len) */
"d %x@%x;l\r", /* getmem.cmdl (addr, len) */ "m %x;l\r", /* getmem.cmdl (addr, len) */
NULL, /* getmem.cmdll (addr, len) */ NULL, /* getmem.cmdll (addr, len) */
"^[0-9A-F]+ ", /* getmem.resp_delim */ "^ [0-9A-F]+ ", /* getmem.resp_delim */
NULL, /* getmem.term */ "? ", /* getmem.term */
NULL, /* getmem.term_cmd */ ".\r", /* getmem.term_cmd */
}, },
{ {
".%s %x\r", /* setreg.cmd (name, value) */ ".%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\\)*\\)", "\\(\\w+\\)=\\([0-9a-fA-F]+\\( +[0-9a-fA-F]+\\b\\)*\\)",
sh3_supply_register, /* supply_register */ sh3_supply_register, /* supply_register */
NULL, /* load_routine (defaults to SRECs) */ NULL, /* load_routine (defaults to SRECs) */
"l\r", /* download command */ "il;s:x\r\006", /* download command */
NULL, /* Load response */ NULL, /* Load response */
"\n:", /* monitor command prompt */ "\n:", /* monitor command prompt */
"\r", /* end-of-line terminator */ "\r", /* end-of-line terminator */