From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 18 22:33:10 2011 Received: (at submit) by debbugs.gnu.org; 19 Jul 2011 02:33:10 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qj07S-0004pv-Dv for submit@debbugs.gnu.org; Mon, 18 Jul 2011 22:33:10 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qj07R-0004pk-BP for submit@debbugs.gnu.org; Mon, 18 Jul 2011 22:33:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qj07K-0006pV-E6 for submit@debbugs.gnu.org; Mon, 18 Jul 2011 22:33:03 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:48916) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qj07K-0006pR-7i for submit@debbugs.gnu.org; Mon, 18 Jul 2011 22:33:02 -0400 Received: from eggs.gnu.org ([140.186.70.92]:35551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qj07I-0005kA-OL for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2011 22:33:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qj07F-0006p2-W8 for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2011 22:33:00 -0400 Received: from mail-gw0-f41.google.com ([74.125.83.41]:45088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qj07F-0006os-LC for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2011 22:32:57 -0400 Received: by gwaa12 with SMTP id a12so1793032gwa.0 for ; Mon, 18 Jul 2011 19:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:mime-version:content-type :user-agent; bh=v8x0qX20hmE6nnnyAM1iFvPsRqoTYLV+FWkzTkRRx8A=; b=vuQCjZBQv6SD+vWjLDg6o+Ma+q+1U3LMvL4QJ4E1icyPuJ5x7xJl7/UlQq+Bm4fDli Ss4Qj8CRa+j3u9gz0Rcwp1ypkLUfW4WERqfgSxRQ5di4c7dFC2kjHyw0IESIKUMPk2T6 aSGRE1oYjoZbhz+4TsvhRvdH3Lzml+i9sk5k0= Received: by 10.236.182.162 with SMTP id o22mr8900028yhm.40.1311042776440; Mon, 18 Jul 2011 19:32:56 -0700 (PDT) Received: from isil.kanru.info (61-30-10-70.static.tfn.net.tw [61.30.10.70]) by mx.google.com with ESMTPS id c63sm3748030yhe.4.2011.07.18.19.32.53 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jul 2011 19:32:55 -0700 (PDT) Received: from kanru by isil.kanru.info with local (Exim 4.76) (envelope-from ) id 1Qj075-0003u3-RE for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2011 10:32:47 +0800 From: Kan-Ru Chen To: bug-gnu-emacs@gnu.org Subject: 24.0.50; Cannot debug lexical-binded function (closure) Date: Tue, 19 Jul 2011 10:32:22 +0800 Message-ID: <87oc0r3sqx.fsf@isil.kanru.info> MIME-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) The lisp debugger doesn't know the closure form: (setq lexical-binding t) (defun my-test nil) (debug-on-entry 'my-test) => (error "my-test is not a user-defined Lisp function") And if the file was byte-compiled, for example: (debug-on-entry 'shell) (shell) => call-interactively: Invalid function: (lambda 256 "Run an inferior shell, with I/O through BUFFER (which defaults to `*shell*'). [rest of the doc string] Thus one cannot debug most byte-compiled lisp functions (46 files under lisp/ have declared lexical-binding). -- Kanru In GNU Emacs 24.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.5) of 2011-07-19 on isil configured using `configure '--with-xpm=no' '--with-gif=no' '--with-tiff=no'' From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 22 17:19:47 2011 Received: (at 9120-done) by debbugs.gnu.org; 22 Aug 2011 21:19:47 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QvbuL-0007vO-GL for submit@debbugs.gnu.org; Mon, 22 Aug 2011 17:19:47 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QvbuE-0007v1-Me for 9120-done@debbugs.gnu.org; Mon, 22 Aug 2011 17:19:42 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAAPHUk5Ld+HZ/2dsb2JhbABBqBR4gUABAQQBViMFCws0EhQYDSQTh3G1NIZIBJ9xhDY X-IronPort-AV: E=Sophos;i="4.68,265,1312171200"; d="scan'208";a="132235171" Received: from 75-119-225-217.dsl.teksavvy.com (HELO ceviche.home) ([75.119.225.217]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 22 Aug 2011 17:17:03 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 6BCD06610A; Mon, 22 Aug 2011 17:17:03 -0400 (EDT) From: Stefan Monnier To: Kan-Ru Chen Subject: Re: bug#9120: 24.0.50; Cannot debug lexical-binded function (closure) Message-ID: References: <87oc0r3sqx.fsf@isil.kanru.info> Date: Mon, 22 Aug 2011 17:17:03 -0400 In-Reply-To: <87oc0r3sqx.fsf@isil.kanru.info> (Kan-Ru Chen's message of "Tue, 19 Jul 2011 10:32:22 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 9120-done Cc: 9120-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > The lisp debugger doesn't know the closure form: > (setq lexical-binding t) > (defun my-test nil) > (debug-on-entry 'my-test) > => (error "my-test is not a user-defined Lisp function") > And if the file was byte-compiled, for example: > (debug-on-entry 'shell) > (shell) > => call-interactively: Invalid function: (lambda 256 "Run an inferior > shell, with I/O through BUFFER (which defaults to `*shell*'). [rest of > the doc string] > Thus one cannot debug most byte-compiled lisp functions (46 files > under lisp/ have declared lexical-binding). I've installed the patch below which should fix this without breaking other uses. Please report any problem you encounter with the new code. Stefan === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-08-22 12:46:45 +0000 +++ lisp/ChangeLog 2011-08-22 21:15:10 +0000 @@ -1,3 +1,9 @@ +2011-08-22 Stefan Monnier + + * emacs-lisp/debug.el (debug-arglist): New function. + (debug-convert-byte-code): Use it. Handle lexical byte-codes. + (debug-on-entry-1): Handle interpreted closures (bug#9120). + 2011-08-22 Juri Linkov * progmodes/compile.el (compilation-mode-font-lock-keywords): === modified file 'lisp/emacs-lisp/debug.el' --- lisp/emacs-lisp/debug.el 2011-07-15 02:16:55 +0000 +++ lisp/emacs-lisp/debug.el 2011-08-22 21:12:18 +0000 @@ -778,6 +778,7 @@ (not (debugger-special-form-p symbol)))) t nil nil (symbol-name fn))) (list (if (equal val "") fn (intern val))))) + ;; FIXME: Use advice.el. (when (debugger-special-form-p function) (error "Function %s is a special form" function)) (if (or (symbolp (symbol-function function)) @@ -835,24 +836,30 @@ (message "Cancelling debug-on-entry for all functions") (mapcar 'cancel-debug-on-entry debug-function-list))) +(defun debug-arglist (definition) + ;; FIXME: copied from ad-arglist. + "Return the argument list of DEFINITION." + (require 'help-fns) + (help-function-arglist definition 'preserve-names)) + (defun debug-convert-byte-code (function) (let* ((defn (symbol-function function)) (macro (eq (car-safe defn) 'macro))) (when macro (setq defn (cdr defn))) - (unless (consp defn) - ;; Assume a compiled code object. - (let* ((contents (append defn nil)) + (when (byte-code-function-p defn) + (let* ((args (debug-arglist defn)) (body - (list (list 'byte-code (nth 1 contents) - (nth 2 contents) (nth 3 contents))))) - (if (nthcdr 5 contents) - (setq body (cons (list 'interactive (nth 5 contents)) body))) - (if (nth 4 contents) + `((,(if (memq '&rest args) #'apply #'funcall) + ,defn + ,@(remq '&rest (remq '&optional args)))))) + (if (> (length defn) 5) + (push `(interactive ,(aref defn 5)) body)) + (if (aref defn 4) ;; Use `documentation' here, to get the actual string, ;; in case the compiled function has a reference ;; to the .elc file. (setq body (cons (documentation function) body))) - (setq defn (cons 'lambda (cons (car contents) body)))) + (setq defn `(closure (t) ,args ,@body))) (when macro (setq defn (cons 'macro defn))) (fset function defn)))) @@ -861,11 +868,12 @@ (tail defn)) (when (eq (car-safe tail) 'macro) (setq tail (cdr tail))) - (if (not (eq (car-safe tail) 'lambda)) + (if (not (memq (car-safe tail) '(closure lambda))) ;; Only signal an error when we try to set debug-on-entry. ;; When we try to clear debug-on-entry, we are now done. (when flag (error "%s is not a user-defined Lisp function" function)) + (if (eq (car tail) 'closure) (setq tail (cdr tail))) (setq tail (cdr tail)) ;; Skip the docstring. (when (and (stringp (cadr tail)) (cddr tail)) @@ -875,9 +883,9 @@ (setq tail (cdr tail))) (unless (eq flag (equal (cadr tail) '(implement-debug-on-entry))) ;; Add/remove debug statement as needed. - (if flag - (setcdr tail (cons '(implement-debug-on-entry) (cdr tail))) - (setcdr tail (cddr tail))))) + (setcdr tail (if flag + (cons '(implement-debug-on-entry) (cdr tail)) + (cddr tail))))) defn)) (defun debugger-list-functions () From unknown Fri Sep 05 11:50:22 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 20 Sep 2011 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 20 18:37:11 2011 Received: (at control) by debbugs.gnu.org; 20 Sep 2011 22:37:11 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R68wB-0003or-3S for submit@debbugs.gnu.org; Tue, 20 Sep 2011 18:37:11 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R68w8-0003oj-0Y for control@debbugs.gnu.org; Tue, 20 Sep 2011 18:37:09 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1R68vw-0007tC-3E for control@debbugs.gnu.org; Tue, 20 Sep 2011 18:36:56 -0400 Date: Tue, 20 Sep 2011 18:36:56 -0400 Message-Id: Subject: control message for bug 9120 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) unarchive 9120 merge 8458 9120 From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 20 21:07:25 2011 Received: (at control) by debbugs.gnu.org; 21 Sep 2011 01:07:25 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R6BHY-00083z-Km for submit@debbugs.gnu.org; Tue, 20 Sep 2011 21:07:25 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R6BHW-00083r-ON for control@debbugs.gnu.org; Tue, 20 Sep 2011 21:07:23 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoEHACY4eU5FpZ7x/2dsb2JhbABCmTWOLXmBUwEBBVYzCzQHCxQYDbtqhn0EoFGERA X-IronPort-AV: E=Sophos;i="4.68,414,1312171200"; d="scan'208";a="137564825" Received: from 69-165-158-241.dsl.teksavvy.com (HELO pastel.home) ([69.165.158.241]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 20 Sep 2011 21:07:09 -0400 Received: by pastel.home (Postfix, from userid 20848) id 303FF58F15; Tue, 20 Sep 2011 21:07:09 -0400 (EDT) From: Stefan Monnier To: control@debbugs.gnu.org Subject: Re: Processed: Re: bug#8458: 24.0.50; Error: delete-minibuffer-contents is not a user-defined Lisp function Message-ID: References: Date: Tue, 20 Sep 2011 21:07:09 -0400 In-Reply-To: (GNU bug Tracking System's message of "Tue, 20 Sep 2011 17:39:03 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) unarchive 9120 forcemerge 9120 8458 thanks From unknown Fri Sep 05 11:50:22 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 19 Oct 2011 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator