带ptrace的内存调试器 [英] Memory debugger with ptrace

查看:135
本文介绍了带ptrace的内存调试器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用内存调试器的功能(只是泄漏检测)来扩展现有的工具.

I would like to expand an existing tool with the functionality of a memory debugger (just leak detection).

我知道一些内存调试器可以通过替换malloc/free并跟踪待释放的内容和分配者来工作.或者通过在某种虚拟机上运行该进程并监视内存访问来实现.

I know that some memory debuggers work by replacing malloc/free and keeping track of what is pending to be freed and who allocated it; or by running the process on sort of a virtual machine and monitoring memory accesses.

我想知道使用ptrace()在malloc/free上设置断点是否有意义,例如,使用 dmalloc 进行重建,并在一个单独的进程中监视分配.会不会太慢?还有其他工具可以这样工作吗?

I want to know if it makes sense to use ptrace() to set breakpoints on malloc/free, instead rebuilding with dmalloc for example, and monitoring allocations in a separate process. Would it be too slow? Does any other tool work this way?

推荐答案

使用调试器并捕获malloc/free调用是不切实际的,原因如下:

It is not practical to use a debugger and trap malloc/free calls for a few of reasons:

  1. 从一个简单的程序到另一个程序的切换开销很大.

  1. The overhead of switching from one process to the other one is just to great on nontrivial programs.

与其他方法相比,您最终将花费相似数量的内存来存储所有权信息. (这是我实际上想要改进的地方)

You'll end up spending a similar amount of memory to store ownership information than with other methods. (This is what I actually wanted to improve)

有很多函数可以工作堆,很容易错过一些函数.

There are quite a few functions that work the heap, and it could be easy to miss some.

这篇关于带ptrace的内存调试器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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