From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: bug#24514: 24.5; Lispy backtraces Date: Thu, 1 Dec 2016 20:23:50 -0500 Message-ID: <0a69afa7-e9e6-e75f-8e90-6438683db98d@gmail.com> References: <20160922231447.GA3833@odonien.localdomain> <98fbb582-3da4-bd83-a2e9-e341dd7f6140@gmail.com> <20160923075116.GA612@odonien.localdomain> <82e39377-f31b-698c-5a9a-343868686799@gmail.com> <20161202005226.GA4215@odonien.localdomain> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Rflbcgx496CvlD8i8gX5ncwgHG4tSQoLX" X-Trace: blaine.gmane.org 1480641904 23394 195.159.176.226 (2 Dec 2016 01:25:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 2 Dec 2016 01:25:04 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 Cc: Emacs developers To: Vasilij Schneidermann Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 02 02:25:00 2016 Return-path: Envelope-to: ged-emacs-devel@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 1cCcax-0005RY-Kq for ged-emacs-devel@m.gmane.org; Fri, 02 Dec 2016 02:24:59 +0100 Original-Received: from localhost ([::1]:59859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCcb1-0001Fi-Fc for ged-emacs-devel@m.gmane.org; Thu, 01 Dec 2016 20:25:03 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCca3-0001Ea-Sk for emacs-devel@gnu.org; Thu, 01 Dec 2016 20:24:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCca0-00048i-Ma for emacs-devel@gnu.org; Thu, 01 Dec 2016 20:24:03 -0500 Original-Received: from mout.kundenserver.de ([212.227.17.13]:60644) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCca0-00047k-D8 for emacs-devel@gnu.org; Thu, 01 Dec 2016 20:24:00 -0500 Original-Received: from [18.26.2.123] ([18.26.2.123]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.184]) with ESMTPSA (Nemesis) id 0LpfQU-1crkMN2PTy-00fORj; Fri, 02 Dec 2016 02:23:57 +0100 In-Reply-To: <20161202005226.GA4215@odonien.localdomain> X-Provags-ID: V03:K0:PLPaemP0BHcutEVjOD6jMqs6QLzIxUv5iztgqGx14AdxWP/S9eM UBYvC9XWNOqZaCoxRR5XAmFd162iu+SVK+6d4i5pO5gLSX0KeQqA0f2UGTAFazzXTgRKDHw 1hbiyqYPJmuFOhBtuGG+sefHROinQGdkmkaOequ4XR3RHVakgl+pmh4EbfRDVKX0SRKT6s5 kQ+m2d66wo5nxfEvQ4Uqw== X-UI-Out-Filterresults: notjunk:1;V01:K0:7H4ttuEhz2w=:EMvVssmwH+gz35uOt44DrX 22d8fzYdQvtVP115hshGUjbCIPl2c61oqG5na6oj3dlkl19EtjtaQzsnuMZxUxGUh4Yr5Rr04 7o1Gq1R5oucHFyqiQjjFE/UiOmurlcSy2Ed9X04kOCmdF6xFFzZCge8VADIj5CyVJU2qhlQvI bD1jl1vkqvr+Cjo7LqwbWE6N+Z8Qq9iNMQY64ith6fyr7QQ5zloWj4B3vprmvQiWAF6gl3sMk EzAO4dbkJFEExXrYsWtVFmWSsHv8Xc3yIpgFnp6Yk8G8CmNXKJdxz2PjmTIx77E8jnTP+GsEv uq/dl/Bb6rQCjni0cvIiosIegqwHe/Sfkx1EOMX86zK8KXQauZhhsgUajtK7dvUC9m0YyRdk9 Jizf4zqXksr7dpG4pax2siheOOu8zBBDsuQCDhPj1gGNmqMKAbTw57IZmGLMdOxaJQujGiCtP DeaJwdKfJtH3cXaSdgFdG5T/XhZmKzihtFZztKsxoV+ub2G+3Zp23MHu0V+DOutVo789DOyob 6yyFLnOv7Xpf5MdyN8PoJwyJFL6BepuNVmyZbvPVIVCKuL3MOoArDMfCB9v08pBMaOd4YVRLz ZfSByrJSAH4gxePITUHQXuSsbhC+9NLTtgYh1px+d1qcphqgk3b3BOCmOU9Set9J0tWHUsho0 9omHijgVVau2scSkmiRPbMWlgbEIT8J+ct7EcJguxYeYqBmJeL9cIJbnH4akfPTBTReQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.13 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:209897 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Rflbcgx496CvlD8i8gX5ncwgHG4tSQoLX Content-Type: multipart/mixed; boundary="O5bbPq3TRp3KqF07in1ACrCo3SoA1tWaH"; protected-headers="v1" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: Vasilij Schneidermann Cc: Emacs developers Message-ID: <0a69afa7-e9e6-e75f-8e90-6438683db98d@gmail.com> Subject: Re: bug#24514: 24.5; Lispy backtraces References: <20160922231447.GA3833@odonien.localdomain> <98fbb582-3da4-bd83-a2e9-e341dd7f6140@gmail.com> <20160923075116.GA612@odonien.localdomain> <82e39377-f31b-698c-5a9a-343868686799@gmail.com> <20161202005226.GA4215@odonien.localdomain> In-Reply-To: <20161202005226.GA4215@odonien.localdomain> --O5bbPq3TRp3KqF07in1ACrCo3SoA1tWaH Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi emacs-devel, The discussion below seems to indicate that there's very little missing a= t the Lisp level to be able to implement `backtrace' in Lisp; is that rig= ht? The documentation for backtrace states: It is written in C, since it must have access to the stack to determine which function calls are active. The return value is always =E2=80=98nil=E2=80=99. But the existence of backtrace-frame seems to (partially) contradict this= ; or am I misunderstanding? The context is that I need to capture backtraces on an Emacs server, and = that I have no way (AFAICT) to know, when my debugger gets invoked, wheth= er the error will then be handled by a condition-case block; thus I end u= p recording too much and my program ends up spending 95% of its time capt= uring useless backtraces. =20 Instead, recording a sequence of backtrace-frame seems fast (thanks Vasil= ij!). But then, if an unhandled exception occurs, I need to actually for= mat the recorded stack frames; which seems to be what `backtrace' does, o= nly at the C level. Cheers Cl=C3=A9ment.=20 On 2016-12-01 19:52, Vasilij Schneidermann wrote: >> Thinking more about this, isn't this enough to implement `backtrace' i= n Lisp? >=20 > Not quite. If you look at backtraces, you'll notice they are constantl= y > prefixed with two spaces. This prefix is conditional and can be > replaced with an asterisk and a space to indicate where you currently > are when stepping through the backtrace. From what I can tell, there i= s > no way to retrieve that information when relying on `backtrace-frame' > only. >=20 > If you ignore that part, it's not too hard to write a replacement: >=20 > (with-output-to-string > (let ((print-level (or print-level 8)) > (i 0) > frame) > (while (setq frame (backtrace-frame i)) > (princ " ") > (if (not (car frame)) > (prin1 (cdr frame)) > (prin1 (cadr frame)) > (prin1 (cddr frame))) > (terpri) > (setq i (1+ i))))) >=20 > How faithful that one is, I don't know. Perhaps this is a discussion b= etter > held on emacs-devel? >=20 --O5bbPq3TRp3KqF07in1ACrCo3SoA1tWaH-- --Rflbcgx496CvlD8i8gX5ncwgHG4tSQoLX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYQM0mAAoJEPqg+cTm90wjiTYP/0+zUhjJu+yBqWPrExui9POW TsjpVwE0az4De2megbHtr/1uyVnSmMCJFE8G43Ava+2aRnBRPsZ/R5x2OPd/DLJD F3E3GO7Keft4BIZVokTj5umaGz0nOBlPLzHTWYIQh3lYg+TCuilwLewSqXpH4gHv Aiq/9bFSnIvsp2Vcdeg2qMkvz0xB/zb0pOGjhBSoq6tk0Xp35DknxSH2yZJuEkOx G6dP8nT7gwcOj6Je5PdugLR9wj/5Uu0m0VszMab9RzkrQKyIW3DfFYSHjjJudZVS uHp22+kGaytkPAwPMRgZY6Fdb4/NiUPh05s24V1aqoUoZDw0TQoAiYAROi3DjqmZ ZzOiE1dXlCjUqMnPYcLXFT4NZzeeuZOZjFi3/10Igdht4fV9mbZsUCtBFJs+QsHA Z336aiTGAjMO6ZVSnAoEwTl9DdBjZvILsGQcKU9T1sFVcUv9E8mXxNpeXa5GHSfX nlA91Y2X48tPpLNc57p+IgvJ0psG6fZs+cYVBKn5Qyb34JxspMHJ+dIG4C7SrJTZ g8AeJK1cJf8ovBMS8GWHq5k08xUgA+8ff7E35Cv4YhwEr0ptHbTlVCrUKS0IGzqq 5dxIrBBzP+M+C0dgvcvmy/tL57SgyWQ6ULd/+5cDqwuamP3Gi3ivUWcDTGRuNx0q ERC/bo9CpLY4Ni5ki18z =L+Ng -----END PGP SIGNATURE----- --Rflbcgx496CvlD8i8gX5ncwgHG4tSQoLX--