summaryrefslogtreecommitdiff
path: root/kernel/debug/kdb/kdb_io.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-07-03 15:19:56 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2023-07-03 15:19:56 -0700
commiteded37770c9f80ecd5ba842359c4f1058d9812c3 (patch)
treef9cbbfb04866fa364d27f0936112bc1be1af77af /kernel/debug/kdb/kdb_io.c
parent56cbceab928d7ac3702de172ff8dcc1da2a6aaeb (diff)
parentb6464883f45ae6412de33e53587974fd86ba811e (diff)
downloadlinux-eded37770c9f80ecd5ba842359c4f1058d9812c3.tar.gz
linux-eded37770c9f80ecd5ba842359c4f1058d9812c3.tar.bz2
linux-eded37770c9f80ecd5ba842359c4f1058d9812c3.zip
Merge tag 'kgdb-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux
Pull kgdb updates from Daniel Thompson: "Fairly small changes this cycle: - An additional static inline function when kgdb is not enabled to reduce boilerplate in arch files - kdb will now handle input with linefeeds more like carriage return. This will make little difference for interactive use but can make it script to use expect-like interaction with kdb - A couple of warning fixes" * tag 'kgdb-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux: kdb: move kdb_send_sig() declaration to a better header file kdb: Handle LF in the command parser kdb: include kdb_private.h for function prototypes kgdb: Provide a stub kgdb_nmicallback() if !CONFIG_KGDB
Diffstat (limited to 'kernel/debug/kdb/kdb_io.c')
-rw-r--r--kernel/debug/kdb/kdb_io.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 5c7e9ba7cd6b..813cb6cf72d6 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -131,6 +131,7 @@ char kdb_getchar(void)
int escape_delay = 0;
get_char_func *f, *f_prev = NULL;
int key;
+ static bool last_char_was_cr;
for (f = &kdb_poll_funcs[0]; ; ++f) {
if (*f == NULL) {
@@ -150,6 +151,18 @@ char kdb_getchar(void)
}
/*
+ * The caller expects that newlines are either CR or LF. However
+ * some terminals send _both_ CR and LF. Avoid having to handle
+ * this in the caller by stripping the LF if we saw a CR right
+ * before.
+ */
+ if (last_char_was_cr && key == '\n') {
+ last_char_was_cr = false;
+ continue;
+ }
+ last_char_was_cr = (key == '\r');
+
+ /*
* When the first character is received (or we get a change
* input source) we set ourselves up to handle an escape
* sequences (just in case).
@@ -244,7 +257,8 @@ poll_again:
*cp = tmp;
}
break;
- case 13: /* enter */
+ case 10: /* linefeed */
+ case 13: /* carriage return */
*lastchar++ = '\n';
*lastchar++ = '\0';
if (!KDB_STATE(KGDB_TRANS)) {