Debugging - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Debugging

Description:

You can edit the data/value and see how the program responds. Call Stack ... Call Stack useful to show from where you've come. Locals window shows scoped variables ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 18
Provided by: jonapr
Category:
Tags: debugging | shows

less

Transcript and Presenter's Notes

Title: Debugging


1
Debugging
2
Motivation
  • To err is human to really foul things up
    requires a computer
  • While we are becoming master VB programmers,
    sometimes well err.
  • We want to recover as quickly as possible!

3
Types of Errors
  • Syntax
  • VB makes it easy to identify these!
  • Run-time
  • You get a Run-time error 28 message box
  • End or Debug
  • Logic
  • Hardest to find fix
  • Presumes we test (almost?) all paths/data

4
Break Mode
  • Not design mode
  • Not run mode
  • Hybrid of both
  • We can evaluate expressions
  • We can see results values of variables
  • We can change properties
  • We can change the code itself

5
Entering Break Mode
  • Breakpoints in code
  • Stop statements in code
  • Break button clicked
  • Run-time error generated DEBUG clicked
  • Debug.Assert statement evaluates to FALSE

6
Breakpoints
  • Marker in your code
  • Tells VB to halt enter Debug mode
  • Not persistent (not saved when you leave VBs
    IDE)
  • F9 toggles on/off

7
Stop Statement
  • Like Breakpoint, except its persistent (saved w/
    code)
  • When compiled (made into an EXE), Stop becomes
    End

8
Debug.Assert
  • Conditionally enters debug mode
  • Debug.Assert booleanExpression
  • Debug.Assert intDenominator ltgt 0
  • If conditional is NOT true, enter debug
  • When compiled, assertion expressions are ignored
  • Persistent saved w/ project

9
Debug Toolbar
  • Start/Continue, Break, End
  • Toggle Breakpoint (set current lines breakpoint)
  • Step into (trace into procedure call)
  • Step over (do procedure call, wait at next line)
  • Step out (finish procedure, wait at parents next
    line)
  • Windows
  • Local (scoped variables of procedure)
  • Immediate (evaluation)
  • Watch (selected expressions)
  • Quick Watch (show result of current expression)
  • Call Stack (display the activation stack)

10
Watch Expression
  • Useful to keep an eye on variables, properties,
    expressions
  • Limit scope as possible
  • Runtime will be faster!
  • Can break on TRUE or on CHANGE

11
Immediate Window
  • Useful for seeing immediate results (thus the
    name!)
  • Evaluate procedures
  • Test expressions
  • Display variable property values

12
Print
  • ? Print
  • Debug.Print expression
  • Print in immediate window
  • Displays info in the immediate window

13
Debug.Print
  • Displays information to the immediate window
  • Is persistent and saved with project
  • Is removed when compiled
  • But parameter remains, so whatever happened
    before WILL still happen, just no printing to
    immediate window
  • Execution of program isnt interupted

14
Locals Window
  • Displays identifier, value, and type of variables
  • Useful to make sure what you think should happen
    is happening!
  • You can edit the data/value and see how the
    program responds

15
Call Stack
  • Shows from whence youve come
  • Most recent at top
  • First invoked procedure at bottom
  • Double clicking on item jumps to invocation point

16
Summary
  • Debugging is an acquired skill
  • VB helps by providing useful tools
  • Immediate window shows information and evaluates
    expressions
  • Call Stack useful to show from where youve come
  • Locals window shows scoped variables
  • Watch expressions and assert can conditionally
    enter debug mode
  • Breakpoints are a good way to force entry into
    debug mode

17
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com