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\arm\ncmonitor.cpp
15 // Kernel crash debugger - NKERN ARM specific portion
19 #define __INCLUDE_REG_OFFSETS__ // for SP_R13U in nk_plat.h
21 #include <kernel/monitor.h>
25 EXPORT_C void Monitor::DisplayNThreadInfo(NThread* pT)
27 TBuf8<80> buf=_L8("NThread @ ");
28 buf.AppendNumFixedWidth((TUint)pT,EHex,8);
30 buf.AppendNum((TUint)pT->iPriority);
34 case NThread::EReady: buf+=_L8("READY"); break;
35 case NThread::ESuspended: buf+=_L8("SUSPENDED"); break;
36 case NThread::EWaitFastSemaphore: buf+=_L8("WAITFSEM "); buf.AppendNumFixedWidth((TUint)pT->iWaitObj,EHex,8); break;
37 case NThread::ESleep: buf+=_L8("SLEEP"); break;
38 case NThread::EBlocked: buf+=_L8("BLOCKED"); break;
39 case NThread::EDead: buf+=_L8("DEAD"); break;
40 case NThread::EWaitDfc: buf+=_L8("WAITDFC"); break;
41 default: buf+=_L8("??"); buf.AppendNumFixedWidth((TUint)pT->iSpare1,EHex,8); break;
44 Printf("Next=%08x Prev=%08x Att=%02x iUserContextType=%02x\r\n",pT->iNext,pT->iPrev,pT->iSpare2,pT->iSpare3);
45 Printf("HeldFM=%08x WaitFM=%08x AddrSp=%08x\r\n",pT->iHeldFastMutex,pT->iWaitFastMutex,pT->iAddressSpace);
46 Printf("Time=%d Timeslice=%d ReqCount=%d\r\n",pT->iTime,pT->iTimeslice,pT->iRequestSemaphore.iCount);
47 Printf("SuspendCount=%d CsCount=%d CsFunction=%08x\r\n",pT->iSuspendCount,pT->iCsCount,pT->iCsFunction);
48 Printf("SavedSP=%08x ExtraContext=%08x ExtraContextSize=%04x\r\n",pT->iSavedSP,pT->iExtraContext,pT->iExtraContextSize);
49 Printf("iUserModeCallbacks=%08x iSpare7=%08x iSpare8=%08x\r\n", pT->iUserModeCallbacks, pT->iSpare7, pT->iSpare8);
50 if (pT != TScheduler::Ptr()->iCurrentThread)
52 TUint32* pS=(TUint32*)pT->iSavedSP;
53 TUint32 reg[12+EXTRA_STACK_SPACE/4];
54 MTRAPD(r,wordmove(reg,pS,48+EXTRA_STACK_SPACE));
58 #ifdef __CPU_SUPPORT_THUMB2EE
59 Printf("TEEHBR %08x ",*pR++);
61 #ifdef __CPU_HAS_CP15_THREAD_ID_REG
62 Printf("RWRWTID %08x ",*pR++);
65 Printf("FPEXC %08x ",*pR++);
67 #ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
68 Printf("CAR %08x ",*pR++);
70 #ifdef __CPU_ARM_USE_DOMAINS
71 Printf("DACR %08x\r\n",*pR++);
73 Printf("R13_USR %08x R14_USR %08x SPSR_SVC %08x\r\n",pR[0],pR[1],pR[2]);
74 Printf(" R4 %08x R5 %08x R6 %08x R7 %08x\r\n",pR[3],pR[4],pR[5],pR[6]);
75 Printf(" R8 %08x R9 %08x R10 %08x R11 %08x\r\n",pR[7],pR[8],pR[9],pR[10]);
76 Printf(" PC %08x\r\n",pR[11]);
82 void Monitor::DisplayNFastSemInfo(NFastSemaphore* pS)
84 Printf("NFastSemaphore @ %08x Count %d OwningThread %08x\r\n",pS,pS->iCount,pS->iOwningThread);
87 void Monitor::DisplayNFastMutexInfo(NFastMutex* pM)
89 Printf("NFastMutex @ %08x HoldingThread %08x iWaiting %08x\r\n",pM,pM->iHoldingThread,pM->iWaiting);
92 void Monitor::DisplaySchedulerInfo()
94 TScheduler* pS=TScheduler::Ptr();
95 Printf("SCHEDULER @%08x: CurrentThread %08x\r\n",pS,pS->iCurrentThread);
96 Printf("RescheduleNeeded=%02x DfcPending=%02x KernCSLocked=%08x\r\n",pS->iRescheduleNeededFlag,pS->iDfcPendingFlag,pS->iKernCSLocked);
97 Printf("DFCS: next %08x prev %08x\r\n",pS->iDfcs.iA.iNext,pS->iDfcs.iA.iPrev);
98 Printf("ProcessHandler=%08x, AddressSpace=%08x\r\n",pS->iProcessHandler,pS->iAddressSpace);
99 Printf("SYSLOCK: HoldingThread %08x iWaiting %08x\r\n",pS->iLock.iHoldingThread,pS->iLock.iWaiting);
100 Printf("Extras 0: %08x 1: %08x 2: %08x 3: %08x\r\n",pS->iExtras[0],pS->iExtras[1],pS->iExtras[2],pS->iExtras[3]);
101 Printf("Extras 4: %08x 5: %08x 6: %08x 7: %08x\r\n",pS->iExtras[4],pS->iExtras[5],pS->iExtras[6],pS->iExtras[7]);
102 Printf("Extras 8: %08x 9: %08x A: %08x B: %08x\r\n",pS->iExtras[8],pS->iExtras[9],pS->iExtras[10],pS->iExtras[11]);
103 Printf("Extras C: %08x D: %08x E: %08x F: %08x\r\n",pS->iExtras[12],pS->iExtras[13],pS->iExtras[14],pS->iExtras[15]);
106 void DumpRegisters(Monitor& m, SFullArmRegSet& a)
108 SNormalRegs& r = a.iN;
109 m.Printf("MODE_USR:\r\n");
110 m.Printf(" R0=%08x R1=%08x R2=%08x R3=%08x\r\n", r.iR0, r.iR1, r.iR2, r.iR3);
111 m.Printf(" R4=%08x R5=%08x R6=%08x R7=%08x\r\n", r.iR4, r.iR5, r.iR6, r.iR7);
112 m.Printf(" R8=%08x R9=%08x R10=%08x R11=%08x\r\n", r.iR8, r.iR9, r.iR10, r.iR11);
113 m.Printf("R12=%08x R13=%08x R14=%08x R15=%08x\r\n", r.iR12, r.iR13, r.iR14, r.iR15);
114 m.Printf("CPSR=%08x\r\n", r.iFlags);
115 m.Printf("MODE_FIQ:\r\n");
116 m.Printf(" R8=%08x R9=%08x R10=%08x R11=%08x\r\n", r.iR8Fiq, r.iR9Fiq, r.iR10Fiq, r.iR11Fiq);
117 m.Printf("R12=%08x R13=%08x R14=%08x SPSR=%08x\r\n", r.iR12Fiq, r.iR13Fiq, r.iR14Fiq, r.iSpsrFiq);
118 m.Printf("MODE_IRQ:\r\n");
119 m.Printf("R13=%08x R14=%08x SPSR=%08x\r\n", r.iR13Irq, r.iR14Irq, r.iSpsrIrq);
120 m.Printf("MODE_SVC:\r\n");
121 m.Printf("R13=%08x R14=%08x SPSR=%08x\r\n", r.iR13Svc, r.iR14Svc, r.iSpsrSvc);
122 m.Printf("MODE_ABT:\r\n");
123 m.Printf("R13=%08x R14=%08x SPSR=%08x\r\n", r.iR13Abt, r.iR14Abt, r.iSpsrAbt);
124 m.Printf("MODE_UND:\r\n");
125 m.Printf("R13=%08x R14=%08x SPSR=%08x\r\n", r.iR13Und, r.iR14Und, r.iSpsrUnd);
126 // m.Printf("MODE_MON:\r\n");
127 // m.Printf("R13=%08x R14=%08x SPSR=%08x\r\n", r.iR13Mon, r.iR14Mon, r.iSpsrMon);
129 SAuxiliaryRegs& aux = a.iA;
130 m.Printf("TEEHBR=%08x CPACR=%08x\r\n", aux.iTEEHBR, aux.iCPACR);
132 SBankedRegs& b = a.iB[0];
133 m.Printf(" SCTLR=%08x ACTLR=%08x PRRR=%08x NMRR=%08x\r\n", b.iSCTLR, b.iACTLR, b.iPRRR, b.iNMRR);
134 m.Printf(" DACR=%08x TTBR0=%08x TTBR1=%08x TTBCR=%08x\r\n", b.iDACR, b.iTTBR0, b.iTTBR1, b.iTTBCR);
135 m.Printf(" VBAR=%08x FCSEID=%08x CTXIDR=%08x\r\n", b.iVBAR, b.iFCSEIDR, b.iCTXIDR);
136 m.Printf("Thread ID RWRW=%08x RWRO=%08x RWNO=%08x\r\n", b.iRWRWTID, b.iRWROTID, b.iRWNOTID);
138 extern TUint32 GetMMUID();
139 m.Printf(" MMUID %08x\r\n", GetMMUID());
142 m.Printf("FPEXC %08x\r\n", a.iMore[0]);
144 #ifdef __CPU_HAS_CACHE_TYPE_REGISTER
145 extern TUint32 GetCacheType();
146 m.Printf("CTYPE %08x\r\n", GetCacheType());
151 EXPORT_C void Monitor::DumpCpuRegisters()
153 SFullArmRegSet& r = *(SFullArmRegSet*)iRegs;
154 DumpRegisters(*this, r);
157 EXPORT_C void Monitor::DisplayCpuFaultInfo()
159 TScheduler* pS = TScheduler::Ptr();
160 SFullArmRegSet& r = *(SFullArmRegSet*)pS->i_Regs;
161 if (TUint(r.iExcCode) > TUint(EArmExceptionUndefinedOpcode))
163 Printf("Exc %1d Cpsr=%08x FAR=%08x FSR=%08x\r\n", r.iExcCode, r.iN.iFlags, r.iB[0].iDFAR, r.iB[0].iDFSR);
164 Printf(" R0=%08x R1=%08x R2=%08x R3=%08x\r\n", r.iN.iR0, r.iN.iR1, r.iN.iR2, r.iN.iR3);
165 Printf(" R4=%08x R5=%08x R6=%08x R7=%08x\r\n", r.iN.iR4, r.iN.iR5, r.iN.iR6, r.iN.iR7);
166 Printf(" R8=%08x R9=%08x R10=%08x R11=%08x\r\n", r.iN.iR8, r.iN.iR9, r.iN.iR10, r.iN.iR11);
167 Printf("R12=%08x R13=%08x R14=%08x R15=%08x\r\n", r.iN.iR12, r.iN.iR13, r.iN.iR14, r.iN.iR15);
168 Printf("R13Svc=%08x R14Svc=%08x SpsrSvc=%08x\r\n", r.iN.iR13Svc, r.iN.iR14Svc, r.iN.iSpsrSvc);
171 EXPORT_C void Monitor::GetStackPointers(NThread* aThread, TUint& aSupSP, TUint& aUsrSP)
173 TScheduler* pS = TScheduler::Ptr();
174 if (aThread == pS->iCurrentThread)
176 SFullArmRegSet& r = *(SFullArmRegSet*)iRegs;
177 aSupSP = r.iN.iR13Svc;
182 TUint32* sp = (TUint32*)aThread->iSavedSP;
184 aUsrSP = sp[SP_R13U];