查找 Solaris 上的错误内存访问
在 Linux、FreeBSD 和其他系统上,我使用 valgrind 来检查内存错误,例如无效读取等。我真的很喜欢 valgrind。现在我必须在 Solaris/OpenSolaris 上测试代码,但无法找到一种方法来以与 valgrind 一样好的方式(或更好;-))获取有关无效读/写的信息。
在网上搜索此内容时,我发现对 libumem 的引用,但我只得到有关内存的报告那里泄漏,而不是无效访问。我缺少什么?
On Linux, FreeBSD and other systems I have valgrind for checking for memory errors like invalid reads and similar. I really love valgrind. Now I have to test code on Solaris/OpenSolaris and can't find a way to get information on invalid reads/writes in an as nice way (or better ;-)) as valgrind there.
When searching for this on the net I find references to libumem, but I get only reports about memory leaks there, not invalid access. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Sun Studio 编译器附带的 dbx 在其“运行时检查”功能(
check
子命令)中包含内存访问检查支持。请参阅:相关的“Sun 内存错误发现工具”是也可从
http://cooltools.sunsource.net/发现/
The dbx included with the Sun Studio compilers includes memory access checking support in its "Run Time Checking" feature (the
check
subcommand). See:The related "Sun Memory Error Discovery Tool" is also available from
http://cooltools.sunsource.net/discover/
从版本 3.11.0 开始,Valgrind 确实在 Solaris 上运行。
请参阅发行说明和支持的平台。
更准确地说,现在支持x86/Solaris 和amd64/Solaris。
对 sparc/Solaris 的支持仍在进行中。
Since version 3.11.0, Valgrind does run on Solaris.
See Release Notes and Supported Platforms.
More precisely, x86/Solaris and amd64/Solaris is now supported.
Support for sparc/Solaris is still in works.
watchmalloc 是一个非常有用的库可以为您的程序动态加载(通常不需要重新编译),然后在所有通常有问题的内存位置设置观察点,例如释放区域或分配的内存块之后。
如果您的程序访问这些无效区域之一,它将收到一个信号,您可以在调试器中检查它。
根据配置,可以监视有问题的区域仅进行写入,也可以进行读取。
watchmalloc is a quite useful library that can be dynamically loaded for your program (usually no need for recompiling) and then sets watchpoints at all the usually problematic memory locations, like freed areas or after an allocated memory block.
If your program accesses one of these invalid areas it gets a signal and you can inspect it in the debugger.
Depending on the configuration problematic areas can be watched for writes only, or also for reads.