gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trace-all.el


From: Joe Corneli
Subject: trace-all.el
Date: Tue, 12 Apr 2005 17:06:01 -0500

I'm debugging the latest version of nero.el; this seems helpful.


;;; trace-all.el --- trace lots of emacs lisp functions at once

;; Copyright (C) 2005 Joe Corneli <address@hidden>
;; Copyright (C) 1993, 1998, 2000, 2005  Free Software Foundation, Inc.

;; includes portions of trace.el by Hans Chalupsky <address@hidden>
;; Created: 15 Dec 1992
;; Keywords: tools, lisp

;; Time-stamp: <jac -- Tue Apr 12 16:47:05 CDT 2005>

;; This file is not part of GNU Emacs, but it is distributed under
;; the same terms as GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 2, or (at your
;; option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; `trace-all' traces all the emacs lisp functions in the current
;;  buffer. It is useful for figuring out what your code is doing.

;; I made a few minor unrelated adjustments to functions from trace.el
;; (included), to quell display of arguments and return values.  This
;; behavior is optional -- here, turned on by default, and more
;; generally, controlled by the value of `trace-show-vars'.

;;; Code:

(require 'trace)

(defun trace-all ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "(defun\\s-+\\([^ \n]+\\)" nil t)
      (trace-function-background (intern
                                  (match-string-no-properties 1))))))


;; Modifications to trace.el:

(defvar trace-show-vars nil)

(defun trace-entry-message (function level argument-bindings)
  ;; Generates a string that describes that FUNCTION has been entered at
  ;; trace LEVEL with ARGUMENT-BINDINGS.
  (format "%s%s%d -> %s: %s\n"
          (mapconcat 'char-to-string (make-string (1- level) ?|) " ")
          (if (> level 1) " " "")
          level
          function
          (if trace-show-vars
              (mapconcat (lambda (binding)
                           (concat
                            (symbol-name (ad-arg-binding-field binding
                                                               'name))
                            "="
                            ;; do this so we'll see strings:
                            (prin1-to-string
                             (ad-arg-binding-field binding 'value))))
                         argument-bindings
                         " ")
            "+")))

(defun trace-exit-message (function level value)
  ;; Generates a string that describes that FUNCTION has been exited at
  ;; trace LEVEL and that it returned VALUE.
  (format "%s%s%d <- %s: %s\n"
          (mapconcat 'char-to-string (make-string (1- level) ?|) " ")
          (if (> level 1) " " "")
          level
          function
          (if trace-show-vars
          ;; do this so we'll see strings:
              (prin1-to-string value)
            "-")))

(provide 'trace-all)

;;; trace-all.el ends here




reply via email to

[Prev in Thread] Current Thread [Next in Thread]