I'm newbie on Eclipse.
In Objective-C, I could print value of an object in console window with this command.
po nameOfValue
Maybe gdb
command. I'm using Eclipse now, what's the equivalent of this in Eclipse?
P.S. I'm debugging a Java app.
But you can override the toString() method of your object and there concatenate the string with the values of each field or whatever you want to print for that object. Then when calling somewhere in the code System. out. print(myObject); it will print the result of the toString() method which you've overridden.
Variables/Expression view – Shows the declared variables and their values. Press Ctrl+Shift+d or Ctrl+Shift+i on a selected variable or expression to show its value. You can also add a permanent watch on an expression/variable that will then be shown in the Expressions view when debugging is on.
To manually open the Expressions view, go to Window | Show View | Debug | Expressions. The Expressions view allows you to monitor certain variables which you have decided to 'watch' during the debugging process. Selecting a variable will display details in the detail pane below the view.
Eclipse has very robust debugging capabilities - much more so than Objective C.
First off, while debugging you can view the values of all variables in the Variables window. Additionally, in the lower part of the Variables window you can type arbitrary Java, select it, right click, then choose to Inspect or Execute. You can actually change the value of variables in your program this way, while its running.
You can do pretty much the same thing in your source pane. Highlight a variable, right click and choose to Inspect it. You can also type in a random expression and execute it. You can also places watches on variables (which I believe you can do in Objective-C), or on expressions.
There is an Expression view which is not displayed by default (on your menu select Window->Views->Expressions, while in Debug perspective). It allows you to add arbitrary (valid) Java expressions and the values of those expressions will then be watched over the lifetime of your debug session, very nifty. Thanks to @Baldrick for the reminder of this great tool.
System.out.println(nameOfValue);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With