]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/AT386/model_dep.c
xnu-3789.70.16.tar.gz
[apple/xnu.git] / osfmk / i386 / AT386 / model_dep.c
index d4a138af8f7c70724c3fde598fd237a6a411fac3..ebb29b76b8f7c921d881579a8847b2dd3c50b0ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
 #include <pexpert/i386/boot.h>
 
 #include <kdp/kdp_dyld.h>
 #include <pexpert/i386/boot.h>
 
 #include <kdp/kdp_dyld.h>
+#include <kdp/kdp_core.h>
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 #include <vm/vm_kern.h>
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 #include <vm/vm_kern.h>
 #include <libkern/OSKextLibPrivate.h>
 
 #include <mach/branch_predicates.h>
 #include <libkern/OSKextLibPrivate.h>
 
 #include <mach/branch_predicates.h>
+#include <libkern/section_keywords.h>
 
 #if    DEBUG
 #define DPRINTF(x...)  kprintf(x)
 
 #if    DEBUG
 #define DPRINTF(x...)  kprintf(x)
 static void machine_conf(void);
 void panic_print_symbol_name(vm_address_t search);
 
 static void machine_conf(void);
 void panic_print_symbol_name(vm_address_t search);
 
-extern boolean_t init_task_died;
 extern const char      version[];
 extern char    osversion[];
 extern int             max_unsafe_quanta;
 extern const char      version[];
 extern char    osversion[];
 extern int             max_unsafe_quanta;
@@ -169,7 +170,7 @@ typedef struct _cframe_t {
 static unsigned panic_io_port;
 static unsigned        commit_paniclog_to_nvram;
 
 static unsigned panic_io_port;
 static unsigned        commit_paniclog_to_nvram;
 
-unsigned int debug_boot_arg;
+SECURITY_READ_ONLY_LATE(unsigned int) debug_boot_arg;
 
 /*
  * Backtrace a single frame.
 
 /*
  * Backtrace a single frame.
@@ -807,6 +808,7 @@ int reset_mem_on_reboot = 1;
 /*
  * Halt the system or reboot.
  */
 /*
  * Halt the system or reboot.
  */
+__attribute__((noreturn))
 void
 halt_all_cpus(boolean_t reboot)
 {
 void
 halt_all_cpus(boolean_t reboot)
 {
@@ -868,22 +870,17 @@ machine_halt_cpu(void) {
        pmCPUHalt(PM_HALT_DEBUG);
 }
 
        pmCPUHalt(PM_HALT_DEBUG);
 }
 
-static int pid_from_task(task_t task)
-{
-        int pid = -1;
-
-        if (task->bsd_info)
-                pid = proc_pid(task->bsd_info);
-
-        return pid;
-}
-
 void
 DebuggerWithContext(
        __unused unsigned int   reason,
        __unused void           *ctx,
 void
 DebuggerWithContext(
        __unused unsigned int   reason,
        __unused void           *ctx,
-       const char              *message)
+       const char              *message,
+       uint64_t                debugger_options_mask)
 {
 {
+       if (debugger_options_mask != DEBUGGER_OPTION_NONE) {
+               kprintf("debugger options (%llx) not supported for desktop.\n", debugger_options_mask);
+       }
+
        Debugger(message);
 }
 
        Debugger(message);
 }
 
@@ -894,8 +891,7 @@ Debugger(
        unsigned long pi_size = 0;
        void *stackptr;
        int cn = cpu_number();
        unsigned long pi_size = 0;
        void *stackptr;
        int cn = cpu_number();
-       task_t task = current_task();
-       int     task_pid = pid_from_task(task);
+
        boolean_t old_doprnt_hide_pointers = doprnt_hide_pointers;
 
        hw_atomic_add(&debug_mode, 1);   
        boolean_t old_doprnt_hide_pointers = doprnt_hide_pointers;
 
        hw_atomic_add(&debug_mode, 1);   
@@ -928,7 +924,7 @@ Debugger(
                __asm__ volatile("movq %%rbp, %0" : "=m" (stackptr));
 
                /* Print backtrace - callee is internally synchronized */
                __asm__ volatile("movq %%rbp, %0" : "=m" (stackptr));
 
                /* Print backtrace - callee is internally synchronized */
-               if (task_pid == 1 && (init_task_died)) {
+               if (strncmp(panicstr, LAUNCHD_CRASHED_PREFIX, strlen(LAUNCHD_CRASHED_PREFIX)) == 0) {
                        /* Special handling of launchd died panics */
                        print_launchd_info();
                } else {
                        /* Special handling of launchd died panics */
                        print_launchd_info();
                } else {
@@ -993,7 +989,7 @@ Debugger(
                     }
                 }
 
                     }
                 }
 
-               if (!panicDebugging) {
+               if (!panicDebugging && !kdp_has_polled_corefile()) {
                        unsigned cnum;
                        /* Clear the MP rendezvous function lock, in the event
                         * that a panic occurred while in that codepath.
                        unsigned cnum;
                        /* Clear the MP rendezvous function lock, in the event
                         * that a panic occurred while in that codepath.
@@ -1264,7 +1260,7 @@ out:
        if (PC != 0)
                kmod_panic_dump(&PC, 1);
 
        if (PC != 0)
                kmod_panic_dump(&PC, 1);
 
-       panic_display_system_configuration();
+       panic_display_system_configuration(FALSE);
 
        doprnt_hide_pointers = old_doprnt_hide_pointers;
 
 
        doprnt_hide_pointers = old_doprnt_hide_pointers;
 
@@ -1344,9 +1340,10 @@ print_tasks_user_threads(task_t task)
                pmap = get_task_pmap(task);
                savestate = get_user_regs(thread);
                rbp = savestate->ss_64.rbp;
                pmap = get_task_pmap(task);
                savestate = get_user_regs(thread);
                rbp = savestate->ss_64.rbp;
+               kdb_printf("\t0x%016llx\n", savestate->ss_64.isf.rip);
                print_one_backtrace(pmap, (vm_offset_t)rbp, cur_marker, TRUE, TRUE);
                kdb_printf("\n");
                print_one_backtrace(pmap, (vm_offset_t)rbp, cur_marker, TRUE, TRUE);
                kdb_printf("\n");
-               }
+       }
 }
 
 void
 }
 
 void
@@ -1461,10 +1458,8 @@ void print_launchd_info(void)
        print_thread_num_that_crashed(task);
        print_threads_registers(thread);
        print_tasks_user_threads(task);
        print_thread_num_that_crashed(task);
        print_threads_registers(thread);
        print_tasks_user_threads(task);
-       kdb_printf("Mac OS version: %s\n", (osversion[0] != 0) ? osversion : "Not yet set");
-       kdb_printf("Kernel version: %s\n", version);
-       panic_display_kernel_uuid();
-       panic_display_model_name();
+
+       panic_display_system_configuration(TRUE);
        
        /* Release print backtrace lock, to permit other callers in the
         * event of panics on multiple processors.
        
        /* Release print backtrace lock, to permit other callers in the
         * event of panics on multiple processors.