Debugging Mohammad Zikky, M.T. 2 Debugging Introduction (1 of 2)  Debugging is methodical process for removing mistakes in a program  So important,

Slides:



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

Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
IMGD 1001: Debugging. 2 Debugging Introduction (1 of 2)  Debugging is methodical process for removing mistakes in a program  So important, whole set.
Chapter 1 - An Introduction to Computers and Problem Solving
Announcements Wednesday's test will be postponed until Thursday – July 7 th, See me if this won’t work for you. Project 1 will be due Monday – July.
Interactive Media and Game Development Debugging.
Chapter 3.5 Debugging Games
Interactive Media and Game Development Debugging.
Debugging Techniques1. 2 Introduction Bugs How to debug Using of debugger provided by the IDE Exception Handling Techniques.
CSCE 590E Spring 2007 Game Programming By Jijun Tang.
IMGD 1001: Debugging by Mark Claypool Robert W. Lindeman
Interactive Media and Game Development Debugging.
Debugging CPSC 315 – Programming Studio Fall 2008.
Computer Science 1620 Programming & Problem Solving.
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.
Programming Fundamentals (750113) Ch1. Problem Solving
Testing and Playtesting
CSCI 101 Introduction to Software Development and Design.
Chapter Languages, Programming and Architecture.
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.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
CSE 486/586 CSE 486/586 Distributed Systems PA Best Practices Steve Ko Computer Sciences and Engineering University at Buffalo.
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Chapter 5: Control Structures II (Repetition)
CHAPTER 5: CONTROL STRUCTURES II INSTRUCTOR: MOHAMMAD MOJADDAM.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
Structured programming 4 Day 34 LING Computational Linguistics Harry Howard Tulane University.
Testing CSE 140 University of Washington 1. Testing Programming to analyze data is powerful It’s useless if the results are not correct Correctness is.
Debugging & Troubleshooting “To err is human, but it takes a computer to really foul things up” © 2004 Lawrence Snyder.
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.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
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.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Making Good Code AKA: So, You Wrote Some Code. Now What? Ray Haggerty July 23, 2015.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
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.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
University of Toronto Department of Computer Science © 2001, Steve Easterbrook CSC444 Lec11- 1 Lecture 11: Debugging & Defensive Programming Terminology.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
Debugging Threaded Applications By Andrew Binstock CMPS Parallel.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Objects First With Java A Practical Introduction Using BlueJ Well-behaved objects 2.1.
Testing CSE 160 University of Washington 1. Testing Programming to analyze data is powerful It’s useless (or worse!) if the results are not correct Correctness.
Test Plan: Introduction o Primary focus: developer testing –Implementation phase –Release testing –Maintenance and enhancement o Secondary focus: formal.
Software Quality Assurance and Testing Fazal Rehman Shamil.
Efficiently Solving Computer Programming Problems Doncho Minkov Telerik Corporation Technical Trainer.
Mobile Testing - Bug Report
14 Compilers, Interpreters and Debuggers
Debugging Intermittent Issues
Testing UW CSE 160 Winter 2017.
Debugging Intermittent Issues
Libraries and Debugging
LESSON 20.
CSS 161: Fundamentals of Computing
Testing UW CSE 160 Spring 2018.
Testing UW CSE 160 Winter 2016.
CSCE 315 – Programming Studio, Fall 2017 Tanzir Ahmed
Programming Fundamentals (750113) Ch1. Problem Solving
CSE 403 Lecture 17 Coding.
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
The lifespan of a variable
Debugging “Why you were up till 2AM”
An Introduction to Debugging
The Troubleshooting theory
Presentation transcript:

Debugging Mohammad Zikky, M.T

2 Debugging Introduction (1 of 2)  Debugging is methodical process for removing mistakes in a program  So important, whole set of tools to help. Called "debuggers"  Trace code, print values, profile  Integrated Development Environments (IDEs) (such as Flash and Game Maker) have one built in  A good debugger is really useful...

3 Debugging Introduction (2 of 2)  But debugging still frustrating  Beginners don't know how to proceed  Even advanced can get "stuck"  Don't know how long it takes to find  Variance can be high  But can treat them in aggregate for predictions  What are some tips?  What methods can be applied? IMGD 1001

4 Outline  Five-step debugging process  Prevention  Debugging tips IMGD 1001

5 Similar steps to Scientific Method  Evaluation  Conjecture/speculation  Deduction  Test  check, repeat  Let’s do one IMGD 1001

6 The Problem: Bubble Sort  We need a routine to sort a list  Algorithm:  Compare adjacent entries in the list  If they’re out of order, swap them  Move on to the next pair  Repeat until the list is sorted  Yes, this is vague  But you might be lucky to get this much description of an algorithm in your code! IMGD 1001

7 Work Through …  Consider array: 3512  Evaluate, then Conjecture/Deduction, then Fix, then Test IMGD 1001

8 The Five Step Debugging Process 1. Reproduce the problem consistently 2. Collect clues 3. Pinpoint the error 4. Repair the problem 5. Test the solution

9 Step 1: Reproduce the Problem Consistently Sample repro steps: 1. Start a single player game 2. Choose Skirmish/fighting on map Find the enemy camp 4. From a distance, use projectile weapons to attack the enemies at the camp 5. Result: 90 percent of the time the game crashes

10 Step 2: Collect Clues  Each clue a chance to rule out a cause  Projectile weapons, distance  Each clue a chance to narrow down the list of suspects  Collision detection system, vectors?  Realize that some clues can be misleading and should be ignored  Skirmish mode...

11 Step 3: Pinpoint the Error Two main methods: 1. Propose a Hypothesis  You have an idea what is causing the bug  Design tests to prove or disprove your hypothesis 2. Divide and Conquer  Narrow down what could be causing the bug  Eliminate possibilities from the top down or  Backtrack from the point of failure upward  Turn off parts, asserts, traces

12 Step 4: Repair the Problem  Propose solution  Consider implications at point in project  Programmer who wrote the code should ideally fix the problem (or at least be consulted)  Explore other ways the bug could occur  Ensure underlying problem fixed and not just a symptom of the problem

13 Step 5: Test the Solution  Verify the bug was fixed  Check original repro steps  Ideally have someone else independently verify the fix  Make sure no new bugs were introduced  At the very end of the project, have other programmers review the fix

14 Expert Debugging Tips  Question assumptions  Minimize interactions and interference  Minimize randomness  Break complex calculations into steps  Check boundary conditions  Disrupt parallel computations  Exploit tools in the debugger  Check code that has recently changed  Explain the bug to someone else  Debug with a partner  Take a break from the problem  Get outside help

15 Tough Debugging Scenarios  Bug exists in Release but not Debug  Uninitialized data or optimization issue  Bug exists on final hardware, not dev-kit  Find out how they differ – usually memory size or disc emulation  Bug disappears when changing something innocuous  Timing or memory overwrite problem  Intermittent problems  Record as much info when it does happen  Unexplainable behavior  Retry, Rebuild, Reboot, Reinstall  Internal compiler errors  Full rebuild, divide and conquer, try other machines  Suspect it’s not your code  Check for patches, updates, or reported bugs  Contact console maker, library maker, or compiler maker

16 Understanding the Underlying System  Knowing C or C++ not enough  Know how the compiler implements code  Know the details of your hardware  Especially important for console development  Know how assembly works and be able to read it  Helps with optimization bugs or compiler issues

17 Adding Infrastructure to Assist in Debugging  Alter game variables during gameplay  Visual AI diagnostics  Logging capability  Recording and playback capability  Track memory allocation  Print as much information as possible on a crash  Educate your entire team  testers, artists, designers, producers

18 Prevention of Bugs  Set compiler to highest warning level  Set compiler warnings to be errors  Compiler on multiple compilers  Write your own memory manager  Use asserts to verify assumptions  Initialize variables when they are declared  Bracket loops and if statements  Use cognitively different variable names  Avoid identical code in multiple places  Avoid magic (hardcoded) numbers  Verify code coverage when testing