Adding "Profiling Starter" app so we can see what's going on during boot system_startup
authorTom Pritchard <tomp@symbian.org>
Thu, 14 Oct 2010 12:39:29 +0100
branchsystem_startup
changeset 37 b8aae0a088d8
parent 36 ec9266033bd7
child 38 61ce54841faa
Adding "Profiling Starter" app so we can see what's going on during boot
hacks/profiling/bld.inf
hacks/profiling/readme.txt
hacks/profiling/startupprofiling.cpp
hacks/profiling/startupprofiling.mmp
hacks/readme.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hacks/profiling/bld.inf	Thu Oct 14 12:39:29 2010 +0100
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2010 Symbian Foundation Ltd
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Build information file for the stem kit.
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+startupprofiling.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hacks/profiling/readme.txt	Thu Oct 14 12:39:29 2010 +0100
@@ -0,0 +1,34 @@
+Profiling:
+
+This is a simple tool that will start the sampling profiler, wait a given period (default = 5mins) and then stop, and unload the profiler.
+Add it to your rom, and to somewhere (early!) in your startup sequence to find out what's happening during a boot sequence.
+
+Argument: -time=<n>
+<n> is the number of milliseconds to wait before stopping the profiler.
+
+
+You can put something like this in a startup command list:
+
+// ---------------------------------------------------------------------------
+
+// r_cmd_profiling
+
+// ---------------------------------------------------------------------------
+
+//
+
+RESOURCE SSM_START_PROCESS_INFO r_cmd_profiling
+
+    {
+
+    priority = 0xFE01;
+
+    execution_behaviour = ESsmFireAndForget;
+
+    name = "Z:\\sys\\bin\\startupprofiling.exe";
+
+    args = "-time=600000000";
+
+    severity = ECmdCriticalSeverity;
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hacks/profiling/startupprofiling.cpp	Thu Oct 14 12:39:29 2010 +0100
@@ -0,0 +1,164 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+//************************************************************************************************************
+//#include <bautils.h>
+#include <profiler.h>
+#include <e32debug.h>
+
+
+
+
+
+//------------------------------------------------------------------------------------------------------------
+void startProfilerServer()
+   {
+	RDebug::Print(_L("Startup Profiling - startProfilerServer()"));
+	_LIT(KParam,"");
+	RProcess p;
+	TInt err;   
+	
+	// Run the Sampling Profiler
+	err=p.Create(KProfilerName,KParam);
+	if (err == KErrNone)
+		{
+		p.Resume();
+		p.Close();
+		User::After(1000000);
+		}
+	else
+		{
+		RDebug::Print(_L("Startup Profiling - ERROR %d: Unable to execute Sampling Profiler\n"), err);
+		}
+	}
+
+
+	
+//************************************************************************************************************
+// PARSE PARAMETER
+//************************************************************************************************************
+TInt parseNumberL(TDes &aArgs, const TDesC &aParam)
+   {
+   TInt     pos, num, ret;
+	TBuf<100> argsTmp;
+   TLex     lexArgs;	   
+   
+   pos = aArgs.Find(aParam);
+   if (pos == KErrNotFound)
+      User::Leave(KErrArgument);
+
+   argsTmp.Insert(0,aArgs);
+   argsTmp.Delete(0,pos + aParam.Length());
+   lexArgs=argsTmp;
+   ret=lexArgs.Val(num);
+   
+   if (ret != KErrNone)
+      User::Leave(KErrArgument);
+   
+   return num;
+   }
+
+
+
+   
+//************************************************************************************************************
+//************************************************************************************************************
+//  MAIN
+//************************************************************************************************************
+//************************************************************************************************************
+void doMainL()
+	{
+	RDebug::Print(_L("Startup Profiling - doMainL"));
+
+	TBuf<100>       buf, args;
+	TInt            waittime(300000000), err;
+
+   _LIT(KParamTime,	"time=");
+		
+   // Get and prepare Command Line
+#ifndef __SECURE_API__
+   RProcess().CommandLine(args);
+#else
+   User::CommandLine(args);   
+#endif
+   args.LowerCase();
+   
+
+   // Parse param and decide what to do  
+   if (args.Find(KParamTime) != KErrNotFound) 
+		{
+		waittime  = parseNumberL(args, KParamTime);  
+		RDebug::Print(_L("Starting Profiler - Wait time requested: %d"), waittime);
+		}
+/*		
+	// ECOM should be already running on a real phone. Does not in testshell mode
+	REComSession ecom;
+	ecom.OpenL();
+	User::After(2000000);	      
+*/
+	// Start the profiler server
+	startProfilerServer();
+	
+	
+	err=Profiler::Start();
+	if (err != KErrNone)
+		{
+		RDebug::Print(_L("Startup Profiling - ERROR %d : Unable to start Sampling Profiler.\n"),err);
+		User::Leave(err);
+		}
+	else
+		{
+		RDebug::Print(_L("Startup Profiling - Profiler Started OK"));
+		}
+		
+	// Now go to sleep until the alloted time (ie until we think boot-up should be complete)	
+	User::After(waittime);
+	RDebug::Print(_L("Startup Profiling - Time's Up, going to stop profiling now"));
+	
+	// Stop, close and unload the profiler properly
+	err=Profiler::Stop();
+	User::After(300000);
+	err=err | Profiler::Close();
+	User::After(300000);
+	err=err | Profiler::Unload();
+	User::After(300000);         
+	if (err != KErrNone)
+		{
+		RDebug::Print(_L("Startup Profiling - ERROR %d : Unable to Stop/Close/Unload Sampling Profiler\n"),err);
+		User::Leave(err);            
+		}
+	}
+
+
+
+//************************************************************************************************************
+//************************************************************************************************************
+// Program Entry
+//************************************************************************************************************
+//************************************************************************************************************
+GLDEF_C TInt E32Main()
+	{	
+	__UHEAP_MARK;
+	CActiveScheduler* rootScheduler = new CActiveScheduler;
+	CActiveScheduler::Install(rootScheduler);
+	CTrapCleanup* theCleanup=CTrapCleanup::New();
+
+	TRAPD(ret,doMainL());	
+	
+	delete theCleanup;	
+	delete rootScheduler;
+	__UHEAP_MARKEND;
+	return(KErrNone);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hacks/profiling/startupprofiling.mmp	Thu Oct 14 12:39:29 2010 +0100
@@ -0,0 +1,30 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET			startupprofiling.exe
+TARGETTYPE		exe
+CAPABILITY     ReadUserData WriteUserData
+SOURCE			startupprofiling.cpp 
+
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+SYSTEMINCLUDE	/epoc32/include/platform
+
+
+LIBRARY 			euser.lib 
+//ecom.lib efile.lib efsrv.lib bafl.lib
+
+VENDORID 0x70000001
+
+SMPSAFE
--- a/hacks/readme.txt	Wed Oct 13 17:18:04 2010 +0100
+++ b/hacks/readme.txt	Thu Oct 14 12:39:29 2010 +0100
@@ -2,7 +2,7 @@
 
 1. syborg_keyboard.cpp
 
-Replace sf\adaptation\qemu\baseport\syborg\syborg_keymap.cpp with this file 
+Replace sf\adaptation\qemu\baseport\syborg\keyboard\syborg_keymap.cpp with this file 
 and rebuild the baseport, to turn F10 into the Key of Death.
 
 Pressing F10 will cause Kern::Fault("KeyOfDeath", 0x0f100f10), which will drop