Re: kernel debugger

From: George Anzinger (george@pioneer.net)
Date: Wed Apr 26 2000 - 08:16:08 EST


I can tell you what I know. Maybe others can fill in the missing code.
In the /arch/??/kernel directory you need to find something called
xxxstubxxx.c where the xxxs can be anything. I don't have this code for
the Alpha. The "stub" communicates with gdb on the "host" system using
a serial line so... you need a serial port and a bare bones driver for
it. In some systems this driver is in the standard serial driver and in
others it is a seperate bit of code. It needs to support the following
two calls: getDebugChar(??) and putDebugChar(char,??) (or is it
(??,char)). Most (all) of the stubs I have seen are braindead about
configuring. In fact I have rewritten the ix86 and ppc stubs to not
need configuring at all. This is good because it means you can set
breakpoints VERY early in the code. Give the you can find the above
code, the rest is easy and I think I can help. Here is what I have
done:

Set up the parse code in main.c that parses the boot string to look for
"break" and execute a breakpoint instruction if it finds it. This gets
you into the debugger very early in the bring up. At this point you can
set breakpoints in the code you are interested in.

Also added a call to initialize the interrupt section of the
get/putDebugChar() code at the end of kernel bring up after all the i/o
is initialized. This should allow gdb on the host to break the target
machine by sending a ^C down the serial line.

Modified traps.c to send all kernel traps to the "stub" trap handler.
traps.c is in the arch/xx/kernel section so you should get it along with
the stub code.

All this code is enabled by the configure symbol CONFIG_KGDB and a
header file from include/archasm/kgdb.h. This file must define the
break point instruction as BREAKPOINT and also define the interrupt
enable entry point.

I have also modified the configure scripts to turn on CONFIG_KGDB and in
the ix86 case define the port, irq, and baud of the serial port.

This, of course, means that config.in and two of the make files are also
modified.

What is left. Well as I said, I have only been working with ix86 and
ppc code. I still haven't tracked down how to actually get the
interrupt conntected to the serial driver. I work on embedded system
that often have only one serial port that must be shared with the system
console. I need to write code to share the line for this.

I would like to see all this in the official tree someday. Cost if not
selected is zero in terms of system space and overhead (i.e. it is
configured completly out), but if needed, well you just turn it on with
your favored varity of config.

George

Jan-Benedict Glaw wrote:
>
> On Wed, Apr 26, 2000 at 05:33:49AM -0700, George Anzinger wrote:
> > Me thinks I could help you more if you were to tell me what version and
> > arch you are trying to debug. I have done some work on kernel debug
> > options for the i386 branch at 2.2.1x rev level.
> >
> > Folks, any support for making kernel debug a configure option in the
> > kernel? I will kick it off with an ix86 patch (to be followed by ppc)
> > if there is interest.
>
> Personally I'm more interested in a kernel debugger patch for Alpha...
> Given the ia32 patches, how hard is it to implement that? I've got an
> lod Alpha board (AXPpci33 aka NoName, 21066 processor at 166MHz, com-
> parable to a P-120) and I'd like to make this machine a MP3 server which
> should be capable of playing a MP3. (Processor is more than fast enough,
> even if the board is nearly about 10 years old;)
>
> However, machine locks hard if I load any sound drivers (OSS as well as
> ALSA (which I prefer)). I got only one card to work: an old "Audio Blaster"
> which seems to be compatible to a SB-Pro, 8bit sound;( However, adding
> printk()s and recompiling is not nice: half an hour for ALSA, about 3 1/2
> hours for a complete kernel incl. modules... Well, a friend gave me access
> to his Alpha which is a "bit" faster;) But cross-compiling the kernel does
> not really ease the task of IRQ debugging (which I think is the case here...)
>
> MfG, JBG
>
> --
> Fehler eingestehen, Größe zeigen: Nehmt die Rechtschreibreform zurück!!!
> /* Jan-Benedict Glaw <jbglaw@lug-owl.de> -- +49-177-5601720 */
> keyID=0x8399E1BB fingerprint=250D 3BCF 7127 0D8C A444 A961 1DBD 5E75 8399 E1BB
>
> ------------------------------------------------------------------------
> Part 1.2Type: application/pgp-signature

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:11 EST