public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "simark at simark dot ca" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/27055] New: Attaching to a process in non-stop mode doesn't work
Date: Fri, 11 Dec 2020 16:38:52 +0000	[thread overview]
Message-ID: <bug-27055-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=27055

            Bug ID: 27055
           Summary: Attaching to a process in non-stop mode doesn't work
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: simark at simark dot ca
  Target Milestone: ---

The program a.out is a simple infinite loop:

#include <unistd.h>

int main() {
    for (;;) {
        sleep (5);
    }
}


Attaching to the process in non-stop mode gives this:

$ ./gdb -q -nx --data-directory=data-directory -ex "set non-stop on"
(gdb) attach 2896612
Attaching to process 2896612
No unwaited-for children left.
(gdb) i th
  Id   Target Id               Frame 
* 1    process 2896612 "a.out" 0xc856e334 in ?? ()
(gdb) bt
#0  0xc856e334 in ?? ()

The state seems a bit broken.  However, continuing and doing ^C makes GDB fall
back on its feet:

(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0xc856e334 in ?? ()
Reading symbols from /home/smarchi/build/binutils-gdb-all-targets/gdb/a.out...
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...
Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.31.so...
Reading symbols from /lib64/ld-linux-x86-64.so.2...
Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/ld-2.31.so...

Program received signal SIGINT, Interrupt.
0x00007f01c856e334 in __GI___clock_nanosleep (clock_id=<optimized out>,
clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7ffc5dbb6f70,
rem=rem@entry=0x7ffc5dbb6f70) at
../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
78      ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or
directory.
(gdb) bt
#0  0x00007f01c856e334 in __GI___clock_nanosleep (clock_id=<optimized out>,
clock_id@entry=0, 
    flags=flags@entry=0, req=req@entry=0x7ffc5dbb6f70,
rem=rem@entry=0x7ffc5dbb6f70)
    at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
#1  0x00007f01c8574047 in __GI___nanosleep (
    requested_time=requested_time@entry=0x7ffc5dbb6f70, 
    remaining=remaining@entry=0x7ffc5dbb6f70) at nanosleep.c:27
#2  0x00007f01c8573f7e in __sleep (seconds=0) at ../sysdeps/posix/sleep.c:55
#3  0x0000563bb85cb15b in main () at test.c:7


A second test is making GDB attach to a process while another one is running:

$ ./gdb -q -nx --data-directory=data-directory a.out -ex "set non-stop on" -ex
"r&" -ex "add-inferior" -ex "inferior 2"
Reading symbols from a.out...
Starting program: /home/smarchi/build/binutils-gdb-all-targets/gdb/a.out 
[New inferior 2]
Added inferior 2 on connection 1 (native)
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) attach 2896985
Attaching to process 2896985
^C^C^C^C

The attach doesn't go through and GDB doesn't respond to inputs.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2020-12-11 16:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 16:38 simark at simark dot ca [this message]
2020-12-23 16:13 ` [Bug gdb/27055] " simark at simark dot ca
2021-02-03  1:16 ` cvs-commit at gcc dot gnu.org
2021-02-03  1:36 ` palves at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27055-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).