From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aKxWAD0tj18DdQAAWB0awg (envelope-from ) for ; Tue, 20 Oct 2020 14:32:29 -0400 Received: by simark.ca (Postfix, from userid 112) id E70341EFC1; Tue, 20 Oct 2020 14:32:28 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F41EE1E58E for ; Tue, 20 Oct 2020 14:32:27 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 894EA3850414; Tue, 20 Oct 2020 18:32:27 +0000 (GMT) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by sourceware.org (Postfix) with ESMTPS id 1EC4A3850414 for ; Tue, 20 Oct 2020 18:32:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1EC4A3850414 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wr1-f51.google.com with SMTP id j7so3378101wrt.9 for ; Tue, 20 Oct 2020 11:32:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=URB0NE8BmNrlKvax50SU+3yDlnUuf1p72KnLk2mug0Q=; b=Cvbf+32CbGTyK9sYjC3/qNid1Wjsh3kNwqUvF/zYn1MopBpd+k6qEwA9HCnE+aohSn gORBbhPjmAb002kLHMd404ArgkvO7j7j1Fw+bl6Z8MBKs/223TAn9oPlYaLhq0RpVDmZ ujX9PEBETqut2K3AfKxW16eytwOxr7kiLzWS0pHywiaJnQekUyRcCoVwirLpvFrmjoqO 6hRUw8WxklD+9XNYTeSuZjIa9mbttKBHzxVYtCzYah/hQaDTMSKJdzE8taiNtTGuqs6p T3/eq4WO31tHD+0nOMxs6mtD1aKreqQY9oSUZ5GdHVwDElGk8D9bQ/6tUZO7Thsc8Pmt 3uzg== X-Gm-Message-State: AOAM531DOesDoUE4z12PmA1LQeOaNPgnw7PasBjNktFmTHVG7KSpObd5 KqoxA7sidrdaPDitg4N6fq/PZSX+lAFvQQ== X-Google-Smtp-Source: ABdhPJysU4ggECnHmhLuHW6KGIPmdt7rg2yTIYavYel8PFhe8UFKaVBG3S426deJiMChDj8WfJ9rNQ== X-Received: by 2002:adf:e8c7:: with SMTP id k7mr4973946wrn.102.1603218743287; Tue, 20 Oct 2020 11:32:23 -0700 (PDT) Received: from ?IPv6:2001:8a0:f91e:6d00:c80a:ea25:47ef:5f73? ([2001:8a0:f91e:6d00:c80a:ea25:47ef:5f73]) by smtp.gmail.com with ESMTPSA id m8sm3979742wrw.17.2020.10.20.11.32.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Oct 2020 11:32:21 -0700 (PDT) Subject: Re: Add a way to invoke redefined (overridden) GDB commands To: Marco Barisione References: <20200914093925.5442-1-mbarisione@undo.io> <371BE292-EE03-4FBE-A963-64F08437A6A7@undo.io> <553d9751c944c660dad4a204cf4609c660baa106.camel@skynet.be> <167570B7-6E55-4136-97DB-2D0F2B191B7D@undo.io> <52E32C75-B5F8-4873-8CE6-2CBC99914F22@undo.io> From: Pedro Alves Message-ID: <0e806f54-5319-e148-c8ae-7322f56f1ac1@palves.net> Date: Tue, 20 Oct 2020 19:32:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <52E32C75-B5F8-4873-8CE6-2CBC99914F22@undo.io> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 10/20/20 7:19 PM, Marco Barisione wrote: > On 20 Oct 2020, at 16:06, Pedro Alves wrote: >> On 10/19/20 8:28 PM, Marco Barisione wrote: >>> On 19 Oct 2020, at 19:47, Philippe Waroquiers 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? +1