From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 D01A73857800 for ; Mon, 14 Sep 2020 09:39:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D01A73857800 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 z1so17943397wrt.3 for ; Mon, 14 Sep 2020 02:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=undo-io.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=wv41IV8Y92PO8pnTsRUa9jW9qpZp3vu8NigSbT/bWIQ=; b=nzFOgY8YYFj01CS42PhbXVBzvoruRXkLs4OIMJ7cvdyWOcqXge1fT2CBJHA1w3JA3u dLDIMfdZP1mRlZT1zX5e8M+vUNNfevLhnv5pRrhgUf6F2IIgzWZz7ASgjScAp6WRPhmd C9ZZUI6N6eCy9BczGDjKentKr0giDK3TtgvH5XY85JSYTtjnQ6C2UZbbjgtGOtfujDU0 ED6i4GG9/kn52lgNIwUBGLsztxmktGj/Yn+2pFrUB+Yfg8USi2wYg4C6trnIHzkqM8IT n081jNdEriqRpV5EuEIroWtTwMrdwv5PBG5whS1sAHB5Qt98KLScgs0olq0kQH2T4TeI jGyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=wv41IV8Y92PO8pnTsRUa9jW9qpZp3vu8NigSbT/bWIQ=; b=tEtJJSBnXYHGUTiVHuDiNBVvPg0089HRhxm01jU2+wjRFqhXrPOp55LZdXr/dKbNqJ ZOzhga12x9V8KCspCHwybzBkXcRmHT/hQNUK0DqKU62k6WMoW5YcxC/cgLt2XxfbzmTi emZZIeqYHPhuXAL0EhhqeogXYCRGDXy27P2M1XSAPEZ0EBb+kZjo3ySVeWPkI4YLGWVH 8E9rgnjvz7falAvzC7H3jNxOKMNxsLXXdUBGZylrHt35ccHeYmVaCGfBKTZ0b9gixa3x wg5+MUMMm4ts5oU4A2yalpBXF1kHMt+Vii5FUEnLnhDRBDxBX+GHvKUCzMoaDbYGHBR9 FlFA== X-Gm-Message-State: AOAM530zQhdGFZT9vVGlCXKocfQZJJXBTU+dLF2YuGi7aSkGdJtCAfvF /utb6r6rLdV8j++xdzwl1MTe05ux2FosgM/X3VJ7sGzIsIxyqF1H7SCDBcO7bHGSL4ZlsKBcIOL 4vkzbhkj5XjyH1NkgfvdlMEyuEIc98U+Ss9VRKhVSz4Nbf1k+H+etvYaXjNDv/GmLxiu3/Afs+A == X-Google-Smtp-Source: ABdhPJzC2iswY0H1lZu7e0dTPGdftO6ImqDmnYIfwsRtYsAZ0nYwxXJETMGdpVcf5gAJDwRoMRJ3Ag== X-Received: by 2002:adf:f78f:: with SMTP id q15mr6261666wrp.206.1600076394528; Mon, 14 Sep 2020 02:39:54 -0700 (PDT) Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust117.5-4.cable.virginm.net. [81.111.29.118]) by smtp.gmail.com with ESMTPSA id q4sm21455375wru.65.2020.09.14.02.39.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 02:39:53 -0700 (PDT) From: Marco Barisione To: gdb-patches@sourceware.org Subject: Add a way to invoke redefined (overridden) GDB commands Date: Mon, 14 Sep 2020 09:39:23 +0000 Message-Id: <20200914093925.5442-1-mbarisione@undo.io> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Mon, 14 Sep 2020 09:39:57 -0000 Currently, when a GDB command is redefined, the original implementation is not available any more. This makes it difficult to build features on top of existing commands. Last year I submitted a patch to fix this but I ran out of time to address the review comments (the original patch was sent on the 28th of October 2019). These patches restart that work and should address all the comments I got last time. As the patchea are very different and a long time passed, I'm submitting as a new series. My patches add a new "uplevel" command and a new gdb.Command.invoke_uplevel method inspired by TCL (as initially suggested by Andrew Burgess) so you can do this: (gdb) define run echo Will run!\n uplevel 0 run end (gdb) run Will run! [... normal output of run ...] There are a couple of other things which could be added to make the "uplevel" command more helpful, but I think they are out of scope and my patches are already useful as they are. The first thing is adding a way of accessing the untokenised arguments to a command via something like "$arg@" (Andrew Burgess suggested "$argv", but Pedro Alves pointed out that would look like an argument vector). Another thing which could be added is the ability to do "uplevel -1 ..." to access the directly redefined command. This is implemented in Python but I couldn't find an obvious way of doing that for the "uplevel" command as there's no way of knowing which command you are currently executing (at least from what I could see). Maybe it could be implemented in a similar way to how command arguments are kept around with scoped_user_args_level, so we could keep a stack of all (user and non-user) commands which are being executed. By checking the latest one you can know what "uplevel -1" would apply to.