Subject: toolchain/29597: gdb mishandles EOF in various ways
To: None <toolchain-manager@netbsd.org, gnats-admin@netbsd.org,>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 03/04/2005 18:50:00
>Number:         29597
>Category:       toolchain
>Synopsis:       gdb EOF-handling bugs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 04 18:50:00 +0000 2005
>Originator:     der Mouse
>Release:        NetBSD 2.0
>Organization:
	Dis-
>Environment:
	Identical symptoms seen on two machines:

	NetBSD/sparc 2.0 on a SPARCclassic:
mainbus0 (root): SUNW,SPARCclassic: hostid 80722791
cpu0 at mainbus0: TMS390S10 @ 50 MHz, on-chip FPU
cpu0: physical 4K instruction (32 b/l), 2K data (16 b/l): cache enabled

	NetBSD/i386 2.0 on a...Xeon, I think:
cpu0 at mainbus0: (uniprocessor)
cpu0: Intel (686-class), 3200.24 MHz, id 0xf34
cpu0: features bfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
cpu0: features bfebfbff<PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX>
cpu0: features bfebfbff<FXSR,SSE,SSE2,SS,HTT,TM,SBF>
cpu0: I-cache 12K uOp cache 8-way
cpu0: L2 cache 1 MB 64B/line 8-way
cpu0: ITLB 4K/4M: 64 entries
cpu0: DTLB 4K/4M: 64 entries
cpu0: 32 page colors

>Description:
	I run with unusual stty settings (eof ^Z susp ^P kill ^X),
	largely for historical reasons.  These cause trouble with gdb.

	The first problem is that, without any configuration at all,
	gdb does not obey my eof setting; typing ^Z suspends gdb, and
	only ^D works for EOF.  (^P does work to suspend.)

	I eventually found "echo edit off > ~/.editrc".  Under past
	NetBSD versions, this makes gdb "work": typing ^Z gives EOF
	behaviour.  (This is the behaviour under 1.4T on many ports and
	1.6.1 on i386; I can't easily check 1.6.* on other ports.)  But
	under 2.0, with that ~/.editrc in place, ^Z echos as ^, Z,
	backspace, backspace, and does nothing (at the (gdb) prompt).
	^D echos as ^, D without backspaces and also does nothing.  The
	only way to exit I've found is "quit".
>How-To-Repeat:
	(on 1.4T, 1.6.1, 2.0, or probably pretty much any other)
	% rm -f ~/.editrc
	% stty eof ^Z susp ^P kill ^X
	% gdb
	...type ^Z and notice that it suspends rather than exiting...
	...type ^D and notice that it exits...

	(on a 1.6.1 or 1.4T or probably other pre-2.0 system)
	% echo edit off > ~/.editrc
	% stty eof ^Z susp ^P kill ^X
	% gdb
	...type ^Z and notice it works as EOF...

	(on 2.0)
	% echo edit off > ~/.editrc
	% stty eof ^Z susp ^P kill ^X
	% gdb
	...type ^Z and notice it doesn't work as EOF...
	...type ^D and notice it doesn't work either...
>Fix:
	Unknown.  But I note that ftp, which also uses editline (its
	behaviour changes if ~/.editrc is in place) behaves correctly
	with this ~/.editrc in place, even on 2.0 (though it breaks the
	same as gdb without ~/.editrc); perhaps gdb needs to do
	something the same way ftp does?

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B