tricks

32
Martin Skarsaune Senior Developer and Co- Owner @MSkarsaune Java Debugging Tricks We’re Hirin g

Upload: martin-skarsaune

Post on 17-Jan-2017

99 views

Category:

Technology


0 download

TRANSCRIPT

Martin SkarsauneSenior Developer and Co-Owner@MSkarsaune

Java Debugging Tricks

高馬丁

We’re Hiring

Execution Order• Code evaluation• Controlling your steps and breaks• Manipulating code flow• Tracking classes and objects• Ensuring WYSIWYG• Debugging concurrent code• Customizing the debugger

SIGHUP!

Frames + threads Variables Watches ?

Test Results?

Console Display ?

Code

Frames + threads Test Results?

Variables + watchesConsole

Code

1. Should you always launch in debug mode?

IMHO: Always Launch in Debug Mode!• Ability to halt and troubleshoot• Threads• Hot code replacement• Consider launching externally

Excecution Order• Code evaluation• Controlling your steps and breaks• Manipulating code flow• Tracking classes and objects• Ensuring WYSIWYG• Debugging concurrent code• Customizing the debugger

2. Evaluating Code

Step Out- Code Evaluation• Both in Java editor and free form• Nothing is private • Watches• In breakpoints• Nested evaluations / breaks • Scrapbook

Execution Order• Code evaluation• Controlling your steps and breaks• Manipulating code flow• Tracking classes and objects• Ensuring WYSIWYG• Debugging concurrent code• Customizing the debugger

3. Controlling your steps and Breaks

Step OUt- Controlling your steps and breaks• Step filters• Frame filters• Smart stepping• Lambda stepping and breakpoints• Exception breakpoints– Break after

Execution Order• Code evaluation• Controlling your steps and breaks• Manipulating code flow• Tracking classes and objects• Ensuring WYSIWYG• Debugging concurrent code• Customizing the debugger

4. Manipulating Code Flow

Step Out- Manipulating Flow• Drop to frame• Modify values – nothing is really final • Force return

Execution Order• Code evaluation• Controlling your steps and breaks• Manipulating code flow• Tracking classes and objects• Ensuring WYSIWYG• Debugging concurrent code• Customizing the debugger

5. Tracking Classes

Step Out - Tracking Classes• Class load breakpoints • Static initializers• All instances and count– Requires ”JVM Memory Debugger View”

plugin

6. Tracking Objects

SteP Out- Track Objects• Instance initializers + default

constructor• Unique Id + Labelling objects • Watch points + instance filter• Tracking references

Execution Order• Code evaluation• Controlling your steps and breaks• Manipulating code flow• Tracking classes and objects• Ensuring WYSIWYG• Debugging concurrent code• Customizing the debugger

7. Is What You See Real?

Step Out- Connection to code• Detecting erroneous source attachment– Editor Warning– Evaluate timestamp of class

• Method breakpoints • Viewing actual code

Execution Order• Code evaluation• Controlling your steps and breaks• Manipulating code flow• Tracking classes and objects• Ensuring WYSIWYG• Debugging concurrent code• Customizing the debugger

8. Dealing With Concurrency

Step Out- concurrency• Instance and thread filters on

breakpoints• Step resume • Analyzing deadlocks

Execution Order• Code evaluation• Controlling your steps and breaks• Manipulating code flow• Tracking classes and objects• Ensuring WYSIWYG• Debugging concurrent code• Customizing the debugger

9. Customizing the DEbugger

Quick Recap - Customizing the debugger• Detail Formatters / Data Type Renderers• Logical Structures

References

10. REferences• IDE documentation• Debugging in IDEA 2016.1 https://

www.youtube.com/watch?v=VdBsUv4lnm4• Decentipede Eclipse plugin update site:

https://skarsaune.github.io/decentipede.update.site

• JavaZone 2015: ”JVM Debugging under the hood”. https://vimeo.com/138957695

Final Questions

?

Thank you for your time!