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
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
Share Improve this question asked Feb 23 at 13:19 EUVEUV 52 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 0I 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745153690a4613987.html
test(argv[1])
won't compile.argv[1]
is achar*
, whiletest
accepts anint
. – Igor Tandetnik Commented Feb 23 at 14:02you really need is a (git) and unit tests
The example that I posted here on SO can be 10 times simplified than real world scenario, so people can understand it easierOr are you saying you need to dump an executable for which you don't have the source code?
I have source, but there are literally tens of thousands of commits between two versions and I need to find where the behaviour changes (often it is dependent on runtime values) It's giant codebase with hundreds of contributors, and yes, we have tens of thousands tests, but very often changes/regression are in external code (framework) – EUV Commented Feb 23 at 22:09