diff usr/src/uts/sparc/os/archdep.c @ 12979:ab9ae749152f

PSARC/2009/617 Software Events Notification Parameters CLI PSARC/2009/618 snmp-notify: SNMP Notification Daemon for Software Events PSARC/2009/619 smtp-notify: Email Notification Daemon for Software Events PSARC/2010/225 fmd for non-global Solaris zones PSARC/2010/226 Solaris Instance UUID PSARC/2010/227 nvlist_nvflag(3NVPAIR) PSARC/2010/228 libfmevent additions PSARC/2010/257 sysevent_evc_setpropnvl and sysevent_evc_getpropnvl PSARC/2010/265 FMRI and FMA Event Stabilty, 'ireport' category 1 event class, and the 'sw' FMRI scheme PSARC/2010/278 FMA/SMF integration: instance state transitions PSARC/2010/279 Modelling panics within FMA PSARC/2010/290 logadm.conf upgrade 6392476 fmdump needs to pretty-print 6393375 userland ereport/ireport event generation interfaces 6445732 Add email notification agent for FMA and software events 6804168 RFE: Allow an efficient means to monitor SMF services status changes 6866661 scf_values_destroy(3SCF) will segfault if is passed NULL 6884709 Add snmp notification agent for FMA and software events 6884712 Add private interface to tap into libfmd_msg macro expansion capabilities 6897919 fmd to run in a non-global zone 6897937 fmd use of non-private doors is not safe 6900081 add a UUID to Solaris kernel image for use in crashdump identification 6914884 model panic events as a defect diagnosis in FMA 6944862 fmd_case_open_uuid, fmd_case_uuisresolved, fmd_nvl_create_defect 6944866 log legacy sysevents in fmd 6944867 enumerate svc scheme in topo 6944868 software-diagnosis and software-response fmd modules 6944870 model SMF maintenance state as a defect diagnosis in FMA 6944876 savecore runs in foreground for systems with zfs root and dedicated dump 6965796 Implement notification parameters for SMF state transitions and FMA events 6968287 SUN-FM-MIB.mib needs to be updated to reflect Oracle information 6972331 logadm.conf upgrade PSARC/2010/290
author Gavin Maltby <gavin.maltby@oracle.com>
date Fri, 30 Jul 2010 17:04:17 +1000
parents 161f8007cab9
children
line wrap: on
line diff
--- a/usr/src/uts/sparc/os/archdep.c	Thu Jul 29 22:45:58 2010 -0700
+++ b/usr/src/uts/sparc/os/archdep.c	Fri Jul 30 17:04:17 2010 +1000
@@ -19,16 +19,13 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/vmparam.h>
@@ -255,10 +252,18 @@
 
 /*
  * Print a stack backtrace using the specified stack pointer.  We delay two
- * seconds before continuing, unless this is the panic traceback.  Note
- * that the frame for the starting stack pointer value is omitted because
+ * seconds before continuing, unless this is the panic traceback.
+ * If we are in the process of panicking, we also attempt to write the
+ * stack backtrace to a staticly assigned buffer, to allow the panic
+ * code to find it and write it in to uncompressed pages within the
+ * system crash dump.
+ *
+ * Note that the frame for the starting stack pointer value is omitted because
  * the corresponding %pc is not known.
  */
+
+extern char *dump_stack_scratch;
+
 void
 traceback(caddr_t sp)
 {
@@ -268,11 +273,20 @@
 
 	cpu_t *cpu;
 
+	uint_t  offset = 0;
+	uint_t  next_offset = 0;
+	char    stack_buffer[2048];
+	char    local_buffer[1024];
+
 	flush_windows();
 
 	if (!panicstr)
 		printf("traceback: %%sp = %p\n", (void *)sp);
 
+	if (panicstr && !dump_stack_scratch) {
+		printf("Warning - stack not written to the dumpbuf\n");
+	}
+
 	/*
 	 * If we are panicking, the high-level interrupt information in
 	 * CPU was overwritten.  panic_cpu has the correct values.
@@ -321,20 +335,53 @@
 			    nextfp->fr_arg[0], nextfp->fr_arg[1],
 			    nextfp->fr_arg[2], nextfp->fr_arg[3],
 			    nextfp->fr_arg[4], nextfp->fr_arg[5]);
+			(void) snprintf(stack_buffer, sizeof (stack_buffer),
+			    "%s:%s+%lx "
+			    "(%lx, %lx, %lx, %lx, %lx, %lx) | ",
+			    mod_containing_pc((caddr_t)pc), sym, off,
+			    nextfp->fr_arg[0], nextfp->fr_arg[1],
+			    nextfp->fr_arg[2], nextfp->fr_arg[3],
+			    nextfp->fr_arg[4], nextfp->fr_arg[5]);
 		} else {
-			printf("%016lx %p (%lx, %lx, %lx, %lx, %lx, %lx)\n",
+			(void) printf("%016lx %p (%lx, %lx, %lx, "
+			    "%lx, %lx, %lx)\n",
 			    (ulong_t)nextfp, (void *)pc,
 			    nextfp->fr_arg[0], nextfp->fr_arg[1],
 			    nextfp->fr_arg[2], nextfp->fr_arg[3],
 			    nextfp->fr_arg[4], nextfp->fr_arg[5]);
+			(void) snprintf(stack_buffer, sizeof (stack_buffer),
+			    "%p (%lx, %lx, %lx, %lx, %lx, %lx) | ",
+			    (void *)pc,
+			    nextfp->fr_arg[0], nextfp->fr_arg[1],
+			    nextfp->fr_arg[2], nextfp->fr_arg[3],
+			    nextfp->fr_arg[4], nextfp->fr_arg[5]);
 		}
 
-		printf("  %%l0-3: %016lx %016lx %016lx %016lx\n"
+		(void) snprintf(local_buffer, sizeof (local_buffer),
+		    "  %%l0-3: %016lx %016lx %016lx %016lx\n"
 		    "  %%l4-7: %016lx %016lx %016lx %016lx\n",
 		    nextfp->fr_local[0], nextfp->fr_local[1],
 		    nextfp->fr_local[2], nextfp->fr_local[3],
 		    nextfp->fr_local[4], nextfp->fr_local[5],
 		    nextfp->fr_local[6], nextfp->fr_local[7]);
+		if (panicstr && dump_stack_scratch) {
+			next_offset = offset + strlen(stack_buffer);
+			if (next_offset < STACK_BUF_SIZE) {
+				bcopy(stack_buffer, dump_stack_scratch + offset,
+				    strlen(stack_buffer));
+				offset = next_offset;
+			} else {
+				/*
+				 * In attempting to save the panic stack
+				 * to the dumpbuf we have overflowed that area.
+				 * Print a warning and continue to printf the
+				 * stack to the msgbuf
+				 */
+				printf("Warning: stack in the dump buffer"
+				    " may be incomplete\n");
+			}
+		}
+		printf("%s", local_buffer);
 
 		fp = nextfp;
 		minfp = fp;
@@ -343,6 +390,8 @@
 	if (!panicstr) {
 		printf("end of traceback\n");
 		DELAY(2 * MICROSEC);
+	} else if (dump_stack_scratch) {
+		dump_stack_scratch[offset] = '\0';
 	}
 }