NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/51069: gdb says "Couldn't get registers: No such process"

>Number:         51069
>Category:       bin
>Synopsis:       gdb says "Couldn't get registers: No such process"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 14 13:45:00 +0000 2016
>Originator:     Andreas Gustafsson
>Release:        NetBSD 7.0

System: NetBSD
Architecture: x86_64
Machine: amd64

When debugging a threaded program, gdb prints the error message
"Couldn't get registers: No such process." and the obvious ways of
continuing execution (cont, step, next...) don't work.

This seems to happen whenever the currently selected thread exits.
On another operating system I tried, gdb automatically switches to a
different thread when the current thread exits, but on NetBSD it
just gets stuck as described above.

It is possible to recover by issuing the command "info threads" and
then manually selecting one of the threads with "thread 1"
(substituting a valid thread number for the "1" as needed), but
this is only temporary because when that thread exits in turn,
the problem recurs.


$ cat test.c
#include <pthread.h>
#include <stdio.h>
void *start(void *arg) {
    puts("Hello, thread");
int main(int argc, char **argv) {
    pthread_t thread;
    pthread_create(&thread, NULL, start, NULL);
    pthread_join(thread, NULL);
    puts("Hello, main");
    return 0;
$ gcc -g test.c -lpthread -o test
$ gdb ./test
GNU gdb (GDB) 7.7.1
Reading symbols from ./test...done.
(gdb) break puts
Breakpoint 1 at 0x400830
(gdb) run
Starting program: /usr/s/u/gson/bugs/netbsd/gdb.threadexit/test 
[New LWP 2]
[Switching to LWP 2]

Breakpoint 1, puts (s=0x400b48 "Hello, thread") at /bracket/prod/7.0gson1/src/lib/libc/stdio/puts.c:57
57      /bracket/prod/7.0gson1/src/lib/libc/stdio/puts.c: No such file or directory.
(gdb) cont
Hello, thread
[Switching to LWP 1]
Couldn't get registers: No such process.
(gdb) cont
Couldn't get registers: No such process.
(gdb) step
Couldn't get registers: No such process.
(gdb) next
Couldn't get registers: No such process.

The expected behavior is that when the first "cont" command is issued,
execution continues until the breakpoint in puts() is hit a second time,
in the call from 'puts("Hello, main");'.



Home | Main Index | Thread Index | Old Index