嵌入式中使用gdb

[b]编译[/b]
[color=darkblue]For gdb:[/color]
/path/to/gdb-src/configure --target=arm-linux-gnueabi
make


[color=darkblue]For GDBserver[/color]
[quote]/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
[/quote]

[b]使用[/b]
[color=darkblue]on embeded system:[/color]
[quote]gdbserver target_ip:target_port prog_dbg[/quote]

[color=darkblue]on pc:[/color]
[quote]cd gdb
./gdb
>>target remote target_ip:target_port
[/quote]
[color=red]这时会出现错误:
错误类型:
Python Exception <type 'exceptions.NameError'> Installation error: gdb.execute_unwinders function is missing:
这个错误表明需要安装gdb
所以make install
[/color]

[b]调试[/b]
(1)改变gdb信号处理的设置
比如,以下设置会告诉gdb在接收到SIGINT时不要停止、打印出来、传递给调试目标程序
[quote]=====================================
(gdb) [color=darkblue]handle SIGINT nostop print pass[/color]
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)
=====================================

[/quote]

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

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

[b]切换线程[/b]
[quote]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[/quote]

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值