gpt4 book ai didi

c - gdb 查找行号的内存地址

转载 作者:IT王子 更新时间:2023-10-29 00:24:10 25 4
gpt4 key购买 nike

假设我已经将 gdb 附加到一个进程,并且在它的内存布局中有一个文件和行号,我想要它的内存地址。如何获取文件x中第n行的内存地址?这是在 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,您可以使用来自 Symbol-Tables-In-Python这目前需要来自 cvs 的最新版本的 gdb,但我想将在 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

关于c - gdb 查找行号的内存地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11287188/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com