Does anyone know what this purple highlighting means in Intellij debug mode?
Immediately after executing this line in the debugger, the program exits with no error message or error thrown.
This is called "Smart Step Into", and allows you to select the method, that you would like to step into for debugging, if there are multiple method calls in a line (like in your example). To use this feature, you would press Shift + F7, and then either click on the method, or use the arrow keys or tab button to choose the method, and then either press Enter or F7 to enter that method.
For reference: https://www.jetbrains.com/help/idea/stepping-through-the-program.html#smart-step-into
Related
In PyCharm debugging mode, is there way to let it stop right after it hits an error but not exit and highlight the offending line? The analogous feature I have in mind is "dbstop if error" of Matlab.
Yes, there is. Under Run, if you hit View Breakpoints (Ctrl + Shift + F8 on Windows) there's a checkbox where you can create an exception breakpoint for any exception.
The given answer was confusing to me. To do this you do not need to go to preferences, what you need to go is to break points menu bar (which is not in preferences for some reason). So:
Go to break point by pressing Command + shift + fn + F8 (Ctrl + Shift + F8 on Windows) or go to the breakpoints you have at the bottom (see picture 1). This opens the break point menu (see picture 2).
Then click enabled (for me suspend was already on so I only needed to click enabled). That's it.
Pic 1:
Pic 2:
Note: the reason this feature is useful is because after running an execution it halts with exactly the program state it caused it to err. For me I have stochastic code due to machine learning and reproducing the error exactly is annoying. I'd rather just see what cased the error, inspect the program state, stack etc and just fix it. There is even a little window at the bottom right to run code so I can test it right there while I am fixing it. I can even do control+shift+E to test pieces of code from my actual code (as I right new code).
I found that by using mouse click, we can create a red dot as a "marker" in R-studio. This is very nice. But how to simply go to this line with a marker?
I use SAS also. In SAS, it is like pressing Ctrl+F2 to create a marker, and press F2 to go to the next marker.
Anyone use this before? Thanks!
That isn't a marker but rather a breakpoint. When you run a script with a breakpoint, execution will stop there. Unfortunately there isn't currently a way to jump to breakpoints.
You can get similar behavior by inserting sections: use Code -> Insert Section to add a section, then Code -> Jump To to jump to any section quickly (there are hotkeys for these as well).
I right-click in the Watch 1 window and select Add Watch but nothing happens.
It is very unintuitive. The command doesn't do anything beyond adding a new row and selecting it. You next type the name of the variable. More intuitive is right-clicking an identifier name in the editor window + Add Watch. Or drag + drop it into the Watch window.
Right click (in your code) on the variable or expression (select it) you want to watch. It will be added to the Watch window.
Little question, large answer! You give us few details of what is happening...
Summarizing, be sure that current statement is around the place where your desired watched variables are, so you can see them on debug mode, i.e.:
Place a break point near there (press F9). Remember that it must be where the variable exists (remember that on C/C++/C# a common variable created inside brackets ({ and }) will be inaccessible outside it - something like that occurs on other languages);
Run the program (F5) and do something that let you on the right place (like pressing a button that launches the function where there are variables you want to watch);
To choose a variable to watch, on debug you must press mouse right button on it and "add watch". "Walk towards" using debug functions step into (F11), step out (shift+F11), step over (F10) or run-until-next-break-point (F5).
I was getting tired of hitting the F10 every step to debug the programs. Are there any program can automate the visual studio to run each debugging step in a consistent frequency? say, 3 seconds for each step?
Regards,
Sam
You can easily do that with a simple script in Autohotkey.
Download it from here: http://www.autohotkey.com/
Install Autohotkey.
Run it.
Find the green "H" icon in the task bar (bottom right).
Right click the icon and select Edit script.
And copy paste this script below.
^!y::
InputBox, input1, How many F10 strokes you want?, , , 250, 100
InputBox, input2, How many seconds between each F10 stroke?, , , 250, 100
if ErrorLevel <> 0
{
MsgBox, CANCEL was pressed.
}
else
{
loop, %input1%
{
Sleep, (input2 * 1000)
Send {F10}
}
MsgBox, "Your F10 script has Ended"
}
return
Then reload (again by right clicking the green "H" icon in task bar).
Press Control+Alt+y to try out the above script.
Sitting there repeatedly hitting F10 can be annoying, but you probably just need to make more use of the inbuilt debugging features.
set a breakpoint at a targetted location and hit F5 to run the program, it will stop when it hits the breakpoint
use F11 to step in to a function
use Shift-F11 to step out of a function
use the breakpoints window (Debug->Windows->Breakpoints) to get a complete list of all the bp's and you can easily enable/disable any of them (or set any of their other options)
use the Exceptions window (Debug->Exceptions) to select exceptions that you want to break on when they are first thrown
familiarize yourself with the options available to breakpoints (right-click on the bp itself to get these)
hit count: specify how many times code should go past the breakpoint before it stops
condition: super useful (i use it all the time), you can use almost any expression in there, including checking the value of inscope variables
when hit: you can run a macro when the breakpoint is hit
filter: to restrict which running thread can break on that breakpoint
Is there any way to tell the debugger to just continue until the next file is accessed, and/or until the next (developer written) function is accessed, without setting debug points ahead of time? I'm kind of new to VS debugging so all I use right now are f5, f10, and f11.
There is currently no way to do what you are asking. The main ways of telling VS to go until something happens are the following
Hit F5 and VS will go until the next user breakpoint or ,depending on your settings and where it occurs, the next exception is raised
Right click and select "Run to cursor"
Shift-F11 breaks out of the current method
Run to cursor doesn't require an explicit break point but it does require that you know where you want to break next.
You can right-click and select "run to cursor" if you just want to run to a specific line ahead in the execution stream.
Another one is Shift-F11 which finishes the current method and breaks again when you get back to the caller.
Actually, there is a way to set conditional break points.
Click in the left margin on the line where you want to break, as usual. (or F9)
Right-click on the red dot. In the context menu, click on "Condition...."
In the dialog, set your condition, e.g., fileName == "foo"
Hit F5 and go until the conditional break is hit.
Looks like there's not a way to do what I wanted to do