diff -r 96d581d2147d -r 184a1eb85cf2 core/builtins/ps.cpp --- a/core/builtins/ps.cpp Fri Jul 09 10:11:55 2010 +0100 +++ b/core/builtins/ps.cpp Mon Jul 26 17:19:00 2010 +0100 @@ -169,6 +169,11 @@ _LIT(KOptAddresses, "addresses"); aOptions.AppendBoolL(iAddresses, KOptAddresses); + +#ifdef FSHELL_MEMORY_ACCESS_SUPPORT + _LIT(KOptCodeSegs, "codesegs"); + aOptions.AppendBoolL(iPrintCodesegs, KOptCodeSegs); +#endif } #if defined(__WINS__) && !defined(EKA2) @@ -317,6 +322,10 @@ iFormatter->AppendFormatL(_L("\tAddress: 0x%08x\r\n"), objectInfo.iAddressOfKernelObject); } } + if (iPrintCodesegs && iMemoryAccess.Handle()) + { + PrintCodeSegsL(aProcess); + } #endif // FSHELL_MEMORY_ACCESS_SUPPORT if (iHandleCount) @@ -542,6 +551,30 @@ } } +void ReleaseCodesegMutex(TAny* aMemAccess) + { + static_cast(aMemAccess)->ReleaseCodeSegMutex(); + } + +void CCmdPs::PrintCodeSegsL(RProcess& aProcess) + { + TInt count = iMemoryAccess.AcquireCodeSegMutexAndFilterCodesegsForProcess(aProcess.Id()); + LeaveIfErr(count, _L("Couldn't acquire codeseg mutex")); + CleanupStack::PushL(TCleanupItem(&ReleaseCodesegMutex, &iMemoryAccess)); + + iFormatter->AppendFormatL(_L("\t%d code segments:\r\n"), count); + + TCodeSegKernelInfo codeSegInfo; + TPckg pkg(codeSegInfo); + while (iMemoryAccess.GetNextCodeSegInfo(pkg) == KErrNone) + { + // Reuse iChunkName, I'm sure it doesn't mind + iChunkName.Copy(codeSegInfo.iFileName); + iFormatter->AppendFormatL(_L("\t\t%S\r\n"), &iChunkName); + } + CleanupStack::PopAndDestroy(); // ReleaseCodesegMutex + } + #ifdef EXE_BUILD EXE_BOILER_PLATE(CCmdPs) #endif