memspy/Engine/Source/MemSpyEngineImp.cpp
branchRCL_3
changeset 21 52e343bb8f80
parent 20 ca8a1b6995f6
--- a/memspy/Engine/Source/MemSpyEngineImp.cpp	Tue Aug 31 16:45:49 2010 +0300
+++ b/memspy/Engine/Source/MemSpyEngineImp.cpp	Wed Sep 01 12:37:10 2010 +0100
@@ -52,11 +52,6 @@
 #include <memspy/engine/memspyenginehelperwindowserver.h>
 #include <memspy/engine/memspyenginehelpercondvar.h>
 
-#ifdef _DEBUG
-#define LOG(args...) RDebug::Printf(args)
-#else
-#define LOG(args...)
-#endif
 
 CMemSpyEngineImp::CMemSpyEngineImp( RFs& aFsSession, CMemSpyEngine& aEngine )
 :   iFsSession( aFsSession ), iEngine( aEngine )
@@ -66,14 +61,18 @@
 
 CMemSpyEngineImp::~CMemSpyEngineImp()
     {
-    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - START" );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - START" );
+#endif
 
     if  ( iMidwife )
         {
         iMidwife->RemoveObserver( *this );
         }
 
-    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - deleting helpers..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - deleting helpers..." );
+#endif
     delete iHelperSysMemTracker;
     delete iServer;
     delete iHelperKernelContainers;
@@ -95,37 +94,52 @@
     
     iHelperWindowServerLoader.Close();
 
-    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - deleting utilities..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - deleting utilities..." );
+#endif
     delete iChunkWatcher;
     delete iUndertaker;
     delete iMidwife;
 
-    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying containers..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying containers..." );
+#endif
     iContainers.ResetAndDestroy();
     iContainers.Close();
 
-    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying driver..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying driver..." );
+#endif
     if  ( iMemSpyDriver )
         {
         iMemSpyDriver->Close();
         delete iMemSpyDriver;
         }
 
-    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying sink..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying sink..." );
+#endif
     delete iSink;
 
-    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - END" );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - END" );
+#endif
     }
 
 
 void CMemSpyEngineImp::ConstructL()
     {
-    LOG( "CMemSpyEngineImp::ConstructL() - START" );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructL() - START" );
+#endif
     //
     iFsSession.SetSessionPath( _L("\\") );
     
+    // Starting the server before the driver connection is made
+    // ensures that only one instance of MemSpy can run (either the S60
+    // UI or the console UI ).
     iServer = CMemSpyEngineServer::NewL( iEngine );
-    
+    //
     iMemSpyDriver = new(ELeave) RMemSpyDriverClient();
     const TInt error = Driver().Open();
     User::LeaveIfError( error );
@@ -149,60 +163,96 @@
     iHelperSysMemTracker = CMemSpyEngineHelperSysMemTracker::NewL( iEngine );
     iMidwife->AddObserverL( *this );
 
-    LOG( "CMemSpyEngineImp::ConstructL() - END" );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructL() - END" );
+#endif
     }
 
 
 void CMemSpyEngineImp::ConstructHelpersL()
     {
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - START" );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - START" );
+#endif
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Heap..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Heap..." );
+#endif
     iHelperHeap = CMemSpyEngineHelperHeap::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Stack..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Stack..." );
+#endif
     iHelperStack = CMemSpyEngineHelperStack::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Code Segments..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Code Segments..." );
+#endif
     iHelperCodeSegment = CMemSpyEngineHelperCodeSegment::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Chunk..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Chunk..." );
+#endif
     iHelperChunk = CMemSpyEngineHelperChunk::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Thread..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Thread..." );
+#endif
     iHelperThread = CMemSpyEngineHelperThread::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Process..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Process..." );
+#endif
     iHelperProcess = CMemSpyEngineHelperProcess::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Server..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Server..." );
+#endif
     iHelperServer = CMemSpyEngineHelperServer::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - AO..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - AO..." );
+#endif
     iHelperActiveObject = CMemSpyEngineHelperActiveObject::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Kernel Containers..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Kernel Containers..." );
+#endif
     iHelperKernelContainers = CMemSpyEngineHelperKernelContainers::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - File System..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - File System..." );
+#endif
     iHelperFileSystem = CMemSpyEngineHelperFileSystem::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - ECOM..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - ECOM..." );
+#endif
     iHelperECom = CMemSpyEngineHelperECom::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - FBSERV..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - FBSERV..." );
+#endif
     iHelperFbServ = CMemSpyEngineHelperFbServ::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - ROM..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - ROM..." );
+#endif
     iHelperROM = CMemSpyEngineHelperROM::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - RAM..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - RAM..." );
+#endif
     iHelperRAM = CMemSpyEngineHelperRAM::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - WindowServer..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - WindowServer..." );
+#endif
     
     TInt err = iHelperWindowServerLoader.Load( _L("memspywindowserverhelper.dll") );
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - WindowServer load err: %d", err );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - WindowServer load err: %d", err );
+#endif
     if ( !err )
         {
 #ifdef __WINS__ // ordinal is different 
@@ -212,19 +262,18 @@
 #endif
         if ( entry != NULL )
             {
-			typedef MMemSpyEngineHelperWindowServer* (*TEntryFn)(void);
-			TRAP(err, iHelperWindowServer = ((TEntryFn)entry)());
-			if (err)
-				{
-				LOG("err from memspywindowserverhelper.dll - %d", err);
-				}
+            iHelperWindowServer = (MMemSpyEngineHelperWindowServer*) entry();
             }
         }
     
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - CondVar..." );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - CondVar..." );
+#endif
     iHelperCondVar = CMemSpyEngineHelperCondVar::NewL( iEngine );
 
-    LOG( "CMemSpyEngineImp::ConstructHelpersL() - END" );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - END" );
+#endif
     }
 
 
@@ -285,14 +334,12 @@
     return iSink->Type();
     }
 
+
 void CMemSpyEngineImp::InstallSinkL( TMemSpySinkType aType )
-	{
-	InstallSinkL( aType, KNullDesC );
-	}
-
-void CMemSpyEngineImp::InstallSinkL( TMemSpySinkType aType, const TDesC& aRootFolder )
     {
-    LOG( "CMemSpyEngineImp::InstallSinkL() - START - switching sink from %d to %d...", (iSink != NULL ? iSink->Type() : -1), aType );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::InstallSinkL() - START - switching sink from %d to %d...", (iSink != NULL ? iSink->Type() : -1), aType );
+#endif
     //
     CMemSpyEngineOutputSink* sink = NULL;
     //
@@ -302,14 +349,16 @@
         sink = CMemSpyEngineOutputSinkDebug::NewL( iEngine );
         break;
     case ESinkTypeFile:
-        sink = CMemSpyEngineOutputSinkFile::NewL( iEngine, aRootFolder );
+        sink = CMemSpyEngineOutputSinkFile::NewL( iEngine );
         break;
         }
     //
     delete iSink;
     iSink = sink;
     //
-    LOG( "CMemSpyEngineImp::InstallSinkL() - END - sink type: %d", iSink->Type() );
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyEngineImp::InstallSinkL() - END - sink type: %d", iSink->Type() );
+#endif
     }