History

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.

Jason Wessel committed 16 years ago

Commit efe2f291 parent 1cee5e33 files · +33 −0Browse files

Unified · Split

3 files
  1. drivers/serial/kgdboc.c +14 −0
  2. include/linux/kgdb.h +3 −0
  3. kernel/debug/kdb/kdb_io.c +16 −0
drivers/serial/kgdboc.c+14−0
@@ -16,6 +16,7 @@ · 15 unmodified lines
16#include <linux/kgdb.h>16#include <linux/kgdb.h>
17#include <linux/kdb.h>17#include <linux/kdb.h>
18#include <linux/tty.h>18#include <linux/tty.h>
19#include <linux/console.h>
19 20
20#define MAX_CONFIG_LEN 4021#define MAX_CONFIG_LEN 40
21 22
@@ -93,12 +94,14 @@ static int configure_kgdboc(void) · 71 unmodified lines
93 int tty_line = 0;94 int tty_line = 0;
94 int err;95 int err;
95 char *cptr = config;96 char *cptr = config;
97 struct console *cons;
96 98
97 err = kgdboc_option_setup(config);99 err = kgdboc_option_setup(config);
98 if (err || !strlen(config) || isspace(config[0]))100 if (err || !strlen(config) || isspace(config[0]))
99 goto noconfig;101 goto noconfig;
100 102
101 err = -ENODEV;103 err = -ENODEV;
104 kgdboc_io_ops.is_console = 0;
102 kgdb_tty_driver = NULL;105 kgdb_tty_driver = NULL;
103 106
104 if (kgdboc_register_kbd(&cptr))107 if (kgdboc_register_kbd(&cptr))
@@ -108,6 +111,17 @@ static int configure_kgdboc(void) · 3 unmodified lines
108 if (!p)111 if (!p)
109 goto noconfig;112 goto noconfig;
110 113
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
111 kgdb_tty_driver = p;125 kgdb_tty_driver = p;
112 kgdb_tty_line = tty_line;126 kgdb_tty_line = tty_line;
113 127
include/linux/kgdb.h+3−0
@@ -247,6 +247,8 @@ struct kgdb_arch { · 246 unmodified lines
247 * the I/O driver.247 * the I/O driver.
248 * @post_exception: Pointer to a function that will do any cleanup work248 * @post_exception: Pointer to a function that will do any cleanup work
249 * for the I/O driver.249 * 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
250 */252 */
251struct kgdb_io {253struct kgdb_io {
252 const char *name;254 const char *name;
@@ -256,6 +258,7 @@ struct kgdb_io { · 3 unmodified lines
256 int (*init) (void);258 int (*init) (void);
257 void (*pre_exception) (void);259 void (*pre_exception) (void);
258 void (*post_exception) (void);260 void (*post_exception) (void);
261 int is_console;
259};262};
260 263
261extern struct kgdb_arch arch_kgdb_ops;264extern struct kgdb_arch arch_kgdb_ops;
kernel/debug/kdb/kdb_io.c+16−0
@@ -673,6 +673,14 @@ kdb_printit: · 672 unmodified lines
673 if (!dbg_kdb_mode && kgdb_connected) {673 if (!dbg_kdb_mode && kgdb_connected) {
674 gdbstub_msg_write(kdb_buffer, retlen);674 gdbstub_msg_write(kdb_buffer, retlen);
675 } else {675 } 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 }
676 while (c) {684 while (c) {
677 c->write(c, kdb_buffer, retlen);685 c->write(c, kdb_buffer, retlen);
678 touch_nmi_watchdog();686 touch_nmi_watchdog();
@@ -719,6 +727,14 @@ kdb_printit: · 40 unmodified lines
719 kdb_input_flush();727 kdb_input_flush();
720 c = console_drivers;728 c = console_drivers;
721 729
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 }
722 while (c) {738 while (c) {
723 c->write(c, moreprompt, strlen(moreprompt));739 c->write(c, moreprompt, strlen(moreprompt));
724 touch_nmi_watchdog();740 touch_nmi_watchdog();