How to write a program to track the value of a certain variable at run-time using debug features???

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hello everyone,

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!!!
int a;
int b;


//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
//accordingly
a=b=1;


double value=f(x); //calculate the value of function f


//now the user want f = 1x +2y, so he set b = 2
b =2;


//and invoke the function f again
value=f(x);
//=================================================


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


Best regards,

Thanh.

.



Relevant Pages

  • Re: Moving from 8051 to AVR
    ... Getting rid of global variables is not "good programming practice". ... int foo; ...
    (comp.arch.embedded)
  • Re: printing the permutation, help
    ... People might not be able to see the post you are replying to. ... Don't use global variables without a very good reason. ... Implicit int was removed in the C99 standard and many considered it bad style even before then, and you don't return a value anyway! ... there are plenty of solutions without bothering with recursion. ...
    (comp.lang.c)
  • Re: Resources about program design in C
    ... an interest in the reasoning behind global variables in C programs. ... A function should isolate its implementation details from the ... imagine a module that implements a stack ... static int stack_ptr; ...
    (comp.lang.c)
  • location of stack and heap varies -- why?
    ... int main{ ... were the same from execution to execution. ... I don't think the Linux systems can be using a single-address-space ... different addresses for the global variables, ...
    (comp.unix.programmer)
  • Re: returning array
    ... >>> How to return an two dimensional array in user defined function ... > This should be int main; ... Those are global variables that are set during the call to enter. ... It's also used to exit loops, ...
    (comp.lang.c)