Subject: kgdb status, questions
To: None <port-i386@NetBSD.ORG>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: port-i386
Date: 04/22/1997 19:30:07
So, FYI, because of the need to debug something, I've gone ahead and
added remote KGDB glue to the i386 port (this is different from Matthias
Drochner's in that it uses the MI KGDB support code that is already
in NetBSD) ... it seems to essentially work correctly:

(target - booted with -d)
. . .
isa0 at mainbus0
com0 at isa0 port 0x3f8-0x3ff irq 4: ns8250 or ns16450, no fifo
com1 at isa0 port 0x2f8-0x2ff irq 3: ns8250 or ns16450, no fifo
com1: kgdb waiting...connected.
. . .

(host)
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.11 (i386-netbsd), Copyright 1993 Free Software Foundation, Inc...
(kgdb) set remotebaud 9600
(kgdb) target remote /dev/tty01
Remote debugging using /dev/tty01
kgdb_connect (verbose=1) at ../../../../arch/i386/i386/kgdb_machdep.c:210
210             if (verbose)
(kgdb) where
#0  kgdb_connect (verbose=1) at ../../../../arch/i386/i386/kgdb_machdep.c:210
#1  0xf81b2dd4 in com_kgdb_attach (sc=0xf86d7000, iot=0, ioh=980)
    at ../../../../dev/isa/com.c:356
#2  0xf81b2fae in com_attach_subr (sc=0xf86d7000)
    at ../../../../dev/isa/com.c:480
#3  0xf81b4729 in com_isa_attach (parent=0xf86c5e80, self=0xf86d7000, 
    aux=0xf8201dfc) at ../../../../dev/isa/com_isa.c:131
#4  0xf811df34 in config_attach (parent=0xf86c5e80, match=0xf81a5a51, 
    aux=0xf8201dfc, print=0xf81b2574 <isaprint>)
    at ../../../../kern/subr_autoconf.c:412
#5  0xf81b26de in isascan (parent=0xf86c5e80, match=0xf86d7000)
    at ../../../../dev/isa/isa.c:183
#6  0xf811dbf4 in config_scan (fn=0xf81b263c <isascan>, parent=0x3d4)
    at ../../../../kern/subr_autoconf.c:235
#7  0xf81b2540 in isaattach (parent=0xf86cdf40, self=0xf86c5e80, 
    aux=0xf8201ed0) at ../../../../dev/isa/isa.c:124
#8  0xf811df34 in config_attach (parent=0xf86cdf40, match=0xf81a5a51, 
    aux=0xf8201ed0, print=0xf81b2428 <mainbus_print>)
    at ../../../../kern/subr_autoconf.c:412
#9  0xf811dced in config_found_sm (parent=0xf86cdf40, aux=0xf8201ed0, 
    print=0xf81b2428 <mainbus_print>, submatch=0)
    at ../../../../kern/subr_autoconf.c:301
#10 0xf81b240e in mainbus_attach (parent=0x0, self=0xf86cdf40, aux=0x0)
---Type <return> to continue, or q <return> to quit---qQuit
 at ../..(kgdb) c
Continuing.

...etc.  There still appear to be a few slight problems... For one,
I can't seem to interrupt the target .. this should be possible
with ^C on the gdb side of things, but it doesn't seem to be working.
Setting a breakpoint in comintr() shows that comintr() isn't getting
called, although I'm fairly sure I've got interrupts enabled on
the serial port.  I'll do some more fiddling with this.

The other problem I'm seeing is the inability to single-step.  If
I attempt to do so, the kernel appears to just keep on going.  However,
I did notice:

Process (pid 1) got signal 5

...which is SIGTRAP, which is what T_BPTFLT is translated into.  Looks
like it set the next breakpoint in the wrong place?  Anyhow, interestingly
enough, the machine booted into multi-user mode (i.e. init didn't die,
not entirely sure why :-).

Anyhow, if anyone has any bright ideas, here, I'd appreciate them,
since I'm not really much of an i386 guru at all (but, rather, just
_really_ needed a decent debugger, for the bus dma stuff :-).

Ciao.

Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                               Home: 408.866.1912
NAS: M/S 258-6                                          Work: 415.604.0935
Moffett Field, CA 94035                                Pager: 415.428.6939