I am looking for a tool that would analyze C/C++ code on windows and should be able capture reads and writes to variables by different functions. For example:
//in file1.c
extern int a;
write_to_a(){
a = 1;
}
// in file2.c
extern int a;
write_to_a_again(){
a = 5;
}
The tool should say that the variable "a" was written in these two functions.
This tool should cover a case like passing pointers or references to functions. For example:
int *p;
*p =2;
functionA(p); // function call
void functionA(int k) // function definition
{
k++;
}
In the above example, the tool should be able to say that the variable "p" was modified.
It should also be able to capture object oriented behavior. For example:
class objA{
int integer_objA;
char characterA;
public:
void increment_integer(){
integer_objA++;
}
void print_this(){
std::cout<<integer_objA<<"\n";
std::cout<<characterA<<"\n";
}
void write_this(){
std::cin>>integer_objA;
std::cin>>characterA;
}
};
class objB{
int integer_objB;
objA objectAB; // instance of class objA
public:
void increment_objectAB(){
objectAB.increment_integer();
}
void writeAB(){
objectAB.write_this();
}
void readAB(){
objectAB.print_this();
}
};
int main(){
objB beta;
std::cout<<"Enter a number and then a character: ";
beta.writeAB();
// increments the value of objectAB
// this also means that beta has now changed because
// one of its member object has changed
beta.increment_objectAB();
beta.readAB();
return 0;
}
In the above example, it should be able to identify that since we change value of objectAB, inside objB's instance beta, beta is the variable/object that is written to and not just objectAB. It would also be great if the same tool has something like an API library that I can use to make it do what I want with the information that it has.
I have used some tools like the Understand tool v4.0 from Scitools, but it does not capture this.
any suggestions?