Hi everybody,

I have a question about function wrapping for C++ code:

I want to wrap a function foo:
int foo( int x, int y )
{
  return x + y;
}

with the following wrapper code:
int I_WRAP_SONAME_FNNAME_ZU(NONE,foo)( int x, int y )
{
  int    result;
  OrigFn fn;
  VALGRIND_GET_ORIG_FN(fn);
  printf("foo's wrapper: args %d %d\n", x, y);
  CALL_FN_W_WW(result, fn, x,y);
  printf("foo's wrapper: result %d\n", result);
  return result;
}

This works fine with gcc but not with g++.

The reason for that is that the mangled label does not match the wrapper
label:
I compile with -S to assembler:

The mangled name for foo: _Z3fooii
The mangled name for foo wrapper: _Z15_vgwZU_NONE_fooii

When I change the label of the wrapper function by hand in the assembler
file to:
_vgwZU_NONE__Z3fooii Valgrind wraps the function correctly.

It seems that it is not possible to wrap C++ functions because the macros
are not powerful enough!
Is there any other possibility to wrap C++ functions?

My solution:
One possibilty could be to extend the Macros in valgrind.h by integrating a
mangeling mechanism to generate correct wrapper names. Can anybody confirm
this?

Thanks in advance.
Mit freundlichen Grüßen / Kind Regards

*Patrick Heckeler*

University of Tuebingen
Wilhelm-Schickard-Institute
Computer Engineering Department
Sand 13 D-72076 Tuebingen
Office B 204

Phone: +49 (0)7071 29 78 977
Fax: +49 (0)7071 29 50 62
Skype: p_heckeler
Email: heckeler [at] informatik [dot] uni-tuebingen [dot] de
WWW: http://www.ti.uni-tuebingen.de/Patrick-Heckeler.876.0.html
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to