EVERYTHING YOU EVER WANTED TO KNOW ABOUT THE KERNEL DEBUGGER (KDB):
Author: Robert Baron
Date: May 15, 1990


I have recently brought the I386 kdb up to spec.  And I decided
that as part of the processes I'd try to document it.  So, what
am I missing in the description below.  (Obviously expertise in
adb is assumed.)  Note: not all machines have :r, :S, <fn>! and pb!
yet;  but they should be added for the other architectures.

Also, I could not take the runpcs/longjmp crap that handled
the flow control, so I redid it -- much more clearly/cleanly.
You might want to look at i386/kdb/kdb_main.c on rvb_X109.


To enter the debugger:
	machine			method

	vax, pmax		"do" key
	sun3			f1,q
	rt			ctrl-alt-break
	i386			ctrl-alt-d


	The format commands:
		 <addr>/<letters>
and write commands
		<addr>/{w,W} values
function exactly as you would expect from adb.  (And note that / and ?
are treated the same.)  So you can use kdb to disassemble code, look at
memory locations and change memory locations.

	$r	-	will print out the register values
	<rname/var	accesses the value of register_name/variable
	>rname/var	sets the value of register_name/variable
(All this is like adb.)

	The neet features are the "step/breakpoint" commands, which are
again analogous to the adb functions:
	:s	-	single step one instruction
	:c,C	- 	continue till the next breakpoint
			(these both takes counts ala adb syntax)
(and now for the wizzy ones)
	:p,P	-	print the instructions while single stepping
	:j	-	step till the next call or return and count
			 the instructions
	:J	-	step till we return to this nesting level
			 (show functions entered and instruction
			  counts.)
	:S	-	step over the function call you are stopped at
	:r,R	-	set a temporary break at the return address, so
			 you effectively step out of this function. (Note:
			 make sure you have done the push %ebp, movl %esp, %ebp
			 before you try this.)

	Breakpoints are set with <addr>:B and <addr>:D and listed with $B, just
like adb.  You may not provide commands to execute when a breakpoint is hit.
<addr>:b #, <addr>:d and $b are very different breakpoints.  They use the i386
hardware match facilities.  You can set up to 4 breakpoints and you have to
specify which one to ":b".  Right now they work analogous to the "B" breakpoints.
But someday, I will implement access to the hardware break on read and break on
write features;  all that is supported now is break on execute.

	Are we done yet, ...

	$l	-	lists the state of all the threads
	$L	-	lists the state and stack of all the threads

	$k	-	does a stack trace
	$c	-	does a stack trace
<thread>$K	-	does a stack trace for the give thread
<addres>$C	-	does a stack trace at the given frame.
   <map>$m	-	prints the map at address <map>
<addres>$Pp	-	prints port
<addres>$PO	-	prints object
<addres>$PM	-	prints map
<addres>$PP	-	prints "page structure"
<addres>$P

<function>! arg0 arg1 ...	invokes function with the given arguments

	R!	-	invokes the function to sync the disk and reboot
	Q!	-	invokes the function to reboot

	pb!	-	invokes the playback function.  The screen is small
			 compared to the info you might want to display; pb
			 will play back each line and wait for a space or
			 return before continuing.  Any other character 
			 terminates playback.  The buffer is 64k.


