(all-completions
"*tramp" (mapcar #'list (mapcar #'buffer-name (buffer-list))))
(all-completions
- "*debug tramp" (mapcar #'list (mapcar #'buffer-name (buffer-list))))))
+ "*debug tramp" (mapcar #'list (mapcar #'buffer-name (buffer-list))))
+ (all-completions
+ "*trace tramp" (mapcar #'list (mapcar #'buffer-name (buffer-list))))))
(defun tramp-list-remote-buffers ()
"Return a list of all buffers with remote `default-directory'."
(format "*tramp/%s %s@%s*" method user-domain host-port)
(format "*tramp/%s %s*" method host-port))))
+(put #'tramp-buffer-name 'tramp-suppress-trace t)
+
(defun tramp-make-tramp-file-name (&rest args)
"Construct a Tramp file name from ARGS.
(put #'tramp-get-debug-buffer 'tramp-suppress-trace t)
(defun tramp-get-debug-file-name (vec)
- "Get the debug buffer for VEC."
+ "Get the debug file name for VEC."
(expand-file-name
(tramp-compat-string-replace "/" " " (tramp-debug-buffer-name vec))
(tramp-compat-temporary-file-directory)))
(put #'tramp-get-debug-file-name 'tramp-suppress-trace t)
+(defun tramp-trace-buffer-name (vec)
+ "A name for the trace buffer for VEC."
+ (tramp-compat-string-replace "debug" "trace" (tramp-debug-buffer-name vec)))
+
+(put #'tramp-trace-buffer-name 'tramp-suppress-trace t)
+
+(defvar tramp-trace-functions nil
+ "A list of non-Tramp functions to be trace with tramp-verbose > 10.")
+
(defun tramp-debug-message (vec fmt-string &rest arguments)
"Append message to debug buffer of VEC.
Message is formatted with FMT-STRING as control string and the remaining
(or tramp-repository-version "")))))
;; Traces.
(when (>= tramp-verbose 11)
- (dolist (elt (all-completions "tramp-" obarray 'functionp))
- (let ((fn (intern elt)))
- (unless (get fn 'tramp-suppress-trace)
- (trace-function-background fn)))))
+ (dolist
+ (elt
+ (append
+ (mapcar #'intern (all-completions "tramp-" obarray 'functionp))
+ tramp-trace-functions))
+ (unless (get elt 'tramp-suppress-trace)
+ (trace-function-background elt))))
;; Delete debug file.
(when (and tramp-debug-to-file (tramp-get-debug-file-name vec))
(ignore-errors (delete-file (tramp-get-debug-file-name vec)))))
"Whether `tramp--test-instrument-test-case' run.
This shall used dynamically bound only.")
+;; When `tramp-verbose' is greater than 10, and you want to trace
+;; other functions as well, do something like
+;; (let ((tramp-trace-functions '(file-name-non-special)))
+;; (tramp--test-instrument-test-case 11
+;; ...))
(defmacro tramp--test-instrument-test-case (verbose &rest body)
"Run BODY with `tramp-verbose' equal VERBOSE.
Print the content of the Tramp connection and debug buffers, if
`should-error' is not handled properly. BODY shall not contain a timeout."
(declare (indent 1) (debug (natnump body)))
`(let* ((tramp-verbose (max (or ,verbose 0) (or tramp-verbose 0)))
- (trace-buffer
- (when (> tramp-verbose 10) (generate-new-buffer " *temp*")))
+ (trace-buffer (tramp-trace-buffer-name tramp-test-vec))
(debug-ignored-errors
(append
'("^make-symbolic-link not supported$"
(unwind-protect
(let ((tramp--test-instrument-test-case-p t)) ,@body)
;; Unwind forms.
- (when trace-buffer
- (untrace-all))
(when (and (null tramp--test-instrument-test-case-p) (> tramp-verbose 3))
- (dolist
- (buf (append
- (tramp-list-tramp-buffers)
- (and trace-buffer (list (get-buffer trace-buffer)))))
+ (untrace-all)
+ (dolist (buf (tramp-list-tramp-buffers))
(with-current-buffer buf
(message ";; %s\n%s" buf (buffer-string)))
(kill-buffer buf))))))