kernel/eka/memmodel/epoc/flexible/mmonitor.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Kernel crash debugger - machine independent portion
       
    15 // 
       
    16 //
       
    17 #define INCLUDED_FROM_ASM	// Make DMemModelProcess::iOsAsid public, safe to 
       
    18 							// do here as the system has crashed and the inline
       
    19 							// DMemModelProcess::OsAsid() requires too much kernel knowlodge.
       
    20 
       
    21 #include <kernel/monitor.h>
       
    22 #include <memmodel.h>
       
    23 
       
    24 void Monitor::DumpMemModelProcessData(DProcess* aProcess)
       
    25 	{
       
    26 	DMemModelProcess* pP=(DMemModelProcess*)aProcess;
       
    27 	// Read the os asid without opening a reference as after the crash this 
       
    28 	// is the only running thread.
       
    29 	Printf("OS ASID=%d, LPD=%08x\r\n",pP->iOsAsid,pP->iPageDir);
       
    30 	Printf("ChunkCount=%d ChunkAlloc=%d\r\n",pP->iChunkCount,pP->iChunkAlloc);
       
    31 	TInt i;
       
    32 	for (i=0; i<pP->iChunkCount; i++)
       
    33 		{
       
    34 		DMemModelProcess::SChunkInfo& ci=pP->iChunks[i];
       
    35 		Printf("%d: Chunk %08x, access count %d\r\n",i,ci.iChunk,ci.iAccessCount);
       
    36 		}
       
    37 	}
       
    38 
       
    39 void Monitor::DumpChunkData(DChunk* aChunk)
       
    40 	{
       
    41 	DMemModelChunk* pC=(DMemModelChunk*)aChunk;
       
    42 	Printf("Owning Process %08x OS ASIDS %08x\r\n",pC->iOwningProcess);
       
    43 	Printf("Size %x, MaxSize %x\r\n",pC->iSize,pC->iMaxSize);
       
    44 	Printf("Attrib %x, StartPos %x\r\n",pC->iAttributes,pC->iStartPos);
       
    45 	Printf("Type %d\r\n",pC->iChunkType);
       
    46 	Printf("PageBitMap=%08x\r\n",pC->iPageBitMap);
       
    47 	DumpCpuChunkData(pC);
       
    48 	}
       
    49 
       
    50 void Monitor::MMProcessInfoCommand()
       
    51 	{
       
    52 	TScheduler* pS=TScheduler::Ptr();
       
    53 #ifdef __SMP__
       
    54 	TInt i;
       
    55 	for (i=0; i<KMaxCpus; ++i)
       
    56 		{
       
    57 		DMonObject* pA = (DMonObject*)pS->iSub[i]->iAddressSpace;
       
    58 		Printf("CPU%d: TheCurrentAddressSpace=%08x\r\n",i,pA);
       
    59 		}
       
    60 #else
       
    61 	DMonObject* pA=(DMonObject*)pS->iAddressSpace;
       
    62 	Printf("TheCurrentAddressSpace=%08x\r\n",pA);
       
    63 #endif
       
    64 	}
       
    65 
       
    66 void Monitor::MDisplayCodeSeg(DCodeSeg* aSeg)
       
    67 	{
       
    68 	DMemModelCodeSeg* seg = (DMemModelCodeSeg*) aSeg;
       
    69 	DMemModelCodeSegMemory* mem = seg->Memory();
       
    70 	Printf("   iKernelData: %08x\r\n",seg->iKernelData);
       
    71 	Printf("   iCreator: %08x\r\n",mem ? mem->iCreator : 0);
       
    72 	}
       
    73 
       
    74 extern TInt MapProcess(DMemModelProcess* aProcess, TBool aForce);
       
    75 
       
    76 EXPORT_C TUint Monitor::MapAndLocateUserStack(DThread* aThread)
       
    77 	{
       
    78 	DMemModelProcess* pP=(DMemModelProcess*)aThread->iOwningProcess;
       
    79 	TInt r = SwitchAddressSpace(pP, EFalse);
       
    80 	if (r!=KErrNone)
       
    81 		return 0;
       
    82 	return aThread->iUserStackRunAddress;
       
    83 	}
       
    84 
       
    85 EXPORT_C TInt Monitor::SwitchAddressSpace(DProcess* aProcess, TBool aForce)
       
    86 	{
       
    87 	return MapProcess((DMemModelProcess*)aProcess, aForce);
       
    88 	}