This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MI3 and async notifications


On Mon, 2019-06-10 at 19:22 -0400, Jonah Graham wrote:
> On Mon, 10 Jun 2019 at 17:19, Jan Vrany <jan.vrany@fit.cvut.cz> wrote:
> 
> > Therefore I'd like to propose a change for MI3 to always send
> > notifications.
> > If such a change would make things complicated for other frontends
> > (Eclipse CDT / Emacs come to mind), I propose new
> > 
> > -gdb-set mi-always-notify 1
> > -gdb-set mi-always-notify 0
> > 
> 
> Thank you for considering the other front end consumers of MI. I am one of
> the current maintainers of CDT so I will share my 2cents.

Thanks!

> 
> Eclipse CDT would certainly require such a flag, but only if MI3 was a
> replacement for MI2. If CDT can continue to use gdb in mi2 mode (CDT
> launches gdb with --interpreter mi2 [1]) then I don't think you need to
> carry on the extra logic in MI3. I haven't followed the discussions on MI3
> closely.

I don't know what are the plans exactly either. My idea was to change it for
MI3 only, so if you do `--interpreter mi2`, nothing will change for you. 

However I guess you may want to use MI3 in future as it will be the default
(I might be wrong but as of current master, MI3 is the default). 
Not breaking CDT is a (very) strong argument, so I think we need the option. It's not
that hard to implement. 

> 
> I assume from the proposal that the -break-insert still gets the done
> message with the breakpoint number in it? And does the async message come
> back after the the ^done? If it does not come after the done CDT will have
> to hold processing the async message until after it finds out if the
> =breakpoint-created was for the MI or CLI inserted breakpoint 

Yes, you will get ^done with all the data as before, only that before ^done
you'll get =breakpoint-created event (with the same data). 

I modified the code to always send notifications in MI3 but not MI2 (patch below),  
here's an example session to demonstrate the difference on -break-insert:

MI2 (current)

./gdb -i=mi2 ./testsuite/outputs/gdb.python/py-msymbol/py-msymbol
=thread-group-added,id="i1"
~"GNU gdb (GDB) 8.3.50.20190611-git\n"
~"Copyright (C) 2019 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by
law."
~"\nType \"show copying\" and \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-pc-linux-gnu\".\n"
~"Type \"show configuration\" for configuration details.\n"
~"For bug reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>;."
~"\n\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\"...\n"
~"Reading symbols from ./testsuite/outputs/gdb.python/py-msymbol/py-msymbol...\n"
(gdb) 
-break-insert main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000001151",func="main",file="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.python/py-
symbol.c",fullname="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.python/py-symbol.c",line="56",thread-groups=["i1"],times="0",original-location="main"}
(gdb) 
quit
&"quit\n"

MI3 with modification (proposed)

jv@sao:~/Projects/gdb/users_jv_patches/gdb$ ./gdb -i=mi3 ./testsuite/outputs/gdb.python/py-msymbol/py-msymbol
=thread-group-added,id="i1"
~"GNU gdb (GDB) 8.3.50.20190611-git\n"
~"Copyright (C) 2019 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by
law."
~"\nType \"show copying\" and \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-pc-linux-gnu\".\n"
~"Type \"show configuration\" for configuration details.\n"
~"For bug reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>;."
~"\n\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\"...\n"
~"Reading symbols from ./testsuite/outputs/gdb.python/py-msymbol/py-msymbol...\n"
(gdb) 
-break-insert main
=breakpoint-created,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000001151",func="main",file="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.python/py-
symbol.c",fullname="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.python/py-symbol.c",line="56",thread-groups=["i1"],times="0",original-location="main"}
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000001151",func="main",file="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.python/py-
symbol.c",fullname="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.python/py-symbol.c",line="56",thread-groups=["i1"],times="0",original-location="main"}
(gdb) 
quit
&"quit\n"

As you can see, you get the notification *before* ^done response. Does that answer 
your questions?


> (consider the
> race condition that a user / script inserts a breakpoint from the CLI at
> the same time as from the MI).

I see. 

> 
> I hope that helps from CDT perspective.
> 

Sure, thanks! So it looks me a new option is the way to go. 

Jan

--
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 13c310d494..2f2d1f2612 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1954,7 +1954,8 @@ mi_execute_command (const char *cmd, int from_tty)
 
       gdb::optional<scoped_restore_tmpl<int>> restore_suppress;
 
-      if (command->cmd != NULL && command->cmd->suppress_notification != NULL)
+      if (command->cmd != NULL && command->cmd->suppress_notification != NULL
+          && mi_version(current_uiout) < 3)
        restore_suppress.emplace (command->cmd->suppress_notification, 1);
 
       command->token = token;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]