⬢ DragonFlyBSD Kernel Audit
DF-2361 / rig-attach.diff
← back to finding ↓ download raw
--- a/sys/kern/tty_cons.c
+++ b/sys/kern/tty_cons.c
@@ -214,9 +214,28 @@ cninit(void)
 void
 cninit_finish(void)
 {
+	/*
+	 * AUDIT RIG for DF-2361/DF-2362 verification (local only, not for
+	 * upstream): attach the gdb debug console at boot when the loader
+	 * sets rig.gdbconsole=1. Mirrors the sio COM_DEBUGGER (flags 0x80)
+	 * attach at sio.c:3113-3119 which does not trigger on this ACPI
+	 * guest (hint.sio.0.flags=0x90 gave a serial console but left
+	 * gdb_tab NULL, verified via DDB). The gdb stub TU under test
+	 * (sys/cpu/x86_64/misc/x86_64-gdbstub.c) is NOT modified.
+	 */
+	{
+		char *ev;
+
+		if ((ev = kgetenv("rig.gdbconsole")) != NULL &&
+		    gdb_tab == NULL && cn_tab != NULL) {
+			gdb_tab = cn_tab;
+			kprintf("rig: gdb_tab attached to console "
+			    "(rig.gdbconsole=%s)\n", ev);
+		}
+	}
+
 	if ((cn_tab == NULL) || cn_mute)
 		return;
+
 	if (cn_tab->cn_dev == NULL) {
 		cn_tab->cn_init_fini(cn_tab);
 		if (cn_tab->cn_dev == NULL) {