From: Marco Barisione <mbarisione@undo.io>
To: Pedro Alves <pedro@palves.net>
Cc: gdb-patches@sourceware.org
Subject: Re: Add a way to invoke redefined (overridden) GDB commands
Date: Mon, 19 Oct 2020 18:41:31 +0100 [thread overview]
Message-ID: <371BE292-EE03-4FBE-A963-64F08437A6A7@undo.io> (raw)
In-Reply-To: <dcaf69e8-a1b3-af96-41fe-7da39a9b6e19@palves.net>
On 12 Oct 2020, at 12:50, Pedro Alves <pedro@palves.net> wrote:
> On 9/14/20 10:39 AM, Marco Barisione wrote:
>> Currently, when a GDB command is redefined, the original implementation is not
>> available any more. This makes it difficult to build features on top of
>> existing commands.
>>
>> Last year I submitted a patch to fix this but I ran out of time to address the
>> review comments (the original patch was sent on the 28th of October 2019).
>> These patches restart that work and should address all the comments I got last
>> time. As the patchea are very different and a long time passed, I'm
>> submitting as a new series.
>>
>> My patches add a new "uplevel" command and a new gdb.Command.invoke_uplevel
>> method inspired by TCL (as initially suggested by Andrew Burgess) so you can
>> do this:
>>
>> (gdb) define run
>> echo Will run!\n
>> uplevel 0 run
>> end
>> (gdb) run
>> Will run!
>> [... normal output of run ...]
>>
>>
>> There are a couple of other things which could be added to make the "uplevel"
>> command more helpful, but I think they are out of scope and my patches are
>> already useful as they are.
>
> So I'm looking at this afresh, and really questioning this "uplevel N"
> design. This it not really like TCL's "uplevel". With TCL's uplevel,
> you are accessing a different scope or frame, not a previous implementation
> of the function that was overwritten. To me, the naming choice is
> confusing, from that angle. If someone extends GDB's CLI to gain support
> for local variables, then a really-TCL-like uplevel is likely handy, and
> then calling that feature "uplevel" would be good.
>
> I also question whether "uplevel N" with "N>0" is really usable, since
> in general you don't know what other scripts may have overridden. E.g.,
> you never know what "uplevel 3 cmd" will run, since you don't know how
> many scripts redefined/overridden cmd.
>
> If we stick with the TCL inspiration, I think a better approach would
> be to add support for renaming commands, like TCL's rename command:
>
> https://www.tcl.tk/man/tcl8.4/TclCmd/rename.htm
>
> So a user would do:
>
> (gdb) rename run org_run
> (gdb) define run
>> echo Will run!\n
>> org_run
>> end
> (gdb) run
> Will run!
> [... normal output of run ...]
> (gdb) org_run
> [... normal output of run ...]
>
> (You can find many examples of TCL's rename in use in GDB's testsuite.)
I will try implementing this then, including the semantics for deleting
a command (copied from the TCL command).
A problem with GDB is that commands can have spaces so:
(gdb) rename foo bar
Is ambiguous. Do you want to delete the "foo bar" command or rename the
"foo" command to "bar"?
Even without deleting command, this would be ambiguous:
(gdb) rename foo bar baz
Unless somebody proposes something different I will use "--" to split
the two command names.
For instance:
(gdb) # Rename "foo" to “bar":
(gdb) rename foo -- bar
(gdb) # Rename "foo bar" to "baz":
(gdb) rename foo bar -- baz
(gdb) # Delete "foo bar":
(gdb) rename foo bar --
(gdb) # Invalid:
(gdb) rename --
(gdb) rename -- hello
--
Marco Barisione
next prev parent reply other threads:[~2020-10-19 17:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-14 9:39 Marco Barisione
2020-09-14 9:39 ` [PATCH 1/2] Move the code to execute a cmd_list_element out from execute_command Marco Barisione
2020-10-05 9:08 ` Andrew Burgess
2020-10-05 9:40 ` Marco Barisione
2020-10-05 17:49 ` Andrew Burgess
2020-09-14 9:39 ` [PATCH 2/2] Add a way to preserve redefined GDB commands for later invocation Marco Barisione
2020-09-14 16:18 ` Eli Zaretskii
2020-09-14 16:51 ` Marco Barisione
2020-10-05 10:24 ` Andrew Burgess
2020-10-05 11:44 ` Marco Barisione
2020-10-05 18:11 ` Andrew Burgess
2020-10-06 7:18 ` Marco Barisione
2020-09-28 7:54 ` [PING] Add a way to invoke redefined (overridden) GDB commands Marco Barisione
2020-10-05 7:42 ` Marco Barisione
2020-10-12 11:50 ` Pedro Alves
2020-10-19 17:41 ` Marco Barisione [this message]
2020-10-19 18:05 ` Pedro Alves
2020-10-19 18:47 ` Philippe Waroquiers via Gdb-patches
2020-10-19 19:28 ` Marco Barisione
2020-10-20 15:06 ` Pedro Alves
2020-10-20 18:19 ` Marco Barisione
2020-10-20 18:32 ` Pedro Alves
2020-10-20 15:15 ` 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=371BE292-EE03-4FBE-A963-64F08437A6A7@undo.io \
--to=mbarisione@undo.io \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
/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