From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nic Ferrier Newsgroups: gmane.emacs.devel Subject: capturing backtraces Date: Sun, 24 Aug 2014 21:43:56 +0100 Message-ID: <874mx1zkhf.fsf@ferrier.me.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1408913071 23155 80.91.229.3 (24 Aug 2014 20:44:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 24 Aug 2014 20:44:31 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 24 22:44:26 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XLeeH-0001hc-L7 for ged-emacs-devel@m.gmane.org; Sun, 24 Aug 2014 22:44:25 +0200 Original-Received: from localhost ([::1]:45234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLeeH-00039e-6F for ged-emacs-devel@m.gmane.org; Sun, 24 Aug 2014 16:44:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLee0-00039V-Vq for emacs-devel@gnu.org; Sun, 24 Aug 2014 16:44:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XLedv-0006Wz-37 for emacs-devel@gnu.org; Sun, 24 Aug 2014 16:44:08 -0400 Original-Received: from static.17.66.46.78.clients.your-server.de ([78.46.66.17]:40344 helo=po1.ferrier.me.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLedu-0006Ws-TU for emacs-devel@gnu.org; Sun, 24 Aug 2014 16:44:03 -0400 Original-Received: from nicferrier-dell-xps (140.35.155.90.in-addr.arpa [90.155.35.140]) by po1.ferrier.me.uk (Postfix) with ESMTPA id 28928AC0AD1; Sun, 24 Aug 2014 22:57:29 +0200 (CEST) Original-Received: from nicferrier-XPS13-9333 (localhost [127.0.0.1]) by nicferrier-dell-xps (Postfix) with ESMTPS id C604B60A01; Sun, 24 Aug 2014 21:43:56 +0100 (BST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 78.46.66.17 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:173815 Archived-At: I want to capture the backtrace that was current at the time of an error into a list, string or buffer. Something like: (condition-case err (thing-that-causes-errors) (error (setq saved-backtrace (way-to-get-backtrace-from-error err)))) Where the function way-to-get-backtrace-from-error represents a function that can get the backtrace from an error. Anyone have a clue how I can do that? I asked this question before and Stefan referred me to macroexp--backtrace (http://lists.gnu.org/archive/html/emacs-devel/2014-05/msg00268.html) which uses backtrace-frame. That function doesn't seem to be able to get the backtrace from the point of the error though: (defun nic-error () (let ((x 1)) (error "MEH"))) (condition-case err (nic-error) (error (backtrace-frame 1))) => (nil condition-case err (nic-error) (error (backtrace-frame 1))) that's not what I want at all, as you can see it grabs the current backtrace of the currently executing stack. We must be able to do this though because the debugger does it to display the backtrace that happened to cause an error when we have debug-on-error turned on. Anyone? Nic