]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ppc/db_trace.c
xnu-792.tar.gz
[apple/xnu.git] / osfmk / ppc / db_trace.c
index d24838fb6958870e0a73c4a3ba1026c324ba5e8c..531f9b6bb2bce08fe46bd664017632f7f3d18565 100644 (file)
 #include <mach/boolean.h>
 #include <vm/vm_map.h>
 #include <kern/thread.h>
+#include <kern/processor.h>
 #include <kern/task.h>
 
+#include <ppc/cpu_internal.h>
+#include <ppc/exception.h>
 #include <machine/asm.h>
 #include <machine/db_machdep.h>
 #include <machine/setjmp.h>
 #include <ddb/db_output.h>
 
 extern jmp_buf_t *db_recover;
-extern struct ppc_saved_state *saved_state[];
 
-struct ppc_saved_state ddb_null_kregs;
+struct savearea ddb_null_kregs;
 
 extern vm_offset_t vm_min_inks_addr;   /* set by db_clone_symtabXXX */
 
 #define DB_NUMARGS_MAX 5
 
 
-extern  char FixedStackStart[], FixedStackEnd[];
-#define        INFIXEDSTACK(va)                                                        \
-       ((((vm_offset_t)(va)) >= (vm_offset_t)&FixedStackStart) &&      \
-       (((vm_offset_t)(va)) < ((vm_offset_t)&FixedStackEnd)))
+#define        INFIXEDSTACK(va)        0                                                       \
 
-#if 0
-
-#define        INKERNELSTACK(va, th)                                   \
-       (th == THR_ACT_NULL ||                          \
-        (((vm_offset_t)(va)) >= th->thread->kernel_stack &&    \
-         (((vm_offset_t)(va)) < th->thread->kernel_stack +     \
-                                KERNEL_STACK_SIZE)) ||         \
-         INFIXEDSTACK(va))
-#else
 #define INKERNELSTACK(va, th) 1
 
-#endif
-
-#ifdef __MACHO__
 struct db_ppc_frame {
        struct db_ppc_frame     *f_frame;
        int                     pad1;
-       db_addr_t               f_retaddr;
+       uint32_t        f_retaddr;
        int                     pad3;
        int                     pad4;
        int                     pad5;
-       db_addr_t               f_arg[DB_NUMARGS_MAX];
+       uint32_t        f_arg[DB_NUMARGS_MAX];
 };
-#endif
 
 #define        TRAP            1
 #define        INTERRUPT       2
@@ -123,47 +109,45 @@ extern int        _setjmp(
  */
 struct db_variable db_regs[] = {
        /* XXX "pc" is an alias to "srr0"... */
-  { "pc",      (int *)&ddb_regs.srr0,  db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "srr0",    (int *)&ddb_regs.srr0,  db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "srr1",    (int *)&ddb_regs.srr1,  db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r0",      (int *)&ddb_regs.r0,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r1",      (int *)&ddb_regs.r1,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r2",      (int *)&ddb_regs.r2,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r3",      (int *)&ddb_regs.r3,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r4",      (int *)&ddb_regs.r4,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r5",      (int *)&ddb_regs.r5,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r6",      (int *)&ddb_regs.r6,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r7",      (int *)&ddb_regs.r7,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r8",      (int *)&ddb_regs.r8,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r9",      (int *)&ddb_regs.r9,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r10",     (int *)&ddb_regs.r10,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r11",     (int *)&ddb_regs.r11,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r12",     (int *)&ddb_regs.r12,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r13",     (int *)&ddb_regs.r13,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r14",     (int *)&ddb_regs.r14,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r15",     (int *)&ddb_regs.r15,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r16",     (int *)&ddb_regs.r16,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r17",     (int *)&ddb_regs.r17,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r18",     (int *)&ddb_regs.r18,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r19",     (int *)&ddb_regs.r19,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r20",     (int *)&ddb_regs.r20,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r21",     (int *)&ddb_regs.r21,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r22",     (int *)&ddb_regs.r22,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r23",     (int *)&ddb_regs.r23,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r24",     (int *)&ddb_regs.r24,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r25",     (int *)&ddb_regs.r25,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r26",     (int *)&ddb_regs.r26,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r27",     (int *)&ddb_regs.r27,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r28",     (int *)&ddb_regs.r28,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r29",     (int *)&ddb_regs.r29,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r30",     (int *)&ddb_regs.r30,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r31",     (int *)&ddb_regs.r31,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "cr",      (int *)&ddb_regs.cr,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "xer",     (int *)&ddb_regs.xer,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "lr",      (int *)&ddb_regs.lr,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "ctr",     (int *)&ddb_regs.ctr,   db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "mq",      (int *)&ddb_regs.mq,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "sr_copyin",(int *)&ddb_regs.sr_copyin,db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "pc",      &ddb_regs.save_srr0,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "srr0",    &ddb_regs.save_srr0,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "srr1",    &ddb_regs.save_srr1,    db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r0",      &ddb_regs.save_r0,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r1",      &ddb_regs.save_r1,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r2",      &ddb_regs.save_r2,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r3",      &ddb_regs.save_r3,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r4",      &ddb_regs.save_r4,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r5",      &ddb_regs.save_r5,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r6",      &ddb_regs.save_r6,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r7",      &ddb_regs.save_r7,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r8",      &ddb_regs.save_r8,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r9",      &ddb_regs.save_r9,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r10",     &ddb_regs.save_r10,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r11",     &ddb_regs.save_r11,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r12",     &ddb_regs.save_r12,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r13",     &ddb_regs.save_r13,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r14",     &ddb_regs.save_r14,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r15",     &ddb_regs.save_r15,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r16",     &ddb_regs.save_r16,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r17",     &ddb_regs.save_r17,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r18",     &ddb_regs.save_r18,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r19",     &ddb_regs.save_r19,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r20",     &ddb_regs.save_r20,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r21",     &ddb_regs.save_r21,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r22",     &ddb_regs.save_r22,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r23",     &ddb_regs.save_r23,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r24",     &ddb_regs.save_r24,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r25",     &ddb_regs.save_r25,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r26",     &ddb_regs.save_r26,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r27",     &ddb_regs.save_r27,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r28",     &ddb_regs.save_r28,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r29",     &ddb_regs.save_r29,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r30",     &ddb_regs.save_r30,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r31",     &ddb_regs.save_r31,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "cr",      &ddb_regs.save_cr,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "xer",     &ddb_regs.save_xer,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "lr",      &ddb_regs.save_lr,      db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "ctr",     &ddb_regs.save_ctr,     db_ppc_reg_value, 0, 0, 0, 0, TRUE },
 };
 struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
 
@@ -174,86 +158,91 @@ db_ppc_reg_value(
        int                     flag,
        db_var_aux_param_t      ap)
 {
-       int                     *dp = 0;
-       db_expr_t               null_reg = 0;
+       db_expr_t *dp = 0;
+       db_expr_t null_reg = 0;
+       uint32_t *dp32;
+       
        register thread_act_t   thr_act = ap->thr_act;
        int                     cpu;
 
        if (db_option(ap->modif, 'u')) {
            if (thr_act == THR_ACT_NULL) {
-               if ((thr_act = current_act()) == THR_ACT_NULL)
+               if ((thr_act = current_thread()) == THR_ACT_NULL)
                    db_error("no user registers\n");
            }
-           if (thr_act == current_act()) {
-               if (IS_USER_TRAP((&ddb_regs)))
-                   dp = vp->valuep;
-               else if (INFIXEDSTACK(ddb_regs.r1))
-                   db_error("cannot get/set user registers in nested interrupt\n");
+           if (thr_act == current_thread()) {
+                       if (IS_USER_TRAP((&ddb_regs))) dp = vp->valuep;
+                       else if (INFIXEDSTACK(ddb_regs.save_r1))
+                               db_error("cannot get/set user registers in nested interrupt\n");
            }
-       } else {
-           if (thr_act == THR_ACT_NULL || thr_act == current_act()) {
-               dp = vp->valuep;
-           } else {
-             if (thr_act->thread &&
-                 !(thr_act->thread->state & TH_STACK_HANDOFF) && 
-                       thr_act->thread->kernel_stack) {
-               int cpu;
-
-               for (cpu = 0; cpu < NCPUS; cpu++) {
-                   if (machine_slot[cpu].running == TRUE &&
-                       cpu_data[cpu].active_thread == thr_act->thread && saved_state[cpu]) {
-                       dp = (int *) (((int)saved_state[cpu]) +
-                                     (((int) vp->valuep) -
-                                      (int) &ddb_regs));
-                       break;
-                   }
-               }
-#if 0
-               if (dp == 0 && thr_act && thr_act->thread)
-                   dp = db_lookup_i386_kreg(vp->name,
-                        (int *)(STACK_IKS(thr_act->thread->kernel_stack)));
-#endif
-               if (dp == 0)
-                   dp = &null_reg;
-             } else if (thr_act->thread &&
-                        (thr_act->thread->state&TH_STACK_HANDOFF)){
-               /* only PC is valid */
-               if (vp->valuep == (int *) &ddb_regs.srr0) {
-                   dp = (int *)(&thr_act->thread->continuation);
-               } else {
-                   dp = &null_reg;
-               }
-             }
+       } 
+       else {
+               if (thr_act == THR_ACT_NULL || thr_act == current_thread()) {
+                       dp = vp->valuep;
+               } 
+               else {
+                       if (thr_act->kernel_stack) {
+                               
+                               int cpu;
+
+                               for (cpu = 0; cpu < real_ncpus; cpu++) {
+                                       if (cpu_to_processor(cpu)->state == PROCESSOR_RUNNING &&
+                                               cpu_to_processor(cpu)->active_thread == thr_act &&
+                                           PerProcTable[cpu].ppe_vaddr->db_saved_state) {
+                                               
+                                               dp = (db_expr_t)(((uint32_t)(PerProcTable[cpu].ppe_vaddr->db_saved_state)) +
+                                                                 (((uint32_t) vp->valuep) -
+                                                                  (uint32_t) &ddb_regs));
+                                               break;
+                                       }
+                               }
+
+                               if (dp == 0) dp = &null_reg;
+                       } 
+                       else {
+                               /* only PC is valid */
+                               if (vp->valuep == (int *) &ddb_regs.save_srr0) {
+                                       dp = (int *)(&thr_act->continuation);
+                               } 
+                               else {
+                                       dp = &null_reg;
+                               }
+                       }
            }
        }
        if (dp == 0) {
-           int cpu;
 
            if (!db_option(ap->modif, 'u')) {
-               for (cpu = 0; cpu < NCPUS; cpu++) {
-                   if (machine_slot[cpu].running == TRUE &&
-                       cpu_data[cpu].active_thread == thr_act->thread && saved_state[cpu]) {
-                           dp = (int *) (((int)saved_state[cpu]) +
-                                         (((int) vp->valuep) -
-                                          (int) &ddb_regs));
-                           break;
-                   }
-               }
+                       for (cpu = 0; cpu < real_ncpus; cpu++) {
+                           if (cpu_to_processor(cpu)->state == PROCESSOR_RUNNING &&
+                               cpu_to_processor(cpu)->active_thread == thr_act &&
+                                   PerProcTable[cpu].ppe_vaddr->db_saved_state) {
+                                   dp = (int *) (((int)(PerProcTable[cpu].ppe_vaddr->db_saved_state)) +
+                                                 (((int) vp->valuep) - (int) &ddb_regs));
+                                       break;
+                               }
+                       }
            }
            if (dp == 0) {
-               if (!thr_act || thr_act->mact.pcb == 0)
-                   db_error("no pcb\n");
-               dp = (int *)((int)(&thr_act->mact.pcb->ss) + 
-                            ((int)vp->valuep - (int)&ddb_regs));
+                       if (!thr_act || thr_act->machine.pcb == 0) db_error("no pcb\n");
+                       dp = (int *)((int)thr_act->machine.pcb + ((int)vp->valuep - (int)&ddb_regs));
            }
        }
-       if (flag == DB_VAR_SET)
-           *dp = *valuep;
-       else
-           *valuep = *dp;
+
+       if(vp->valuep == (int *) &ddb_regs.save_cr) {   /* Is this the CR we are doing? */
+               dp32 = (uint32_t *)dp;                                          /* Make this easier */
+               if (flag == DB_VAR_SET) *dp32 = *valuep;
+               else *valuep = *dp32;
+       }
+       else {                                                                                  /* Normal 64-bit registers */
+               if (flag == DB_VAR_SET) *dp = *valuep;
+               else *valuep = *(unsigned long long *)dp;
+       }
+       
        return(0);
 }
 
+
 void
 db_find_trace_symbols(void)
 {
@@ -310,7 +299,7 @@ db_find_arg(
        int             inst;
        char            *name;
 
-#if    XXX_BS
+#if    0
        db_find_task_sym_and_offset(calleepc, &name, &offset, task);
        calleep = calleepc-offset;
 
@@ -352,64 +341,40 @@ db_nextframe(
        extern char *   trap_type[];
        extern int      TRAP_TYPES;
 
-       struct ppc_saved_state *saved_regs;
+       struct savearea *saved_regs;
 
        task_t task = (thr_act != THR_ACT_NULL)? thr_act->task: TASK_NULL;
 
        switch(frame_type) {
        case TRAP:
-#if 0
-           /*
-            * We know that trap() has 1 argument and we know that
-            * it is an (strcut i386_saved_state *).
-            */
-           saved_regs = (struct i386_saved_state *)
-                       db_get_task_value((int)&((*fp)->f_arg0),4,FALSE,task);
-           if (saved_regs->trapno >= 0 && saved_regs->trapno < TRAP_TYPES) {
-               db_printf(">>>>> %s trap at ",
-                       trap_type[saved_regs->trapno]);
-           } else {
-               db_printf(">>>>> trap (number %d) at ",
-                       saved_regs->trapno & 0xffff);
-           }
-           db_task_printsym(saved_regs->eip, DB_STGY_PROC, task);
-           db_printf(" <<<<<\n");
-           *fp = (struct i386_frame *)saved_regs->ebp;
-           *ip = (db_addr_t)saved_regs->eip;
-#else
+
            db_printf(">>>>> trap <<<<<\n");
            goto miss_frame;
-#endif
            break;
        case INTERRUPT:
            if (*lfp == 0) {
                db_printf(">>>>> interrupt <<<<<\n");
                goto miss_frame;
            }
-#if 0
-           db_printf(">>>>> interrupt at "); 
-           ifp = (struct interrupt_frame *)(*lfp);
-           *fp = ifp->if_frame;
-           if (ifp->if_iretaddr == db_return_to_iret_symbol_value)
-               *ip = ((struct i386_interrupt_state *) ifp->if_edx)->eip;
-           else
-               *ip = (db_addr_t) ifp->if_eip;
-           db_task_printsym(*ip, DB_STGY_PROC, task);
-           db_printf(" <<<<<\n");
-#else
            db_printf(">>>>> interrupt <<<<<\n");
            goto miss_frame;
-#endif
            break;
        case SYSCALL:
-           if (thr_act != THR_ACT_NULL && thr_act->mact.pcb) {
-               *ip = (db_addr_t) thr_act->mact.pcb->ss.srr0;
-               *fp = (struct db_ppc_frame *) (thr_act->mact.pcb->ss.r1);
+           if (thr_act != THR_ACT_NULL && thr_act->machine.pcb) {
+               *ip = (db_addr_t) thr_act->machine.pcb->save_srr0;
+               *fp = (struct db_ppc_frame *) (thr_act->machine.pcb->save_r1);
                break;
            }
            /* falling down for unknown case */
        default:
        miss_frame:
+               
+               if(!pmap_find_phys(kernel_pmap, (addr64_t)*fp)) {       /* Check if this is valid */
+                       db_printf("Frame not mapped %08X\n",*fp);               /* Say not found */
+                       *fp = 0;                                                                                /* Show not found */
+                       break;                                                                                  /* Out of here */
+               }
+               
                if ((*fp)->f_frame)
                    *ip = (db_addr_t)
                            db_get_task_value((int)&(*fp)->f_frame->f_retaddr,
@@ -472,7 +437,7 @@ db_stack_trace_cmd(
            if (!have_addr && !trace_thread) {
                        have_addr = TRUE;
                        trace_thread = TRUE;
-                       act_list = &(current_task()->thr_acts);
+                       act_list = &(current_task()->threads);
                        addr = (db_expr_t) queue_first(act_list);
            } 
                else if (trace_thread) {
@@ -480,11 +445,11 @@ db_stack_trace_cmd(
                                if (!db_check_act_address_valid((thread_act_t)addr)) {
                                        if (db_lookup_task((task_t)addr) == -1)
                                                return;
-                                       act_list = &(((task_t)addr)->thr_acts);
+                                       act_list = &(((task_t)addr)->threads);
                                        addr = (db_expr_t) queue_first(act_list);
                                } 
                                else {
-                                       act_list = &(((thread_act_t)addr)->task->thr_acts);
+                                       act_list = &(((thread_act_t)addr)->task->threads);
                                        thcount = db_lookup_task_act(((thread_act_t)addr)->task,
                                                                        (thread_act_t)addr);
                                }
@@ -492,13 +457,13 @@ db_stack_trace_cmd(
                        else {
                                th = db_default_act;
                                if (th == THR_ACT_NULL)
-                                       th = current_act();
+                                       th = current_thread();
                                if (th == THR_ACT_NULL) {
                                        db_printf("no active thr_act\n");
                                        return;
                                }
                                have_addr = TRUE;
-                               act_list = &th->task->thr_acts;
+                               act_list = &th->task->threads;
                                addr = (db_expr_t) queue_first(act_list);
                        }
            }
@@ -514,10 +479,10 @@ next_thread:
        frame_count = count;
 
        if (!have_addr && !trace_thread) {
-           frame = (struct db_ppc_frame *)(ddb_regs.r1);
-           callpc = (db_addr_t)ddb_regs.srr0;
-           linkpc = (db_addr_t)ddb_regs.lr;
-           th = current_act();
+           frame = (struct db_ppc_frame *)(ddb_regs.save_r1);
+           callpc = (db_addr_t)ddb_regs.save_srr0;
+           linkpc = (db_addr_t)ddb_regs.save_lr;
+           th = current_thread();
            task = (th != THR_ACT_NULL)? th->task: TASK_NULL;
        } 
        else if (trace_thread) {
@@ -529,7 +494,7 @@ next_thread:
                else {
                        th = db_default_act;
                        if (th == THR_ACT_NULL)
-                          th = current_act();
+                          th = current_thread();
                        if (th == THR_ACT_NULL) {
                           db_printf("no active thread\n");
                           return;
@@ -537,56 +502,42 @@ next_thread:
            }
            if (trace_all_threads)
                db_printf("---------- Thread 0x%x (#%d of %d) ----------\n",
-                         addr, thcount, th->task->thr_act_count);
+                         addr, thcount, th->task->thread_count);
 
 next_activation:
 
            user_frame = 0;
 
            task = th->task;
-           if (th == current_act()) {
-               frame = (struct db_ppc_frame *)(ddb_regs.r1);
-               callpc = (db_addr_t)ddb_regs.srr0;
-                       linkpc = (db_addr_t)ddb_regs.lr;
+           if (th == current_thread()) {
+               frame = (struct db_ppc_frame *)(ddb_regs.save_r1);
+               callpc = (db_addr_t)ddb_regs.save_srr0;
+                       linkpc = (db_addr_t)ddb_regs.save_lr;
            } 
                else {
-                       if (th->mact.pcb == 0) {
+                       if (th->machine.pcb == 0) {
                        db_printf("thread has no pcb\n");
                                goto thread_done;
                        }
-                       if (!th->thread) {
-                               register struct ppc_saved_state *pss =
-                                                       &th->mact.pcb->ss;
-       
-                               db_printf("thread has no shuttle\n");
-       #if 0
-                               frame = (struct db_ppc_frame *) (pss->r1);
-                               callpc = (db_addr_t) (pss->srr0);
-                               linkpc = (db_addr_t) (pss->lr);
-       #else
-                               goto thread_done;
-       #endif
-                       }
-                       else if ((th->thread->state & TH_STACK_HANDOFF) ||
-                                 th->thread->kernel_stack == 0) {
-                               register struct ppc_saved_state *pss =
-                                                       &th->mact.pcb->ss;
+                       if (th->kernel_stack == 0) {
+                               register struct savearea *pss =
+                                                       th->machine.pcb;
        
                                db_printf("Continuation ");
-                               db_task_printsym((db_expr_t)th->thread->continuation,
+                               db_task_printsym((db_expr_t)th->continuation,
                                                                DB_STGY_PROC, task);
                                db_printf("\n");
-                               frame = (struct db_ppc_frame *) (pss->r1);
-                               callpc = (db_addr_t) (pss->srr0);
-                               linkpc = (db_addr_t) (pss->lr);
+                               frame = (struct db_ppc_frame *) (pss->save_r1);
+                               callpc = (db_addr_t) (pss->save_srr0);
+                               linkpc = (db_addr_t) (pss->save_lr);
                        } 
                        else {
                                int cpu;
        
-                               for (cpu = 0; cpu < NCPUS; cpu++) {
-                                       if (machine_slot[cpu].running == TRUE &&
-                                               cpu_data[cpu].active_thread == th->thread &&
-                                               saved_state[cpu]) {
+                               for (cpu = 0; cpu < real_ncpus; cpu++) {
+                                       if (cpu_to_processor(cpu)->state == PROCESSOR_RUNNING &&
+                                               cpu_to_processor(cpu)->active_thread == th &&
+                                               PerProcTable[cpu].ppe_vaddr->db_saved_state) {
                                                break;
                                        }
                                }
@@ -596,22 +547,22 @@ next_activation:
                                         * which is not the top_most one in the RPC chain:
                                         * use the activation's pcb.
                                         */
-                                       struct ppc_saved_state *pss;
+                                       struct savearea *pss;
        
-                                       pss = (struct ppc_saved_state *)th->mact.pcb;
-                                       frame = (struct db_ppc_frame *) (pss->r1);
-                                       callpc = (db_addr_t) (pss->srr0);
-                                       linkpc = (db_addr_t) (pss->lr);
+                                       pss = th->machine.pcb;
+                                       frame = (struct db_ppc_frame *) (pss->save_r1);
+                                       callpc = (db_addr_t) (pss->save_srr0);
+                                       linkpc = (db_addr_t) (pss->save_lr);
                                        } else {
-                                               if (cpu == NCPUS) {
-                                                       register struct ppc_saved_state *iks;
+                                               if (cpu == real_ncpus) {
+                                                       register struct savearea *iks;
                                                        int r;
                        
-                                                       iks = (struct ppc_saved_state *)th->mact.pcb;
+                                                       iks = th->machine.pcb;
                                                        prev = db_recover;
                                                        if ((r = _setjmp(db_recover = &db_jmp_buf)) == 0) {
-                                                               frame = (struct db_ppc_frame *) (iks->r1);
-                                                               callpc = (db_addr_t) (iks->lr);
+                                                               frame = (struct db_ppc_frame *) (iks->save_r1);
+                                                               callpc = (db_addr_t) (iks->save_lr);
                                                                linkpc = 0;
                                                        } else {
                                                                /*
@@ -631,16 +582,16 @@ next_activation:
                                                        db_printf(">>>>> active on cpu %d <<<<<\n",
                                                                  cpu);
                                                        frame = (struct db_ppc_frame *)
-                                                       (saved_state[cpu]->r1);
-                                                       callpc = (db_addr_t) saved_state[cpu]->srr0;
-                                                       linkpc = (db_addr_t) saved_state[cpu]->lr;
+                                                       (PerProcTable[cpu].ppe_vaddr->db_saved_state->save_r1);
+                                                       callpc = (db_addr_t) PerProcTable[cpu].ppe_vaddr->db_saved_state->save_srr0;
+                                                       linkpc = (db_addr_t) PerProcTable[cpu].ppe_vaddr->db_saved_state->save_lr;
                                                }
                                        }
                                }
            }
        } else {
            frame = (struct db_ppc_frame *)addr;
-           th = (db_default_act)? db_default_act: current_act();
+           th = (db_default_act)? db_default_act: current_thread();
            task = (th != THR_ACT_NULL)? th->task: TASK_NULL;
            if (frame->f_frame) {
              callpc = (db_addr_t)db_get_task_value
@@ -709,7 +660,7 @@ next_activation:
                                        goto next_act;
                                }
                        }
-               } else {
+           } else {
                        frame_type = 0;
                        prev = db_recover;
                        if ((r = _setjmp(db_recover = &db_jmp_buf)) == 0) {
@@ -724,11 +675,11 @@ next_activation:
                }
 
            if (name == 0 || offset > db_maxoff) {
-               db_printf("[%08X]0x%08X(", frame, callpc);
+                       db_printf("[%08X]0x%08X(", frame, callpc);
            } else {
                db_printf("[%08X]%s", frame, name);
-               if (offset)
-                        db_printf("+%x", offset);
+                       if (offset)
+                               db_printf("+%llx", offset);
                db_printf("(");
           };
 
@@ -786,16 +737,6 @@ next_activation:
 
            if (frame == 0) {
        next_act:
-               if (th->lower != THR_ACT_NULL) {
-                   if (top_act == THR_ACT_NULL)
-                       top_act = th;
-                   th = th->lower;
-                   db_printf(">>>>> next activation 0x%x ($task%d.%d) <<<<<\n",
-                             th,
-                             db_lookup_task(th->task),
-                             db_lookup_task_act(th->task, th));
-                   goto next_activation;
-               }
                /* end of chain */
                break;
            }
@@ -819,7 +760,7 @@ next_activation:
        if (trace_all_threads) {
            if (top_act != THR_ACT_NULL)
                th = top_act;
-           th = (thread_act_t) queue_next(&th->thr_acts);
+           th = (thread_act_t) queue_next(&th->task_threads);
            if (! queue_end(act_list, (queue_entry_t) th)) {
                db_printf("\n");
                addr = (db_expr_t) th;