From jeremyp@gsmx07.alcatel.com.au  Thu Feb  7 12:39:03 2002
Return-Path: <jeremyp@gsmx07.alcatel.com.au>
Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27])
	by hub.freebsd.org (Postfix) with ESMTP id 7E65637B41A
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  7 Feb 2002 12:38:59 -0800 (PST)
Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1])
	by netau1.alcanet.com.au (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id HAA13556
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 8 Feb 2002 07:38:57 +1100 (EDT)
Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au
 (PMDF V5.2-32 #37645) with ESMTP id <01KE0V0QH3W05IK0SK@cim.alcatel.com.au>
 for FreeBSD-gnats-submit@freebsd.org; Fri, 8 Feb 2002 07:39:01 +1100
Received: (from jeremyp@localhost)	by gsmx07.alcatel.com.au (8.11.6/8.11.6)
 id g17Kcrt79668; Fri, 08 Feb 2002 07:38:53 +1100 (EST envelope-from jeremyp)
Message-Id: <200202072038.g17Kcrt79668@gsmx07.alcatel.com.au>
Date: Fri, 08 Feb 2002 07:38:53 +1100 (EST)
From: Peter Jeremy <peter.jeremy@alcatel.com.au>
Reply-To:
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] Inaccurate GDB documentation
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         34709
>Category:       gnu
>Synopsis:       [patch] Inaccurate GDB documentation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    marcel
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 07 12:40:01 PST 2002
>Closed-Date:    Wed Feb 27 23:54:59 UTC 2008
>Last-Modified:  Wed Feb 27 23:54:59 UTC 2008
>Originator:     Peter Jeremy
>Release:        FreeBSD 4.4-STABLE i386
>Organization:
Alcatel Australia
>Environment:
System: FreeBSD aalp03.alcatel.com.au 4.4-STABLE FreeBSD 4.4-STABLE #0: Wed Dec 19 03:14:51 EST 2001     root@aalp03.alcatel.com.au:/usr/obj/usr/src/sys/wansim  i386

>Description:
	The GDB .info documentation states (node "Patching"):
`set write on'
`set write off'
     If you specify `set write on', GDB opens executable and core files
     for both reading and writing; if you specify `set write off' (the
     default), GDB opens them read-only.

	When in kgdb mode, the "set write" command has no effect.  Instead
	the command line option "-wcore" must be used.  This option is not
	documented in the .info file.  Whilst it is documented in the
	man page, GNU man pages are generally not reliable.

>How-To-Repeat:

aalp03# gdb -k /kernel /dev/mem
GNU gdb 4.18
...
#0  0xc0159bf0 in mi_switch ()
(kgdb) set write on 
(kgdb) exec-file /kernel
(kgdb) core-file /dev/mem
IdlePTD 3457024
initial pcb at 724e000
panic messages:
---
---
#0  0xc0159bf0 in mi_switch ()
(kgdb) x/4x sched_yield+16
0xc01fffa4 <sched_yield+16>:    0x00004eb8      0x5dec8900      0x00768dc3     0x8be58955
(kgdb) print {int}0xc01fffa4 = 0x00004eb8
kvm_write:write failed
(kgdb)
	
>Fix:

	The .info file should be updated to correctly document GDB
	behaviour.  The following patch is untested.

Index: gdb.texinfo
===================================================================
RCS file: /usr/ncvs/src/contrib/gdb/gdb/doc/gdb.texinfo,v
retrieving revision 1.3
diff -u -r1.3 gdb.texinfo
--- gdb.texinfo 2 May 1999 11:25:25 -0000       1.3
+++ gdb.texinfo 7 Feb 2002 20:36:58 -0000
@@ -1266,6 +1266,15 @@
 a signal to display the source code for the frame.
 @end ifclear
 
+@item -kernel
+@itemx -k
+Use gdb in kernel debugging mode.
+The prompt is set to @samp{kgdb}.
+
+@item -wcore
+This option may only be used in kernel debugging mode while debugging
+a ``live'' kernel and makes the corefile @file{/dev/mem} writable.
+
 @ifset SERIAL
 @ifclear HPPA
 @item -b @var{bps}
@@ -7865,6 +7874,9 @@
 @end ifclear
 files for both reading and writing; if you specify @samp{set write
 off} (the default), @value{GDBN} opens them read-only.
+Note that this command has no effect in kernel debugging mode.
+To write to @file{/dev/mem}, you must specift @samp{-wcore} on the
+command line.
 
 If you have already loaded a file, you must load it again (using the
 @code{exec-file}
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->marcel 
Responsible-Changed-By: marcel 
Responsible-Changed-When: Sat Jul 17 01:47:55 GMT 2004 
Responsible-Changed-Why:  
That's what you get when you enhance gdb by kluging. I'm not sure 
it's important to fix, because it would require changing contributed 
files or otherwise remove the feature. FreeBSD 4 is getting near 
its end, so this probably can be closed... 

http://www.freebsd.org/cgi/query-pr.cgi?pr=34709 
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Wed Feb 27 23:54:15 UTC 2008 
State-Changed-Why:  
Apparently this only applied to FreeBSD 4, which is EOL. 

noted by:	Bruce Cran 

http://www.freebsd.org/cgi/query-pr.cgi?pr=34709 
>Unformatted:
