How to only debug my code with Delve Go Debugger? - go

Whenever I debug Go code with Delve, I need to set breakpoints on almost every line of my code and hit Continue rather than Step Into, because Step Into will step through every line of code that I imported, and not just the code that I wrote. How do I only debug my code, and let Delve step over any imported functions so that I don't need to set breakpoints at every line of my code?

Related

VScode Golang output to debug console is buffered and not flushed even on a breakpoint

I'm debugging a loop in which each iteration outputs a line and then hits a breakpoint.
I need to see that output line when the breakpoint is hit, although the output is buffered in the debug console so it doesn't flush for several lines, how do I manage to make it flush on every iteration, or when hitting a breakpoint?
I'm pretty sure it's not a code problem because if I run the program and use a fmt.Scan() to pause execution on each iteration, the output is flushed correctly each time.
It seems to be an issue with the debug console, go debugger Delve or the Microsoft Go extension. Can I configure the buffering of this console in vscode?

How can I see which line a program is using?

I want to see which line my program is using. For example, the program is on line 231, but I don't know that. Is there a way to do this?
While running in debug mode from Visual Studio you can:
Set a breakpoint. The debugger will kick in and pause execution on
that line.
Press the "Pause" button on the VS toolbar. Program
execution will immediately pause and the debugger will show you what
line its on.
Write code involving System.Diagnostics.Debugger (such as Debugger.Break();) where you beed the debugger to pause execution. This method has the added bonus of not relying on Visual Studio to be the debugger - if you're one of those weird-os. ;-)
Tools->Options->Text Editor->C# and the check line numbers.
Then set a breakpoint.
Only thing that comes to mind is for you to put a comment at the end of each line with the line number, then look at the comment as you step through. But that would only work in debug mode and only after hitting a breakpoint.
One major problem trying this in regular mode, running as normal, is that C# does not run. It compiles into byte code, and there is not a one-to-one correlation between C# lines and IL lines. So I'm afraid in that sense, this cannot be done.

Debugging at IntelliJ IDEA 14.1.3

I am curious how to execute previous line of code while debugging?
Currently, I see the following buttons:
- Step over;
- Step into;
- Force step into;
- Step out;
but no button "Step previous".
By default, you cannot advance backwards while debugging code. Since code runs are temporal, one should be able to re-run the code that they're debugging to narrow in on what specifically they want to observe in the debugger.
However, if you really want to be able to debug and step backwards, then the Chronon plugin is a viable option. Note that you won't be dropped into a debug context immediately, and you won't be able to access any live evaluation, but this will allow you to debug your code by stepping forwards and backwards.
You could Drop Frame - it will return you to a previous method, so you can step on that line again. See When using the Java debugger in Intellij what does "Drop Frame" mean?

Avoid starting debugging from the beginning

Is it possible to set a starting point for the debugger so that every debugging session
will start immediately from that point (instead of starting from the beginning of the code)?
Or to express it differently:
Isn't it possible to somehow store everything until the breakpoint so that next time the debugger could just instantly resume to that specific breakpoint (instead of starting from the beginning of the code and pausing at the breakpoint)?. Is there any debugger that can do this?
I am using Microsoft Visual Studio Express 2012.
Thank you.
Use a Debugger in visual studio.
In your code, click on the line number, you will see a dot on the line.
When you run the program, it will 'pause' at the line you specify, you can then walk through your program line by line from there
You can use a breakpoint at a line that you want to inspect.
You have a description how to do it here.
You could attach a debugger to a running process, but i'm afraid that it will be on a random place of execution. You could make a wait for a key or button press in your code and attach to your program before continuing.
No. It would have to run the code up to the point you want to get all the variables etc in the right state. If you just set a breakpoint where you're interested from and hit F5 it should get there quickly enough.
If it doesn't get there quickly enough, jot down the variables used and make some unit tests round the troublesome functions instead. That will skip the 10 minutes.

Xcode, stepping through my own code using breakpoints

Usually, this works, but in addition to my own code there a lot of machine code too, which doesn't really help me out with debugging my own program logic.
Is there a way to step through only my own code?
First put a breakpoint where you want to start step over.After the breakpoint ,Use this button to step over through the code.The play button just runs till the next breakpoint
You probably want to be using the next command or "step over" button in the debugger UI instead of step or "step into" to avoid stepping into each function as you debug. You might still want to step into your own functions, of course, but next will let you step over framework functions instead of diving into their assembly.

Resources