what's the meaning of the circle node in pdgs which is generated by frama-c

ぃ、小莉子 提交于 2019-12-22 18:26:31

问题


I use frama-c tool to analyse the code below.

  int main (int argc, char *argv[])
  {
     int i,a;
     for (i = 0; i < 100; i += 1)
     {
        a=0;
        if (a==0)
        {
            continue;
        }
        else
        {
            break;
        }
     }
     return 0;
  }

the cmd is

   frama-c -pdg -dot-pdg graph main.c

My question is about the control dependence. what's the circle node means? I try to explain the "while" node, maybe it stand for one time loop , because a loop start from "i<100",so there a control dependence ("i<100" ------o "while" ). Is what I guess right ? but what is the "break" node mean? I guess that node "goto __Cont;" is related to the "break;" statement in the "else" block.
I think I have no clear abstract model in my head for understanding the control dependence completely and accurately . Would you help me or give me any suggestion ?. Many Thanks in Advance Tao.


回答1:


Use the command frama-c -print main.c to see how the program was translated (I include the translated version below).

The statement goto __Cont; in the normalized version is the translation of continue; in the original.

And, as Binyamin said, the for loop was normalized into a while loop.

int main(int argc, char **argv)
{
  int __retres;
  int i;
  int a;
  i = 0;
  while (i < 100) {
    a = 0;
    if (a == 0) { goto __Cont; }
    else { break; }
    __Cont: /* internal */ i ++;
  }
  __retres = 0;
  return (__retres);
}



回答2:


Most of it is self explanatory:

  • circle - flow control (branching)
  • rhombus - condition (a == 0 etc.)
  • square - assignment

Your for loop was translated to a while loop



来源:https://stackoverflow.com/questions/9926688/whats-the-meaning-of-the-circle-node-in-pdgs-which-is-generated-by-frama-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!