在GDB中获取地址和硬币

在GDB中获取地址和硬币,gdb,Gdb,我在ASM(NASM)中有一个程序,我想获得一个地址,但在我用GDB调试时发生了一些奇怪的错误(我键入了“next”,程序退出)。GDB中有一些bug吗 test.asm BITS 32 section .text global _start _start: call function mov eax,0x41414141 function: # esi get the address of "mov eax,0x41414141" pop esi # Exit xor eax,ea

我在ASM(NASM)中有一个程序,我想获得一个地址,但在我用GDB调试时发生了一些奇怪的错误(我键入了“next”,程序退出)。GDB中有一些bug吗

test.asm

BITS 32

section .text
global _start

_start:
call function
mov eax,0x41414141



function:
# esi get the address of "mov eax,0x41414141"
pop esi

# Exit
xor eax,eax
xor ebx,ebx
mov al,0x01
int 0x80
调试

$ nasm  -f elf test.asm
$ ld test.o -o test
$ gdb -q ./test
Reading symbols from /root/Desktop/test...(no debugging symbols found)...done.
(gdb) info functions
All defined functions:

Non-debugging symbols:
0x08048060  _start
0x0804806a  function
(gdb) b function
Breakpoint 1 at 0x804806a
(gdb) run # Execute _start
Starting program: /root/Desktop/test 

Breakpoint 1, 0x0804806a in function ()
(gdb) # We're going to execute "pop esi" now
(gdb) next # Execute only 1 instruction
Single stepping until exit from function function,
which has no line number information.
[Inferior 1 (process 26492) exited normally]
# WHY EXIT? We was going to execute "pop esi" !!
您使用了“next”,它告诉gdb执行源代码级步骤(移动到源代码中的下一行)。由于您没有构建包含调试信息的可执行文件,gdb不知道如何执行此操作。 有两种解决方案:

  • 启用调试信息的生成。我不知道nasm,但它似乎使用了常用的-g开关来启用调试信息。组装时添加此项
  • 在gdb中使用nexti。这将只执行下一条汇编指令,而不关心源代码