10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
12 // |
12 // |
13 // Description: |
13 // Description: |
14 // e32\nkernsmp\x86\ncmonitor.cpp |
14 // e32\nkernsmp\x86\ncmonitor.cpp |
15 // Kernel crash debugger - NKERN X86 specific portion |
15 // Kernel crash debugger - NKERNSMP X86 specific portion |
16 // |
16 // |
17 // |
17 // |
18 |
18 |
19 #define __INCLUDE_NTHREADBASE_DEFINES__ |
19 #define __INCLUDE_NTHREADBASE_DEFINES__ |
20 |
20 |
21 #include "nk_priv.h" |
21 #include "nk_priv.h" |
22 #include <x86.h> |
22 #include <x86.h> |
23 #include <kernel/monitor.h> |
23 #include <kernel/monitor.h> |
24 |
24 |
25 |
25 |
26 void Monitor::DisplaySpinLock(const char* aTitle, TSpinLock* aLock) |
26 void DisplayNThreadStackedRegs(Monitor& m, SThreadReschedStack& reg) |
27 { |
27 { |
28 volatile TUint32* p = (volatile TUint32*)aLock; |
28 m.Printf("CR0 %08x RsF %08x EIP %08x RSN %08x\r\n", reg.iCR0, reg.iReschedFlag, reg.iEip, reg.iReason); |
29 Printf("%s %08x %08x\r\n", aTitle, p[0], p[1]); |
|
30 } |
29 } |
31 |
30 |
32 EXPORT_C void Monitor::DisplayNThreadInfo(NThread* aT) |
31 void DisplaySubSchedulerExt(Monitor& m, TSubScheduler& ss) |
33 { |
32 { |
34 DisplayNSchedulableInfo(aT); |
33 TSubSchedulerX& x = ss.iSSX; |
|
34 m.Printf("Extras[ 0] %08x Extras[ 1] %08x Extras[ 2] %08x Extras[ 3] %08x\r\n", x.iSSXP[0], x.iSSXP[1], x.iSSXP[2], x.iSSXP[3]); |
|
35 m.Printf("Extras[ 4] %08x Extras[ 5] %08x Extras[ 6] %08x Extras[ 7] %08x\r\n", x.iSSXP[4], x.iSSXP[5], x.iSSXP[6], x.iSSXP[7]); |
|
36 m.Printf("Extras[ 8] %08x i_IrqCount %08x i_ExcInfo %08x i_CrashSt %08x\r\n", x.iSSXP[8], x.iIrqCount, x.iExcInfo, x.iCrashState); |
|
37 m.Printf("i_APICID %08x i_IrqNestC %08x i_IrqStkTp %08x i_Tss %08x\r\n", x.iAPICID, x.iIrqNestCount, x.iIrqStackTop, x.iTss); |
|
38 m.Printf("CpuFreqM %08x CpuFreqS %08x CpuPeriodM %08x CpuPeriodS %08x\r\n", x.iCpuFreqRI.iR.iM, x.iCpuFreqRI.iR.iX, x.iCpuFreqRI.iI.iM, x.iCpuFreqRI.iI.iX); |
|
39 m.Printf("TmrFreqM %08x TmrFreqS %08x TmrPeriodM %08x TmrPeriodS %08x\r\n", x.iTimerFreqRI.iR.iM, x.iTimerFreqRI.iR.iX, x.iTimerFreqRI.iI.iM, x.iTimerFreqRI.iI.iX); |
|
40 m.Printf("TmstampOff %08x %08x iSSXP2[0] %08x iSSXP2[1] %08x\r\n", I64HIGH(x.iTimestampOffset.i64), I64LOW(x.iTimestampOffset.i64), x.iSSXP2[0], x.iSSXP2[1]); |
35 } |
41 } |
36 |
42 |
37 void Monitor::DisplayNSchedulableInfo(NSchedulable* aS) |
43 void DisplaySchedulerExt(Monitor& m, TScheduler& s) |
38 { |
44 { |
39 NThread* t = aS->iParent ? (NThread*)aS : 0; |
45 volatile TUint32* sx = (volatile TUint32*)&s.iSX; |
40 NThreadGroup* g = aS->iParent ? 0 : (NThreadGroup*)aS; |
46 m.Printf("Extras 0: %08x 1: %08x 2: %08x 3: %08x\r\n",sx[0],sx[1],sx[2],sx[3]); |
41 |
47 m.Printf("Extras 4: %08x 5: %08x 6: %08x 7: %08x\r\n",sx[4],sx[5],sx[6],sx[7]); |
42 if (t && aS->iParent==aS) |
48 m.Printf("Extras 8: %08x 9: %08x A: %08x B: %08x\r\n",sx[8],sx[9],sx[10],sx[11]); |
43 Printf("NThread @%08x Pri %d\r\n",aS,aS->iPriority); |
49 m.Printf("Extras C: %08x D: %08x E: %08x F: %08x\r\n",sx[12],sx[13],sx[14],sx[15]); |
44 else if (t) |
|
45 Printf("NThread @%08x (G:%08x) Pri %d\r\n",aS,aS->iParent,aS->iPriority); |
|
46 else |
|
47 Printf("NThreadGroup @%08x Pri %d\r\n",aS,aS->iPriority); |
|
48 Printf("Rdy=%02x Curr=%02x LastCpu=%d CpuChg=%02x FrzCpu=%d\r\n", aS->iReady, aS->iCurrent, aS->iLastCpu, aS->iCpuChange, aS->iFreezeCpu); |
|
49 Printf("Next=%08x Prev=%08x Parent=%08x CPUaff=%08x\r\n", aS->iNext, aS->iPrev, aS->iParent, aS->iCpuAffinity); |
|
50 Printf("PauseCount %02x Susp %1x\r\n", aS->iPauseCount, aS->iSuspended); |
|
51 DisplaySpinLock("SpinLock", &aS->iSSpinLock); |
|
52 Printf("Stopping %02x Events %08x %08x EventState %08x\r\n", aS->iStopping, aS->iEvents.iA.iNext, aS->iEvents.iA.iPrev, aS->iEventState); |
|
53 Printf("TotalCpuTime %08x %08x RunCount %08x %08x\r\n", aS->iTotalCpuTime32[1], aS->iTotalCpuTime32[0], aS->iRunCount32[1], aS->iRunCount32[0]); |
|
54 |
|
55 if (g) |
|
56 { |
|
57 // Thread group |
|
58 return; |
|
59 } |
|
60 |
|
61 Printf("WaitState %02x %02x [%02x %02x] (%08x)\r\n", t->iWaitState.iWtC.iWtStFlags, t->iWaitState.iWtC.iWtObjType, |
|
62 t->iWaitState.iWtC.iWtStSpare1, t->iWaitState.iWtC.iWtStSpare2, t->iWaitState.iWtC.iWtObj); |
|
63 Printf("BasePri %d MutexPri %d Att=%02x\r\n", t->iBasePri, t->iMutexPri, t->i_ThrdAttr); |
|
64 Printf("HeldFM=%08x FMDef=%02x AddrSp=%08x\r\n", t->iHeldFastMutex, t->iFastMutexDefer, t->iAddressSpace); |
|
65 Printf("Time=%d Timeslice=%d ReqCount=%08x\r\n", t->iTime, t->iTimeslice, t->iRequestSemaphore.iCount); |
|
66 Printf("SuspendCount=%d CsCount=%d CsFunction=%08x\r\n", t->iSuspendCount, t->iCsCount, t->iCsFunction); |
|
67 Printf("LinkedObjType %02x LinkedObj %08x\r\n", t->iLinkedObjType, t->iLinkedObj); |
|
68 Printf("SavedSP=%08x WaitLink:%08x %08x %d\r\n", t->iSavedSP, t->iWaitLink.iNext, t->iWaitLink.iPrev, t->iWaitLink.iPriority); |
|
69 Printf("iNewParent=%08x iExtraContext=%08x, iExtraContextSize=%08x\r\n", t->iNewParent, t->iExtraContext, t->iExtraContextSize); |
|
70 Printf("iUserModeCallbacks=%08x iNThreadBaseSpare6=%08x\r\n", t->iUserModeCallbacks, t->iNThreadBaseSpare6); |
|
71 Printf("iNThreadBaseSpare7=%08x iNThreadBaseSpare8=%08x iNThreadBaseSpare9=%08x\r\n", t->iNThreadBaseSpare7, t->iNThreadBaseSpare8, t->iNThreadBaseSpare9); |
|
72 if (!aS->iCurrent) |
|
73 { |
|
74 TUint32* pS=(TUint32*)t->iSavedSP; |
|
75 SThreadReschedStack reg; |
|
76 MTRAPD(r,wordmove(®,pS,sizeof(SThreadReschedStack))); |
|
77 if (r==KErrNone) |
|
78 { |
|
79 Printf("CR0 %08x RsF %08x EIP %08x RSN %08x\r\n", reg.iCR0, reg.iReschedFlag, reg.iEip, reg.iReason); |
|
80 } |
|
81 } |
|
82 NewLine(); |
|
83 } |
|
84 |
|
85 void Monitor::DisplayNFastSemInfo(NFastSemaphore* pS) |
|
86 { |
|
87 if (pS->iCount >= 0) |
|
88 Printf("NFastSemaphore @ %08x Count %d OwningThread %08x\r\n",pS,pS->iCount,pS->iOwningThread); |
|
89 else |
|
90 Printf("NFastSemaphore @ %08x Count %08x (%08x) OwningThread %08x\r\n",pS,pS->iCount,pS->iCount<<2,pS->iOwningThread); |
|
91 } |
|
92 |
|
93 void Monitor::DisplayNFastMutexInfo(NFastMutex* aM) |
|
94 { |
|
95 Printf("NFastMutex @ %08x HoldingThread %08x iWaitQ Pri Mask %08x %08x\r\n", aM, aM->iHoldingThread, aM->iWaitQ.iPresent[1], aM->iWaitQ.iPresent[0]); |
|
96 DisplaySpinLock("SpinLock", &aM->iMutexLock); |
|
97 } |
|
98 |
|
99 void DisplaySubSchedulerInfo(Monitor& m, TSubScheduler& ss) |
|
100 { |
|
101 m.Printf("\r\nSUBSCHEDULER %d @%08x:\r\n",ss.iCpuNum,&ss); |
|
102 m.Printf("CurrentThread=%08x\r\n", ss.iCurrentThread); |
|
103 m.Printf("DFCS %08x %08x CPU# %08x CPUmask %08x\r\n", ss.iDfcs.iA.iNext, ss.iDfcs.iA.iPrev, ss.iCpuNum, ss.iCpuMask); |
|
104 m.Printf("KLCount %d DFCPending %02x ReschedNeeded %02x InIDFC %02x\r\n", ss.iKernLockCount, ss.iDfcPendingFlag, ss.iRescheduleNeededFlag, ss.iInIDFC); |
|
105 m.Printf("AddressSpace=%08x ReschedIPIs=%08x iNextIPI %08x\r\n", ss.iAddressSpace, ss.iReschedIPIs, ss.iNextIPI); |
|
106 volatile TUint32* pL = (volatile TUint32*)&ss.iReadyListLock; |
|
107 m.Printf("SpinLock %08x %08x %08x %08x\r\n", pL[0], pL[1], pL[2], pL[3]); |
|
108 m.Printf("Extras[ 0] %08x Extras[ 1] %08x Extras[ 2] %08x Extras[ 3] %08x\r\n", ss.iExtras[0], ss.iExtras[1], ss.iExtras[2], ss.iExtras[3]); |
|
109 m.Printf("Extras[ 4] %08x Extras[ 5] %08x Extras[ 6] %08x Extras[ 7] %08x\r\n", ss.iExtras[4], ss.iExtras[5], ss.iExtras[6], ss.iExtras[7]); |
|
110 m.Printf("Extras[ 8] %08x i_IrqCount %08x i_ExcInfo %08x i_CrashSt %08x\r\n", ss.iExtras[8], ss.i_IrqCount, ss.i_ExcInfo, ss.i_CrashState); |
|
111 m.Printf("i_APICID %08x i_IrqNestC %08x i_IrqStkTp %08x i_Tss %08x\r\n", ss.i_APICID, ss.i_IrqNestCount, ss.i_IrqStackTop, ss.i_Tss); |
|
112 m.Printf("i_TmrMultF %08x i_TmrMultI %08x i_CpuMult %08x Extras[13] %08x\r\n", ss.i_TimerMultF, ss.i_TimerMultI, ss.i_CpuMult, ss.iExtras[19]); |
|
113 m.Printf("i_TmOffL %08x i_TmOffH %08x Extras[16] %08x Extras[17] %08x\r\n", ss.iExtras[20], ss.iExtras[21], ss.iExtras[22], ss.iExtras[23]); |
|
114 m.Printf("iLastTimestamp %08x %08x iReschedCount %08x %08x\r\n", ss.iLastTimestamp32[1], ss.iLastTimestamp32[0], ss.iReschedCount32[1], ss.iReschedCount32[0]); |
|
115 } |
|
116 |
|
117 void Monitor::DisplaySchedulerInfo() |
|
118 { |
|
119 TScheduler* pS=TScheduler::Ptr(); |
|
120 Printf("SCHEDULER @%08x:\r\n",pS); |
|
121 Printf("ProcessHandler=%08x MonitorExceptionHandler=%08x RescheduleHook=%08x\r\n",pS->iProcessHandler,pS->iMonitorExceptionHandler,pS->iRescheduleHook); |
|
122 Printf("iActiveCpus1=%08x, iActiveCpus2=%08x, iNumCpus=%d\r\n",pS->iActiveCpus1,pS->iActiveCpus2,pS->iNumCpus); |
|
123 Printf("SYSLOCK @ %08x\r\n",&pS->iLock); |
|
124 DisplayNFastMutexInfo(&pS->iLock); |
|
125 DisplaySpinLock("IdleSpinLock", &pS->iIdleSpinLock); |
|
126 Printf("IdleDfcs %08x %08x CpusNotIdle %08x IdleGeneration %02x IdleSpillCpu %02x\r\n", |
|
127 pS->iIdleDfcs.iA.iNext, pS->iIdleDfcs.iA.iPrev, pS->iCpusNotIdle, pS->iIdleGeneration, pS->iIdleSpillCpu); |
|
128 Printf("Extras 0: %08x 1: %08x 2: %08x 3: %08x\r\n",pS->iExtras[0],pS->iExtras[1],pS->iExtras[2],pS->iExtras[3]); |
|
129 Printf("Extras 4: %08x 5: %08x 6: %08x 7: %08x\r\n",pS->iExtras[4],pS->iExtras[5],pS->iExtras[6],pS->iExtras[7]); |
|
130 Printf("Extras 8: %08x 9: %08x A: %08x B: %08x\r\n",pS->iExtras[8],pS->iExtras[9],pS->iExtras[10],pS->iExtras[11]); |
|
131 Printf("Extras C: %08x D: %08x E: %08x F: %08x\r\n",pS->iExtras[12],pS->iExtras[13],pS->iExtras[14],pS->iExtras[15]); |
|
132 Printf("Extras 10: %08x 11: %08x 12: %08x 13: %08x\r\n",pS->iExtras[16],pS->iExtras[17],pS->iExtras[18],pS->iExtras[19]); |
|
133 Printf("Extras 14: %08x 15: %08x 16: %08x 17: %08x\r\n",pS->iExtras[20],pS->iExtras[21],pS->iExtras[22],pS->iExtras[23]); |
|
134 |
|
135 TInt i; |
|
136 for (i=0; i<KMaxCpus; ++i) |
|
137 { |
|
138 TSubScheduler& ss = *pS->iSub[i]; |
|
139 DisplaySubSchedulerInfo(*this,ss); |
|
140 } |
|
141 } |
50 } |
142 |
51 |
143 SFullX86RegSet& RegSet(TInt aCpu) |
52 SFullX86RegSet& RegSet(TInt aCpu) |
144 { |
53 { |
145 TScheduler* pS=TScheduler::Ptr(); |
54 TScheduler* pS=TScheduler::Ptr(); |
146 TSubScheduler& ss = *pS->iSub[aCpu]; |
55 TSubScheduler& ss = *pS->iSub[aCpu]; |
147 SCpuData* cpudata = (SCpuData*)ss.i_Tss; |
56 SCpuData* cpudata = (SCpuData*)ss.iSSX.iTss; |
148 return cpudata->iRegs; |
57 return cpudata->iRegs; |
149 } |
58 } |
150 |
59 |
151 TX86Tss& TSS(TInt aCpu) |
60 TX86Tss& TSS(TInt aCpu) |
152 { |
61 { |
153 TScheduler* pS=TScheduler::Ptr(); |
62 TScheduler* pS=TScheduler::Ptr(); |
154 TSubScheduler& ss = *pS->iSub[aCpu]; |
63 TSubScheduler& ss = *pS->iSub[aCpu]; |
155 return *(TX86Tss*)ss.i_Tss; |
64 return *ss.iSSX.iTss; |
156 } |
65 } |
157 |
66 |
158 void Monitor::DumpCpuRegisters() |
67 void Monitor::DumpCpuRegisters() |
159 { |
68 { |
160 TInt i; |
69 TInt i; |