Chapter 15 Debugging.

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

Chapter 15 Debugging. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Debugging with High Level Languages.
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.
FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
Lecture 2 Introduction to C Programming
Debugging Techniques1. 2 Introduction Bugs How to debug Using of debugger provided by the IDE Exception Handling Techniques.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts and Debugging.
If You Missed Last Week Go to Click on Syllabus, review lecture 01 notes, course schedule Contact your TA ( on website) Schedule.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts, Testing and Debugging.
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
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.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
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.
1 Debugging. 2 A Lot of Time is Spent Debugging Programs Debugging. Cyclic process of editing, compiling, and fixing errors. n Always a logical explanation.
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.
Testing Methods Carl Smith National Certificate Year 2 – Unit 4.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
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.
Chapter 2.11 Program Validation. Reliable System = Reliable Hardware AND Reliable Software AND Compatible Hardware and Software.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
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.
Introduction Chapter 1 1/22/16. Check zyBooks Completion Click on the boxes for each section.
Introduction to Computing Systems and Programming Programming.
1 CSE1301 Computer Programming: Lecture 16 Flow Diagrams and Debugging.
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP
Testing and Debugging UCT Department of Computer Science Computer Science 1015F Hussein Suleman March 2009.
Wrapper Classes Debugging Interlude 1
Programming in C in a UNIX environment
User-Written Functions
Introduction to programming
Testing and Debugging PPT By :Dr. R. Mall.
Chapter 9, Testing.
7 - Programming 7P, Q, R - Testing.
Chapter 2- Visual Basic Schneider
Testing and Debugging.
Testing UW CSE 160 Winter 2017.
Loop Structures.
2_Testing Testing techniques.
CS 240 – Lecture 11 Pseudocode.
Testing UW CSE 160 Spring 2018.
Chapter 6 The while Statement
Designing and Debugging Batch and Interactive COBOL Programs
Chapter 2 – Getting Started
Chapter 6 Programming.
Testing UW CSE 160 Winter 2016.
Debugging 9/22/15 & 9/23/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
Chapter 6 Programming.
Chapter 2- Visual Basic Schneider
Chapter 15 Debugging.
Chapter 6: Repetition Statements
Program Correctness and Efficiency
POWERPOINT PRESENTATION
An Introduction to Debugging
An Overview of C.
Perl Programming Dr Claire Lambert
Review of Previous Lesson
Chapter 15 Debugging.
WJEC GCSE Computer Science
CHAPTER 6 Testing and Debugging.
Chapter 6 Programming.
Chapter 15 Debugging.
Presentation transcript:

Chapter 15 Debugging

Debugging with High Level Languages Same goals as low-level debugging Examine and set values in memory Execute portions of program Stop execution when (and where) desired Want debugging tools to operate on high-level language constructs Examine and set variables, not memory locations Trace and set breakpoints on statements and function calls, not instructions ...but also want access to low-level tools when needed

Types of Errors Syntactic Errors Semantic Errors Algorithmic Errors Input code is not legal Caught by compiler (or other translation mechanism) Semantic Errors Legal code, but not what programmer intended Not caught by compiler, because syntax is correct Algorithmic Errors Problem with the logic of the program Program does what programmer intended, but it doesn't solve the right problem

Syntactic Errors Common errors: missing semicolon or brace mis-spelled type in declaration One mistake can cause an avalanche of errors because compiler can't recover and gets confused main () { int i int j; for (i = 0; i <= 10; i++) { j = i * 7; printf("%d x 7 = %d\n", i, j); } } missing semicolon

Semantic Errors Common Errors missing braces, so printf not part of if Missing braces to group statements together Confusing assignment with equality Wrong assumptions about operator precedence, associativity Wrong limits on for-loop counter Uninitialized variables main () { int i int j; for (i = 0; i <= 10; i++) j = i * 7; printf("%d x 7 = %d\n", i, j); } missing braces, so printf not part of if

Algorithmic Errors Design is wrong, so program does not solve the correct problem Difficult to find Program does what we intended Problem might not show up until many runs of program Maybe difficult to fix Have to redesign, may have large impact on program code Classic example: Y2K bug only allow 2 digits for year, assuming 19__

Testing “Program testing can be used to show the presence of bugs, but never show their absence” -- Edsger W. Dijkstra and you need to accept that an exhaustive testing is not possible… Black-Box Testing assumes nothing about the internals of the program replies upon input/output specification is sometimes automated White-Box Testing supplements black-box testing increases test coverage often uses an assertion

Debugging Techniques Ad-Hoc Source-Level Debugger Insert printf statements to track control flow and values Code explicitly checks for values out of expected range, etc. Advantage: No special debugging tools needed Disadvantages: Requires intimate knowledge of code and expected values Frequent re-compile and execute cycles Inserted code can be buggy Source-Level Debugger Examine and set variable values Tracing, breakpoints, single-stepping on source-code statements

Source-Level Debugger debug web page of cloud 9

Source-Level Debugging Techniques Breakpoints Stop when a particular statement is reached Stop at entry or exit of a function Conditional breakpoints: Stop if a variable is equal to a specific value, etc. Watchpoints: Stop when a variable is set to a specific value Single-Stepping Execute one statement at a time Step "into" or step "over" function calls Step into: next statement is first inside function call Step over: execute function without stopping Step out: finish executing current function and stop on exit

Source-Level Debugging Techniques Displaying Values Show value consistent with declared type of variable Dereference pointers (variables that hold addresses) See Chapter 17 Inspect parts of a data structure See Chapters 19 and 17

Programming for Correctness Accurate Specification Modular Design Defensive Programming Comment your code Adopt a consistent coding style Avoid (unsubstantiated) assumptions Avoid global variables Reply on the compiler (let the compiler generate as many warning messages as possible) …

꼭 기억해야 할 것 Type of errors Testing Source-level debugger Syntactic errors Semantic errors Algorithmic errors Testing Black-box testing White-box testing Source-level debugger Breakpoints Single-stepping Displaying values Programming for correctness Accurate specification Modular design Defensive programming