Chapter 15 Debugging.

Slides:



Advertisements
Similar presentations
Chapter 15 Debugging. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Debugging with High Level Languages.
Advertisements

Why care about debugging? How many of you have written a program that worked perfectly the first time? No one (including me!) writes a program that works.
Programming Types of Testing.
Lecture 2 Introduction to C Programming
Introduction to C Programming
Debugging Techniques1. 2 Introduction Bugs How to debug Using of debugger provided by the IDE Exception Handling Techniques.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts and Debugging.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
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.
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
Debugger Presented by 李明璋 2012/05/08. The Definition of Bug –Part of the code which would result in an error, fault or malfunctioning of the program.
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.
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.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
2_Testing Testing techniques. Testing Crucial stage in the software development process. Significant portion of your time on testing for each programming.
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. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
Debugging Xin Tong. GDB GNU Project debugger Allows you to see what is going on `inside' another program while it executes or crashed. (Faster than printing.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
CMSC 104, Version 8/061L14AssignmentOps.ppt Assignment Operators Topics Increment and Decrement Operators Assignment Operators Debugging Tips Reading Section.
Chapter 7 What’s Wrong with It? (Syntax and Logic Errors) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Introduction to Computing Systems and Programming Programming.
1 CSE1301 Computer Programming: Lecture 16 Flow Diagrams and Debugging.
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
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
Lab 4: Loops and Iteration Graham Northup
Wrapper Classes Debugging Interlude 1
Programming in C in a UNIX environment
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Introduction to programming
Testing and Debugging PPT By :Dr. R. Mall.
Chapter 2 - Introduction to C Programming
7 - Programming 7P, Q, R - Testing.
Chapter 2- Visual Basic Schneider
Testing and Debugging.
Software Design and Development
2_Testing Testing techniques.
CS 240 – Lecture 11 Pseudocode.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 15 Debugging.
Common C Programming Errors, GDB Debugging
Chapter 2 - Introduction to C Programming
Debugging 9/22/15 & 9/23/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Chapter 2- Visual Basic Schneider
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
Chapter 2- Visual Basic Schneider
Chapter 15 Debugging.
Chapter 2 - Introduction to C Programming
POWERPOINT PRESENTATION
Chapter 2 - Introduction to C Programming
design OO words Debug Variables Data types
An Overview of C.
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 h Missing braces to group statements together Confusing assignment with equality Wrong assumptions about operator precedence, associativity Wrong limits on for-loop counter Uninitialized variables h 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__

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 main window of Cygwin version of gdb

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