2.1.1 Choosing Files

本文详细介绍了GDB调试器的命令行参数使用方法,包括如何指定执行文件、core文件及进程ID等,并解释了不同选项如-symbolsfile、-execfile、-corefile和-commandfile的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

2.1.1 Choosing Files

      一旦gdb启动,可以读到任何任何参数而非选项像指定一个执行文件,core文件或者进程ID.这跟参数被"-se","-c" 或者"-p"选项分别指定了一样 (gdb读到的第一没有关联选项的参数视为跟"-se"选项之后的参数。第二个没有选项的参数,可以视为紧跟"-c"或者"-p"的参数)。如果第二个参数以数字开头,gdb首先把它作为一个进程号去关联,如果失败,则尝试作为一个core文件去打开。如果你有一个以数字开头的core文件,你可以加上选项来避免误认为进程号。

 

     如果gdb没有设置成支持 core,比如绝大数的嵌入式目标,则会抱怨第二个参数并且忽略它。许多选项都有长和短的形式,我们均列在下面的列表中。你截取长格式的选项,gdb是可以识别的,只要所代表的选项不模糊。(推荐,flag选项参数以"--" 开始,而不用“-”开始)。

-symbols file -s file         从file 文件中读取symbol table. -exec file -e file           用file作为可执行文件去执行,在core dump协助下检查纯数据。 -se file
从file读取 symbol table,并把file作为可执行文件
-core file -c file          file作为core dump去检查
-pid number -p number
链接到进程 number .
-command file -x file
从file中执行命令 . 这个文件的内容被认为源命令。可以参见 See Command files.
-eval-command command -ex command
执行单个 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




     

-directory directory -d directory
Add directory to the path to search for source and script files.
-r -readnow
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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值