public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Jan Vrany <jan.vrany@fit.cvut.cz>,
	"gdb@sourceware.org" <gdb@sourceware.org>
Cc: "Joel Brobecker" <brobecker@adacore.com>,
	"Tom Tromey" <tom@tromey.com>,
	"André Pönitz" <apoenitz@t-online.de>,
	"Jonah Graham" <jonah@kichwacoders.com>
Subject: Re: MI3 and async notifications
Date: Thu, 20 Jun 2019 15:31:00 -0000	[thread overview]
Message-ID: <5687f162-d938-7eff-55ba-cf72d9d91e58@simark.ca> (raw)
In-Reply-To: <eb096f74218b0fe29861d440953fcaf30f799838.camel@fit.cvut.cz>

On 2019-06-19 4:57 p.m., Jan Vrany wrote:
> But consider `set` CLI and `-gdb-set` MI commands: 
> 
> (gdb) 
> set directories /foo/bar
> &"set directories /foo/bar\n"
> &"Warning: /foo/bar: No such file or directory.\n"
> =cmd-param-changed,param="directories",value="/foo/bar:$cdir:$cwd"
> ^done
> (gdb)
> 
> and
> 
> -gdb-set directories /baz/qux
> &"Warning: /baz/qux: No such file or directory.\n"
> ^done
> 
> In this case. the response carries no data at all so in order to synthesize the event
> I need to look at the originating command and parse its arguments to pick the name and value.
> And as you can see above, the value parameter to the command is just "/foo/bar" while
> the value in the event is "/foo/bar:$cdir:$cwd" - another little thing to care about in this
> very case. 
> 
> Indeed, not a rocket science, but as you see, it requires to write a little specialized 
> piece of code for "every" command (vs. not having to write anything at all if I'd get the event from 
> GDB). Maybe the phrase "complex logic" was improper - complex in a way that each case has to be
> dealt with individually and if one forgets, the internal model can get out of sync. 

For the -gdb-set case, this suggests that the ^done response should contain the new value.  The reason
being that, as you have shown, GDB can massage it a little bit.  Since the value can end up different
than what the frontend asked for, the frontend would need to be informed of the new/final value.

>> The observers wouldn't know whether it's a "real" event coming from GDB or one you created
>> yourself, so it shouldn't make any difference to them.
>>
>> Or (re-reading your message, I realized that this is what you might be trying to explain)
>> are you saying that your library is very low level, and that users of the library send
>> "-break-insert" on their own and your library just forwards the MI command to GDB, so your
>> library doesn't really know (unless it sniffs the user command) that a -break-insert
>> command has been issued? 
> 
> Precisely! The library does not really know and therefore would have to "sniff". 
> 
>>  If so, that might explain my incomprehension.  All the MI-handling
>> code I have been exposed to has been a bit more high level, where the user calls some
>> "breakInsert" function of the library.  The library knows it's sending a -break-insert, so
>> it can easily handle the response however it wants (including generating a "breakpoint created"
>> event if it wants to).
> 
> Yeah, I guess that's more common approach. I decided to make it more lower-level as this gives me
> more flexibility. Or so it looked back then :-)

Ok, then I understand how ugly it is to try to track the commands and their responses.  I would tend to
say that it falls in the category "you're not using it the way it was intended to": you basically have
two or more interlocutors talking to GDB on the MI channel, whereas GDB expects to be talking to a single
interlocutor.  And your two or more interlocutors are not aware of each other's actions.

It sounds like each "interlocutor" should have its own MI channel.  Assuming the bug I mentioned earlier
is fixed (about cross-MI channel notifications not being sent), the internals of your library (which
maintains the model) would get notified whenever the user of your library creates a breakpoint with
-break-insert.

> Yes, I completely understand. This and this is a valid concern. I said it before - the last thing I want is to
> break other people's stuff "that works for decades" because of my obscure thing. If the decision out of this
> discussion is "no", I'll happily deal with it in my library. No problem whatsoever.
> 
>>
>> So at least, if we end up choosing to unconditionally emit the =breakpoint-created event, I would prefer
>> keeping the -break-insert response as-is, for backwards compatibility (for existing frontends) and
>> simplicity (for basic use cases), even if it means there's some redundancy.
>>
> 
> Yes, that was my original proposal, keep everything as it is, just to emit events in addition. 
> Either unconditionally or only if mi-always-async is set (at the cost of having yet another option
> which is also far from ideal). 

Ok, I had lost track of who suggested what in this long thread.

I am still unsure about emitting events unconditionally.  For example: some frontends want to
insert "internal" breakpoints, which are breakpoints that are not going to be directly shown to
users.  They send a -break-insert and decide that the breakpoint which results from this won't be
propagated to the UI.  But breakpoint async events are propagated to the UI (presumably because
they originate from the user creating a breakpoint in the CLI).  If GDB now emits an event for
the -break-insert breakpoint, the frontend can't know right away which future =breakpoint-created
event it should ignore.  Again, it would need to buffer all =breakpoint-created events until it
gets the ^done, then let pass through all events except the one that matches the created breakpoint.

Simon

  reply	other threads:[~2019-06-20 15:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10 21:19 Jan Vrany
2019-06-10 23:23 ` Jonah Graham
2019-06-11  8:50   ` Jan Vrany
2019-06-11 13:37     ` Jonah Graham
2019-07-05 20:00       ` Pedro Alves
2019-07-05 21:58         ` Jonah Graham
2019-06-15 14:34 ` Tom Tromey
2019-06-17 10:53   ` Jan Vrany
2019-06-17 12:11     ` Jonah Graham
2019-06-17 12:14     ` Joel Brobecker
2019-06-17 12:26       ` Jonah Graham
2019-06-17 12:56         ` Joel Brobecker
2019-06-17 13:12           ` Jonah Graham
2019-06-17 13:12           ` Jan Vrany
2019-06-17 13:23             ` Jonah Graham
2019-06-17 20:45               ` Joel Brobecker
2019-06-17 20:58                 ` Jan Vrany
2019-06-17 21:50                   ` Jonah Graham
2019-06-17 19:52     ` André Pönitz
2019-06-18  3:14 ` Simon Marchi
2019-06-18 20:38   ` Jan Vrany
2019-06-19 15:29     ` Simon Marchi
2019-06-19 20:58       ` Jan Vrany
2019-06-20 15:31         ` Simon Marchi [this message]
2019-06-20 20:46           ` Jan Vrany
2019-07-05 19:35           ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5687f162-d938-7eff-55ba-cf72d9d91e58@simark.ca \
    --to=simark@simark.ca \
    --cc=apoenitz@t-online.de \
    --cc=brobecker@adacore.com \
    --cc=gdb@sourceware.org \
    --cc=jan.vrany@fit.cvut.cz \
    --cc=jonah@kichwacoders.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).