Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Marco Barisione <mbarisione@undo.io>
Cc: GDB patches mailing list <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2 2/5] gdb: prevent prefix commands from being hooks
Date: Mon, 15 Mar 2021 23:17:48 -0400	[thread overview]
Message-ID: <e9da7945-b033-960a-860c-f87b463afd00@polymtl.ca> (raw)
In-Reply-To: <A406FF9C-FD73-4777-899E-FD1B384292D8@undo.io>



On 2021-03-09 4:42 a.m., Marco Barisione wrote:
> On 8 Mar 2021, at 21:32, Simon Marchi <simon.marchi@polymtl.ca> wrote:
>> Ahhh, changes that touch command handling are always scary stuff, we
>> need to be really careful not to break existing use cases or paint
>> ourselves in corners for future use cases.  Probably why nobody dares to
>> review it.  I'll give it a try, but know that it still scares me :).
> 
> It did scare me and took a while because of the many corner cases,
> difficult combinations of features.
> 
> My reasoning behind this is that the behaviour is currently confusing
> (that is, what the user would expect doesn’t happen) and forbidding
> this should allow changes in the future quite easily.
> 
>> One question that pops up is, what if someone ever wants to make a hook
>> for a prefixed command.  For example, let's say I want to hook "info
>> inferiors".  I don't think that's possible today, but let's say we want
>> to make it possible.  How would that work?
>>
>> This doesn't work:
>>
>>   (gdb) define hook-info inferiors
>>    Undefined command: "hook-info".  Try "help".
>>
>> So... maybe defining "hook-info" as a prefix command would allow it?
>> Not sure, I didn't really think this through, but I wonder if you
>> thought about that case.
> 
> You can do it with “define info hook-inferiors” which I found a bit
> surprising when I discovered it.

I didn't know that!  And it's even tested:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/testsuite/gdb.base/define.exp;h=ff34e7f294376454fbefb868f4e3f90b6105f0d8;hb=HEAD#l296

... and documented in the manual.

> I think that hooks are incredibly useful but limited. My hope is that
> my patch series will make them less needed as you can get a better and
> more powerful behaviour with command renaming.

I mentioned in a previous review (somewhere in the default-args series,
I can't find it right now) that I was not too comfortable in having
features allowing modifying the behavior of builtin commands in
undocumented ways.  You could say that hooks are a way to do that.  But
at least, even if you define a hook-backtrace, the backtrace part still
works as usual, just that there are some things happening before.  Maybe
I'm a bit too afraid that some script I'm using breaks some other script
I'm using because it decided to rename some core command...

But I see why that would be useful (we use proc renaming in TCL for the
testsuite).  It's a tradeoff, with powerful tools you can go great
things but are also more likely to shoot yourself in the foot.  And I
guess we can't protect the users from themselves for everything,
otherwise our tool is useless.  And since the concept was deemed ok by
other reviewers / maintainers previously, I won't object to it.

Simon

  reply	other threads:[~2021-03-16  3:18 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 10:07 [PATCH 0/4] Add support for command renaming Marco Barisione via Gdb-patches
2021-01-08 10:07 ` [PATCH 1/4] gdb: add lookup_cmd_exact to simplify a common pattern Marco Barisione via Gdb-patches
2021-01-10  0:06   ` Lancelot SIX via Gdb-patches
2021-01-17 10:47     ` Marco Barisione via Gdb-patches
2021-01-17 19:02       ` Lancelot SIX via Gdb-patches
2021-01-25 11:33         ` Luis Machado via Gdb-patches
2021-01-08 10:07 ` [PATCH 2/4] gdb: prevent prefix commands from being hooks Marco Barisione via Gdb-patches
2021-01-08 10:07 ` [PATCH 3/4] gdb: update the docs for add_cmd and do_add_cmd to match reality Marco Barisione via Gdb-patches
2021-01-08 10:07 ` [PATCH 4/4] gdb: Add support for renaming commands Marco Barisione via Gdb-patches
2021-01-08 10:30   ` Eli Zaretskii via Gdb-patches
2021-01-25 11:26 ` [PATCH v2 0/5] Add support for command renaming Marco Barisione via Gdb-patches
2021-01-25 11:26   ` [PATCH v2 1/5] gdb: add lookup_cmd_exact to simplify a common pattern Marco Barisione via Gdb-patches
2021-03-08 18:58     ` Simon Marchi
2021-05-07 14:47       ` Marco Barisione via Gdb-patches
2021-01-25 11:26   ` [PATCH v2 2/5] gdb: prevent prefix commands from being hooks Marco Barisione via Gdb-patches
2021-03-08 21:32     ` Simon Marchi via Gdb-patches
2021-03-09  9:42       ` Marco Barisione via Gdb-patches
2021-03-16  3:17         ` Simon Marchi via Gdb-patches [this message]
2021-05-07 14:59           ` Marco Barisione via Gdb-patches
2021-05-07 19:30             ` Simon Marchi via Gdb-patches
2021-05-07 20:11               ` Marco Barisione via Gdb-patches
2021-05-14 20:38       ` [PATCH v3 " Marco Barisione via Gdb-patches
2021-01-25 11:26   ` [PATCH v2 3/5] gdb: update the docs for add_cmd and do_add_cmd to match reality Marco Barisione via Gdb-patches
2021-03-08 22:52     ` Simon Marchi via Gdb-patches
2021-03-08 23:10       ` Simon Marchi via Gdb-patches
2021-05-14 20:39       ` [PATCH v3 3/5] gdb: move declarations and docs for cli-decode.c to cli-decode.h Marco Barisione via Gdb-patches
2021-01-25 11:26   ` [PATCH v2 4/5] gdb: generate the prefix name for prefix commands on demand Marco Barisione via Gdb-patches
2021-03-08 23:25     ` Simon Marchi via Gdb-patches
2021-03-16 17:00       ` Simon Marchi via Gdb-patches
2021-05-12 11:10       ` Marco Barisione via Gdb-patches
2021-01-25 11:26   ` [PATCH v2 5/5] gdb: Add support for renaming commands Marco Barisione via Gdb-patches
2021-03-23 18:45     ` Simon Marchi via Gdb-patches
2021-05-14 20:41       ` [PATCH v3 5/5] gdb: add " Marco Barisione via Gdb-patches
2021-02-08 17:53   ` [PING] [PATCH v2 0/5] Add support for command renaming Marco Barisione via Gdb-patches
2021-02-15  8:27     ` [PING2] " Marco Barisione via Gdb-patches
2021-02-22  8:28       ` [PING 3] " Marco Barisione via Gdb-patches
2021-03-01  8:32         ` [PING 4] " Marco Barisione via Gdb-patches
2021-03-08  9:23           ` [PING 5] " Marco Barisione via Gdb-patches

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=e9da7945-b033-960a-860c-f87b463afd00@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=mbarisione@undo.io \
    --cc=simon.marchi@polymtl.ca \
    /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