How to write a program to track the value of a certain variable at run-time using debug features???
I'm totally new to the group and I would like to learn from you. Thank
you in advance!
I need to write a program to track whether a mathematical function has
changed during run-time or not. The program should work with any
mathematical function provided by users.
Let's take an example in the C language:
//The users define the two parameters a, b as two global variables.
The users can define as many parameters as possible and my program
does not know about this!!!
//below is the prototype for our mathematical function
void f(vector x);
//at first, an user wants f = 1x+1y, so he sets the value of a, b
double value=f(x); //calculate the value of function f
//now the user want f = 1x +2y, so he set b = 2
//and invoke the function f again
As can be seen from the code above, the function f has changed from f
= x+y to f=x+2y and my program needs to track this at run-time (The
function f, along with its parameters (a and b), will be integrated
with my program).
However, the problem is that my program will NOT KNOW which function
to be provided by the users and which/ how many parameters (defined as
global variables) the function may take
I think that one solution for the problem might be:
1. List all global variables currently used in the program
2. Find out which global variables are being used by f (I can do that
by parsing the source code file of f)
3. Tracking the value of all these global variables to see whether
they have been changed outside of f or not. If they have, then
possibly that f has been changed too.
Now the question is: How to list all global variables and how to track
the value of a certain global variable at run-time???
I wonder whether the existing debugger of windows/Visual Studio can
provide me with the necessary APIs to answer the question above?
Thank you so much for your help