当前位置: 技术问答>linux和unix
gdb 调试多线程程序 断点处不停止
来源: 互联网 发布时间:2017-05-29
本文导语: 本帖最后由 bytxl 于 2014-09-02 18:28:35 编辑 系统中一个deamon程序,/lib下存在libpthread-2.6.1.so 现在要用gdb调试这个程序,上传libthread_db-1.0.so到/lib下,修改权限777 $ sudo ldconfig 重启该deamon,开始调试 $ gdb test `pidof test` -...
现在要用gdb调试这个程序,上传libthread_db-1.0.so到/lib下,修改权限777
$ sudo ldconfig
重启该deamon,开始调试
$ gdb test `pidof test` -d ~/code
可以看到如下信息(部分省略),说明成功attach到该deamon,并且可以调试多线程:
GNU gdb 6.7.1
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
Attaching to program: /test, process 12813
......
Reading symbols from /lib/libpthread.so.0...done.
[Thread debugging using libthread_db enabled]
[New Thread 0xb610caf0 (LWP 12813)]
......
然后在程序中打上断点,c继续运行,在界面触发该断点所在功能,出现如下类似信息:
[Switching to Thread 0xb4f09b90 (LWP 12820)]
Breakpoint 1, login_handle (r=0xb4f0930c) at handle.c:235
235 char *psz_username = NULL;
(gdb)
Continuing.
没有在断点处停止,只是显示了一下断点的信息,然后就Continuing了(上面不是本人使用命令c继续运行的),请牛人指教原因
(另附:几周前还是可以正常调试的,昨天到今天,突然不能这么调试了。本人检查过代码,跟该deamon程序应该是一样的)
|
are u sure the daemon has the same code base as you indicated on the command line to gdb?
did you do any optimization during compilation?
did u try to set breakpoint on the function name instead of a line inside the function?
is this function running in a child process?
did you do any optimization during compilation?
did u try to set breakpoint on the function name instead of a line inside the function?
is this function running in a child process?
|
多进程 一直用的printf.......