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



Dear Paul,

Thank you for your discussion.

Paul Pluzhnikov wrote:
If you are going to restrict your users in certain ways, such as
above, a much simpler solution is to tell them:

I think your solution might not be simpler than the wrapper approach.
If I understand correctly, when using the wrapper approach, the only
thing that users need to do is to add the following macros to their
include file. For example:
#define int Parameter<int>
#define double Parameter<double>
#define Foo Paramter<Foo>
....

When using your approach, user will have to meet two requirements as
follow:

- when you are solving for a given f(x), you must ensure that f()
is a true function of x (i.e. ensure that no external parameter
modification happens).

- when you are done with f(x), you can change what f(x) does in
arbitrary ways, but you must call solver_reset() routine.


The first requirement may not be easy to follow, and may force the
user to change their existing code significantly.

Besides, this approach doesn't solve *anything*: if some globals
are pointers, then you must track not only that the pointer itself
didn't change, but the "pointed to" thing didn't change either.


You have pointed out a really interesting issue. (Thanks!) If user use
some global pointers, then one solution is to provide them with some
type of pointer wrappers, smt like the Reference Counter by Scott
Meyer (in the book "More Effective C++"). This might make sure that we
can track both normal and pointer global variables.

I am correct?

The only API Linux debuggers use is ptrace(). In order to "reuse" it,
your program must have detailed understanding of the ELF file format,
which isn't too difficult, but isn't trivial either.

Thank you very much for the information. I will take a look at how to
deal with ELF file format.

Best regards,

Thanh.

.



Relevant Pages

  • COM Smart pointer doesnt keep its reference
    ... COM Smart pointer doesn't keep its reference ... and previous can be abstracted to a base wrapper class. ... Each class stores as a member variable a pointer to the COM ... CString sRow; ...
    (microsoft.public.vc.language)
  • Confusion with std::map
    ... I'm trying to use a map with a string key, and a pointer to objects ... cList is a similar wrapper around a vector, ... with BCB 5 Pro) but when I compile and run with g++ the data ...
    (comp.lang.cpp)
  • Re: C# - getting binary data from .lib
    ... I changed the wrapper to your second suggestion and it seems to be ... int retCode = create(id, scale, ptrImage); ... You now control the pointer returned. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: C# - Interop causing AccessViolationException
    ... C++ Wrapper ... // Get pointer to frame - using SharperCV wrapped for OpenCV ... one of the parameters is an empty byte array ... char rgb_greybar); ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Conversion of unmanaged structure containing array to the managed one!
    ... The way I do it is casting the pointer to ... pointer in your managed wrapper. ...
    (microsoft.public.dotnet.languages.vc)