From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CwARO+Mu+F+1JwAAWB0awg (envelope-from ) for ; Fri, 08 Jan 2021 05:07:31 -0500 Received: by simark.ca (Postfix, from userid 112) id DFD471E99A; Fri, 8 Jan 2021 05:07:31 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 89D8A1E4F4; Fri, 8 Jan 2021 05:07:31 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 315F8384A01A; Fri, 8 Jan 2021 10:07:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 315F8384A01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610100451; bh=E0Jd8XBh/waP76ZxnntiJTKVZqATMe42m73EhIqldww=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=PykMnUpF8NgtmbmtZdAVVcF79W6FUpUO2+yckGuCth7gRTHZwiWZyX1KwOsb7g0MZ iyz5/PkOc7Ceq96M7v8iqCGrFTCY0sS0Gzt1sWgjZfzBpXWwnby6aNsrbmj+dQs4zi pJdfWxZoceg31mRUj8SBVNf9NdolXt6RQrKIGLwk= Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id CF8003858025 for ; Fri, 8 Jan 2021 10:07:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CF8003858025 Received: by mail-wr1-x432.google.com with SMTP id d26so8379231wrb.12 for ; Fri, 08 Jan 2021 02:07:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E0Jd8XBh/waP76ZxnntiJTKVZqATMe42m73EhIqldww=; b=sOt/OMZm+ylvsf+Og9Q2SGr/hOw+y4Ihy0YlRWlDY/ANAygzF1XivZuweYARCKsCj/ 46bUHLMuogwWWt8L4Je/FrXjwQthbcRn2P9a47sXmK46yJlSejaQlndR+2J86zc1Ruzz wvPqin4sq0AKwgwHvZoO/MBriRVDC6eGTTTgzkUERrWTYXY3JpLJcRFE7eqRx1c0I2Yz flEhxAdqPBJtFFVFJaZ+kAr4mSgKyKJTuigjir9Jsljt4ahC4eT+ur0HDJHLPIUL1VOh RBLoqyK2LXSeLN8dDHkC9W5zNDG5RT9zKuFEjGo1VZuj2by/2R5om393o1gkOpxxEvmH 1aRQ== X-Gm-Message-State: AOAM531Ao/DbSGSFku2A53fwueroKAHfzRyWvCQrsVRmSY2l831yWbKa yRH/yBYIPz6ltTGgX02ZbqCYx+cZ13FCj4JfRp9MR7tk15nzErfM0n8eVTob3mv5uaTc+LpN64R ETAXq+YuSo8O6hgikHncJ++TwbW5oPz+ow1Df57h5CLTy2xr+C/WILFTFJsOwuVl5XptMvQsgUH q5 X-Google-Smtp-Source: ABdhPJxu76nfTiT0pMsKsXkuAlLnk9qmNvxCBh2yhlOsz6ZkZqi2lzqwCaUkqlXkDCrsl+NPOACVlA== X-Received: by 2002:a5d:4683:: with SMTP id u3mr2916151wrq.19.1610100447625; Fri, 08 Jan 2021 02:07:27 -0800 (PST) Received: from focaccia.undoers.io (cpc159317-cmbg20-2-0-cust151.5-4.cable.virginm.net. [81.111.29.152]) by smtp.gmail.com with ESMTPSA id s205sm11579143wmf.46.2021.01.08.02.07.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jan 2021 02:07:27 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH 0/4] Add support for command renaming Date: Fri, 8 Jan 2021 10:07:02 +0000 Message-Id: <20210108100706.96190-1-mbarisione@undo.io> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 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: , From: Marco Barisione via Gdb-patches Reply-To: Marco Barisione Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This patch series adds support for command renaming to GDB. The main use case is to extend existing commands: * The original command gets renamed. * A new command with the same original name gets defined and then calls the renamed one. This feature is accessible via GDB commands ("rename" and "define -rename-existing-to") and in Python via a new rename_existing_to argument argument to gdb.Command.__init__. This is the third attempt at achieving this, the first patch series (see https://sourceware.org/legacy-ml/gdb-patches/2019-10/msg00985.html) used a completely different approach where a command, once overwritten, was preserved by the new command (via a new field in cmd_list_element). Overwriting commands could access the original implementation via a Python method on gdb.Command. The second attempt (see https://sourceware.org/pipermail/gdb-patches/2020-September/171829.html) was a revised version of the previous one which worked in a similar way, but using a slightly different terminology. It also added a way to access this feature via a GDB command, not only via Python. In response to my patches, Pedro Alves recommended a different approach involving command renaming, which is what I implemented here. Note that I didn't use "v3" in these patches are the approach is completely different from previous attempts, so it's not really a new version of already proposed patches (even if the end goal of this feature is the same). Marco Barisione (4): gdb: add lookup_cmd_exact to simplify a common pattern gdb: prevent prefix commands from being hooks gdb: update the docs for add_cmd and do_add_cmd to match reality gdb: Add support for renaming commands gdb/NEWS | 26 + gdb/cli/cli-decode.c | 708 +++++++++++++++--- gdb/cli/cli-decode.h | 3 + gdb/cli/cli-script.c | 368 +++++++-- gdb/command.h | 103 ++- gdb/doc/gdb.texinfo | 55 +- gdb/doc/python.texi | 38 +- gdb/python/py-cmd.c | 172 ++++- gdb/testsuite/gdb.base/command-renaming.exp | 571 ++++++++++++++ gdb/testsuite/gdb.base/define-prefix.exp | 24 + .../gdb.python/py-rename-existing.exp | 364 +++++++++ .../gdb.python/py-rename-existing.py | 46 ++ 12 files changed, 2238 insertions(+), 240 deletions(-) create mode 100644 gdb/testsuite/gdb.base/command-renaming.exp create mode 100644 gdb/testsuite/gdb.python/py-rename-existing.exp create mode 100644 gdb/testsuite/gdb.python/py-rename-existing.py -- 2.28.0