嵌入式中使用gdb
编译
Forgdb:
/path/to/gdb-src/configure --target=arm-linux-gnueabi make
ForGDBserver
../.././../gnulib/import/mbrtowc.c:125:error:'MB_CUR_MAX'undeclared(firstuseinthisfunction)
vim../gnulib/import/mbrtowc.c
#defineMB_CUR_MAX1
make
使用
onembededsystem:
onpc:
./gdb
>>targetremotetarget_ip:target_port
这时会出现错误:
错误类型:
PythonException<type'exceptions.NameError'>Installationerror:gdb.execute_unwindersfunctionismissing:
这个错误表明需要安装gdb
所以makeinstall
调试
(1)改变gdb信号处理的设置
比如,以下设置会告诉gdb在接收到SIGINT时不要停止、打印出来、传递给调试目标程序
(gdb)handleSIGINTnostopprintpass
SIGINTisusedbythedebugger.
Areyousureyouwanttochangeit?(yorn)y
SignalStopPrintPasstoprogramDescription
SIGINTNoYesYesInterrupt
(gdb)
=====================================
(2)使用gdb命令直接向调试的应用程序发送信号
首先在你希望发送信号的语句处设置断点,然后运行程序,当停止到断点所在位置后,用gdb的signal命令发送信号给调试目标程序
(gdb)signalSIGINT
ContinuingwithsignalSIGINT.
Breakpoint1,handler(signal=2)atmain.cpp:15
15printf("Signalhandler.../n";
====================================
切换线程
threadID切换当前调试的线程为指定ID的线程。
breakthread_test.c:123threadall在所有线程中相应的行上设置断点
threadapplyID1ID2command让一个或者多个线程执行GDB命令command。
threadapplyallcommand让所有被调试线程执行GDB命令command
http://blog.csdn.net/expleeve/article/details/6258175
https://sourceware.org/gdb/wiki/BuildingCrossGDBandGDBserver
http://www.cnx-software.com/2012/01/31/debugging-embedded-linux-with-gdbserver-and-insight-gdb-gui/
http://stackoverflow.com/questions/33657527/a-python-exception-error-in-gdb-7-10
https://lists.gnu.org/archive/html/bug-gnulib/2009-05/msg00268.html
http://www.cnblogs.com/xuxm2007/archive/2011/04/01/2002162.html