sl@0
|
1 |
// Copyright (c) 1994-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\nkern\x86\ncmonitor.cpp
|
sl@0
|
15 |
// Kernel crash debugger - NKERN ARM specific portion
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "nk_priv.h"
|
sl@0
|
20 |
#include <x86.h>
|
sl@0
|
21 |
#include <kernel/monitor.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
EXPORT_C void Monitor::DisplayNThreadInfo(NThread* pT)
|
sl@0
|
25 |
{
|
sl@0
|
26 |
TBuf8<80> buf=_L8("NThread @ ");
|
sl@0
|
27 |
buf.AppendNumFixedWidth((TUint)pT,EHex,8);
|
sl@0
|
28 |
buf+=_L8(" Pri ");
|
sl@0
|
29 |
buf.AppendNum((TUint)pT->iPriority);
|
sl@0
|
30 |
buf+=_L8(" NState ");
|
sl@0
|
31 |
switch (pT->iSpare1)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
case NThread::EReady: buf+=_L8("READY"); break;
|
sl@0
|
34 |
case NThread::ESuspended: buf+=_L8("SUSPENDED"); break;
|
sl@0
|
35 |
case NThread::EWaitFastSemaphore: buf+=_L8("WAITFSEM "); buf.AppendNumFixedWidth((TUint)pT->iWaitObj,EHex,8); break;
|
sl@0
|
36 |
case NThread::ESleep: buf+=_L8("SLEEP"); break;
|
sl@0
|
37 |
case NThread::EBlocked: buf+=_L8("BLOCKED"); break;
|
sl@0
|
38 |
case NThread::EDead: buf+=_L8("DEAD"); break;
|
sl@0
|
39 |
case NThread::EWaitDfc: buf+=_L8("WAITDFC"); break;
|
sl@0
|
40 |
default: buf+=_L8("??"); buf.AppendNumFixedWidth((TUint)pT->iSpare1,EHex,8); break;
|
sl@0
|
41 |
}
|
sl@0
|
42 |
PrintLine(buf);
|
sl@0
|
43 |
Printf("Next=%08x Prev=%08x Att=%02x ExcInUserMode=%02x\r\n",pT->iNext,pT->iPrev,pT->iSpare2,pT->iSpare3);
|
sl@0
|
44 |
Printf("HeldFM=%08x WaitFM=%08x AddrSp=%08x\r\n",pT->iHeldFastMutex,pT->iWaitFastMutex,pT->iAddressSpace);
|
sl@0
|
45 |
Printf("Time=%d Timeslice=%d ReqCount=%d\r\n",pT->iTime,pT->iTimeslice,pT->iRequestSemaphore.iCount);
|
sl@0
|
46 |
Printf("SuspendCount=%d CsCount=%d CsFunction=%08x\r\n",pT->iSuspendCount,pT->iCsCount,pT->iCsFunction);
|
sl@0
|
47 |
Printf("iUserModeCallbacks=%08x iSpare7=%08x iSpare8=%08x\r\n", pT->iUserModeCallbacks, pT->iSpare7, pT->iSpare8);
|
sl@0
|
48 |
Printf("SavedSP=%08x\r\n",pT->iSavedSP);
|
sl@0
|
49 |
if (pT != TScheduler::Ptr()->iCurrentThread)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
TUint32* pS=(TUint32*)pT->iSavedSP;
|
sl@0
|
52 |
SThreadStack reg;
|
sl@0
|
53 |
MTRAPD(r,wordmove(®,pS,sizeof(SThreadStack)));
|
sl@0
|
54 |
if (r==KErrNone)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
Printf("EBX %08x ESI %08x EDI %08x EBP %08x\r\n",reg.iEbx,reg.iEsi,reg.iEdi,reg.iEbp);
|
sl@0
|
57 |
Printf("EIP %08x CR0 %08x FS %08x GS %08x\r\n",reg.iEip,reg.iCR0,reg.iFs,reg.iGs);
|
sl@0
|
58 |
}
|
sl@0
|
59 |
}
|
sl@0
|
60 |
NewLine();
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
void Monitor::DisplayNFastSemInfo(NFastSemaphore* pS)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
Printf("NFastSemaphore @ %08x Count %d OwningThread %08x\r\n",pS,pS->iCount,pS->iOwningThread);
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
void Monitor::DisplayNFastMutexInfo(NFastMutex* pM)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
Printf("NFastMutex @ %08x HoldingThread %08x iWaiting %08x\r\n",pM,pM->iHoldingThread,pM->iWaiting);
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
void Monitor::DisplaySchedulerInfo()
|
sl@0
|
74 |
{
|
sl@0
|
75 |
TScheduler* pS=TScheduler::Ptr();
|
sl@0
|
76 |
Printf("SCHEDULER @%08x: CurrentThread %08x\r\n",pS,pS->iCurrentThread);
|
sl@0
|
77 |
Printf("RescheduleNeeded=%02x DfcPending=%02x KernCSLocked=%08x\r\n",pS->iRescheduleNeededFlag,pS->iDfcPendingFlag,pS->iKernCSLocked);
|
sl@0
|
78 |
Printf("DFCS: next %08x prev %08x\r\n",pS->iDfcs.iA.iNext,pS->iDfcs.iA.iPrev);
|
sl@0
|
79 |
Printf("ProcessHandler=%08x, AddressSpace=%08x\r\n",pS->iProcessHandler,pS->iAddressSpace);
|
sl@0
|
80 |
Printf("SYSLOCK: HoldingThread %08x iWaiting %08x\r\n",pS->iLock.iHoldingThread,pS->iLock.iWaiting);
|
sl@0
|
81 |
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
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
void Monitor::DumpCpuRegisters()
|
sl@0
|
88 |
{
|
sl@0
|
89 |
SFullX86RegSet& r=*(SFullX86RegSet*)iRegs;
|
sl@0
|
90 |
Printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\r\n",r.iEax,r.iEbx,r.iEcx,r.iEdx);
|
sl@0
|
91 |
Printf("ESP=%08x EBP=%08x ESI=%08x EDI=%08x\r\n",r.iEsp,r.iEbp,r.iEsi,r.iEdi);
|
sl@0
|
92 |
Printf(" CS=%08x EIP=%08x EFL=%08x SS=%08x\r\n",r.iCs,r.iEip,r.iEflags,r.iSs);
|
sl@0
|
93 |
Printf(" DS=%08x ES=%08x FS=%08x GS=%08x\r\n",r.iDs,r.iEs,r.iFs,r.iGs);
|
sl@0
|
94 |
Printf("IrqNest=%08x\r\n",r.iIrqNestCount);
|
sl@0
|
95 |
NewLine();
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
void Monitor::DisplayCpuFaultInfo()
|
sl@0
|
99 |
{
|
sl@0
|
100 |
TScheduler* pS = TScheduler::Ptr();
|
sl@0
|
101 |
TAny* p = pS->i_ExcInfo;
|
sl@0
|
102 |
if (!p)
|
sl@0
|
103 |
return;
|
sl@0
|
104 |
TX86ExcInfo& a=*(TX86ExcInfo*)p;
|
sl@0
|
105 |
Printf("Exc %02x EFLAGS=%08x FAR=%08x ErrCode=%08x\r\n",a.iExcId,a.iEflags,a.iFaultAddress,a.iExcErrorCode);
|
sl@0
|
106 |
Printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\r\n",a.iEax,a.iEbx,a.iEcx,a.iEdx);
|
sl@0
|
107 |
Printf("ESP=%08x EBP=%08x ESI=%08x EDI=%08x\r\n",a.iEsp,a.iEbp,a.iEsi,a.iEdi);
|
sl@0
|
108 |
Printf(" CS=%08x EIP=%08x DS=%08x SS=%08x\r\n",a.iCs,a.iEip,a.iDs,a.iSs);
|
sl@0
|
109 |
Printf(" ES=%08x FS=%08x GS=%08x\r\n",a.iEs,a.iFs,a.iGs);
|
sl@0
|
110 |
if (a.iCs&3)
|
sl@0
|
111 |
{
|
sl@0
|
112 |
Printf("SS3=%08x ESP3=%08x\r\n",a.iSs3,a.iEsp3);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
EXPORT_C void Monitor::GetStackPointers(NThread* aThread, TUint& aSupSP, TUint& aUsrSP)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
TScheduler* pS = TScheduler::Ptr();
|
sl@0
|
119 |
if (aThread == pS->iCurrentThread)
|
sl@0
|
120 |
aSupSP = ((SFullX86RegSet*)iRegs)->iEsp;
|
sl@0
|
121 |
else
|
sl@0
|
122 |
aSupSP = (TUint)aThread->iSavedSP;
|
sl@0
|
123 |
|
sl@0
|
124 |
// User SP is in the exception info on the top of the supervisor stack
|
sl@0
|
125 |
TUint stackTop = (TUint)aThread->iStackBase + aThread->iStackSize;
|
sl@0
|
126 |
TX86ExcInfo* excRegs = (TX86ExcInfo*)(stackTop-sizeof(TX86ExcInfo));
|
sl@0
|
127 |
aUsrSP = excRegs->iEsp3;
|
sl@0
|
128 |
}
|