返回首页   进站必读


11.3.1 run(或r)

从头开始连续运行程序。
示例程序:

#include <stdio.h>

int main(int argc, char *argv[])
{
	printf("hello\n");
	printf("akaedu\n");

	reutrn 0;
}
$gcc -g main.c -o main
$gdb main
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
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 "i486-linux-gnu".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /home/xwp/main...done.
(gdb)run Starting program: /home/akaedu/main
hello
akaedu

Program exited normally.
(gdb)

11.3.2 start

开始执行程序,停在main函数第一行语句前面等待命令

(gdb)start
Temporary breakpoint 1 at 0x80483ed: file main.c, line 5.
Starting program: /home/xwp/main

Temporary breakpoint 1, main () at main.c:5
5 printf("hello\n");
(gdb)

11.3.3 quit(或q)

退出gdb调试环境。

(gdb)quit
A debugging session is active.
Inferior 1 [process 11490] will be killed.

Quit anyway? (y or n) y $