Exception Handling and Tolerance of Software Faults Prepared by: Saeid Pashazadeh Written By: Flaviu Cristian University of California,San Diego (session.

Slides:



Advertisements
Similar presentations
Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 1 Summer school on Formal Models.
Advertisements

Models of Concurrency Manna, Pnueli.
Statement-Level Control Structures
Control Structures Any mechanism that departs from straight-line execution: –Selection: if-statements –Multiway-selection: case statements –Unbounded iteration:
Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
3 Decision Making: Equality and Relational Operators A condition is an expression that can be either true or false. Conditions can be formed using the.
Lecture 16 Subroutine Calls and Parameter Passing Semantics Dragon: Sec. 7.5 Fischer: Sec Procedure declaration procedure p( a, b : integer, f :
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
CSE115/ENGR160 Discrete Mathematics 04/12/11 Ming-Hsuan Yang UC Merced 1.
Programming Language Semantics Denotational Semantics Chapter 5 Based on a lecture by Martin Abadi.
C SC 520 Principles of Programming Languages Principles of Programming Languages Lecture 08 Control Semantics & Continuations.
Remote Procedure Call in SR Programming Language By Tze-Kin Tsang 3/20/2000.
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
Exceptions (Large parts of these copied from Ed Schonberg’s slides)
Chapter 11 Exception Handling and Event Handling.
Slides prepared by Rose Williams, Binghamton University Chapter 13 Interfaces and Inner Classes.
1 Computer System Overview OS-1 Course AA
Describing Syntax and Semantics
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
CHAPTER 6 FILE PROCESSING. 2 Introduction  The most convenient way to process involving large data sets is to store them into a file for later processing.
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 5 Data Flow Testing
Induction and recursion
1 Exception and Event Handling (Based on:Concepts of Programming Languages, 8 th edition, by Robert W. Sebesta, 2007)
CONTROL FLOW IN C++ Satish Mishra PGT CS KV Trimulgherry.
Presented By Dr. Shazzad Hosain Asst. Prof., EECS, NSU
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
Comp 249 Programming Methodology Chapter 13 Interfaces & Inner Classes Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
© S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Recursive Algorithms &
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Mathematical Preliminaries
Sequencers SQO,SQC,SQL.
Flow of Control Joe McCarthy CSS 161: Fundamentals of Computing1.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.
1 Introduction to Turing Machines
SENG521 (Fall SENG 521 Software Reliability & Testing Fault Tolerant Software Systems: Techniques (Part 4a) Department of Electrical.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Functional Programming
Definition of the Programming Language CPRL
CSE202: Introduction to Formal Languages and Automata Theory
Chapter 4 (Part 3): Mathematical Reasoning, Induction & Recursion
Chapter 3 of Programming Languages by Ravi Sethi
Software Testing.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Denotational Semantics
Software Testing and Maintenance 1
Chapter 3 Loops Section 3.3 Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Introduction To Flowcharting
Mini Language Interpreter Programming Languages (CS 550)
Subprograms and Programmer Defined Data Type
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Statement-Level Control Structures
Application: Algorithms
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Exception and Event Handling
Conditional Loops Counted Loops
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Theory of Computation Lecture 23: Turing Machines III
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Presentation transcript:

Exception Handling and Tolerance of Software Faults Prepared by: Saeid Pashazadeh Written By: Flaviu Cristian University of California,San Diego (session 1)

 Programs are designed to produce certain intended, or standard, state transitions in computers and their peripheral devices.  Exists circumstances which might prevent a program from providing its specified service.  Since such circumstances are expected to occur rarely,programmers refer to them as exceptions.  Exceptions have to be handeled with care since the state of a program can be inconsistant when their occurrence is detected.

 Detection and handling of exceptions Occupies two third of code.  Because of rarely occurrence, is least documented,tested and understood part.  Most of design faults exist in exceptional handling codes.

Exception Mechanisms Resumption mechanism Resumption mechanism With a resumption mechanism, signalling an exception E leads to the temporary halt of the execution of C, the transfer of control to a handler associated with E and resumption of the execution of C with the command that follows the one that signalled E if the handler executes a resume command. With a termination mechanism, signalling the occurrence of an exception E while the body of a command C is executed leads to the (exceptional) termination of C. Thus, while with a termination mechanism, signalling an exception has a meaning similar to that of an exit command, with a resumption mechanism, it has a meaning similar to that of calling a procedure. Termination mechanism Termination mechanism

In Termination mechanism recovery is done before signaling exception. In Termination mechanism recovery is done before signaling exception. In resumption what we must do for recovery ? In resumption what we must do for recovery ? if the only advantage of a resumption mechanism over a termination mechanism is that it saves the work done before the exception is signalled, while with a termination mechanism, that work must be undone and repeated. if exception masking is possible, the only advantage of a resumption mechanism over a termination mechanism is that it saves the work done before the exception is signalled, while with a termination mechanism, that work must be undone and repeated. If, then termination is clearly advantageous, since resumption is not as inductive to recovering a consistent state for M before signalling an exception as is termination. If exception masking is not possible, then termination is clearly advantageous, since resumption is not as inductive to recovering a consistent state for M before signalling an exception as is termination.

Some authors belive: Some authors belive: 1. termination mechanism cover resumption mechanism. 2. Resumption is fault – prone 3. Ada and C++ uses termination mechanism

When a sequential program P is invoked in some initial storage state s, the goal is to make the computer storage reach a final state s', such that some intended relationship exists between s and s'. When a sequential program P is invoked in some initial storage state s, the goal is to make the computer storage reach a final state s', such that some intended relationship exists between s and s'. We denote by s an initial storage state, by s' a final state, and by S the set of all possible storage states. We denote by s an initial storage state, by s' a final state, and by S the set of all possible storage states. A storage state is a mapping from storage unit names to values storable in those units. A storage state is a mapping from storage unit names to values storable in those units. We use n instead of s(n), and n', instead of s'(n). We use n instead of s(n), and n', instead of s'(n). Basic Notations

A standard specification Gσ (G for goal, and σ for standard) of a sequential program P is a relation between initial and final storage states: A standard specification Gσ (G for goal, and σ for standard) of a sequential program P is a relation between initial and final storage states: A pair (s,s') Є S×S is in Gσ if an intended outcome of invoking P in the initial state s is to make P terminate normally in the final state s'. (Normal termination in a Pascal-like language means that control returns to the `next' command, separated by a semicolon from P.)

(The set Integer contains all integers i Є Z that are not smaller than a constant min Є Z and that are not greater than a constant max Є Z, min ≤0 ≤ max, where Z denotes the infinite set of mathematical integers.) (The set Integer contains all integers i Є Z that are not smaller than a constant min Є Z and that are not greater than a constant max Є Z, min ≤0 ≤ max, where Z denotes the infinite set of mathematical integers.) procedure F(in out n: Integer) n! ≡ if n = 0 then 1 else n × (n _ 1)!

For example, GFσ is partial. Indeed, GFσ does not define a final value for n when its initial value is negative. A specification Gσ is partial if its domain dom(Gσ) is a strict subset of the set S of all possible initial states.

A program is a syntactic object that is built according to a certain programming language grammar. procedure F(in out n: Integer); var k,m: Integer; begin k:=0; m:=1; while k < n do k:=k+1 ; m:=m * k od; n:=m end;

The standard semantics [P]σ of a program P is the actual function from input to output states that P computes when it terminates normally. The standard semantics [P]σ of a program P is the actual function from input to output states that P computes when it terminates normally. A pair of states (s,s') is in [P]σ if, when invoked in the initial state s Є S, the program P terminates normally in the final state s’Є S.

The set of all initial states s Є S for which a program P terminates normally in some final state s’ Є S which satisfies the standard specification Gσ is the standard domain SD of P (with respect to Gσ): For example, the standard domain of the program F with respect to the specification GFσ is the domain {0,1,...,7} of the relation [F]σ ∩ GFσ.

Exceptional Program Specification and Semantics If a program P is invoked in an initial state which is outside the standard domain SD, the standard service Gσ specified for P can not be provided by P. The set of all states which are not in the standard domain is the exceptional domain ED of that program: If a program P is invoked in an initial state which is outside the standard domain SD, the standard service Gσ specified for P can not be provided by P. The set of all states which are not in the standard domain is the exceptional domain ED of that program: ED ≡ S - SD. ED ≡ S - SD. For example, the exceptional domain of the factorial procedure F with respect to its standard specification GFσ is Integer-{0,...,7}, that is, {min,...,-1}U {8,...,max}. For example, the exceptional domain of the factorial procedure F with respect to its standard specification GFσ is Integer-{0,...,7}, that is, {min,...,-1}U {8,...,max}.

An invocation of a program in its exceptional domain is an exception occurrence. An invocation of a program in its exceptional domain is an exception occurrence. To handle exception occurrences, it is convenient to allow for occasional (exceptional) alterations of the sequential (standard) composition rule for operation invocations. To handle exception occurrences, it is convenient to allow for occasional (exceptional) alterations of the sequential (standard) composition rule for operation invocations. An exception mechanism is a language control structure which allows a programmer to express that the standard continuation of a program is to be replaced by an exceptional continuation when an exception is detected in that program. An exception mechanism is a language control structure which allows a programmer to express that the standard continuation of a program is to be replaced by an exceptional continuation when an exception is detected in that program.

Procedure P signals e. P[e:K] (A) [B:H] (B) O[d:H] Exceptional Exit Point “e” in P If B evaluates to true or O signals d, then H is invoked. If H terminates with a “signal e” sequencer, then the standard continuation of the (a) or (b) construct is abandoned.

procedure FE(in out n: Integer) signals negative; var k,m: Integer; begin [n<0: signal negative]; k:=0; m:=1; while k < n do k:=k+1 ; m:=m * k od; n:=m end;