Reputation: 5
Let's suppose I have program like this:
int test(int n) {
n++;
std::cout << n << std::endl
n += 15;
return n + 1;
}
int main(int argc, char** argv) {
auto result = test(argv[1]);
std::cout << result << std::endl
}
How can I record its execution, so I can dump something like:
Visited Function: main with arguments (argc: 2, argv ["path", 7])
Visited Function test with arguments (n: 7)
test: N set to 8
test: N set to 23
test: N set to 24
Exit function test
Main: result set to 24
or at least
Visited Function: main with arguments (argc: 2, argv ["path", 7])
Visited Function test with arguments (n: 7)
test: N set to 8
// or maybe without stdlib if possible
test: Visited operator std::cout with 8
test: Visited operator std::cout with std::endl
test: N set to 23
test: N set to 24
Exit function test
Main: result set to 24
Exit function main
It is like if a ran program under debugger and only used "Step Into" until the program ends. And between all those Step Into I'd dump things like current function name and values of locals.
Why I need that?
I have one program in two versions v1 and v1.01
And 1.01 introduced regression, so I want to compare their behaviour on the same input, so I can automatically find the regression.
Some people suggested instrumentation, but I'd rather have something like rr debugger or windows time travel record because it is universal, language agnostic.
But if it is hard to dump such a thing from those tools, then I'll try to go with instrumentation.
C++, MSVC on Windows or Clang on Linux (preferably MSVC on Windows)
I tried using Windows Time Travel, but I don't know how to dump their recording format into something human readable
Upvotes: -2
Views: 80
Reputation: 213829
I want to compare their behaviour on the same input
For any program that is longer than ~1000 lines, your approach will result in enormous dumps of local variables.
In addition, you will drown in non-essential differences: process ids, timestamps, local ports are all going to be different. Stack addresses may be different. If you don't disable ASLR, heap addresses will be different etc. etc.
I'd rather have something like rr debugger
The rr
is exactly what you need: run both versions of the program under rr
until the place where you observe divergence, then run back and forth until you find where the regression happens.
Upvotes: 0