Groups
Groups
Sign in
Groups
Groups
嵌入式linux
Conversations
About
Send feedback
Help
gdb 使用 core dump 调试
4 views
Skip to first unread message
stan8688
unread,
May 5, 2008, 9:32:18 PM
5/5/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 嵌入式linux
在linux环境下调试多线程,总觉得不像.NET那么方便。这几天就为找一个死锁的bug折腾好久,介绍一下用过的方法吧。
多线程如果dump,多为段错误,一般都涉及内存非法读写。可以这样处理,使用下面的命令打开系统开关,让其可以在死掉的时候生成core文件。
ulimit -c unlimited
这样的话死掉的时候就可以在当前目录看到core.pid(pid为进程号)的文件。接着使用gdb:
gdb ./bin ./core.pid
进去后,使用bt查看死掉时栈的情况,在使用frame命令。
还有就是里面某个线程停住,也没死,这种情况一般就是死锁或者涉及消息接受的超时问题(听人说的,没有遇到过)。遇到这种情况,可以使用:
gcore pid (调试进程的pid号)
手动生成core文件,在使用pstack(linux下好像不好使)查看堆栈的情况。如果都看不出来,就仔细查看代码,看看是不是在
if,return,break,continue这种语句操作是忘记解锁,还有嵌套锁的问题,都需要分析清楚了。
最后,说一句,静心看代码,捶胸顿足是没有用的。
Reply all
Reply to author
Forward
0 new messages