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

Integrate debug with purpose #182

Merged
merged 2 commits into from
Mar 15, 2021
Merged

Integrate debug with purpose #182

merged 2 commits into from
Mar 15, 2021

Conversation

wyuenho
Copy link
Collaborator

@wyuenho wyuenho commented Mar 14, 2021

debug supplies its own display actions to pop-to-buffer in order to reuse a window, which usually isn't what we want to do when there are multiple split windows, some of which maybe too small for a debug backtrace buffer. This PR hands the control of window picking back to purpose.

@wyuenho wyuenho force-pushed the fix-debug branch 2 times, most recently from d9c7ab8 to b71cd71 Compare March 14, 2021 17:01
@wyuenho wyuenho merged commit aa4e737 into bmag:master Mar 15, 2021
@wyuenho wyuenho deleted the fix-debug branch March 15, 2021 18:48
@bcc32
Copy link
Contributor

bcc32 commented Apr 1, 2021

This change appears to have broken the d command in the debugger (continue until the next Elisp function call). I verified this by invoking the debugger and pressing d repeatedly.

With the 'debug integration excluded, I see:

Debugger entered--entering a function:
* spacemacs-buffer/refresh()
* apply(spacemacs-buffer/refresh nil)
* spacemacs/home()

But with the integration, I get an infinite loop of purpose--debug functions:

Debugger entered--entering a function:
* #f(compiled-function () #<bytecode 0x29683cd>)()
  purpose--debug(#f(compiled-function (&rest args) "Enter debugger.  \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger.\nArguments are mainly for use when this is called from the internals\nof the evaluator.\n\nYou may call with no args, or you may pass nil as the first arg and\nany other args you like.  In that case, the list of args after the\nfirst will be printed into the backtrace buffer.\n\nIf `inhibit-redisplay' is non-nil when this function is called,\nthe debugger will not be entered." (interactive nil) #<bytecode 0xee91cd>) lambda)
  apply(purpose--debug #f(compiled-function (&rest args) "Enter debugger.  \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger.\nArguments are mainly for use when this is called from the internals\nof the evaluator.\n\nYou may call with no args, or you may pass nil as the first arg and\nany other args you like.  In that case, the list of args after the\nfirst will be printed into the backtrace buffer.\n\nIf `inhibit-redisplay' is non-nil when this function is called,\nthe debugger will not be entered." (interactive nil) #<bytecode 0xee91cd>) lambda)
  debug(lambda)
* #f(compiled-function () #<bytecode 0x25ded25>)()
  purpose--debug(#f(compiled-function (&rest args) "Enter debugger.  \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger.\nArguments are mainly for use when this is called from the internals\nof the evaluator.\n\nYou may call with no args, or you may pass nil as the first arg and\nany other args you like.  In that case, the list of args after the\nfirst will be printed into the backtrace buffer.\n\nIf `inhibit-redisplay' is non-nil when this function is called,\nthe debugger will not be entered." (interactive nil) #<bytecode 0xee91cd>) lambda)
  apply(purpose--debug #f(compiled-function (&rest args) "Enter debugger.  \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger.\nArguments are mainly for use when this is called from the internals\nof the evaluator.\n\nYou may call with no args, or you may pass nil as the first arg and\nany other args you like.  In that case, the list of args after the\nfirst will be printed into the backtrace buffer.\n\nIf `inhibit-redisplay' is non-nil when this function is called,\nthe debugger will not be entered." (interactive nil) #<bytecode 0xee91cd>) lambda)
  debug(lambda)
* #f(compiled-function () #<bytecode 0x19ac269>)()
  purpose--debug(#f(compiled-function (&rest args) "Enter debugger.  \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger.\nArguments are mainly for use when this is called from the internals\nof the evaluator.\n\nYou may call with no args, or you may pass nil as the first arg and\nany other args you like.  In that case, the list of args after the\nfirst will be printed into the backtrace buffer.\n\nIf `inhibit-redisplay' is non-nil when this function is called,\nthe debugger will not be entered." (interactive nil) #<bytecode 0xee91cd>) lambda)
  apply(purpose--debug #f(compiled-function (&rest args) "Enter debugger.  \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger.\nArguments are mainly for use when this is called from the internals\nof the evaluator.\n\nYou may call with no args, or you may pass nil as the first arg and\nany other args you like.  In that case, the list of args after the\nfirst will be printed into the backtrace buffer.\n\nIf `inhibit-redisplay' is non-nil when this function is called,\nthe debugger will not be entered." (interactive nil) #<bytecode 0xee91cd>) lambda)
  debug(lambda)
* #f(compiled-function () #<bytecode 0x18da33d>)()
  purpose--debug(#f(compiled-function (&rest args) "Enter debugger.  \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger.\nArguments are mainly for use when this is called from the internals\nof the evaluator.\n\nYou may call with no args, or you may pass nil as the first arg and\nany other args you like.  In that case, the list of args after the\nfirst will be printed into the backtrace buffer.\n\nIf `inhibit-redisplay' is non-nil when this function is called,\nthe debugger will not be entered." (interactive nil) #<bytecode 0xee91cd>) debug)
* apply(purpose--debug #f(compiled-function (&rest args) "Enter debugger.  \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger.\nArguments are mainly for use when this is called from the internals\nof the evaluator.\n\nYou may call with no args, or you may pass nil as the first arg and\nany other args you like.  In that case, the list of args after the\nfirst will be printed into the backtrace buffer.\n\nIf `inhibit-redisplay' is non-nil when this function is called,\nthe debugger will not be entered." (interactive nil) #<bytecode 0xee91cd>) debug)
  debug(debug)
  debug--implement-debug-on-entry()
  apply(debug--implement-debug-on-entry nil)
  spacemacs/home()
  funcall-interactively(spacemacs/home)
  call-interactively(spacemacs/home nil nil)
  command-execute(spacemacs/home)

@wyuenho
Copy link
Collaborator Author

wyuenho commented Apr 2, 2021

But it looks like you are debugging debug?

@bmag
Copy link
Owner

bmag commented Apr 2, 2021

@bcc32 I will look into this, but please provide a bit more details how to reproduce the error - what steps exactly do I need to perform? Don't know how to translate "invoking the debugger" into actual actions, I don't think you meant M-x debug RET.

@bcc32
Copy link
Contributor

bcc32 commented Apr 2, 2021

Ah, sorry for my unclear report.

But it looks like you are debugging debug?

No, I was trying to debug spacemacs/home in the example I pasted.

what steps exactly do I need to perform?

Try defining the following command:

(defun some-random-command ()
  (interactive)
  (message "%s" (file-remote-p "/")))

And then M-x debug-on-entry RET expand-file-name RET

When you invoke M-x some-random-command, the debugger appears. Pressing d is supposed to "step into" the file-remote-p function call, but instead it steps into the purpose--debug functions.

@bmag
Copy link
Owner

bmag commented Apr 2, 2021

@bcc32 ok, I was able to repro by using beginning-of-buffer as the entry point for debugging. Should be fixed by #184.
@wyuenho can you verify that the fix doesn't break any use-cases on your side?

@bcc32
Copy link
Contributor

bcc32 commented Apr 2, 2021

Cool, #184 appears to work for me. I still see the purpose stuff show up, but it doesn't recurse, and eventually continues on to the functions called by the entry point.

@bmag
Copy link
Owner

bmag commented Apr 5, 2021

I reverted this PR for now (in 06f727e)

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

Successfully merging this pull request may close these issues.

3 participants