|
1 // Copyright (c) 2009-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\nkernsmp\nk_mon.cpp |
|
15 // Kernel crash debugger - NKERNSMP platform-independent portion |
|
16 // |
|
17 // |
|
18 |
|
19 #define __INCLUDE_NTHREADBASE_DEFINES__ |
|
20 |
|
21 #include "nk_bal.h" |
|
22 #include <kernel/monitor.h> |
|
23 #include "nk_priv.h" |
|
24 |
|
25 void Monitor::DisplaySpinLock(const char* aTitle, TSpinLock* aLock) |
|
26 { |
|
27 volatile TUint32* p = (volatile TUint32*)aLock; |
|
28 Printf("%s %08x %08x\r\n", aTitle, p[0], p[1]); |
|
29 } |
|
30 |
|
31 EXPORT_C void Monitor::DisplayNThreadInfo(NThread* aT) |
|
32 { |
|
33 DisplayNSchedulableInfo(aT); |
|
34 } |
|
35 |
|
36 extern void DisplayNThreadStackedRegs(Monitor&, SThreadReschedStack&); |
|
37 extern void DisplaySubSchedulerExt(Monitor& m, TSubScheduler& ss); |
|
38 extern void DisplaySchedulerExt(Monitor& m, TScheduler& s); |
|
39 |
|
40 void Monitor::DisplayNSchedulableInfo(NSchedulable* aS) |
|
41 { |
|
42 NThread* t = aS->iParent ? (NThread*)aS : 0; |
|
43 NThreadGroup* g = aS->iParent ? 0 : (NThreadGroup*)aS; |
|
44 |
|
45 if (t && aS->iParent==aS) |
|
46 Printf("NThread @%08x Pri %d\r\n",aS,aS->iPriority); |
|
47 else if (t) |
|
48 Printf("NThread @%08x (G:%08x) Pri %d\r\n",aS,aS->iParent,aS->iPriority); |
|
49 else |
|
50 Printf("NThreadGroup @%08x Pri %d\r\n",aS,aS->iPriority); |
|
51 Printf("Rdy=%02x Curr=%02x LastCpu=%d CpuChg=%02x FrzCpu=%d\r\n", aS->iReady, aS->iCurrent, aS->iLastCpu, aS->iCpuChange, aS->iFreezeCpu); |
|
52 Printf("Next=%08x Prev=%08x Parent=%08x\r\n", aS->iNext, aS->iPrev, aS->iParent); |
|
53 Printf("CPUaff=%08x PrefCpu=%02x TCpu=%02x FCpu=%02x\r\n", aS->iCpuAffinity, aS->iPreferredCpu, aS->iTransientCpu, aS->iForcedCpu); |
|
54 Printf("PauseCount %02x Susp %1x ACount %02x ActiveState %d\r\n", aS->iPauseCount, aS->iSuspended, aS->iACount, aS->iActiveState); |
|
55 DisplaySpinLock("SpinLock", &aS->iSSpinLock); |
|
56 Printf("Stopping %02x Events %08x %08x EventState %08x\r\n", aS->iStopping, aS->iEvents.iA.iNext, aS->iEvents.iA.iPrev, aS->iEventState); |
|
57 Printf("TotalCpuTime %08x %08x RunCount %08x %08x\r\n", aS->iTotalCpuTime.i32[1], aS->iTotalCpuTime.i32[0], aS->iRunCount.i32[1], aS->iRunCount.i32[0]); |
|
58 Printf("TotalActiveTime %08x %08x LastActivation %08x %08x\r\n", aS->iTotalActiveTime.i32[1], aS->iTotalActiveTime.i32[0], aS->iLastActivationTime.i32[1], aS->iLastActivationTime.i32[0]); |
|
59 Printf("SavedCpuTime %08x %08x SavedActiveTime %08x %08x\r\n", aS->iSavedCpuTime.i32[1], aS->iSavedCpuTime.i32[0], aS->iSavedActiveTime.i32[1], aS->iSavedActiveTime.i32[0]); |
|
60 Printf("LastRunTime %08x %08x LbLink %08x %08x LbState %02x\r\n", aS->iLastRunTime.i32[1], aS->iLastRunTime.i32[0], aS->iLbLink.iNext, aS->iLbLink.iPrev, aS->iLbState); |
|
61 |
|
62 DUMP_LOAD_BALANCE_INFO(aS); |
|
63 volatile TUint32* el = (volatile TUint32*)&aS->iEnumerateLink; |
|
64 Printf("EnumLink %08x %08x\r\n", el[0], el[1]); |
|
65 |
|
66 if (g) |
|
67 { |
|
68 // Thread group |
|
69 return; |
|
70 } |
|
71 |
|
72 Printf("WaitState %02x %02x [%02x %02x] (%08x)\r\n", t->iWaitState.iWtC.iWtStFlags, t->iWaitState.iWtC.iWtObjType, |
|
73 t->iWaitState.iWtC.iWtStSpare1, t->iWaitState.iWtC.iWtStSpare2, t->iWaitState.iWtC.iWtObj); |
|
74 Printf("BasePri %d MutexPri %d NomPri %d Att=%02x\r\n", t->iBasePri, t->iMutexPri, t->iNominalPri, t->i_ThrdAttr); |
|
75 Printf("HeldFM=%08x FMDef=%02x AddrSp=%08x Initial=%d\r\n", t->iHeldFastMutex, t->iFastMutexDefer, t->iAddressSpace, t->iInitial); |
|
76 Printf("Time=%d Timeslice=%d ReqCount=%08x\r\n", t->iTime, t->iTimeslice, t->iRequestSemaphore.iCount); |
|
77 Printf("SuspendCount=%d CsCount=%d CsFunction=%08x\r\n", t->iSuspendCount, t->iCsCount, t->iCsFunction); |
|
78 Printf("LinkedObjType %02x LinkedObj %08x CoreCyc %02x RebalAttr %02x\r\n", t->iLinkedObjType, t->iLinkedObj, t->iCoreCycling, t->iRebalanceAttr); |
|
79 Printf("SavedSP=%08x WaitLink:%08x %08x %d\r\n", t->iSavedSP, t->iWaitLink.iNext, t->iWaitLink.iPrev, t->iWaitLink.iPriority); |
|
80 Printf("iNewParent=%08x iExtraContext=%08x, iExtraContextSize=%08x\r\n", t->iNewParent, t->iExtraContext, t->iExtraContextSize); |
|
81 Printf("iUserModeCallbacks=%08x iNThreadBaseSpare6=%08x\r\n", t->iUserModeCallbacks, t->iNThreadBaseSpare6); |
|
82 Printf("iNThreadBaseSpare7=%08x iNThreadBaseSpare8=%08x iNThreadBaseSpare9=%08x\r\n", t->iNThreadBaseSpare7, t->iNThreadBaseSpare8, t->iNThreadBaseSpare9); |
|
83 if (!aS->iCurrent) |
|
84 { |
|
85 TUint32* pS=(TUint32*)t->iSavedSP; |
|
86 SThreadReschedStack reg; |
|
87 MTRAPD(r,wordmove(®,pS,sizeof(SThreadReschedStack))); |
|
88 if (r==KErrNone) |
|
89 DisplayNThreadStackedRegs(*this, reg); |
|
90 } |
|
91 NewLine(); |
|
92 } |
|
93 |
|
94 void Monitor::DisplayNFastSemInfo(NFastSemaphore* pS) |
|
95 { |
|
96 if (pS->iCount >= 0) |
|
97 Printf("NFastSemaphore @ %08x Count %d OwningThread %08x\r\n",pS,pS->iCount,pS->iOwningThread); |
|
98 else |
|
99 Printf("NFastSemaphore @ %08x Count %08x (%08x) OwningThread %08x\r\n",pS,pS->iCount,pS->iCount<<2,pS->iOwningThread); |
|
100 } |
|
101 |
|
102 void Monitor::DisplayNFastMutexInfo(NFastMutex* aM) |
|
103 { |
|
104 Printf("NFastMutex @ %08x HoldingThread %08x iWaitQ Pri Mask %08x %08x\r\n", aM, aM->iHoldingThread, aM->iWaitQ.iPresent[1], aM->iWaitQ.iPresent[0]); |
|
105 DisplaySpinLock("SpinLock", &aM->iMutexLock); |
|
106 } |
|
107 |
|
108 void DisplaySubSchedulerInfo(Monitor& m, TSubScheduler& ss) |
|
109 { |
|
110 m.Printf("\r\nSUBSCHEDULER %d @%08x:\r\n", ss.iCpuNum, &ss); |
|
111 m.Printf("CurrentThread=%08x\r\n", ss.iCurrentThread); |
|
112 m.Printf("IDFCs %08x %08x CPU# %08x CPUmask %08x\r\n", ss.iDfcs.iA.iNext, ss.iDfcs.iA.iPrev, ss.iCpuNum, ss.iCpuMask); |
|
113 m.Printf("ExIDFCs %08x %08x CurIDFC %08x PendFlg %08x\r\n", ss.iExIDfcs.iA.iNext, ss.iExIDfcs.iA.iPrev, ss.iCurrentIDFC, *(TUint32*)&ss.iRescheduleNeededFlag); |
|
114 m.DisplaySpinLock("ExIDfcLock", &ss.iExIDfcLock); |
|
115 m.Printf("KLCount %d InIDFC %02x EvPend %02x\r\n", ss.iKernLockCount, ss.iInIDFC, ss.iEventHandlersPending); |
|
116 m.Printf("LbQ %08x %08x LbCtr %02x\r\n", ss.iLbQ.iA.iNext, ss.iLbQ.iA.iPrev, ss.iLbCounter); |
|
117 m.Printf("AddrSp %08x RschdIPIs %08x iNextIPI %08x\r\n", ss.iAddressSpace, ss.iReschedIPIs, ss.iNextIPI); |
|
118 m.DisplaySpinLock("ReadyListLock", &ss.iReadyListLock); |
|
119 m.Printf("EvtHand %08x %08x InitThrd %08x SLOC %08x %08x\r\n", ss.iEventHandlers.iA.iNext, ss.iEventHandlers.iA.iPrev, |
|
120 ss.iInitialThread, I64HIGH(ss.iSpinLockOrderCheck), I64LOW(ss.iSpinLockOrderCheck)); |
|
121 m.DisplaySpinLock("EventHandlerLock", &ss.iEventHandlerLock); |
|
122 m.Printf("LastTmstmp %08x %08x RschdCount %08x %08x\r\n", ss.iLastTimestamp.i32[1], ss.iLastTimestamp.i32[0], ss.iReschedCount.i32[1], ss.iReschedCount.i32[0]); |
|
123 |
|
124 m.Printf("DeferShutdown %4d RdyThrdC %d Uncached %08x\r\n", ss.iDeferShutdown, ss.iRdyThreadCount, ss.iUncached); |
|
125 DisplaySubSchedulerExt(m, ss); |
|
126 TPriListBase* b = (TPriListBase*)&ss; |
|
127 m.Printf("PriClassThrdC %4d %4d %4d %4d\r\n", ss.iPriClassThreadCount[0], ss.iPriClassThreadCount[1], ss.iPriClassThreadCount[2], ss.iPriClassThreadCount[3]); |
|
128 m.Printf("Present %08x %08x\r\n", b->iPresent[1], b->iPresent[0]); |
|
129 TInt k; |
|
130 TUint64 p64 = b->iPresent64; |
|
131 for (k=KNumPriorities-1; k>=0; --k, p64+=p64) |
|
132 { |
|
133 if (p64>>63) |
|
134 { |
|
135 m.Printf("Priority %2d -> %08x\r\n", k, ss.EntryAtPriority(k)); |
|
136 } |
|
137 } |
|
138 } |
|
139 |
|
140 void Monitor::DisplaySchedulerInfo() |
|
141 { |
|
142 TScheduler* pS=TScheduler::Ptr(); |
|
143 Printf("SCHEDULER @%08x:\r\n",pS); |
|
144 Printf("ProcessHandler %08x MonitorExcHndlr %08x ReschedHook %08x\r\n",pS->iProcessHandler,pS->iMonitorExceptionHandler,pS->iRescheduleHook); |
|
145 Printf("iThreadAcceptCpus %08x iIpiAcceptCpus %08x iNumCpus %d\r\n",pS->iThreadAcceptCpus,pS->iIpiAcceptCpus,pS->iNumCpus); |
|
146 Printf("iCpusComingUp %08x iCpusGoingDown %08x CCDeferCnt %d\r\n",pS->iCpusComingUp,pS->iCpusGoingDown,pS->iCCDeferCount); |
|
147 Printf("iCCSyncCpus %08x CCReactiv8Cpus %08x CCState %08x\r\n",pS->iCCSyncCpus,pS->iCCReactivateCpus,pS->iCCState); |
|
148 Printf("IdleDfcs %08x %08x CpusNotIdle %08x IdleGen %02x IdleSpillCpu %02x\r\n", |
|
149 pS->iIdleDfcs.iA.iNext, pS->iIdleDfcs.iA.iPrev, pS->iCpusNotIdle, pS->iIdleGeneration, pS->iIdleSpillCpu); |
|
150 DisplaySpinLock("IdleSpinLock", &pS->iIdleSpinLock); |
|
151 Printf("SYSLOCK @ %08x\r\n",&pS->iLock); |
|
152 DisplayNFastMutexInfo(&pS->iLock); |
|
153 |
|
154 DisplaySpinLock("EnumerateLock", &pS->iEnumerateLock); |
|
155 volatile TUint32* at = (volatile TUint32*)&pS->iAllThreads; |
|
156 volatile TUint32* ag = (volatile TUint32*)&pS->iAllGroups; |
|
157 Printf("AllThrds %08x %08x AllGroups %08x %08x\r\n", at[0], at[1], ag[0], ag[1]); |
|
158 DisplaySpinLock("IdleBalanceLock", &pS->iIdleBalanceLock); |
|
159 DisplaySpinLock("BalanceListLock", &pS->iBalanceListLock); |
|
160 Printf("BalList %08x %08x LastBalanceTime %08x %08x\r\n", pS->iBalanceList.iA.iNext, pS->iBalanceList.iA.iPrev, |
|
161 I64HIGH(pS->iLastBalanceTime), I64LOW(pS->iLastBalanceTime)); |
|
162 Printf("LbCntr %02x RebalanceDfcQ %08x NeedBal %02x\r\n", pS->iLbCounter, pS->iRebalanceDfcQ, pS->iNeedBal); |
|
163 Printf("iCCRequestLevel %08x iPoweringOff %08x DetachCnt %08x\r\n",pS->iCCRequestLevel,pS->iPoweringOff,pS->iDetachCount); |
|
164 |
|
165 DisplaySchedulerExt(*this, *pS); |
|
166 volatile TUint32* sc = (volatile TUint32*)&pS->iSchedScratch[0]; |
|
167 Printf("Scratch 0: %08x 1: %08x 2: %08x 3: %08x\r\n",sc[0],sc[1],sc[2],sc[3]); |
|
168 Printf("Scratch 4: %08x 5: %08x 6: %08x 7: %08x\r\n",sc[4],sc[5],sc[6],sc[7]); |
|
169 Printf("Scratch 8: %08x 9: %08x A: %08x B: %08x\r\n",sc[8],sc[9],sc[10],sc[11]); |
|
170 Printf("Scratch C: %08x D: %08x E: %08x F: %08x\r\n",sc[12],sc[13],sc[14],sc[15]); |
|
171 |
|
172 TInt i; |
|
173 for (i=0; i<KMaxCpus; ++i) |
|
174 { |
|
175 TSubScheduler& ss = *pS->iSub[i]; |
|
176 DisplaySubSchedulerInfo(*this, ss); |
|
177 } |
|
178 NewLine(); |
|
179 } |
|
180 |