Subject: bin/23107: Can't ^D out of GDB 5.3+libedit
To: None <gnats-bugs@gnats.netbsd.org>
From: None <nathanw@wasabisystems.com>
List: netbsd-bugs
Date: 10/08/2003 18:46:38
>Number:         23107
>Category:       bin
>Synopsis:       Can't ^D out of GDB 5.3+libedit
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 08 22:47:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Nathan J. Williams
>Release:        NetBSD 1.6ZC
>Organization:
	Wasabi Systems, Inc.
>Environment:
System: NetBSD marvin-the-martian.stuartst.com 1.6ZC NetBSD 1.6ZC (MARVIN) #67: Mon Sep 29 14:29:10 EDT 2003 nathanw@marvin-the-martian.stuartst.com:/nbsd/src/sys/arch/i386/compile/MARVIN i386
Architecture: i386
Machine: i386
>Description:

GDB 5.3 built against libedit rather than GNU readline fails
to exit if EOF (control-D) is typed at a blank prompt. The user must
type "quit".

>How-To-Repeat:

256 marvin-the-martian:nathanw>/usr/bin/gdb
GNU gdb 5.3nb1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386--netbsdelf".
(gdb) ^D

... notice that nothing happens ...

(gdb) q
257 marvin-the-martian:nathanw>

>Fix:

I believe the problem is in libedit's implementation of
rl_callback_read_char(), which simply returns when it encounters an
EOF character. GDB expects the GNU readline behavior of calling thee
callback with a NULL buffer:

 - Function: void rl_callback_read_char (void)
     Whenever an application determines that keyboard input is
     available, it should call `rl_callback_read_char()', which will
     read the next character from the current input source.  If that
     character completes the line, `rl_callback_read_char' will invoke
     the LHANDLER function saved by `rl_callback_handler_install' to
     process the line.  `EOF' is  indicated by calling LHANDLER with a
     `NULL' line.

>Release-Note:
>Audit-Trail:
>Unformatted: