Dap-mode with doom emacs? - debugging

I recently switched from Vscode which has an incredible debugging experience that I’m used to.
For example, I can start an app locally, place breakpoints and run a curl request and vscode automatically puts you into the debug console where you can interpret your code
I want this workflow in emacs because Im loving everything else that emacs has to offer. However, I have to switch to vscode to actually get work done and have a good debugging experience
My current emacs configuration:
pipenv-activate works
projectile works
lsp enabled
pyright working and i get autocomplete etc
restclient
pytest works
But enabling the built-in debugger in .doom.d/init.el gets me nothing. Trying to M-x toggle breakpoint does nothing and gives me an error in the mini buffer
I’ve tried to configure dap-mode using a few different examples online but none work for me. Does anyone have a similar setup and know how to configure dap-mode with the default doom emacs config structure? Or do you suggest something other than dap mode?

You can check helping web pages:
https://docs.doomemacs.org/latest/modules/tools/debugger/
https://emacs-lsp.github.io/dap-mode/page/configuration/
In init.el, add :
In: tools :
debugger +lsp)
For example for me in C++, I need to do :
In the config.el, add:
;; to debug with DAP-MODE
(setq dap-auto-configure-mode t)
(requires 'dap-cpptools)
Next :
M-x -> “dap-cpptools-setup” (once)
M-x -> “dap-debug-edit-template” (indicate the binary path)
Template is open, I need to complete to specify the binary
M-x -> “eval-buffer” (to be done on the template buffer to use it)
M-x -> “dap-debug” (launches the debug)

Related

Spyder debugger freezes on second restart of code

My task is to repeatedly rerun a code from beginning. As I do not want to run the code to the end I set a breakpoint() command. However, Spyder freezes when the code is the second time called from debug mode. For demonstration a simple program is sufficient:
print('Hello World!')
breakpoint()
After launching Spyder I start the small program by F5. Everything works as expected and I jumped into the debug mode. Now I press again F5 and the code restarts correctly from the debug mode. After again pressing F5 the code is not restarted and instead the IDE freezes. It is not possible by any means to rerun the code again from debug mode. Interrupting the kernel by pressing the red button (see screenshot below) does not help. Trying to leave the debug mode by !q does not leave the debug mode. The only possibility to rerun the code is quite cumbersome, i.e. I have to restart the kernel (Ctrl+.) that takes a while. How to debug code under these circumstances?
Is this a bug of the IDE or expected behavior? How can I restart the code by a simple key press as often as possible from debug mode?
This is a screenshot of the Spyder console with comments in red added.
I use a recent version a WinPython with latest Spyder 5.4.0, Python 3.10.4 64-bit, Qt 5.15.2, PyQt5 5.15.6, Windows 10Pro Version 21H2. The problem also appears with Spyder 5.3.3 A similar problem (or maybe the same) appears with a different Python version.
After many trials, I noticed that there is something strange with IPython console. I noticed that when it hangs after running a code, if I delete all user variables, it worked fine.
Then I tryed to delete all variables before execution, and it work fine.
Therefore I discovered that a solution that worked for me is to go to preferences -> Run -> and untick the option 'Remove all variables before execution'
It is quite annoying because I have to do it manually every time before running, but in this way the spyder does not appear to hang anymore! I hope that the Spyder developers will solve it soon.
-
I automatically solved by typing at the beginning of any script these lines, inspired from the question Code to clear console and variables in Spyder :
try:
from IPython import get_ipython
get_ipython().magic('clear')
get_ipython().magic('reset -f')
import matplotlib.pyplot as plt
plt.close('all')
except:
pass
similar to Matlab in which you normally start your code with
clc
close all
clear all

How to prevent distortion of code window in gdb -tui? Debugging commands scroll up and break graphics

I just started using gdb, so gdb -tui helps visualize process.
However when gdb commands rise up they push window with source code so everything becomes broken.
I set variable to TERM=xterm-256color
as some suggest and this didn't help.
Same behavior for st alacritty and even tty.
You can use ctrl + L to refresh your tui. But the output of your code (like printf) will be lost together with distortion.
Recommended a tremendous gdb plugin -- gdb-dashboard
Faced the same issue. Using the following command helped.
ref
This should resolve the graphics issue.
I haven't found how to prevent graphics distortion in gdb -tui.
But there are better tools to archive same goal.
Probably -tui option exists only for limited cases when better options are not available due to limitations of installed software.
Using vim with Termdebug lets view code during debug as gdb -tui mode does but without graphics break.
enable termdebug
:packadd termdebug
start termdebug
:Termdebug
You can press control_l in gdb -tui to refresh screen. But adding additional key combination after every command is obviously inconvenient.

visual studio code "launch json" on run, how to set debug console as default

I went to user settings to set the debug console to default (when I try to debug now the default console is terminal. I lose the small debug icons to skip, stop etc even when I manually select debug console). I am watching Python tutorials using Vs Code and his default is debug. How can I do this?
Secondly, when I try to run or debug, I am prompted to open LaunchJS, even if it is already open. I attempted to run it using the debug selection "current file, integrated terminal" and also "Python: Attach". Neither will work although the JSON file has these options. I looked at some MS videos but I am not understanding the problem.
Any help is appreciated. Thanks.
I found the answer at this link: https://code.visualstudio.com/docs/python/python-tutorial
I had not selectd a Python interpreter which establishes a python workspace. Was just trying to run with debugger. A simple program now runs. My guess is that the Python tutorial I selected is too old to follow with this version of VS Code, since I am unfamiliar with any version of VS Code.
Thanks.

prompt missing running delve using gud in emacs?

Here is the experience running delve from the command line on my Windows 10 desktop using MSYS-2:
Now here is the experience running delve from GNU emacs (W64) version 25.1.1 -
ShellPrompt> emacs -nw H:/code/Go/book/chap1_lissajous/lissajous.go
C-x-2
M-x dlv
Run dlv (like this): dlv debug H:/code/Go/book/chap1_lissajous/lissajous.go
Navigate to lissajous.go:34 and hit C-x-C-a-C-b to toggle a breakpoint
Navigate to dlv buffer
Hit 'c', and the experience looks like this for this entire interaction:
Notice the absence of (dlv) in front of the c (continue) command when running using emacs. The result is the same using emacs in non-terminal mode as well.
I tried to find any gud customizations that needed to be applied for the prompt to show up. I could not find any, and I was unable to find anyone else facing this issue online. Does anybody know if I am missing something?
NOTE: I have had to post images instead of formatted text because I couldn't figure how to get markdown to render the code in a formatted way with the line numbers from the debugger. I wasn't allowed to post the question with unformatted code. I apologize to those who are only able to view the text of my post and not the images. The images are needed to view the question completely.

Interactive pyDev console at breakpoint

I'm using Aptana Studio with Pydev 1.5.3 to debug my Django applications. I use PyDev's remote debugger and some code in manage.py and for most of the time this setup is working successfully- I can set breakpoints, inspect variables and step/continue through my code.
However, I'd like to execute arbitrary code at the breakpoint- the thing I really miss after switching from pdb to Eclipse debugging. There is an interactive console available in debug perspective but it is inactive for me.
So my question- is it possible to set up an interactive console in PyDev with remote debugger which could "inject" code at breakpoint?
strange, i am using pydev 1.5.6 for remote debugging and I can use the interactive console - i type the cmmand, hit enter, after a while get results back; check your firewall is not blocking anything (if you are sure, the interactive console works in local mode). there is even settings in pydev source code to set how much of stdout should be returned back to client (in chars), it should work
After some digging I discovered that I can use Expressions view to access variables properties and view results of class methods, but that still isn't a complete console at breakpoint though.
With PyDev 1.5.5 it should be possible:
In "Variables" view, you can right-click on a name, then select "change value".
The console is working as well, albeit a bit tricky.
It is only for inspection and in a very strange way: you have to input the text in the "Debug server" console, and you will get the output in the "filename" console.
Note also that you need to press enter twice, leaving an empty line.
While the "empty line" trick is documented, the issue about two different console for input and output is not, and I think it may be a bug.
On my development stack running Apache + mod_wsgi entering commands into the console had their output routed to the site's error logs. To resolve this you have set the stdoutToServer=True and sterrToServer=True to route capture all output to the PyDev remote debugger:
from pydevsrc import pydevd;pydevd.settrace('192.168.2.8', stdoutToServer=True, stderrToServer=True) #clone and put on python path: https://github.com/tenXer/PyDevSrc

Resources