static void OutputUserFunctionsInfo( void *theEnv) { struct FunctionDefinition *theFunction; int i; for (theFunction = GetFunctionList(theEnv); theFunction != NULL; theFunction = theFunction->next) { OutputProfileInfo(theEnv,ValueToString(theFunction->callFunctionName), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID, theFunction->usrData), NULL,NULL,NULL,NULL); } for (i = 0; i < MAXIMUM_PRIMITIVES; i++) { if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL) { OutputProfileInfo(theEnv,EvaluationData(theEnv)->PrimitivesArray[i]->name, (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID, EvaluationData(theEnv)->PrimitivesArray[i]->usrData), NULL,NULL,NULL,NULL); } } }
static void OutputConstructsCodeInfo( void *theEnv) { #if (! DEFFUNCTION_CONSTRUCT) && (! DEFGENERIC_CONSTRUCT) && (! OBJECT_SYSTEM) && (! DEFRULE_CONSTRUCT) #pragma unused(theEnv) #endif #if DEFFUNCTION_CONSTRUCT DEFFUNCTION *theDeffunction; #endif #if DEFRULE_CONSTRUCT struct defrule *theDefrule; #endif #if DEFGENERIC_CONSTRUCT DEFGENERIC *theDefgeneric; DEFMETHOD *theMethod; unsigned methodIndex; char methodBuffer[512]; #endif #if OBJECT_SYSTEM DEFCLASS *theDefclass; HANDLER *theHandler; unsigned handlerIndex; #endif #if DEFGENERIC_CONSTRUCT || OBJECT_SYSTEM char *prefix, *prefixBefore, *prefixAfter; #endif char *banner; banner = "\n*** Deffunctions ***\n\n"; #if DEFFUNCTION_CONSTRUCT for (theDeffunction = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,NULL); theDeffunction != NULL; theDeffunction = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,theDeffunction)) { OutputProfileInfo(theEnv,EnvGetDeffunctionName(theEnv,theDeffunction), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData), NULL,NULL,NULL,&banner); } #endif banner = "\n*** Defgenerics ***\n"; #if DEFGENERIC_CONSTRUCT for (theDefgeneric = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,NULL); theDefgeneric != NULL; theDefgeneric = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,theDefgeneric)) { prefixBefore = "\n"; prefix = EnvGetDefgenericName(theEnv,theDefgeneric); prefixAfter = "\n"; for (methodIndex = EnvGetNextDefmethod(theEnv,theDefgeneric,0); methodIndex != 0; methodIndex = EnvGetNextDefmethod(theEnv,theDefgeneric,methodIndex)) { theMethod = GetDefmethodPointer(theDefgeneric,methodIndex); EnvGetDefmethodDescription(theEnv,methodBuffer,510,theDefgeneric,methodIndex); if (OutputProfileInfo(theEnv,methodBuffer, (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->usrData), prefixBefore,prefix,prefixAfter,&banner)) { prefixBefore = NULL; prefix = NULL; prefixAfter = NULL; } } } #endif banner = "\n*** Defclasses ***\n"; #if OBJECT_SYSTEM for (theDefclass = (DEFCLASS *) EnvGetNextDefclass(theEnv,NULL); theDefclass != NULL; theDefclass = (DEFCLASS *) EnvGetNextDefclass(theEnv,theDefclass)) { prefixAfter = "\n"; prefix = EnvGetDefclassName(theEnv,theDefclass); prefixBefore = "\n"; for (handlerIndex = EnvGetNextDefmessageHandler(theEnv,theDefclass,0); handlerIndex != 0; handlerIndex = EnvGetNextDefmessageHandler(theEnv,theDefclass,handlerIndex)) { theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex); if (OutputProfileInfo(theEnv,EnvGetDefmessageHandlerName(theEnv,theDefclass,handlerIndex), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID, theHandler->usrData), prefixBefore,prefix,prefixAfter,&banner)) { prefixBefore = NULL; prefix = NULL; prefixAfter = NULL; } } } #endif banner = "\n*** Defrules ***\n\n"; #if DEFRULE_CONSTRUCT for (theDefrule = (struct defrule *) EnvGetNextDefrule(theEnv,NULL); theDefrule != NULL; theDefrule = (struct defrule *) EnvGetNextDefrule(theEnv,theDefrule)) { OutputProfileInfo(theEnv,EnvGetDefruleName(theEnv,theDefrule), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData), NULL,NULL,NULL,&banner); } #endif }
globle void ProfileResetCommand( void *theEnv) { struct FunctionDefinition *theFunction; int i; #if DEFFUNCTION_CONSTRUCT DEFFUNCTION *theDeffunction; #endif #if DEFRULE_CONSTRUCT struct defrule *theDefrule; #endif #if DEFGENERIC_CONSTRUCT DEFGENERIC *theDefgeneric; unsigned int methodIndex; DEFMETHOD *theMethod; #endif #if OBJECT_SYSTEM DEFCLASS *theDefclass; HANDLER *theHandler; unsigned handlerIndex; #endif ProfileFunctionData(theEnv)->ProfileStartTime = 0.0; ProfileFunctionData(theEnv)->ProfileEndTime = 0.0; ProfileFunctionData(theEnv)->ProfileTotalTime = 0.0; ProfileFunctionData(theEnv)->LastProfileInfo = NO_PROFILE; for (theFunction = GetFunctionList(theEnv); theFunction != NULL; theFunction = theFunction->next) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theFunction->usrData)); } for (i = 0; i < MAXIMUM_PRIMITIVES; i++) { if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,EvaluationData(theEnv)->PrimitivesArray[i]->usrData)); } } #if DEFFUNCTION_CONSTRUCT for (theDeffunction = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,NULL); theDeffunction != NULL; theDeffunction = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,theDeffunction)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData)); } #endif #if DEFRULE_CONSTRUCT for (theDefrule = (struct defrule *) EnvGetNextDefrule(theEnv,NULL); theDefrule != NULL; theDefrule = (struct defrule *) EnvGetNextDefrule(theEnv,theDefrule)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData)); } #endif #if DEFGENERIC_CONSTRUCT for (theDefgeneric = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,NULL); theDefgeneric != NULL; theDefgeneric = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,theDefgeneric)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefgeneric->header.usrData)); for (methodIndex = EnvGetNextDefmethod(theEnv,theDefgeneric,0); methodIndex != 0; methodIndex = EnvGetNextDefmethod(theEnv,theDefgeneric,methodIndex)) { theMethod = GetDefmethodPointer(theDefgeneric,methodIndex); ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->usrData)); } } #endif #if OBJECT_SYSTEM for (theDefclass = (DEFCLASS *) EnvGetNextDefclass(theEnv,NULL); theDefclass != NULL; theDefclass = (DEFCLASS *) EnvGetNextDefclass(theEnv,theDefclass)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefclass->header.usrData)); for (handlerIndex = EnvGetNextDefmessageHandler(theEnv,theDefclass,0); handlerIndex != 0; handlerIndex = EnvGetNextDefmessageHandler(theEnv,theDefclass,handlerIndex)) { theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex); ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theHandler->usrData)); } } #endif }
GLDEF_C TInt E32Main() { test.Title(); if (!HaveMMU()) { test.Printf(_L("This test requires an MMU\n")); return KErrNone; } test.Start(_L("Load test LDD")); TInt r=User::LoadLogicalDevice(KLddFileName); test(r==KErrNone || r==KErrAlreadyExists); test_KErrNone(UserHal::PageSizeInBytes(PageSize)); // Determine which types of paging are supported TUint32 attrs = DPTest::Attributes(); gRomPagingSupported = (attrs & DPTest::ERomPaging) != 0; gCodePagingSupported = (attrs & DPTest::ECodePaging) != 0; gDataPagingSupported = (attrs & DPTest::EDataPaging) != 0; // Does this memory model support pinning. TInt mm = UserSvr::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, 0, 0) & EMemModelTypeMask; gPinningSupported = mm >= EMemModelTypeFlexible; RPageMove pagemove; test.Next(_L("Open test LDD")); test_KErrNone(pagemove.Open()); // Determine whether this is a smp device. NumberOfCpus = pagemove.NumberOfCpus(); if (NumberOfCpus > 1) Repitions = 1000; // SMP system therefore likely to get KErrInUse in less repitions. test.Next(_L("Attempting to move regular local data pages")); { const TInt size=16384; TUint8* array = new TUint8[size]; test_NotNull(array); TestUserData(pagemove, array, size); _T_PRINTF(_L("Walk heap\n")); User::Check(); delete [] array; } test.Next(_L("Attempting to move regular global coarse data pages")); { const TInt size=1<<20; // Make this chunk multiple of 1MB so it is a coarse memory object on FMM RChunk chunk; test_KErrNone(chunk.CreateDisconnectedGlobal(_L("Dave"), 0, size, size)); TUint8* array = chunk.Base(); TestUserData(pagemove, array, size); TestMovingRealtime(pagemove, array, size, NULL, EFalse); TestCommitDecommit(pagemove, chunk); chunk.Close(); } if (gDataPagingSupported) { test.Next(_L("Attempting to move demand paged fine local user data pages")); const TInt size=16384; TChunkCreateInfo createInfo; createInfo.SetDisconnected(0, size, size); createInfo.SetPaging(TChunkCreateInfo::EPaged); RChunk chunk; test_KErrNone(chunk.Create(createInfo)); TUint8* array = chunk.Base(); TestUserData(pagemove, array, size, ETrue); TestMovingRealtime(pagemove, array, size, NULL, EFalse, ETrue); TestPageTableDiscard(pagemove, array, size); TestCommitDecommit(pagemove, chunk); chunk.Close(); test.Next(_L("Attempting to move demand paged coarse global user data pages")); const TInt sizeCoarse = 1 << 20; // Make this chunk multiple of 1MB so it is a coarse memory object on FMM TChunkCreateInfo createInfoCoarse; createInfoCoarse.SetDisconnected(0, sizeCoarse, sizeCoarse); createInfoCoarse.SetGlobal(_L("Dave")); createInfoCoarse.SetPaging(TChunkCreateInfo::EPaged); RChunk chunkCoarse; test_KErrNone(chunkCoarse.Create(createInfoCoarse)); array = chunkCoarse.Base(); TestUserData(pagemove, array, sizeCoarse, ETrue); TestMovingRealtime(pagemove, array, sizeCoarse, NULL, EFalse, ETrue); TestPageTableDiscard(pagemove, array, sizeCoarse); TestCommitDecommit(pagemove, chunkCoarse); chunkCoarse.Close(); } test.Next(_L("Attempting to move DLL writable static data pages")); { const TInt size=16384; TUint8* array = DllWsd::Address(); TestUserData(pagemove, array, size); } test.Next(_L("Attempting to move user self-mod code chunk page when IMB'ing and executing")); RChunk codeChunk; test_KErrNone(codeChunk.CreateLocalCode(PageSize,PageSize)); TestMovingCodeChunk(pagemove, codeChunk, EFalse); codeChunk.Close(); if (gDataPagingSupported) { test.Next(_L("Attempting to move paged user self-mod code chunk page when IMB'ing and executing")); TChunkCreateInfo createInfo; createInfo.SetCode(PageSize, PageSize); createInfo.SetPaging(TChunkCreateInfo::EPaged); RChunk pagedCodeChunk; test_KErrNone(pagedCodeChunk.Create(createInfo)); TestMovingCodeChunk(pagemove, pagedCodeChunk, ETrue); pagedCodeChunk.Close(); } test.Next(_L("Attempting to move RAM drive")); if ((MemModelAttributes()&EMemModelTypeMask) == EMemModelTypeMultiple) { for (TInt i=0; i<Repitions; i++) test_KErrNone(pagemove.TryMovingUserPage((TAny*)0xA0000000)); } else if ((MemModelAttributes()&EMemModelTypeMask) == EMemModelTypeMoving) { for (TInt i=0; i<Repitions; i++) test_KErrNone(pagemove.TryMovingUserPage((TAny*)0x40000000)); } else if ((MemModelAttributes()&EMemModelTypeMask) == EMemModelTypeFlexible) { // do nothing, RAM drive is not special } else { test.Printf(_L("Don't know where the RAM drive is!")); test(0); } #if 0 test.Next(_L("Attempting to move kernel heap pages")); for (TInt i=0; i<Repitions; i++) test_KErrNone(pagemove.TryMovingKHeap()); #endif if ((MemModelAttributes()&EMemModelTypeMask) != EMemModelTypeFlexible) {// Only the moving and multiple memory models move kernel stack pages. test.Next(_L("Attempting to move kernel stack pages")); for (TInt i=0; i<Repitions; i++) test_KErrNone(pagemove.TryMovingKStack()); } test.Next(_L("Attempting to move ROM pages")); TestMovingRom(pagemove); test.Next(_L("Attempting to move kernel code pages")); for (TInt i=0; i<Repitions; i++) test_KErrNone(pagemove.TryMovingKCode()); test.Next(_L("Attempting to move regular code pages")); TestMovingCode(pagemove, RamLoadedFunction); TestMovingRealtime(pagemove, NULL, 0, RamLoadedFunction, ETrue, EFalse); if (gCodePagingSupported) { test.Next(_L("Attempting to move demand paged code pages")); TestMovingCode(pagemove, DllTestFunction, ETrue); TestMovingRealtime(pagemove, NULL, 0, DllTestFunction, ETrue, ETrue); } /* Setup CodeModifier Test Driver */ StartCodeModifierDriver(); test(KErrNone==Device.InitialiseCodeModifier(/* Max break points */ 5 )); test.Next(_L("Attempting to move code page being modified\n")); test_KErrNone(TestCodeModification(pagemove)); test.Next(_L("Attempting to move code (async) while page being modified")); test_KErrNone(TestCodeModificationAsync(pagemove)); StopCodeModifierDriver(); test.Next(_L("Attempting to move ROM Locale DLL Page")); test_KErrNone(E32TestLocale(1)); test.Next(_L("Attempting to move RAM Locale DLL Page")); test_KErrNone(E32TestLocale(0)); test.Next(_L("Close test LDD")); pagemove.Close(); User::FreeLogicalDevice(KLddFileName); test.End(); return(KErrNone); }
static void OutputConstructsCodeInfo( Environment *theEnv) { #if (! DEFFUNCTION_CONSTRUCT) && (! DEFGENERIC_CONSTRUCT) && (! OBJECT_SYSTEM) && (! DEFRULE_CONSTRUCT) #pragma unused(theEnv) #endif #if DEFFUNCTION_CONSTRUCT Deffunction *theDeffunction; #endif #if DEFRULE_CONSTRUCT Defrule *theDefrule; #endif #if DEFGENERIC_CONSTRUCT Defgeneric *theDefgeneric; Defmethod *theMethod; unsigned short methodIndex; StringBuilder *theSB; #endif #if OBJECT_SYSTEM Defclass *theDefclass; DefmessageHandler *theHandler; unsigned handlerIndex; #endif #if DEFGENERIC_CONSTRUCT || OBJECT_SYSTEM const char *prefix, *prefixBefore, *prefixAfter; #endif const char *banner; banner = "\n*** Deffunctions ***\n\n"; #if DEFFUNCTION_CONSTRUCT for (theDeffunction = GetNextDeffunction(theEnv,NULL); theDeffunction != NULL; theDeffunction = GetNextDeffunction(theEnv,theDeffunction)) { OutputProfileInfo(theEnv,DeffunctionName(theDeffunction), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData), NULL,NULL,NULL,&banner); } #endif banner = "\n*** Defgenerics ***\n"; #if DEFGENERIC_CONSTRUCT theSB = CreateStringBuilder(theEnv,512); for (theDefgeneric = GetNextDefgeneric(theEnv,NULL); theDefgeneric != NULL; theDefgeneric = GetNextDefgeneric(theEnv,theDefgeneric)) { prefixBefore = "\n"; prefix = DefgenericName(theDefgeneric); prefixAfter = "\n"; for (methodIndex = GetNextDefmethod(theDefgeneric,0); methodIndex != 0; methodIndex = GetNextDefmethod(theDefgeneric,methodIndex)) { theMethod = GetDefmethodPointer(theDefgeneric,methodIndex); DefmethodDescription(theDefgeneric,methodIndex,theSB); if (OutputProfileInfo(theEnv,theSB->contents, (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->header.usrData), prefixBefore,prefix,prefixAfter,&banner)) { prefixBefore = NULL; prefix = NULL; prefixAfter = NULL; } } } SBDispose(theSB); #endif banner = "\n*** Defclasses ***\n"; #if OBJECT_SYSTEM for (theDefclass = GetNextDefclass(theEnv,NULL); theDefclass != NULL; theDefclass = GetNextDefclass(theEnv,theDefclass)) { prefixAfter = "\n"; prefix = DefclassName(theDefclass); prefixBefore = "\n"; for (handlerIndex = GetNextDefmessageHandler(theDefclass,0); handlerIndex != 0; handlerIndex = GetNextDefmessageHandler(theDefclass,handlerIndex)) { theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex); if (OutputProfileInfo(theEnv,DefmessageHandlerName(theDefclass,handlerIndex), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID, theHandler->header.usrData), prefixBefore,prefix,prefixAfter,&banner)) { prefixBefore = NULL; prefix = NULL; prefixAfter = NULL; } } } #endif banner = "\n*** Defrules ***\n\n"; #if DEFRULE_CONSTRUCT for (theDefrule = GetNextDefrule(theEnv,NULL); theDefrule != NULL; theDefrule = GetNextDefrule(theEnv,theDefrule)) { OutputProfileInfo(theEnv,DefruleName(theDefrule), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData), NULL,NULL,NULL,&banner); } #endif }
void ProfileResetCommand( Environment *theEnv, UDFContext *context, UDFValue *returnValue) { struct functionDefinition *theFunction; int i; #if DEFFUNCTION_CONSTRUCT Deffunction *theDeffunction; #endif #if DEFRULE_CONSTRUCT Defrule *theDefrule; #endif #if DEFGENERIC_CONSTRUCT Defgeneric *theDefgeneric; unsigned short methodIndex; Defmethod *theMethod; #endif #if OBJECT_SYSTEM Defclass *theDefclass; DefmessageHandler *theHandler; unsigned handlerIndex; #endif ProfileFunctionData(theEnv)->ProfileStartTime = 0.0; ProfileFunctionData(theEnv)->ProfileEndTime = 0.0; ProfileFunctionData(theEnv)->ProfileTotalTime = 0.0; ProfileFunctionData(theEnv)->LastProfileInfo = NO_PROFILE; for (theFunction = GetFunctionList(theEnv); theFunction != NULL; theFunction = theFunction->next) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theFunction->usrData)); } for (i = 0; i < MAXIMUM_PRIMITIVES; i++) { if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,EvaluationData(theEnv)->PrimitivesArray[i]->usrData)); } } #if DEFFUNCTION_CONSTRUCT for (theDeffunction = GetNextDeffunction(theEnv,NULL); theDeffunction != NULL; theDeffunction = GetNextDeffunction(theEnv,theDeffunction)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData)); } #endif #if DEFRULE_CONSTRUCT for (theDefrule = GetNextDefrule(theEnv,NULL); theDefrule != NULL; theDefrule = GetNextDefrule(theEnv,theDefrule)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData)); } #endif #if DEFGENERIC_CONSTRUCT for (theDefgeneric = GetNextDefgeneric(theEnv,NULL); theDefgeneric != NULL; theDefgeneric = GetNextDefgeneric(theEnv,theDefgeneric)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefgeneric->header.usrData)); for (methodIndex = GetNextDefmethod(theDefgeneric,0); methodIndex != 0; methodIndex = GetNextDefmethod(theDefgeneric,methodIndex)) { theMethod = GetDefmethodPointer(theDefgeneric,methodIndex); ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->header.usrData)); } } #endif #if OBJECT_SYSTEM for (theDefclass = GetNextDefclass(theEnv,NULL); theDefclass != NULL; theDefclass = GetNextDefclass(theEnv,theDefclass)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefclass->header.usrData)); for (handlerIndex = GetNextDefmessageHandler(theDefclass,0); handlerIndex != 0; handlerIndex = GetNextDefmessageHandler(theDefclass,handlerIndex)) { theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex); ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theHandler->header.usrData)); } } #endif }