aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/debug/kdb/kdb_bt.c
diff options
context:
space:
mode:
authorDaniel Thompson <daniel.thompson@linaro.org>2019-10-25 08:33:26 +0100
committerDaniel Thompson <daniel.thompson@linaro.org>2019-10-28 12:07:57 +0000
commit4f27e824bf83dfc2f6dc1a54fae419be7cd335af (patch)
treead3f49c857d6cfe483e4a3dbc18afcf8a604f9a7 /kernel/debug/kdb/kdb_bt.c
parentd04213af90935d8b247c1327c9ea142fc037165f (diff)
downloadlinux-4f27e824bf83dfc2f6dc1a54fae419be7cd335af.tar.gz
kdb: Remove special case logic from kdb_read()
kdb_read() contains special case logic to force it exit after reading a single character. We can remove all the special case logic by directly calling the function to read a single character instead. This also allows us to tidy up the function prototype which, because it now matches getchar(), we can also rename in order to make its role clearer. This does involve some extra code to handle btaprompt properly but we don't mind the new lines of code here because the old code had some interesting problems (bad newline handling, treating unexpected characters like <cr>). Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20191025073328.643-4-daniel.thompson@linaro.org
Diffstat (limited to 'kernel/debug/kdb/kdb_bt.c')
-rw-r--r--kernel/debug/kdb/kdb_bt.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c
index 0e94efe07b72..4af48ac53625 100644
--- a/kernel/debug/kdb/kdb_bt.c
+++ b/kernel/debug/kdb/kdb_bt.c
@@ -75,9 +75,10 @@ static void kdb_show_stack(struct task_struct *p, void *addr)
static int
kdb_bt1(struct task_struct *p, unsigned long mask, bool btaprompt)
{
- char buffer[2];
- if (kdb_getarea(buffer[0], (unsigned long)p) ||
- kdb_getarea(buffer[0], (unsigned long)(p+1)-1))
+ char ch;
+
+ if (kdb_getarea(ch, (unsigned long)p) ||
+ kdb_getarea(ch, (unsigned long)(p+1)-1))
return KDB_BADADDR;
if (!kdb_task_state(p, mask))
return 0;
@@ -85,12 +86,17 @@ kdb_bt1(struct task_struct *p, unsigned long mask, bool btaprompt)
kdb_ps1(p);
kdb_show_stack(p, NULL);
if (btaprompt) {
- kdb_getstr(buffer, sizeof(buffer),
- "Enter <q> to end, <cr> to continue:");
- if (buffer[0] == 'q') {
- kdb_printf("\n");
+ kdb_printf("Enter <q> to end, <cr> or <space> to continue:");
+ do {
+ ch = kdb_getchar();
+ } while (!strchr("\r\n q", ch));
+ kdb_printf("\n");
+
+ /* reset the pager */
+ kdb_nextline = 1;
+
+ if (ch == 'q')
return 1;
- }
}
touch_nmi_watchdog();
return 0;