在GDB中,如何找出谁在堆上的地址? [英] In GDB, how to find out who malloc'ed an address on the heap?

查看:191
本文介绍了在GDB中,如何找出谁在堆上的地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GDB中有一个指针,如何找到它在堆上首先分配的位置?



在WinDBG中,这可以通过!heap -p -a< 0x12345678> 在打开 gflags / i< * exe>因为Valgrind可以告诉我内存被分配的位置(当它检测到一些泄漏时),我猜这也是可以的?



/ p>

(这不是关于观察点,这是给我的情况,我随机地进入In GDB,应用程序,看一个指针,想知道谁创建了这个的记忆?)






在GDB中使用反向调试是一种非常新颖的方式,可能是正确的方式来解决这个问题。使用GDB 7.1 - 最新的稳定版本,我遇到了一些问题。反向调试在GDB中是一个相当新的功能,所以我需要查看HEAD(7.2)来修复它。



它可能会说出一些关于GDB方法的成熟性,我觉得当它更成熟时肯定会被使用。 (Awesome功能!)

解决方案

Valgrind劫持内存管理调用,这就是堆检查器的工作原理。在GDB本身没有任何设施可以告诉您 malloc(3)返回的地址。我建议研究 mtrace glibc分配调试


I have a pointer in GDB, how can I find out where it was first allocated on the heap?

In WinDBG, this can be done by !heap -p -a <0x12345678> after turning on gflags /i <*exe> +ust

Since Valgrind can tell me where the memory is allocated (when it detects some leaks), I guess this is also possible?

(This is NOT about watchpoint. This is given the situation where I randomly break into the In GDB, application, look at a pointer and want to know "who created this piece of memory"?)


Using reverse debugging in GDB is a very novel way and probably the correct way to solve this problem. I encountered some problem with that approach with GDB 7.1 -- the latest stable version. Reverse debugging is a rather new feature in GDB so I needed to check out HEAD (7.2) to fix it.

It probably says something about the matureness of the GDB approach but I think it should definitely be used when it's more mature. (Awesome feature!)

解决方案

Valgrind hijacks memory management calls, that's how heap checkers work. There's no facility in GDB itself to tell you where given address was returned by malloc(3). I suggest looking into mtrace and glibc allocation debugging.

这篇关于在GDB中,如何找出谁在堆上的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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