1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/nkern/x86/ncmonitor.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,128 @@
1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32\nkern\x86\ncmonitor.cpp
1.18 +// Kernel crash debugger - NKERN ARM specific portion
1.19 +//
1.20 +//
1.21 +
1.22 +#include "nk_priv.h"
1.23 +#include <x86.h>
1.24 +#include <kernel/monitor.h>
1.25 +
1.26 +
1.27 +EXPORT_C void Monitor::DisplayNThreadInfo(NThread* pT)
1.28 + {
1.29 + TBuf8<80> buf=_L8("NThread @ ");
1.30 + buf.AppendNumFixedWidth((TUint)pT,EHex,8);
1.31 + buf+=_L8(" Pri ");
1.32 + buf.AppendNum((TUint)pT->iPriority);
1.33 + buf+=_L8(" NState ");
1.34 + switch (pT->iSpare1)
1.35 + {
1.36 + case NThread::EReady: buf+=_L8("READY"); break;
1.37 + case NThread::ESuspended: buf+=_L8("SUSPENDED"); break;
1.38 + case NThread::EWaitFastSemaphore: buf+=_L8("WAITFSEM "); buf.AppendNumFixedWidth((TUint)pT->iWaitObj,EHex,8); break;
1.39 + case NThread::ESleep: buf+=_L8("SLEEP"); break;
1.40 + case NThread::EBlocked: buf+=_L8("BLOCKED"); break;
1.41 + case NThread::EDead: buf+=_L8("DEAD"); break;
1.42 + case NThread::EWaitDfc: buf+=_L8("WAITDFC"); break;
1.43 + default: buf+=_L8("??"); buf.AppendNumFixedWidth((TUint)pT->iSpare1,EHex,8); break;
1.44 + }
1.45 + PrintLine(buf);
1.46 + Printf("Next=%08x Prev=%08x Att=%02x ExcInUserMode=%02x\r\n",pT->iNext,pT->iPrev,pT->iSpare2,pT->iSpare3);
1.47 + Printf("HeldFM=%08x WaitFM=%08x AddrSp=%08x\r\n",pT->iHeldFastMutex,pT->iWaitFastMutex,pT->iAddressSpace);
1.48 + Printf("Time=%d Timeslice=%d ReqCount=%d\r\n",pT->iTime,pT->iTimeslice,pT->iRequestSemaphore.iCount);
1.49 + Printf("SuspendCount=%d CsCount=%d CsFunction=%08x\r\n",pT->iSuspendCount,pT->iCsCount,pT->iCsFunction);
1.50 + Printf("iUserModeCallbacks=%08x iSpare7=%08x iSpare8=%08x\r\n", pT->iUserModeCallbacks, pT->iSpare7, pT->iSpare8);
1.51 + Printf("SavedSP=%08x\r\n",pT->iSavedSP);
1.52 + if (pT != TScheduler::Ptr()->iCurrentThread)
1.53 + {
1.54 + TUint32* pS=(TUint32*)pT->iSavedSP;
1.55 + SThreadStack reg;
1.56 + MTRAPD(r,wordmove(®,pS,sizeof(SThreadStack)));
1.57 + if (r==KErrNone)
1.58 + {
1.59 + Printf("EBX %08x ESI %08x EDI %08x EBP %08x\r\n",reg.iEbx,reg.iEsi,reg.iEdi,reg.iEbp);
1.60 + Printf("EIP %08x CR0 %08x FS %08x GS %08x\r\n",reg.iEip,reg.iCR0,reg.iFs,reg.iGs);
1.61 + }
1.62 + }
1.63 + NewLine();
1.64 + }
1.65 +
1.66 +void Monitor::DisplayNFastSemInfo(NFastSemaphore* pS)
1.67 + {
1.68 + Printf("NFastSemaphore @ %08x Count %d OwningThread %08x\r\n",pS,pS->iCount,pS->iOwningThread);
1.69 + }
1.70 +
1.71 +void Monitor::DisplayNFastMutexInfo(NFastMutex* pM)
1.72 + {
1.73 + Printf("NFastMutex @ %08x HoldingThread %08x iWaiting %08x\r\n",pM,pM->iHoldingThread,pM->iWaiting);
1.74 + }
1.75 +
1.76 +void Monitor::DisplaySchedulerInfo()
1.77 + {
1.78 + TScheduler* pS=TScheduler::Ptr();
1.79 + Printf("SCHEDULER @%08x: CurrentThread %08x\r\n",pS,pS->iCurrentThread);
1.80 + Printf("RescheduleNeeded=%02x DfcPending=%02x KernCSLocked=%08x\r\n",pS->iRescheduleNeededFlag,pS->iDfcPendingFlag,pS->iKernCSLocked);
1.81 + Printf("DFCS: next %08x prev %08x\r\n",pS->iDfcs.iA.iNext,pS->iDfcs.iA.iPrev);
1.82 + Printf("ProcessHandler=%08x, AddressSpace=%08x\r\n",pS->iProcessHandler,pS->iAddressSpace);
1.83 + Printf("SYSLOCK: HoldingThread %08x iWaiting %08x\r\n",pS->iLock.iHoldingThread,pS->iLock.iWaiting);
1.84 + Printf("Extras 0: %08x 1: %08x 2: %08x 3: %08x\r\n",pS->iExtras[0],pS->iExtras[1],pS->iExtras[2],pS->iExtras[3]);
1.85 + Printf("Extras 4: %08x 5: %08x 6: %08x 7: %08x\r\n",pS->iExtras[4],pS->iExtras[5],pS->iExtras[6],pS->iExtras[7]);
1.86 + Printf("Extras 8: %08x 9: %08x A: %08x B: %08x\r\n",pS->iExtras[8],pS->iExtras[9],pS->iExtras[10],pS->iExtras[11]);
1.87 + Printf("Extras C: %08x D: %08x E: %08x F: %08x\r\n",pS->iExtras[12],pS->iExtras[13],pS->iExtras[14],pS->iExtras[15]);
1.88 + }
1.89 +
1.90 +void Monitor::DumpCpuRegisters()
1.91 + {
1.92 + SFullX86RegSet& r=*(SFullX86RegSet*)iRegs;
1.93 + Printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\r\n",r.iEax,r.iEbx,r.iEcx,r.iEdx);
1.94 + Printf("ESP=%08x EBP=%08x ESI=%08x EDI=%08x\r\n",r.iEsp,r.iEbp,r.iEsi,r.iEdi);
1.95 + Printf(" CS=%08x EIP=%08x EFL=%08x SS=%08x\r\n",r.iCs,r.iEip,r.iEflags,r.iSs);
1.96 + Printf(" DS=%08x ES=%08x FS=%08x GS=%08x\r\n",r.iDs,r.iEs,r.iFs,r.iGs);
1.97 + Printf("IrqNest=%08x\r\n",r.iIrqNestCount);
1.98 + NewLine();
1.99 + }
1.100 +
1.101 +void Monitor::DisplayCpuFaultInfo()
1.102 + {
1.103 + TScheduler* pS = TScheduler::Ptr();
1.104 + TAny* p = pS->i_ExcInfo;
1.105 + if (!p)
1.106 + return;
1.107 + TX86ExcInfo& a=*(TX86ExcInfo*)p;
1.108 + Printf("Exc %02x EFLAGS=%08x FAR=%08x ErrCode=%08x\r\n",a.iExcId,a.iEflags,a.iFaultAddress,a.iExcErrorCode);
1.109 + Printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\r\n",a.iEax,a.iEbx,a.iEcx,a.iEdx);
1.110 + Printf("ESP=%08x EBP=%08x ESI=%08x EDI=%08x\r\n",a.iEsp,a.iEbp,a.iEsi,a.iEdi);
1.111 + Printf(" CS=%08x EIP=%08x DS=%08x SS=%08x\r\n",a.iCs,a.iEip,a.iDs,a.iSs);
1.112 + Printf(" ES=%08x FS=%08x GS=%08x\r\n",a.iEs,a.iFs,a.iGs);
1.113 + if (a.iCs&3)
1.114 + {
1.115 + Printf("SS3=%08x ESP3=%08x\r\n",a.iSs3,a.iEsp3);
1.116 + }
1.117 + }
1.118 +
1.119 +EXPORT_C void Monitor::GetStackPointers(NThread* aThread, TUint& aSupSP, TUint& aUsrSP)
1.120 + {
1.121 + TScheduler* pS = TScheduler::Ptr();
1.122 + if (aThread == pS->iCurrentThread)
1.123 + aSupSP = ((SFullX86RegSet*)iRegs)->iEsp;
1.124 + else
1.125 + aSupSP = (TUint)aThread->iSavedSP;
1.126 +
1.127 + // User SP is in the exception info on the top of the supervisor stack
1.128 + TUint stackTop = (TUint)aThread->iStackBase + aThread->iStackSize;
1.129 + TX86ExcInfo* excRegs = (TX86ExcInfo*)(stackTop-sizeof(TX86ExcInfo));
1.130 + aUsrSP = excRegs->iEsp3;
1.131 + }