Re: How to write a program to track the value of a certain variable at run-time using debug features???
- From: "classicalmania" <trungthanh78@xxxxxxxxx>
- Date: 19 Mar 2007 07:52:05 -0700
On 19 Mar, 18:38, Ulrich Eckhardt <dooms...@xxxxxxxx> wrote:
Uli
Dear Ulrich,
Thank you for your quick helps. Firstly, apologies for my possibly off-
topic topic, but I think that possibly there might be some Linux-based
debug tools for my purpose.
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
Give me an example how your program is supposed to behave in action. IOW,
what is the user-input and what is the program output? Collecting
use-cases is a good start for defining the behaviour in general.
Secondly, I am afraid that my first post does not properly show what I
would like to ask (sorry about that). Actually as a part of my
research I have written an algorithm to solve numerical functions. The
algorithm will be integrated by users with the code of their numerical
functions so that their program can solve the functions.
In other word, my algorithm will treat users' numerical functions as
black boxes. It will solve them no matter what is the content of these
functions provided that they conform to the format y=f(vector x).
However, there is a problem: the functions of users may change
dynamically over time (for example, they may change from y=x+y to y=x
+2y, as shown in the previous post). My algorithm needs to track this
change without knowning anything about user source code. That's why I
am thinking about using Linux debug features.
As mentioned above, I do not want users to enter code dynamically.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.
This is possible, but very complicated in C because it is a statically
compiled language. If you want the user to enter code that is to be
executed, you might want to take a look at dynamic languages like Python
instead. If you want to stay with C, you need to learn about the ELF
binary format (which is used by Linux) and you need to learn about memory
protection methods in order to track accesses to variables.
Instead users will integrate my algorithm with their source code and
compile it, and I need to track how many variables they are using and
whether their variables have changed or not.
Do you have any idea about this issue?
Thank you very much and again sorry for my slightly off-topic
question.
Best regards,
Thanh.
.
- Prev by Date: Re: Is splint the best for static code checking? I mean free.
- Next by Date: Re: Is splint the best for static code checking? I mean free.
- Previous by thread: Is splint the best for static code checking? I mean free.
- Next by thread: Re: How to write a program to track the value of a certain variable at run-time using debug features???
- Index(es):
Relevant Pages
|