Open progfolio opened 5 months ago
From a quick glance it seems like many of the calls to exwm--log
are inserted as the first form in a function and do not make use of any arguments. We could replace these calls by introducing a global-minor-mode, e.g. exwm-debug-mode, which adds before advice to exwm's functions and calls exwm--log.
That should take care of 107 of the 254 instances of exwm--log in the code base.
One alteration this approach would require is modifying xcb-debug:compile-time-function-name
, since the forms would no longer be present at compile time. We should be able to get the same information at run time. I've done something similar in Elpaca:
(defun elpaca--caller-name (n &rest skip)
"Return Nth calling function's name, skipping symbols in SKIP."
(cl-loop with current = (backtrace-frame (1+ n)) ;; Skip this function call.
with previous = nil
while (and (or (not (eq (car current) t))
(memq (cadr current) skip))
(setq previous current current (backtrace-frame (cl-incf n))))
finally return (cadr (or current previous))))
Which produces the Continued by:
lines in Elpaca's logs:
log:
[2024-05-30 08:12:16] Package queued
[2024-05-30 08:12:16] Continued by: elpaca--process
[2024-05-30 08:12:16] Queueing Dependencies
[2024-05-30 08:12:16] Continued by: elpaca--check-status
[2024-05-30 08:12:16] Unblocked by: xelb
[2024-05-30 08:12:16] No Info dir file found
[2024-05-30 08:12:16] Continued by: elpaca--add-info-path
[2024-05-30 08:12:16] Activating package
[2024-05-30 08:12:16] Package build dir added to load-path
[2024-05-30 08:12:16] Caching autoloads
[2024-05-30 08:12:16] Autoloads cached
[2024-05-30 08:12:16] Continued by: elpaca--activate-package
[2024-05-30 08:12:16] ✓ 0.001 secs
EDIT: I see now we already have an exwm-debug
global minor mode.
It's just a matter of altering it to use the advice approach.
Improvements to debugging are very welcome. In my experience, some functions are invoked so often that tracing them leads to noise in the log. Many functions include the empty (exwm--log)
call after a conditional for this reason. Maybe there is a way to disable some of them?
Another consideration is that we already have the exwm-debug
minor mode. I wonder whether it would make sense to add this feature to it.
Alternatively, we could add some kind of "bug report" command, but that's a later problem.
Originally posted by @Stebalien in https://github.com/emacs-exwm/exwm/issues/43#issuecomment-2138355135