code instrumentation in AST

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



     Hi, Everyone~

     I need to do some research in the area of software testing with
the help of GCC.Especially I intend to instrument some assert code in
the AST of GCC.

     Take the following code as an example:

     int main()
     {
         char str[10], *buf;
         scanf("%s", buf);
         strcpy(str, buf);
         return 0;
     }

     after instrumentation finished, it looks like this:

     int main()
     {
         char str[10], *buf;
         scanf("%s", buf);
         assert(strlen(buf)<10);       // Instrumentatiom to make sure
that the length of the later one is less than the former one.
         strcpy(str, buf);
         return 0;
     }

     I already had a good understand on the structures of the gcc
AST.Instrumentation could be done by manually inserting the AST nodes
one by one.
     However, what I care is that if there is any feasible internal
functions or tools buildon GCC for inserting the instrumentation code
conveniently and quickly.

     Thanks a lot~

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux