|
From: Nicholas N. <n.n...@gm...> - 2009-10-01 21:01:24
|
On Fri, Oct 2, 2009 at 1:36 AM, Alexander Potapenko <gl...@go...> wrote:
>
> It appears that the suppressions generated by Valgrind on Mac OS
> contain function names with the gcc mangling scheme (ok for Linux, but
> invalid for Mac OS).
> For example, for the following code:
>
> -------------------------
> #include <stdio.h>
>
> struct Foo {
> void bar() {
> int *a = new int;
> *a = 12345;
> delete a;
> a = new int;
> if (*a == 12345) printf("67890\n");
> }
> };
>
> int main() {
> Foo foo;
> foo.bar();
> return 0;
> }
> -------------------------
>
> valgrind --gen-suppressions=all produces the following suppression:
>
> -------------------------
> {
> <insert_a_suppression_name_here>
> Memcheck:Cond
> fun:_ZN3Foo3barEv
> fun:main
> }
> -------------------------
>
> This suppression really works on Mac OS, but _ZN3Foo3barEv can't be
> demangled with c++filt on this platform (it should be
> "__ZN3Foo3barEv")
>
> The question is: is it the bug or a feature? Do the suppressions on
> every platform rely on the same mangling algorithm?
Valgrind uses GCC's demangling algorithm. AIUI, this generally works
on Linux and Mac because most programs are compiled with GCC.
I guess it works because Valgrind internally adds the extra
underscore, even though it doesn't print this (see my other response
to you). If you play around with suppressions for C functions that
don't involve mangling, the underscore behaviour should become
clearer.
Nick
|