First public contribution.
1 // Copyright (c) 1994-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\nkern\x86\ncmonitor.cpp
15 // Kernel crash debugger - NKERN ARM specific portion
21 #include <kernel/monitor.h>
24 EXPORT_C void Monitor::DisplayNThreadInfo(NThread* pT)
26 TBuf8<80> buf=_L8("NThread @ ");
27 buf.AppendNumFixedWidth((TUint)pT,EHex,8);
29 buf.AppendNum((TUint)pT->iPriority);
33 case NThread::EReady: buf+=_L8("READY"); break;
34 case NThread::ESuspended: buf+=_L8("SUSPENDED"); break;
35 case NThread::EWaitFastSemaphore: buf+=_L8("WAITFSEM "); buf.AppendNumFixedWidth((TUint)pT->iWaitObj,EHex,8); break;
36 case NThread::ESleep: buf+=_L8("SLEEP"); break;
37 case NThread::EBlocked: buf+=_L8("BLOCKED"); break;
38 case NThread::EDead: buf+=_L8("DEAD"); break;
39 case NThread::EWaitDfc: buf+=_L8("WAITDFC"); break;
40 default: buf+=_L8("??"); buf.AppendNumFixedWidth((TUint)pT->iSpare1,EHex,8); break;
43 Printf("Next=%08x Prev=%08x Att=%02x ExcInUserMode=%02x\r\n",pT->iNext,pT->iPrev,pT->iSpare2,pT->iSpare3);
44 Printf("HeldFM=%08x WaitFM=%08x AddrSp=%08x\r\n",pT->iHeldFastMutex,pT->iWaitFastMutex,pT->iAddressSpace);
45 Printf("Time=%d Timeslice=%d ReqCount=%d\r\n",pT->iTime,pT->iTimeslice,pT->iRequestSemaphore.iCount);
46 Printf("SuspendCount=%d CsCount=%d CsFunction=%08x\r\n",pT->iSuspendCount,pT->iCsCount,pT->iCsFunction);
47 Printf("iUserModeCallbacks=%08x iSpare7=%08x iSpare8=%08x\r\n", pT->iUserModeCallbacks, pT->iSpare7, pT->iSpare8);
48 Printf("SavedSP=%08x\r\n",pT->iSavedSP);
49 if (pT != TScheduler::Ptr()->iCurrentThread)
51 TUint32* pS=(TUint32*)pT->iSavedSP;
53 MTRAPD(r,wordmove(®,pS,sizeof(SThreadStack)));
56 Printf("EBX %08x ESI %08x EDI %08x EBP %08x\r\n",reg.iEbx,reg.iEsi,reg.iEdi,reg.iEbp);
57 Printf("EIP %08x CR0 %08x FS %08x GS %08x\r\n",reg.iEip,reg.iCR0,reg.iFs,reg.iGs);
63 void Monitor::DisplayNFastSemInfo(NFastSemaphore* pS)
65 Printf("NFastSemaphore @ %08x Count %d OwningThread %08x\r\n",pS,pS->iCount,pS->iOwningThread);
68 void Monitor::DisplayNFastMutexInfo(NFastMutex* pM)
70 Printf("NFastMutex @ %08x HoldingThread %08x iWaiting %08x\r\n",pM,pM->iHoldingThread,pM->iWaiting);
73 void Monitor::DisplaySchedulerInfo()
75 TScheduler* pS=TScheduler::Ptr();
76 Printf("SCHEDULER @%08x: CurrentThread %08x\r\n",pS,pS->iCurrentThread);
77 Printf("RescheduleNeeded=%02x DfcPending=%02x KernCSLocked=%08x\r\n",pS->iRescheduleNeededFlag,pS->iDfcPendingFlag,pS->iKernCSLocked);
78 Printf("DFCS: next %08x prev %08x\r\n",pS->iDfcs.iA.iNext,pS->iDfcs.iA.iPrev);
79 Printf("ProcessHandler=%08x, AddressSpace=%08x\r\n",pS->iProcessHandler,pS->iAddressSpace);
80 Printf("SYSLOCK: HoldingThread %08x iWaiting %08x\r\n",pS->iLock.iHoldingThread,pS->iLock.iWaiting);
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]);
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]);
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]);
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]);
87 void Monitor::DumpCpuRegisters()
89 SFullX86RegSet& r=*(SFullX86RegSet*)iRegs;
90 Printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\r\n",r.iEax,r.iEbx,r.iEcx,r.iEdx);
91 Printf("ESP=%08x EBP=%08x ESI=%08x EDI=%08x\r\n",r.iEsp,r.iEbp,r.iEsi,r.iEdi);
92 Printf(" CS=%08x EIP=%08x EFL=%08x SS=%08x\r\n",r.iCs,r.iEip,r.iEflags,r.iSs);
93 Printf(" DS=%08x ES=%08x FS=%08x GS=%08x\r\n",r.iDs,r.iEs,r.iFs,r.iGs);
94 Printf("IrqNest=%08x\r\n",r.iIrqNestCount);
98 void Monitor::DisplayCpuFaultInfo()
100 TScheduler* pS = TScheduler::Ptr();
101 TAny* p = pS->i_ExcInfo;
104 TX86ExcInfo& a=*(TX86ExcInfo*)p;
105 Printf("Exc %02x EFLAGS=%08x FAR=%08x ErrCode=%08x\r\n",a.iExcId,a.iEflags,a.iFaultAddress,a.iExcErrorCode);
106 Printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\r\n",a.iEax,a.iEbx,a.iEcx,a.iEdx);
107 Printf("ESP=%08x EBP=%08x ESI=%08x EDI=%08x\r\n",a.iEsp,a.iEbp,a.iEsi,a.iEdi);
108 Printf(" CS=%08x EIP=%08x DS=%08x SS=%08x\r\n",a.iCs,a.iEip,a.iDs,a.iSs);
109 Printf(" ES=%08x FS=%08x GS=%08x\r\n",a.iEs,a.iFs,a.iGs);
112 Printf("SS3=%08x ESP3=%08x\r\n",a.iSs3,a.iEsp3);
116 EXPORT_C void Monitor::GetStackPointers(NThread* aThread, TUint& aSupSP, TUint& aUsrSP)
118 TScheduler* pS = TScheduler::Ptr();
119 if (aThread == pS->iCurrentThread)
120 aSupSP = ((SFullX86RegSet*)iRegs)->iEsp;
122 aSupSP = (TUint)aThread->iSavedSP;
124 // User SP is in the exception info on the top of the supervisor stack
125 TUint stackTop = (TUint)aThread->iStackBase + aThread->iStackSize;
126 TX86ExcInfo* excRegs = (TX86ExcInfo*)(stackTop-sizeof(TX86ExcInfo));
127 aUsrSP = excRegs->iEsp3;