sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32\nkernsmp\x86\ncmonitor.cpp
|
sl@0
|
15 |
// Kernel crash debugger - NKERN X86 specific portion
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#define __INCLUDE_NTHREADBASE_DEFINES__
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "nk_priv.h"
|
sl@0
|
22 |
#include <x86.h>
|
sl@0
|
23 |
#include <kernel/monitor.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
void Monitor::DisplaySpinLock(const char* aTitle, TSpinLock* aLock)
|
sl@0
|
27 |
{
|
sl@0
|
28 |
volatile TUint32* p = (volatile TUint32*)aLock;
|
sl@0
|
29 |
Printf("%s %08x %08x\r\n", aTitle, p[0], p[1]);
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
EXPORT_C void Monitor::DisplayNThreadInfo(NThread* aT)
|
sl@0
|
33 |
{
|
sl@0
|
34 |
DisplayNSchedulableInfo(aT);
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
void Monitor::DisplayNSchedulableInfo(NSchedulable* aS)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
NThread* t = aS->iParent ? (NThread*)aS : 0;
|
sl@0
|
40 |
NThreadGroup* g = aS->iParent ? 0 : (NThreadGroup*)aS;
|
sl@0
|
41 |
|
sl@0
|
42 |
if (t && aS->iParent==aS)
|
sl@0
|
43 |
Printf("NThread @%08x Pri %d\r\n",aS,aS->iPriority);
|
sl@0
|
44 |
else if (t)
|
sl@0
|
45 |
Printf("NThread @%08x (G:%08x) Pri %d\r\n",aS,aS->iParent,aS->iPriority);
|
sl@0
|
46 |
else
|
sl@0
|
47 |
Printf("NThreadGroup @%08x Pri %d\r\n",aS,aS->iPriority);
|
sl@0
|
48 |
Printf("Rdy=%02x Curr=%02x LastCpu=%d CpuChg=%02x FrzCpu=%d\r\n", aS->iReady, aS->iCurrent, aS->iLastCpu, aS->iCpuChange, aS->iFreezeCpu);
|
sl@0
|
49 |
Printf("Next=%08x Prev=%08x Parent=%08x CPUaff=%08x\r\n", aS->iNext, aS->iPrev, aS->iParent, aS->iCpuAffinity);
|
sl@0
|
50 |
Printf("PauseCount %02x Susp %1x\r\n", aS->iPauseCount, aS->iSuspended);
|
sl@0
|
51 |
DisplaySpinLock("SpinLock", &aS->iSSpinLock);
|
sl@0
|
52 |
Printf("Stopping %02x Events %08x %08x EventState %08x\r\n", aS->iStopping, aS->iEvents.iA.iNext, aS->iEvents.iA.iPrev, aS->iEventState);
|
sl@0
|
53 |
Printf("TotalCpuTime %08x %08x RunCount %08x %08x\r\n", aS->iTotalCpuTime32[1], aS->iTotalCpuTime32[0], aS->iRunCount32[1], aS->iRunCount32[0]);
|
sl@0
|
54 |
|
sl@0
|
55 |
if (g)
|
sl@0
|
56 |
{
|
sl@0
|
57 |
// Thread group
|
sl@0
|
58 |
return;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
Printf("WaitState %02x %02x [%02x %02x] (%08x)\r\n", t->iWaitState.iWtC.iWtStFlags, t->iWaitState.iWtC.iWtObjType,
|
sl@0
|
62 |
t->iWaitState.iWtC.iWtStSpare1, t->iWaitState.iWtC.iWtStSpare2, t->iWaitState.iWtC.iWtObj);
|
sl@0
|
63 |
Printf("BasePri %d MutexPri %d Att=%02x\r\n", t->iBasePri, t->iMutexPri, t->i_ThrdAttr);
|
sl@0
|
64 |
Printf("HeldFM=%08x FMDef=%02x AddrSp=%08x\r\n", t->iHeldFastMutex, t->iFastMutexDefer, t->iAddressSpace);
|
sl@0
|
65 |
Printf("Time=%d Timeslice=%d ReqCount=%08x\r\n", t->iTime, t->iTimeslice, t->iRequestSemaphore.iCount);
|
sl@0
|
66 |
Printf("SuspendCount=%d CsCount=%d CsFunction=%08x\r\n", t->iSuspendCount, t->iCsCount, t->iCsFunction);
|
sl@0
|
67 |
Printf("LinkedObjType %02x LinkedObj %08x\r\n", t->iLinkedObjType, t->iLinkedObj);
|
sl@0
|
68 |
Printf("SavedSP=%08x WaitLink:%08x %08x %d\r\n", t->iSavedSP, t->iWaitLink.iNext, t->iWaitLink.iPrev, t->iWaitLink.iPriority);
|
sl@0
|
69 |
Printf("iNewParent=%08x iExtraContext=%08x, iExtraContextSize=%08x\r\n", t->iNewParent, t->iExtraContext, t->iExtraContextSize);
|
sl@0
|
70 |
Printf("iUserModeCallbacks=%08x iNThreadBaseSpare6=%08x\r\n", t->iUserModeCallbacks, t->iNThreadBaseSpare6);
|
sl@0
|
71 |
Printf("iNThreadBaseSpare7=%08x iNThreadBaseSpare8=%08x iNThreadBaseSpare9=%08x\r\n", t->iNThreadBaseSpare7, t->iNThreadBaseSpare8, t->iNThreadBaseSpare9);
|
sl@0
|
72 |
if (!aS->iCurrent)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
TUint32* pS=(TUint32*)t->iSavedSP;
|
sl@0
|
75 |
SThreadReschedStack reg;
|
sl@0
|
76 |
MTRAPD(r,wordmove(®,pS,sizeof(SThreadReschedStack)));
|
sl@0
|
77 |
if (r==KErrNone)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
Printf("CR0 %08x RsF %08x EIP %08x RSN %08x\r\n", reg.iCR0, reg.iReschedFlag, reg.iEip, reg.iReason);
|
sl@0
|
80 |
}
|
sl@0
|
81 |
}
|
sl@0
|
82 |
NewLine();
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
void Monitor::DisplayNFastSemInfo(NFastSemaphore* pS)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
if (pS->iCount >= 0)
|
sl@0
|
88 |
Printf("NFastSemaphore @ %08x Count %d OwningThread %08x\r\n",pS,pS->iCount,pS->iOwningThread);
|
sl@0
|
89 |
else
|
sl@0
|
90 |
Printf("NFastSemaphore @ %08x Count %08x (%08x) OwningThread %08x\r\n",pS,pS->iCount,pS->iCount<<2,pS->iOwningThread);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
void Monitor::DisplayNFastMutexInfo(NFastMutex* aM)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
Printf("NFastMutex @ %08x HoldingThread %08x iWaitQ Pri Mask %08x %08x\r\n", aM, aM->iHoldingThread, aM->iWaitQ.iPresent[1], aM->iWaitQ.iPresent[0]);
|
sl@0
|
96 |
DisplaySpinLock("SpinLock", &aM->iMutexLock);
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
void DisplaySubSchedulerInfo(Monitor& m, TSubScheduler& ss)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
m.Printf("\r\nSUBSCHEDULER %d @%08x:\r\n",ss.iCpuNum,&ss);
|
sl@0
|
102 |
m.Printf("CurrentThread=%08x\r\n", ss.iCurrentThread);
|
sl@0
|
103 |
m.Printf("DFCS %08x %08x CPU# %08x CPUmask %08x\r\n", ss.iDfcs.iA.iNext, ss.iDfcs.iA.iPrev, ss.iCpuNum, ss.iCpuMask);
|
sl@0
|
104 |
m.Printf("KLCount %d DFCPending %02x ReschedNeeded %02x InIDFC %02x\r\n", ss.iKernLockCount, ss.iDfcPendingFlag, ss.iRescheduleNeededFlag, ss.iInIDFC);
|
sl@0
|
105 |
m.Printf("AddressSpace=%08x ReschedIPIs=%08x iNextIPI %08x\r\n", ss.iAddressSpace, ss.iReschedIPIs, ss.iNextIPI);
|
sl@0
|
106 |
volatile TUint32* pL = (volatile TUint32*)&ss.iReadyListLock;
|
sl@0
|
107 |
m.Printf("SpinLock %08x %08x %08x %08x\r\n", pL[0], pL[1], pL[2], pL[3]);
|
sl@0
|
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]);
|
sl@0
|
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]);
|
sl@0
|
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);
|
sl@0
|
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);
|
sl@0
|
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]);
|
sl@0
|
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]);
|
sl@0
|
114 |
m.Printf("iLastTimestamp %08x %08x iReschedCount %08x %08x\r\n", ss.iLastTimestamp32[1], ss.iLastTimestamp32[0], ss.iReschedCount32[1], ss.iReschedCount32[0]);
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
void Monitor::DisplaySchedulerInfo()
|
sl@0
|
118 |
{
|
sl@0
|
119 |
TScheduler* pS=TScheduler::Ptr();
|
sl@0
|
120 |
Printf("SCHEDULER @%08x:\r\n",pS);
|
sl@0
|
121 |
Printf("ProcessHandler=%08x MonitorExceptionHandler=%08x RescheduleHook=%08x\r\n",pS->iProcessHandler,pS->iMonitorExceptionHandler,pS->iRescheduleHook);
|
sl@0
|
122 |
Printf("iActiveCpus1=%08x, iActiveCpus2=%08x, iNumCpus=%d\r\n",pS->iActiveCpus1,pS->iActiveCpus2,pS->iNumCpus);
|
sl@0
|
123 |
Printf("SYSLOCK @ %08x\r\n",&pS->iLock);
|
sl@0
|
124 |
DisplayNFastMutexInfo(&pS->iLock);
|
sl@0
|
125 |
DisplaySpinLock("IdleSpinLock", &pS->iIdleSpinLock);
|
sl@0
|
126 |
Printf("IdleDfcs %08x %08x CpusNotIdle %08x IdleGeneration %02x IdleSpillCpu %02x\r\n",
|
sl@0
|
127 |
pS->iIdleDfcs.iA.iNext, pS->iIdleDfcs.iA.iPrev, pS->iCpusNotIdle, pS->iIdleGeneration, pS->iIdleSpillCpu);
|
sl@0
|
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]);
|
sl@0
|
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]);
|
sl@0
|
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]);
|
sl@0
|
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]);
|
sl@0
|
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]);
|
sl@0
|
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]);
|
sl@0
|
134 |
|
sl@0
|
135 |
TInt i;
|
sl@0
|
136 |
for (i=0; i<KMaxCpus; ++i)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
TSubScheduler& ss = *pS->iSub[i];
|
sl@0
|
139 |
DisplaySubSchedulerInfo(*this,ss);
|
sl@0
|
140 |
}
|
sl@0
|
141 |
}
|
sl@0
|
142 |
|
sl@0
|
143 |
SFullX86RegSet& RegSet(TInt aCpu)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
TScheduler* pS=TScheduler::Ptr();
|
sl@0
|
146 |
TSubScheduler& ss = *pS->iSub[aCpu];
|
sl@0
|
147 |
SCpuData* cpudata = (SCpuData*)ss.i_Tss;
|
sl@0
|
148 |
return cpudata->iRegs;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
|
sl@0
|
151 |
TX86Tss& TSS(TInt aCpu)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
TScheduler* pS=TScheduler::Ptr();
|
sl@0
|
154 |
TSubScheduler& ss = *pS->iSub[aCpu];
|
sl@0
|
155 |
return *(TX86Tss*)ss.i_Tss;
|
sl@0
|
156 |
}
|
sl@0
|
157 |
|
sl@0
|
158 |
void Monitor::DumpCpuRegisters()
|
sl@0
|
159 |
{
|
sl@0
|
160 |
TInt i;
|
sl@0
|
161 |
for (i=0; i<KMaxCpus; ++i)
|
sl@0
|
162 |
{
|
sl@0
|
163 |
SFullX86RegSet& r = RegSet(i);
|
sl@0
|
164 |
Printf("CPU %d:\r\n", i);
|
sl@0
|
165 |
Printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\r\n",r.iEax,r.iEbx,r.iEcx,r.iEdx);
|
sl@0
|
166 |
Printf("ESP=%08x EBP=%08x ESI=%08x EDI=%08x\r\n",r.iEsp,r.iEbp,r.iEsi,r.iEdi);
|
sl@0
|
167 |
Printf(" CS=%08x EIP=%08x EFL=%08x SS=%08x\r\n",r.iCs,r.iEip,r.iEflags,r.iSs);
|
sl@0
|
168 |
Printf(" DS=%08x ES=%08x FS=%08x GS=%08x\r\n",r.iDs,r.iEs,r.iFs,r.iGs);
|
sl@0
|
169 |
Printf("IrqNest=%08x\r\n",r.iIrqNestCount);
|
sl@0
|
170 |
NewLine();
|
sl@0
|
171 |
}
|
sl@0
|
172 |
}
|
sl@0
|
173 |
|
sl@0
|
174 |
void Monitor::DisplayCpuFaultInfo()
|
sl@0
|
175 |
{
|
sl@0
|
176 |
TScheduler* pS=TScheduler::Ptr();
|
sl@0
|
177 |
TInt i;
|
sl@0
|
178 |
for (i=0; i<KMaxCpus; ++i)
|
sl@0
|
179 |
{
|
sl@0
|
180 |
Printf("CPU %d:\r\n", i);
|
sl@0
|
181 |
TSubScheduler& ss = *pS->iSub[i];
|
sl@0
|
182 |
if (!ss.i_ExcInfo)
|
sl@0
|
183 |
continue;
|
sl@0
|
184 |
TX86ExcInfo& a = *(TX86ExcInfo*)ss.i_ExcInfo;
|
sl@0
|
185 |
Printf("Exc %02x EFLAGS=%08x FAR=%08x ErrCode=%08x\r\n",a.iExcId,a.iEflags,a.iFaultAddress,a.iExcErrorCode);
|
sl@0
|
186 |
Printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\r\n",a.iEax,a.iEbx,a.iEcx,a.iEdx);
|
sl@0
|
187 |
Printf("ESP=%08x EBP=%08x ESI=%08x EDI=%08x\r\n",a.iEsp,a.iEbp,a.iEsi,a.iEdi);
|
sl@0
|
188 |
Printf(" CS=%08x EIP=%08x DS=%08x SS=%08x\r\n",a.iCs,a.iEip,a.iDs,a.iSs);
|
sl@0
|
189 |
Printf(" ES=%08x FS=%08x GS=%08x\r\n",a.iEs,a.iFs,a.iGs);
|
sl@0
|
190 |
if (a.iCs&3)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
Printf("SS3=%08x ESP3=%08x\r\n",a.iSs3,a.iEsp3);
|
sl@0
|
193 |
}
|
sl@0
|
194 |
NewLine();
|
sl@0
|
195 |
}
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
EXPORT_C void Monitor::GetStackPointers(NThread* aThread, TUint& aSupSP, TUint& aUsrSP)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
TScheduler* pS = TScheduler::Ptr();
|
sl@0
|
201 |
TBool user_done = FALSE;
|
sl@0
|
202 |
if (aThread->iCurrent)
|
sl@0
|
203 |
{
|
sl@0
|
204 |
TInt i = aThread->iLastCpu;
|
sl@0
|
205 |
if (RegSet(i).iCs & 3)
|
sl@0
|
206 |
aSupSP = RegSet(i).iEsp;
|
sl@0
|
207 |
else
|
sl@0
|
208 |
{
|
sl@0
|
209 |
aUsrSP = RegSet(i).iEsp;
|
sl@0
|
210 |
aSupSP = TSS(i).iEsp0;
|
sl@0
|
211 |
user_done = TRUE;
|
sl@0
|
212 |
}
|
sl@0
|
213 |
}
|
sl@0
|
214 |
else
|
sl@0
|
215 |
aSupSP = (TUint)aThread->iSavedSP;
|
sl@0
|
216 |
|
sl@0
|
217 |
if (!user_done)
|
sl@0
|
218 |
{
|
sl@0
|
219 |
// User SP is in the exception info on the top of the supervisor stack
|
sl@0
|
220 |
TUint stackTop = (TUint)aThread->iStackBase + aThread->iStackSize;
|
sl@0
|
221 |
TX86ExcInfo* excRegs = (TX86ExcInfo*)(stackTop - sizeof(TX86ExcInfo));
|
sl@0
|
222 |
aUsrSP = excRegs->iEsp3;
|
sl@0
|
223 |
}
|
sl@0
|
224 |
}
|