gdb的出错消息

一直以来,运行gdb,之后输入 attach <PID>,会收到一些错误消息:
> gdb
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB.  Type “show warranty” for details.
This GDB was configured as “i386-marcel-freebsd”.
(gdb) attach 7590
Attaching to process 7590
/usr/src/gnu/usr.bin/gdb/libgdb/../../../../contrib/gdb/gdb/solib-svr4.c:1443: internal-error: legacy_fetch_link_map_offsets called without legacy link_map support enabled.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n

/usr/src/gnu/usr.bin/gdb/libgdb/../../../../contrib/gdb/gdb/solib-svr4.c:1443: internal-error: legacy_fetch_link_map_offsets called without legacy link_map support enabled.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n
Reading symbols from /usr/local/kde4/bin/dolphin…(no debugging symbols found)…done.
….
Loaded symbols for /usr/local/kde4/lib/libkfontinst.so.5
Reading symbols from /libexec/ld-elf.so.1…done.
Loaded symbols for /libexec/ld-elf.so.1
[Switching to Thread 0x2dd6b260 (LWP 100239)]
0x29be3243 in select () from /lib/libc.so.7
(gdb)
一直也不知道是什么道理…… 今天去网上查,终于看见一个说法:
需要attach的话,只能运行 gdb -p <PID> <exec file>
也就是说,要提供原来的可执行文件,才能attach到一个现有process……
我试了一下,的确好了:
> gdb -p 7590 /usr/local/kde4/bin/dolphin
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB.  Type “show warranty” for details.
This GDB was configured as “i386-marcel-freebsd”…(no debugging symbols found)…
Attaching to program: /usr/local/kde4/bin/dolphin, process 7590
Reading symbols from /usr/local/kde4/lib/libkio.so.7…(no debugging symbols found)…done.
Loaded symbols for /usr/local/kde4/lib/libkio.so.7
……
Reading symbols from /libexec/ld-elf.so.1…done.
Loaded symbols for /libexec/ld-elf.so.1
[Switching to Thread 0x2dd6b260 (LWP 100239)]
0x29be3243 in select () from /lib/libc.so.7
(gdb)
貌似这个问题,在GDB里面很早就修正了。FreeBSD随系统自带的GDB还是6.1.1,ports里倒是提供了一个6.6,但是不支持调试多线程的程序…… 不知道啥时候这个事情能够解决……

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.