Trailing breakpoints in VS 2010? - visual-studio-2010

Does anyone know if there is a way or plugin that allows you to create a trailing breakpoint while debugging. For example I want to set a breakpoint on some class and then as I step to the next line and my breakpoint gets updated to that line. Then step to the next line and my breakpoint gets updated to that line, etc... This would be really useful when diving deep into a class hierarchy and being able to start debugging again at the same point where I stopped.

Just toggle the breakpoint whenever you want it, since you're stepping through the code anyway.
I don't see a lot of value in this, but the F9 (for toggling breakpoint) and F10 (for stepping to the next line) keys are right next to one another.
To debug, just:
Set the breakpoint on the first line of code you want to hit.
When the breakpoint hits for the first time, use F9 to remove the breakpoint (if desired).
Press F10/F11 to step to (or into) the next line.
I don't see much value when you keep moving the breakpoint, unless you keep breakpoints there along the hierarchy.

Related

How can I get the Xcode debugger to step into the assembly of a function?

Whenever I try to step into a function for which I don't have the source code, e.g. anything in an Apple library, the debugger just skips to the next line. How can I have it go into the assembly instead? I can workaround this by setting a symbolic breakpoint for the function that I want to step into, but this is less convenient.
Hold Control when pressing the step controls. Works for me in Xcode 12.
The stepping controls have alternative operations for working with disassembly or threads. You use the Control and Control-Shift modifier keys to call these alternatives. Press Control to step by assembly language instruction instead of by statement (the step icons change to show a dot rather than a line under the arrow) or Control-Shift to step into or over the active thread only while holding other threads stopped (the step icons show a dashed rather than solid line below the arrow).
https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/debugging_tools.html

How to set all lines as breakpoints in CLion?

I am using CLion to debug C programs, however I keep finding myself in the situation of needing to set all lines as breakpoints. Currently the only way I can set all lines as breakpoints is by manually marking each line as a breakpoint, one line at a time. I looked for alternative ways to set lines as breakpoints and the only thing i found was that I could use keyboard shortcuts to toggle breakpoints and I could view all breakpoints. I also tried highlighting all lines in the file and then toggling breakpoints, but it would only toggle breakpoints for a single line - the line selected right before highlighting all lines in the file.
Is there or is there not currently any way to set all lines as breakpoints in one go in CLion?
Also, I considered asking this on superuser.com, however there were ~200x more questions (13 vs 3275) about CLion on StackOverflow so I asked it here instead.
Setting all lines as breakpoints would be the same as stepping through a program. So set a breakpoint at the beginning of main and step through.

IDEA: Debugger skipping lines

I am not sure what's going on here.
I set up a breakpoint.
I start code in debug mode.
Debugger jumps to the breakpoint
I step over
Debugger goes somewhere but the next line ...
Is this a known issue? Am i not using the tool correctly?
Here is an example:
Debugger starts, we stop at the breakpoint.
Instead of going to the constructor of the class i asked to step into to (expect to get to line 29)
It's jumping to superclass automatically (!#$!#)
But then ... when i step over it skips lines ..
I would like (when i step over) to go to the next line and when i step in to think less and do what it's told. Is this a configuration issue somewhere in my instance?
To get behavior similar to Eclipse use Run | Smart Step Into, this will skip directly to the constructor ignoring any other executable code that can run before it. Note that step over will not step through lines that do not contain executable code (line #21).
While using keyboard shortcut is much faster, you can still add Smart Step Into action to the toolbar in File | Settings | Menus and Toolbars, Main Toolbar.

Is there any way to debug compiled components using Matlab Debugger?

Is there a way in which I can debug my compiled Matlab components, using native Matlab debugger, like Visual Studio "Attach to process" option, or something like that?
I mean EXE stand-alone files, DLLs, COM in-process servers or .NET components.
You can't debug them in the sense of being able to step through the MATLAB code line by line, as you can with MATLAB's own debugger prior to compilation. One of the steps that the MATLAB deployment products take is to encrypt the MATLAB code (so you can preserve your IP when distributing the deployed component). The ability to step through the code in a debugger after deployment would defeat the purpose of that.
I experimented with using something like :
try
catch ME
waitbar(0,ME.message)
end
This was quite an effective and generic solution.
you may want to break down the code into multiple parts and debug each to save compiling time.
good luck,
dan
You can follow the instructions to debug:
Debugging:
Using the Debugging Tool will let you stop your program in mid-execution to examine the contents of variables and other things which can help you find mistakes in your program. M-file programs are stopped at "breakpoints". To create a breakpoint, simply press F12 and a red dot will appear next to the line where your cursor is. You can also click on the dash next to the line number on the left side of the M-file window to achieve the same result.
Then press F5 or Debug->Run from the menu to run the program. It will stop at the breakpoint with a green arrow next to it. You can then examine the contents of variables in the workspace, step, continue or stop your program using the Debug menu. To examine contents of a variable, simply type its name into the workspace, but be warned: you can only look at the values of variables in the file you stop in, so this means that you'll probably need multiple breakpoints to find the source of your problem. There are several different ways you can move through the program from a breakpoint. One way is to go through the whole program, line by line, entering every function that is called. This is effective if you don't know where the problem is. There's also a way to simply step through the function you're currently stopped in, one line at a time, and instead of going through the child functions line by line MATLAB will simply give you the results of those functions.
Finally, note that you cannot set a breakpoint until you save the M-file. If you change something, you must save before the breakpoint "notices" your changes. This situation is depicted in MATLAB by changing the dots from red to gray. Sometimes, you'll save but the dots will still be gray; this occurs when you have more than one breakpoint in multiple files. To get around this (which is really annoying), you have to keep going to "exit debug mode" until it turns gray. Once you're completely out of debug mode, your file will save and you'll be ready to start another round of debugging. Using comments to help you debug code. you want to test the effects of leaving out certain lines of code (to see, for example, if the program still returns Inf if you take them out), you can comment out the code. To do this, highlight it and then go to:
Text -> Comment
Or press CTRL+R. This will simply put a '%' in front of every line; if the line is already commented out it will put another '%' there so when you uncomment them the pattern of comment lines will not change. Commented lines will be ignored by the compiler, so the effect will be that the program is run without them.
To uncomment a line go to
Text -> Uncomment
Or press CTRL+T.
Another use of commenting is to test the difference between two different possible sets of code to do something (for example, you may want to test the effect of using ODE113 as opposed to ODE45 to solve a differential equation, so you'd have one line calling each). You can test the difference by commenting one out and running the program, then uncommenting that one and commenting the other one out, and calling the program again.
How to escape infinite loops?
MATLAB can't directly tell you you have an infinite loop, it does attempt to give you some hints. The first comes when you terminate the program. Terminate it by pressing CTRL+C and MATLAB will give you a message telling you exactly what line you stopped on. If your program is running a long time, it is likely the line you stopped in is in the middle of an infinite loop. sometimes MATLAB won't even let you return to the main window to press CTRL-C. In this case you probably have to kill the whole MATLAB process. After this, add a "pause (0.001)" or a similarly small value in the loop you suspect to be the infinite one. Whenever MATLAB passes this instruction you will be able to interact with MATLAB for a (very) short time, e.g. go to the main window and press CTRL-C with MATLAB being able to respond to your command.

Visual Studio 2008 - Debugging tips/tricks - Continue "until next function" or "until next file"

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

Resources