Skip to content

Commit db2f9c7

Browse files
author
Daniel Thompson
committed
kdb: Fix console handling when editing and tab-completing commands
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 Reviewed-by: Douglas Anderson <dianders@chromium.org> Tested-by: Justin Stitt <justinstitt@google.com> Link: https://lore.kernel.org/r/20240424-kgdb_read_refactor-v3-3-f236dbe9828d@linaro.org Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
1 parent 09b3598 commit db2f9c7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/debug/kdb/kdb_io.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ static char *kdb_read(char *buffer, size_t bufsize)
383383
kdb_printf("\n");
384384
kdb_printf(kdb_prompt_str);
385385
kdb_printf("%s", buffer);
386+
if (cp != lastchar)
387+
kdb_position_cursor(kdb_prompt_str, buffer, cp);
386388
} else if (tab != 2 && count > 0) {
387389
/* How many new characters do we want from tmpbuffer? */
388390
len_tmp = strlen(p_tmp) - len;
@@ -396,6 +398,9 @@ static char *kdb_read(char *buffer, size_t bufsize)
396398
kdb_printf("%s", cp);
397399
cp += len_tmp;
398400
lastchar += len_tmp;
401+
if (cp != lastchar)
402+
kdb_position_cursor(kdb_prompt_str,
403+
buffer, cp);
399404
}
400405
}
401406
kdb_nextline = 1; /* reset output line number */

0 commit comments

Comments
 (0)