Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp806247imm; Fri, 31 Aug 2018 13:56:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbvZZ4IPdzbviNQg8R4O0HZ6jWIif+h6vQDAssw4wblWSXJa/JH3PLrO1jL++/G0zGTy0qL X-Received: by 2002:a63:91c2:: with SMTP id l185-v6mr16374383pge.321.1535748995789; Fri, 31 Aug 2018 13:56:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535748995; cv=none; d=google.com; s=arc-20160816; b=jyYCXd58JHOYazIVlDQxvm1hX6064Lg3B9Wx2Y9ZMUi+NUfBBVKoFlGjx7y9EwGIDg JkWXZBTAx3MallPX7Rp8XsGKGsePbYMJy42cpnk634K2sPLaIcThPStwRLP0WoRb3Mpk AoHlOtoqLVrJGlrF/N0Wfh93kT3fH72+5qVtVkyExVpOGfhT3+VGBexvlIqJOFLErzb5 SMR8YwOd3Vs8MnRFH51W1BrpBXPt1zksG0vTJ3aShHeAOVSvRB82xUiKiyxUMv1ZpWlP kPfxojTxGhb2nh18AMDeCh95utaR32xJx41TktP+TZisnYLWa/9hiV5bJd24QJ6X+2IP UdpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=60/OBHwJ0Jhy0mtbYMzYiVyHmch8QP1Vwd6y9Ee0VNU=; b=VkU2hlJDsGbtLDX18gVdJkO7fcK1Ed+1o1Qa7R44ds8KQHOMLqwyjfNyBk7dsGdYjT sz7Reda5lXEkSsfu52hnERTE+MpA2mdr3Jgyrdy6uwmqv79Jla2Zf6hnvfq0l4vvhtu2 Q7is59z/IEBIsGCdRDgLOBWCr73kQ2oxE3LrmCfvI52Fqi7nLt/jndMhY4np/ytrAZDu TDXh4KSTapEdxQhnA+aRJOhse3BoDHukdVuY95LxXd/G8VI8UY7tzvocbezzTBdmfFcu /7srvHXLQ0OZ05gO0tQqsDotslotCBuDI4ofAdzSC99q8EhqxNMMIvhcAce5gN1W8aIy McIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cKvzXTQe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3-v6si10752936pgw.135.2018.08.31.13.55.51; Fri, 31 Aug 2018 13:56:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cKvzXTQe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbeIABBt (ORCPT + 99 others); Fri, 31 Aug 2018 21:01:49 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34273 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727561AbeIABBt (ORCPT ); Fri, 31 Aug 2018 21:01:49 -0400 Received: by mail-wm0-f67.google.com with SMTP id j25-v6so4199095wmc.1 for ; Fri, 31 Aug 2018 13:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=60/OBHwJ0Jhy0mtbYMzYiVyHmch8QP1Vwd6y9Ee0VNU=; b=cKvzXTQefoDzyp7THWxaYvcMxDN+AOPUggGDqy0lqEAM/YoaH0rheUt5vzyebXnEct BMs4+GceVKVjK/QO60yQt2aDWcKs5PG8tTGNmO0HysL7gpPTb6Fr/PJR7qyVmY1Z3si8 Nz9Na229P/uzgnhezmt2dsCkJCCqsArvYtl5M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=60/OBHwJ0Jhy0mtbYMzYiVyHmch8QP1Vwd6y9Ee0VNU=; b=Qt9w3ACVTNtkBk+Bc5WKCXeiIkQiYbkvmHfVzvLBeBhUCb9M5v7uGwS+TAccg5cfPn 7DO6r9e9PcbkUlM/mjxvU/jdN2T+EiIMtz9NOn9J5G5RBEeoaZeWDBBCJuELO8b8Fa+u cYn4qf/HV7sFREBbIzY09Je8EuOMUykkceLYzbTozoivflQkarOCDDasG92kWHopM24I nmLv7jH9Wm4NymqEPzyKPiun6GYF1ktzMRmaBEkAlu5U5fvlE8lHDUq2Lz48Sfi+HeRB A7MddwpIS5KI5qOZXy0EtinHxuvFl/bfQrYNHPdjwmgU6/igtqbwP6ALSVRITXHHlnnn Ra4g== X-Gm-Message-State: APzg51Dcnfvzs0EJeeDA+2NsEiLNzw3IJOjcEcjMdBmOXCBK6OxzqVYw VC6/BdExEmduu3hjKHlA6sETmJlkLuM= X-Received: by 2002:a1c:ee15:: with SMTP id m21-v6mr1335367wmh.112.1535748754811; Fri, 31 Aug 2018 13:52:34 -0700 (PDT) Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id u4-v6sm7659356wro.47.2018.08.31.13.52.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Aug 2018 13:52:33 -0700 (PDT) From: Daniel Thompson To: Jason Wessel Cc: Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH 4/5] kdb: Improve handling of characters from different input sources Date: Fri, 31 Aug 2018 21:51:41 +0100 Message-Id: <20180831205142.23609-5-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180831205142.23609-1-daniel.thompson@linaro.org> References: <20180831205142.23609-1-daniel.thompson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently if an escape timer is interrupted by a character from a different input source then the new character is discarded and the function returns '\e' (which will be discarded by the level above). It is hard to see why this would ever be the desired behaviour. Fix this to return the new character rather then the '\e'. This is a bigger refactor that might be expected because the new character needs to go through escape sequence detection. Signed-off-by: Daniel Thompson --- kernel/debug/kdb/kdb_io.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index f735d859f28b..8f2470016250 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -122,8 +122,8 @@ static int kdb_getchar(void) { #define ESCAPE_UDELAY 1000 #define ESCAPE_DELAY (2*1000000/ESCAPE_UDELAY) /* 2 seconds worth of udelays */ - char escape_data[5]; /* longest vt100 escape sequence is 4 bytes */ - char *ped = escape_data; + char buf[4]; /* longest vt100 escape sequence is 4 bytes */ + char *pbuf = buf; int escape_delay = 0; get_char_func *f, *f_escape = NULL; int key; @@ -145,27 +145,22 @@ static int kdb_getchar(void) continue; } - if (escape_delay == 0 && key == '\e') { - escape_delay = ESCAPE_DELAY; - ped = escape_data; + /* Reset state on first character from an input source */ + if (f_escape != f) { f_escape = f; - } - if (escape_delay) { - if (f_escape != f) - return '\e'; - - *ped++ = key; - key = kdb_read_handle_escape(escape_data, - ped - escape_data); - if (key < 0) - return '\e'; - if (key == 0) - continue; + pbuf = buf; + escape_delay = ESCAPE_DELAY; } - break; /* A key to process */ + *pbuf++ = key; + key = kdb_read_handle_escape(buf, pbuf - buf); + if (key < 0) /* no escape sequence; return first character */ + return buf[0]; + if (key > 0) + return key; } - return key; + + unreachable(); } /* -- 2.17.1