This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
MI: event notification
- From: Nick Roberts <nickrob at snap dot net dot nz>
- To: gdb at sourceware dot org
- Date: Wed, 21 Jun 2006 13:16:09 +1200
- Subject: MI: event notification
In the past there have been discussions about the performance of certain
MI commands. To reduce the overhead, I would like to add some event
notification where GDB informs that front end when something has changed
I think this has always been the intention but that nothing has so far
been implemented. As a start, and by way of an example, I attach a patch
that tries to say when the stack has changed so that MI command(s)
-stack-list-frames, -stack-list-arguments need not be issued while stepping
within the same frame, for example.
>From the manual:
`NOTIFY-ASYNC-OUTPUT ==>'
`[ TOKEN ] "=" ASYNC-OUTPUT'
Using the patch, "=stack-changed\n" gets printed every time the stack changes
e.g
(gdb)
-exec-finish
^running
(gdb)
=stack-changed
*stopped,reason="function-finished",thread-id="0",frame={addr="0x080487cc",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbff7efa4"}],file="myprog.c",fullname="/home/nickrob/myprog.c",line="112"},gdb-result-var="$1",return-value="9"
(gdb)
-exec-next
^running
(gdb)
*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x080487d1",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbff7efa4"}],file="myprog.c",fullname="/home/nickrob/myprog.c",line="108"}
(gdb)
-exec-continue
^running
(gdb)
=stack-changed
*stopped,reason="breakpoint-hit",bkptno="1",thread-id="0",frame={addr="0x080488aa",func="myprint",args=[{name="i",value="2"},{name="j",value="2"}],file="myprint.c",fullname="/home/nickrob/myprint.c",line="9"}
(gdb)
WDYT?
--
Nick http://www.inet.net.nz/~nickrob
*** mi-main.c 13 May 2006 16:42:07 +1200 1.84
--- mi-main.c 21 Jun 2006 12:38:48 +1200
*************** mi_execute_async_cli_command (char *mi,
*** 1339,1344 ****
--- 1339,1346 ----
if (!target_can_async_p ())
{
+ static struct frame_id previous = {0, 0, 0, 0, 0, 0};
+ struct frame_id current;
/* Do this before doing any printing. It would appear that some
print code leaves garbage around in the buffer. */
do_cleanups (old_cleanups);
*************** mi_execute_async_cli_command (char *mi,
*** 1346,1351 ****
--- 1348,1362 ----
the stopped message. */
if (last_async_command)
fputs_unfiltered (last_async_command, raw_stdout);
+ current = get_frame_id (get_current_frame ());
+ if (!frame_id_eq (previous, current))
+ fputs_unfiltered ("=stack-changed\n", raw_stdout);
+ previous.stack_addr = current.stack_addr;
+ previous.stack_addr_p = current.stack_addr_p;
+ previous.code_addr = current.code_addr;
+ previous.code_addr_p = current.code_addr_p;
+ previous.special_addr = current.special_addr;
+ previous.special_addr_p = current.special_addr_p;
fputs_unfiltered ("*stopped", raw_stdout);
mi_out_put (uiout, raw_stdout);
mi_out_rewind (uiout);