−
D
]
(e.g. P(Zn)) (e.g. n-dim boxes)
Concrete domain Abstract domain
Elements in D]
represent properties of interest (semantical)
are computer-representable (algorithmic)
Choosing D] is a trade-off between cost and expressiveness
Antoine Min´e Building a specialized static analyzer p. 8 / 112
Introduction Static analysis
Abstract interpretation (cont.)
For each concrete semantic operator F : Dn ! D:
assignment,
test,
control-flow join, etc.
define F] : D]n ! D] that
can be implemented (algorithm)
is sound: F(
(X]
1), . . . ,
(X]
n))
(F](X]
1, . . . ,X]
n))
various precision / cost trade-offs
=) computable over-approximation
Antoine Min´e Building a specialized static analyzer p. 9 / 112
Introduction Static analysis
Construction by refinement
Approach
define a concrete semantics
build a simple and fast analyzer (intervals)
refine the analyzer until 0 false alarm:
determine which necessary properties are missed
add / refine an abstract domain to infer it
Benefits
sound by construction
efficient (adapted cost / precision trade-off)
encourages modular, reusable abstractions
Antoine Min´e Building a specialized static analyzer p. 10 / 112
Introduction First analyses
Analysis input and output
Astrée
− alarms
− invariants
(environment
configuration)
C sources
(preprocessed)
Antoine Min´e Building a specialized static analyzer p. 11 / 112
Introduction First analyses
Example analysis
loop.c
1 void main() {
2 unsigned i;
3 for (i=10; i>=0; i--) {
4 /* */
5 }
6 }
Starting the analysis
% astree loop.c --exec-fn main | egrep WARN
Antoine Min´e Building a specialized static analyzer p. 13 / 112
Introduction First analyses
Example analysis
loop.c
1 void main() {
2 unsigned i;
3 for (i=10; i>=0; i--) {
4 /* */
5 }
6 }
Analysis result
% astree loop.c --exec-fn main | egrep WARN
loop.c:3.19-22::[call#main@1:loop@4>=4:]: WARN:
unsigned int arithmetic range [-1, 4294967294]
中国航空网 www.aero.cn
航空翻译 www.aviation.cn
本文链接地址:航空资料41(91)