From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Lisp-friendly backtraces [was: Lispy backtraces] Date: Mon, 05 Dec 2016 08:20:30 -0500 Message-ID: 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> <0a69afa7-e9e6-e75f-8e90-6438683db98d@gmail.com> <53ba4534-1ec3-4e4f-d929-1a72f79c1abe@gmail.com> <83mvgblniy.fsf@gnu.org> <143c480c-a9db-7053-4b70-175633197981@gmail.com> <83a8cbl94w.fsf@gnu.org> <233f14a0-7542-5d0c-d8da-209e7e5e54f7@gmail.com> <838trvkq72.fsf@gnu.org> <27574c57-658c-c87b-4ddc-b24f83e2867c@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1480944082 29052 195.159.176.226 (5 Dec 2016 13:21:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Dec 2016 13:21:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 05 14:21:18 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 1cDtCn-00079n-2t for ged-emacs-devel@m.gmane.org; Mon, 05 Dec 2016 14:21:17 +0100 Original-Received: from localhost ([::1]:40464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDtCr-0002bm-49 for ged-emacs-devel@m.gmane.org; Mon, 05 Dec 2016 08:21:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDtCF-0002JS-4Y for emacs-devel@gnu.org; Mon, 05 Dec 2016 08:20:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDtCC-0000lj-06 for emacs-devel@gnu.org; Mon, 05 Dec 2016 08:20:43 -0500 Original-Received: from [195.159.176.226] (port=37126 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cDtCB-0000lE-P4 for emacs-devel@gnu.org; Mon, 05 Dec 2016 08:20:39 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cDtC5-0000v4-2z for emacs-devel@gnu.org; Mon, 05 Dec 2016 14:20:33 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:KxyGjz+ODdT/TjYSK+e9YSccYXo= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:210056 Archived-At: > + if (!NILP (nskip)) > + { > + CHECK_NUMBER(nskip); ^^ Please put a space before every open paren. > + EMACS_INT to_skip = XINT(nskip); > + while (to_skip > 0 && backtrace_p (pdl)) { > + to_skip--; > + pdl = backtrace_next (pdl); > + } > + } Why not use the same `base` arg as `backtrace-frame` instead of `nskip`? > - defsubr (&Sbacktrace); > + DEFSYM (QCdebug_on_exit, ":debug-on-exit"); > + defsubr (&Smapbacktrace); You remove the defsubr of Sbacktrace, but you don't remove the corresponding DEFUN. > (defun backtrace () > "Print a trace of Lisp function calls currently active. > Output stream used is value of `standard-output'." > (mapbacktrace #'~/backtrace-1 1)) Have you tried it both byte-compiled and interpreted? Maybe this function is just simple enough that the result is the same in both cases, but in my experience, the stack is sufficiently different in the two cases that a constant nskip doesn't cut it (hence the use of `base` in backtrace-frame). Stefan