From: Daniel Thompson <daniel.thompson@linaro.org>
To: Jason Wessel <jason.wessel@windriver.com>,
Douglas Anderson <dianders@chromium.org>
Cc: kgdb-bugreport@lists.sourceforge.net,
linux-kernel@vger.kernel.org,
Daniel Thompson <daniel.thompson@linaro.org>,
stable@vger.kernel.org
Subject: [PATCH v2 3/7] kdb: Fix console handling when editing and tab-completing commands
Date: Mon, 22 Apr 2024 17:35:56 +0100 [thread overview]
Message-ID: <20240422-kgdb_read_refactor-v2-3-ed51f7d145fe@linaro.org> (raw)
In-Reply-To: <20240422-kgdb_read_refactor-v2-0-ed51f7d145fe@linaro.org>
Currently, if the cursor position is not at the end of the command buffer
and the user uses the Tab-complete functions, then the console does not
leave the cursor in the correct position.
For example consider the following buffer with the cursor positioned
at the ^:
md kdb_pro 10
^
Pressing tab should result in:
md kdb_prompt_str 10
^
However this does not happen. Instead the cursor is placed at the end
(after then 10) and further cursor movement redraws incorrectly. The
same problem exists when we double-Tab but in a different part of the
code.
Fix this by sending a carriage return and then redisplaying the text to
the left of the cursor.
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
---
kernel/debug/kdb/kdb_io.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index a42607e4d1aba..69549fe42e87b 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -364,6 +364,8 @@ static char *kdb_read(char *buffer, size_t bufsize)
kdb_printf("\n");
kdb_printf(kdb_prompt_str);
kdb_printf("%s", buffer);
+ if (cp != lastchar)
+ kdb_position_cursor(kdb_prompt_str, buffer, cp);
} else if (tab != 2 && count > 0) {
/* How many new characters do we want from tmpbuffer? */
len_tmp = strlen(p_tmp) - len;
@@ -377,6 +379,9 @@ static char *kdb_read(char *buffer, size_t bufsize)
kdb_printf("%s", cp);
cp += len_tmp;
lastchar += len_tmp;
+ if (cp != lastchar)
+ kdb_position_cursor(kdb_prompt_str,
+ buffer, cp);
}
}
kdb_nextline = 1; /* reset output line number */
--
2.43.0
next prev parent reply other threads:[~2024-04-22 16:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 16:35 [PATCH v2 0/7] kdb: Refactor and fix bugs in kdb_read() Daniel Thompson
2024-04-22 16:35 ` [PATCH v2 1/7] kdb: Fix buffer overflow during tab-complete Daniel Thompson
2024-04-22 21:39 ` Justin Stitt
2024-04-22 23:51 ` Doug Anderson
2024-04-23 10:17 ` Daniel Thompson
2024-04-22 16:35 ` [PATCH v2 2/7] kdb: Use format-strings rather than '\0' injection in kdb_read() Daniel Thompson
2024-04-22 23:52 ` Doug Anderson
2024-04-23 10:37 ` Daniel Thompson
2024-04-22 16:35 ` Daniel Thompson [this message]
2024-04-22 23:52 ` [PATCH v2 3/7] kdb: Fix console handling when editing and tab-completing commands Doug Anderson
2024-04-22 16:35 ` [PATCH v2 4/7] kdb: Merge identical case statements in kdb_read() Daniel Thompson
2024-04-22 23:52 ` Doug Anderson
2024-04-22 16:35 ` [PATCH v2 5/7] kdb: Use format-specifiers rather than memset() for padding " Daniel Thompson
2024-04-22 23:52 ` Doug Anderson
2024-04-22 16:35 ` [PATCH v2 6/7] kdb: Replace double memcpy() with memmove() " Daniel Thompson
2024-04-22 23:52 ` Doug Anderson
2024-04-22 16:36 ` [PATCH v2 7/7] kdb: Simplify management of tmpbuffer " Daniel Thompson
2024-04-22 23:52 ` Doug Anderson
2024-04-23 11:02 ` Daniel Thompson
2024-04-22 22:49 ` [PATCH v2 0/7] kdb: Refactor and fix bugs " Justin Stitt
2024-04-23 11:19 ` Daniel Thompson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240422-kgdb_read_refactor-v2-3-ed51f7d145fe@linaro.org \
--to=daniel.thompson@linaro.org \
--cc=dianders@chromium.org \
--cc=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®