From owner-doc-jp@jp.freebsd.org  Tue Mar 18 13:22:32 1997
Received: by jaz.jp.freebsd.org (8.8.5+2.7Wbeta5/8.7.3) id NAA05040
	Tue, 18 Mar 1997 13:22:32 +0900 (JST)
Received: by jaz.jp.freebsd.org (8.8.5+2.7Wbeta5/8.7.3) with SMTP id NAA05035
	for <doc-jp@jp.freebsd.org>; Tue, 18 Mar 1997 13:22:30 +0900 (JST)
Received: from amont.astec.co.jp (amont.astec.co.jp [172.20.10.1]) by tokyonet-entrance.astec.co.jp (8.6.12+2.5Wb7/3.4Wbeta5-astecMX2.3) with ESMTP id NAA08249 for <doc-jp@jp.freebsd.org>; Tue, 18 Mar 1997 13:22:28 +0900
Received: from domino.astec.co.jp (domino.astec.co.jp [172.20.10.12]) by amont.astec.co.jp (8.7.6/3.5Wbeta-astecMX2.4) with SMTP id NAA28316 for <doc-jp@jp.freebsd.org>; Tue, 18 Mar 1997 13:22:27 +0900 (JST)
Received: by domino.astec.co.jp (4.1/astec-1.0)
	id AA13289; Tue, 18 Mar 97 13:22:25 JST
Message-Id: <9703180422.AA13289@domino.astec.co.jp>
To: doc-jp@jp.freebsd.org
From: HANAI Hiroyuki <hanai@astec.co.jp>
In-Reply-To: Your message of "Tue, 18 Mar 1997 13:11:11 +0900 (JST)"
References: <199703180411.NAA28228@sirius.sbl.cl.nec.co.jp>
X-Mailer: Mew version 1.06 on Emacs 19.34.1, Mule 2.3
Mime-Version: 1.0
Content-Type: Text/Plain; charset=iso-2022-jp
Date: Tue, 18 Mar 1997 13:22:25 +0900
Reply-To: doc-jp@jp.freebsd.org
Precedence: bulk
X-Distribute: distribute [version 2.1 (Alpha) patchlevel=19]
X-Sequence: doc-jp 2690
Subject: [doc-jp 2690] Re: cvsup.sgml and kerneldebug.sgml have been updated.
Errors-To: owner-doc-jp@jp.freebsd.org
Sender: owner-doc-jp@jp.freebsd.org

$BIMED$5$s(B>
> $B$O$J$$$5$s(B:
> >$B!t(B $B$J$+$J$+%3%f%$$G$7$g$&(B? ;-)
> 
>   $B$*$b$$$C$-$j$3$f$$$G$9$M$'!#Nr;K$K;D$kO+:n$H$$$($^$7$g$&!#(B

$B$5$i$K(B, $BMh7n9f$*$/$j$K$J$C$?(B, $B%O!<%I%G%#%9%/$H(B MO $B$NOC$b(B
$B0l=o$K:\$;$i$l$l$P$b$C$H$3$f$/$J$C$?$s$G$9$,$M$'!D(B

> >>   1.13      +73 -2     src/share/doc/handbook/kerneldebug.sgml
> >$B$H$$$&$3$H$J$N$G(B, $B$A$g$C$HLu$,I,MW$+$b$7$l$s$G$9(B.
> 
>   $B$3$l$O$J$+$J$+$*$b$7$m$=$&$G$9$h$s!#(B

$B$G$7$g$7$g(B.

1.12 $B$H$N(B diff $B$r2<$KIU$1$F$*$-$^$9(B.

Index: kerneldebug.sgml
===================================================================
RCS file: /home/ncvs/src/share/doc/handbook/kerneldebug.sgml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- kerneldebug.sgml	1997/02/22 12:58:44	1.12
+++ kerneldebug.sgml	1997/03/18 00:42:36	1.13
@@ -1,4 +1,4 @@
-<!-- $Id: kerneldebug.sgml,v 1.12 1997/02/22 12:58:44 peter Exp $ -->
+<!-- $Id: kerneldebug.sgml,v 1.13 1997/03/18 00:42:36 joerg Exp $ -->
 <!-- The FreeBSD Documentation Project -->
 
 <chapt><heading>Kernel Debugging<label id="kerneldebug"></heading>
@@ -33,7 +33,10 @@
   to <tt>gdb</tt> run in `kernel debug mode'.  This can be accomplished by
   either starting the <tt>gdb</tt> with the option <tt>-k</tt>, or by linking
   and starting it under the name <tt>kgdb</tt>.  This is not being
-  done by default, however.</em>
+  done by default, however, and the idea is basically deprecated since
+  the GNU folks do not love it if their tools behave differently when
+  called by another name.  This feature might as well be discontinued
+  in further releases.</em>
 
   When the kernel has been built make a copy of it, say
   <tt>kernel.debug</tt>, and then run <tt>strip -d</tt> on the
@@ -410,6 +413,74 @@
   Remember that it is hard to read the on-line manual while
   single-stepping the kernel.
 
+<sect><heading>On-line kernel debugging using remote GDB</heading>
+
+<p>This feature is supported since FreeBSD 2.2, and it's actually
+  a very neat one.
+
+  GDB used to support <em/remote debugging/ for a long time
+  already.  This is done using a very simple protocol along a
+  serial line.  Obviously, and opposed to the other methods
+  described above, you need two machines for doing this.  One is
+  the host providing the debugging environment, including all
+  the sources, and a copy of the kernel binary with all the
+  symbols in it, and the other one is the target machine that
+  simply runs a similar copy of the very same kernel (but stripped
+  off the debugging information).
+
+  You should configure the kernel in question with <tt>config -g</tt>,
+  include <em/DDB/ into the configuration, and compile it as usual.
+  This gives a large blurb of a binary, due
+  to the debugging information.  Copy this kernel to the target
+  machine, strip the debugging symbols off with <tt>strip -x</tt>,
+  and boot it using the <tt/-d/ boot option.  Connect the first
+  serial line of the target machine to any serial line of the
+  debugging host.  Now, on the debugging machine, go to the compile
+  directory of the target kernel, and start gdb:
+<tscreen><verb>
+% gdb -k kernel
+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.16 (i386-unknown-freebsd), 
+Copyright 1996 Free Software Foundation, Inc...
+(kgdb) 
+</verb></tscreen>
+
+  Initialize the remote debugging session (assuming the first serial
+  port is being used) by:
+<tscreen><verb>
+(kgdb) target remote /dev/cuaa0
+</verb></tscreen>
+
+  Now, on the target host (that entered DDB right before even starting
+  the device probe), type:
+<tscreen><verb>
+Debugger("Boot flags requested debugger")
+Stopped at	Debugger+0x35: movb	$0, edata+0x51bc
+db> gdb
+</verb></tscreen>
+
+  DDB will respond with:
+<tscreen><verb>
+Next trap will enter GDB remote protocol mode
+</verb></tscreen>
+
+  Every time you type ``gdb'', the mode will be toggled between
+  remote GDB and local DDB.  In order to force a next trap
+  immediately, simply type ``s'' (step).  Your hosting GDB will
+  now gain control over the target kernel:
+<tscreen><verb>
+Remote debugging using /dev/cuaa0
+Debugger (msg=0xf01b0383 "Boot flags requested debugger")
+    at ../../i386/i386/db_interface.c:257
+(kgdb) 
+</verb></tscreen>
+
+  You can use this session almost as any other GDB session, including
+  full access to the source, running it in gud-mode inside an Emacs
+  window (which gives you an automatic source code display in another
+  Emacs window) etc.
 
 <sect><heading>Debugging a console driver</heading>
 
