|
From: Andres T. <and...@ta...> - 2015-03-16 13:57:16
|
Hi, I'm having a hard time wrapping functions like helgrind does.
My problem is the next:
I have this file (main.cpp):
-------------------main.cpp------------------------------------------
int testFunction(int a)
{
return a + 1;
}
int main(void)
{
int i;
for(i=0;i<2;++i)
cout << testFunction(1) << endl;
return 0;
}
---------------------------------------------------------------------------
And I have my valgrind tool:
---------------------------fb_main.c----------------------------------------
.
.
.
#define WRAP_FUNC(retType, macroName, f, args...) \
retType I_WRAP_SONAME_FNNAME_ZZ(macroName,f)(args); \
retType I_WRAP_SONAME_FNNAME_ZZ(macroName,f)(args)
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <pthread.h>
WRAP_FUNC(int, NONE, testFunction, int a)
{
return 1;
}
------------------------------------------------------------------------------------------------------
And when I try to run the binary from main.cpp with my tool I get this:
------------------------------------------------------------------------------------------------------------
[andres@localhost valgrind]$
/home/andres/Documents/valgrind/install/bin/valgrind --tool=foobar
../test/a.out
==11636== Nulgrind, the minimal Valgrind tool
==11636== Copyright (C) 2002-2013, and GNU GPL'd, by Nicholas Nethercote.
==11636== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==11636== Command: ../prueba/a.out
==11636==
valgrind: m_redir.c:605 (vgPlain_redir_notify_new_DebugInfo):
Assertion 'is_plausible_guest_addr(sym_avmas.main)' failed.
Segmentation fault (core dumped)
------------------------------------------------------------------------------------------------------------
I know I'm doing something wrong because helgrind works, but I don't
realize what. Maybe someone of you knows what's going on(I have the
preload.so).
ps: I'm using valgrind 3.11 from the svn repository.
Regards,
Andres
|