我想使用gdb和makefile脚本演示我的程序,但make不会在gdb之后执行更多命令

时间:2014-02-19 22:51:05

标签: makefile gdb

这是我的makefile代码

all: ass3

ass3: ass3.asm
    nasm -f elf ass3.asm
    ld -m elf_i386 -s ass3.o -o demo
    echo Start debugging\n
    gdb demo
    echo Breakpoint after first case has been calculated\n
    b *0x804809e
    echo Printing 1st case answer\n
    i ecx
    echo Breakpoint after second case has been calculated\n
    b *0x80480ba
    i ecx
    echo Breakpoint on third case showing the execution path when the difference of time    is negative\n
    b *0x8048113
    echo Since Initial time is large than final time, it will jump to an error catcher\n
    r
    echo Program caught the error and terminated the program\n

binaries = demo

clean: 
    rm -f $(binaries) *~

当我键入make时,它在gdb上停止,当我按下“q”(退出)时,它只是继续执行回显,直到它停止在b * 0x804809e这是一个gdb命令

如何让我的makefile代码在gdb上运行演示?

1 个答案:

答案 0 :(得分:2)

gdb启动自己的提示,因此您无法直接与其进行交互。

它在启动后在启动时读取.gdbinit,因此您可以修改它以使其自动化。

修改:

这些问题可能会对您有所帮助:

  1. What are the best ways to automate a GDB debugging session?
  2. Where is .gdbinit is located and how can I edit it?