我试图远程debugging使用GDB。 在目标计算机上(使用Ubuntu Mate 15.10的Raspberry Pi),我运行gdbserver :4444 main
。 在我的笔记本电脑上,运行./arm-linux-gnueabihf-gdb ~/workspace/piCCompileProj/Debug/main
。 在gdb提示符下(在我的笔记本电脑上),我input:
target remote <target>:4444 run
但是gdb报告这个错误信息:
“远程”目标不支持“运行”。 尝试“帮助目标”或“继续”。
我如何使用gdb remote? 当我直接在Raspberry Pi上使用gdb时,它按预期运行。
我找到解决我的问题。
如果我在我的PI上运行gdbserver :4444 main
,那么主程序将启动并且不需要在gdb中run
命令。 要完全控制gdb我在PI gdbserver --multi :4444
使用gdbserver --multi :4444
一个可以在本地PC中使用命令: ./arm-linux-gnueabihf-gdb -x /path/init
其中./arm-linux-gnueabihf-gdb -x /path/init
的内容文件是:
symbol-file /home/username/workspace/piCCompileProj/Debug/main target extended-remote 192.168.0.100:4444 set remote exec-file /home/username/cppSandbox/main
这是什么帮助我(如果有任何初学者在这里寻找解决方案)
假设 : Ubuntu(17.04) – > Host & Raspberry Pi(Model-3b) – > Target ,我的可执行文件(.o)file-> dowhile
第1步 :从主机为目标制作可执行文件(.o)文件。 请找到以下命令:
arm-linux-gnueabihf-gcc -g dowhile.c -o dowhile
请下载相应的库以成功运行此命令。
第2步 :将生成的可执行文件(dowhile.o)复制到目标机器,如下所示:
scp dowhile root@10.xyz:/xxxx/yyyy/
(请根据您的目标和来源填写x和y的详细信息)
另外,检查复制的可执行文件是否正常工作:
./dowhile
第3步 :在目标机器上运行gdbserver
:
gdbserver localhost:2000 dowhile
(保留2000或任何您的端口号码,它将无论如何将工作)
第4步 :在主机上运行gdb
:
gdb-multiarch dowhile
步骤5 :将架构设置为arm
(gdb) set architecture armv5te
第6步 :远程连接目标
(gdb) target remote 10.xyz:2000
你完成了:)
快乐调试!