Date: Wed, 11 Sep 1996 01:20:03 -0700 From: Julian Elischer <julian@whistle.com> To: current@freebsd.org Subject: [HOWTO] Kernel GDB stubs Message-ID: <32367633.167EB0E7@whistle.com>
index | next in thread | raw e-mail
[-- Attachment #1 --]
I'd like to nominate the crew who got the kernel gdb
stub going, for some sort of "GOD for a day" award.
I've been using it with xxgdb over gdb..
the ability to just dump out structures in the kernel,
and single step with source,
all in differnet windows, etc. etc. is amazing..
I'm almost looking forward for excuses to use it..
today I found 2 bugs in the appletalk code, and cleared up my
understanding of some aspects of the VFS system, found a long-standing
bug in a frame-relay driver, and stopped a DEVFS panic,
all using it..
this is almost TOO easy..
Of course you need 2 machines but I have a little old 486
hanging off the back of my pentium here, and it's great.
I did the regulation config -g MYKERN,
then modified the Makefile to add:
cp kernel kernel.debug
strip -d kernel
The debug kernel is a bit big
-rwxr-xr-x 1 julian bmann 8783261 Sep 11 00:25 kernel.debug
but you install the stripped one..
in the compile directory I have the following .gdbinit
set remotebaud 9600
file kernel.debug
target remote /dev/cuaa1
then inthat directory simply run gdb or xxgdb or ddd or tkgdb
or whatever frontend you like.
gdb just sits and awaits a breakpoint or whatever..
don't forget to set
sysctl -w debug.debugger_on_panic=1
on teh target machine if you want to catch panics
and do <CTL><ALT><ESC> once to get into the ddb
then "gdb" to set gdb mode, followed by "cont".
or
Boot: -g
If you have problems, I have the attached patches to sio.c
to make it work for me though some people don't need these.
bde has another patch he prefers, but you shouldn't have sio0 open for
anything else or naturally there will be confusion....
julian
[-- Attachment #2 --]
Index: sio.c
===================================================================
RCS file: /cvs/freebsd/src/sys/i386/isa/sio.c,v
retrieving revision 1.145
diff -c -r1.145 sio.c
*** 1.145 1996/09/06 23:08:05
--- sio.c 1996/09/11 08:16:51
***************
*** 70,75 ****
--- 70,76 ----
#include <i386/isa/isa.h>
#include <i386/isa/isa_device.h>
#include <i386/isa/sioreg.h>
+ #include <machine/cons.h>
#ifdef COM_ESP
#include <i386/isa/ic/esp.h>
***************
*** 266,271 ****
--- 267,274 ----
void *devfs_token_cuai;
#endif
};
+ static int cn_initialised = -2;
+ struct siocnstate sp;
/*
* XXX public functions in drivers should be declared in headers produced
***************
*** 993,998 ****
--- 996,1005 ----
#else
tp = com->tp = &sio_tty[unit];
#endif
+ if( unit == comconsole )
+ if ( cn_initialised == -1 )
+ cn_initialised = 0;
+
s = spltty();
/*
* We jump to this label after all non-interrupted sleeps to pick
***************
*** 1221,1226 ****
--- 1228,1235 ----
com->active_out = FALSE;
wakeup(&com->active_out);
wakeup(TSA_CARR_ON(tp)); /* restart any wopeners */
+ if( unit == comconsole )
+ cn_initialised = -1;
splx(s);
}
***************
*** 2285,2291 ****
/*
* Following are all routines needed for SIO to act as console
*/
- #include <machine/cons.h>
struct siocnstate {
u_char dlbl;
--- 2294,2299 ----
***************
*** 2324,2329 ****
--- 2332,2339 ----
int divisor;
Port_t iobase;
+ /* -2 = initial -1 = don't bother, 1 = done */
+ if((cn_initialised != 0) && (cn_initialised != -2)) return;
/*
* Save all the device control registers except the fifo register
* and set our default ones (cs8 -parenb speed=comdefaultrate).
***************
*** 2348,2353 ****
--- 2358,2364 ----
* an interrupt by floating the IRQ line.
*/
outb(iobase + com_mcr, (sp->mcr & MCR_IENABLE) | MCR_DTR | MCR_RTS);
+ cn_initialised++ ;
}
static void
***************
*** 2356,2361 ****
--- 2367,2373 ----
{
Port_t iobase;
+ if(cn_initialised < 0) return;
/*
* Restore the device control registers.
*/
***************
*** 2370,2375 ****
--- 2382,2388 ----
*/
outb(iobase + com_mcr, sp->mcr | MCR_DTR | MCR_RTS);
outb(iobase + com_ier, sp->ier);
+ cn_initialised--;
}
void
***************
*** 2407,2413 ****
int c;
Port_t iobase;
int s;
- struct siocnstate sp;
iobase = siocniobase;
s = spltty();
--- 2420,2425 ----
***************
*** 2429,2435 ****
int c;
Port_t iobase;
int s;
- struct siocnstate sp;
iobase = siocniobase;
s = spltty();
--- 2441,2446 ----
***************
*** 2448,2454 ****
int c;
{
int s;
- struct siocnstate sp;
s = spltty();
siocnopen(&sp);
--- 2459,2464 ----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32367633.167EB0E7>
