Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 213FDEB64D9 for ; Sat, 17 Jun 2023 10:51:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 39ABD8632E; Sat, 17 Jun 2023 12:50:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="VNkLMYfI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1FE86862E8; Sat, 17 Jun 2023 12:50:28 +0200 (CEST) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 66AF0862F9 for ; Sat, 17 Jun 2023 12:50:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f8f3786f20so15184925e9.2 for ; Sat, 17 Jun 2023 03:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686999022; x=1689591022; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rHFn8uQUoHCD/2XK8iv3AyQZBIH04mWSB9iq9s+JU1E=; b=VNkLMYfIdC984ziSexe9RcTTl4UL98hFIh85aNfBN9UCrxHREuI4UMi4oODp0zvqtn QE2q5CoZtRcCMAWR6RnpICmJ9pyLPgf2ToZukKlWFKbpyflRRNag0T4q8Hb2UZ65M9Cj exx6LuWaU7ZgKVMGKyYqIV+AIkhZG0k6SRVEM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686999022; x=1689591022; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rHFn8uQUoHCD/2XK8iv3AyQZBIH04mWSB9iq9s+JU1E=; b=G6Mt/cHDinitB5fgFKibMK/c4t3UOolW4hqOid9p/ezWYnbPpL12aDVFJ066KNP4jh djiXTGPm59bT+S9rWAVMNfm7D6F2sp0fJWnCiq3zunem1yEtfHPKUhlUYJGct0FpRLi/ kilS5ACTEBdDJmkCXTVpqm4e1CM9ySDGemoCxErgoCqhfTpODJp79JR4oALDuKBiDIAh pypjc14FrHCi/6CbEVYGPabVs7lm/6/b1XrTp8YzUI4jOUCGSCuHhJX8J9gUAUfgOqME dlNxme2EhlOyzXh4T2u8ODcmDkjHR5EToSVxrbX3P+mUwDu8oFOqVVnGixRvUOVSigKA uAjw== X-Gm-Message-State: AC+VfDxvVh0g6vnzzANwFxWiPOhn0MAvHNKmhIfYmqHPG4isuCexXjWr 4bYFdMmZ+tUr6pWLgK938raHMe+h7qod9Il7Ol8= X-Google-Smtp-Source: ACHHUZ4pCol5FKf/c/wDwCllseglLJnApZc1/9GdKwFP4P6HAdv25Vndsmet/BKaRg81Plyu02CwVg== X-Received: by 2002:a05:600c:21c9:b0:3f7:678a:cf20 with SMTP id x9-20020a05600c21c900b003f7678acf20mr4018791wmj.16.1686999022722; Sat, 17 Jun 2023 03:50:22 -0700 (PDT) Received: from sjg1.roam.corp.google.com (79-67-123-132.dynamic.dsl.as9105.com. [79.67.123.132]) by smtp.gmail.com with ESMTPSA id l22-20020a7bc356000000b003f7e4d143cfsm4735171wmj.15.2023.06.17.03.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 03:50:22 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: =?UTF-8?q?Pali=20Roh=C3=A1r?= , Simon Glass Subject: [PATCH 5/6] getch: debugging Date: Sat, 17 Jun 2023 11:49:52 +0100 Message-ID: <20230617104956.1402370-6-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230617104956.1402370-1-sjg@chromium.org> References: <20230617104956.1402370-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Simon Glass --- common/cli_getch.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/common/cli_getch.c b/common/cli_getch.c index 61d4cb261b81..cd44415a9f67 100644 --- a/common/cli_getch.c +++ b/common/cli_getch.c @@ -6,8 +6,11 @@ * Copyright 2022 Google LLC */ +#define LOG_CATEGORY LOGC_CORE + #include #include +#include /** * enum cli_esc_state_t - indicates what to do with an escape character @@ -134,6 +137,8 @@ static int cli_ch_esc(struct cli_ch_state *cch, int ichar, int cli_ch_process(struct cli_ch_state *cch, int ichar) { + log_debug(" [ichar=%x, esc_len=%d] ", ichar, cch->esc_len); + /* * ichar=0x0 when error occurs in U-Boot getchar() or when the caller * wants to check if there are more characters saved in the escape @@ -141,12 +146,18 @@ int cli_ch_process(struct cli_ch_state *cch, int ichar) */ if (!ichar) { if (cch->emitting) { - if (cch->emit_upto < cch->esc_len) - return cch->esc_save[cch->emit_upto++]; + if (cch->emit_upto < cch->esc_len) { + int ch; + + ch = cch->esc_save[cch->emit_upto++]; + log_debug(" [->%x] ", ch); + return ch; + } cch->emit_upto = 0; cch->emitting = false; cch->esc_len = 0; } + log_debug(" [->0] "); return 0; } else if (ichar == -ETIMEDOUT) { /* @@ -156,15 +167,19 @@ int cli_ch_process(struct cli_ch_state *cch, int ichar) */ if (cch->esc_len) { cch->esc_len = 0; + log_debug(" [->esc] "); return '\e'; } /* Otherwise there is nothing to return */ + log_debug(" [->0] "); return 0; } - if (ichar == '\n' || ichar == '\r') + if (ichar == '\n' || ichar == '\r') { + log_debug(" [->nl] "); return '\n'; + } /* handle standard linux xterm esc sequences for arrow key, etc. */ if (cch->esc_len != 0) { @@ -186,6 +201,7 @@ int cli_ch_process(struct cli_ch_state *cch, int ichar) cch->esc_save[cch->esc_len++] = ichar; ichar = cch->esc_save[cch->emit_upto++]; cch->emitting = true; + log_debug(" [->reject %x] ", ichar); return ichar; case ESC_CONVERTED: /* valid escape sequence, return the resulting char */ @@ -205,5 +221,6 @@ int cli_ch_process(struct cli_ch_state *cch, int ichar) return 0; } + log_debug(" [->%x] ", ichar); return ichar; } -- 2.41.0.162.gfafddb0af9-goog