dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/symbianelfformatter.h
changeset 0 c6b0df440bee
equal deleted inserted replaced
-1:000000000000 0:c6b0df440bee
       
     1 // Copyright (c) 2006-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 // Implements two examples of the ECOM Symbian Elf Core Dump API
       
    15 //
       
    16 
       
    17 /**
       
    18  @file
       
    19  @internalTechnology
       
    20  @released
       
    21 */
       
    22 
       
    23 #ifndef __SYMBIAN_ELF_FORMATTER_H__
       
    24 #define __SYMBIAN_ELF_FORMATTER_H__
       
    25 
       
    26 // Abstract ECOM API definition
       
    27 #include <formatterapi.h>
       
    28 #include <symbianelfdefs.h>
       
    29 #include <crashdatasource.h>
       
    30 
       
    31 #include "symbianelfoptions.h"
       
    32 #include <crashdatasave.h>
       
    33 #include "tsymbianelfformatter.h"
       
    34 #include "symbianelfstringinfo.h"
       
    35 
       
    36 const TUint32 KSymbianELFFormatterUid = { 0x10282fe3 };
       
    37 _LIT(KPluginDescription, "Symbian Elf Core Dump formatter");
       
    38 
       
    39 /**
       
    40 @internalTechnology
       
    41 @released
       
    42 Symbian ELF formatter plugin is loaded by the core dump server and notified about the crash event.
       
    43 Then it dupms crash data in the ELF file format.
       
    44 @see CCrashDataSave
       
    45 */
       
    46 class CSymbianElfFormatter : public CCoreDumpFormatter
       
    47 {
       
    48     friend void CSymbianElfFormatterTest::TestSuiteL(TSuite aSuite); //test harness
       
    49     enum { KElfDumpFileLength = 23 };
       
    50 public:
       
    51 	static CSymbianElfFormatter* NewL();
       
    52 	static CSymbianElfFormatter* NewLC();
       
    53 	virtual ~CSymbianElfFormatter();
       
    54 
       
    55 public:
       
    56 
       
    57 	virtual void ConfigureDataSaveL( CCrashDataSave * aDataSave );
       
    58 
       
    59 	virtual void ConfigureDataSourceL( CCrashDataSource * aDataSource );
       
    60 
       
    61 	virtual void GetDescription( TDes & aPluginDescription );
       
    62 
       
    63 	virtual void CrashEventL( TCrashInfo* aCrashInfo );
       
    64 
       
    65 	virtual TInt GetNumberConfigParametersL( );
       
    66 
       
    67 	virtual COptionConfig * GetConfigParameterL( const TInt aIndex );
       
    68 
       
    69 	virtual void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue );
       
    70 
       
    71 public:
       
    72 
       
    73 private:
       
    74 
       
    75     /** Helper structure for creating data segs for stacks and .rodata/.bss/.data sections */
       
    76 	struct TSegmentInfo
       
    77 	{
       
    78         /** base memory address of the segment */
       
    79 		TUint32 iSegBase;
       
    80         /** size of the segment data */
       
    81 		TUint32 iSegSize;
       
    82         /** access rights to the segment data */
       
    83 		TUint32 iFlags;
       
    84 
       
    85         /** reserved for future */
       
    86 		TUint32 iSpare1;
       
    87         /** reserved for future */
       
    88 		TUint32 iSpare2;
       
    89 	};
       
    90 
       
    91     /**
       
    92      @publishedPartner
       
    93      @released
       
    94      List of TSegmentInfo structures
       
    95     @see TSegmentInfo
       
    96     @see RArray
       
    97     */
       
    98 	typedef RArray<TSegmentInfo> RSegmentList;
       
    99 
       
   100 	void ConstructL();
       
   101 	CSymbianElfFormatter();
       
   102 	void FindAllOfSameClassRepresentation( RRegisterList &aRegs,
       
   103 											RRegisterList &aRegsOfSameClassRepr,
       
   104 											ESYM_REGCLASS aClass,
       
   105 											ESYM_REGREP aRepr );
       
   106 
       
   107 	TUint WriteSymbianInfoL(const TCrashInfo &aCrashInfo, const TUint32 aCrc32);
       
   108 
       
   109 	TUint WriteDataSegmentsL( const TUint64 & aThreadId,
       
   110 							  const TUint64 & aPid,
       
   111 							  const RThreadPointerList &aThreadList,
       
   112 							  const RCodeSegPointerList &aCodeSegs,
       
   113 							  RSegmentList &aDataSegs,
       
   114 							  RArray<TUint> &aDataSegOffsets );
       
   115 
       
   116 	TUint WriteCodeSegmentsL( const TUint64 & aThreadId,
       
   117 							  const RCodeSegPointerList &aCodeSegs,
       
   118 							  RArray<TUint> &aCodeSegOffsets );
       
   119 
       
   120 	TUint WriteThreadInfoL(const TUint64 & aPid, const RThreadPointerList &aThreadList);
       
   121 
       
   122 	TUint WriteProcessInfoL(const TUint64 & aPid, const RProcessPointerList &aProcessList);
       
   123 	TUint WriteExecutableInfoL(const RCodeSegPointerList &aCodeSegs, const TUint64 &aTime, const TUint64 &aTid);
       
   124 
       
   125 	void  WriteRegisterInfoL( const TUint64 & aTid,
       
   126 							  const TUint64 & aPid,
       
   127 							  RArray<TUint>& aOffsets,
       
   128 							  RRegisterList &aArmExcRegs,
       
   129 							  const RThreadPointerList &aThreadList);
       
   130 	TUint WriteStringInfoL();
       
   131 
       
   132 	void SetArmRegsFromCrashDataL(const TCrashInfo &aCrashInfo, RRegisterList &aArmExcRegs);
       
   133 
       
   134 	TBool GetArmExcReg(const TCrashInfo &aCrashInfo, const TRegisterData & aReg, TRegisterValue32 & aVal);
       
   135 
       
   136 	void UpdateCrashProgressL( const TDesC &aProgress );
       
   137 	TUint32 CalcExecCrcL(const TUint64 &aTid, const TCodeSegInfo &aExecInfo );
       
   138 
       
   139 	void PrepareFileNameL(TUint64 aStamp);
       
   140     TUint WriteTraceBufferL();
       
   141 
       
   142 	static void CleanupCodeSegList(TAny *aArray);
       
   143 	static void CleanupProcessList(TAny *aArray);
       
   144 	static void CleanupThreadList(TAny *aArray);
       
   145 
       
   146 private:
       
   147 
       
   148     /** Pointer to data source object created and managed by core dump server, provides API to gather necessary info about the crash */
       
   149 	CCrashDataSource * iDataSource;
       
   150 
       
   151     /** Pointer to writer plugin created and managed by core dump server, provides API to store the dump information*/
       
   152 	CCrashDataSave	 * iDataSave;
       
   153 
       
   154     /** Keep track of the current media-position indicator */
       
   155 	TUint			   iOffset;
       
   156 
       
   157     /** Responsible for holding all the strings required to be stored in ELF string info segment */
       
   158 	CStringInfoTable * iStrInfoTbl;
       
   159 
       
   160     /** Symbian ELF formatter configuration parameter list */
       
   161 	CElfOptions		 * iElfOptions;
       
   162 
       
   163 	/** Dump file Name */
       
   164 	RBuf iElfFileName;
       
   165 };
       
   166 
       
   167 #endif // __SYMBIAN_ELF_FORMATTER_H__