Software has been under scrutiny by the verification community from various angles in the recent past. There are two major algorithmic approaches to ensure the correctness of and to eliminate bugs from such systems: software model checking and static analy
Figure3.Fragmentsof(a)theattributedabstractsyntaxtree(AST),and(b)theannotatedcontrol owgraph(CFG).
123456789101112
voidf(intx){inta,b;int*p;
p=(int*)
malloc(sizeof(int));*p=42;
if(x==0){free(p);a=*p;}
b=a+*p;}
modelchecking.ConsiderthecontrivedcodefragmentinFigure2,whichisobviously awed.Notonlydoesitcon-tainapotentialaccessofanuninitializedvariable(ainline11),butalsodereferencesapointerthathasalreadybeenfreed(pinline9),andassignsavaluetoavariablethatisneverusedafterwards(binline11).
WewillillustratethelabelingoftheASTandCFG,thegenerationofNuSMVcodethatimplementsthechecksandtheeaseofaddingpropertiestoGoanna.Again,wedemon-strateitinthecontextofuninitializedvariablesforthesakeofsimplicity.
4.1AnnotationofCFG
Figure2.Sourcecodeexample
Theprogramanalysisbuildsonanannotatedcontrol owgraph.Generatingthecontrol owgraph—withoutannotations—forthecodefragmentisstraightforward.AfragmentoftheASTisdepictedinFigure3(a)andthere-sultingCFGinFigure3(b).EachnodeislabeledwithanIDandalabel.TheIDsrefertoidenti ersintheintermedi-ateformatgeneratedbytheparserandareusedfortechnicalreasonsonly.TheattributesofnodesintheASTareusedtolabeltheedgewiththeparentnodeinFigure3(a).OnlynodesoncertainlevelsintheASTwillbeusedtobuildtheCFG,inthisexamplenodes59,63,72and78.5
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新高等教育F. Model checking software at compile time(8)全文阅读和word下载服务。
相关推荐: