From patchwork Fri Aug 31 20:51:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 145702 Delivered-To: patches@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1217111ljw; Fri, 31 Aug 2018 13:52:35 -0700 (PDT) X-Received: by 2002:a1c:4e16:: with SMTP id g22-v6mr6175521wmh.111.1535748755089; Fri, 31 Aug 2018 13:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535748755; cv=none; d=google.com; s=arc-20160816; b=PGn+KRNtLM5Z98kxJ7oP5RgXkaHGRGUK3QcC+bX7m3HqxAyHuY918ssBU5vo3tOq1V Gm4wqEJrYDKEBS1x/bfLHyZ9Szhw/Gx8j+XKKJqRzWYHDZBU2a+L4IjxazsUiFFaQhWA jt5/ovH7sPFa/wdYQk10w89NuPqKRK2OMkPY6nSE5GcfwdBfXPrZmGHQUwUfJ03q8aDv ZTt7YxoCitl0paaR08vArMLXpigfuxIm55pUN/CnslwJZSlWPuR8oOho4jCmVFkXxhBI 7Y16aQMrQHNe/8fM5aqcdpHAh3rFQyPtyYTA2fxVzQkIHVhELg8eDI9vRa7PajSaFYVH whQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=60/OBHwJ0Jhy0mtbYMzYiVyHmch8QP1Vwd6y9Ee0VNU=; b=fLvc5C4AjEMZKDb8GQexF7SWpbAWz5FndHfMCSRjuoeNNJjYOMohd8kfN7tUAo52Ol 8FVn2eNRXrJG6nv8nuQ8GTBTwqc29xCU3hQ5YWq8I4dpW3sYbkuDxWOijocnpmIXykh7 nzCSRb0CEqR2g5xjwePA3AoSD9uCN1EMOIehUIzJBqVhPWhexeSawHeCSdj/ZhLyLbDX 56ZYJM6yV2p1YwNH4BhY/Zlw7p0FQCNb4vU4mgHmm3AtrXsiiRrzm/LVgjkEKQUxw/tD sRi83/9KQnfDqOwp8ij/Iq8CcjJcAqXpBcRqIbqmNPg4D4jeGSaIFU40HtyqyswVoHNR VDVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cKvzXTQe; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j65-v6sor3237738wmj.16.2018.08.31.13.52.35 for (Google Transport Security); Fri, 31 Aug 2018 13:52:35 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cKvzXTQe; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=rD0HfeXnR8cJGshqW9LlyUvLGQPJNuREgtkT81Myi4rPRTZ0a2ojvTvVeCfm5tsckA ACylI13u852GIjqzwpXT0pDdboH3IleWANVi+RaUx9o7+30p5L+MsSCyEaFKpfW+fc3u zfHXw68kfiB3CZhhQXKAzl/KmkOY+rUL0NZjBNhIBzjcnTBtjSekmiAkLFev+8luLGOy rcxxact2vSFB2WqAWq3dARGfb0pND+Y4/z9dW6WoNjwXjIEbcDaCLGJYj2SIfvxWPJIn zWoLp78YNuD7y9BDGGWHhzpeBRmvYM9VxncNcL10yjIR5B4D8hvmnBgW5OLIrUhOiF3S 1JKg== X-Gm-Message-State: APzg51DrBE7jSKXX8DKdHO2/075s7XsUN6IE5NVPHu+IxT7gvLW/XN/R UYth6OwTHBf3jORtXNLZM1zTrNJu X-Google-Smtp-Source: ANB0VdaNyFdZW0UM9YzaFkjjdNKLuCwn8IBFdRFE+E/39Zn/RFWF71mbEve7rlgIBPnS55O8Z5zcUw== X-Received: by 2002:a1c:ee15:: with SMTP id m21-v6mr1335367wmh.112.1535748754811; Fri, 31 Aug 2018 13:52:34 -0700 (PDT) Return-Path: 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> 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(-) -- 2.17.1 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(); } /*