dbgsrv/coredumpserver/server/inc/coredumpsession.h
changeset 0 c6b0df440bee
equal deleted inserted replaced
-1:000000000000 0:c6b0df440bee
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology
       
    21  @released
       
    22 */
       
    23 
       
    24 #ifndef CORE_DUMP_SESSION_H
       
    25 #define CORE_DUMP_SESSION_H
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <e32base.h>
       
    29 #include <s32file.h>
       
    30 #include <e32property.h>
       
    31 #include <bsul\inifile.h>
       
    32 #include <scmdatatypes.h>
       
    33 
       
    34 #include <rm_debug_api.h>
       
    35 
       
    36 // Project inclues
       
    37 #include <crashdata.h>
       
    38 #include "coredumpserver.h"
       
    39 #include <coredumpserverapi.h>
       
    40 #include <optionconfig.h>
       
    41 #include <crashdatasave.h>
       
    42 #include "servercrashdatasource.h"
       
    43 #include "flashdatasource.h"
       
    44 #include "coretargetobserver.h"
       
    45 
       
    46 using namespace Debug;
       
    47 using namespace BSUL;
       
    48 
       
    49         enum TPreProcessingActionType {ENoPreAction = 0, ESuspendThread = 0x1, ESuspendProcess = 0x2};
       
    50         enum TPostProcessingActionType {ENoPostAction = 0, EResumeThread = 0x1, EResumeProcess = 0x2, EKillProcess = 0x4, EDeleteCrashLog = 0x5};
       
    51 
       
    52 /**
       
    53 Core dump server session that handles messages from core dump clients.
       
    54 @see CCoreDumpServer
       
    55 @see RCoreDumpSession
       
    56 */
       
    57 class CCoreDumpSession : public CSession2
       
    58 	{	
       
    59 	public:		// Construction
       
    60 		IMPORT_C static CCoreDumpSession* NewL( RSecuritySvrSession &aSecSess );
       
    61 
       
    62 	public:		// Destruction
       
    63 		IMPORT_C ~CCoreDumpSession();
       
    64 		
       
    65 	public:		// CCoreDumpSession
       
    66 		IMPORT_C virtual void ServiceL (const RMessage2& aMessage);
       
    67 
       
    68 	private:
       
    69 		CCoreDumpSession( RSecuritySvrSession &aSecSess );
       
    70 
       
    71     protected:
       
    72 		void ConstructL();
       
    73 		
       
    74 	private:	// CCoreDumpSession
       
    75 		void PanicClient(const RMessage2& aMessage, TInt aPanic);
       
    76 		void DispatchMessageL(const RMessage2& aMessage);
       
    77 
       
    78 		HBufC8 * MarshalListL( TListRequest & req, TAny * list );
       
    79 		void GetListL( const RMessage2& aMessage );
       
    80 		void ListInfoL( const RMessage2& aMessage );
       
    81 
       
    82         //make sure that those calls leave
       
    83 		void GetPluginListL(const RMessage2& aMessage);
       
    84 		void PluginRequestL(const RMessage2& aMessage);
       
    85 
       
    86 	//	TInt StartDebugSessionL(const RMessage2& aMessage);
       
    87 
       
    88 		void RefreshPluginListL();
       
    89 
       
    90         void ObservationRequestL( const RMessage2 &aMessage );
       
    91         void AttachTargetL( const TDesC &aTargetName, const TDesC &aTargetOwnerName );
       
    92         void DetachTargetL( const TDesC &aTargetName, const TDesC &aTargetOwnerName );
       
    93 
       
    94 		TInt GetByPId( const TUint aPid );
       
    95 
       
    96 		void CreateFormatterL( const TUid loadRequestUid );
       
    97 		void CreateWriterL( const TUid loadRequestUid );
       
    98         void DeleteFormatterL( const TUid freeRequestUid, const TUint index );
       
    99         void DeleteWriterL( const TUid freeRequestUid, const TUint index );
       
   100 
       
   101         void BindPluginsL(const TUint aIndex, TUint aPair);
       
   102 		void SetPluginsL( const TUid aFormatterUID, 
       
   103 							const TUid aWriterUID, 
       
   104 							const TBool aLoad );
       
   105 
       
   106 		void GetNumberConfigParametersL( const RMessage2& aMessage );
       
   107 		void GetConfigParameterL( const RMessage2& aMessage );
       
   108 		void SetConfigParameterL( const RMessage2& aMessage );
       
   109 		void SetConfigParameterL( const TInt aIndex, 
       
   110 								 const TInt32 & aValue, 
       
   111 								 const TDesC & aDescValue );
       
   112 
       
   113 		void UpdateConfigParametersL( );
       
   114 
       
   115 
       
   116 		void LoadConfigFileL( const RMessage2* aMessage = NULL );
       
   117 		void SaveConfigFileL( const RMessage2* aMessage = NULL );
       
   118 
       
   119 		
       
   120 		enum TCoreDumpIniKey
       
   121 			{
       
   122 			EIniKeyType,
       
   123 			EIniKeyIndex,
       
   124 			EIniKeyValue
       
   125 			};
       
   126 
       
   127 		HBufC * GenerateKeyStringLC( TUint aIndex, 
       
   128 									 TCoreDumpIniKey aKey );
       
   129 
       
   130 		void RecreateConfigurationL( BSUL::CIniDocument16 * aPersistConfigData );
       
   131 
       
   132 		void ChangeConfigParamsL( const COptionConfig::TParameterSource aSource,
       
   133 								  BSUL::CIniDocument16	*	aPersistConfigData,
       
   134                                   const TInt aIndex = -1);
       
   135 
       
   136 		void SaveConfigParamL(  const COptionConfig	 *	aParam, 
       
   137 								const TPtrC			 &	aSectName,
       
   138 								const TInt				aSaveIndex,
       
   139 								BSUL::CIniDocument16 *	aPersistConfigData );
       
   140 
       
   141 		void OpenIniFileLC( const RMessage2		  *	aMessage, 
       
   142 							const TBool				aSaving,
       
   143 							RFs					  & aFsSession,
       
   144 							HBufC				 *&	aFileName,
       
   145 							BSUL::CIniDocument16 *&	aPersistConfigData );
       
   146 
       
   147 		void OpenIniFileLC( const TBool				aSaving,
       
   148 							RFs					  & aFsSession,
       
   149 							HBufC				 *&	aFileName,
       
   150 							BSUL::CIniDocument16 *&	aPersistConfigData );
       
   151 
       
   152 		void ReadPluginUidFilesL( );
       
   153 		
       
   154 //		void ReadSCMConfigListL();
       
   155 //		void WriteSCMConfigListL();
       
   156 		//void UpdateSCMConfigParameterL( TConfigItem::TSCMDataType aDataType, const TInt32 & aPriority );
       
   157 		
       
   158 		void ValidatePluginL( const TUid aPluginUid ) const;
       
   159         void SetCrashEventsL(CTargetObserver &aObserver, TKernelEventAction aAction);
       
   160         
       
   161         void RefreshCrashListFromFlashL();
       
   162         void GetCrashInfoL(TInt aCrashId, TCrashInfo& aCrashInfo);
       
   163         void DeleteCrashLogL(const RMessage2& aMessage);
       
   164         void DeleteCrashPartitionL();
       
   165         void ProcessCrashLogL(const RMessage2& aMessage);
       
   166         void ProcessCrashLogAsyncL(const RMessage2& aMessage);
       
   167         void CancelProcessCrashLogAsync(const RMessage2& aMessage);
       
   168         void UpdateProgressL(const TDesC &aProgress) const;
       
   169 
       
   170     public:
       
   171         CCrashDataSource* DataSource() const {return iDataSource;};
       
   172         CFlashDataSource* FlashDataSource() const {return iFlashDataSource;};
       
   173         CCoreDumpFormatter* GetValidFormatter(const TUint aCount);
       
   174         TInt32 PreProcessingAction() const;
       
   175         TInt32 PostProcessingAction() const;
       
   176         void SuspendProcessL(TUint64 aPid);
       
   177         void KillProcessL(TUint64 aPid);
       
   178         void ResumeProcessL(TUint64 aPid);
       
   179         void ResumeThreadL(TUint64 aTid);
       
   180         CCoreDumpServer& Server() const;
       
   181         virtual void CreateL();
       
   182 
       
   183 	private:	// Data members
       
   184         RSecuritySvrSession &iSecSess;
       
   185 		
       
   186 		TUint					iKeyEvent;
       
   187 		
       
   188         /** keeps list of ECOM plugin types */
       
   189 		RPluginList				iPluginList;
       
   190 
       
   191 		TUint					iTotalThreadListDescSize;
       
   192 		RThreadPointerList      iThreadPointerList; 
       
   193 		HBufC8*					iMarshalledThreadList;
       
   194         
       
   195 		TUint					iTotalProcessListDescSize;
       
   196 		RProcessPointerList		iProcessPointerList;
       
   197 		HBufC8*					iMarshalledProcessList;
       
   198 
       
   199 		TUint					iTotalExecutableListDescSize;
       
   200 		RExecutablePointerList	iExecutablePointerList;
       
   201 		HBufC8*					iMarshalledExecutableList;
       
   202 		
       
   203 		//this stores the crashes that are in the flash partition
       
   204 		TUint					iTotalCrashInfoDescSize;
       
   205 		RCrashInfoPointerList	iCrashList;
       
   206 		HBufC8*					iMarshalledCrashList;
       
   207 		
       
   208         typedef RPointerArray<CCoreDumpFormatter> RFormatterPointerList;
       
   209         
       
   210         /** list of formatter plugin instances */
       
   211 		RFormatterPointerList	iFormatterPlugins;
       
   212 		
       
   213         /** list of formatter plugin info objects coresponding to actual instances*/
       
   214         RPluginPointerList      iFormatterInfos;
       
   215 		HBufC8*					iMarshalledFormatterList;
       
   216 		TUint					iTotalFormatterListDescSize;
       
   217 
       
   218         typedef RPointerArray<CCrashDataSave> RWriterPointerList;
       
   219         
       
   220         /** list of writer plugin instances */
       
   221 		RWriterPointerList		iWriterPlugins;
       
   222 		
       
   223         /** list of writer plugin info objects coresponding to actual instances*/
       
   224         RPluginPointerList      iWriterInfos;
       
   225 		HBufC8*					iMarshalledWriterList;
       
   226 		TUint					iTotalWriterListDescSize;
       
   227 
       
   228 		CServerCrashDataSource* iDataSource;
       
   229 		CFlashDataSource* iFlashDataSource;
       
   230         CCrashHandler*			iCrashHandler;
       
   231 
       
   232         enum TCrashEventTypes 
       
   233 			{
       
   234 			ECrashHwExc = 0x1, 
       
   235 			ECrashKillThread = 0x2, 
       
   236 			ECrashHwExcAndKillThread = 0x3
       
   237 			};
       
   238 
       
   239 		typedef RPointerArray<CTargetObserver>		RObservationList;
       
   240 		
       
   241 		RObservationList iObservationList;
       
   242 
       
   243     private:
       
   244         TInt32 iPreCrashEventAction;
       
   245         TInt32 iPostCrashEventAction;
       
   246         TInt32 iCrashEventTypes;
       
   247 
       
   248 
       
   249 		// Configuration parameters for current system. It is the collection
       
   250 		// of config params from CDS and currently loaded plugins
       
   251 		typedef RPointerArray<COptionConfig>	RConfigParameterList;
       
   252 		RConfigParameterList	  iTotalConfigList; //no need to destroy the content
       
   253 
       
   254 		/** The maximum size of the configuration parameter that was found 
       
   255 		when the entire list iTotalConfigList was last updated. It is useful
       
   256 		when allocating descriptor for client/server transfer */
       
   257 		TInt					iMaxConfigParamSize;
       
   258 
       
   259 		/** Configuration parameters for CDS. */
       
   260 		RConfigParameterList     iConfigList;
       
   261 		
       
   262 		/** configuration parameters for SCM configuration */
       
   263 		RConfigParameterList	 iScmConfigList;
       
   264 		
       
   265 		
       
   266 
       
   267 		TUid					iOurSecureID;
       
   268 		RArray<TUid>			iAllowedPlugins;
       
   269 
       
   270 		TUint32					iSpare0;
       
   271 		TUint32					iSpare1;
       
   272 		TUint32					iSpare2;
       
   273 		TUint32					iSpare3;
       
   274 		TUint32					iSpare4;
       
   275 		TUint32					iSpare5;
       
   276 		
       
   277     private:
       
   278     	void PrintScmConfigL();
       
   279     	
       
   280     	static void CleanupSCMConfiguration(TAny* );
       
   281 };
       
   282 
       
   283 #endif	// CORE_DUMP_SESSION_H
       
   284