Boppity Bop
Boppity Bop

Reputation: 10463

How to find which code outputs certain debug string in Visual Studio?

Is there a way to find out which piece of code does certain prints in the Output window in Visual Studio?

I have very large project which outputs bunch of small prints repeatedly in thousands. It might take days to find where is it because it doesn't have a constant string to do a simple text search in code. It seems the output is dynamic (like a property name)..

And it is real-time app. Really difficult to debug cos its just goes haywire if you pause it for a second..

Any way it can be done (other than eyeballing 1000s of debug statements)?

Upvotes: 0

Views: 151

Answers (2)

Sergey Vlasov
Sergey Vlasov

Reputation: 27890

You can try my Runtime Flow tool (30-day trial). Set filter to include your code and the debug output method, start monitoring and capture debug output calls, search for your certain debug string as the parameter to the debug output method in the Flow window, see what calls this output method.

Upvotes: 1

Ton Plooij
Ton Plooij

Reputation: 2641

I'm assuming that your app is generating these prints using System.Diagnostics.Debug or .Trace calls. In that case you can write a TraceListener and add it to the Debug.Listeners collection. You then have your own handler for the prints and can likely filter your dynamic output (or set a conditional breakpoint). If that's not sufficient you can use System.Diagnostics.StackTrace within your handler to print calling functions real-time.

Upvotes: 1

Related Questions