Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve debugging #44

Open
progfolio opened this issue May 30, 2024 · 2 comments
Open

improve debugging #44

progfolio opened this issue May 30, 2024 · 2 comments

Comments

@progfolio
Copy link
Collaborator

progfolio commented May 30, 2024

Alternatively, we could add some kind of "bug report" command, but that's a later problem.

Originally posted by @Stebalien in #43 (comment)

@progfolio
Copy link
Collaborator Author

progfolio commented May 30, 2024

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.

@medranocalvo
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants