Subject: (inactive) kgdb without disabling com port on host
To: None <netbsd-help@netbsd.org>
From: Greg Troxel <gdt@ir.bbn.com>
List: netbsd-help
Date: 09/24/2004 15:47:37
I have a number of systems and would like them to run the same kernel
(common build procedure, binary upgrades).  I would further like them
to be usable with remote kernel gdb.  Each system has 1 serial port
(IBM T30, 600E, 600, T41/docking-station, X31/ultrabase).

I enabled KGDB in the kernel, but:
(gdb) target remote /dev/dty00
/dev/dty00: Device busy.

After reading sources, I see that in sys/dev/ic/com.c:comopen():

#ifdef KGDB
       /*
        * If this is the kgdb port, no other use is permitted.
	 */
	 if (ISSET(sc->sc_hwflags, COM_HW_KGDB))
	    return (EBUSY);
#endif

following this at attach time:

	if (iot == com_kgdb_iot && iobase == com_kgdb_addr) {
		if (!ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
			com_kgdb_attached = 1;

			SET(sc->sc_hwflags, COM_HW_KGDB);
		}
		aprint_normal("%s: kgdb\n", sc->sc_dev.dv_xname);
	}


I realize that one can't use kgdb and a com port for something else at
the same time, but my 'host' was not booted with -d, and has 0 for
both kgdb_debug_panic and kgdb_debug_init.  So I don't see the harm in
using the single serial port for the host.

Has anyone tried just removing the check in comopen, or added some
boot-time variable to enable kgdb, so that it is disabled otherwise
and the serial port is usable?  I'm about to disable the comopen
check, since apparently it's disabled if the port is the console, and
will see what happens.