Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
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: Tue, 20 Oct 2020 19:19:22 +0100	[thread overview]
Message-ID: <52E32C75-B5F8-4873-8CE6-2CBC99914F22@undo.io> (raw)
In-Reply-To: <ad7a4744-0d30-fbd9-8604-0683329d7d7d@palves.net>

On 20 Oct 2020, at 16:06, Pedro Alves <pedro@palves.net> wrote:
> On 10/19/20 8:28 PM, Marco Barisione wrote:
>> On 19 Oct 2020, at 19:47, Philippe Waroquiers <philippe.waroquiers@skynet.be> wrote:
> 
>>> I am wondering how rename will interact with alias:
>>> alias are resolved at definition time, so a rename
>>> following an alias might not have the expected effect.
>> 
>> That’s a very good point. I didn’t consider aliases and hooks.
>> 
>> My use case is for building on top of existing commands so they can
>> be extended/tweaked.  Aliases and hooks need to follow the new
>> command, including the ones set by users (so I have no way of knowing
>> about them).
>> I can’t think of any way of making a rename command work like this.
>> 
>> Any idea?
> 
> In my previous example, where it read:
> 
> (gdb) rename run org_run
> (gdb) define run
> ...
> 
> merge those two commands into a single atomic operation?
> 
> Like:
> 
> (gdb) rename-define run org_run
>> echo Will run!\n
>> org_run
>> end
> (gdb) run
>  Will run!
>  [... normal output of run ...]
> (gdb) org_run
>  [... normal output of run ...]
> 
> Unlike "rename", "rename-define" (strawman name) would take care
> of moving the alias and pre/post hooks to the new implementation.


I can’t think of any good name for a command so maybe it should just
be an option to define?

    (gdb) define -rename-existing orig_run run
    echo Will run\n
    orig_run
    end

Or "define -r" for short.

GDB would not ask if you want to redefine the existing command as I
think that the user’s intention would be quite clear.

Similarly, in Python we could have a "rename_existing" argument to
gdb.Command.__init__ ().


"rename" still seems useful, but hooks/aliases would follow the
rename:

    (gdb) define foo
    echo Hello world\n
    end
    (gdb) alias my-alias = foo
    (gdb) rename foo bar
    (gdb) bar
    Hello world
    (gdb) foo
    Undefined command: “foo".  Try "help”.
    (gdb) my-alias
    Hello world

I think that rename with an "=" would be a bit confusing and would
not provide a way of deleting commands (unlike rename in TCL).


What do you think?


-- 
Marco Barisione


  reply	other threads:[~2020-10-20 18:19 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
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 [this message]
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=52E32C75-B5F8-4873-8CE6-2CBC99914F22@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