This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: fix error when remote TCP connection dropped


Ping?

Jim Blandy <jimb at codesourcery.com> writes:
> If GDB is talking to a remote target over TCP, and the remote target
> exits unexpectedly while the program is running, GDB prints a
> mysterious error message about a watchdog timer having expired.
>
> I have a gdbserver running 'getc' (a program that reads a character
> from stdin and prints it) in another window.  Then:
>
>   $ ~/gdb/exp/nat/gdb/gdb getc
>   GNU gdb 6.7.50-20070926-cvs
>   Copyright (C) 2007 Free Software Foundation, Inc.
>   License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>   This is free software: you are free to change and redistribute it.
>   There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>   and "show warranty" for details.
>   This GDB was configured as "i686-pc-linux-gnu"...
>   Using host libthread_db library "/lib/libthread_db.so.1".
>   (gdb) target remote :1729
>   Remote debugging using :1729
>   0x00360810 in ?? ()
>   (gdb) b main
>   Breakpoint 1 at 0x80483c5: file getc.c, line 6.
>   (gdb) c
>   Continuing.
>
>   Breakpoint 1, main () at getc.c:6
>   6         int c = getchar ();
>   (gdb) next
>
> At this point, if I kill the gdbserver, GDB says:
>
>   Watchdog has expired.  Target detached.
>   (gdb) quit
>
> There is no watchdog timer involved.
>
> The fix is pretty trivial.  It seems the SERIAL_TIMEOUT case is
> already handled above, and all existing read_prim functions do return
> 0 on EOF (including those based on Windows and Winsock functions).
>
> Okay for trunk?  (Not worth it for branch.)
>
> gdb/ChangeLog:
> 2007-09-26  Jim Blandy  <jimb@codesourcery.com>
>
> 	* serial.h (struct serial_ops): Document read_prim to return zero
> 	at EOF.
> 	* ser-base.c (do_ser_base_readchar): Return SERIAL_EOF when
> 	read_prim returns zero, not SERIAL_TIMEOUT.
>
> Index: gdb/ser-base.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ser-base.c,v
> retrieving revision 1.11
> diff -u -r1.11 ser-base.c
> --- gdb/ser-base.c	23 Aug 2007 18:08:37 -0000	1.11
> +++ gdb/ser-base.c	26 Sep 2007 18:34:29 -0000
> @@ -279,9 +279,7 @@
>    if (status <= 0)
>      {
>        if (status == 0)
> -	/* 0 chars means timeout.  (We may need to distinguish between EOF
> -	   & timeouts someday.)  */
> -	return SERIAL_TIMEOUT;	
> +        return SERIAL_EOF;
>        else
>  	/* Got an error from read.  */
>  	return SERIAL_ERROR;	
> Index: gdb/serial.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/serial.h,v
> retrieving revision 1.17
> diff -u -r1.17 serial.h
> --- gdb/serial.h	23 Aug 2007 18:08:37 -0000	1.17
> +++ gdb/serial.h	26 Sep 2007 18:34:29 -0000
> @@ -244,7 +244,7 @@
>         interesting.  */
>      void (*async) (struct serial *scb, int async_p);
>      /* Perform a low-level read operation, reading (at most) COUNT
> -       bytes into SCB->BUF.  */
> +       bytes into SCB->BUF.  Return zero at end of file.  */
>      int (*read_prim)(struct serial *scb, size_t count);
>      /* Perform a low-level write operation, writing (at most) COUNT
>         bytes from BUF.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]