|
From: John R. <jr...@bi...> - 2015-03-30 05:01:28
|
> I want to trace a special function used in the guest program. > For example, a function defined like this: > */msg_type * alloc_msg(char type, int num) > /*When the guest program call this special function "alloc_msg", my valgrind tool can know the input args:"type" and "num", and when "alloc_msg" return, my valgrind tool can know the return value. Note that in some cases similar functionality is provided outside of valgrind by tools such as ltrace. Also, using dlopen() with RTLD_NEXT enables the construction of a shared library that can "wrap" any call to a function that has dynamic linkage. Any call that goes through the PLT [ProgramLinkageTable] can be intercepted this way. Calls to a C static function cannot, nor calls to an inlined function. Once built, the shared library can be activated for any process without re-compilation or re-linking, by using the shell environment variable LD_PRELOAD. Consult "man dlopen" and search the 'net for a complete example. Both of these are not exactly what you asked for, but they are substantially similar in significant ways, avoid using valgrind altogether, and usually execute at least 10 times faster than valgrind. |