views:

741

answers:

5

I have a VB app that I need to monitor while it is running. I added some variables to the Watch window, but while the app is running the watch window is greyed out. The only way that I have found to see the variable values is to use Debug -> Break All, but this stops the program.

I have used other IDEs and they allow active variables to be monitored. Is this possible in VS?

Sorry if this is a noob question.

UPDATE: To be clear, my app is communicating with a piece of lab equipment and and as data is sent or received or errors are detected counters are incremented. I would like to watch these counters but I don't want to build a screen to do this since they are for debugging. I just assumed that this is basic functionality in any IDE

SHOCKED: It seems that Visual Studio does not offer this (what I would consider) basic functionality. For those that seem to think that this is not possible with an interpreted language, consider this thought experiment. If you pressed Break All quickly followed by a Continue then you would refresh the watch window - correct? Why then can't Visual Studio do this as a single Refresh Watch command or better yet allow this function to automatically run at a period specified by the user. No debug writes, no log files, no stopping your program mid-stream and creating timeouts. I am just shocked that you cannot do this. Its a little like not having breakpoints.

+1  A: 

After you've done "break" to give control of the program to the debugger, then you can "step" through the code using function keys like F10 and F11. During each 'step', the program evaluates one or more statements; after each step it stops (until the next step), and while (only while) it's stopped you can 'watch' its current state.

There are other ways too to break into the debugger (to use the Watch window while the program is stopped): other ways like to set 'breakpoints', and use the 'run to cursor' feature.


Of course, but stopping a program that is actively receiving or sending data to a some other process, driver, etc, stops this communication and causes timeouts and other problems.

That's true. To watch values change in real-time, I use a log file:

  • Add statements to my code, such that when I change the value of a variable I emit a new line to a log file (showing the changed value)

  • Run the program

  • Watch new lines being appended to the log file using a utility like tail -f.

I've never see a debugger with the functionality you mention. The closest thing to the functionality you mentioned (and which isn't exactly the functionality you mentioned) is How to: Set a Data Breakpoint (Native Only).

ChrisW
Of course, but stopping a program that is actively receiving or sending data to a some other process, driver, etc, stops this communication and causes timeouts and other problems.
NormD
There are lots of problems with a log file. Lets say you are receiving thousands of data packets per sec, if instead of simply incrementing a counter, you write a line to a log file, the system will fall over. Even writing to a console is a very heavyweight operation compared to incrementing a counter.
NormD
In another comment, you said "Codewarrior and Chameleon allow you to ... specify a refresh interval in secs or msec"; you can build the same logic into your logging, e.g. write to the log file once every few seconds. Anyway, I think you have your answer now.
ChrisW
A: 

Make sure you are in "Debug" build and Microsoft Debugger is running as a service and not blocked/disabled.

Zepplock
I press F5 and the app runs. I assume this is the debug build since if I break the app the variables all have values.Hoes does one run debug as a service? Would this allow me to see the variables as the program is changing?
NormD
A: 

Which IDE or development environment shows - in real time - the values of variables in the Watch window, without having to hit any breakpoints, while the application is running?

Visual Studio doesn't provide this. In order to get updated values in the Watch window, or edit items there, the app needs to be at a breakpoint or debugging.

marcc
Both Codewarrior and Chameleon allow you to manually refresh the contents of the variables or set an automatic refresh, specifying a refresh interval in secs or msec.I just assumed this is base functionality in any debugger.
NormD
Ah, it's certainly been a while since I've used Codewarrior. I wasn't aware of this, which is why I asked which IDEs let you do this. I'm impressed, and do wish Visual Studio had a similar feature. Thanks for the information.
marcc
A: 

What you're attempting to do is not possible in Visual Studio. All of the variable inspection windows (watch, locals, autos, etc ...) rely on the debugee process being in a break state in order to function.

This is true of essentially any debugger I've worked with in the past. At least those which use a compiled language.

I'm curious as to what IDE's you're referring to? Did they deal with interpreted languages?

JaredPar
A: 

This should help you: How to trace and debug in Visual C++ .NET and in Visual C++ 2005

Jimbo
Thank you for the pointer, but the article says that it applies to C++ and does not mention VB. Also from a quick review it seems to use lots of debug write statements, which are certainly a lot more work than tracing a variable.
NormD