Skip to content

Commit eded377

Browse files
committed
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
2 parents 56cbcea + b646488 commit eded377

5 files changed

Lines changed: 20 additions & 2 deletions

File tree

include/linux/kdb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ int kdb_process_cpu(const struct task_struct *p)
196196
return cpu;
197197
}
198198

199+
extern void kdb_send_sig(struct task_struct *p, int sig);
200+
199201
#ifdef CONFIG_KALLSYMS
200202
extern const char *kdb_walk_kallsyms(loff_t *pos);
201203
#else /* ! CONFIG_KALLSYMS */

include/linux/kgdb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,5 +365,6 @@ extern void kgdb_free_init_mem(void);
365365
#define dbg_late_init()
366366
static inline void kgdb_panic(const char *msg) {}
367367
static inline void kgdb_free_init_mem(void) { }
368+
static inline int kgdb_nmicallback(int cpu, void *regs) { return 1; }
368369
#endif /* ! CONFIG_KGDB */
369370
#endif /* _KGDB_H_ */

kernel/debug/kdb/kdb_io.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ char kdb_getchar(void)
131131
int escape_delay = 0;
132132
get_char_func *f, *f_prev = NULL;
133133
int key;
134+
static bool last_char_was_cr;
134135

135136
for (f = &kdb_poll_funcs[0]; ; ++f) {
136137
if (*f == NULL) {
@@ -149,6 +150,18 @@ char kdb_getchar(void)
149150
continue;
150151
}
151152

153+
/*
154+
* The caller expects that newlines are either CR or LF. However
155+
* some terminals send _both_ CR and LF. Avoid having to handle
156+
* this in the caller by stripping the LF if we saw a CR right
157+
* before.
158+
*/
159+
if (last_char_was_cr && key == '\n') {
160+
last_char_was_cr = false;
161+
continue;
162+
}
163+
last_char_was_cr = (key == '\r');
164+
152165
/*
153166
* When the first character is received (or we get a change
154167
* input source) we set ourselves up to handle an escape
@@ -244,7 +257,8 @@ static char *kdb_read(char *buffer, size_t bufsize)
244257
*cp = tmp;
245258
}
246259
break;
247-
case 13: /* enter */
260+
case 10: /* linefeed */
261+
case 13: /* carriage return */
248262
*lastchar++ = '\n';
249263
*lastchar++ = '\0';
250264
if (!KDB_STATE(KGDB_TRANS)) {

kernel/debug/kdb/kdb_keyboard.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <linux/ctype.h>
1414
#include <linux/io.h>
1515

16+
#include "kdb_private.h"
17+
1618
/* Keyboard Controller Registers on normal PCs. */
1719

1820
#define KBD_STATUS_REG 0x64 /* Status register (R) */

kernel/debug/kdb/kdb_private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ extern char kdb_task_state_char (const struct task_struct *);
194194
extern bool kdb_task_state(const struct task_struct *p, const char *mask);
195195
extern void kdb_ps_suppressed(void);
196196
extern void kdb_ps1(const struct task_struct *p);
197-
extern void kdb_send_sig(struct task_struct *p, int sig);
198197
extern char kdb_getchar(void);
199198
extern char *kdb_getstr(char *, size_t, const char *);
200199
extern void kdb_gdb_state_pass(char *buf);

0 commit comments

Comments
 (0)