The Debugger - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

The Debugger

Description:

An uncaught exception occurs. You select the debug button ( ) on any tool bar ... Can specify 'caught', 'uncaught' or both. Evaluating Expressions ... – PowerPoint PPT presentation

Number of Views:53
Avg rating:3.0/5.0
Slides: 15
Provided by: homeM8
Category:

less

Transcript and Presenter's Notes

Title: The Debugger


1
The Debugger
  • Unit 06

2
Unit Objectives
  • To learn how to
  • Use Eclipses debugger
  • Set breakpoints
  • Use inspectors

3
The Application Developer Debugger
  • The text-based debugger (jdb) supplied with the
    JDK does not have to be invoked
  • Eclipses debugger is a visual debugger
  • It is opened under the following conditions
  • Execution hits a breakpoint that you inserted
  • An uncaught exception occurs
  • You select the debug button ( ) on any tool
    bar

4
Debugger Capabilities
  • Modify
  • Code while in the debugger
  • Data values while stepping through code
  • While in the debugger
  • Set breakpoints
  • No unnecessary editions are created
  • Multithreading support
  • To debug your code you do not have to
  • Recompile in the Java editor, or
  • Add source code, such as System.out.println(...)
    into the code

5
Debugger Perspective
Execution Stack Frame
  • Debugger can
  • be used to inspect,
  • change, and step
  • through code
  • The source can
  • be changed,saved,
  • and resumed from
  • within the debugger

Variables Pane
Source
6
Stack Frames
  • The debugger displays lists of stack frames
    before exception or breakpoint occur
  • Stack frames
  • Correspond to a called method
  • Are in reverse chronological order -- Last one
    executed is first
  • Any stack frame can be selected and dropped to.
    The code is then
  • re-executed
  • Choose a frame and
  • select the Relaunch
  • option defined in the
  • pop-up
  • Variable values are
  • not reset when a
  • stack frame is
  • dropped

7
Stepping Through Code
  • Method source for the current stack frame can be
    executed line by line using the debuggers
    navigation buttons

Step Into
Step Return
Step Over
Terminate
Suspend
Resume
8
Stepping Through Code Commands
  • Resume - Continues execution until breakpoint or
    thread ends
  • Suspend - Interrupts a running thread
  • Terminate - Ends the execution of the selected
    thread
  • Step Into Steps into a method call and executes
    the first line of code in that method
  • Step Over - Executes the next line of code in the
    current method
  • Step Return - Continues execution until the end
    of the current method (until a return)
  • Step with Filters Continues execution until the
    next line of code which is not filtered out

1 2 3 4 5 6 7
9
Breakpoints
  • Setting a breakpoint in a method causes execution
    to be suspended when the method appears on the
    stack frame
  • Source can
  • then be
  • stepped
  • through
  • and objects
  • inspected
  • Breakpoints
  • remain set
  • until they
  • are explicitly
  • removed
  • from a
  • method

breakpoints
10
Breakpoint Properties
  • Right-click on a breakpoint to get to its
    properties sheet
  • Properties include
  • Enabled and disabled
  • Hit count
  • Doesnt break until n occurrences
  • Suspend Policy
  • Thread vs. VM
  • Enabling condition
  • Can break when a specified condition is true, or
    whenever the value of a specified expression
    changes
  • Restriction to certain threads

11
Exception Breakpoints
  • Exception can be enabled as breakpoints in the
    Breakpoint view
  • Execution will suspend wherever the exception is
    raised
  • Can specify caught, uncaught or both.

12
Evaluating Expressions
  • The Display and Expressions views can be used to
    examine the value of an expression.

13
The Variables View
  • The Variables view allows you to examine the
    contents of an object
  • A '' next to a variable name indicates that it
    is an object
  • An object can be opened up to reveal the values
    of its attributes

14
What You Have Learned
  • How to
  • Start the debugger
  • Add breakpoints to your code
  • Use the debugger to step through code and inspect
    objects
Write a Comment
User Comments (0)
About PowerShow.com