Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science [email protected] 2013...

18
Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science [email protected] http://sce.uhcl.edu/yue/ 2013 CSCI 3333 Data Structures

Transcript of Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science [email protected] 2013...

Page 1: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Java Debugging in Eclipse

by

Dr. Bun YueProfessor of Computer Science

[email protected]://sce.uhcl.edu/yue/

2013

CSCI 3333 Data Structures

Page 2: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

General Resources

Like other IDE, Eclipse includes a good debugger for Java.

Allows developers to control program execution for investigation.

http://help.eclipse.org/juno/index.jsp: check the section on debugging.

Page 3: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Java Editor

The editor already provides assistance in program development and debugging.

Page 4: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Example

Page 5: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Perspective

Page 6: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Debugging

Likes solving mystery and puzzles, CSI, etc.

You need to have:1. Domain knowledge2. Reasoning3. Investigating and looking for clues4. Making and testing hypothesis

A debugger can help in (3) and (4).

Page 7: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Java Debugging

To debug a Java program, use one of the following: the debug button Run > Debug As > Java Application After confirmation, a debug perspective

(view) is open. You can check variable values during program suspension by breakpoints.

Page 8: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Breakpoints

Can be used to suspend program execution.

Developers can then check variable values.

Can be disabled.

Page 9: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Example

Page 10: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Example

Page 11: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Variable view

Page 12: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Actions after halted

Examples: Step into, Skip all breakpoints, Step Return, drop to frame, etc.

Page 13: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Method breakpoint

Page 14: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Watchpoint

A watchpoint is used to watch a variable.

The debugger halts when the variable is accessed.

You can toggle a watchpoint on a variable by right-clicking the declaration line of the variable.

Page 15: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Hit Count

Page 16: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

More tips

More features and tips from http://javapapers.com/core-java/top-10-java-debugging-tips-with-eclipse/. E.g. Watch points Conditional breakpoints …

Video tutorial: http://eclipsetutorial.sourceforge.net/debugger.html

Page 17: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

More tutorial

http://www.vogella.com/articles/EclipseDebugging/article.html

Page 18: Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu  2013 yue@uhcl.edu

Questions and Comments?