Chapter 7 Debugging Techniques Xiaogang Su Department of Statistics University of Central Florida.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Chapter 15 Debugging. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Debugging with High Level Languages.
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.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Visual Basic Debugging Tools Appendix D 6/27/20151Dr. Monther Aldwairi.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Formula Auditing, Data Validation, and Complex Problem Solving
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
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.
Chapter 3 Planning Your Solution
Debugging Logic Errors CPS120 Introduction to Computer Science Lecture 6.
 Knowledge and use of tools and resources in a system: standard libraries, system calls, debuggers, the shell environment, system programs and scripting.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
Visual Basic Chapter 1 Mr. Wangler.
Introduction to Shell Script Programming
Debugging applications, using properties Jim Warren – COMPSCI 280 S Enterprise Software Development.
1 Chapter 9 Writing, Testing, and Debugging Access Applications.
Enhancing User Interaction Through Programming
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 7.1 Test-Driving the Wage Calculator Application.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
Using Client-Side Scripts to Enhance Web Applications 1.
Debugging. 2 © 2003, Espirity Inc. Module Road Map 1.Eclipse Debugging  Debug Perspective  Debug Session  Breakpoint  Debug Views  Breakpoint Types.
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
ME 142 Engineering Computation I Debugging Techniques.
VB – Debugging Tools Appendix D. Why do we need debugging? Every program has errors, and the process of finding these errors is debugging Types of errors.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Guide to Oracle 10g ITBIS373 Database Development Lecture 4a - Chapter 4: Using SQL Queries to Insert, Update, Delete, and View Data.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
Chapter Six Introduction to Shell Script Programming.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
How to Program? -- Part 1 Part 1: Problem Solving –Analyze a problem –Decide what steps need to be taken to solve it. –Take into consideration any special.
COP 3530 Spring 12 Discussion Session 1. Agenda 1.Introduction 2.Remote programming 3.Separate code 4.Compile -- g++,makefile 5.Debug -- gdb 6.Questions?
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
AVCE ICT – Unit 7 - Programming Session 12 - Debugging.
Chapter 7 What’s Wrong with It? (Syntax and Logic Errors) Clearly Visual Basic: Programming with Visual Basic nd Edition.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
ME 142 Engineering Computation I
How to debug an application
Introduction to Programming and Visual Basic
Debugging Dwight Deugo
Testing and Debugging.
Microsoft Access Illustrated
Important terms Black-box testing White-box testing Regression testing
DEBUGGING.
Important terms Black-box testing White-box testing Regression testing
Debuggers.
Chapter 2- Visual Basic Schneider
Debugging Visual Basic Programs
Debugging Dwight Deugo
Chapter 15 Debugging.
Debugging.
Chapter 15 Debugging.
Presentation transcript:

Chapter 7 Debugging Techniques Xiaogang Su Department of Statistics University of Central Florida

Section 7.1 Using the Debug Option (Self-Study) Objectives Use the DEBUG option in the DATA statement to help identify logic problems.

Scenario You have taken a new position in the company. Your predecessor wrote some code that was not working at the time he left. You need to identify what the program code is currently doing and where the problem is. ? ? ?

Scenario - Current Results Obs EMP_COUNTRY bonus type category 1 USA 2500 Overpaid 10 2 USA 2700 Overpaid 10 3 USA Overpaid 10 4 USA 4200 Overpaid 10 5 USA 3100 Overpaid 10 6 USA 2900 Overpaid 10 7 CANADA 8500 Overpaid 10 8 USA 3400 Overpaid 10 9 USA 2900 Overpaid USA 2700 Overpaid USA 3300 Overpaid USA 2200 Overpaid USA 1900 Overpaid 10

Scenario - Expected Results Obs EMP_COUNTRY bonus type category 1 USA 2500 Overpaid 10 2 USA 2700 Overpaid 10 3 USA Overpaid 10 4 USA 4200 Overpaid 10 5 USA 3100 Overpaid 10 6 USA 2900 Overpaid 10 7 CANADA 8500 Overpaid 10 8 USA 3400 Overpaid 10 9 USA 2900 Overpaid USA 2700 Overpaid USA 3300 Underpaid 1 12 USA 2200 Underpaid 1 13 USA 1900 Overpaid 10

Syntax Errors versus Logic Errors A syntax error occurs when program statements do not conform to the rules of the SAS language. An error message is produced by SAS and written to the log. A logic error occurs when the program statements follow the rules, but the results are not correct.

Logic Errors A non-programming example of a logic error: Recipe for Garlic Bread Spread butter on bread and sprinkle garlic powder on the bread. Place the bread on a baking sheet. Place the baking sheet under the broiler for 10 minutes. Remove and enjoy! Recipe for Garlic Bread Spread butter on bread and sprinkle garlic powder on the bread. Place the bread on a baking sheet. Place the baking sheet under the broiler for 10 minutes. Remove and enjoy! Notice that there is no step about turning on the broiler. The instructions work, but do not result in a desired finished product.

The DEBUG Option The DEBUG option is an interactive interface to the DATA step during DATA step execution. This option is useful to determine which piece of code is executing which piece of code is not executing what the current value of a particular variable is whether a “watch” must be placed on particular variables to inform you when the value changes.

The DEBUG Option General form of the DEBUG option: DATA data-set-name / DEBUG;

DEBUG Commands When the DEBUG option is running, these commands are very useful.

11 DEBUG Commands Controlling Program Execution: GO: Starts or resumes execution of the DATA step JUMP: Restarts execution of a suspended program STEP: Executes statements one at a time in the active program

12 DEBUG Commands Controlling the Windows HELP: Displays information about DEBUG commands SWAP: Switches control between the Source window and the Log window

13 DEBUG Commands Manipulating DATA Step Variables CALCULATE: Evaluates a debugger expression and displays the result DESCRIBE: Displays the attributes of one or more variables EXAMINE: Displays the value of one or more variables SET: Assigns a new value to a specified variable

14 DEBUG Commands Manipulating Debugging Requests BREAK: Suspends program execution at an executable statement DELETE: Deletes breakpoints or the watch status of variables in the DATA step LIST: Displays all occurrences of the item that is listed in the argument SET: Controls whether the debugger displays a continuous record of the DATA step execution WATCH: Suspends execution when the value of a specified variable changes

15 DEBUG Commands Tailoring the Debugger ENTER : Executes statements one at a time QUIT : Terminates a debugger session

What the DEBUG Option Cannot Do The DEBUG option can help to identify where a problem may be, but it is the programmer’s responsibility to solve the problem.

The FIRSTOBS= and OBS= Options The FIRSTOBS= and OBS= data set options are useful for testing because they can restrict the number of observations read in from a SAS data set. The number specified on the FIRSTOBS= option indicates the first observation number to read and the number specified on the OBS= option indicates the last observation number to read. SET data-set-name(FIRSTOBS=n OBS=n);

Determining Logic Errors This demonstration illustrates using the DEBUG option to identify which pieces of code are or are not executing display the data values of selected variables watch the data values of selected variables change. Program: Chap7.sas

Section 7.2 Using the PUT Statement (Self Study) Objectives Use the PUT statement in the DATA step to help identify logic problems.

Scenario You have taken a new position in the company. Your predecessor wrote some code that was not working at the time he left. You need to identify what the program code is currently doing and where the problem is. ? ? ?

The PUT Statement By default the PUT statement writes information to the log. This is useful to determine which piece of code is executing which piece of code is not executing what the current value of a particular variable is what the current values of all variables are.

The PUT Statement General forms of the PUT statement: PUT 'text'; PUT variable-name=; PUT _ALL_;

What the PUT Statement Cannot Do The PUT statement can help identify where a problem may be, but it is the programmer’s responsibility to solve the problem.

Determining Logic Errors This demonstration illustrates running code that does not produce the intended results and using the PUT statement to identify which pieces of code are or are not executing display the data values of all variables display the data values of selected variables.

A way to debug File: Chap7.sas