Debugging Taken from notes by Dr. Neil Moore

Slides:



Advertisements
Similar presentations
Getting started with MPLAB Launch MPLAB Set Toolbar as in the next slide by clicking the leftmost icon Open a new Source file by choosing [FILE][NEW] Type.
Advertisements

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.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
How to Debug VB .NET Code.
Lecture 17: Animation Yoni Fridman 7/27/01 7/27/01.
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.
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.
DEBUGGING CHAPTER Topics  Getting Started with Debugging  Types of Bugs –Compile-Time Bugs –Bugs Attaching Scripts –Runtime Errors  Stepping.
Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation.
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.
Diagnostic Pathfinder for Instructors. Diagnostic Pathfinder Local File vs. Database Normal operations Expert operations Admin operations.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Eclipse debugger.
Debugging and Profiling With some help from Software Carpentry resources.
Mobile Programming Lecture 3 Debugging. Lecture 2 Review What widget would you use to allow the user to enter o a yes/no value o a range of values from.
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.
1First BlueJ Day, Houston, Texas, 1st March 2006 Debugging in BlueJ Davin McCall.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Debug in Visual Studio Windows Development Fundamentals LESSON 2.5A.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
AVCE ICT – Unit 7 - Programming Session 12 - Debugging.
Netbeans QuickStart. Creating a project File->New Project –For now you want General->Java Application –Then fill in the project details.
Debugging using By: Samuel Ashby. What is debugging?  A bug is an error in either a program or the hardware itself.  Debugging is first locating and.
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.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Learning to use a ‘For Loop’ and a ‘Variable’. Learning Objective To use a ‘For’ loop to build shapes within your program Use a variable to detect input.
The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP
DEBUG.
Error Analysis Logic Errors.
List Algorithms Taken from notes by Dr. Neil Moore & Dr. Debby Keen
Debugging with Eclipse
Appendix A Barb Ericson Georgia Institute of Technology May 2006
BIT116: Scripting Lecture 06
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Debugging Dwight Deugo
Eclipse Navigation & Usage.
Testing and Debugging.
Computer Programming I
Debugging CMSC 202.
LESSON 20.
Testing Key Revision Points.
Barb Ericson Georgia Institute of Technology Dec 2009
Debugging Techniques.
Using Visual Studio with C#
Important terms Black-box testing White-box testing Regression testing
Important terms Black-box testing White-box testing Regression testing
Debugging with Eclipse
List Algorithms Taken from notes by Dr. Neil Moore
Compile, Build, and Debug
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
Debugging CSCE 121 J. Michael Moore.
Tonga Institute of Higher Education
Structured Programming Taken from notes by Dr. Neil Moore
Using a Debugger 1-Jan-19.
Testing, debugging, and using support libraries
Debuggers and Debugging
Debugging Taken from notes by Dr. Neil Moore
Recursion Taken from notes by Dr. Neil Moore
Debugging Dwight Deugo
Where is my error?.
CMPE212 – Reminders Assignment 2 due today, 7pm.
Debugging with Eclipse
Workshop for Programming And Systems Management Teachers
Presentation transcript:

Debugging Taken from notes by Dr. Neil Moore CS 115 Lecture Debugging Taken from notes by Dr. Neil Moore

Debugging We’ve seen how to write test cases to help you find bugs in your program. What should you do when you find something is wrong? Find the line that’s wrong and fix it Which line is wrong? We know the symptoms, not the disease So our job is like that of a doctor Find out what’s making the patient sick!

Debugging Sometimes just reading and tracing the program is enough And once upon a time that was the only option But doctors can run tests, ask questions… If we could interact with the program while it’s running… we might be able to see the bug as it happens, we need “X-Ray vision”

The debugger The debugger is a tool for controlling and inspecting a program as it runs Part of most IDEs (WingIDE and IDLE for sure) It does not find the bugs for you Instead, it “Slows down” the program by letting you run it one line at a time (step through code) Shows you variables and their values as they change Shows what functions are currently running (“call stack”)

Breakpoints When using the debugger, you usually start by setting a breakpoint. This tells the debugger to pause the program just before it executes that line. In WingIDE, click next to the line number A red dot appears to show there is a breakpoint there. Click it again to turn it off Note: breakpoints are not saved with the program! In IDLE, right click the line of code and choose “Set breakpoint”. The line will be highlighted in yellow

Breakpoints To run with the debugger in WingIDE, click the “Debug” icon, the program will start running In IDLE select Debug → Debugger then run the program normally (using Run Module) The program will run full-speed until control reaches the breakpoint Then the program pauses, the IDE gives you control If you run the program without using “Debug”, breakpoints are ignored, the program runs normally. You may have to put in more than one breakpoint if you have branches or loops, to make sure execution actually reaches one of them

Single-stepping Single stepping means running the next line of the program. In most IDEs there are 3 ways to single-step. Step Over (“Over” in IDLE) Execute the current line, pausing again when it finishes If the line calls a function, the whole function’s code will be executed without being seen

Single-stepping Step Into (“Step” in IDLE) Step Out (“Out” in IDLE) Execute the current line, pausing at the start of the next line to be executed If the line calls a function, execution will pause at the start of that function’s definition Step Out (“Out” in IDLE) Executing the rest of this function, pausing after it returns Stepped into a function you didn’t want to see? Use this to get back to the calling code

Single-stepping More about the difference in the different modes when we cover functions These stepping functions only work when your program is paused by the debugger So only in debug mode And you must have a breakpoint set somewhere

Debugging variables The watch window shows you the variables that exist before executing the current line In WingIDE, called “Stack Data” In IDLE, called “Locals” Shows variables that are in scope Already defined in this function Not destroyed yet (at end of the function) Also shows their values and types Watch this window when single-stepping That will show you which variables are changing and how Make sure they change as you expect them to!