Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print out values while debugging

In Xcode I am able to "po" any values while debugging. Is there a way to do this in Android Studio?

For example, if I hit a breakpoint and want to print out certain values in realtime as opposed to having to use Logs in my code?

like image 609
vikzilla Avatar asked Nov 10 '15 06:11

vikzilla


People also ask

How do I show variables in Debug mode?

Hover over a variable to see its value. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

How do you Debug a print statement?

Print statement debugging is a process in which a developer instruments their application with “printf” statements to generate output while the program is executing. The output generated helps diagnose issues within the program.

How can I see the variable value while debugging in Eclipse?

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.

How do I show Debug variables in Intellij?

You can click on the Run icon in the gutter area and select the Debug option. You can invoke context actions on the class or main method by using Alt+Enter and choose the Debug action. You can also start it from the Run menu, or by pressing Shift F9.


1 Answers

You can do the following steps:

1- Set BreakPoint in the line you want to evaluate Ctrl+F8.

2- Run your code in debug mode or press Shift+F9.

3- When reached to the BreakPoint press Alt+F8 or click on the following button.

enter image description here

4- Then type your value in text-field and click on the Evaluate button.

enter image description here

References:

  • https://www.jetbrains.com/help/idea/debugging-code.html

  • https://www.jetbrains.com/help/idea/evaluating-expressions.html

like image 76
Amir Avatar answered Sep 18 '22 12:09

Amir