Un modello integrato control-flow e data-flow per il rilevamento ...
Un modello integrato control-flow e data-flow per il rilevamento ...
Un modello integrato control-flow e data-flow per il rilevamento ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
2.1. Modelli <strong>control</strong> <strong>flow</strong> 15<br />
1 int main() {<br />
2 int a, b;<br />
3 a = 1; b = 2;<br />
4 f(a);<br />
5 g();<br />
6 f(b);<br />
7 }<br />
8<br />
9 void f(int x) {<br />
10 syscall5();<br />
11 if (x == 1)<br />
12 syscall3();<br />
13 else if (x == 2)<br />
14 syscall4();<br />
15 }<br />
16<br />
17 void g() {<br />
18 syscall2();<br />
19 }<br />
f.10<br />
main.4 main.5<br />
f.12 f.14<br />
main.6<br />
g.18<br />
syscall5() syscall3() syscall4() syscall2()<br />
Figura 2.3: Esempio riguardante la parte induttiva della definizione dell’EG.<br />
ma non osservati potrebbero non essere sco<strong>per</strong>ti, in questo caso particolare quelli da<br />
f.14 a main.4 e da f.12 a main.6. Grazie alla parte induttiva si riescono a ricavare<br />
senza problemi.<br />
Definizione 3 ( call<br />
→, rtn<br />
→) Sia EG(X ) = (V, Ecall, Ecrs, Ertn) un execution graph.<br />
r call<br />
→ r ′<br />
se e solo se esiste un <strong>per</strong>corso da r a r ′<br />
Analogamente r rtn<br />
→ r ′<br />
archi in Ertn.<br />
se e solo se esiste un <strong>per</strong>corso da r a r ′<br />
costituito solo da archi in Ecall.<br />
costituito solo da<br />
Definizione 4 ( xcall<br />
→ , Execution stack) Sia EG(X ) = (V, Ecall, Ecrs, Ertn) un execution<br />
graph. r xcall<br />
→ r ′<br />
se e solo se:<br />
• (r, r ′<br />
) ∈ Ecall oppure<br />
• esiste r ′′<br />
∈ V tale che (r, r ′′<br />
′′ crs<br />
) ∈ Ecall e r → r ′<br />
Definizione 5 (Successore) <strong>Un</strong> execution stack s ′ = 〈r ′<br />
1<br />
, r′ 2<br />
, . . . , r′<br />
n ′ 〉 è un suc-<br />
cessore di s = 〈r1, r2, . . . , rn〉 in un execution graph se esiste un intero k tale che<br />
rn rtn<br />
→ rk, (rk, r ′<br />
k ) ∈ Ecrs, r ′<br />
k<br />
call<br />
→ r ′<br />
n ′ e ri = r ′<br />
i<br />
<strong>per</strong> 1 ≤ i < k.<br />
Intuitivamente quest’ultima definizione significa che affinché s ′ sia successore di s i<br />
due stack devono: