Debug "Clear All" option in VS2010 IDE? - visual-studio

I am using Visual Studio 2010, and because of the amount of debug output I'm producing, and the difficulty of finding the beginning of the output for a new run, I have been manually using the Debug "Clear All" action (from the mouse right-click popup menu on the Debug output window). Plus I have to put some kind of break or dialog box in the beginning, just so I have a chance to do this before the debug output gets going.
Well after a couple of thousand times, this is getting very, very old (seriously, because its come up in almost every programming project I've done in the last five years). But I cannot seem to find any option or simple Debug.{method} to do this automatically for me.
This has been bugging me forever, and though its a simple question, I have never found an easy answer (short of writing my own listener) in any version of the .net VS IDE's.
Anyone know how to do this or have any ideas? thnx..

Right click the middle of the output window and turn off all but Program Output

What I do in cases like this is to use Debug View but to see the debug output in Debug view you need to detach the process from you visual studio debugger. You can do that through the Debug->Processes window.
What debug view provides is extra highlighting and coloring of different kind of debug output so that the relevant things are easily recognizable. Furthermore, you can stop receiving debug output by simply hitting a key on its toolbar.
I know that this might not answer your question but this at least gives you an option to do it otherwise.

Related

Visual studio start line by line debugging in the middle of a program

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.

Why is there no way to 'break on next statement' in Visual Studio?

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".

Is there any way to check currently executing code in visual studio?

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 to filter output in Visual Studio 2012+?

I am having problem inspecting specific things in my Debug.WriteLn output in Visual Studio 2015. (Same thing in 2012 and 2013 version too.)
XCode and Eclipse both include a filter-box on top of the Output window. I tried to find a similar extension for Visual Studio but I had no luck. Is there any way to have a similar feature and filter the output window?
I use this method:
Open Debug – Output window, just by right click on the Window.
You can Check / Uncheck as per your need.
One thing I just found in VS 2017 (and I think it's in other versions too) is:
Tools | Options | Debugging | General > Redirect all Output Window text to the Immediate Window
This gives you just the program's Debug.WriteX output in the immediate window and leaves all that other trash in the output window, which you can leave closed.
I can still go look at the trash in the output window if I need to for some reason; it isn't suppressed. It just doesn't make it into the immediate window.
And I just leave the little immediate window docked at the bottom.
I think it's good because with all the trash coming out in the output window, I really wasn't paying any more attention to the output than I would a terms of use agreement (which is to say, just about none), so the baby was getting thrown out with the bath water. But now I actually see some program debug output that lo and behold, needs attention.
IMHO Microsoft should expand the output window dropdown box to include all the categories that FetFrumos pointed out in his answer, so developers can just leave it set to "Program Output". I think this would be a good improvement.
Various services in VS write to the output window so there is an in-built filter based on source. You can often select the source such as "Build Output", "Test discovery", "General", "Debug" etc.
Debug.Write calls are intercepted by VS and the text ends up in the Output window but there is no in built filtering.
I can think of 3 ways around this:
Use DbgView to intercept the Debug.Write messages instead of letting VS intercept them. DbgView has very powerful filtering and coloring features*
Try this extension that colors the output based on regular expressions
Write your own extension (it's not that difficult!)
(*) If you go down this route note that Debug.Write is just a trace and when you attach the VS debugger it will add itself as the trace lister. Same for DbgView. But when you detach it will not remove the listener and the messages will be lost.
I've wanted to filter Visual Studio output for many years. Eventually I decided to write an extension to do it. If you're interested, you can check it out at niahtextfilter.com.
Here's an idea of what it does:

Nothing displayed in Output window (Visual Studio 2008)

I have been assigned to a project at work and I need to do some old-style debug because the Debug itself doesn't work with the libraries which are being used.
So, since it's a C++ with Qt application, I first tried with qDebug(). Then with cout, and finally with printf (which I hate in comparision to the former ones). NOTHING.
Nothing is written into the output window of Visual Studio 2008, and I'm quite sure it is executing these lines of code (I even tried to put a qDebug at the very beginning of the main.cpp). It is a GUI app by the way, and I've tried Debug output as well as Build output, but nothing is displayed.
I have looked for similar questions, but none of them provided a solution yet. Any help?
Chances are, your Visual Studio environment has been configured to redirect all output from the Output Window to the Immediate Window. I've been bitten by this a couple of times, as this is inexplicably a default setting for certain environment configurations.
To reset the setting, follow these steps:
From the "Tools" menu, select "Options".
Expand the "Debugging" item in the tree to the left, and select "General".
In the list to the right, scroll down to "Redirect all Output Window text to the Immediate Window", and ensure that it is unchecked.
Click OK to return sanity to the world.
It looks like you can't use qDebug directly if it is not a console based application. Sounds weird to me, but sadly it is like that.

Resources