From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Vasilij Schneidermann Newsgroups: gmane.emacs.bugs Subject: bug#24514: 24.5; [WIP][PATCH] Lispy backtraces Date: Fri, 23 Sep 2016 09:51:16 +0200 Message-ID: <20160923075116.GA612@odonien.localdomain> References: <20160922231447.GA3833@odonien.localdomain> <98fbb582-3da4-bd83-a2e9-e341dd7f6140@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: blaine.gmane.org 1474622499 32067 195.159.176.226 (23 Sep 2016 09:21:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 23 Sep 2016 09:21:39 +0000 (UTC) User-Agent: Mutt/1.7.0 (2016-08-17) To: =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel , 24514@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 23 11:21:34 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnMfQ-00057L-Vs for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Sep 2016 11:21:13 +0200 Original-Received: from localhost ([::1]:42810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnMfP-0002kC-73 for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Sep 2016 05:21:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnLHE-0007pr-6v for bug-gnu-emacs@gnu.org; Fri, 23 Sep 2016 03:52:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnLH8-00057j-8E for bug-gnu-emacs@gnu.org; Fri, 23 Sep 2016 03:52:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnLH8-00057W-5C for bug-gnu-emacs@gnu.org; Fri, 23 Sep 2016 03:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bnLH7-0005mW-Tg for bug-gnu-emacs@gnu.org; Fri, 23 Sep 2016 03:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Sep 2016 07:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24514 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24514-submit@debbugs.gnu.org id=B24514.147461710522199 (code B ref 24514); Fri, 23 Sep 2016 07:52:01 +0000 Original-Received: (at 24514) by debbugs.gnu.org; 23 Sep 2016 07:51:45 +0000 Original-Received: from localhost ([127.0.0.1]:33027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnLGr-0005lz-8p for submit@debbugs.gnu.org; Fri, 23 Sep 2016 03:51:45 -0400 Original-Received: from mail-wm0-f45.google.com ([74.125.82.45]:33921) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnLGo-0005lm-S0 for 24514@debbugs.gnu.org; Fri, 23 Sep 2016 03:51:43 -0400 Original-Received: by mail-wm0-f45.google.com with SMTP id 197so3275325wmk.1 for <24514@debbugs.gnu.org>; Fri, 23 Sep 2016 00:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RwFB4rL9waNoAvG9f5Ad/NDMzW5TozJPPPxHDpuwXBU=; b=wuY20WuMixlIVt78zvPci1x60yFII5lK8WXJTBCJjIAOIP5qCRobxgQXx0hWTTvV+k tEABgKLDmHZ7HT4I3oSglKoVYOQldLYzI9rohwGdQmvCCtpCLjQvVLd+PxVirWDRwv2j NhVnAlxH19e3AO3JnpC6F/qdUr5kWW9ukvuWNXV1Tk/7e1g43iDA9GSo99W6XMzcI6p5 PmNRgkyBFPbw0UZbTW/FYf0HQT+K8uzWr/uuXkq4zqcXOixgwhiaLvsTzjjQCI962LTS +fvLfmE90JYHE8wBGMEGN9Nh5VyJt3co9KVT1wf29sBcW1v+AvxOaIHRLuq1alxdMr4g s5jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RwFB4rL9waNoAvG9f5Ad/NDMzW5TozJPPPxHDpuwXBU=; b=J9errUda+1z29AY1pLxRiomkZD4R4kI0tnm6Fu8ExB0tWlpgat6C+9VhDuz54bVcWq J8d9OhJ3b9l4Gy8jyn2JfJKyoAunvA2cHWApxtEqAqvE4IeOUMHwqp6A6Tvm0CU+9N1n YUQIaX+yggcaeVvzoe3ADDQl4fDn0Wa6psjKKkm0l7gPjchq7pmBRnKPgrn/KIcGvQg9 n4GAx+4/WZkFnHclNcjFYTlNDvxliVtSUAawDmVkswUsHSF/CCsDuw7QX7gBFcdA2I6i 3F+evIT28pbjO/KMiND+g72sA2WCldi9z9yVBgvCqGzxnbMI9O+Cdstfz0sTCu1Pvc0B f7Jw== X-Gm-Message-State: AA6/9RmOLOqZiR1QftTGJrcO+XzTXVTGld6hEsAI9zpjqFLi68R/2jaxMn32kWqZrvhgGQ== X-Received: by 10.28.136.197 with SMTP id k188mr1509542wmd.54.1474617097087; Fri, 23 Sep 2016 00:51:37 -0700 (PDT) Original-Received: from localhost ([89.204.137.24]) by smtp.gmail.com with ESMTPSA id 188sm1781462wmo.1.2016.09.23.00.51.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Sep 2016 00:51:36 -0700 (PDT) Content-Disposition: inline In-Reply-To: <98fbb582-3da4-bd83-a2e9-e341dd7f6140@gmail.com> 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: 208.118.235.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:123585 Archived-At: > This looks great! I love it. And the patch looks very clean, too. Thanks! I've updated the patch after a bit more testing. The extra debug line happened because the search in debug.el did actually search for a `debug' call, so `(search-forward "\ (debug")` would match a call to `debug-foo` as well. Assuming there will always be extra args, this can be solved by appending a space to the search string. In case this is not true, I'll have to go for `re-search-forward` to handle a `(debug)` as well. The other problem was that there were extraneous spaces at times, this can be handled by making the line that prepends an argument with a space unconditional. > But it scares me a bit. Some tools do depend on e.g. trimming a > backtrace after printing it. Does edebug work with your patch, for > example? Yes, it does. However, you're raising a good point here. I would expect such a change to neither break Emacs core nor any of the bundled Emacs Lisp code. Guarantees about popular external code are hard to make, but communicating the change with the respective authors and maintainers should do the trick. What I've initially asked for is whether there might be any good reason for *not* doing things this way. I've grepped the 24.5 sources and most usage of `backtrace' appears to be of diagnostic nature. The only thing other than `debug.el` manipulating them is `edebug-backtrace' which I've never heard of before. I'll take a better look at its sources for my next revision of the patch. > I'm not sure what the right way to transition is. Maybe Emacs should > let Lisp programs access the backtraces in a structured way, and then > backtrace printing would only be a user-facing facility (programs > wouldn't use the textual representation). There is actually a way to do this, simply use `backtrace-frame' with an increasing integer argument until it returns nil: (let ((frame t) ; dummy value to kick-start the loop (i 0)) (while frame (setq frame (backtrace-frame i)) (message "%S" frame) (setq i (1+ i)))) This feature is used in `ert.el` to save a backtrace and reconstruct it. Perhaps all current users of `backtrace' that rely on its current representation should be using `backtrace-frame' instead?