Subject: bin/23107: Can't ^D out of GDB 5.3+libedit
To: None <>
From: None <>
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
>Originator:     Nathan J. Williams
>Release:        NetBSD 1.6ZC
	Wasabi Systems, Inc.
System: NetBSD 1.6ZC NetBSD 1.6ZC (MARVIN) #67: Mon Sep 29 14:29:10 EDT 2003 i386
Architecture: i386
Machine: i386

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".


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>


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.