Debugging CPSC 315 – Programming Studio Fall 2008.

Slides:



Advertisements
Similar presentations
VCE SD Theory Slideshows By Mark Kelly Vceit.com Debugging Techniques.
Advertisements

xUnit Test Patterns (Some) xUnit Test Patterns (in practice) by Adam Czepil.
Version Control System (Sub)Version Control (SVN).
Debugging Mohammad Zikky, M.T. 2 Debugging Introduction (1 of 2)  Debugging is methodical process for removing mistakes in a program  So important,
Programming Types of Testing.
Developer Testing and Debugging. Resources Code Complete by Steve McConnell Code Complete by Steve McConnell Safari Books Online Safari Books Online Google.
Chapter 3.5 Debugging Games
Interactive Media and Game Development Debugging.
Software Quality Assurance Inspection by Ross Simmerman Software developers follow a method of software quality assurance and try to eliminate bugs prior.
Race Conditions. Isolated & Non-Isolated Processes Isolated: Do not share state with other processes –The output of process is unaffected by run of other.
Debugging Introduction to Computing Science and Programming I.
Interactive Media and Game Development Debugging.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
16/27/2015 3:38 AM6/27/2015 3:38 AM6/27/2015 3:38 AMTesting and Debugging Testing The process of verifying the software performs to the specifications.
Interactive Media and Game Development Debugging.
SM3121 Software Technology Mark Green School of Creative Media.
CODING Research Data Management. Research Data Management Coding When writing software or analytical code it is important that others and your future.
Debugging Logic Errors CPS120 Introduction to Computer Science Lecture 6.
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Introduction to High-Level Language Programming
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
CSE 486/586 CSE 486/586 Distributed Systems PA Best Practices Steve Ko Computer Sciences and Engineering University at Buffalo.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Tracking The Problem  By Aaron Jackson. What’s a Problem?  A suspicious or unwanted behavior in a program  Not all problems are errors as some perceived.
Structured programming 4 Day 34 LING Computational Linguistics Harry Howard Tulane University.
Testing, Bug Fixing and Debugging the Code Yordan Dimitrov Telerik Corporation
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
CS 1308 Computer Literacy and The Internet Software.
The First in GPON Verification Classic Mistakes Verification Leadership Seminar Racheli Ganot FlexLight Networks.
Debugging Chapter 23. Outline  Overview of Debugging  Finding a Defect  Fixing a Defect  Psychological Considerations in Debugging  Debugging Tools—Obvious.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
DEBUGGING. BUG A software bug is an error, flaw, failure, or fault in a computer program or system that causes it to produce an incorrect or unexpected.
Chapter 22 Developer testing Peter J. Lane. Testing can be difficult for developers to follow  Testing’s goal runs counter to the goals of the other.
Testing and Debugging Session 9 LBSC 790 / INFM 718B Building the Human-Computer Interface.
Debugging Strategies from Software Carpentry. Agan's Rules Many people make debugging harder than it needs to be by: Using inadequate tools Not going.
Systems Life Cycle. Know the elements of the system that are created Understand the need for thorough testing Be able to describe the different tests.
Debugging and Profiling With some help from Software Carpentry resources.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
Debugging of # P. Hristov 04/03/2013. Introduction Difficult problem – The behavior is “random” and depends on the “history” – The debugger doesn’t.
Fixing the Defect CEN4072 – Software Testing. From Defect to Failure How a defect becomes a failure: 1. The programmer creates a defect 2. The defect.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
Version Control and SVN ECE 297. Why Do We Need Version Control?
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
CompSci 100E 18.1 Testing and Debugging Robert A Wagner.
Outline Announcements: –HW I key online this afternoon –HW II due Friday –Sign up to discuss projects Debugging Testging for correctness.
Efficiently Solving Computer Programming Problems Doncho Minkov Telerik Corporation Technical Trainer.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
Troubleshooting. What is Troubleshooting ? Troubleshooting is a problem solving method. Other problem solving methods are invention, innovation, engineering.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
Error Analysis Logic Errors.
FOP: Multi-Screen Apps
Unit Testing.
14 Compilers, Interpreters and Debuggers
Testing and Debugging PPT By :Dr. R. Mall.
CSCE 315 – Programming Studio, Fall 2017 Tanzir Ahmed
CPSC 315 – Programming Studio
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
Debugging “Why you were up till 2AM”
Regression testing Tor Stållhane.
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
CS 240 – Advanced Programming Concepts
An Introduction to Debugging
For Tutors Introduce yourself.
Review of Previous Lesson
Presentation transcript:

Debugging CPSC 315 – Programming Studio Fall 2008

Bugs Term has been around a long time Edison Mark I – moth in machine Mistake made by programmers Also (and maybe better) called: Errors Defects Faults

Sources of Bugs Bad Design Wrong/incorrect solution to problem From system-level to statement-level Insufficient Isolation Changes in one area affect another Typos Entered wrong text, chose wrong variable Later changes/fixes that aren’t complete A change in one area affects another

Debugging in Software Engineering Programmer speed has high correlation to debugging speed Best debuggers can go up to 10 times faster Faster finding bugs Find more bugs Introduce fewer new bugs

Ways NOT to Debug Guess at what’s causing it Don’t try to understand what’s causing it Fix the symptom instead of the cause Special case code Blame it on someone else’s code Only after extensive testing/proof Blame it on the compiler/computer Yes, it happens, but almost never is this the real cause

An Approach to Debugging 1. Stabilize the error 2. Locate the source 3. Fix the defect 4. Test the fix 5. Look for similar errors Goal: Figure out why it occurs and fix it completely

1. Stabilize the Error Find a simple test case to reliably produce the error Narrow it to as simple a case as possible Some errors resist this Failure to initialize Pointer problems Timing issues

1. Stabilizing the Error Converge on the actual (limited) error Bad: “It crashes when I enter data” Better: “It crashes when I enter data in non-sorted order” Best: “It crashes when I enter something that needs to be first in sorted order” Create hypothesis for cause Then test hypothesis to see if it’s accurate

2. Locate the Source This is where good code design helps Again, hypothesize where things are going wrong in code itself Then, test to see if there are errors coming in there Simple test cases make it easier to check

When it’s Tough to Find Source Create multiple test cases that cause same error But, from different “directions” Refine existing test cases to simpler ones Try to find source that encompasses all errors Could be multiple ones, but less likely Brainstorm for sources, and keep list to check Talk to others Take a break

Finding Error Locations Process of elimination Identify cases that work/failed hypotheses Narrow the regions of code you need to check Use unit tests to verify smaller sections Process of expansion: Be suspicious of: areas that previously had errors code that changed recently Expand from suspicious areas of code

Alternative to Finding Specific Source Brute Force Debugging “Guaranteed” to find bug Examples: Rewrite code from scratch Automated test suite Full design/code review Fully output step-by-step status Don’t spend more time trying to do a “quick” debug than it would take to brute-force it.

3. Fix the Defect Make sure you understand the problem Don’t fix only the symptom Understand what’s happening in the program, not just the place the error occurred Understand interactions and dependencies Save the original code Be able to “back out” of change

Fixing the Code Change only code that you have a good reason to change Don’t just try things till they work Make one change at a time

4. Check Your Fix After making the change, check that it works on test cases that caused errors Then, make sure it still works on other cases Regression test Add the error case to the test suite

5. Look for Similar Errors There’s a good chance similar errors occurred in other parts of program Before moving on, think about rest of program Similar routines, functions, copied code Fix those areas immediately

Preventing Bugs Or Finding Difficult Ones Good Design Self-Checking code Output options Print statements can be your friend…

Debugging Tools Debuggers Often integrated Can examine state in great detail Don’t use debuggers to do “blind probing” Can be far less productive than thinking harder and adding output statements Use as “last resort” to identify sources, if you can’t understand another way

Non-traditional Debugging Tools Source code comparators (diff) Compiler warning messages Extended syntax/logic checkers Profilers Test frameworks