I want to employ an automatic unit test generation approach in C++ with the help of LLVM. The approach should automatically acquire the states of specific objects during a dynamic analysis of the application under test (AUT). After the data has been recorded I want to write the test. Here, the test should reconstruct the objects with the recorded test data as a setup before executing the method/code under test.
With object states I mean all member variable values of an object including references to other objects (for which I also need to acquire and reconstruct the whole object state). However, since ALL member values include those of private member variables, I ran into a problem. From what I have learned, there is no way to access private member variables in C++. That is, unless the object type in question is a friend with any of "my object types" or provides direct access functions to its private members.
Actually, I can solve this problem for types which have been declared in the source code of the AUT. Here, I can use LLVM to instrument the types with the necessary code during compilation. However, I cannot do this for referenced types from precompiled libraries which the AUT uses.
Hence, my question: Have you any idea how I can record and reconstruct the full states of arbritrary objects for which I do not have the source code? Could direct copying of memory help?
Since my approach is actually basic (automatic) unit test generation, I'm sure there has to be way to implement this in C++. After all, such kinds of generators have already been implemented in Java and C#.