CSE 403 Lecture 18 Debugging.

Slides:



Advertisements
Similar presentations
Recursion CS 367 – Introduction to Data Structures.
Advertisements

Week 1 Part II Kyle Dewey. Overview Lab The art of programming Basic data types Variable declaration and initialization Data representation.
CSE 332: C++ exceptions Overview of C++ Exceptions Normal program control flow is halted –At the point where an exception is thrown The program call stack.
Programming Types of Testing.
Chapter 3.5 Debugging Games
B-1 Lecture 2: Problems, Algorithms, and Programs © 2000 UW CSE University of Washington Computer Programming I.
Introduction to a Programming Environment
BY: SACHIN SHRIVASTAVA Operating System By : Sachin Shrivastava 1.
Computer Programming I An Introduction to the art and science of programming with C++
Problem of the Day  Why are manhole covers round?
CSC 107 – Programming For Science. The Week’s Goal.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
CSE 351 GDB Introduction. Lab 1 Status? How is Lab 1 going? I’ll be available at the end of class to answer questions There are office hours later today.
CSC 212 – Data Structures Lecture 2: Primitives, References, & Classes.
Today’s Topics O-Notation Testing/Debugging Data Structures Next Class: Writing correct programs:Column 4.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
Bugs CS100 how to prevent them, how to find them and how to terminate them.
Revisiting building. Preprocessing + Compiling 2 Creates an object file for each code file (.c ->.o) Each.o file contains code of the functions and structs.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Chapter 0: Historical Overview.
1 Class #509 The Heisenberg Principal of Debugging A Method for Recording Execution and Program State in a Live Embedded System, for Later Playback and.
Lecture 3 – MapReduce: Implementation CSE 490h – Introduction to Distributed Computing, Spring 2009 Except as otherwise noted, the content of this presentation.
Recursion Version 1.0.
CMSC201 Computer Science I for Majors Lecture 20 – Recursion (Continued) Prof. Katherine Gibson Based on slides from UPenn’s CIS 110, and from previous.
Recursion what is it? how to build recursive algorithms
Games Programming in Scratch
Exceptions In this lecture:
CS 540 Database Management Systems
CSE 374 Programming Concepts & Tools
Computer Programming (BCT 1113)
Building Java Programs
Development and Testing Ch4.1. Algorithm Analysis
CSE 403 Software Engineering
Kernel Tracing David Ferry, Chris Gill
Creating and Modifying Text part 2
Error Handling Summary of the next few pages: Error Handling Cursors.
CSC 253 Lecture 8.
The C “switch” Statement
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
The C “switch” Statement
CSE341: Programming Languages Section 1
CSC 253 Lecture 8.
Chapter 11 Introduction to Programming in C
CSE341: Programming Languages Section 1
Building Java Programs
Algorithm Discovery and Design
The switch Statement Topics Multiple Selection switch Statement
Lesson 12.
Topic 1: Problem Solving
CSE 403 Lecture 17 Coding.
Michael Ernst CSE 140 University of Washington
Program Breakdown, Variables, Types, Control Flow, and Input/Output
Mid Term II Review.
Error Analysis Runtime Errors.
Homework Any Questions?.
Robust Coding and Debugging
Tonga Institute of Higher Education IT 141: Information Systems
An Introduction to Debugging
Loops.
Robust Coding and Debugging
Tonga Institute of Higher Education IT 141: Information Systems
Last Class We Covered Recursion Stacks Parts of a recursive function:
C Data Types and Variable
The Troubleshooting theory
Planning and Estimation
Review of Previous Lesson
Chapter 13 Recursion Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
IPC144 Introduction to Programming Using C Week 2 – Lesson 2
CHAPTER 6 Testing and Debugging.
Presentation transcript:

CSE 403 Lecture 18 Debugging

Efficiency and code tuning Final points Reductions in strength if (sqrt(x) < sqrt(y))… Memory management Even in Java / C# Preallocating/reusing large objects Buffer pool

Efficiency vs. Clarity Almost always favor clarity over efficiency The human reader is more important Compilers and processors have improved significantly in the last four decades

Debugging What are the key steps in debugging a program?

Kernigan and Pike's debugging wisdom Look for common patterns Common bugs have distinct signatures int n; scanf("%d", n); Examine most recent change Don't make the same mistake twice Debug it now, not later Numerology of failures Example – editor that dropped every 1024th char Get a stack trace Read before typing

K & P, II Explain your code to someone else Make the bug reproducible Divide and conquer Find simplest failing case Display output to localize your search Debugging with printf() Write self checking code Keep records

My favorite bugs (and stupidities) BI280 Business Basic Interpreter written in C for CP/M Sporadic failure of parsing Only happened when Basic program was changed (after being loaded) Parsing done by interpreter, each time a line was executed Adding printf's to code also changed behaviour

The Bug Uninitialized variable Variable used by the parser to hold a character that would be either a binary operator or end of line Parsing algorithm looked at last character and tested if it was a binary operator to continue parsing

Don't do this Can cover up very bad things try { doSomething(); } catch (Exception e){ Can cover up very bad things Violates K&P: Debug it now, not later

Apocryphal (but still a good story) A program which fails only in the month of September

Apocryphal (but still a good story) A program which fails only in the month of September char monthName[9]; strcpy(monthName, "September");

ConferenceXP Video conferencing system would run (after initial install) for about an hour and then fail System would not work at all at this point In a week it would start working again (for an hour) Repeated recovery every week

Solution Install process (erroneously) set event log to "overwrite events older than 7 days Application was very verbose in logging Failure when log was full