Basic Debugging (compilation)

Slides:



Advertisements
Similar presentations
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Advertisements

Problem Solving and Program Design Programming. COMP104 Lecture 3 / Slide 2 Problem Solving Process l Define and analyze the problem. l Develop a solution.
Problem Solving and Program Design. COMP104 Problem Solving / Slide 2 Our First Program // a simple program #include using namespace std; int main() {
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
If You Missed Last Week Go to Click on Syllabus, review lecture 01 notes, course schedule Contact your TA ( on website) Schedule.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
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.
General Programming Introduction to Computing Science and Programming I.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
1 JavaScript in Context. Server-Side Programming.
1 C++ Programming Basics Chapter 2 Lecture CSIS 10A.
Program Errors and Debugging Week 10, Thursday Lab.
Chapter 5 Repetition and Loop Statements Lecture Notes Prepared By: Blaise W. Liffick, PhD Department of Computer Science Millersville University Millersville,
Working with arrays (we will use an array of double as example)
Syntax and Semantics, and the Program Development Process ROBERT REAVES.
1 Program Planning and Design Important stages before actual program is written.
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.
Error messages 25-Apr-17.
User-Defined Functions II TK1914: C++ Programming.
CHAPTER 2 PART #3 C++ INPUT / OUTPUT 1 st Semester King Saud University College of Applied studies and Community Service CSC1101 By: Fatimah.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
The Debugging Process Syntax Errors CPS120 Introduction to Computer Science Lecture 4.
Debugging M-Files Steve Gu Feb 08, Outline What’s Debugging? Types of Errors Finding Errors Debugging Example Using Debugging Features.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Problem Solving and Program Design. Problem Solving Process Define and analyze the problem. Develop a solution. Write down the solution steps in detail.
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors Locate seg faults and bus errors Prepared by Dr. Spiegel.
Wrapper Classes Debugging Interlude 1
Basic concepts of C++ Presented by Prof. Satyajit De
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors
Introduction to Computing Science and Programming I
Programming what is C++
5.01 Understand Different Types of Programming Errors
ME 142 Engineering Computation I
CMPT 201.
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
Completing the Problem-Solving Process
Compilation and Debugging
Compilation and Debugging
Testing and Debugging.
Chapter 5 Conclusion CIS 61.
CSCI 161: Introduction to Programming
Chapter 2 part #3 C++ Input / Output
5.01 Understand Different Types of Programming Errors
Chapter 2 – Getting Started
Chapter 2 Elementary Programming
Chapter 15 Debugging.
Introduction to C++ Programming
Common C Programming Errors, GDB Debugging
Programming Funamental slides
Functions A function is a “pre-packaged” block of code written to perform a well-defined task Why? Code sharing and reusability Reduces errors Write and.
Debugging 9/22/15 & 9/23/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Debugging CSCE 121 J. Michael Moore.
Tonga Institute of Higher Education
Reference Parameters.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 15 Debugging.
Namespaces How Shall I Name Thee?.
An Introduction to Debugging
Chapter 2 part #3 C++ Input / Output
Introduction to Programming - 1
Chapter 1 c++ structure C++ Input / Output
CHAPTER 6 Testing and Debugging.
Debugging 101 Exterminating Vermin.
Presentation transcript:

Basic Debugging (compilation) Compiler errors occur when a program has incorrect syntax/construction messages may be cryptic, but… line numbers (where the error occurred) are provided Start on the line identified in the first error note: it may actually be before the listed line fix that error, then recompile sometimes errors cascade from an earlier error more than one error may disappear!

Functionality OK, program compiles and runs, but it’s wrong – now what? Insert diagnostic output statements using cout at locations where you suspect things are going wrong or other critical points in the code beginning and end of functions after complex calculations to display intermediate results, e.g. variables affected by each major algorithm step Remove extra output statements when problem is solved or use // to “comment them out”

Another Debugging/Testing technique Use a compiler directive or a variable to activate print statements Avoids have to comment out print statements – just set/unset the variable, but… It has runtime overhead: the if statement always gets executed… // this goes at the top of the file (set to 0 to turn it off) #define DEBUG 1 or, as a global const DEBUG=1; … // example: somewhere in the file a random function… void somefunction() { If(DEBUG) { cout << “entered somefunction()…” << endl; } … function statements … }

Common Programming Errors Omitting braces ( { }) Omitting a closing brace ( } ) Misuse of = for == Missing statement end “;”