使用GDB调试组件(NASM)



我正在尝试使用GDB调试一些组件,并且有一些问题。输入GDB后,我将无法添加断点,并且文件命令似乎不起作用。确切的输出在底部。我尝试搜索答案,但似乎没有用。我正在运行Ubuntu 17.10

main.asm

section .text
global _start
_start:
    mov ecx, string
    call printStr
    exit:
    mov eax, 1
    mov ebx, 0
    int 0x80
    printStr:
    pusha
    cmp byte [ecx], 0
    je breakPrintStr
    mov eax, 4
    mov ebx, 2
    mov edx, 1
    int 0x80
    add ecx, 1
    jmp printStr
    breakPrintStr:
    popa
    ret
section .data
    string db 'Hello, World!',0xa,0

makefile

file = main
compile: $(file).asm Makefile
    nasm -g -f elf -F dwarf $(file).asm
    ld -m elf_i386 -s -o $(file) $(file).o
    rm $(file).o
    chmod +x $(file)

然后我使用

启动GDB
gdb main
(gdb) file main

导致

Reading symbols from main...(no debugging symbols found)...done.

(gdb) b _global

导致

No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n])

搜索后,我终于弄清楚了。校正后的file如下:

file = main
compile: $(file).asm Makefile
    nasm  -g -f elf -F dwarf $(file).asm
    ld -m elf_i386 -o $(file) $(file).o
    rm $(file).o
    chmod +x $(file)

最新更新