Using a Debugger. SWC What is ”debugging”? An error in a computer program is often called a ”bug”… …so, to ”debug” is to find and get rid of errors in.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

While loops.
Coding and Debugging. Requirements and Specification Recall the four steps of problem solving: Orient, Plan, Execute, Test Before you start the implementation.
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
Why care about debugging? How many of you have written a program that worked perfectly the first time? No one (including me!) writes a program that works.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
MT311 Tutorial Li Tak Sing( 李德成 ). Uploading your work You need to upload your work for tutorials and assignments at the following site:
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
Well-behaved objects Debugging. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Prevention vs Detection.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Finding and Debugging Errors
How to Debug VB .NET Code.
Guidelines for working with Microsoft Visual Studio.Net.
Visual Basic Debugging Tools Appendix D 6/27/20151Dr. Monther Aldwairi.
Guidelines for working with Microsoft Visual Studio 6.
CS 2511 Fall  Windows:  Start->Specialized Academic Software- >Programming Languages->NetBeans->NetBeans IDE x.y.z  where x.y.z is a version.
CIT 590 Debugging. Find a laptop Please take a moment to open up your laptop and open up Eclipse. If you do not have a laptop, please find a friend. If.
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Debugging applications, using properties Jim Warren – COMPSCI 280 S Enterprise Software Development.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation.
Playing Back Scripts In HP LoadRunner >>>>>>>>>>>>>>>>>>>>>>
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
VB – Debugging Tools Appendix D. Why do we need debugging? Every program has errors, and the process of finding these errors is debugging Types of errors.
Testing and Debugging Session 9 LBSC 790 / INFM 718B Building the Human-Computer Interface.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables.
The Software Development Process
Debuggers in Python. The Debugger Every programming IDE has a tool called a debugger. This application does NOT locate or fix your bugs for you! It slows.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Copyright © 2004 – 2013 Curt Hill Java Debugging In Eclipse.
Hints on debugging
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 4 Slide 1 Slide 1 What we'll cover here l Using the debugger: Starting the debugger Setting.
Georgia Institute of Technology Creating Classes part 2 Barb Ericson Georgia Institute of Technology June 2006.
NETBEANS DEBUGGER.  To create a breakpoint place the cursor at the desired location.  Go to the Run -> toogle line Breakpoint or Ctrl +F8. It creates.
Debug in Visual Studio Windows Development Fundamentals LESSON 2.5A.
5.01 Understand Different Types of Programming Errors
CSC 1201 LAB RULES Nouf Aljaffan (C) CSC 1201 Course at KSU.
Debugging What coders (programmers) do to find the errors (“bugs”) in their own programs “Bugs” – Admiral Grace Hopper, developer of the world’s first.
15 Copyright © 2004, Oracle. All rights reserved. Debugging Triggers.
AVCE ICT – Unit 7 - Programming Session 12 - Debugging.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
MOOR ERROR HANDLING Types of error How to test your code for errors How to detect errors How to recover from errors.
1 Using an Integrated Development Environment. Integrated Development Environments An Integrated Development Environment, or IDE, permits you to edit,
5.01 Understand Different Types of Programming Errors
CS1101X Programming Methodology
Debugging Dwight Deugo
Eclipse Navigation & Usage.
Testing and Debugging.
Computer Programming I
Debugging CMSC 202.
Testing Key Revision Points.
Important terms Black-box testing White-box testing Regression testing
Important terms Black-box testing White-box testing Regression testing
5.01 Understand Different Types of Programming Errors
Debugging with Eclipse
CIS 470 Mobile App Development
Test Automation For Web-Based Applications
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
Debugging Taken from notes by Dr. Neil Moore
Testing, debugging, and using support libraries
Debuggers and Debugging
Debugging Taken from notes by Dr. Neil Moore
CIS 470 Mobile App Development
Debugging Dwight Deugo
Debugging with Eclipse
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Using a Debugger

SWC What is ”debugging”? An error in a computer program is often called a ”bug”… …so, to ”debug” is to find and get rid of errors in a program Applies to logical errors, syntax errors are handled by the compiler Logical errors can be extremely hard to find…

SWC Strategies for debugging Write error-free programs! Ideal, but practically impossible  Write ”defensive” code. Do up-front checks for e.g. null references, illegal values, etc.. Read the code. Many errors can actually be caught just by reading the code Read the code (again). Many errors can actually be caught just by reading the code (really) Explain the code to others. Trying to verbalise the code can often reveal errors

SWC Strategies for debugging Create proper tests. Will help you detect errors and pinpoint their location (if the test is detailed enough…) Logging/printouts. This is often a beginners approach to debugging. Can work, but tedious Use a debugger. Only realistic approach in larger programs

SWC What is a ”debugger” A special program which can ”manage” execution of another program –Pause program execution at a specific point –Start the program from that point again –Let a user run the program one line at a time –Inspect the value of variables In modern integrated development environments – like NetBeans – the debugger is an integral part of the environment.

SWC Keep it simple… Modern debugges can do a lot of stuff – you only need to know a little bit to get started –Breakpoints –Variable inspection –Stepping over –Stepping into –Stepping out of

SWC Breakpoints A breakpoint is set at a line in a program The breakpoint makes the debugger pause execution of the program at this line This enables us to see the values of variables at this point in the program! We run a program in ”debug mode” by pressing Ctrl + F5

SWC Breakpoints in Netbeans Breakpoint (Ctrl + F8, or click in left margin)

Breakpoints in Netbeans SWC Breakpoint Program is paused here!

Breakpoints in Netbeans SWC See current value of a variable by hovering mouse cursor over it

Breakpoints in Netbeans SWC See current values of all variables, instance fields, parameters, etc. in the ”Variables” debug window

SWC The debugging toolbar This little toolbar actually contains all we need to know (and use) about the debugger at this point Various actions to take, now that the program is paused at a breakpoint

SWC Finish Debugger Session Finishes the debugging ”session” In other words – stop the program, we are done for now! Shortcut: Shift + F5

SWC Pause Pauses the program… …how is that different than pausing at a breakpoint?? Could e.g pause a long iteration Shortcut: None…

SWC Continue Continue execution of the program, until the next breakpoint is met If no more breakpoints, program simply runs to the end Shortcut: F5

SWC Step Over Move one line ahead, staying in the current method (what else?) Often referred to as ”single-stepping” Executes all method calls in the line of code Shortcut: F8

SWC Step Over Expression Almost like Step Over, but only executes one of the method calls in the line of code Invoke again to execute next method call Useful to analyse complex lines of code, without actually stepping into the called code Shortcut: Shift + F8

SWC Step Into If the line of code contains a method call, the debugger ”steps into” that code Useful for following the details of a method call Can not step into library methods… Shortcut: F7

SWC Step Out The debugger returns to the method which called the method we are currently inside Note that remaining lines of code in the called method are executed Shortcut: Ctrl + F7

SWC Run to Cursor Runs the program to the current position of the mouse cursor Like an ad-hoc breakpoint Useful for e.g breaking out of a loop, while staying inside a method Shortcut: F4

SWC Debugging in a nutshell Set breakpoints where needed Run program in debug mode (Ctrl + F5) Inspect variable values at breakpoints (mouse hovering, the ”Variables” debug window) Use the Step… facilities to continue execution from the breakpoint Rewrite the code as appropriate Repeat from the top…