Valgrind 的地块工具不会分析我的应用程序 [英] Valgrind's massif tool will not profile my application

查看:13
本文介绍了Valgrind 的地块工具不会分析我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 CentOS 存储库中的标准 gcc 4.4 软件包在 64 位 CentOS 5.8 上开发一个静态链接的 64 位 C++ 应用程序.它使用的内存似乎比我预期的要多,所以我尝试使用 massif 来分析内存使用情况.我已经用调试信息编译,然后运行 ​​

I am developing a statically-linked 64-bit C++ application on 64-bit CentOS 5.8 using the standard gcc 4.4 packages from the CentOS repositories. It appears to be using more memory than I expected, so I tried using massif to profile the memory usage. I have compiled with debug information and then run

valgrind --tool=massif ./MyProg

valgrind --tool=massif ./MyProg

来自 MyProg 所在的目录.除了以下 massif.out.XXXX 示例之外,它永远不会产生任何结果.

from the directory where MyProg resides. It never produces any results other than the following massif.out.XXXX example.

desc: (none)
cmd: ./MyProg
time_unit: i
#-----------
snapshot=0
#-----------
time=0
mem_heap_B=0
mem_heap_extra_B=0
mem_stacks_B=0
heap_tree=empty

请注意,这是文件的全部内容,我的程序可以运行几分钟.

Note that that is the entire contents of the file and my program can run for many minutes.

我尝试了 valgrind 和 massif 的各种选项,但均无济于事.我什至尝试使用 MyProg 的绝对路径,以防万一.我已经尝试下载 valgrind 的最新稳定版本(3.8.1)并编译和运行它(因为 CentOS 使用的是 3.5.0),结果相同.作为健全性检查,我跑了

I have tried various options to valgrind and massif to no avail. I even tried using the absolute path to MyProg, just in case. I've tried downloading the most recent stable version of valgrind (3.8.1) and compiling and running that (since CentOS is using 3.5.0) with the same result. As a sanity check I ran

valgrind --tool=massif ls -l

valgrind --tool=massif ls -l

并且它按预期生成了多个内存使用量非零的快照.

and it produced multiple snapshots with non-zero memory usage as expected.

我已经尝试使用我能想到的所有关键字组合进行在线搜索,但没有发现任何类似的问题.

I've tried searching online using every combination of keywords I could think of but did not find any similar problems.

附带说明一下,我可以使用 valgrind 的默认 memcheck 工具成功地分析应用程序,以防万一这是有用的信息.

As a side note, I can successfully profile the application using valgrind's default memcheck tool, in case that is useful information.

有人知道为什么 massif 无法分析我的应用程序吗?

Does anyone know why massif would fail to profile my application?

推荐答案

如果应用是静态链接的,则无法使用valgrind进行分析.Valgrind 通过向您的程序提供它自己的分配函数版本来工作,它通过覆盖动态查找来完成.

If the application is statically linked, it cannot be analyzed using valgrind. Valgrind works by providing it's own version of the allocation functions to your program, which it accomplishes by overriding the dynamic lookup.

如果您可以动态链接标准库(libc 和 libstdc++),那么它应该能够执行您正在寻找的内存分析.

If you can dynamically link with the standard libraries (libc and libstdc++), then it should probably be able to perform the memory analysis you're looking for.

来自 Valgrind 常见问题解答:

其次,如果你的程序是静态链接的,大多数 Valgrind 工具将无法正常工作,因为它们无法用自己的版本替换某些函数,例如 malloc.

Second, if your program is statically linked, most Valgrind tools won't work as well, because they won't be able to replace certain functions, such as malloc, with their own versions.

这篇关于Valgrind 的地块工具不会分析我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆