GDB报错 Don‘t know how to run. Try “help target“.

初次使用GDB调试工具,从编译到运行,跳了不少坑。明明照着命令格式,敲下去的命令,总是报错。

比如:

# /tmp/mipsel-linux-gdb                                                         
GNU gdb (GDB) 7.12.1                                                            
Copyright (C) 2017 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 "--host=mipsel-linux --target=mipsel-buildroot-linux-
gnu".                                                                           
Type "show configuration" for configuration details.                            
For bug reporting instructions, please see:                                     
<http://www.gnu.org/software/gdb/bugs/>.                                        
Find the GDB manual and other documentation resources online at:                
<http://www.gnu.org/software/gdb/documentation/>.                               
For help, type "help".                                                          
Type "apropos word" to search for commands related to "word".                                                      
(gdb) file /usr/bin/utelnetd                                                    
Reading symbols from /usr/bin/utelnetd...(no debugging symbols found)...done.   
(gdb) run                                                                       
Don't know how to run.  Try "help target". 

网上搜索出来的答案,总结下就是需要配置要调试的target ip,开发板上运行gdb server,PC运行gdb。

但是,问号脸??我就是在调试设备上运行gdb,为啥是远程gdb?

真相很简单,编译gdb的时候,--target参数指定错误。

下面是我的gdb编译指令:

./configure --host=mipsel-linux --target=mipsel-buildroot-linux-gnu-gcc --prefix=/home/usr/gateway/install --program-prefix=mipsel-linux- --disable-build-warnings
make CC=mipsel-buildroot-linux-gnu-gcc AR=mipsel-buildroot-linux-gnu-ar LD=mipsel-buildroot-linux-gnu-ld
make install

编译报错:

checking target system type... Invalid configuration `mipsel-buildroot-linux-gnu-gcc': machine `mipsel-buildroot-linux-gnu' not recognized

configure: error: /bin/sh ./config.sub mipsel-buildroot-linux-gnu-gcc failed

make: *** [gdb] Error 1

原因是config.sub中有一个检查

# Object if more than one company name word.

            *-*-*)

                        echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2

                        exit 1

研究了一会儿gdb的makefile,--target改成了这样:

--target=mipsel-buildroot-linux-gnu

这里跳过后面遇到的其他编译问题,最后完成了编译。

开开心心的加载新出炉的mipsel-linux-gdb,一执行就遇到:

(gdb) attach 6177                                                               
Don't know how to attach.  Try "help target".   

或者

(gdb) r                                                                         
Don't know how to run.  Try "help target". 

仔细核对自己指令和参数,没毛病啊。。

试了网上说的各种方法命令,最后想了想。编译时,会指定--host和--target,host好理解,target是啥?答案请另百度。

抱着试一试的想法,又改成了这样

--target=mipsel-linux

编译通过,加载,执行,成功~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值