code instrumentation in AST
QiangHuang
qianghuang87@gmail.com
Tue Jun 2 07:10:00 GMT 2009
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~
More information about the Gcc-help
mailing list