OS X has a terrible anti-feature called ".dSYM" files. These are directories that you must generate after you build you program, with a tool called "dsymutil". Search for "--dsymutil" in this section of the valgrind manual:
http://valgrind.org/docs/manual/manual-core.html#manual-core.erropts I'm actually surprised that you get any line info in the single-pass case. But it's been a while since I tried to use valgrind on a program with only one source file. -Dave On Mar 23, 2012, at 8:16 AM CDT, Peter Cogan wrote: > Hi, > > I have a problem running valgrind on os x that I cannot replicate on Ubuntu. > The problem is as follows: > > I'm trying to compile a program with debugging symbols so that valgrind will > give me line numbers. I have found that if I compile a simple test program in > one go (with -g) then it contains the line numbers. However, if I compile in > two passes (i.e. compile then link) then it does not contain the line > numbers. > > Here's the compile command for the single pass case: > > g++ -g file.c -o file > > And for two passes > g++ -g -c file.c -o file.o > g++ -g file.o -o file > > The actual program looks like this and contains a simple Invalid Write > int main(){ > int* x = new int[10]; > x[10]=1; > } > > If I compile with one pass then valgrind gives the following (note the line > number at the end file.c:3) > ==24114== 40 bytes in 1 blocks are definitely lost in loss record 2 of 9 > ==24114== at 0xB823: malloc (vg_replace_malloc.c:266) > ==24114== by 0x5768D: operator new(unsigned long) (in > /usr/lib/libstdc++.6.0.9.dylib) > ==24114== by 0x576DA: operator new[](unsigned long) (in > /usr/lib/libstdc++.6.0.9.dylib) > ==24114== by 0x100000F09: main (file.c:3) > > whereas if I compile in two passes I get this (with no line number): > ==24135== 40 bytes in 1 blocks are definitely lost in loss record 2 of 9 > ==24135== at 0xB823: malloc (vg_replace_malloc.c:266) > ==24135== by 0x5768D: operator new(unsigned long) (in > /usr/lib/libstdc++.6.0.9.dylib) > ==24135== by 0x576DA: operator new[](unsigned long) (in > /usr/lib/libstdc++.6.0.9.dylib) > ==24135== by 0x100000F09: main (in ./file) > > What's interesting is that if I debug my little test program with GDB I can > see line numbers. So somehow valgrind is not getting them. > > My system is OS X 10.7.3 with gcc 4.2.1 and valgrind 3.7.0 > Note that I could not reproduce the problem on Ubuntu - there valgrind sees > the line numbers no matter what. > > thanks for any help > Peter > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > Valgrind-users mailing list > Valgrind-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/valgrind-users ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users