From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#38195: 27.0.50; `edebug-remove-instrumentation' doesn't work for adviced functions Date: Tue, 26 Nov 2019 22:01:32 +0100 Message-ID: <87a78iuzbn.fsf@web.de> References: <87mucz98y9.fsf@web.de> <87r22brq3b.fsf@gnus.org> <87eeya9z3z.fsf@web.de> <87imnm4315.fsf@web.de> <87eey9z1mr.fsf@web.de> <87o8xaoe6j.fsf@web.de> <877e3t78l5.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="168137"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Stefan Monnier , 38195@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 26 22:06:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iZi2H-000hYd-Eh for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Nov 2019 22:06:13 +0100 Original-Received: from localhost ([::1]:59002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZi2F-0004pa-6P for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Nov 2019 16:06:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46502) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZi1C-0004gu-Vj for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2019 16:05:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZhyE-00030E-Nr for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2019 16:02:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47115) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iZhyE-000301-Ia for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2019 16:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iZhyE-0004mC-GA for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2019 16:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Nov 2019 21:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38195 X-GNU-PR-Package: emacs Original-Received: via spool by 38195-submit@debbugs.gnu.org id=B38195.157480210718337 (code B ref 38195); Tue, 26 Nov 2019 21:02:02 +0000 Original-Received: (at 38195) by debbugs.gnu.org; 26 Nov 2019 21:01:47 +0000 Original-Received: from localhost ([127.0.0.1]:53088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iZhxz-0004lh-AF for submit@debbugs.gnu.org; Tue, 26 Nov 2019 16:01:47 -0500 Original-Received: from mout.web.de ([212.227.17.12]:51193) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iZhxy-0004lU-78 for 38195@debbugs.gnu.org; Tue, 26 Nov 2019 16:01:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1574802093; bh=DJOt+0/HoOLr1LTkNbb2tLDGnrcjNOPUrXae9T42AGM=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=iPDeoSvoysZvrMJLwpyVKpooo0VzWpfL0I/jzRbWUet/IO4R7es+im9X4bOt7kcFz rQ5UJKjuZiKUyxPQJqGIFHyOjNtazztyWHXa2pyGMPZWZghBQdQvOA0UvLKTgkckg7 /tEflKUZVIhzckfcftqUR72j2Fh+iB7mD95sTBoA= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([94.218.222.9]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MMVpy-1iSYIF1n5i-008JpD; Tue, 26 Nov 2019 22:01:33 +0100 In-Reply-To: <877e3t78l5.fsf@web.de> (Michael Heerdegen's message of "Thu, 21 Nov 2019 12:49:26 +0100") X-Provags-ID: V03:K1:PvSO51OqC0g73Mziqwh3r2LCFHIYf6kfy1RTguJD8G+fDrEwkAf i00Yo76TS2D9xnH0ff2vmWcueeZ3kACIPrVV3S+q3+0SAAzBNoXs0oVkPyllHz1MkaQ3fPi 6B8DThBi/uxb+sNbPBIEI15jc+Zr2hVhem/94NhD1Xt62hm5RY9m10+xJTRlJ52Xu8IEQ8A i9EzAj0f3FWYcvdoWTdmg== X-UI-Out-Filterresults: notjunk:1;V03:K0:DWEQTgeXwGE=:An90YADeUe+qPwJfaRGXza SLnlJtHtbyVgQZcgjqCtJxCDtEJ66LoiqL2B84P86RqJLsPmQIO5GJ9nvl498EKccvfx76xoI liQdqQUJdB8V3bExwnwmx+Uuj+wl0amyv0ofdA0cABIpnBh3J91hUh2vovcdEgmKH8hyuHKrU 2DSFPxM/Jai3Hkgwn7LC4NUo/R/Dsvg8gl24BTn3jC+nBiPhDbOJCGoSmPRQtTNtBw0rP5JGX UmHrbznTC40GGfJEIcNsVivjJKgMLV0ZnG9hF4esfe85AE4q2DlwgWN1gKe0Il0u/+r7DbqBy Li548R57yZSrSHZpIxPdf8+w/3e5rQfe7qrj5OyeOWLkc7XMrT0VcxsSPB868YHjqxjsGQnLR szfbDZSWBKDnhV1zUURwnrGwlclP55G3opZJx4MWBeshYTGTufvJznua8/k5QVsh0dmSYkXnd y0jproylYSxqyR9BGbTXUnDEzvrLmKpQ8ZTmtuAefwiE8I8M7Hgb+pDvKKrUZNI8GdsofMCcM GfWNzHpB1FUZ7xPzjvF6gn/x3pfCXZWY5FTm7+sjB3C5F8i7BkHHGQGH/T0kd8LFvXxiULig0 t2KgDVshaQDUyMIJuraBcfXGPE/frWoVecHjD/+f+GrxSRFYVIKBM5unpbST+28V6DlIYotNC rd8JQgSxTGdZPU+4EK8oTk8UkmZ+KSSkWoHpLYO7rUQxgjANRqcYbIUpkoPS6hyoQs65fDkjo cHWDBa84VbdwmilEUOY9ccn6DG4NluYjVT9HKJywCdRgT3BMFVOoWq4mU2gi1vPjFELvxucV X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:172490 Archived-At: --=-=-= Content-Type: text/plain Michael Heerdegen writes: > BTW, I also wonder if we should enhance the command > `edebug-remove-instrumentation' so that it is able to reload source > files. It could look at the SYMOL's `symbol-file's, collect these, load > the files, and only do what it does now for the symbols that are still > wrapped. Here is a draft. Any thoughts (Lars)? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-WIP-edebug-see-38195-ask-whether-to-reload-files-to-.patch Content-Transfer-Encoding: quoted-printable =46rom 681370954b2f5168e6e0793a9a7ded76db671682 Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Tue, 26 Nov 2019 19:23:45 +0100 Subject: [PATCH] WIP: edebug: see 38195, ask whether to reload files to deinstrument =2D-- lisp/emacs-lisp/edebug.el | 73 ++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index d68ed966f8..29bb27fc0d 100644 =2D-- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -4586,36 +4586,77 @@ edebug--unwrap*-symbol-function (was-macro `(macro . ,unwrapped)) (t unwrapped)))))) +(defcustom edebug-reload-files 'ask + "Whether `edebug-remove-instrumentation' should reload files. + +When non-nil, `edebug-remove-instrumentation' will reload files +where possible to get rid of instrumentation. When the non-nil +value is the symbol 'ask, ask for every individual file before +loading it. + +When nil or when no defining file can be found remove edebug +instrumentation by manipulating symbol functions." + :type '(choice (const :tag "On" t) + (const :tag "Ask for every file" ask) + (const :tag "Off" nil))) + +(defun edebug-get-instrumented-functions () + (let ((functions '())) + (mapatoms + (lambda (symbol) + (when (and (get symbol 'edebug) + (or (functionp symbol) + (macrop symbol)) + (edebug--unwrap*-symbol-function + symbol)) + (push symbol functions))) + obarray) + functions)) + (defun edebug-remove-instrumentation (functions) "Remove Edebug instrumentation from FUNCTIONS. Interactively, the user is prompted for the function to remove instrumentation for, defaulting to all functions." (interactive (list - (let ((functions nil)) - (mapatoms - (lambda (symbol) - (when (and (get symbol 'edebug) - (or (functionp symbol) - (macrop symbol)) - (edebug--unwrap*-symbol-function - symbol)) - (push symbol functions))) - obarray) + (let ((functions (edebug-get-instrumented-functions))) (unless functions (error "Found no functions to remove instrumentation from")) (let ((name (completing-read "Remove instrumentation from (default all functions): " functions))) - (if (and name - (not (equal name ""))) + (if (and name (not (equal name ""))) (list (intern name)) - functions))))) - ;; Remove instrumentation. + t))))) + (unless (listp functions) + (setq functions (edebug-get-instrumented-functions))) + (when edebug-reload-files + (let ((files '())) + (dolist (f functions) + (when-let ((file (symbol-file f 'defun))) + (unless (cl-some (apply-partially #'file-equal-p file) files) + (push file files)))) + (let ((do-all (eq edebug-reload-files t)) + file) + (while files + (setq file (pop files)) + (when (or do-all + (pcase (car (read-multiple-choice + (format "Load %s ?" file) + (list (list ?y "y" "Reload this file") + (list ?Y "Y" "\ +Reload this and all following files") + (list ?n "n" "Don't load this file= ") + (list ?N "N" "\ +Don't load this and any following files")))) + (?y t) + (?Y (setq do-all t) t) + (?n nil) + (?N (setq files nil) nil))) + (load file 'noerror nil 'nosuffix)))))) (dolist (symbol functions) - (when-let ((unwrapped - (edebug--unwrap*-symbol-function symbol))) + (when-let ((unwrapped (edebug--unwrap*-symbol-function symbol))) (defalias symbol unwrapped))) (message "Removed edebug instrumentation from %s" (mapconcat #'symbol-name functions ", "))) =2D- 2.24.0 --=-=-= Content-Type: text/plain Regards, Michael. --=-=-=--