Skip to content

Commit efe2f29

Browse files
committed
kgdboc,kdb: Allow kdb to work on a non open console port
If kdb is open on a serial port that is not actually a console make sure to call the poll routines to emit and receive characters. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Martin Hicks <mort@sgi.com>
1 parent 1cee5e3 commit efe2f29

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎drivers/serial/kgdboc.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/kgdb.h>
1717
#include <linux/kdb.h>
1818
#include <linux/tty.h>
19+
#include <linux/console.h>
1920

2021
#define MAX_CONFIG_LEN 40
2122

@@ -93,12 +94,14 @@ static int configure_kgdboc(void)
9394
int tty_line = 0;
9495
int err;
9596
char *cptr = config;
97+
struct console *cons;
9698

9799
err = kgdboc_option_setup(config);
98100
if (err || !strlen(config) || isspace(config[0]))
99101
goto noconfig;
100102

101103
err = -ENODEV;
104+
kgdboc_io_ops.is_console = 0;
102105
kgdb_tty_driver = NULL;
103106

104107
if (kgdboc_register_kbd(&cptr))
@@ -108,6 +111,17 @@ static int configure_kgdboc(void)
108111
if (!p)
109112
goto noconfig;
110113

114+
cons = console_drivers;
115+
while (cons) {
116+
int idx;
117+
if (cons->device && cons->device(cons, &idx) == p &&
118+
idx == tty_line) {
119+
kgdboc_io_ops.is_console = 1;
120+
break;
121+
}
122+
cons = cons->next;
123+
}
124+
111125
kgdb_tty_driver = p;
112126
kgdb_tty_line = tty_line;
113127

‎include/linux/kgdb.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ struct kgdb_arch {
247247
* the I/O driver.
248248
* @post_exception: Pointer to a function that will do any cleanup work
249249
* for the I/O driver.
250+
* @is_console: 1 if the end device is a console 0 if the I/O device is
251+
* not a console
250252
*/
251253
struct kgdb_io {
252254
const char *name;
@@ -256,6 +258,7 @@ struct kgdb_io {
256258
int (*init) (void);
257259
void (*pre_exception) (void);
258260
void (*post_exception) (void);
261+
int is_console;
259262
};
260263

261264
extern struct kgdb_arch arch_kgdb_ops;

‎kernel/debug/kdb/kdb_io.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,14 @@ int kdb_printf(const char *fmt, ...)
673673
if (!dbg_kdb_mode && kgdb_connected) {
674674
gdbstub_msg_write(kdb_buffer, retlen);
675675
} else {
676+
if (!dbg_io_ops->is_console) {
677+
len = strlen(kdb_buffer);
678+
cp = kdb_buffer;
679+
while (len--) {
680+
dbg_io_ops->write_char(*cp);
681+
cp++;
682+
}
683+
}
676684
while (c) {
677685
c->write(c, kdb_buffer, retlen);
678686
touch_nmi_watchdog();
@@ -719,6 +727,14 @@ int kdb_printf(const char *fmt, ...)
719727
kdb_input_flush();
720728
c = console_drivers;
721729

730+
if (!dbg_io_ops->is_console) {
731+
len = strlen(moreprompt);
732+
cp = moreprompt;
733+
while (len--) {
734+
dbg_io_ops->write_char(*cp);
735+
cp++;
736+
}
737+
}
722738
while (c) {
723739
c->write(c, moreprompt, strlen(moreprompt));
724740
touch_nmi_watchdog();

0 commit comments

Comments
 (0)