I work with C/CPP on Embedded systems, and in my code I have some sections that is run from some memory that is "invalid" and MUST NOT be called until some condition is met.
for simplicity:
Lets say foo()
is such function and is invalid while g_isMemoryValid == false
except for foo() there are couple of houndred other functions in the invalid memory section with several calls each from all the modules.
my problem is to find all instances where i enter the invalid section and verify i didnt miss any call!
How can i ensure that all branches where foo()
is run are meet g_isMemoryValid == true
Solution Should output:
The line which jumps to the code(or instruction address),
but even if it will emit the module name only,
Or Hell... [OK, NOT_OK] will do :)
Note: Even solutions that will solve only subset of the scenarios will do!
Notice that there many scenarios in addition to simple if(g_isMemoryValid)
wrapper like call chaining the calling function in itself not called while condition is not met or some different syntax of the branch
if (g_isMemoryValid)
foo(); // should pass
if (!g_isMemoryValid)
return;
foo(); // should pass too