LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 5535|回复: 2

怎么样用gdb attach调试一个进程?

[复制链接]
发表于 2006-1-2 15:35:05 | 显示全部楼层 |阅读模式
我试了几次都不成功
  1. [leo@leo ~]$ gdb
  2. GNU gdb 6.2
  3. Copyright 2004 Free Software Foundation, Inc.
  4. GDB is free software, covered by the GNU General Public License, and you are
  5. welcome to change it and/or distribute copies of it under certain conditions.
  6. Type "show copying" to see the conditions.
  7. There is absolutely no warranty for GDB.  Type "show warranty" for details.
  8. This GDB was configured as "i686-pc-linux-gnu".
  9. (gdb) attach 10433
  10. Attaching to process 10433
  11. Reading symbols from /mnt/share/tmp/Research/fceu/src/fceu...done.
  12. Using host libthread_db library "/lib/libthread_db.so.1".
  13. Reading symbols from /lib/libz.so.1...done.
  14. Loaded symbols for /lib/libz.so.1
  15. Reading symbols from /usr/lib/libSDL-1.2.so.0...done.
  16. Loaded symbols for /usr/lib/libSDL-1.2.so.0
  17. Reading symbols from /lib/libpthread.so.0...done.
  18. [Thread debugging using libthread_db enabled]
  19. [New Thread -1213580864 (LWP 10433)]
  20. Loaded symbols for /lib/libpthread.so.0
  21. Reading symbols from /lib/libc.so.6...done.
  22. Loaded symbols for /lib/libc.so.6
  23. Reading symbols from /lib/libm.so.6...done.
  24. Loaded symbols for /lib/libm.so.6
  25. Reading symbols from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5...done.
  26. Loaded symbols for /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5
  27. Reading symbols from /lib/libdl.so.2...done.
  28. Loaded symbols for /lib/libdl.so.2
  29. Reading symbols from /usr/lib/libasound.so.2...done.
  30. Loaded symbols for /usr/lib/libasound.so.2
  31. Reading symbols from /usr/lib/libX11.so.6...done.
  32. Loaded symbols for /usr/lib/libX11.so.6
  33. Reading symbols from /usr/lib/libXext.so.6...done.
  34. Loaded symbols for /usr/lib/libXext.so.6
  35. Reading symbols from /usr/lib/libvga.so.1...done.
  36. Loaded symbols for /usr/lib/libvga.so.1
  37. Reading symbols from /lib/ld-linux.so.2...done.
  38. Loaded symbols for /lib/ld-linux.so.2
  39. Reading symbols from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libgcc_s.so.1...done.
  40. Loaded symbols for /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libgcc_s.so.1
  41. Reading symbols from /usr/lib/libXcursor.so.1.0.2...done.
  42. Loaded symbols for /usr/lib/libXcursor.so.1.0.2
  43. Reading symbols from /usr/lib/libXrender.so.1...done.
  44. Loaded symbols for /usr/lib/libXrender.so.1
  45. Reading symbols from /usr/lib/X11/locale/lib/common/xlcDef.so.2...done.
  46. Loaded symbols for /usr/lib/X11/locale/lib/common/xlcDef.so.2
  47. 0xffffe410 in ?? ()
  48. (gdb) l
  49. 357     
  50. 358      return(0);
  51. 359     }
  52. 360     
  53. 361     #ifdef EXTGUI
  54. 362     int FCEUSDLmain(int argc, char *argv[])
  55. 363     #else
  56. 364     int main(int argc, char *argv[])
  57. 365     #endif
  58. 366     {
  59. (gdb) s
  60. Cannot find bounds of current function
  61. (gdb)
  62. Cannot find bounds of current function
  63. (gdb) s
  64. Cannot find bounds of current function
  65. (gdb) n
  66. Cannot find bounds of current function
  67. (gdb)
复制代码
被attach的进程是停止执行了,可是用s,n等命令都不行
可是gdb的info里明明写着
  1. You can examine and modify an attached process with [color="Magenta"]all[/color] the GDB commands that are ordinarily available when you start processes with `run'.
复制代码
发表于 2006-1-3 12:11:24 | 显示全部楼层
试了一下,如果给你的被attach的进程设一个断点(breakpoint)则可以调试
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-1-3 19:39:21 | 显示全部楼层
怎么设置断点啊?
我bt了一下,结果发现运行到共享库里去了,难怪n和s都不行呢
但是还是不知道该怎么办
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表