diff -r ca8a1b6995f6 -r 52e343bb8f80 memspy/Console/Source/ConsoleMenu.cpp --- a/memspy/Console/Source/ConsoleMenu.cpp Tue Aug 31 16:45:49 2010 +0300 +++ b/memspy/Console/Source/ConsoleMenu.cpp Wed Sep 01 12:37:10 2010 +0100 @@ -39,17 +39,18 @@ #include "ConsoleDWOperation.h" -CMemSpyConsoleMenu::CMemSpyConsoleMenu( RMemSpySession& aSession, CConsoleBase& aConsole ) -: CActive( EPriorityHigh ), iSession( aSession ), iConsole( aConsole ), iOutputType(EOutputTypeDebug) +CMemSpyConsoleMenu::CMemSpyConsoleMenu( CMemSpyEngine& aEngine, CConsoleBase& aConsole ) +: CActive( EPriorityHigh ), iEngine( aEngine ), iConsole( aConsole ) { CActiveScheduler::Add( this ); - // TODO: iEngine.SetObserver( this ); + iEngine.SetObserver( this ); } CMemSpyConsoleMenu::~CMemSpyConsoleMenu() { Cancel(); + iEngine.SetObserver( NULL ); } @@ -60,9 +61,9 @@ } -CMemSpyConsoleMenu* CMemSpyConsoleMenu::NewLC( RMemSpySession& aSession, CConsoleBase& aConsole ) +CMemSpyConsoleMenu* CMemSpyConsoleMenu::NewLC( CMemSpyEngine& aEngine, CConsoleBase& aConsole ) { - CMemSpyConsoleMenu* self = new(ELeave) CMemSpyConsoleMenu( aSession, aConsole ); + CMemSpyConsoleMenu* self = new(ELeave) CMemSpyConsoleMenu( aEngine, aConsole ); CleanupStack::PushL( self ); self->ConstructL(); return self; @@ -75,7 +76,7 @@ // First line - sink type (defaults to file) _LIT( KLine1, "1 or T. Toggle output mode between file or trace [%S]" ); - if ( iOutputType == EOutputTypeDebug ) + if ( iEngine.SinkType() == ESinkTypeDebug ) { _LIT( KLine1Trace, "Trace" ); iConsole.Printf( KLine1, &KLine1Trace ); @@ -203,7 +204,14 @@ void CMemSpyConsoleMenu::OnCmdSinkTypeToggleL() { - iOutputType = iOutputType == EOutputTypeFile ? EOutputTypeDebug : EOutputTypeFile; + if ( iEngine.SinkType() == ESinkTypeDebug ) + { + iEngine.InstallSinkL( ESinkTypeFile ); + } + else + { + iEngine.InstallSinkL( ESinkTypeDebug ); + } } @@ -216,7 +224,7 @@ _LIT( KMsg, "Ouputting Kernel data..." ); RedrawStatusMessage( KMsg ); - iSession.OutputKernelHeapDataL( iOutputType ); + iEngine.HelperHeap().OutputHeapDataKernelL(); RedrawStatusMessage( KNullDesC ); } @@ -231,7 +239,14 @@ _LIT( KMsg, "Ouputting Kernel Object listing..." ); RedrawStatusMessage( KMsg ); // - iSession.OutputKernelObjectsL( iOutputType ); + CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers(); + CMemSpyEngineGenericKernelObjectContainer* model = kernelContainerManager.ObjectsAllL(); + CleanupStack::PushL( model ); + // + CMemSpyEngineOutputSink& sink = iEngine.Sink(); + model->OutputL( sink ); + // + CleanupStack::PopAndDestroy( model ); RedrawStatusMessage( KNullDesC ); } @@ -243,7 +258,7 @@ RDebug::Printf( "[MCon] CMemSpyConsoleMenu::OnCmdCSVListingStackL() - START" ); #endif - iSession.OutputCompactStackInfoL( iOutputType ); + iEngine.HelperStack().OutputStackInfoForDeviceL(); } @@ -253,7 +268,7 @@ RDebug::Printf( "[MCon] CMemSpyConsoleMenu::OnCmdCSVListingHeapL() - START" ); #endif - iSession.OutputCompactHeapInfoL( iOutputType ); + iEngine.HelperHeap().OutputHeapInfoForDeviceL(); } @@ -281,34 +296,44 @@ TPtr pCmdBuf( cmdBuf->Des() ); pCmdBuf.Copy( iCommandBuffer ); pCmdBuf.Append( KMemSpyConsoleWildcardCharacter ); - - TInt err; - TProcessId procId; - TRAP(err, procId = iSession.GetProcessIdByNameL(pCmdBuf)); + // + CMemSpyEngineObjectContainer& container = iEngine.Container(); + const TInt count = container.Count(); + TFullName fullThreadName; // - if (err == KErrNone) - { - RArray threads; - - TRAP(err, iSession.GetThreadsL(procId, threads)); - if (err == KErrNone) - { - _LIT( KProcessingRequest, "** Dumping Heap Data for thread: %S" ); - TFullName fullThreadName; - - for( TInt i=0; i= 0 ) + { + _LIT( KProcessingRequest, "** Dumping Heap Data for thread: %S" ); + const TInt threadCount = process.Count(); + for( TInt i=0; iName(); + fullThreadName = thread.FullName(); iConsole.Printf( KProcessingRequest, &fullThreadName ); iConsole.Write( KMemSpyConsoleNewLine ); // - TRAP_IGNORE( iSession.OutputThreadHeapDataL(iOutputType, thread->Id()) ); - - delete thread; + TRAP_IGNORE( iEngine.HelperHeap().OutputHeapDataUserL( thread ) ); } + + break; } + + ++index; } CleanupStack::PopAndDestroy( cmdBuf ); @@ -344,36 +369,38 @@ TPtr pCmdBuf( cmdBuf->Des() ); pCmdBuf.Copy( iCommandBuffer ); pCmdBuf.Append( KMemSpyConsoleWildcardCharacter ); - - TInt err; - TProcessId procId; - TRAP(err, procId = iSession.GetProcessIdByNameL(pCmdBuf)); - // - if (err == KErrNone) - { - RArray threads; - - TRAP(err, iSession.GetThreadsL(procId, threads)); - if (err == KErrNone) - { - _LIT( KProcessingRequest, "** Dumping Heap Cell List for thread: %S" ); - TFullName fullThreadName; - - for( TInt i=0; iName(); - iConsole.Printf( KProcessingRequest, &fullThreadName ); - iConsole.Write( KMemSpyConsoleNewLine ); - // - TRAP_IGNORE( iSession.OutputThreadCellListL(iOutputType, thread->Id()) ); - - delete thread; - } - } - } - + // + CMemSpyEngineObjectContainer& container = iEngine.Container(); + const TInt count = container.Count(); + TFullName fullThreadName; + // + TInt index = 0; + while( index < count ) + { + CMemSpyProcess& process = container.At( index ); + const TPtrC processName( process.Name() ); + // + if ( processName.MatchF( pCmdBuf ) >= 0 ) + { + _LIT( KProcessingRequest, "** Dumping Heap Cell List for thread: %S" ); + const TInt threadCount = process.Count(); + for( TInt i=0; i