d e b u g g in g j a v a w ith e clip seleveraging the eclipse ecosystem | © 2005 bill dudney |...

30
Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Debugging Java With Eclipse Killing Bugs in your Java Code with the Eclipse Debugger

Upload: others

Post on 24-Feb-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Debugging Java With Eclipse

Killing Bugs in your Java Code with the Eclipse Debugger

Page 2: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Agenda

Debugging

Debugging Perspective

Debugging Java Applications

Debugging Remotely

Page 3: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Debugging

Jargon - shotgun debugging n. the making of relatively undirected changes to software in the hope that a bug will be perturbed out of existence. This almost never works, and usually introduces more bugs.

Page 4: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Debugging

Reference.com - debugging: To search for and eliminate malfunctioning elements or errors in: debug a spacecraft before launch; debug a computer program.

Page 5: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Debugging

Wikipedia - Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware thus making it behave as expected. Debugging tends to be harder when various subsystems are tightly coupled, as changes in one may cause bugs to emerge in another.

Page 6: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Good Old Days

GDB - C/C++/Objective-C

other GNU languages as well

Command line - but very powerful

Cool theme song :-)

Page 7: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Bad Old Days

JDB

painful to use, slow, not very feature rich

Logging was easier

Thus everyone went to logging

Page 8: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Agenda

Debugging

Debugging Perspective

Debugging Java Applications

Debugging Remotely

Page 9: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Debugging Perspective

Page 10: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Debugging View

View threads

Start/Stop/Pause the program

Step through your program

Controlling the VM

Page 11: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Variables View

View any value in your application

See the state of your app

Page 12: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Breakpoints View

Edit Breakpoints

Manipulate Breakpoints

Page 13: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Breakpoint Properties

Page 14: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Expressions View

View Variables

Examine Program State

Page 15: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Display View

Manipulate Variables

Manipulate Program State

Page 16: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Agenda

Debugging

Debugging Perspective

Debugging Java Applications

Debugging Remotely

Page 17: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Methodical

Test Driven Development

Unit Testing

Developer Testing

Good Requirements Definition

Use Cases lead to Test Cases

Page 18: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Setting Breakpoints

Line

Method

Class load

Exception

Watch Point

Page 19: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Setting Line Breakpoints

Double Click in the margin

Page 20: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Setting Method Breakpoints

Double Click in the margin

Page 21: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Method Breakpoint Properties

Page 22: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Class Loading Breakpoints

Page 23: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Exception Breakpoints

Page 24: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Watch Point Breakpoints

Double Click in the margin on a field

Page 25: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Watch Point Properties

Page 26: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Enough Presentation Lets Debug

JUnit Test

Drives code

helps find bugs

control over execution

Page 27: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Agenda

Debugging

Debugging Perspective

Debugging Java Applications

Debugging Remotely

Page 28: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Remote Debugging

Get VM listening for connections

-Xdebug - start and listen

-Xrunjdwp:args

Example-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8111,suspend=n

Page 29: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Enough Presentation Lets Debug

Cactus Test

Drives code

helps find bugs

control over execution

Page 30: D e b u g g in g J a v a W ith E clip seLeveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0 Agenda Debugging Debugging Perspective Debugging Java

Leveraging the Eclipse Ecosystem | © 2005 Bill Dudney | Made available under the EPL 1.0

Conclusion

IDE Debuggers are powerful and full featured

Stop Logging

Remote Debugging

Works like a champ and prevents costly redeploys to add logging statements