From owner-svn-src-head@freebsd.org Sat Jan 14 22:06:32 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3EAF0CAFB5D; Sat, 14 Jan 2017 22:06:32 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0FBA315DA; Sat, 14 Jan 2017 22:06:32 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pg0-x241.google.com with SMTP id 75so1745349pgf.3; Sat, 14 Jan 2017 14:06:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=B5dJHvF93BbMFgelc7PVnVp1eaL6j1kxIVieN2bMiTg=; b=sn1DxRSqWP5n7X3edZNmdXykfyTqO1ZQ0n+426nyHsR8rqvIpSMq3bebaO/90zSTm1 ty9VyN7w9HnmMK73SMjHzQ5bSORdFA6HL5UpxgV10amgybJGloVoXMVGXxzZr14FlTxM NHyp1EXLXoXIT2RE2wrWhEBz5HoxHK6EXCcxxKeUFA0LXskOGjVzQziaJm7xnqsleyv1 TDphm3n33WlFQmDwpSJl4v1MKNadhVZOHrUEwRFEB64Rb40ru/HZXPvV9uiFKRjeYnhP oooCi3PSbanksH2FbOj0P5USeowPJf/djnwC4kt2Qu/ke7PviuPaz6bCUz1yWsrjn1qT M3tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=B5dJHvF93BbMFgelc7PVnVp1eaL6j1kxIVieN2bMiTg=; b=s12QDqFZJI/bOC3M2VSJz46bV091BHzUalXrrCpqQj166vENm+gX/HGIPZklz7MkFC 0FMPc0kHSkFZVMC+i8zCatIruij5cVszbxQRBHZe4sILAwYinYHkiVEEfUQINJrDFbIc Ux4SeLdiUt0v1qEHOgnydXiLgxtA7vJrUU2OuYAjUMdD063bz39BVIf+9wUXArkNc0qd 4uQHQOvvs1m2A3dxVRyDWt+JtUHTnIfEnEnu8b0VnZq3VVZU+tAvBk8ty9dDg+BfXMYh 4A2krjFiW/iEK3ojnMdsAWvGv1qjpGmbwIm4oPKDtX3MvKFRiH/n7UeEMp0zcRXruXAT DyCQ== X-Gm-Message-State: AIkVDXLEz33WnBkScInay96fHldRocsPhVESsa9b9s/x0I+8favsJWou6NH8YOFbOTM0BQ== X-Received: by 10.84.199.194 with SMTP id d2mr39369975plh.134.1484431591543; Sat, 14 Jan 2017 14:06:31 -0800 (PST) Received: from raichu ([2604:4080:1102:0:ca60:ff:fe9d:3963]) by smtp.gmail.com with ESMTPSA id r1sm37534060pgn.48.2017.01.14.14.06.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Jan 2017 14:06:30 -0800 (PST) Sender: Mark Johnston Date: Sat, 14 Jan 2017 14:06:29 -0800 From: Mark Johnston To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, rang@acm.org Subject: Re: svn commit: r311952 - head/sys/ddb Message-ID: <20170114220629.GB18065@raichu> References: <201701120022.v0C0MaHq053076@repo.freebsd.org> <20170113131948.P1465@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170113131948.P1465@besplex.bde.org> User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2017 22:06:32 -0000 On Fri, Jan 13, 2017 at 02:51:04PM +1100, Bruce Evans wrote: > On Thu, 12 Jan 2017, Mark Johnston wrote: > > > Log: > > Enable the use of ^C and ^S/^Q in DDB. > > > > This lets one interrupt DDB's output, which is useful if paging is > > disabled and the output device is slow. > > This is quite broken. It removes the code that was necessary for avoiding > loss of input. Hi Bruce, I've reverted this for now. I haven't thought much about how db_check_interrupt() might losslessly poll the console driver for ctrl-C, but I do think it's a valuable feature to have - just this morning I absent-mindedly dumped a 128K-entry KTR ring from a DDB prompt after having set $lines = 0, and had to wait for quite a while to get my prompt back. > > > Modified: head/sys/ddb/db_input.c > > ============================================================================== > > --- head/sys/ddb/db_input.c Thu Jan 12 00:09:31 2017 (r311951) > > +++ head/sys/ddb/db_input.c Thu Jan 12 00:22:36 2017 (r311952) > > @@ -63,7 +63,6 @@ static int db_lhist_nlines; > > #define BLANK ' ' > > #define BACKUP '\b' > > > > -static int cnmaygetc(void); > > static void db_delete(int n, int bwd); > > static int db_inputchar(int c); > > static void db_putnchars(int c, int count); > > @@ -291,12 +290,6 @@ db_inputchar(c) > > return (0); > > } > > > > -static int > > -cnmaygetc() > > -{ > > - return (-1); > > -} > > - > > BSD never had a usable console API (function) for checking for input. > cncheckc() is the correct name for such a function. The actual > cncheckc() returns any input that it finds. This is not the main > problem here. The input will have to be read here anyway to determine > what it is. The problems are that there is no console API at all for > ungetting characters in the input stream, and this function doesn't > even use a stub cnungetc(), but drops the input on the floor. It does > document this behaviour in a comment, but doesn't say that it is wrong. > > > int > > db_readline(lstart, lsize) > > char * lstart; > > @@ -350,7 +343,7 @@ db_check_interrupt(void) > > { > > int c; > > > > - c = cnmaygetc(); > > + c = cncheckc(); > > switch (c) { > > case -1: /* no character */ > > return; > > The stub function always returns -1, so db_check_interrupt() is turned into > a no-op. > > db_check_interrupt() now eats the first byte of any input on every call. > > > @@ -361,7 +354,7 @@ db_check_interrupt(void) > > > > case CTRL('s'): > > do { > > - c = cnmaygetc(); > > + c = cncheckc(); > > if (c == CTRL('c')) > > db_error((char *)0); > > } while (c != CTRL('q')); > > This is now a bad implementation of xon/xoff. It doesn't support ixany, > but busy-waits for ^Q or ^C using cncheckc(). It should at least > busy-wait using cngetc(), since that might be do a smarter busy wait. > cngetc() is actually only slightly smarter -- it uses busy-waiting too, > but with cpu_spinwait() in the loop. This cpu_spinwait() makes little > difference since cncheckc() tends to be a heavyweight function. Only > cpu_spinwait()s in the innermost loops of cncheckc(), if any, are likely > to have much effect. > > Multiple consoles complicate this a bit. > > db_check_interrupt() is called after every db_putc() of a newline. So > the breakage is mainly for type-ahead while writing many lines. I'll note that type-ahead interacts rather poorly with DDB's behaviour of repeating the previous command upon reading an empty input line: entering a carriage return at any point while "show ktr" is working will cause it to be started again once it's finished. > > Control processing belongs in the lowest level of console drivers, and > at least the xon/xoff part is very easy to do. This makes it work for > contexts like boot messages -- this can only be controlled now by booting > with -p, which gives something like an automatic ^S after every line, > but the control characters for this mode are unusual and there is no > way to get back to -p mode after turning it off or not starting with it. > > [...]