one proposal ... `Z'T`,'ADDR`,'LENGTH`,'IGNORE_COUNT ??
Masahiro Fukuda
masahiro@lsi.nec.co.jp
Wed Sep 22 02:35:00 GMT 1999
Hi,
I recently realize that gdb-19990830 extends some
keyword into gdb serial protocol, and I also read
some mailing list archives.
My name is Masahiro Fukuda. Independently, I added
some keyword (actually [B/b] just like J.T.C did) into
gdb serial protocol in order to transmit "breakpoint" to
gdbserver instead of writing TRAP instruction.
Some arguements including <addr>, <length>, <ignore_count>
follow breakpiont keyword in my code. Those command packets
are generated in v850_insert_hw_breakpint()/v850_insert_watchpoint()
in v850-tdep.c.
Andrew suggested me that I would join gdb mailing list
when I wrote an e-mail to him how I should do for this
kind of proposal.
Expected typical scenario is shown below when ignore count
is transmitted to target. Suppose, there are three
breakponits/watchpoints and each has following ignore count.
number type ignore count
------------------------------------------
#1 hardware breakpoint 7
#2 read watchpoint 5
#3 write watchpoint 3
Please find the gdb/target communication below with illustration.
(a) Breakpoints/watchpoints are inserted before continue.
(b) Gdb continues target. Target decrements each ignore count
every time when target hits respective breakpoint/watchpoint
without making any communication with gdb as far as
respective ignore count does not equal to zero.
At last, target tells gdb after it hits breakpoint/watchpoint
whose ignore count equal to zero.
(c) breakpoints/watchpoints are removed after target stopps
and each current ignore count is retrieved from target.
---------------------- illustration ----------------------
gdb side -------------------- target side
(a)insert breakpoints -----------------------> (#1, 7)
before continue -----------------------> (#2, 5)
with ignore count -----------------------> (#3, 3)
(b)continue ----------------------------------->
wait for target | #1 hit (#1, 7->6)
to stop | #1 hit (#1, 6->5)
| #1 hit (#1, 5->4)
| #2 hit (#2, 5->4)
time | #3 hit (#3, 3->2)
| #1 hit (#1, 4->3)
| #1 hit (#1, 3->2)
| #1 hit (#1, 2->1)
| #2 hit (#2, 4->3)
| #3 hit (#3, 2->1)
| #1 hit (#1, 1->0)
V #1 hit (#1, 0->!)
target stop <-------------------------------
(c)remove breakponits -----------------------> (#1 )
remained ignore count returns (0) <---------
remove breakponits -----------------------> (#2 )
remained ignore count returns (3) <---------
remove breakponits -----------------------> (#3 )
remained ignore count returns (1) <---------
---------------------- illustration ----------------------
Next, please find the proposed Z/z packet.
---------------------- proposed Z/z packet ----------------------
remove `z'T`,'ADDR`,'LENGTH` `z' should retrieve
break remained IGNORE_COUNT
or from target.
watcchpoint reply `OK'IGNORE_COUNT for success
The others are the same
as current spec.
insert `Z'T`,'ADDR`,'LENGTH`,'IGNORE_COUNT just add IGNORE_COUNT
break The othera are the same
or as current spec.
watcchpoint
---------------------- proposed Z/Z packet ----------------------
---------------------- current Z/Z packet ----------------------
remove break or `z'T`,'ADDR`,'LENGTH See `Z'.
watchpoint *(draft)*
*(optional)*
insert break or `Z'T`,'ADDR`,'LENGTH T is type: `0' - software
watchpoint *(draft)* breakpoint, `1' - hardware
*(optional)* breakpoint, `2' - write
watchpoint, `3' - read
watchpoint, `4' - access
watchpoint; ADDR is address;
LENGTH is in bytes. For a
software breakpoint, LENGTH
specifies the size of the
instruction to be patched.
For hardware breakpoints and
watchpoints LENGTH specifies
the memory region to be
monitored.
reply `E'NN for an error
reply `OK' for success
`' If not supported.
---------------------- current Z/Z packet ----------------------
Some fragment of my code is shown below.
I will follow snapshot specification(I will modify my code to
adjust snapshot specification) such like....
B -> Z
w -> 2
r -> 3
a -> 4
---------------------- cut cut cut ----------------------
int
v850_insert_watchpoint(addr,len,type)
int addr, len, type;
{
char buf[PBUFSIZ], *p;
struct breakpoint *b, *tmp; /* breakpoint.c */
int ignore_count; /* see breakpoint.h */
value_ptr v; /* see breakpoint.h */
int watch_addr;
/* construct "Bw"<memaddr>","<len>","<ignore_count>" if type == 0 */
/* construct "Br"<memaddr>","<len>","<ignore_count>" if type == 1 */
/* construct "Ba"<memaddr>","<len>","<ignore_count>" if type == 2 */
/* sprintf (buf, "Bx%lx,%x,%x", (unsigned long) memaddr, len, ignore); */
p = buf;
*p++ = 'B';
if (type == 0)
*p++ = 'w';
else if (type == 1)
*p++ = 'r';
else if (type == 2)
*p++ = 'a';
else
error ("(_o_) sorry...watchpoint has wrong value for 'type' ");
p += hexnumstr (p, (ULONGEST) addr);
*p++ = ',';
p += hexnumstr (p, (ULONGEST) len);
*p++ = ',';
ignore_count = 0;
ALL_BREAKPOINTS_SAFE(b, tmp)
{
if (b->exp != NULL) {
v = evaluate_expression (b->exp);
watch_addr = VALUE_ADDRESS(v) + VALUE_OFFSET(v);
if ( watch_addr == addr) {
ignore_count = b->ignore_count;
b->ignore_count = 0;
break;
}
}
}
p += hexnumstr (p, (ULONGEST) ignore_count);
*p++ = ':';
*p = '\0';
putpkt (buf);
getpkt (buf, 0);
return 0; /* 0 when success, -1 when failure */
}
---------------------- cut cut cut ----------------------
Best regards,
Fukuda, M
More information about the Gdb
mailing list