From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.bugs Subject: bug#25393: FEATURE REQUEST: *Backtrace* -- C source code def highlight + jump to def. Date: Sun, 08 Jan 2017 00:29:13 -0800 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (generated by - "") Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1483864273 3163 195.159.176.226 (8 Jan 2017 08:31:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 8 Jan 2017 08:31:13 +0000 (UTC) To: 25393@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 08 09:31:09 2017 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 1cQ8se-000056-Hs for geb-bug-gnu-emacs@m.gmane.org; Sun, 08 Jan 2017 09:31:08 +0100 Original-Received: from localhost ([::1]:60649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQ8si-00030Z-N2 for geb-bug-gnu-emacs@m.gmane.org; Sun, 08 Jan 2017 03:31:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQ8sb-00030I-Tx for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2017 03:31:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQ8sY-00073p-PT for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2017 03:31:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59299) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cQ8sY-00073l-LS for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2017 03:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cQ8sY-000785-A1 for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2017 03:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Jan 2017 08:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.148386423027362 (code B ref -1); Sun, 08 Jan 2017 08:31:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Jan 2017 08:30:30 +0000 Original-Received: from localhost ([127.0.0.1]:46465 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQ8s2-00077G-1Q for submit@debbugs.gnu.org; Sun, 08 Jan 2017 03:30:30 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:38780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQ8rz-000773-S2 for submit@debbugs.gnu.org; Sun, 08 Jan 2017 03:30:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQ8rs-0006oT-Vm for submit@debbugs.gnu.org; Sun, 08 Jan 2017 03:30:22 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:59034) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cQ8rs-0006o2-Rp for submit@debbugs.gnu.org; Sun, 08 Jan 2017 03:30:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQ8rq-0002m8-Ny for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2017 03:30:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQ8rn-0006kL-EL for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2017 03:30:18 -0500 Original-Received: from nov-007-i629.relay.mailchannels.net ([46.232.183.183]:32231) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cQ8rm-0006DU-AD for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2017 03:30:15 -0500 X-Sender-Id: techassets|x-authuser|lawlist@cp31.deluxehosting.com Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 63918100349 for ; Sun, 8 Jan 2017 08:29:22 +0000 (UTC) Original-Received: from cp31.deluxehosting.com (ip-10-107-69-155.us-west-2.compute.internal [10.107.69.155]) by relay.mailchannels.net (Postfix) with ESMTPA id 894151003C8 for ; Sun, 8 Jan 2017 08:29:21 +0000 (UTC) X-Sender-Id: techassets|x-authuser|lawlist@cp31.deluxehosting.com Original-Received: from cp31.deluxehosting.com ([TEMPUNAVAIL]. [10.135.9.54]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.7.8); Sun, 08 Jan 2017 08:29:22 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: techassets|x-authuser|lawlist@cp31.deluxehosting.com X-MailChannels-Auth-Id: techassets X-MC-Loop-Signature: 1483864161783:3861589591 X-MC-Ingress-Time: 1483864161782 Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:57512 helo=server.local) by cp31.deluxehosting.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1cQ8qp-000693-B1 for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2017 03:29:15 -0500 X-AuthUser: lawlist@cp31.deluxehosting.com X-Originating-IP: 45.48.239.195 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:127899 Archived-At: As a feature request, the Emacs team may wish to consider implementing the ability for users to highlight C source code definitions in the *Backtrace* buffer and jump to the function definitions. The highlighting of said functions makes the *Backtrace* buffer prettier, and it's handy to jump to the definitions with buttons. A check should probably be included to see whether the `find-function-C-source-directory' contains C source code files before creating highlighting/buttons for jumping: Here is the link to the related thread: http://emacs.stackexchange.com/questions/29875/debugging-debugger-mode-how-to-highlight-the-culprit In my use-case, it wasn't very obvious to me that `/` was the cause of my backtrace error message because it was not highlighted -- this is true even though I am aware that the problem is always near the top of the debugger buffer. It is just not a function I use a lot and it didn't really look like a function because it was just regular text coloration. (require 'debug) (defun debugger-make-xrefs (&optional buffer) "Attach cross-references to function names in the `*Backtrace*' buffer." (interactive "b") (with-current-buffer (or buffer (current-buffer)) (save-excursion (setq buffer (current-buffer)) (let ((inhibit-read-only t) (old-end (point-min)) (new-end (point-min))) (if debugger-previous-backtrace (let (old-start new-start (all-match t)) (goto-char (point-max)) (with-temp-buffer (insert debugger-previous-backtrace) (while (and all-match (not (bobp))) (setq old-end (point)) (forward-line -1) (setq old-start (point)) (with-current-buffer buffer (setq new-end (point)) (forward-line -1) (setq new-start (point))) (if (not (zerop (let ((case-fold-search nil)) (compare-buffer-substrings (current-buffer) old-start old-end buffer new-start new-end)))) (setq all-match nil)))) (delete-region new-end (point-max)) (goto-char (point-max)) (insert (substring debugger-previous-backtrace (- old-end (point-min)))) (narrow-to-region (point-min) new-end))) (goto-char (point-min)) (while (progn (goto-char (+ (point) 2)) (skip-syntax-forward "^w_") (not (eobp))) (let* ((beg (point)) (end (progn (skip-syntax-forward "w_") (point))) (fn (function-called-at-point)) ;; MODIFICATION (sym (intern-soft (buffer-substring-no-properties beg end))) ;; MODIFICATION (file (if fn (let* ( (function fn) (advised (and (symbolp function) (featurep 'nadvice) (advice--p (advice--symbol-function function)))) ;; If the function is advised, use the symbol that has the ;; real definition, if that symbol is already set up. (real-function (or (and advised (advice--cd*r (advice--symbol-function function))) function)) ;; Get the real definition. (def (if (symbolp real-function) (or (symbol-function real-function) (signal 'void-function (list real-function))) real-function)) (aliased (or (symbolp def) ;; Advised & aliased function. (and advised (symbolp real-function) (not (eq 'autoload (car-safe def)))))) (file-name (find-lisp-object-file-name function (if aliased 'defun def)))) file-name) (and sym (symbol-file sym 'defun))))) (when (or fn file) ;; MODIFICATION (goto-char beg) (re-search-forward "\\(\\sw\\|\\s_\\)+") (help-xref-button 0 'help-function-def sym file))) (forward-line 1)) (widen)) (setq debugger-previous-backtrace (buffer-string)))))