Но я обнаружил кое-что странное.
Мой код на языке C выглядит следующим образом:
Код: Выделить всё
#include
int main(int argc, char *argv[]) {
int a = 4;
a += 3;
int b = 4;
int c = b*a;
printf("%d\n", c);
return 0;
}
Код: Выделить всё
gcc ./test.c
Код: Выделить всё
[xxx@xxxx 23:29:23 ~]
$ gdb ./a.out
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...
(No debugging symbols found in ./a.out)
(gdb) run
Starting program: /home/heyuanhong/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
28
[Inferior 1 (process 179733) exited normally]
(gdb) disassemble main
Dump of assembler code for function main:
0x0000555555555149 : endbr64
0x000055555555514d : push %rbp
0x000055555555514e : mov %rsp,%rbp
0x0000555555555151 : sub $0x20,%rsp
0x0000555555555155 : mov %edi,-0x14(%rbp)
0x0000555555555158 : mov %rsi,-0x20(%rbp)
0x000055555555515c : movl $0x4,-0xc(%rbp)
0x0000555555555163 : addl $0x3,-0xc(%rbp)
0x0000555555555167 : movl $0x4,-0x8(%rbp)
0x000055555555516e : mov -0x8(%rbp),%eax
0x0000555555555171 : imul -0xc(%rbp),%eax
0x0000555555555175 : mov %eax,-0x4(%rbp)
0x0000555555555178 : mov -0x4(%rbp),%eax
0x000055555555517b : mov %eax,%esi
0x000055555555517d : lea 0xe80(%rip),%rax # 0x555555556004
0x0000555555555184 : mov %rax,%rdi
0x0000555555555187 : mov $0x0,%eax
0x000055555555518c : call 0x555555555050
0x0000555555555191 : mov $0x0,%eax
0x0000555555555196 : leave
0x0000555555555197 : ret
End of assembler dump.
(gdb) b *0x0000555555555171
Breakpoint 1 at 0x555555555171
(gdb) x/1bx 0x0000555555555171
0x555555555171 : 0x0f
(gdb) disassemble main
Dump of assembler code for function main:
0x0000555555555149 : endbr64
0x000055555555514d : push %rbp
0x000055555555514e : mov %rsp,%rbp
0x0000555555555151 : sub $0x20,%rsp
0x0000555555555155 : mov %edi,-0x14(%rbp)
0x0000555555555158 : mov %rsi,-0x20(%rbp)
0x000055555555515c : movl $0x4,-0xc(%rbp)
0x0000555555555163 : addl $0x3,-0xc(%rbp)
0x0000555555555167 : movl $0x4,-0x8(%rbp)
0x000055555555516e : mov -0x8(%rbp),%eax
0x0000555555555171 : imul -0xc(%rbp),%eax
0x0000555555555175 : mov %eax,-0x4(%rbp)
0x0000555555555178 : mov -0x4(%rbp),%eax
0x000055555555517b : mov %eax,%esi
0x000055555555517d : lea 0xe80(%rip),%rax # 0x555555556004
0x0000555555555184 : mov %rax,%rdi
0x0000555555555187 : mov $0x0,%eax
0x000055555555518c : call 0x555555555050
0x0000555555555191 : mov $0x0,%eax
0x0000555555555196 : leave
0x0000555555555197 : ret
End of assembler dump.
мой вопрос: почему после создания точки останова по адресу 0x0000555555555171 ( imul - 0xc(%rbp),%eax), инструкция int 3(код операции: 0xcc) не отображается?
Я думаю, адрес 0x0000555555555171 должен быть 0xcc, потому что я только что установил точку останова, а не достиг точки останова.
Моя ОС — Ubuntu 22.04, версия gcc — 11.4.0, процессор — Intel(R) Core(TM) i9-14900KF
Подробнее здесь: https://stackoverflow.com/questions/790 ... nstruction
Мобильная версия