From grog@freebie.lemis.com Fri Apr 23 21:43:34 1999
Return-Path: <grog@freebie.lemis.com>
Received: from allegro.lemis.com (allegro.lemis.com [192.109.197.134])
	by hub.freebsd.org (Postfix) with ESMTP id DF7EE150B9
	for <FreeBSD-gnats-submit@FreeBSD.org>; Fri, 23 Apr 1999 21:43:30 -0700 (PDT)
	(envelope-from grog@freebie.lemis.com)
Received: from freebie.lemis.com (freebie.lemis.com [192.109.197.137])
	by allegro.lemis.com (8.9.1/8.9.0) with ESMTP id OAA16183
	for <FreeBSD-gnats-submit@FreeBSD.org>; Sat, 24 Apr 1999 14:10:59 +0930 (CST)
Received: (from grog@localhost)
	by freebie.lemis.com (8.9.3/8.9.0) id OAA09541;
	Sat, 24 Apr 1999 14:10:57 +0930 (CST)
Message-Id: <199904240440.OAA09541@freebie.lemis.com>
Date: Sat, 24 Apr 1999 14:10:57 +0930 (CST)
From: Greg Lehey <grog@lemis.com>
Sender: grog@freebie.lemis.com
Reply-To: grog@lemis.com
To: FreeBSD-gnats-submit@FreeBSD.org
Subject: Recent kernels have broken symbol tables, confusing gdb
X-Send-Pr-Version: 3.2

>Number:         11299
>Category:       kern
>Synopsis:       Recent kernels have broken symbol tables, confusing gdb
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    grog
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 23 21:50:01 PDT 1999
>Closed-Date:    Thu Aug 19 19:54:35 PDT 1999
>Last-Modified:  Thu Aug 19 20:08:18 PDT 1999
>Originator:     Greg Lehey
>Release:        FreeBSD-4.0-CURRENT
>Organization:
LEMIS
>Environment:

	4.0-CURRENT after about mid-April

>Description:

I've just had a strange experience.  I have some gdb macros which I
use for debugging Vinum.  One, ps, gives me a ps-like listing:

(kgdb) ps
Check your .gdbinit, it contains a y command
  pid    proc    addr   uid  ppid  pgrp   flag stat comm         wchan
 1544 c68a5100 c6df3000    0  1534  1544  004006  2  Vinum
 1534 c68a57e0 c6ddb000    0  1524  1534  004086  3  bash         wait c68a57e0
 1524 c68a5c00 c6dc9000 1004  1516  1524  004086  3  bash         wait c68a5c00

Another macro helps me load symbols from a kld:

Without:

(kgdb) bt
#0  Debugger (msg=0xc11696a0 "vinum debug") at ../../i386/i386/db_interface.c:318
#1  0xc1163585 in ?? ()
#2  0xc01826ea in spec_ioctl (ap=0xc6df4e1c) at ../../miscfs/specfs/spec_vnops.c:440

With:

(kgdb) bt
#0  Debugger (msg=0xc11696a0 "vinum debug") at ../../i386/i386/db_interface.c:318
#1  0xc1163585 in vinumioctl (dev=0x40001901, cmd=0xc008464b, data=0xc6df4ee0 "", flag=0x3, p=0xc68a5100)
    at /src/PANIC/src/sys/modules/Vinum/../../dev/Vinum/vinumioctl.c:96
#2  0xc01826ea in spec_ioctl (ap=0xc6df4e1c) at ../../miscfs/specfs/spec_vnops.c:440

This has worked quite nicely for some time.  Since yesterday, after
building a kernel with newbus support, I get strange messages if I
read in the Vinum symbols before reading in the kernel symbols:

(kgdb) bt
#0  Debugger (msg=0xc11696a0 "vinum debug") at ../../i386/i386/db_interface.c:318
#1  0xc1163585 in vinumioctl (dev=0x40001901, cmd=0xc008464b, data=0xc6df4ee0 "", flag=0x3, p=0xc68a5100)
    at /src/PANIC/src/sys/modules/Vinum/../../dev/Vinum/vinumioctl.c:96
During symbol reading, "repeated" header file opt_global.h not previously seen, at symtab pos 23.
During symbol reading, Invalid symbol data: type number (2,2) out of range at symtab pos 25..
#2  0xc01826ea in spec_ioctl (ap=0xc6df4e1c) at ../../miscfs/specfs/spec_vnops.c:440

The following stack frames also look strange:

#5  0xc017ccdd in vn_ioctl (fp=<error type>, com=<incomplete type>, data=<incomplete type>, p=<error type>)
    at vnode_if.h:395
#6  0xc015c5f7 in ioctl (p=0xc68a5100, uap=0xc6df4f94) at ../../kern/sys_generic.c:564
#7  0xc021e916 in syscall (frame=<error type>) at ../../i386/i386/trap.c:1071

I debugged gdb and found that it was finding these references
(opt_global.h) in cd9660_rrip.o, which it read after reading the Vinum
kld symbols.  If I can convince it to read the kernel symbols first, I
don't have any trouble.  I don't think that it's anything to do with
that particular file; there must be about 30 files in a typical kernel
build which refer to this symbol.

>How-To-Repeat:

	See above.  The "ps" macro is in
	/usr/src/sys/modules/vinum/.gdbinit.kernel, and the "asf"
	macro which loads the symbols of the vinum kld is in
	/usr/src/sys/modules/vinum/.gdbinit.vinum.paths.  It's
	probably easiest to start vinum: just run vinum(8) without any
	parameters, and then enter:

	# vinum
	vinum -> debug 256
	vinum -> debug

	This will cause gdb to go into serial debugging mode.  It
	would also probably be possible to do this with gdb against
	/dev/mem.  If anybody proposes to try it this way, contact me
	and we'll discuss what is needed.

>Fix:

	Not investigated.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: grog 
State-Changed-When: Thu Aug 19 19:54:35 PDT 1999 
State-Changed-Why:  
Problem has gone away. 


Responsible-Changed-From-To: freebsd-bugs->grog 
Responsible-Changed-By: grog 
Responsible-Changed-When: Thu Aug 19 19:54:35 PDT 1999 
Responsible-Changed-Why:  
grog closed this PR. 
>Unformatted:

Greg Lehey, 20 August 1999

	This problem appears to have solved itself.  It no longer
	happens, so I'm closing this PR.
