Subject: MI debugger magic key sequence
To: None <>
From: Eduardo Horvath <>
List: tech-kern
Date: 09/20/2000 16:35:19
Breaking into the debugger from the console is an interesting problem.
Most serial drivers have code to check if they are the console if they
receive a BREAK and check if they are the console.  Others can have
keyboards attached and have checks for specific key sequences.

These methods are not particularly flexible or customizable.  There are
times when you don't want a machine to ignore BREAK.  It might be
desirable to have a long, obscure key sequence break into the
debugger.  And one serial driver may be used by different ports that have
different key sequences to enter the debugger.  Or different sequences
should be used by different ports.

Anyway, I'm proposing an interface to solve these issues:


This is a MD routine that needs to be defined for each port.  It does
whatever is necessary to enter the debugger, PROM, whatever.

db_check_magic(dev_t, dev, int k);

Checks the key sequence (k) to see if it matches the the magic sequence.
If there is a match, it calls db_console().

dev	dev_t of the instance of the device that recieved a keystroke.

k	Byte read from serial line or keyboard.  Break is represented by
	the value `-1'.

db_set_magic(char *magic);

This routine changes the magic key sequence.  Since the magic sequence can
contain non-ASCII values, it's length must be explicitly specified.
[Need to define some escape sequences for things like BREAK, `\0', etc.]

ddb.magic sysctl variable will be added.  This takes a
string.  db_set_magic() will be used to convert ddb.magic to an internal

db_check_magic() will be implemented as either an inline function or
macro.  There will also be a `static struct db_magic_state' used
internally to run a state machine allowing complicated multi-byte magic
debugger sequences.

Eduardo Horvath