• Keine Ergebnisse gefunden

Lecture 09 (07-12-2015)

N/A
N/A
Protected

Academic year: 2022

Aktie "Lecture 09 (07-12-2015)"

Copied!
28
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Systeme hoher Qualitรคt und Sicherheit Universitรคt Bremen WS 2015/2016

Christoph Lรผth Jan Peleska Dieter Hutter

Lecture 09 (07-12-2015)

Static Program Analysis

(2)

Where are we?

01: Concepts of Quality

02: Legal Requirements: Norms and Standards 03: The Software Development Process

04: Hazard Analysis

05: High-Level Design with SysML

06: Formal Modelling with SysML and OCL 07: Detailed Specification with SysML

08: Testing

09: Static Program Analysis

10 and 11: Software Verification (Hoare-Calculus) 12: Model-Checking

13: Concurrency 14: Conclusions

(3)

Today: Static Program Analysis

Analysis of run-time behavior of programs without executing them (sometimes called static testing) Analysis is done for all possible runs of a program (i.e. considering all possible inputs)

Typical tasks

๏‚ง Does the variable x have a constant value ?

๏‚ง Is the value of the variable x always positive ?

๏‚ง Can the pointer p be null at a given program point ?

๏‚ง What are the possible values of the variable y ?

These tasks can be used for verification (e.g. is there any possible dereferencing of the null pointer), or for

optimisation when compiling.

(4)

Program Analysis in the Development Cycle

(5)

Usage of Program Analysis

Optimising compilers

Detection of sub-expressions that are evaluated multiple times Detection of unused local variables

Pipeline optimisations

Program verification

Search for runtime errors in programs Null pointer dereference

Exceptions which are thrown and not caught

Over/underflow of integers, rounding errors with floating point numbers

Runtime estimation (worst-caste executing time, wcet) In other words, specific verification aspects.

(6)

Program Analysis: The Basic Problem

Basic Problem:

Given a property P and a program p, we say ๐‘ โŠจ ๐‘ƒ if a P holds for p. An algorithm (tool) ๐œ™ which decides P is a computable predicate ๐œ™: ๐‘ โ†’ ๐ต๐‘œ๐‘œ๐‘™. We say:

๏‚ง ๐œ™ is sound if whenever ๐œ™ ๐‘ then ๐‘ โŠจ ๐‘ƒ.

๏‚ง ๐œ™ is safe (or complete) if whenever ๐‘ โŠจ ๐‘ƒ then ๐œ™ ๐‘ .

From the basic problem it follows that there are no sound and safe tools for interesting properties.

๏‚ง In other words, all interesting tools must either under- or overapproximate.

All interesting program properties are undecidable.

(7)

Program Analysis: Approximation

Correct Errors

Overapproximation Underapproximation

Underapproximation only finds correct programs but may miss out some

๏‚ง Useful in optimising compilers

๏‚ง Optimisation must respect semantics of program, but may optimise.

Overapproximation finds all errors but may find non-errors (false positives)

๏‚ง Useful in verification.

๏‚ง Safety analysis must find all errors, but may report some more.

๏‚ง Too high rate of false positives may hinder acceptance of tool.

Not computable

Computable

All programs

(8)

Program Analysis Approach

Provides approximate answers

๏‚ง yes / no / donโ€™t know or

๏‚ง superset or subset of values

Uses an abstraction of programโ€™s behavior

๏‚ง Abstract data values (e.g. sign abstraction)

๏‚ง Summarization of information from

execution paths e.g. branches of the if-else statement

Worst-case assumptions about environmentโ€™s behavior

๏‚ง e.g. any value of a method parameter is possible

Sufficient precision with good performance

(9)

Flow Sensitivity

Flow-sensitive analysis

Considers program's flow of control

Uses control-flow graph as a representation of the source

Example: available expressions analysis

Flow-insensitive analysis

Program is seen as an unordered collection of statements

Results are valid for any order of statements e.g. S1 ; S2 vs. S2 ; S1

Example: type analysis (inference)

(10)

Context Sensitivity

Context-sensitive analysis

Stack of procedure invocations and return values of method parameters

Results of analysis of the method M depend on the caller of M

Context-insensitive analysis

Produces the same results for all possible invocations of M independent of possible callers and parameter values.

(11)

Intra- vs. Inter-procedural Analysis

Intra-procedural analysis

Single function is analyzed in isolation

Maximally pessimistic assumptions about parameter values and results of procedure calls

Inter-procedural analysis

Whole program is analyzed at once Procedure calls are considered

(12)

Data-Flow Analysis

Focus on questions related to values of variables and their lifetime Selected analyses:

Available expressions (forward analysis)

๏‚ง Which expressions have been computed already without change of the occurring variables (optimization) ?

Reaching definitions (forward analysis)

๏‚ง Which assignments contribute to a state in a program point?

(verification)

Very busy expressions (backward analysis)

๏‚ง Which expressions are executed in a block regardless which path the program takes (verification) ?

Live variables (backward analysis)

๏‚ง Is the value of a variable in a program point used in a later part of the program (optimization) ?

(13)

Our Simple Programming Language

In the last lecture, we introduced a very simple language with a C-like syntax.

Synposis:

Arithmetic operators given by

๐‘Ž โˆท= ๐‘ฅ ๐‘› ๐‘Ž1 ๐‘œ๐‘๐‘Ž ๐‘Ž2 Boolean operators given by

๐‘ โ‰” true false not ๐‘ ๐‘1๐‘œ๐‘๐‘ ๐‘2 ๐‘Ž1๐‘œ๐‘๐‘Ÿ ๐‘Ž2 ๐‘œ๐‘๐‘ โˆˆ ๐‘Ž๐‘›๐‘‘, ๐‘œ๐‘Ÿ , ๐‘œ๐‘๐‘Ÿ โˆˆ =, <, โ‰ค, >, โ‰ฅ, โ‰  Statements given by

๐‘† โˆท=

๐‘ฅ โ‰” ๐‘Ž ๐‘™ | ๐‘ ๐‘˜๐‘–๐‘ ๐‘™ ๐‘†1; ๐‘†2 | ๐‘–๐‘“ ๐‘ ๐‘™ ๐‘†1 ๐‘’๐‘™๐‘ ๐‘’ ๐‘†2 ๐‘คโ„Ž๐‘–๐‘™๐‘’ ๐‘ ๐‘™ {๐‘†}

(14)

Computing the Control Flow Graph

To calculate the cfg, we define some functions on the abstract syntax:

๏‚ง The initial label (entry point) init: ๐‘† โ†’ ๐ฟ๐‘Ž๐‘

๏‚ง The final labels (exit points) final: ๐‘† โ†’ โ„™ ๐ฟ๐‘Ž๐‘

๏‚ง The elementary blocks block: ๐‘† โ†’ โ„™ ๐ต๐‘™๐‘œ๐‘๐‘˜๐‘  where an elementary block is

โ–บ an assignment [x:= a],

โ–บ or [skip],

โ–บ or a test [b]

๏‚ง The control flow flow: ๐‘† โ†’ โ„™ ๐ฟ๐‘Ž๐‘ ร— ๐ฟ๐‘Ž๐‘ and reverse control flowR: ๐‘† โ†’ โ„™ ๐ฟ๐‘Ž๐‘ ร— ๐ฟ๐‘Ž๐‘ .

The control flow graph of a program S is given by

๏‚ง elementary blocks block ๐‘† as nodes, and

(15)

Labels, Blocks, Flows: Definitions

๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘ฅ โ‰” ๐‘Ž ๐‘™ = ๐‘™

๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘ ๐‘˜๐‘–๐‘ ๐‘™ = ๐‘™

๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘†1; ๐‘†2 = ๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘†2

๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘–๐‘“ ๐‘ ๐‘™ ๐‘†1 ๐‘’๐‘™๐‘ ๐‘’ {๐‘†2} = ๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘†1 โˆช ๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘†2 ๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘คโ„Ž๐‘–๐‘™๐‘’ ๐‘ ๐‘™ ๐‘† = {๐‘™}

๐‘–๐‘›๐‘–๐‘ก ๐‘ฅ โ‰” ๐‘Ž ๐‘™ = ๐‘™ ๐‘–๐‘›๐‘–๐‘ก ๐‘ ๐‘˜๐‘–๐‘ ๐‘™ = ๐‘™

๐‘–๐‘›๐‘–๐‘ก ๐‘†1; ๐‘†2 = ๐‘–๐‘›๐‘–๐‘ก ๐‘†1

๐‘–๐‘›๐‘–๐‘ก (๐‘–๐‘“ ๐‘ ๐‘™ ๐‘†1 ๐‘’๐‘™๐‘ ๐‘’ ๐‘†2 = ๐‘™ ๐‘–๐‘›๐‘–๐‘ก (๐‘คโ„Ž๐‘–๐‘™๐‘’ ๐‘ ๐‘™ ๐‘† = ๐‘™

๐‘“๐‘™๐‘œ๐‘ค ๐‘ฅ โ‰” ๐‘Ž ๐‘™ = โˆ… ๐‘“๐‘™๐‘œ๐‘ค ๐‘ ๐‘˜๐‘–๐‘ ๐‘™ = โˆ…

๐‘“๐‘™๐‘œ๐‘ค ๐‘†1; ๐‘†2 = ๐‘“๐‘™๐‘œ๐‘ค ๐‘†1 โˆช ๐‘“๐‘™๐‘œ๐‘ค ๐‘†2 โˆช ๐‘™, ๐‘–๐‘›๐‘–๐‘ก ๐‘†2 ) ๐‘™ โˆˆ ๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘†1

๐‘“๐‘™๐‘œ๐‘ค ๐‘–๐‘“ ๐‘ ๐‘™ ๐‘†1 ๐‘’๐‘™๐‘ ๐‘’ {๐‘†2 } = ๐‘“๐‘™๐‘œ๐‘ค ๐‘†1 โˆช ๐‘“๐‘™๐‘œ๐‘ค ๐‘†2 โˆช {(๐‘™, ๐‘–๐‘›๐‘–๐‘ก ๐‘†1 ), ๐‘™, ๐‘–๐‘›๐‘–๐‘ก ๐‘†2 ) ๐‘“๐‘™๐‘œ๐‘ค (๐‘คโ„Ž๐‘–๐‘™๐‘’ ๐‘ ๐‘™ ๐‘† = ๐‘“๐‘™๐‘œ๐‘ค ๐‘† โˆช ๐‘™, ๐‘–๐‘›๐‘–๐‘ก ๐‘† โˆช { ๐‘™โ€ฒ, ๐‘™ |๐‘™โ€ฒ โˆˆ ๐‘“๐‘–๐‘›๐‘Ž๐‘™ ๐‘† }

๐‘“๐‘™๐‘œ๐‘ค๐‘… ๐‘† = ๐‘™โ€ฒ, ๐‘™ ๐‘™, ๐‘™โ€ฒ โˆˆ ๐‘“๐‘™๐‘œ๐‘ค(๐‘†)}

๐‘๐‘™๐‘œ๐‘๐‘˜๐‘  ๐‘ฅ โ‰” ๐‘Ž ๐‘™ = ๐‘ฅ โ‰” ๐‘Ž ๐‘™ ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘  ๐‘ ๐‘˜๐‘–๐‘ ๐‘™ = ๐‘ ๐‘˜๐‘–๐‘ ๐‘™

๐‘๐‘™๐‘œ๐‘๐‘˜๐‘  ๐‘†1; ๐‘†2 = ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘  ๐‘†1 โˆช ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘  ๐‘†2 ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘  ๐‘–๐‘“ ๐‘ ๐‘™ ๐‘†1 ๐‘’๐‘™๐‘ ๐‘’ ๐‘†2

= ๐‘ ๐‘™ โˆช ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘  ๐‘†1 โˆช ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘  ๐‘†2 ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘  ๐‘คโ„Ž๐‘–๐‘™๐‘’ ๐‘ ๐‘™ ๐‘† = ๐‘ ๐‘™ โˆช ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘ (๐‘†)

๐‘™๐‘Ž๐‘๐‘’๐‘™๐‘  ๐‘† = ๐‘™ ๐ต ๐‘™ โˆˆ ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘ (๐‘†)}

๐น๐‘‰ ๐‘Ž = free variables in ๐‘Ž

๐ด๐‘’๐‘ฅ๐‘ ๐‘† = non-trival subexpressions

in ๐‘† (variables and constants are trivial)

(16)

An Example Program

init(P) = 1 final(P) = {3}

blocks(P) =

{ [x := a+b]1, [y := a*b]2, [y > a+b]3, [a:=a+1]4, [x:= a+b]5} flow(P) = {(1, 2), (2, 3), (3, 4), (4, 5), (5, 3)}

flowR(P) = {(2, 1), (3, 2), (4, 3), (5, 4), (3, 5)}

labels(P) = {1, 2, 3, 4, 5)

FV(a + b) = {a, b}

FV(P) = {a, b, x, y}

Aexp(P) = {a+b, a*b, a+1}

x := a +b

y > a + b

a := a + 1

x := a + b

1

5 4 3

y := a * b 2 P = [x := a+b]1; [y := a*b]2; while [y > a+b]3 { [a:=a+1]4; [x:= a+b]5 }

(17)

Available Expression Analysis

x := a +b

y > a + b

a := a + 1

x := a + b

1

5 4 3

y := a * b 2 S :

For each program point, which

expressions must have already been computed, and not modified, on all paths to this program point.

The available expression analysis will determine:

(18)

Available Expression Analysis

kill( [x :=a]l ) = ๐‘Žโ€ฒ โˆˆ ๐ด๐‘’๐‘ฅ๐‘ ๐‘† ๐‘ฅ โˆˆ ๐น๐‘‰ โ€ฒ๐‘Ž } kill( [skip]l ) = โˆ…

kill( [b]l ) = โˆ…

gen( [x :=a]l ) = ๐‘Žโ€ฒ โˆˆ ๐ด๐‘’๐‘ฅ๐‘ ๐‘Ž ๐‘ฅ โˆ‰ ๐น๐‘‰ โ€ฒ๐‘Ž } gen( [skip]l ) = โˆ…

gen( [b]l ) = ๐ด๐‘’๐‘ฅ๐‘(๐‘)

AEin( l ) = โˆ…, if l โˆˆ init(S) ๐ด๐ธ๐‘œ๐‘ข๐‘ก ๐‘™โ€ฒ ๐‘™โ€ฒ, ๐‘™ โˆˆ ๐‘“๐‘™๐‘œ๐‘ค(๐‘†) , otherwise

AEout ( l ) = ๐ด๐ธ๐‘–๐‘› ๐‘™ \ ๐‘˜๐‘–๐‘™๐‘™ ๐ต๐‘™ โˆช ๐‘”๐‘’๐‘› ๐ต๐‘™ , where ๐ต๐‘™ โˆˆ ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘ (๐‘†)

x := a +b

y > a + b

a := a + 1

x := a + b

1

5 4 3

y := a * b 2 S :

l kill(l) gen(l)

1 โˆ… {a+b}

2 โˆ… {a*b}

3 โˆ… {a+b}

4 {a+b, a*b, a+1} โˆ…

5 โˆ… {a+b}

l AEin AEout

1 โˆ… {a+b}

2 {a+b} {a+b, a*b}

3 {a+b} {a+b}

4 {a+b} โˆ…

5 โˆ… {a+b}

(19)

Reaching Definitions Analysis

Reaching definitions (assignment) analysis determines if:

An assignment of the form [x := a]l may reach a certain program point k if there is an execution of the

program where x was last assigned a value at l when the program point k is reached

x := 5

x > 1

y := x * y

x := x - 1

1

5 4 3

y := 1 2 S :

(20)

Reaching Definitions Analysis

kill( [skip]l ) = โˆ… kill( [b]l ) = โˆ…

kill( [x :=a]l ) = ๐‘ฅ, ? โˆช ๐‘ฅ, ๐‘˜ ๐ต๐‘˜ ๐‘–๐‘  ๐‘Ž๐‘› ๐‘Ž๐‘ ๐‘ ๐‘–๐‘”๐‘š๐‘’๐‘›๐‘ก ๐‘–๐‘› ๐‘†}

gen( [x :=a]l ) = { ๐‘ฅ, ๐‘™ } gen( [skip]l ) = โˆ…

gen( [b]l ) = โˆ…

RDin( l ) = { ๐‘ฅ, ? |๐‘ฅ โˆˆ ๐น๐‘‰ ๐‘  if l โˆˆ init(S) ๐‘…๐ท๐‘œ๐‘ข๐‘ก ๐‘™โ€ฒ ๐‘™โ€ฒ, ๐‘™ โˆˆ ๐‘“๐‘™๐‘œ๐‘ค ๐‘† otherwise

RDout ( l ) = ๐‘…๐ท๐‘–๐‘› ๐‘™ \ ๐‘˜๐‘–๐‘™๐‘™ ๐ต๐‘™ โˆช ๐‘”๐‘’๐‘› ๐ต๐‘™ where ๐ต๐‘™ โˆˆ ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘ (๐‘†)

x := 5

x > 1

y := x * y

x := x - 1

1

5 4 3

y := 1 2

l kill(Bl) gen(Bl)

1 {(x,?), (x,1),(x,5)} {(x, 1)}

2 {(y,?), (y,2),(y,4)} {(y, 2)}

3 โˆ… โˆ…

4 {(y,?), (y,2),(y,4)} {(y, 4)}

5 {(x,?), (x,1),(x,5)} {(x, 5)}

S :

l RDin RDout

1 {(x,?), (y,?)} {(x,1), (y,?)}

2 {(x,1), (y,?)} {(x,1), (y,2)}

3 {(x,1), (x,5), (y,2), (y,4)} {(x,1), (x,5), (y,2), (y,4)}

4 {(x,1), (x,5), (y,2), (y,4)} {(x,1), (x,5),(y,4)}

5 {(x,1), (x,5),(y,4)} {(x,5),(y,4)}

(21)

Live Variables Analysis

A variable x is live at some program point (label l) if there exists if there

exists a path from l to an exit point that does not change the variable.

Live Variables Analysis determines:

Application: dead code elemination.

x := 2

x := 1

y > x

z := y

yes no

1

5

4 3

y := 4 2 S :

z := y*y 6

x := z

7

For each program point, which variables may be live at the exit from that point.

(22)

Live Variables Analysis

kill( [x :=a]l ) = {๐‘ฅ}

kill( [skip]l ) = โˆ… kill( [b]l ) = โˆ… gen( [x :=a]l ) = ๐น๐‘‰(๐‘Ž)

gen( [skip]l ) = โˆ… gen( [b]l ) = ๐น๐‘‰(๐‘)

LVout( l ) = โˆ… if l โˆˆ final(S) ๐ฟ๐‘‰๐‘–๐‘› ๐‘™โ€ฒ ๐‘™โ€ฒ, ๐‘™ โˆˆ ๐‘“๐‘™๐‘œ๐‘ค๐‘… ๐‘† otherwise

LVin ( l ) = ๐ฟ๐‘‰๐‘œ๐‘ข๐‘ก ๐‘™ \ ๐‘˜๐‘–๐‘™๐‘™ ๐ต๐‘™ โˆช ๐‘”๐‘’๐‘› ๐ต๐‘™ where ๐ต๐‘™ โˆˆ ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘ (๐‘†)

x := 2

x := 1

y > x

z := y

yes no

1

5

4 3

y := 4 2

l kill(l) gen(l)

1 {x} โˆ…

2 {y} โˆ…

3 {x} โˆ…

4 โˆ… {x, y}

5 {z} {y}

6 {z} {y}

7 {x} {z}

l LVin LVout

1 โˆ… โˆ…

2 โˆ… {y}

3 {y} {x, y}

4 {x, y} {y}

5 {y} {z}

6 {y} {z}

7 {z} โˆ…

S :

z := y*y 6

x := z

7

(23)

First Generalized Schema

Analysis๏‚ฐ ( l ) = ๐„๐• if ๐‘™ โˆˆ ๐„

โ–ก Analysis๏‚ท ( lโ€˜ ) ๐‘™โ€ฒ, ๐‘™ โˆˆ ๐…๐ฅ๐จ๐ฐ ๐‘† } otherwise Analysis๏‚ท ( l ) = ๐‘“l ( Analysis๏‚ฐ ( l ) )

With:

โ–ก is either ๏• or ๏‰

๐„๐• is the initial / final analysis information ๐…๐ฅ๐จ๐ฐ is either flow or flowR

๐„ is either {init(S)} or final(S)

๐‘“๐‘™ is the transfer function associated with ๐ต๐‘™ โˆˆ ๐‘๐‘™๐‘œ๐‘๐‘˜๐‘ (๐‘†) Backward analysis: ๐…๐ฅ๐จ๐ฐ = flowR, ๏‚ท = IN, ๏‚ฐ = OUT

Forward analysis: ๐…๐ฅ๐จ๐ฐ = flow, ๏‚ท = OUT, ๏‚ฐ = IN

(24)

Partial Order

๐ฟ = ๐‘€, โŠ‘ is a partial order iff

๏‚ง Reflexivity: โˆ€๐‘ฅ โˆˆ ๐‘€. ๐‘ฅ โŠ‘ ๐‘ฅ

๏‚ง Transitivity: โˆ€๐‘ฅ, ๐‘ฆ, ๐‘ง โˆˆ ๐‘€. ๐‘ฅ โŠ‘ ๐‘ฆ โˆง ๐‘ฆ โŠ‘ ๐‘ง โ‡’ ๐‘ฅ โŠ‘ ๐‘ง

๏‚ง Anti-symmetry: โˆ€๐‘ฅ, ๐‘ฆ โˆˆ ๐‘€. ๐‘ฅ โŠ‘ ๐‘ฆ โˆง ๐‘ฆ โŠ‘ ๐‘ฅ โ‡’ ๐‘ฅ = ๐‘ฆ

Let ๐ฟ = ๐‘€, โŠ‘ be a partial order, ๐‘† โŠ† ๐‘€

๏‚ง ๐‘ฆ โˆˆ ๐‘€ is upper bound for ๐‘† ๐‘† โŠ‘ ๐‘ฆ iff โˆ€๐‘ฅ โˆˆ ๐‘†. ๐‘ฅ โŠ‘ ๐‘ฆ

๏‚ง ๐‘ฆ โˆˆ ๐‘€ is lower bound for S (๐‘ฆ โŠ‘ ๐‘†) iff โˆ€๐‘ฅ โˆˆ ๐‘†. ๐‘ฆ โŠ‘ ๐‘ฅ

๏‚ง Least upper bound โจ†๐‘‹ โˆˆ ๐‘€ of ๐‘‹ โŠ† ๐‘€:

โ–บ ๐‘‹ โŠ‘ โจ†๐‘‹ โˆง โˆ€๐‘ฆ โˆˆ ๐‘€. ๐‘‹ โŠ‘ ๐‘ฆ โ‡’ โจ†๐‘‹ โŠ‘ ๐‘ฆ

๏‚ง Greatest lower bound โŠ“ ๐‘‹ of ๐‘‹ โŠ† ๐‘€:

โ–บ โŠ“ ๐‘‹ โŠ‘ ๐‘‹ โˆง โˆ€๐‘ฆ โˆˆ ๐‘€. ๐‘ฆ โŠ‘ ๐‘‹ โ‡’ ๐‘ฆ โŠ‘ โŠ“ ๐‘‹

(25)

Lattice

A lattice (โ€œVerbundโ€) is a partial order L = (M, โŠ‘) such that

โŠ”X and โŠ“X exist for all X โŠ† M

Unique greatest element โŠค = โŠ”M = โŠ“โˆ…

Unique least element โŠฅ = โŠ“M = โŠ”โˆ…

(26)

Transfer Functions

Transfer functions to propagate information along the execution path (i.e. from input to output, or vice versa)

Let ๐ฟ = ๐‘€, โŠ‘ be a lattice. Let ๐น be the set of transfer functions of the form

fl : L ๏‚ฎ L with l being a label

Knowledge transfer is monotone

๏‚ง โˆ€ ๐‘ฅ, ๐‘ฆ. ๐‘ฅ โŠ‘ ๐‘ฆ โŸน ๐‘“๐‘™ ๐‘ฅ โŠ‘ ๐‘“๐‘™ ๐‘ฆ

Space ๐น of transfer functions

๏‚ง ๐น contains all transfer functions fl

๏‚ง ๐น contains the identity function id: โˆ€๐‘ฅ โˆˆ ๐‘€. ๐‘–๐‘‘ ๐‘ฅ = ๐‘ฅ

๏‚ง ๐น is closed under composition: โˆ€ ๐‘“, ๐‘” โˆˆ ๐น. ๐‘” โˆ˜ ๐‘“ โˆˆ ๐น

(27)

The Generalized Analysis

Analysis๏‚ฐ ( l ) = โŠ” Analysis๏‚ท ( lโ€˜ ) | (lโ€ฒ, l) โˆˆ ๐น๐‘™๐‘œ๐‘ค ๐‘† โŠ” { ๐œ„๐ธโ€ฒ }

with ๐œ„๐ธโ€ฒ = ๐ธ๐‘‰ if ๐‘™ โˆˆ ๐ธ

โŠฅ otherwise Analysis๏‚ท ( l ) = ๐‘“๐‘™( Analysis๏‚ฐ ( l ) )

With:

L property space representing data flow information with ๐ฟ, โŠ‘ a lattice

๐น๐‘™๐‘œ๐‘ค is a finite flow (i.e. ๐‘“๐‘™๐‘œ๐‘ค or ๐‘“๐‘™๐‘œ๐‘ค๐‘… )

๐ธ๐‘‰ is an extremal value for the extremal labels ๐ธ (i.e. ๐‘–๐‘›๐‘–๐‘ก ๐‘† or ๐‘“๐‘–๐‘›๐‘Ž๐‘™(๐‘†)

transfer functions ๐‘“๐‘™ of a space of transfer functions ๐น

(28)

Summary

Static Program Analysis is the analysis of run-time behavior of programs without executing them

(sometimes called static testing).

Approximations of program behaviours by analyzing the programโ€˜s cfg.

Analysis include

๏‚ง available expressions analysis,

๏‚ง reaching definitions,

๏‚ง live variables analysis.

These are instances of a more general framework.

These techniques are used commercially, e.g.

๏‚ง AbsInt aiT (WCET)

Referenzen

ร„HNLICHE DOKUMENTE

The basic problem of static program analysis: virtually all interesting program properties are

๏‚„Produces the same results for all possible invocations of M independent of possible callers and parameter values.

Static Program Analysis is the analysis of run-time behavior of programs without executing them (sometimes called static testing). Approximations of program behaviours by

Analysis of run-time behavior of programs without executing them (sometimes called static testing) Analysis is done for all possible runs of a program (i.e. is there any

A funny measure on IR Example Want to define r Habra on R Borel the be f Lef numbers rational to mass that assigns measure just be all rational numbers Let q Ok Couaidu.. points in

Fulfillment of these obligations will not harm the political correlation Turkey establishes between its recognition of the Republic of Cyprusโ€™ claim to sovereignty over the entire

After the mode is canceled, the line data, which has been sent in the horizontal display period, is written in the display RAM at the time of the next trailing edge of the LP signal.

The larger number of aggressive workers encountering NM + C9T dummies in experiment 1 could have been due to two different reasons: (a) cis-9-tricosene may interfere with the