【问题标题】:Run valgrind in 32 bit mode on Mac 10.6?在 Mac 10.6 上以 32 位模式运行 valgrind?
【发布时间】:2011-08-30 06:45:29
【问题描述】:

如果我在 Mac 10.6 中编译一个带有 -m32 标志的 32 位可执行文件,例如:

gcc -m32 test.c -o 测试

在“test”上运行 valgrind 失败并出现错误:

valgrind: ./test: 无法执行二进制文件

是否有任何标志可以传递给 valgrind 来执行此操作?在 32 位模式下编译 valgrind 是唯一的选择吗?

谢谢

【问题讨论】:

  • 尝试完全删除 -m32 标志。该错误意味着二进制文件不适用于您的架构(64 位)。

标签: 32-bit valgrind


【解决方案1】:

Blender,-m32 标志只是意味着以 32 位模式编译文件。 Mac 10.6 可以正常运行 32 位可执行文件。

【讨论】:

  • 请用 cmets 回答其他 cmets。答案是对您问题的真实答案。
  • 是的,但是在 Blender 的评论或您的第一条评论下看不到 cmets 按钮。不过,这是在此评论下。错误?
【解决方案2】:

我也有这个问题,由 MacPorts 构建/安装的 valgrind。然而,当我自己构建它时,问题就消失了。我可以确认没有额外配置选项的 valgrind 默认构建支持 Snow Leopard 上的 32 位和 64 位程序(使用版本 3.6.1。)

【讨论】:

    【解决方案3】:

    您在使用哪个版本的 Valgrind 时遇到问题?

    在 Linux 和 MacOS 上,单个版本的 Valgrind 可以自动检测 32 位和 64 位二进制文​​件并执行正确的操作。

    这是我在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)
    

    【讨论】:

      猜你喜欢
      • 2014-01-27
      • 1970-01-01
      • 2013-02-13
      • 2014-07-23
      • 2013-02-23
      • 1970-01-01
      • 1970-01-01
      • 2011-03-12
      • 2011-02-17
      相关资源
      最近更新 更多