From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id rihVHDUqj1/JdAAAWB0awg (envelope-from ) for ; Tue, 20 Oct 2020 14:19:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 654D91EFC1; Tue, 20 Oct 2020 14:19:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,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 1D9161E58E for ; Tue, 20 Oct 2020 14:19:32 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 697BB3947411; Tue, 20 Oct 2020 18:19:31 +0000 (GMT) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 06DAD3861845 for ; Tue, 20 Oct 2020 18:19:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 06DAD3861845 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=undo.io Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mbarisione@undo.io Received: by mail-wr1-x42b.google.com with SMTP id j7so3329216wrt.9 for ; Tue, 20 Oct 2020 11:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=undo-io.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=BXshpHbMfD04hW8y1fNjyCyizR03IuoKl97c0ivfxag=; b=shTmloeVvcFTA/ZfDmoy+t+O8H+dvZhYXzKkz60JSJuAcvJPSjf5/+t0xo9rJ4STmr TBpS8x94jYj0epz4k2qgieZodWdDxeRDW15mVW+euG5gv9CvtQJ3tVzKxmyxQnp37ru1 Cdu8Vf7BO4C3aAA1ImUjkaiW8fRw8Ecw5MqVzHr1lC2UyH3PrOQ17ADqIDMqDs85pAbJ 3tHFatievWVioubMxbK3srZOQknzy/qdRza7OHfUJnUzBBHOEsT+WRGayCvLYv1MbdRs i2QjzdiRQkEdgYrMv34IA1hF5kYuoAJhbPTBWjGAfB9o79mGEoQdLrRr2+9S/j0+1jKN 7gJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=BXshpHbMfD04hW8y1fNjyCyizR03IuoKl97c0ivfxag=; b=eOjth5kS0DQWWz+85DGioYgJbrjeKK4P0RK1J06guDKZCO5ofHUpiRPnoJTFjW1JAP QkXQLMkGbt4OVA88/D5B0Is/Bwd1QxIATDxLM8vEQqew0e9ji+sTMf/l0KqYBmQh+XWT 2SKvzlizEvEB21n1g83LKZJl+8AgEAn309raj2iQ9glLYugALQmQ5TzqFq3aL2Nuglp7 3/G3Ieo6Tlqedf4HQoUAN1LA/ztkfJP3HXTiODlld0T6nz9EMjrbrOC7r6o3Wevnn/zL IQzSQQq491qnDsReqWIIpQjOSTrxA1UmuXfOcNr4NKEGGSq90GOMxckdIsHtVUP/hM6/ 5Teg== X-Gm-Message-State: AOAM533B9Y7H3a4AYVCqfD0LEj5Ud36rn3C+Kl3q7xtSWbmXAyka39sS qlsCsJy08WIkKQp0JwR2OXwhpLsR4FSZ5KEK X-Google-Smtp-Source: ABdhPJzsI5Koxs1iw975Na+rJQESzLsoOEwhS2FLvyW785Bt5M3Ldz/IElLtRgu0yNqEvqfJ34ulKw== X-Received: by 2002:adf:fd07:: with SMTP id e7mr4704712wrr.377.1603217967969; Tue, 20 Oct 2020 11:19:27 -0700 (PDT) Received: from [192.168.0.114] (cpc159317-cmbg20-2-0-cust117.5-4.cable.virginm.net. [81.111.29.118]) by smtp.gmail.com with ESMTPSA id h16sm4078754wre.87.2020.10.20.11.19.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2020 11:19:27 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.0.3.2.82\)) Subject: Re: Add a way to invoke redefined (overridden) GDB commands From: Marco Barisione In-Reply-To: Date: Tue, 20 Oct 2020 19:19:22 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <52E32C75-B5F8-4873-8CE6-2CBC99914F22@undo.io> 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> To: Pedro Alves X-Mailer: Apple Mail (2.3654.0.3.2.82) 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 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: >=20 >>> 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. >>=20 >> That=E2=80=99s a very good point. I didn=E2=80=99t consider aliases = and hooks. >>=20 >> 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=E2=80=99t think of any way of making a rename command work like = this. >>=20 >> Any idea? >=20 > In my previous example, where it read: >=20 > (gdb) rename run org_run > (gdb) define run > ... >=20 > merge those two commands into a single atomic operation? >=20 > Like: >=20 > (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 ...] >=20 > Unlike "rename", "rename-define" (strawman name) would take care > of moving the alias and pre/post hooks to the new implementation. I can=E2=80=99t 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=E2=80=99s 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 =3D foo (gdb) rename foo bar (gdb) bar Hello world (gdb) foo Undefined command: =E2=80=9Cfoo". Try "help=E2=80=9D. (gdb) my-alias Hello world I think that rename with an "=3D" would be a bit confusing and would not provide a way of deleting commands (unlike rename in TCL). What do you think? --=20 Marco Barisione