gdb将内存地址解释为对象 [英] gdb interpret memory address as an object

查看:821
本文介绍了gdb将内存地址解释为对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调查基于可用核心转储的崩溃。应用程序崩溃是一个C ++程序,用gcc构建并在RH5上运行。回溯似乎有效,直到第1帧。尝试打印一个对象我得到
< invalid address>,< error reading variable>
因为我有对象的地址#2框架是一个有效的假设,我可以以某种方式转储的对象分配的内存,并仍然收集一些信息。此外,不是试图猜测对象如何对齐,我可以强制gdb打印地址,如果它是一个对象,即使它检测到一些错误。我的想法是,也许对象已经被删除,但也许内存仍然存在,我可以打印一些成员变量。

I am investigating a crash, based on the available core dump. The application crashing is a C++ program, built with gcc and running on RH5. The backtrace seems valid till the #1 frame. There trying to print an object I get <invalid address>, <error reading variable> Since I have the address of the object from the #2 frame is it a valid presumption that I can somehow 'dump' the memory in which the object is allocated and still collect some info. Furthermore, instead of trying to guess how the object is aligned, can I force gdb to print the address as if it is an object, even though it detects some error. My idea is that maybe the object has already been deleted, but just maybe the memory is still there and I can print some member variable.

请注释是否可能,如果可能,应如何在gdb术语中执行。 10x。

Please comment on is that possible, and if so, how it should be done in gdb terms. 10x.

推荐答案

好吧,如果你有地址,你总是可以做:

Well, if you have an address you can always do:

print *(class MyClass *)pointer_var

这篇关于gdb将内存地址解释为对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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