Gdb can't detach from a program that's linked with libc_r. It gives the message "ptrace: No such process". The same program linked with libc can be attached/detached fine. The only way to quit gdb is to kill it. By sprinkling the code with printf()s it looks like variable `inferior_pid' (which is passed to ptrace() when detaching) is getting changed. For example, it'll go from say 41694 -> 172766. I tracked it down to a location in gnu/usr.bin/binutils/gdb/freebsd-uthread.c line 429: inferior_pid = find_active_thread (); Unfortunately, after that point it's over my head so I can't really figure out where it's going wrong. Fix: Don't know. How-To-Repeat: Compile the following program: main(){ printf("pid: %d\n", getpid()); while(1) sleep(1); } twice with: gcc -o test1 test.c gcc -o test2 test.c -pthread and try attaching/detaching from it, the first one will succeed, the second won't.
Responsible Changed From-To: freebsd-bugs->mp Over to maintainer.
This is also trivial to fix. child_ops won't recognize the pid of thread, so it has to be set to default pid. diff -c /usr/src/gnu/usr.bin/binutils/gdb/freebsd-uthread.c.bak /usr/src/gnu/usr.bin/binutils/gdb/freebsd-uthread.c *** /usr/src/gnu/usr.bin/binutils/gdb/freebsd-uthread.c.bakSat Jan 12 16:35:14 2002 --- /usr/src/gnu/usr.bin/binutils/gdb/freebsd-uthread.c Sat Feb 9 16:56:54 2002 *************** *** 452,457 **** --- 452,462 ---- char *args; int from_tty; { + struct cleanup *old_chain; + old_chain = save_inferior_pid (); + + inferior_pid = main_pid; + child_ops.to_detach (args, from_tty); } ========================================================================= For RAIDANT status see: http://cranford.eng.netapp.com:8015/ant3/index.cgi To submit RAIDANT test descriptions go to: http://web.netapp.com/engineering/projects/raidv2/testing/ Ontap on the web: http://web.netapp.com/engineering/projects/raidv2/testing/global/
Responsible Changed From-To: mp->marcel Still has relevance with gdb6. Keep an eye on it...
State Changed From-To: open->feedback Can somebody please verify or falsify, whether this issue still exists with libthread on recent FreeBSD versions? I was able to compile the example code, but when trying to attach to it via gdb i get this error: /usr/src/gnu/usr.bin/gdb/libgdb/../../../../contrib/gdb/gdb/solib-svr4.c:1444: internal-error: legacy_fetch_link_map_offsets called without legacy link_map support enabled.
Responsible Changed From-To: marcel->freebsd-bugs Assign back to the pool. I haven't been working on it and it's unlikely I will in the near future.
State Changed From-To: feedback->open feedback is the wrong state
libc_r has gone long ago