Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've seen this in a lot of IDEs (even in the most popular and heavily used ones, like Visual Studio): if you want to watch a variable's value, you have to manually type its name in the Watches section of the debugger. Why can't there just be a list of all of them with checkboxes next to them ?

The developer can then just check the box next to the one he wants to watch and that's it. Variables with identical names can probably be numbered in some way (for example a, b, x(1), x(2), c, etc.

I've seen some exceptions to this (NetBeans or BlueJ), but there are exceptions to everything, right ?

Maybe it's a stupid question, maybe not, but I've always wondered why this is so.

share|improve this question
    
which version of visual are you using? –  Simon Apr 5 '12 at 17:26

3 Answers 3

up vote 8 down vote accepted

I've actually never seen an IDE (haven't worked with Visual Studio though) where the debugger didn't have a view that shows you all the the variables of the current stack frame. A "watch expression" view is provided separately because it allows you to have complex expressions (that may include method calls as well as variables) computed automatically.

share|improve this answer
    
I think you're close to solving my dilemma, but I don't quite understand it. Are you saying that you can (usually) watch something other than variables, execution flow and thread(s) information ? Maybe it's those complex expressions that you mentioned, but I don't understand exactly what those are. Can you give me some example or elaborate your answer a little more ? Thank you. –  Radu Murzea Apr 5 '12 at 20:33
    
@SoboLAN: a watch expression could be something like variable1.method(variable2) + variable3 –  Michael Borgwardt Apr 6 '12 at 7:59

In Visual Studio you have always (been using VS since v4) been able to select a variable in the code window (eg: via ctrl-click or mouse scrub) then drag-n-drop it to the watch window.

There is also the auto window which only shows vars that are currently being accessed (and the eternally helpful "function returned value" feature ).

The Locals windows shows all variables in the current scope.

you can also mouse over a variable while debugging, right-click it and select "Add Watch".

you can also bind the Debug.AddWatch command to any shortcut of your choosing.

barring a "read-my-mind and guess which vars I want to look at" feature, I think it's actually pretty easy and well implemented. (said with humour not sarcasm)

Good Luck

share|improve this answer

In Visual Studio, I think what you are looking for is the Locals window.

Visual Studio

NetBeans has a similar feature:

NetBeans

share|improve this answer
    
In addition, in Visual Studio, you can place your mouse over a variable name in the code and (if it's in scope) you'll see its value pop up. If it's an object, you'll be able to browse its properties and variables (and those of its base) - so no need to search for the variable in the locals field if you can see it right there in the code. –  doppelgreener Apr 5 '12 at 23:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.