From: Marco Barisione <mbarisione@undo.io>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Add a way to preserve overridden GDB commands for later invocation
Date: Fri, 01 Nov 2019 21:01:00 -0000 [thread overview]
Message-ID: <2E9BBFD2-6643-4958-AF6B-FFC974FFF479@undo.io> (raw)
In-Reply-To: <87wocj1k3y.fsf@tromey.com>
On 1 Nov 2019, at 19:18, Tom Tromey <tom@tromey.com> wrote:
>>>>>> "Marco" == Marco Barisione <mbarisione@undo.io> writes:
> Could you say what unexpected behavioural changes you would anticipate?
> I tend to think it would be clearer if all commands were treated
> identically.
>
> Is there some implementation difficulty doing it? Or was it just that
> you didn't think it was useful?
I was mainly worried about changing the behaviour in ways which could be
unexpected. For instance, an instance of gdb.Command may end up living longer
than expected.
Another thing is that a command which was written before this patch may not be
using the original implementation just because it was not possible before, so
block a further command from accessing it as well. See the example later in
the email.
If you don't think these are problems I'm happy to simplify the code.
> In this model, if a Python command overrides a built-in command, and
> then is itself overridden, can the new command still access the
> underlying built-in command?
Let's say you override delete. Let's call the first class overriding it
DeleteCommand1 and the second DeleteCommand2.
If DeleteCommand1 didn't use preserve_when_overridden then
DeleteCommand2.invoke_overridden will just call the original delete.
If DeleteCommand1 was preserved, then DeleteCommand2.invoke_overridden
will call DeleteCommand1.invoke. At this point DeleteCommand1 may just do
whatever it needs on its own, or call its own invoke_overridden method
which will call the original delete command.
DeleteCommand2 has not way to invoke the original delete command directly.
This is partly because I'm not sure how I would expose this in a nice way,
but mainly because I don't want commands to accidentally skip some
previous implementation by accident. For instance, if we had an
invoke_original method, then DeleteCommand2 could call that and skip
DeleteCommand1.
> What happens in the weird case that you have a command alias X, then
> override X, and then override the thing that the original X was aliased
> to? Will calling the overridden X do the right thing? Really I'm
> wondering if that crashes -- maybe a counter-argument to my wish for
> generality is that aliases should not be overridden.
Oh right, aliases are treated a bit differently and I didn't think of
testing that. I should add a test and see.
--
Marco Barisione
next prev parent reply other threads:[~2019-11-01 21:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-28 13:33 [PATCH] " Marco Barisione
2019-10-28 17:36 ` Eli Zaretskii
2019-10-28 18:12 ` Marco Barisione
2019-11-01 8:55 ` [PATCH v2] " Marco Barisione
2019-11-01 9:14 ` Eli Zaretskii
2019-11-01 19:18 ` Tom Tromey
2019-11-01 21:01 ` Marco Barisione [this message]
2019-11-05 10:17 ` Andrew Burgess
2019-11-06 8:42 ` Marco Barisione
2019-11-07 10:22 ` Marco Barisione
2019-11-06 16:00 ` 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=2E9BBFD2-6643-4958-AF6B-FFC974FFF479@undo.io \
--to=mbarisione@undo.io \
--cc=gdb-patches@sourceware.org \
--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).