>Number:         158719
>Category:       gnu
>Synopsis:       [patch] Fix kgdb on sparc64
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 08 07:40:01 UTC 2011
>Closed-Date:
>Last-Modified:
>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 [email protected]:/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 
[email protected]:/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:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to