os/kernelhwsrv/kernel/eka/memmodel/epoc/flexible/mmonitor.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/memmodel/epoc/flexible/mmonitor.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,88 @@
     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 +// Kernel crash debugger - machine independent portion
    1.18 +// 
    1.19 +//
    1.20 +#define INCLUDED_FROM_ASM	// Make DMemModelProcess::iOsAsid public, safe to 
    1.21 +							// do here as the system has crashed and the inline
    1.22 +							// DMemModelProcess::OsAsid() requires too much kernel knowlodge.
    1.23 +
    1.24 +#include <kernel/monitor.h>
    1.25 +#include <memmodel.h>
    1.26 +
    1.27 +void Monitor::DumpMemModelProcessData(DProcess* aProcess)
    1.28 +	{
    1.29 +	DMemModelProcess* pP=(DMemModelProcess*)aProcess;
    1.30 +	// Read the os asid without opening a reference as after the crash this 
    1.31 +	// is the only running thread.
    1.32 +	Printf("OS ASID=%d, LPD=%08x\r\n",pP->iOsAsid,pP->iPageDir);
    1.33 +	Printf("ChunkCount=%d ChunkAlloc=%d\r\n",pP->iChunkCount,pP->iChunkAlloc);
    1.34 +	TInt i;
    1.35 +	for (i=0; i<pP->iChunkCount; i++)
    1.36 +		{
    1.37 +		DMemModelProcess::SChunkInfo& ci=pP->iChunks[i];
    1.38 +		Printf("%d: Chunk %08x, access count %d\r\n",i,ci.iChunk,ci.iAccessCount);
    1.39 +		}
    1.40 +	}
    1.41 +
    1.42 +void Monitor::DumpChunkData(DChunk* aChunk)
    1.43 +	{
    1.44 +	DMemModelChunk* pC=(DMemModelChunk*)aChunk;
    1.45 +	Printf("Owning Process %08x OS ASIDS %08x\r\n",pC->iOwningProcess);
    1.46 +	Printf("Size %x, MaxSize %x\r\n",pC->iSize,pC->iMaxSize);
    1.47 +	Printf("Attrib %x, StartPos %x\r\n",pC->iAttributes,pC->iStartPos);
    1.48 +	Printf("Type %d\r\n",pC->iChunkType);
    1.49 +	Printf("PageBitMap=%08x\r\n",pC->iPageBitMap);
    1.50 +	DumpCpuChunkData(pC);
    1.51 +	}
    1.52 +
    1.53 +void Monitor::MMProcessInfoCommand()
    1.54 +	{
    1.55 +	TScheduler* pS=TScheduler::Ptr();
    1.56 +#ifdef __SMP__
    1.57 +	TInt i;
    1.58 +	for (i=0; i<KMaxCpus; ++i)
    1.59 +		{
    1.60 +		DMonObject* pA = (DMonObject*)pS->iSub[i]->iAddressSpace;
    1.61 +		Printf("CPU%d: TheCurrentAddressSpace=%08x\r\n",i,pA);
    1.62 +		}
    1.63 +#else
    1.64 +	DMonObject* pA=(DMonObject*)pS->iAddressSpace;
    1.65 +	Printf("TheCurrentAddressSpace=%08x\r\n",pA);
    1.66 +#endif
    1.67 +	}
    1.68 +
    1.69 +void Monitor::MDisplayCodeSeg(DCodeSeg* aSeg)
    1.70 +	{
    1.71 +	DMemModelCodeSeg* seg = (DMemModelCodeSeg*) aSeg;
    1.72 +	DMemModelCodeSegMemory* mem = seg->Memory();
    1.73 +	Printf("   iKernelData: %08x\r\n",seg->iKernelData);
    1.74 +	Printf("   iCreator: %08x\r\n",mem ? mem->iCreator : 0);
    1.75 +	}
    1.76 +
    1.77 +extern TInt MapProcess(DMemModelProcess* aProcess, TBool aForce);
    1.78 +
    1.79 +EXPORT_C TUint Monitor::MapAndLocateUserStack(DThread* aThread)
    1.80 +	{
    1.81 +	DMemModelProcess* pP=(DMemModelProcess*)aThread->iOwningProcess;
    1.82 +	TInt r = SwitchAddressSpace(pP, EFalse);
    1.83 +	if (r!=KErrNone)
    1.84 +		return 0;
    1.85 +	return aThread->iUserStackRunAddress;
    1.86 +	}
    1.87 +
    1.88 +EXPORT_C TInt Monitor::SwitchAddressSpace(DProcess* aProcess, TBool aForce)
    1.89 +	{
    1.90 +	return MapProcess((DMemModelProcess*)aProcess, aForce);
    1.91 +	}