开发者

Run valgrind in 32 bit mode on Mac 10.6?

开发者 https://www.devze.com 2023-03-07 23:32 出处:网络
If I compile a 32 bit executable in Mac 10.6, with the -m32 flag, like: gcc -m32 test.c -o test running valgrind on \"test\" fails with the error:

If I compile a 32 bit executable in Mac 10.6, with the -m32 flag, like:

gcc -m32 test.c -o test

running valgrind on "test" fails with the error:

valgrind: ./test: cannot execute binary file

Are there any flags to pass to valgrind to e开发者_如何学编程xecute this? Is the only option to compile valgrind in 32 bit mode?

Thanks


Blender, the -m32 flag just means to compile the file in 32-bit mode. Mac 10.6 runs 32-bit executables just fine.


I had this problem too, with valgrind built/installed by MacPorts. When I built it myself, however, the problem went away. I can confirm that a default build of valgrind with no extra configure options supports both 32-bit and 64-bit programs on Snow Leopard (used version 3.6.1.)


What version of Valgrind are you having trouble with?

On Linux and MacOS, a single build of Valgrind can automatically detect and do the right thing for both 32 and 64-bit binaries.

Here is what I see on Mac OS X 10.6.7 (10J869):

$ echo "int main() { free(1); return 0; }" | gcc -xc - -g -o a.out
$ echo "int main() { free(1); return 0; }" | gcc -xc - -g -o a.out32 -m32
$ valgrind --version
valgrind-3.7.0.SVN

$ valgrind ./a.out
==46102== Memcheck, a memory error detector
==46102== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==46102== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright info
==46102== Command: ./a.out
==46102== 
--46102-- ./a.out:
--46102-- dSYM directory is missing; consider using --dsymutil=yes
==46102== Invalid free() / delete / delete[] / realloc()
==46102==    at 0x100010E9F: free (vg_replace_malloc.c:366)
==46102==    by 0x100000F26: main (in ./a.out)
==46102==  Address 0x1 is not stack'd, malloc'd or (recently) free'd
==46102== 
==46102== 
==46102== HEAP SUMMARY:
==46102==     in use at exit: 88 bytes in 1 blocks
==46102==   total heap usage: 1 allocs, 1 frees, 88 bytes allocated
==46102== 
==46102== LEAK SUMMARY:
==46102==    definitely lost: 0 bytes in 0 blocks
==46102==    indirectly lost: 0 bytes in 0 blocks
==46102==      possibly lost: 0 bytes in 0 blocks
==46102==    still reachable: 0 bytes in 0 blocks
==46102==         suppressed: 88 bytes in 1 blocks
==46102== 
==46102== For counts of detected and suppressed errors, rerun with: -v
==46102== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

$ valgrind ./a.out32
==46103== Memcheck, a memory error detector
==46103== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==46103== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright info
==46103== Command: ./a.out32
==46103== 
--46103-- ./a.out32:
--46103-- dSYM directory is missing; consider using --dsymutil=yes
==46103== Invalid free() / delete / delete[] / realloc()
==46103==    at 0xF7D8: free (vg_replace_malloc.c:366)
==46103==    by 0x1F7B: main (in ./a.out32)
==46103==  Address 0x1 is not stack'd, malloc'd or (recently) free'd
==46103== 
==46103== 
==46103== HEAP SUMMARY:
==46103==     in use at exit: 320 bytes in 7 blocks
==46103==   total heap usage: 7 allocs, 1 frees, 320 bytes allocated
==46103== 
==46103== LEAK SUMMARY:
==46103==    definitely lost: 0 bytes in 0 blocks
==46103==    indirectly lost: 0 bytes in 0 blocks
==46103==      possibly lost: 0 bytes in 0 blocks
==46103==    still reachable: 260 bytes in 6 blocks
==46103==         suppressed: 60 bytes in 1 blocks
==46103== Rerun with --leak-check=full to see details of leaked memory
==46103== 
==46103== For counts of detected and suppressed errors, rerun with: -v
==46103== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号