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().
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 have been given a project that is the biggest pile of spaghetti I have ever seen, with 0 unit tests or any obvious naming conventions.
I find it hard to believe there is still no way while running in Debug to have Visual Studio automatically break on the next executing line of solution code.
In this case, I know the code is hitting a specific 5000 line of code file - but there isn't even an easy way to just write a breakpoint to every single line!
Is there any logical reason why in 2017 (or even 2010) this functionality doesn't exist?
Or perhaps it does and I haven't found out how!
Is there any logical reason why in 2017 (or even 2010) this functionality doesn't exist?
Please Put a break point in your code -> debug, then Right click on the text editor in VS, you will see below:
You can use the "Break all" button in the visual studio (Ctrl+Alt+Break is the default shortcut).
You might need to switch between the running threads in order to see highlighted instruction within your code.
Then you can just continue debugging, as usual.
If you do not see any of those two controls, go to View->Toolbars and check both "Debug" and "Debug Location".
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!
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.
Is there a Visual Studio macro (either for version 2008 or 2010) to set a breakpoint on the start of every method in a class?
I've seen hints of references, but I've not been able to dig an actual one out.
A Visual Studio extension named OzCode does have a feature to set/unset breakpoints on all members of a class. I use this extension a lot, as it has some very nice debugging enhancements.
Admittedly though, I haven't used the set/unset breakpoint feature much, but it's an option for you.
There are some good ideas here:
How to put breakpoint in every function of .cpp file?
Wouldn't you be better off just single-stepping through your source code?
I can't imagine why a breakpoint at the start of every method would be any better than single-stepping. You're going to end up breaking everywhere anyway, and single-stepping provides the additional advantage of showing you the logical flow of your code paths.
You'll probably definitely want to learn the keyboard shortcut keys, but they can depend on how you have your VS environment set up. Look in your "Debug" menu for the "Step Over" and "Step Into" items. (Normally, Step Over is F10 and Step Into is F11.) The only difference is that, if the currently highlighted line contains a function call, Step Into will allow you to single-step through the code in the called function (this is probably most like what you want to do), while Step Over will simply call the function and stop on the next line in the current function.