gdb查找行号的内存地址 [英] gdb find memory address of line number

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

问题描述

说我已经将gdb附加到一个进程,并且在其内存布局中有一个文件和行号,我想要它的内存地址.如何获取文件x中第n行的内存地址?这是在Linux x86上.

Say I have attached gdb to a process and within the its memory layout there is a file and line number which I would like the memory address of. How can I get the memory address of line n in file x? This is on Linux x86.

推荐答案

(gdb) info line test.c:56
Line 56 of "test.c" starts at address 0x4005ae <main+37>
   and ends at 0x4005ba <main+49>.

此外,您还可以使用python中的'last'属性 Symbol-Tables-In-Python 目前,这需要cvs的gdb的最新版本,但我想它将在7.5中具有一般可用性

additionally with python you may be able to use the 'last' attribute from Symbol-Tables-In-Python this currently requires a very recent version of gdb from cvs, but i imagine will have general availability in 7.5

(gdb) py x = gdb.find_pc_line(gdb.decode_line("test.c:56")[1][0].pc); gdb.execute("p/x " + str(x.pc)); gdb.execute("p/x " + str(x.last))
$15 = 0x4005ae
$16 = 0x4005b9

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

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