How can I find out which line will be executed after performing any action?
If I know what will be executed I can put break point there. But what if I am not sure where to set breakpoint or just I need to go to the executing line faster (without setting breakpoints).
"Break All" is not what I look for. It is pausing debugging, so I cannot perform any action (just after which I want Visual Studio sets breakpoint automatically)
In other words, for example I want to start debugging each line after clicking a button, without putting breakpoints. Is it possibile?
For a .NET application you can use my Runtime Flow tool (30-day trial) to see code that is executed after some action.
Set a breakpoint at the line you want to stop after. Then once the breakpoint is hit Step Into or press F11 in Visual Studio. This takes you to the very next line of code that executes, no matter where it is in the project.
Related
I am working on a program and a lot of the buttons and menu items are dynamically created. Its especially hard to work on because I don't know where they are created and assigned to. It would help if I could start up the program via debugger, get to the menu, then switch to "line by line" style debugging like pressing F10, where the next line of code ran would break, and then press one of the buttons to get more info about it once the break happens. Is there any way I can do this in visual studio?
In Visual Studio, you have the Solution Explorer. There you see the Project files, they are under the top level Solution. If you right click on your main project, go to: Debug > Step Into New Instance.
If you work on a .NET application, you can use my Runtime Flow tool to see what code is executed when you select a menu item or press a button.
The closest way I could figure out how to do this is to go into Debug>Disable All Breakpoints and then when I get to where I need to be in the program go back and Enable All Breakpoints. Of course this only works if there is a large number of breakpoints in places in the program.
I've been working on a C# project and I don't know the program flow. I want to know all the executing codes in a particular flow. I can press the pause button to check current executing code, but to check entire flow, I need to keep on pressing F11 or next line, which is cumbersome. BTW, I got it from here
Find out what line of code my app is currently running in Visual Studio's debug mode
I would like to know is there any way in visual studio to check currently executing code without pausing or placing break points?
I often use the VS debugging breakpoint or debug menu options like "Step Into/Out" or use the pausing button.
But if you don't want to use them, the Runtime Flow tool is a workaround I know which can help you see code that is executed:
Find out which line will be executed in Visual Studio debug mode
A feature request for VS IDE:
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/17332198-is-there-any-way-to-check-currently-executing-code
In VS2017, debug has a new feature called "Run execution to here", I know that it doesn't really meet your requirement, but it is a better workaround if you don't want to step Into debugging one step by one step. Move your mouse to the icon and click the button, now your code will run and stop on that line the next time it is hit in your code path.
If you want this ability at debug time then consider IntelliTrace
ReSharper has a Call Tracking feature that can display incoming and outgoing calls sequenced in an interactive, graphical tree view.
See if this helps.
The issue here is that there is code running but you don't know where and you want to see what is going on. A good example is the code is stuck in a loop somewhere but you don't know where.
To break-into the running code:
Option 1: Select the 'Debug' menu item, and then select the 'Break All' menu item.
Option 2: Press keys Ctrl+Alt+Break.
This will break into the code where it is executing and you will step into debugging just as if you hit a breakpoint.
Happy debugging!
I need to stop at breakpoint in case when other breakpoint was passed. Is it possible realize in VC++?
Why did you debug your two breakpoint using this way? If the debugging runs to the specific code line, it would call the conditional, and then trigger the conditional breakpoint, if it just runs to A code line, I don't think it could call the conditional in B code line unless it really calls/runs to this line.
I do c#, and I know JetBrains Rider has exactly the feature you want. Called Dependent breakpoints. So I guess their c++ IDE CLion also has the feature.
In Visual Studio, you can manually do this. Set up the two breakpoints, disable B first. Run the code, after A got hit and the execution suspends, then enable B, press continue.
How can I prevent Visual Studio from tracing into strlen() and other such functions?
I have a source line like:
i = my_function(x, strlen(x));
When I step into this line of source, I don't want to step into strlen(), but only my_function(). Is there a way to remove these as I encounter them?
You can right-click on the line in the debugger and choose to step directly into my_function, or if the call has multiple argument function calls, you can step into one of your choosing from the right-click menu. This doesn't let you skip those automatically, but it is helpful.
Assuming you mean stepping through the code in the debugger within Visual Studio. You should be able to just press F10 to step over code when you're on that line. If you press F11, that'll step into the code which means you'll travel down into the code for strlen().
1) I put a breakpoint, VS breaks where I put the breakpoint.
2) I then start browsing around the code normally to put another breakpoint
somewhere down the execution path. (maybe in another class in some other cs file)
3) I would now like to return to where I first stopped (just navigation in the code. Do not confuse with the go back in debugger feature used in VS's intellitrace debugging tool)
Right now I place a bookmark and return to my bookmark. But I forget most of times to place a bookmark. Hence this question. There's got to be a shortcut to get back to current line of execution or stopped at or whatever phrase is used to describe this. I also have Resharper if I can craft up some hotkey or shortcut. Anyway I can get back to where the debugger has "broken". I sometimes also use Ctrl - multiple times to navigate backwards.
thank you
That would be the Visual Studio command "Debug.ShowNextStatement" (usually assigned to Alt+Num*). You can also use the Breakpoints Window (Alt+Ctrl+B) to navigate between your breakpoints.
UPDATE: I implemented #Alex 's request for a more discoverable and accessible MenuItem for this functionality, as part of a commercial Visual Studio extension I created called OzCode. It works similarly to Resharper's Context Actions: when you are in break mode but have navigated far away from the 'current statement', this QuickAction will appear:
I tend to use the call stack window, double click the top line in the stack trace causes the editor window to display the code line where execution halted