Bug 12853 - Unable to quit GDB if remote TCP connection is lost
Summary: Unable to quit GDB if remote TCP connection is lost
Status: RESOLVED WORKSFORME
Alias: None
Product: gdb
Classification: Unclassified
Component: remote (show other bugs)
Version: 7.5
: P2 normal
Target Milestone: ---
Assignee: Keith Seitz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-07 12:53 UTC by jon
Modified: 2014-05-21 23:22 UTC (History)
3 users (show)

See Also:
Host: windows 7 / cygwin / linux
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jon 2011-06-07 12:53:43 UTC
If using a TCP remote connection (E.g. tar ext localhost:1234), if the target connection is lost for some reason, it is no longer possible to quit GDB.

(gdb) quit
A debugging session is active.

        Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) y
putpkt: write failed: Connection reset by peer.
(gdb)

i.e. you get the putpkt error message, and then get returned to the prompt.

Pressing ctrl-c several times just results in:

(gdb) Quit
(gdb) Quit
(gdb) Quit...

being printed.

This is occuring on a Windows 7 64-bit / Cygwin system.
Comment 1 Keith Seitz 2011-11-14 22:08:14 UTC
I cannot reproduce with the 7.3 branch (7.3.1-20111104-cvs) or CVS HEAD. I've tried this on cygwin, too (Windows 2008 Server):

SHELL A:
$ gdbserver :1234 foo
Process foo created; pid = 1936
Listening on port 1234

SHELL B:
$ gdb -nx -q foo
(gdb) b main
Breakpoint 1 at 0x401196: file foo.c, line 6.
(gdb) tar remote :1234
Remote debugging using :1243
warning: Can not parse target XML description; XML support was disabled at compile time
warning: Can not parser XML library list; XML support was disabled at compile time
0x775e0005 in ?? ()
(gdb) c
Breakpoint 1, main () at foo.c:6
6   return 0;
(gdb)

SHELL C:
$ ps waux | grep gdbserver | kill `awk '{print $1}'`

SHELL B:
(gdb) quit
A debugging session is active.

     Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) y
qTStatus: remote connection closed
$ 

Can you verify any of this or provide me with a test that demonstrates the problem better?
Comment 2 Keith Seitz 2012-08-28 16:44:39 UTC
It's almost ten months. This still works, as described, on CVS HEAD (7.5.50.20120828-cvs) and the 7.5 branch. I'm closing this bug.
Comment 3 Jan Smets 2014-05-21 11:50:47 UTC
Can someone please re-investigate? I'm having the same issue with 7.5

1) connect to a remote target
2) attach to a process
3) disconnect/reset the remote target
4) watch the timeout
5) try detaching or quit gdb

(gdb) attach 165209617
Attaching to process 165209617
[New Thread 165209617.165209617]
0x07ab29bc in __memPoolInit ()
(gdb) c
Continuing.
^C
[Thread 165209617.165209617] #1 stopped.
0x07ab29bc in __memPoolInit ()
Ignoring packet error, continuing...
Stopping Thread 165209617.165209617 failed: timeout
(gdb) Ignoring packet error, continuing...
Stopping Thread 165209617.165209617 failed: timeout
(gdb) (gdb)
Continuing.
Cannot execute this command while the selected thread is running.
(gdb) 
(gdb) exit
Undefined command: "exit".  Try "help".
(gdb) quit
A debugging session is active.

        Inferior 1 [process 165209617] will be detached.

Quit anyway? (y or n) y

Ignoring packet error, continuing...
Bogus trace status reply from target: timeout
(gdb) 
A debugging session is active.

        Inferior 1 [process 165209617] will be detached.
.... (can't get out of GDB!!)
Comment 4 Pedro Alves 2014-05-21 23:22:57 UTC
(In reply to Jan Smets from comment #3)
> Can someone please re-investigate? I'm having the same issue with 7.5

You'll most probably need a more recent GDB.

Keith mentioned 7.5.50.20120828-cvs
(future 7.6), and the 7.5 branch (what ended up as 7.5.1).

In any case 7.5 is old by now.  Please reopen if you can reproduce it with a 7.7, or ideally a recent snapshot or git head (we're not that far from 7.8 now).