`

嵌入式中使用gdb

 
阅读更多
编译
For gdb:
/path/to/gdb-src/configure --target=arm-linux-gnueabi
make


For GDBserver
引用
/path/to/gdb-src/gdb/gdbserver/configure --host=arm-linux-gnueabi
../.././../gnulib/import/mbrtowc.c:125: error: 'MB_CUR_MAX' undeclared (first use in this function)
vim ../gnulib/import/mbrtowc.c
#define MB_CUR_MAX 1
make


使用
on embeded system:
引用
gdbserver target_ip:target_port prog_dbg


on pc:
引用
cd gdb
./gdb
>>target remote target_ip:target_port

这时会出现错误:
错误类型:
Python Exception <type 'exceptions.NameError'> Installation error: gdb.execute_unwinders function is missing:
这个错误表明需要安装gdb
所以make install


调试
(1)改变gdb信号处理的设置
比如,以下设置会告诉gdb在接收到SIGINT时不要停止、打印出来、传递给调试目标程序
引用
=====================================
(gdb) handle SIGINT nostop print pass
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) y

Signal Stop Print Pass to program Description
SIGINT No Yes Yes Interrupt
(gdb)
=====================================



(2)使用gdb命令直接向调试的应用程序发送信号
首先在你希望发送信号的语句处设置断点,然后运行程序,当停止到断点所在位置后,用gdb的signal命令发送信号给调试目标程序
引用
====================================
(gdb) signal SIGINT
Continuing with signal SIGINT.

Breakpoint 1, handler (signal=2) at main.cpp:15
15 printf("Signal handler.../n";
====================================


切换线程
引用
info threads 显示当前可调试的所有线程,每个线程会有一个GDB为其分配的ID,后面操作线程的时候会用到这个ID。 前面有*的是当前调试的线程。

thread ID 切换当前调试的线程为指定ID的线程。

break thread_test.c:123 thread all 在所有线程中相应的行上设置断点

thread apply ID1 ID2 command 让一个或者多个线程执行GDB命令command。

thread apply all command 让所有被调试线程执行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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics