From peterjeremy@acm.org  Fri Jul  8 07:32:29 2011
Return-Path: <peterjeremy@acm.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D4C911065678
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  8 Jul 2011 07:32:29 +0000 (UTC)
	(envelope-from peterjeremy@acm.org)
Received: from mail10.syd.optusnet.com.au (mail10.syd.optusnet.com.au [211.29.132.191])
	by mx1.freebsd.org (Postfix) with ESMTP id 564CE8FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  8 Jul 2011 07:32:28 +0000 (UTC)
Received: from server.vk2pj.dyndns.org (c220-239-116-103.belrs4.nsw.optusnet.com.au [220.239.116.103])
	by mail10.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p687WPCB005324
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 8 Jul 2011 17:32:26 +1000
Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1])
	by server.vk2pj.dyndns.org (8.14.4/8.14.4) with ESMTP id p687WN6u090827;
	Fri, 8 Jul 2011 17:32:23 +1000 (EST)
	(envelope-from peter@server.vk2pj.dyndns.org)
Received: (from peter@localhost)
	by server.vk2pj.dyndns.org (8.14.4/8.14.4/Submit) id p687WNRw090826;
	Fri, 8 Jul 2011 17:32:23 +1000 (EST)
	(envelope-from peter)
Message-Id: <201107080732.p687WNRw090826@server.vk2pj.dyndns.org>
Date: Fri, 8 Jul 2011 17:32:23 +1000 (EST)
From: Peter Jeremy <peterjeremy@acm.org>
Reply-To: Peter Jeremy <peterjeremy@acm.org>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] Fix kgdb on sparc64
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         158719
>Category:       gnu
>Synopsis:       [patch] Fix kgdb(1) on sparc64
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    marius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 08 07:40:01 UTC 2011
>Closed-Date:    Sat Aug 13 17:38:48 UTC 2011
>Last-Modified:  Sat Aug 13 17:38:48 UTC 2011
>Originator:     Peter Jeremy
>Release:        FreeBSD 8.2-STABLE amd64
>Organization:
n/a
>Environment:
System: FreeBSD sb1500.vk2pj.dyndns.org 9.0-CURRENT FreeBSD 9.0-CURRENT #1: Wed\
 Jun 22 17:53:58 EST 2011 root@sb1500.vk2pj.dyndns.org:/usr/obj/usr/src/sys/sb1\
500 sparc64

Patch also tested on: FreeBSD server.vk2pj.dyndns.org 8.2-STABLE FreeBSD 8.2-STABLE #11: Fri Apr 22 11:55:58 EST 2011 root@server.vk2pj.dyndns.org:/var/obj/usr/src/sys/server amd64

>Description:
	kgdb does not work on sparc64.  Following some investigation,
	the problem is that the sparc64 kgdb has two "core_stratum"
	target_ops structures active - the default "Local core dump file"
	defined in contrib/gdb/gdb/corelow.c and the FreeBSD-specific
	"kernel core dump file" defined in gnu/usr.bin/gdb/kgdb/trgt.c

	On at least i386 and amd64, the "Local core dump file" is
	inhibited by statically defining coreops_suppress_target as
	non-zero in gnu/usr.bin/gdb/libgdb/fbsd-threads.c (this file
	defines "FreeBSD multithreaded core dump file" target_ops
	which is itself inhibited by fbsdcoreops_suppress_target in
	gnu/usr.bin/gdb/kgdb/trgt.c).

	sparc64 does not include fbsd-threads.c and therefore
	the "Local core dump file" is not inhibited.  As a result,
	contrib/gdb/gdb/target.c::find_core_target() finds multiple
	targets and returns NULL.

	Note that it's possible that similar problems exist on other
	architectures.

>How-To-Repeat:
	Run "kgdb /boot/kernel/kernel /dev/mem" as root on sparc64.
	It will report "GDB can't read core files on this machine."

>Fix:
	It's not possible to directly inhibit the "Local core dump file"
	by defining coreops_suppress_target in trgt.c because that
	results in a duplicate definition on (eg) amd64.  Likewise a
	weak DATA symbol does not override a strong BSS symbol.

	The following patch therefore defines coreops_suppress_target
	in a file that is only active on sparc64 kgdb.

Index: gnu/usr.bin/gdb/kgdb/trgt_sparc64.c
===================================================================
RCS file: /usr/ncvs/src/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c,v
retrieving revision 1.8
diff -u -r1.8 trgt_sparc64.c
--- gnu/usr.bin/gdb/kgdb/trgt_sparc64.c	1 May 2008 20:36:48 -0000	1.8
+++ gnu/usr.bin/gdb/kgdb/trgt_sparc64.c	8 Jul 2011 06:17:55 -0000
@@ -197,3 +197,9 @@
 	/* printf("%s: %lx =%s\n", __func__, pc, pname); */
 	return (NULL);
 }
+/* 
+** Disable the default "Local core dump file" target.  This is done in
+** libgdb/fbsd-threads.c for most targets but that file is not used on
+** sparc64
+*/
+int coreops_suppress_target = 1;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: marius 
State-Changed-When: Sat Aug 6 21:40:58 UTC 2011 
State-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=158719 

From: Mark Linimon <linimon@lonesome.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: gnu/158719: [patch] Fix kgdb(1) on sparc64
Date: Sat, 6 Aug 2011 21:28:24 -0500

 ----- Forwarded message from Marius Strobl <marius@alchemy.franken.de> -----
 
 Date: Sun, 7 Aug 2011 00:07:44 +0200
 From: Marius Strobl <marius@alchemy.franken.de>
 To: peterjeremy@acm.org, freebsd-bugs@FreeBSD.org
 Cc: 
 Subject: Re: gnu/158719: [patch] Fix kgdb(1) on sparc64
 User-Agent: Mutt/1.4.2.3i
 
 On Sat, Aug 06, 2011 at 09:41:45PM +0000, marius@FreeBSD.org wrote:
 > Synopsis: [patch] Fix kgdb(1) on sparc64
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: marius
 > State-Changed-When: Sat Aug 6 21:40:58 UTC 2011
 > State-Changed-Why: 
 > 
 
 This was closed accidentally; while the problem was fixed in r224687 this
 PR shouldn't have been closed until that revision and the ones leading
 up to it are MFC'ed.
 
 ----- End forwarded message -----
State-Changed-From-To: closed->open 
State-Changed-By: linimon 
State-Changed-When: Sun Aug 7 03:45:54 UTC 2011 
State-Changed-Why:  
reopen; closed accidentally. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158719 
Responsible-Changed-From-To: freebsd-bugs->marius 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Aug 7 03:46:23 UTC 2011 
Responsible-Changed-Why:  
Over as MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158719 
State-Changed-From-To: open->patched 
State-Changed-By: linimon 
State-Changed-When: Mon Aug 8 03:59:54 UTC 2011 
State-Changed-Why:  
set as MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158719 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: gnu/158719: commit references a PR
Date: Sat, 13 Aug 2011 13:09:52 +0000 (UTC)

 Author: marius
 Date: Sat Aug 13 13:09:43 2011
 New Revision: 224832
 URL: http://svn.freebsd.org/changeset/base/224832
 
 Log:
   MFC: r224687
   
   Compile fbsd-threads.c. Amongst others this is necessary for a working
   kgdb(1).
   
   PR:		158719
   Reviewed by:	marcel
 
 Modified:
   stable/8/gnu/usr.bin/gdb/arch/sparc64/Makefile
   stable/8/gnu/usr.bin/gdb/arch/sparc64/init.c
 Directory Properties:
   stable/8/gnu/usr.bin/gdb/arch/sparc64/   (props changed)
 
 Modified: stable/8/gnu/usr.bin/gdb/arch/sparc64/Makefile
 ==============================================================================
 --- stable/8/gnu/usr.bin/gdb/arch/sparc64/Makefile	Sat Aug 13 12:57:51 2011	(r224831)
 +++ stable/8/gnu/usr.bin/gdb/arch/sparc64/Makefile	Sat Aug 13 13:09:43 2011	(r224832)
 @@ -1,6 +1,7 @@
  # $FreeBSD$
  
  .if !defined(GDB_CROSS_DEBUGGER)
 +LIBSRCS+= fbsd-threads.c
  LIBSRCS+= solib.c solib-legacy.c solib-svr4.c
  LIBSRCS+= sparc-nat.c sparc64-nat.c sparc64fbsd-nat.c
  .endif
 
 Modified: stable/8/gnu/usr.bin/gdb/arch/sparc64/init.c
 ==============================================================================
 --- stable/8/gnu/usr.bin/gdb/arch/sparc64/init.c	Sat Aug 13 12:57:51 2011	(r224831)
 +++ stable/8/gnu/usr.bin/gdb/arch/sparc64/init.c	Sat Aug 13 13:09:43 2011	(r224832)
 @@ -11,6 +11,7 @@ extern initialize_file_ftype _initialize
  extern initialize_file_ftype _initialize_ser_hardwire;
  extern initialize_file_ftype _initialize_ser_pipe;
  extern initialize_file_ftype _initialize_ser_tcp;
 +extern initialize_file_ftype _initialize_thread_db;
  extern initialize_file_ftype _initialize_sparc64fbsd_nat;
  extern initialize_file_ftype _initialize_sparc64_nat;
  extern initialize_file_ftype _initialize_sparc_nat;
 @@ -124,6 +125,7 @@ initialize_all_files (void)
    _initialize_ser_pipe ();
    _initialize_ser_tcp ();
  #ifndef CROSS_DEBUGGER
 +  _initialize_thread_db ();
    _initialize_sparc64fbsd_nat ();
    _initialize_sparc64_nat ();
    _initialize_sparc_nat ();
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: marius 
State-Changed-When: Sat Aug 13 17:38:37 UTC 2011 
State-Changed-Why:  
close 

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