这是否总是GDB调试程序的地址? [英] Is this always the address for GDB debug program?
问题描述
我会缩小我的问题:
GDB中的入口地址对于同一个程序保持不变(甚至在重新引导和重写源代码之后)。
为什么会这样呢?
例如, 0x80483f4 是起始地址。
** 0x80483f4 **< main()> push%ebp│
│0x80483f5 mov%esp,%ebp│
│0x80483f7 sub $ 0x10,%esp│
│0x80483fa< main()+ 6> movl $ 0x3,-0x4(%ebp)│
│0x8048401 movl $ 0x3,-0x8(%ebp)│
│0x8048408 mov $ 0x0,%eax│
│0x804840d< main()+ 25>离开│
│0x804840e< main()+ 26> ret
除此之外,我们得到的值,比方说 0x80483fa ,总是相同的。
$ 2 = 0x80483fa< main()+ 6>
(gdb)x $ 2
0x80483fa< main()+ 6>:0x3fc45c7
(gdb)p 0x3fc45c7
$ 3 = 66864583< - 即使在重启后也是如此。
这是什么暗示我?
我对之前的价值感兴趣,在每次赋值之后(比如稍后说c = a + b),一次不使用断点来逐步完成一行。
源代码:
int main()
{
int b = 3;
int a = 3;
返回0;
}
有人可以向我解释这个吗?谢谢。
(我也会将它标记为家庭作业,但实际上并不是这样。)
例如0x80483f4是起始地址。
这很可能。除非你有PIE(与位置无关的可执行文件),否则它将永远保持不变(对于一个二进制文件)。
$ 2 = 0x80483fa< main()+ 6>
(gdb)x $ 2
0x80483fa< main()+ 6>:0x3fc45c7
这是 main()+ 6
中指令的二进制表示形式。
$ b
(gdb)p 0x3fc45c7
$ 3 = 66864583 < - 即使重启后也是如此。
这意味着0x3fc45c7是十进制的66864583 ...
请注意,这与 a
或 b
。
顺便说一句,在赋值之前获取变量值的最好方法是在赋值之前赋值 printf
。
I will narrow down my questions:
The entry address in GDB stays the same for the same program (even after reboot, and after rewriting the source code).
Why is that?
For example 0x80483f4 is the starting address.
**0x80483f4** <main()> push %ebp │
│0x80483f5 <main()+1> mov %esp,%ebp │
│0x80483f7 <main()+3> sub $0x10,%esp │
│0x80483fa <main()+6> movl $0x3,-0x4(%ebp) │
│0x8048401 <main()+13> movl $0x3,-0x8(%ebp) │
│0x8048408 <main()+20> mov $0x0,%eax │
│0x804840d <main()+25> leave │
│0x804840e <main()+26> ret
Beside that, the value we get from, let say, 0x80483fa, is always the same.
$2 = 0x80483fa <main()+6>
(gdb) x $2
0x80483fa <main()+6>: 0x3fc45c7
(gdb) p 0x3fc45c7
$3 = 66864583 <-- even after reboot.
What does this suggest me?
I am interested in the values before and after each assignment (say c = a+b later), without using breakpoints to step through one line at a time.
The source code:
int main()
{
int b = 3;
int a = 3;
return 0;
}
Can someone please explain this to me? Thanks. (I would also mark this as homework, although it really isn't.)
For example 0x80483f4 is the starting address.
This is likely. Unless you have PIE (position independent executables), it will stay the same (for one binary) forever.
$2 = 0x80483fa <main()+6> (gdb) x $2 0x80483fa <main()+6>: 0x3fc45c7
That is the binary representation of the instructions at main()+6
. Will never change in one binary.
(gdb) p 0x3fc45c7 $3 = 66864583 <-- even after reboot.
That means 0x3fc45c7 is 66864583 in decimal...
Note that none of this has anything to do with a
or b
.
BTW the best way to get values of variables "before assignment" is to printf
them before the assignment.
这篇关于这是否总是GDB调试程序的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!