+ bframes[i] = sframe[LRindex]; /* Save the link register */
+
+// syms_formataddr((vm_offset_t)bframes[i], syminfo, sizeof (syminfo));
+// kdb_printf(" %s\n", syminfo);
+ if(!i) kdb_printf(" "); /* Indent first time */
+ else if(!(i & 7)) kdb_printf("\n "); /* Skip to new line every 8 */
+ kdb_printf("0x%08X ", bframes[i]); /* Dump the link register */
+
+ stackptr = sframe[0]; /* Chain back */
+ }
+ kdb_printf("\n");
+ if(i >= DUMPFRAMES) kdb_printf(" backtrace continues...\n"); /* Say we terminated early */
+ if(i) kmod_panic_dump((vm_offset_t *)&bframes[0], i); /* Show what kmods are in trace */
+
+}
+
+void commit_paniclog(void) {
+ unsigned long pi_size = 0;
+
+ if (debug_buf_size > 0) {
+ if (commit_paniclog_to_nvram) {
+ unsigned int bufpos;
+
+ /* XXX Consider using the WKdm compressor in the
+ * future, rather than just packing - would need to
+ * be co-ordinated with crashreporter, which decodes
+ * this post-restart. The compressor should be
+ * capable of in-place compression.
+ */
+ bufpos = packA(debug_buf, (unsigned) (debug_buf_ptr - debug_buf), debug_buf_size);
+ /* If compression was successful,
+ * use the compressed length
+ */
+ pi_size = bufpos ? bufpos : (unsigned) (debug_buf_ptr - debug_buf);
+
+ /* Truncate if the buffer is larger than a
+ * certain magic size - this really ought to
+ * be some appropriate fraction of the NVRAM
+ * image buffer, and is best done in the
+ * savePanicInfo() or PESavePanicInfo() calls
+ * This call must save data synchronously,
+ * since we can subsequently halt the system.
+ */
+ kprintf("Attempting to commit panic log to NVRAM\n");
+ /* N.B.: This routine (currently an IOKit wrapper that
+ * calls through to the appropriate platform NVRAM
+ * driver, must be panic context safe, i.e.
+ * acquire no locks or require kernel services.
+ * This does not appear to be the case currently
+ * on some platforms, unfortunately (the driver
+ * on command gate serialization).
+ */
+ pi_size = PESavePanicInfo((unsigned char *)debug_buf,
+ ((pi_size > 2040) ? 2040 : pi_size));
+ /* Uncompress in-place, to allow debuggers to examine
+ * the panic log.
+ */
+ if (bufpos)
+ unpackA(debug_buf, bufpos);
+ }
+ }