2.1.1 Choosing Files
一旦gdb启动,可以读到任何任何参数而非选项像指定一个执行文件,core文件或者进程ID.这跟参数被"-se","-c" 或者"-p"选项分别指定了一样 (gdb读到的第一没有关联选项的参数视为跟"-se"选项之后的参数。第二个没有选项的参数,可以视为紧跟"-c"或者"-p"的参数)。如果第二个参数以数字开头,gdb首先把它作为一个进程号去关联,如果失败,则尝试作为一个core文件去打开。如果你有一个以数字开头的core文件,你可以加上选项来避免误认为进程号。
如果gdb没有设置成支持 core,比如绝大数的嵌入式目标,则会抱怨第二个参数并且忽略它。许多选项都有长和短的形式,我们均列在下面的列表中。你截取长格式的选项,gdb是可以识别的,只要所代表的选项不模糊。(推荐,flag选项参数以"--" 开始,而不用“-”开始)。
-
从file读取 symbol table,并把file作为可执行文件
-
链接到进程
number .
-
从file中执行命令
. 这个文件的内容被认为源命令。可以参见 See
Command files.
-
执行单个 gdb命令Execute a single
gdb command.
This option may be used multiple times to call multiple commands. It mayalso be interleaved with `-command' as required.
gdb -ex 'target sim' -ex 'load' / -x setbreakpoints -ex 'run' a.out
-
Add
directory to the path to search for source and script files.
- Read each symbol file's entire symbol table immediately, rather thanthe default, which is to read it incrementally as it is needed. This makes startup slower, but makes future operations faster.
-symbols
file
-s
file
从file 文件中读取symbol table.
-exec
file
-e
file
用file作为可执行文件去执行,在core dump协助下检查纯数据。
-se
file
-core
file
-c
file
file作为core dump去检查
-pid
number
-p
number
-command
file
-x
file
-eval-command
command
-ex
command
-directory
directory
-d
directory
-r
-readnow