This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Debugging C++ using instrumentation.
- From: lrtaylor at micron dot com
- To: <shriram_vishwanathan at persistent dot co dot in>, <gcc-help at gcc dot gnu dot org>
- Date: Tue, 6 Jul 2004 14:04:39 -0600
- Subject: RE: Debugging C++ using instrumentation.
Unfortunately, I can't give you much information, but I believe this is
possible (at least on UNIX/Linux). I've seen something similar done for
memory profilers (malloc and free would be overridden by custom versions
in a shared library). The way it worked more or less (as near as I can
remember anyway) is that there were special versions of functions that
were to be overridden in a shared library, and the runtime linker was
told to load this library before any others using (maybe) the LD_PRELOAD
variable or something like that. That way, the function calls would
resolve to those defined in this special library.
Unfortunately, I don't remember much beyond that, and I could be
remembering things wrong. However, the important point is that I
believe you can in fact override functions at runtime. However, this is
not going to be the forum to get a complete answer, since I believe it
has nothing to do with the compiler, but rather with the runtime linker.
You might try a binutils list or something similar. Also look at the
man page for "ld.so".
Good luck,
Lyle
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Shriram V
Sent: Monday, July 05, 2004 7:14 AM
To: gcc-help@gcc.gnu.org
Subject: Debugging C++ using instrumentation.
Hi Gurus,
I was wondering if there is a method that allows a call to an arbitrary
function to be intercepted and replaced by a new function at runtime /
compile-time / link-time.
<SNIP>