This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA]: Use regexp to check result of write reg/memory in monitors
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFA]: Use regexp to check result of write reg/memory in monitors
- From: Stephane Carrez <Stephane dot Carrez at worldnet dot fr>
- Date: Sat, 02 Dec 2000 23:58:19 +0100
Hi!
The Gdb monitor framework only supports a fixed pattern for the output
produced by write_memory and store_register.
For the 68HC11 buffalo monitor, the memory write command produces some output
that depends on the command. Setting a register also produces an output that
depends on the register being set.
The following patch uses the 'setmem.resp_delim' and 'setreg.resp_delim'
of monitor_ops to specify two regular expressions to check the output
of the 'setmem.cmdb' and 'setreg.cmd' commands. These two fields are
currently not used. They are null for all existing monitors (see grep output).
Can you approve this patch?
Stephane
2000-12-03 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* monitor.c (setmem_resp_delim_pattern): New regexp pattern.
(setreg_resp_delim_pattern): Likewise.
(setmem_resp_delim_fastmap): New buffer.
(setreg_resp_delim_fastmap): Likewise.
(monitor_open): Initialize above regexp if they are defined.
(monitor_write_memory): Use regexp to check the result of write.
(monitor_store_register): Likewise to check result of register set.
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.14
diff -p -r1.14 monitor.c
*** monitor.c 2000/11/03 22:00:56 1.14
--- monitor.c 2000/12/02 21:56:07
*************** static char register_fastmap[256];
*** 126,131 ****
--- 126,137 ----
static struct re_pattern_buffer getmem_resp_delim_pattern;
static char getmem_resp_delim_fastmap[256];
+ static struct re_pattern_buffer setmem_resp_delim_pattern;
+ static char setmem_resp_delim_fastmap[256];
+
+ static struct re_pattern_buffer setreg_resp_delim_pattern;
+ static char setreg_resp_delim_fastmap[256];
+
static int dump_reg_flag; /* Non-zero means do a dump_registers cmd when
monitor_wait wakes up. */
*************** monitor_open (char *args, struct monitor
*** 749,754 ****
--- 755,768 ----
compile_pattern (mon_ops->getmem.resp_delim, &getmem_resp_delim_pattern,
getmem_resp_delim_fastmap);
+ if (mon_ops->setmem.resp_delim)
+ compile_pattern (mon_ops->setmem.resp_delim, &setmem_resp_delim_pattern,
+ setmem_resp_delim_fastmap);
+
+ if (mon_ops->setreg.resp_delim)
+ compile_pattern (mon_ops->setreg.resp_delim, &setreg_resp_delim_pattern,
+ setreg_resp_delim_fastmap);
+
unpush_target (targ_ops);
if (dev_name)
*************** monitor_store_register (int regno)
*** 1337,1342 ****
--- 1351,1363 ----
else
monitor_printf (current_monitor->setreg.cmd, name, val);
+ if (current_monitor->setreg.resp_delim)
+ {
+ monitor_debug ("EXP setreg.resp_delim\n");
+ monitor_expect_regexp (&setreg_resp_delim_pattern, NULL, 0);
+ if (current_monitor->flags & MO_SETREG_INTERACTIVE)
+ monitor_printf ("%s\r", paddr_nz (val));
+ }
if (current_monitor->setreg.term)
{
monitor_debug ("EXP setreg.term\n");
*************** monitor_write_memory (CORE_ADDR memaddr,
*** 1463,1468 ****
--- 1484,1495 ----
monitor_printf_noecho (cmd, memaddr);
+ if (current_monitor->setmem.resp_delim)
+ {
+ monitor_debug ("EXP setmem.resp_delim");
+ monitor_expect_regexp (&setmem_resp_delim_pattern, NULL, 0);
+ monitor_printf ("%x\r", val);
+ }
if (current_monitor->setmem.term)
{
monitor_debug ("EXP setmem.term");