How to debug BSD kernel?
Let's call a debug target machine "A" and a dubug work machine "B". We access to "tty01" of machine A through "tty00" of machine B.
  1. Put the following configuration options to the configuration file and build "bsd" and "bsd.gdb" on machie B.
    makeoptions     DEBUG="-g"
    options         DEBUG
    options         KGDB
    options         "KGDBDEV=0x800001" 
    
    Note that "0x8000001" indicates "tty01" of machine A, majar device number is 8 and minor is 1.

  2. Copy "bsd" to machine A and reboot it.

  3. On the directory where "bsd.gdb" exists on machine B, execute the following command.
    gdb -k bsd.gdb
    
    It would be very useful if you run "gdb" on Emacs.

  4. Type the following "gdb" subcommand on machine B to access machine A.
    target remote /dev/tty00
    

    Now the kernel on machine A is suspended.

  5. Try "gdb" command whatever you like. For instance, set a break point and continue the kernel on machine A....