Eclipse: Improve debugging and display variable values on mouseOver - visual-studio

Is it possible to view variable values in Eclipse when debugging? Right now when I "mouse over" a variable all I get is the definition.
e.g. for [int mLastView] I get [com.company.samples.MyClass.mLastView] instead of 1. The value that was assigned to it.
Also, is there anyway to improve debugging in Eclipse?
For starter: making the breakpoints visible as in VS (see below)?
Eclipse Break Point
Visual Studio Break Point

I posted this over at Stack Overflow and one of the suggestions was to go into Window -> Preferences -> Java -> Editor -> Hovers and select the Variable Values option and assign a modifier.
When I was first trying to resolve this issue, this was one of the options I looked at, but oddly enough, there was no Variable Values preference available, it was missing. Once my “fix” above was applied, it magically appeared:
Click to see the pictureBroken Link

Actually, since eclipse3.4, not only do you see the value of a variable when you pass the mouse over it, you can actually inspect it:
When debugging, hovers for variables have been enhanced to display an object inspector. The inspector will display logical structures according to the toggle setting in the visible Variables or Expressions view.

If you hit the breakpoint while you are debugging, you do see the value of the variable when you mouse over. You can also select an expression, and inspect the value of it's evaluation using the "Inspect" menu option. You can also use the "Variables" view to see the current value of all in-scope variables.

About breakpoint visibility:
Right-click on the right outline of the editor, you'll see some Preferences, and there in Annotations you can select Breakpoints. I personally added Text as Highlighted and some pinky colour. Shame that the highlighting is really buggy, sticks here and there, breaks between lines, etc. But it somehow works for most cases.
(Another shame is that breakpoint bullet is often hidden behind some suggestion icon or what - why they can't make the gutter wider like Idea does, I don't know.)

I got similar but a little different problem with the thread-starter. Sometimes during debugging, I mouse over a variable, I see it current value. Sometimes it's just the definition, like in coding mode. So what caused the first case, what the second?
PS: Of course I can always choose to view Variables (Alt+Shift+Q,V) but it's faster if you have mouse over value instantly.
Thanks

Related

Navigating within Visual Studio DataTip

When a DataTip is open while debugging in Visual Studio it appears the only way to get to a specific object property is scrolling with the mouse.
This can get very cumbersome as some objects can have hundreds of properties and scrolling to a property near the bottom takes a long time.
Yes, I know I can scroll faster if I hover the mouse over the bottom edge and pin a property once I found it but it can still take a long time to get to the property and pin it.
I've tried various combinations with Ctrl and Alt but what ever key I press the DataTip is promptly closed...
Once the DataTip has focus, you don't have to use the mouse. You can use the PgUp/PgDn (Page Up/Page Down) keys on your keyboard. But you're right: There is not a way to get to the end of the list or to get to items that start with a certain letter. When I need to do that often I take one of two approaches:
If possible, I create a [temporary] variable assignment after the code-line of interest and ensure that the variable gets assigned to the property of interest.
Create a watch variable and interact with that.
Open an Immediate Window and paste a copy of the object-instance name in question. Once in the Immediate Window, IntelliSense is available as soon as you type the "."--you can then type the letter of the property in question and drill-down as needed more quickly.
(Probaby the best tip!)
Open (and keep open for convenience) a Debug | Windows | Autos and/or Debug | Windows | Locals window. Those windows simplify navigating variables near the code break or in the current module--and they even seem to retain their tree-node-expanded state in some cases while debugging. More information is available here: https://msdn.microsoft.com/en-us/library/bhawk8xd.aspx
You could use the oz-code as an extension tool which could help you search the properties or variables easily.
Search in debug mode inside an object

visual studio highlighting space / horizontal line between parentheses

I would like to show a vertical line, next to the linenumbers, in my visual studio 2010 between parentheses when my courser is between those 2 parantheses.
I alread had that option enabled, but somehow its gone.
edit: is nobody using that feature? one of the very nice things when you are debugging
Is no one using that feature??
Edit: so last push!! there must be a way to see where the space between parentheses starts and ends.
edit: here is an image
EDIT: I still haven't found what i'm looking for. VS is so powerful there must somewhere an option or a plugin. It is really useful when you can see where your { begins and ends }.
Anyone a clue?
I haven't seen the horizontal line feature since 2008. I hated it so I haven't been looking for it either.
You should however be able to see the braces being highlighted when your cursor is on them. If not, perhaps you've changed your theme or possibly some colors in your Options menu.
Here's what you should try:
Tools ->
Options(down at the bottom of the drop-down) ->
Environment ->
Fonts and Colors
Make sure the Show settings for: selector is showing Text Editor.
The one(s) you're looking for are Brace Matching (Highlight/Rectangle).
Attempt to change it to your choosing and see if the changes take place. If not, reset to the defaults and re-check it's enabled.
Also...
Another suggestion that can be handy to get a temporary look at the extents of the body you can hover your mouse just along the margin it will highlight the most nested body. You may have to do some tweaking of your colors to make it vibrant. I use a darker color and have my code block highlighting white. I know it's not what you're looking for but it might be somewhat of a band aid.

Watch Expression in Xcode

Say I am debugging. Say I need to know what the value of [somevariable count]
How would I do so?
If what you want to do is know the value of the expression while program execution is halted, then do something like
> p (int)[somevariable count]
in the gdb console.
Note:
People searching for the term "watch" might be expecting an answer about being able to observe when a value changes. For that question these are some answers that are more appropriate:
Watching variables in Xcode
Xcode LLDB watchpoints
Put a breakpoint on the relevant code line.
When Xcode stops on that line, in the debug area (the bottom of the screen is splitted to two parts, look at the right one, if you don't see the bottom part, shift+cmd+Y, plus sometimes the right side or the left side are hidden and there are small buttons on the right bottom side to show them), you see all of the local and global variables.
Right click (or two fingers) that debug area, and you will see a context menu with one of the options "add expression".
Type in your expression.
Note:
above previous user's comment about the word "watch" is pretty clear to whomever comes from any other IDE but not in Xcode.

Can I add my own code snippets to xcode 4?

It'd be really handy to have collection KVC accessor snippets in xcode, as they're a pain to do by hand. Has anyone who's been using 4 for a while worked out how to add new ones?
(...we're allowed to talk about it now, right?)
Yes, it's quite easy - you just highlight text you want to use as a snippet and drag it into the snippets area (dragging selected text can be difficult, I find it works better if you drag from the left edge of the editor). It brings up a dialog box asking you to name it.
Also, you can have custom parameters in snippets - if you put the text <#paramName#> anywhere in the code you are dragging, when you use the snippet it will come up as a replaceable parameter that you can tab between just like in the official Snippets.
Also make sure to set a completion prefix, which makes it shorter to activate the snippet as you are typing. The nice thing about using Snippets over other solutions like global system text expanders, is that snippets can also be limited to being valid in a certain area of code - so for example a snippet that filled out a string formatting line can be marked as valid only within a block, not outside a method. That way the completion prefix only hits in areas where it's valid to use.
You can edit a snippet by clicking once on it, a box will come up with the snippet text and some other snippet settings you can edit.
A tip to help you drag the code every time, select text then click + hold (do not move mouse) until mouse pointer changes from "I" to pointer. You'll then be able to drag the selected text to the Code Snippet Library.
Drag the highlighted code to the Snippet library. (It can be stubborn and not want to drag. Holding the mouse button down for a moment before dragging seems to help.)
You can use Snippets to manage code snippets in Xcode. Check out this demo http://www.youtube.com/watch?v=il4kE4diy0k
Simply select the code, the press ALT key and drag it into the code snippets library and rename it there, Make sure to press the ALT key, other than this you won'n be able to drag it.

VS2010 Debugging: Display Datatip w/o mouseover (use keyboard)?

I'm in VS2010, on a breakpoint. How can I cause a datatip to be displayed for a given variable/expression w/o using my mouse to hover it?
That can't be done, exactly, but you can get the same result by selecting the variable you want to watch (using ReSharper's Ctrl + Alt + →/← can speed this up), and pressing Shift + F9, which will raise "QuickWatch" modal window with the datatip contained within.
If you prefer, you can also go into Options->Keyboard and bind the Debug.AddWatch to a different keyboard shortcut, and use that instead of Shift + F9, and then your variable data will persist in the Watch window so you can come back to it later (as suggested here)
You can also do this by opening the command window (Ctrl + Alt + A) and typing Debug.AddWatch variable_name.
While you can pin multiple windows in VS it will be a somewhat cumbersome experience and you will have to over it.
I personally use visual studio plugin called Oz Code, that automatically annotates all the local variables and intermediate results so I don't have to chose which variables to pinpoint.
The results looks something like this:
Will adding a watch not be suitable? When you hit your breakpoint the relevant details of the variable will be shown in the watch window.
Perhaps I have misunderstood what you're trying to achieve here!
You can click the 'pin' icon to force any datatip to stay open, and it will update to the current contents when you hit the breakpoint.
I don't know of a way to open a specified tip without pinning it, however.
The Locals and Autos windows might be helpful as they show all local variables, (they even show the return value of called functions!).
Note however that they show directly only variables in scope, so if you need a detail property that it is not yet menotioned in the code you can drilldown using the →/← keys, however if it is already mentioned in the code in the current scope then you should be able to see it directly in the Autos window.

Resources