Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103019815
D28676.id83902.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D28676.id83902.diff
View Options
Index: sys/ddb/db_input.c
===================================================================
--- sys/ddb/db_input.c
+++ sys/ddb/db_input.c
@@ -54,6 +54,14 @@
static char * db_lc; /* current character */
static char * db_le; /* one past last character */
+/*
+ * Raw input buffer, processed only for certain control characters.
+ */
+#define DB_RAW_SIZE 512
+static char db_raw[DB_RAW_SIZE];
+static int db_raw_pos;
+static int db_raw_cnt;
+
/*
* Simple input line history support.
*/
@@ -65,11 +73,13 @@
#define BLANK ' '
#define BACKUP '\b'
-static int cnmaygetc(void);
static void db_delete(int n, int bwd);
static int db_inputchar(int c);
static void db_putnchars(int c, int count);
static void db_putstring(char *s, int count);
+static int db_raw_pop(void);
+static void db_raw_push(int);
+static int db_raw_space(void);
static void
db_putstring(s, count)
@@ -307,10 +317,49 @@
return (0);
}
+/* Get a character from the console, first checking the raw input buffer. */
+int
+db_getc(void)
+{
+ int c;
+
+ if (db_raw_cnt == 0) {
+ c = cngetc();
+ } else {
+ c = db_raw_pop();
+ if (c == '\r')
+ c = '\n';
+ }
+ return (c);
+}
+
+/* Whether the raw input buffer has space to accept another character. */
static int
-cnmaygetc()
+db_raw_space(void)
+{
+
+ return (db_raw_cnt < DB_RAW_SIZE);
+}
+
+/* Un-get a character from the console by buffering it. */
+static void
+db_raw_push(int c)
{
- return (-1);
+
+ if (!db_raw_space())
+ db_error(NULL);
+ db_raw[(db_raw_pos + db_raw_cnt++) % DB_RAW_SIZE] = c;
+}
+
+/* Drain a character from the raw input buffer. */
+static int
+db_raw_pop(void)
+{
+
+ if (db_raw_cnt == 0)
+ return (-1);
+ db_raw_cnt--;
+ return (db_raw[db_raw_pos++ % DB_RAW_SIZE]);
}
int
@@ -339,7 +388,7 @@
db_lc = lstart;
db_le = lstart;
- while (!db_inputchar(cngetc()))
+ while (!db_inputchar(db_getc()))
continue;
db_capture_write(lstart, db_le - db_lbuf_start);
@@ -361,30 +410,48 @@
return (db_le - db_lbuf_start);
}
+static void
+db_do_interrupt(const char *reason)
+{
+
+ db_disable_pager();
+ db_pager_quit = 1;
+ db_error(reason);
+}
+
void
db_check_interrupt(void)
{
int c;
- c = cnmaygetc();
- switch (c) {
- case -1: /* no character */
- return;
-
- case CTRL('c'):
- db_error((char *)0);
- /*NOTREACHED*/
-
- case CTRL('s'):
- do {
- c = cnmaygetc();
- if (c == CTRL('c'))
- db_error((char *)0);
- } while (c != CTRL('q'));
- break;
+ /*
+ * Check console input for control characters. Non-control characters
+ * are buffered. When buffer space is exhausted, further non-control
+ * input is dropped on the floor in order to continue responding to
+ * control input.
+ */
+ for (;;) {
+ c = cncheckc();
+ switch (c) {
+ case -1: /* no character */
+ return;
+
+ case CTRL('c'):
+ db_do_interrupt("^C");
+ /*NOTREACHED*/
+
+ case CTRL('s'):
+ do {
+ c = cncheckc();
+ if (c == CTRL('c'))
+ db_do_interrupt("^C");
+ } while (c != CTRL('q'));
+ break;
- default:
- /* drop on floor */
- break;
+ default:
+ if (db_raw_space())
+ db_raw_push(c);
+ break;
+ }
}
}
Index: sys/ddb/db_output.c
===================================================================
--- sys/ddb/db_output.c
+++ sys/ddb/db_output.c
@@ -260,7 +260,7 @@
db_printf("--More--\r");
done = 0;
while (!done) {
- c = cngetc();
+ c = db_getc();
switch (c) {
case 'e':
case 'j':
Index: sys/ddb/ddb.h
===================================================================
--- sys/ddb/ddb.h
+++ sys/ddb/ddb.h
@@ -197,6 +197,7 @@
/* instruction disassembler */
void db_error(const char *s);
int db_expression(db_expr_t *valuep);
+int db_getc(void);
int db_get_variable(db_expr_t *valuep);
void db_iprintf(const char *,...) __printflike(1, 2);
struct proc *db_lookup_proc(db_expr_t addr);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 20, 10:01 PM (19 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14748142
Default Alt Text
D28676.id83902.diff (3 KB)
Attached To
Mode
D28676: ddb: enable the use of ^C and ^S/^Q
Attached
Detach File
Event Timeline
Log In to Comment