OBSERVING FACTS AND TRACKING ORIGINS CEN 4072 -PPT8.

Slides:



Advertisements
Similar presentations
Towards a Standard Interface for Runtime Inspection in AOP Environments OOPSLA Workshop on Tool for AOSD, Seattle, November 2002 Katharina Mehner and Awais.
Advertisements

10 Software Engineering Foundations of Computer Science ã Cengage Learning.
Chapter 3.5 Debugging Games
Tutorial 6 & 7 Symbol Table
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.
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
C How to Program, 6/e Summary © by Pearson Education, Inc. All Rights Reserved.
Fundamentals of Python: From First Programs Through Data Structures
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Introduction to Systems Analysis and Design Trisha Cummings.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
System Testing There are several steps in testing the system: –Function testing –Performance testing –Acceptance testing –Installation testing.
Fundamentals of Python: First Programs
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
1/20 Symbolic Execution and Program Testing Charngki PSWLAB Symbolic Execution and Program Testing James C.King IBM Thomas J.Watson Research Center.
Problem Determination Your mind is your most important tool!
General Programming Introduction to Computing Science and Programming I.
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Bug Localization with Machine Learning Techniques Wujie Zheng
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
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.
SE: CHAPTER 7 Writing The Program
What does a computer program look like: a general overview.
Problem of the Day  Why are manhole covers round?
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Testing and Debugging Session 9 LBSC 790 / INFM 718B Building the Human-Computer Interface.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Debugging and Profiling With some help from Software Carpentry resources.
1 Test Selection for Result Inspection via Mining Predicate Rules Wujie Zheng
Debugging parallel programs. Breakpoint debugging Probably the most widely familiar method of debugging programs is breakpoint debugging. In this method,
C Functions Three major differences between C and Java functions: –Functions are stand-alone entities, not part of objects they can be defined in a file.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
Fixing the Defect CEN4072 – Software Testing. From Defect to Failure How a defect becomes a failure: 1. The programmer creates a defect 2. The defect.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
1 CEN 4072 Software Testing PPT12: Fixing the defect.
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Objects First With Java A Practical Introduction Using BlueJ Well-behaved objects 2.1.
Chapter – 8 Software Tools.
CS223: Software Engineering Lecture 25: Software Testing.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Institute of Radio Physics and Electronics ILug-Cal Introduction to GDB Institute of Radio Physics and Electronics and Indian GNU/Linux Users Group Kolkata.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 4.
Course Contents KIIT UNIVERSITY Sr # Major and Detailed Coverage Area
14 Compilers, Interpreters and Debuggers
User-Written Functions
Regression Testing with its types
Testing Tutorial 7.
Testing and Debugging PPT By :Dr. R. Mall.
Scripts & Functions Scripts and functions are contained in .m-files
Computer Programming.
Programming Fundamentals (750113) Ch1. Problem Solving
PPT1: How failures come to be
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
JAsCo an Aspect-Oriented approach tailored for
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
Introduction to Data Structure
Review of Previous Lesson
PADLA: A Dynamic Log Level Adapter Using Online Phase Detection
Presentation transcript:

OBSERVING FACTS AND TRACKING ORIGINS CEN PPT8

OBSERVING FACTS Observation determines facts about what has happened in a concrete run, as opposed to deduction that only tells us what might happen. These techniques include: - Classical logging - Interactive Debuggers -Postmortem debugging -Visualization and Summarization techniques

PRINCIPLES OF OBSERVATION  Do not Interfere  Whatever that is observed should be an effect of the original run – rather than an effect of the observation. Any observation technique should alter the original run as little as it can.  Know what and when to observe  Remember: a Program run is a long succession of huge program states.  Observation is only effective if we know what part of the state to observe and at which moments during the execution to observe.  Proceed Systematically  Do not observe values at random, rather use a systematic way such as the scientific method.  Always be aware of the current hypothesis, the predictions, and how the actual observations contribute to the hypothessis.

LOGGING Logging refers to creating a log while a program is running in order to observe values and witness events as the program runs. “Printf debugging” can have a few drawbacks including cluttered code, cluttered output, slowdown of the program, and loss of data. To help fix these problems, it is better to use dedicated logging techniques including:  Use Standard Formats – Standard formats make it easy to search and filter logs  Make logging optional – turn logging off when not being debugged  Allow for variable granularity – it may be helpful to focus on specific events or levels of detail  Be persistent – Allow to re-enable or reuse logging features  Have specific macros - can be turned on or off- for focusing and for creating production code.

LOGGING FRAMEWORK: LOG4J LOG4J is a popular logging framework for JAVA programs, but is also available for C, C++, C#, PERL, python, RUBY, and Eiffel. The main idea of LOG4J is to assign each class in a given program an individual or common logger.  Each logger has a level from Debug (least importance) to info, warn, error, and fatal.  The messages are logged by invoking methods such as debug(), info(), warn(), error(), and fatal().

LOG4J EXAMPLE CODE Demonstration of invoking methods to create logging messages with different priorities.

LOGGING WITH ASPECTS Logging statements still clutter the source code, so many programmers remove the debugging and logging code once debugging is complete. Rather than combining actual computational code with logging code, as is the case above, some languages treat these two different types of code as separate entities called aspects. Each aspect holds only the code for its individual concern, for example, a logging aspect holds the logging code in one syntactical entity called an advice. In the ASPECTJ language we have to specify the location when an advice is executed. This is done using a point cut – a set of locations (join points) at which the previously cited advice is to be woven into the code.

EXAMPLE OF USING ASPECTS 1. Create an advice : { System.out.println(“Calling Article.buy()”); } Assume we have an Article class with a buy() method 2. Create a pointcut named ‘buyMethod()’: pointcut buyMethod (): call(public void Article.buy()); 3. Combine into an aspect named LogBuy: public aspect LogBuy{ pointcut buyMethod(): call(public void Article.buy()); before(): buyMethod() { System.out.println(:Calling Article.buy()”) } } //note: before() indicates that the advice is //called before the actual call. 4. “Weave” aspect into original code: Class Article { public void buy(){ System.out.println(“Entering Article.buy()”); original_buy(); System.out.println(Leaving Article.buy()”); } public void original_buy(){ //Original code of Article.buy() }

DEBUGGERS An alternative to logging techniques is to use an external observation tool that hooks into the execution of the program and observes the state at specific moments in time without changing the program code in any way. The most important observation tools are known as debuggers. Debuggers provide three functionalities to help you observe actual executions:  Execute the program and make it stop on specified conditions  Observe the state of the stopped program  Change the state of the stopped program. *An example would be the GNU debugger or GDB.*

DEBUGGING WITH GDB Invoked by compiling the program with the –g flag: Then we must load the program into the debugger: We predict that a[0]=0 should hold at line 38, so we create a breakpoint at line 38: Now we can run the program with the breakpoint set: We can then check the values of individual variables:

EMBEDDED DEBUGGERS Normally, a debugger invokes the program that is being debugged. A system can be set up to have it call a debugger on itself. An interpreted language such as PYTHON can have the interactive interpreter invoked, which allows you to explore all of the program’s state at will. Example:Executing this code obtains: *Be sure to remove from production code to avoid giving users control of your program.

COCA DEBUGGER Events and data are characterized by attributes, which can be used in queries to obtain all events or data where the query would be satisfied. A query consists of two parts: Data queries – A query current_data(attributes) denotes the subset of the execution data in which the given attributes hold i.e. – current_data(type-int) denotes all data whos type is int Time queries – A query fget(attributes) denotes the subset of the execution time in which the attributes hold. i.e. – fget(func=shell_sort) denotes all events in which the current function is shell_sort.

TOOLS FOR OBSERVATION AND DEBUGGING  LOG4J –  Has seen countless enhancements and incarnations since 1996  ASPECTJ –  Aspect oriented programming  GDB -  Mimics Sun’s DBX interactive debugger  DDD –  Front end to GDB and other debuggers  eDOBS –  Uses UML diagrams for visualization

OMNISCIENT DEBUGGING (ODB) We want to be able to support the programmer in examining the history of the state without having to restart the entire program.  Execute and record – We can record every single change to every single aspect of the state. This allows the programmer to move through the recording rather than the actual execution.  Step back-and-forth in time – Allowing the execution to be halted and actually stepped forward or backward based on the time stamp for each frame.  Issue event queries – Allow the programmer to jump to specific events rather than having to step back and forth through the entire program.

DYNAMIC SLICING A dynamic slice encompasses a part of the program that could have been influenced, or been influenced by, a specific variable at some point. This only applies to one single concrete run. Example: The dynamic slice in b applies to the run in which n and a are read in as 2 and 0, respectively, only.

DYNAMIC SLICE – STEPS TO COMPUTE First, we would require a trace, or a list of statements in the order they were executed during the concrete run. In this trace, we record the variables that were read and written as the program was executed. Also, we introduce a predicate pseudovariable for each predicate that controls execution. Each of these pseudovariables is written by the statement that controls execution and read by the statements that are controlled. Now we can compute dynamic slices: 1.For each write w to a variable, assign an empty dynamic slice. 2.Proceed forward through the trace. Whenever the value is written, consider all variables read in that statement. For each variable, consider the line where it was last written and the dynamic slice. Compute the union of these lines and slices and assign it to the write variable. 3.All definitions will be assigned a slice that holds all origins of all values.

DYNAMIC SLICE – EXAMPLE OF CALCULATION

Dynamic Slice: -A dynamic backward slice only applies to one concrete run. -More precise than static slice. -Typically encompasses 5% of program’s statements -More overhead -Cannot be reused Static Slice: -A static backward slice encompasses the entire program. -Typically encompasses 30% of program’s statements. -Can be reused. DYNAMIC VS. STATIC SLICE

WHYLINE DEBUGGER “Workspace that Helps You Link Instructions to Numbers and Events” A debugger where the programmer can ask “Why did my program fail?” Example is from a PACMAN program. 1.Big Dot.isEaten is set to true 2.Therefore, the isEaten variable is true 3.The negation not is false. 4.Although Pac is within 2m of Ghost is true. 5.The and conjuction evaluates to false. 6.Therefore, the else clause is taken.

TRACKING INFECTIONS The following is a general strategy that combines observation and dependences to narrow down arbitrary infection sites. 1.Start with the infected value as reported by the failure. 2.Follow back the dependences to potential origins. 3.Observe the origins and judge whether the individual origins are infected or not. 4.If you find an earlier infected value, repeat steps 2 and 3 to track its origins. 5.When you find an infected value V where all values that V depends on are sane you have found the defect. 6.Fix the defect and verify that the failure no longer occurs.

TOOLS  ODB  The ODB debugger is available publicly and was developed by Lewis in  Available at