--- a/kernel/eka/debug/crashMonitor/group/release.txt Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of the License "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:
-# Version information for crash monitor data
-#
-
-Version 1.00.002
-=================
-(Made by XXXX XXXX XX/06/2009)
-
-1. OliverStuart
- 1. MINOR CHANGE: CR1970: Adding missing S60 distribution files and correcting IDs.
- 2. MINOR CHANGE: CR1994: Updating incorrect copyright headers.
-
-Version 1.00.001
-=================
-(Made by Vino Jose 09/06/2009)
-
-1. OliverStuart
- 1. MINOR CHANGE: CR1970: Setting correct IDs on S60 distribution policy files.
- 2. MINOR CHANGE: CR1994: Replacing Symbian copyright notices with SF notices.
-
-Version 1.00.000
-=================
-
-(Made by stephenroberts 17/11/2008)
-
-1. stephenroberts
- MILESTONE: Capari,GT0441,MS3.x,DSx: PREQ1700: Extend core dump server to capture system crash data
- Initial release of PREQ1700. The System Crash Monitor and Crash Log Walker supports the following data types:
- TCrashOffsetsHeader version 1
- TCrashInfoHeader version 1
- TRawData version 1
- TThreadData version 1
- TThreadStack version 1
- TRegisterValue version 1
- TRegisterSet version 1
- TMemoryDump version 1
- TCodeSegmentSet version 1
- TCodeSegment version 1
- TCodeSegment version 1
- TVariantSpecificData version 1
- TRomHeaderData version 1
- TSCMLockData version 1
- TScmChecksum version 1
\ No newline at end of file
--- a/kernel/eka/debug/crashMonitor/group/scmkern_lib.mmp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32/kernel/scmlib.mmh
-//
-//
-
-ALWAYS_BUILD_AS_ARM
-
-TARGET scmkern_lib.lib
-TARGETTYPE klib
-
-#include "scmlib.mmh"
\ No newline at end of file
--- a/kernel/eka/debug/crashMonitor/group/scmlib.mmh Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\kernel\scmlib.mmh
-//
-//
-
-USERINCLUDE ../inc
-USERINCLUDE ../../../include/nkern
-USERINCLUDE ../../../include/kernel
-
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-#ifdef SYMBIAN_OLD_EXPORT_LOCATION
-SYMBIAN_BASE_SYSTEMINCLUDE(drivers)
-#endif
-
-SOURCEPATH ../src
-SOURCE scmdatatypes.cpp
-SOURCE scmbytestreamutil.cpp
-SOURCE crashlogwalker.cpp
-SOURCE scmconfigitem.cpp
-SOURCE scmconfig.cpp
-SOURCE scmchksum.cpp
-SOURCE scmthreaddata.cpp
-SOURCE scmprocessdata.cpp
-SOURCE scmlockdata.cpp
-SOURCE scmvariantdata.cpp
-SOURCE scmromdata.cpp
-SOURCE scmmulticrashinfo.cpp
--- a/kernel/eka/debug/crashMonitor/group/scmonitor.mmp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32/kernel/scmonitor.mmp
-//
-//
-
-#ifdef EPOC32
-
-#define INCLUDE_EKERN_LIB
-#include "../../../kernel/kern_int.mmh"
-
-
-targettype kext
-
-#ifndef SMP
-
-//userinclude ../../../include/drivers
-//userinclude ../../../kernel
-//userinclude ../inc
-
-
-sourcepath ../src/arm
-source cscmdatasave.cpp
-
-sourcepath ../src
-source scmdatasave.cpp
-source scmonitor.cpp
-
-library exmoncommon.lib
-staticlibrary scmkern_lib.lib
-
-
-epocallowdlldata
-
-noexportlibrary
-
-linkas scmonitor.dll
-
-#endif //SMP endif
-
-#endif //EPOC32 endif
-
-
-//#define SCM_COMM_OUTPUT // use this define for writing debug data to comm port
-
--- a/kernel/eka/debug/crashMonitor/group/scmusr_lib.mmp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32/kernel/scmlib.mmp
-//
-//
-
-ALWAYS_BUILD_AS_ARM
-
-TARGET scmusr_lib.lib
-TARGETTYPE lib
-
-#include "scmlib.mmh"
\ No newline at end of file
--- a/kernel/eka/debug/crashMonitor/inc/crashlogwalker.h Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// some utility classes for writing data to buffer
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-#ifndef __CRASH_LOG_WALKER_H_INCLUDED__
-#define __CRASH_LOG_WALKER_H_INCLUDED__
-
-#include <e32cmn.h>
-
-#include <scmdatatypes.h>
-
-namespace Debug
- {
-
- /**
- * This class provides functionality to walk through a crash log in a data buffer
- * ensuring it is valid and getting the information we require back
- */
- class TCrashLogWalker
- {
- public:
- TCrashLogWalker(TDesC8& aBuffer);
-
- TInt ReadLogHeader(const TInt aStartPoint);
- TInt GetCrashSize() const;
- TInt GetCrashId() const;
- const TRmdArmExcInfo& GetCrashContext() const;
- const TCrashInfoHeader& GetCrashHeader() const;
- const TCrashOffsetsHeader& GetOffsetsHeader() const;
-
-#ifndef __KERNEL_MODE__
- MByteStreamSerializable* GetNextDataTypeL(TInt& aPos, SCMStructId& aId, TInt& aBufferSize);
- TRawData* GetRawDataTypeL(TInt& aPos, TInt& aBufferSize, TDes8& aRawBuf, TInt aStartRawPosition = 0);
-#endif
-
- void UpdateBuffer(TDesC8& aBuffer);
-
- private:
-
- void HelpAssignRegisterToContext(const TRegisterValue& aRegVal);
-
- private:
- TDesC8& iBuffer; //buffer containing data for the log we are walking - not all of it, just the bit of interest
- TCrashInfoHeader iCrashHeader; //Stores the header of the log we are walking
- TCrashOffsetsHeader iOffsets; //Stores the offsets header of the log we are walking
- TRmdArmExcInfo iContext; //Stores the register context of the log we are walking
-
- TByteStreamReader iReader;
-
- private:
- TInt VerifyHeader();
-
- };
-
- }
-
-#endif // __CRASH_LOG_WALKER_H_INCLUDED__
--- a/kernel/eka/debug/crashMonitor/inc/scmbytestreamutil.h Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// some utility classes for writing data to buffer
-//
-// WARNING: This file contains some APIs which are internal and are subject
-// to change without notice. Such APIs should therefore not be used
-// outside the Kernel and Hardware Services package.
-//
-
-/**
- @file
- @internalTechnology
-*/
-#ifndef __SCMBYTESTREAMUTIL_H_
-#define __SCMBYTESTREAMUTIL_H_
-
-#include <e32cmn.h>
-#include <e32def.h>
-#include <e32const.h>
-
-
-namespace Debug
- {
- /**
- * Base class for byte stream write - simply deals with the supplied buffer & position
- */
- class TByteStreamBase
- {
- public:
- TByteStreamBase(TUint8* aBuffer);
- virtual void SetPosition(TInt aPosition);
- virtual TInt CurrentPosition() const;
-
- protected:
-
- /**
- * Pointer to the buffer we will use to write/read to
- */
- TUint8* iBuffer;
-
- /**
- * Current position in buffer
- */
- TInt iPos;
- };
-
- /**
- * Class for reading byte stream
- */
- class TByteStreamReader : public TByteStreamBase
- {
- public:
- TByteStreamReader(TUint8* aBuffer);
- inline virtual TUint8 ReadByte();
- inline TUint16 ReadShort();
- inline TUint32 ReadInt();
- inline TUint64 ReadInt64();
- };
-
- /**
- * Class for writing byte stream
- */
- class TByteStreamWriter : public TByteStreamBase
- {
- public:
- TByteStreamWriter(TUint8* aBuffer, TBool aPhsEnabled = ETrue);
- virtual void WriteByte(TUint8 aValue);
- inline void WriteShort(TUint16 aValue);
- inline void WriteInt(TUint32 aValue);
- inline void WriteInt64(TUint64 aValue);
- inline virtual void EnablePhysicalWriting();
- inline virtual void DisablePhysicalWriting();
- inline virtual TBool PhysicalWritingEnabled() const {return iPhysEnabled;};
- inline TInt GetBytesWritten() const {return iBytesWritten;};
- void ResetBytesWritten();
-
- protected:
-
- /**
- * This records whether or not physical writing via DoPhysical write from set writer
- */
- TBool iPhysEnabled;
-
- /**
- * Records the number of bytes we have written to our buffer
- */
- TInt iBytesWritten;
- };
-
- /**
- * This is the interface to write to flash
- */
- class MPhysicalWriterImpl
- {
- public:
- virtual void DoPhysicalWrite(TAny* aData,TInt aPos, TInt aLen) = 0;
- };
-
-
- /**
- *Class for writing byte stream via cache
- */
- class TCachedByteStreamWriter : public TByteStreamWriter
- {
- public:
-
- TCachedByteStreamWriter(TUint8* aCacheBuffer, TInt aCacheSize, TBool aPhysEnabled = ETrue);
- virtual TInt CurrentPosition() const;
- virtual void WriteByte(TUint8 aValue);
- virtual TInt FlushCache();
- void SetWriterImpl(MPhysicalWriterImpl* aPhysicalWriter);
- TInt GetCacheSize() const {return iCacheSize; };
-
- protected:
- TInt iCacheSize;
- TUint8* iCacheBuffer;
- MPhysicalWriterImpl* iPhysicalWriter;
- };
-
- /**
- * Serialization implementation interface
- */
- class MByteStreamSerializable
- {
- public:
- virtual TInt Serialize(TByteStreamWriter& aWriter) = 0;
- virtual TInt Deserialize(TByteStreamReader& aReader) = 0;
- virtual TInt GetSize() const = 0;
- };
- }
-
-
-#include <scmbytestreamutil.inl>
-
-
-
-#endif /*BYTESTREAMUTIL_H_*/
--- a/kernel/eka/debug/crashMonitor/inc/scmbytestreamutil.inl Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-//
-// WARNING: This file contains some APIs which are internal and are subject
-// to change without noticed. Such APIs should therefore not be used
-// outside the Kernel and Hardware Services package.
-//
-
-#include <e32des8.h>
-
-namespace Debug
- {
- /**
- * TByteStreamReader implementation
- */
-
- /**
- * Returns the next byte from the stream
- * @return TUint8 byte requested
- */
- inline TUint8 TByteStreamReader::ReadByte()
- {
- return iBuffer[iPos++];
- }
-
- /**
- * Returns the next short from the stream
- * @return TUint16 short requested
- */
- inline TUint16 TByteStreamReader::ReadShort()
- {
- TUint8 b1 = ReadByte();
- TUint8 b2 = ReadByte();
- return (TUint16)(b1 + (b2 << 8));
- }
-
- /**
- * Returns the next TUInt32 from the stream
- * @return TUInt32 TUInt32 requested
- */
- inline TUint32 TByteStreamReader::ReadInt()
- {
- TUint16 s1 = ReadShort();
- TUint16 s2 = ReadShort();
- return s1 + (s2 << 16);
- }
-
- /**
- * Returns the next TUInt64 from the stream
- * @return TUInt64 TUInt64 requested
- */
- inline TUint64 TByteStreamReader::ReadInt64()
- {
- TUint32 high = ReadInt();
- TUint32 low = ReadInt();
- return MAKE_TUINT64(high, low) ;
- }
-
- /**
- * TByteStreamWriter implementation
- */
-
- /**
- * Writes a short to the stream
- * @param aValue Value to write to stream
- */
- inline void TByteStreamWriter::WriteShort(TUint16 aValue)
- {
- WriteByte((TUint8) aValue);
- WriteByte((TUint8) (aValue >> 8));
- }
-
- /**
- * Writes an int to the stream
- * @param aValue Value to write to stream
- */
- inline void TByteStreamWriter::WriteInt(TUint32 aValue)
- {
- WriteByte((TUint8)aValue);
- WriteByte((TUint8) (aValue >> 8));
- WriteByte((TUint8) (aValue >> 16));
- WriteByte((TUint8) (aValue >> 24));
- }
-
- /**
- * Writes a 64 bit int to the stream
- * @param aValue Value to write to stream
- */
- inline void TByteStreamWriter::WriteInt64(TUint64 aValue)
- {
- WriteInt(I64HIGH(aValue));
- WriteInt(I64LOW(aValue));
- }
-
- /**
- * Enables physical writing such that the physical writers DoPhysicalWrite
- * method will be invoked upon a write. This may write to a given media
- * as defined by the implementation of this method
- */
- inline void TByteStreamWriter::EnablePhysicalWriting()
- {
- iPhysEnabled = ETrue;
- }
-
- /**
- * Disables physical writing such that the physical writers DoPhysicalWrite
- * method will not be invoked upon a write.
- */
- inline void TByteStreamWriter::DisablePhysicalWriting()
- {
- iPhysEnabled = EFalse;
- }
- }
-
-
-//eof
--- a/kernel/eka/debug/crashMonitor/inc/scmconfig.h Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-//
-// WARNING: This file contains some APIs which are internal and are subject
-// to change without notice. Such APIs should therefore not be used
-// outside the Kernel and Hardware Services package.
-//
-
-/**
- @file
- @internalTechnology
-*/
-#ifndef __SCMCONFIG_H_INCLUDED__
-#define __SCMCONFIG_H_INCLUDED__
-
-
-#include <e32def.h>
-
-#include <scmbytestreamutil.h>
-#include <scmconfigitem.h>
-
-namespace Debug{
-
- //Note -- Changing the size of this requires a change in KScmConfigMaxSize
- _LIT8(KScmConfigHeaderString, "SCMCONFIG");
-
- /**
- * This class handles the configuration section of the crash partition.
- * It is responsible for reading and writing it
- */
- class SCMConfiguration : public MByteStreamSerializable
- {
-
- public:
-
- //The 9 here refers to the size of KScmConfigHeaderString which is serialised
- static const TInt KScmConfigMaxSize = TConfigItem::ELast * sizeof(TConfigItem) + 9;
-
- SCMConfiguration();
- virtual ~SCMConfiguration();
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- TConfigItem* GetNextItem();
- TInt SetDefaultConfig();
-
- TInt CreateConfigItem(const TConfigItem::TSCMDataType aDataType, const TUint8 aPriority, const TInt32 aSizeToDump);
- TInt ModifyConfigItemPriority(const TConfigItem::TSCMDataType aDataType, const TUint8 aPriority);
-
- void ResetToHighestPriority();
-
- TBool operator == (const SCMConfiguration& aOther) const;
-
- TConfigItem* ConfigList() const;
- TInt InsertToList(TConfigItem* aItem);
- void ClearList();
-
- private:
-
- /**
- * This is an ordered linked list of TConfigItems. The first is the highest priority and so on until the lowest priority
- */
- TConfigItem* iConfigList;
-
- /**
- * Everytime GetNextItemToDump is called this moves down along the list
- */
- TConfigItem* iNextItem;
-
- private:
- TInt RemoveFromList(TConfigItem* aItem);
-
-
- };
- }
-
-#endif /*__SCMCONFIG_H_INCLUDED__*/
--- a/kernel/eka/debug/crashMonitor/inc/scmconfigitem.h Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// some utility classes for writing data to flash buffer
-//
-// WARNING: This file contains some APIs which are internal and are subject
-// to change without notice. Such APIs should therefore not be used
-// outside the Kernel and Hardware Services package.
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#ifndef __SCMCONFIGITEM_H_INCLUDED__
-#define __SCMCONFIGITEM_H_INCLUDED__
-
-
-#include <e32def.h>
-#ifndef __KERNEL_MODE__
-#include <e32std.h>
-#endif // ! __KERNEL_MODE__
-
-#include <scmbytestreamutil.h>
-
-
-namespace Debug
- {
- /**
- * This object represents a data type to dump
- */
- class TConfigItem : public MByteStreamSerializable
- {
- public:
- enum TSCMDataType
- {
- EExceptionStacks, /**< Dumps exception stacks */
- EVariantSpecificData, /**< Dumps Variant Specific data */
- ERomInfo, /**< Dumps ROM Build Info */
- ELocks, /**< Dumps Kernel Lock Info */
- EKernelHeap, /**< Dumps the Kernel Heap */
- ETraceData, /**< Dumps any trace data we find */
- EProcessCodeSegs, /**< Dumps System wide Code Segments for each Process */
- EThreadsUsrStack, /**< Dumps System wide User Stacks for each thread */
- EThreadsSvrStack, /**< Dumps System wide Supervisor Stacks for each thread */
- EThreadsUsrRegisters, /**< Dumps User Registers available for every thread in the System */
- EThreadsSvrRegisters, /**< Dumps Supervisor Registers available for every thread in the System */
- EProcessMetaData, /**< Dumps the Process List */
- EThreadsMetaData, /**< Dumps the Thread List */
- ECrashedProcessCodeSegs, /**< Dumps the Code Segments for the process that has crashed */
- ECrashedProcessUsrStacks, /**< Dumps the User stacks for each thread in the process that has crashed */
- ECrashedProcessSvrStacks, /**< Dumps the Supervisor stacks for each thread in the process that has crashed */
- ECrashedProcessMetaData, /**< Dumps Info about the process that has crashed */
- ECrashedThreadMetaData, /**< Dumps Info about the Thread that has crashed */
- ELast /**< End Marker */
- };
-
- TConfigItem();
- TConfigItem(TSCMDataType aDataType, TUint8 aPriority, TInt32 aSizeToDump);
-
- TSCMDataType GetDataType() const;
- TInt GetPriority() const;
- TInt GetSizeToDump() const;
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- void SetSpaceRequired(TUint aSpaceReq);
- TUint GetSpaceRequired();
-
- void Print() const;
- TBool operator == (const TConfigItem& aOther) const;
- TConfigItem* Next() const;
-
-#ifndef __KERNEL_MODE__
- static const TDesC& GetSCMConfigOptionText(TConfigItem::TSCMDataType aType);
-#endif // ! __KERNEL_MODE__
-
- private:
- TSCMDataType iDataType; /** The type this data represents */
- TUint iSizeToDump; /** the size of the data to dump */
- TUint iSpaceRequiredToDump; /** If known, this will contain the size of the data we need to dump */
- TUint8 iPriority; /** Priority of this data (0 is not required) */
- TConfigItem* iNext; /** Next config item in list */
-
- friend class SCMConfiguration;
-
- };
- }
-
-
-#endif // __SCMCONFIGITEM_H_INCLUDED__
--- a/kernel/eka/debug/crashMonitor/inc/scmdatasave.h Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\include\kernel\scmdatasave.h
-// Kernel System crash data save header file
-//
-// WARNING: This file contains some APIs which are internal and are subject
-// to change without notice. Such APIs should therefore not be used
-// outside the Kernel and Hardware Services package.
-//
-
-#ifndef SCMDATASAVE_H
-#define SCMDATASAVE_H
-
-/**
- @file
- @internalComponent
- */
-
-#include <plat_priv.h>
-#include <kernel/monitor.h>
-#include <e32des8.h>
-#include <arm.h>
-#include <crashflash.h>
-
-#include <scmdatatypes.h>
-#include <scmbytestreamutil.h>
-#include <scmconfig.h>
-
-using namespace Debug;
-
-IMPORT_C TInt64 CrashTime();
-
-
-_LIT8(KKernelHeapChunkName, "ekern.exe::SvHeap");
-_LIT8(KKernelProcessName, "ekern.exe");
-
-
-/**
- * This class handles gathering of the kernel data and writing it to flash
- *
- */
-class SCMDataSave : MPhysicalWriterImpl
- {
- public:
- enum TRegisterSetType
- {
- EUserRegisters = 0,
- ESupervisorRegisters = 1,
- EFullCPURegisters = 2,
- ERegSetNone = 3,
- ERegLast
- };
-
- enum TStackType
- {
- EUsrStack = 0,
- ESvrStack = 1,
- EStackTypeNone = 2,
- EStackLast
- };
-
- enum TDumpScope
- {
- EThreadSpecific = 0,
- EProcessSpecific = 1,
- ESystemWide = 2,
- EDumpLast
- };
-
- /**
- * This structure defines the type of data we wish to dump for a given kernel object
- */
- struct TDataToDump
- {
- TBool iMetaData; /**< Dump meta data about object */
- TBool iCodeSegs; /**< Dump DProcess code segs (ignored for other objects) */
- TStackType iStk; /**< Dump this stack type */
- TRegisterSetType iReg; /**< Dump this register set */
-
- TDataToDump()
- {
- //upon construction, nothing is set to be dumped
- iMetaData = EFalse;
- iCodeSegs = EFalse;
- iStk = EStackTypeNone;
- iReg = ERegSetNone;
- }
-
- };
-
- enum TWriteSelect
- {
- EWriteFlash = 0, /**< write data to flash */
- EWriteComm =1, /**< write data to comm port */
- ELast
- };
-
- public:
-
- IMPORT_C SCMDataSave(Monitor* aMonitor, CrashFlash* aFlash);
- virtual ~SCMDataSave();
-
-
- TInt LogCrashHeader(const TDesC8& aCategory, TInt aReason, TInt aCrashId, TUint& aSizeDumped);
- TInt LogThreadData(DThread* aThread, TUint& aSizeDumped);
- TInt LogProcessData(DProcess* aProcess, TUint& aSizeDumped);
- TInt LogCodeSegments(DProcess* aProcess, TUint& aSizeDumped);
-
- TInt LogThreadUserStack(DThread* aThread, TBool aFullStack, TUint& aSizeDumped);
- TInt LogThreadSupervisorStack(DThread* aThread, TBool aFullStack, TUint& aSizeDumped);
-
- TInt LogRegisters(DThread* aThread, const TRegisterSetType& aRegType, TUint& aSizeDumped);
- TInt LogCPURegisters(TUint& aSizeDumped);
- TInt ReadUserRegisters(DThread* aThread, TArmRegSet& aRegs, TUint32& aAvailableRegs);
- TInt ReadSystemRegisters(DThread* aThread, TArmRegSet& aRegs, TUint32& aAvailableRegs);
- void ReadCPURegisters(SFullArmRegSet& aRegs);
-
- TInt LogMemory(const TUint8* aStartAddress, TInt aLength, const DThread* aThread, TUint& aSizeDumped);
- TInt LogExceptionStacks(TUint& aSizeDumped);
- TInt LogTraceBuffer(TInt aSizeToDump, TUint& aSizeDumped);
- TInt LogLocks(TUint& aSizeDumped);
- TInt LogRawData(const TDesC8& aData, TUint& aSizeDumped);
- TInt LogVariantSpecificData(TUint& aSizeDumped);
- TInt LogRomInfo(TUint& aSizeDumped);
-
- TInt LogKernelHeap(TUint& aSizeDumped);
- TInt FindKernelHeap(TInt32& aHeapLocation, TInt32& aHeapSize);
-
- TInt LogConfig(SCMConfiguration& aConfig);
- TInt ReadConfig(SCMConfiguration& aScmConfig);
-
-
- void Write(const TAny* aSomething, TInt aSize);
- static void WriteUart(const TUint8* aData, TInt aSize);
- static void WriteUart(const TDesC8& aDes);
- virtual void DoPhysicalWrite(TAny* aData, TInt aPos, TInt aLen);
-
- void WriteCrashFlash(TInt aPos, TInt& aSize, const TDesC8& aBuffer);
-
- TInt GetRegisterType(const TRegisterSetType& aSetType, TInt32& aRegNumber, TUint32& aRegisterType);
- TInt GetByteCount();
- void SetByteCount(TInt aByte);
-
-
- TWriteSelect GetWriteSelect();
- void SetWriteSelect(TWriteSelect aWriteSelect);
-
- TUint SpaceRemaining();
- TUint MaxLogSize();
-
- void SetCrashStartingPoint(TUint32 aStart);
- TUint32 GetCrashStartingPoint() {return iStartingPointForCrash;}
-
- public:
-
- /** Offsets header to assist parsing */
- TCrashOffsetsHeader iHdr;
-
- /** Basic crash info */
- TCrashInfoHeader iCrashInf;
-
- /** Writer for physical writing */
- TCachedByteStreamWriter* iWriter;
-
- private:
- Monitor* iMonitor; //need to use this to map memory and things like that
- CrashFlash* iFlash;
- TTraceDump iTrace;
-
- TInt iByteCount;
-
- //This is a pointer to memory on the heap we can use that is the same size as iFlash.GetFlashBlockSize()
- HBuf8* iFlashCache;
-
- TWriteSelect iWriteSelect;
- TBool iPerformChecksum;
- TScmChecksum iChecksum;
-
- TUint32 iStartingPointForCrash;
- };
-
-#endif /*SCMDATASAVE_H*/
--- a/kernel/eka/debug/crashMonitor/inc/scmdatatypes.h Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,804 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// Definitions for the data types the SCM stores to flash
-//
-// WARNING: This file contains some APIs which are internal and are subject
-// to change without notice. Such APIs should therefore not be used
-// outside the Kernel and Hardware Services package.
-//
-
-
-#ifndef __SCMDATATYPES_H_INCLUDED__
-#define __SCMDATATYPES_H_INCLUDED__
-
-
-#include <e32rom.h>
-
-#include <scmbytestreamutil.h>
-#include <scmtrace.h>
-
-/**
- @file
- @internalComponent
- */
-
-namespace Debug
-{
- /** SCM Data Types Major Number */
- static const TInt KSCMDataTypesMajorVersion = 1;
-
- /** SCM Data Types Minor Number */
- static const TInt KSCMDataTypesMinorVersion = 0;
-
- /** SCM Data Types Build Number */
- static const TInt KSCMDataTypesBuildNumber = 0;
-
- /**
- Specifies the type of a code segment.
- @see TCodeSegListEntry
- */
- enum TCodeSegType
- {
- EUnknownCodeSegType = 0, /**< Signifies an unknown code segment type. */
- EExeCodeSegType = 1, /**< Signifies a code segment belonging to an executable. */
- EDllCodeSegType = 2 /**< Signifies a code segment belonging to a library. */
- };
-
-
- /**
- Used for storing the contents of a 32 bit register
- */
- typedef TUint32 TRegisterValue32;
-
- /**
- Structure containing information about the state of the registers when a
- hardware exception occurred
- */
- class TRmdArmExcInfo
- {
- public:
- /** Enumeration detailing the types of exception which may occur. */
- enum TExceptionType
- {
- /** Enumerator signifying that a prefetch abort error has occurred. */
- EPrefetchAbort = 0,
- /** Enumerator signifying that a data abort error has occurred. */
- EDataAbort = 1,
- /** Enumerator signifying that an undefined instruction error has occurred. */
- EUndef =2
- };
-
- /** Value of CPSR. */
- TRegisterValue32 iCpsr;
- /** Type of exception which has occurred. */
- TExceptionType iExcCode;
- /** Value of R13 supervisor mode banked register. */
- TRegisterValue32 iR13Svc;
- /** Value of user mode register R4. */
- TRegisterValue32 iR4;
- /** Value of user mode register R5. */
- TRegisterValue32 iR5;
- /** Value of user mode register R6. */
- TRegisterValue32 iR6;
- /** Value of user mode register R7. */
- TRegisterValue32 iR7;
- /** Value of user mode register R8. */
- TRegisterValue32 iR8;
- /** Value of user mode register R9. */
- TRegisterValue32 iR9;
- /** Value of user mode register R10. */
- TRegisterValue32 iR10;
- /** Value of user mode register R11. */
- TRegisterValue32 iR11;
- /** Value of R14 supervisor mode banked register. */
- TRegisterValue32 iR14Svc;
- /** Address which caused exception (System Control Coprocessor Fault Address Register) */
- TRegisterValue32 iFaultAddress;
- /** Value of System Control Coprocessor Fault Status Register. */
- TRegisterValue32 iFaultStatus;
- /** Value of SPSR supervisor mode banked register. */
- TRegisterValue32 iSpsrSvc;
- /** Value of user mode register R13. */
- TRegisterValue32 iR13;
- /** Value of user mode register R14. */
- TRegisterValue32 iR14;
- /** Value of user mode register R0. */
- TRegisterValue32 iR0;
- /** Value of user mode register R1. */
- TRegisterValue32 iR1;
- /** Value of user mode register R2. */
- TRegisterValue32 iR2;
- /** Value of user mode register R3. */
- TRegisterValue32 iR3;
- /** Value of user mode register R12. */
- TRegisterValue32 iR12;
- /** Value of user mode register R15, points to instruction which caused exception. */
- TRegisterValue32 iR15;
- };
- /**
- * This enum defines the type of struct we are dealing with when we
- * are serialising/deserialising
- */
- enum SCMStructId
- {
- ESCMFirst,
- ESCMOffsetsHeader,
- ESCMTCrashInfo,
- ESCMProcessData,
- ESCMThreadData,
- ESCMThreadStack,
- ESCMRegisterValue,
- ESCMRegisterSet,
- ESCMMemory,
- ESCMCodeSegSet,
- ESCMCodeSeg,
- ESCMRawData,
- ESCMTraceData,
- ESCMLocks,
- ESCMKernelHeap,
- ESCMVariantData,
- ESCMRomHeader,
- ESCMLast
- };
-
- /**
- * This class represents the header at the start of a crash log
- * describing the size of the crash log and minimal location
- * information
- */
- class TCrashOffsetsHeader : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMCrashOffsetsMaxSize = 20 * sizeof(TUint32) + sizeof(TUint16);
-
- enum TCrashHeaderVersion
- {
- EChVersion1 = 1
- };
-
- TCrashOffsetsHeader();
-
- //From MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- TBool operator == (const TCrashOffsetsHeader& aOther) const;
-
- SCMStructId iId;
- TCrashHeaderVersion iVersion;
-
- //These next members are offsets to the crash data in the log
- TUint32 iCTFullRegOffset;
- TUint32 iCTUsrStkOffset;
- TUint32 iCTSvrStkOffset;
- TUint32 iCPMetaOffset;
- TUint32 iCTMetaOffset;
- TUint32 iCPCodeSegOffset;
- TUint32 iSysUsrStkOffset;
- TUint32 iSysSvrStkOffset;
- TUint32 iSysUsrRegOffset;
- TUint32 iSysSvrRegOffset;
- TUint32 iTLstOffset;
- TUint32 iPLstOffset;
- TUint32 iSysCodeSegOffset;
- TUint32 iExcStkOffset;
- TUint32 iTraceOffset;
- TUint32 iScmLocksOffset;
- TUint32 iKernelHeapOffset;
- TUint32 iVarSpecInfOffset;
- TUint32 iRomInfoOffset;
-
- TUint32 iSpare1;
- TUint32 iSpare2;
- TUint32 iSpare3;
- TUint32 iSpare4;
- TUint32 iSpare5;
- TUint32 iSpare6;
-
- };
-
- /**
- * This class stores meta data for a given crash
- */
- class TCrashInfoHeader : public MByteStreamSerializable
- {
- public:
-
- static const TInt KMaxCatSize = 80;
- static const TInt KSCMCrashInfoMaxSize = 76 + KMaxCatSize;
-
- enum TCrashInfoHeaderVersion { ECiVersion1 = 1 };
- TCrashInfoHeader();
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- TBool operator == (const TCrashInfoHeader& aOther) const;
-
-
- SCMStructId iId;
- TCrashInfoHeaderVersion iVersion;
- TInt32 iLogSize;
- TInt32 iFlashAlign;
- TInt32 iCachedWriterSize;
- TUint64 iPid;
- TUint64 iTid;
- TInt32 iExitType;
- TInt32 iExitReason;
- TInt32 iExcCode;
- TInt64 iCrashTime;
- TInt32 iCrashId;
- TInt32 iFlashBlockSize;
- TInt32 iFlashPartitionSize;
- TVersion iSCMDataTypesVersion;
- TUint32 iCategorySize;
- TBuf8<KMaxCatSize> iCategory;
-
- TInt32 iSpare1;
- TInt32 iSpare2;
- };
-
- /**
- * This class is used for a raw memory dump. It will always be preceded by a TMemoryDump.
- *
- * Note: This class contains a TPtr8 to store the data
- * name. Due to us not being able to allocate memory when the system
- * is down, we assume that the memory to which this points is owned
- * by someone else. It is constructed to point to NULL. To make use
- * of this, before serialising the data, ensure to set it to point to
- * the location required. Equally, when derserialising, ensure to allocate
- * a descriptor of required bytes (determined from TMemoryDump) and set it to iData, otherwise
- * the name will be ignored upon reading.
- */
- class TRawData : public MByteStreamSerializable
- {
- public:
-
- //Note this doesnt include the data, as this number is not determinable
- static const TInt KSCMRawDataMaxSize = 2 * sizeof(TUint32) + sizeof(TUint16);
-
- enum TTRawDataVersion { ETRawData1 = 1 };
- TRawData();
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- TInt Deserialize(TInt aStartPos, TByteStreamReader& aReader);
-
- SCMStructId iId;
- TTRawDataVersion iVersion;
-
- TInt32 iLength;
- TPtr8 iData;
-
- };
-
- /**
- * This class stores meta data for a given process
- */
- class TProcessData : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMProcessDataMaxSize = sizeof(TUint16) + sizeof(TUint64) + 2 * sizeof(TUint32) + KMaxProcessName;
-
- enum TProcessDataVersion { EProcData1 = 1 };
- TProcessData();
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- SCMStructId iId;
- TProcessDataVersion iVersion;
-
- TUint64 iPid;
- TUint32 iNamesize; //Length of process filename in bytes
- TInt32 iPriority;
-
- TBuf8<KMaxProcessName> iName;
-
- TInt32 iSpare1;
- TInt32 iSpare2;
- TInt32 iSpare3;
- };
-
- /**
- * This class stores meta data for a given thread
- */
- class TThreadData : public MByteStreamSerializable
- {
- public:
-
- static const TInt KMaxThreadName = KMaxProcessName;
- static const TInt KSCMThreadDataMaxSize = sizeof(TUint32) + sizeof(TUint16) + 11 * sizeof(TUint32) + 2 * sizeof(TUint64) + KMaxThreadName;
-
- enum TThreadDataVersion { EThreadData1 = 1 };
- TThreadData();
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- SCMStructId iId;
- TInt32 iVersion;
- TInt32 iPriority;
- TUint64 iTid;
- TUint64 iOwnerId;
- TInt32 iSvcSP;
- TInt32 iSvcStack;
- TInt32 iSvcStacksize;
- TInt32 iUsrSP;
- TInt32 iUsrStack;
- TInt32 iUsrStacksize;
- TUint32 iNamesize;
- TUint32 iLastCpu;
- TInt32 iSvcHeap;
- TInt32 iSvcHeapSize;
-
- TBuf8<KMaxThreadName> iName;
-
- TInt32 iSpare1;
- TInt32 iSpare2;
- };
-
- /**
- * This class stores the stack for a given thread. The type (user or supervisor) is given
- * by iStackType. It will be followed by a TMemoryDump containing the stack
- */
- class TThreadStack : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMThreadStackMaxSize = sizeof(TUint32) + sizeof(TUint16) + 2 * sizeof(TUint32) + sizeof(TUint64);
-
- enum TThreadStackVersion { EStackVersion1 = 1 };
-
- enum TThreadStackType
- {
- EUsrStack,
- ESvrStack,
- EIRQStack,
- EFIQStack,
- ELast
- };
-
- TThreadStack();
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- SCMStructId iId;
- TThreadStackVersion iVersion;
- TThreadStackType iStackType;
- TUint64 iThreadId;
- TUint32 iStackSize;
-
- TInt32 iSpare1;
- TInt32 iSpare2;
- };
-
- /**
- * Stores the value of a given register and tells you its type
- */
- class TRegisterValue : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMRegisterValueMaxSize = sizeof(TUint32) + sizeof(TUint16) + 2 * sizeof(TUint8) + sizeof(TUint16) + sizeof(TUint32) + 2 * sizeof(TUint64);
-
- TRegisterValue();
-
- enum TRegisterValueVersion { ERegisterValueVersion1 = 1 };
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- SCMStructId iId;
- TRegisterValueVersion iVersion;
- TInt64 iOwnId;
-
- /**
- * Same as Sym32_reginfod::rd_id
- * if rid_class == ESYM_REG_CORE
- * rd_id is one of rm_debug_api.h::TFunctionalityRegister
- * else
- * rd_id is CoProcessor number, eg 15 for ARM CP15
- */
- TUint32 iType;
-
- TUint8 iClass; //Same as Sym32_reginfod::rid_class
- TUint16 iSubId; //used for coprocessors
-
- /**
- * Same as Sym32_reginfod::rd_repre
- * ESYM_REG_8 == 0,
- * ESYM_REG_16 == 1,
- * ESYM_REG_32 == 2,
- * ESYM_REG_64 == 3
- */
- TUint8 iSize; //register size
-
- // Register value
- union
- {
- // Value of an 8 bit register
- TUint8 iValue8;
-
- // Value of a 16 bit register
- TUint16 iValue16;
-
- // Value of a 32 bit register
- TUint32 iValue32;
-
- // Value of a 64 bit register
- TUint64 iValue64;
- };
-
-
- };
-
- /**
- * This class is a header for our register set.
- */
- class TRegisterSet : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMRegisterSetMaxSize = sizeof(TUint32) + sizeof(TUint16) + sizeof(TUint32);
-
- TRegisterSet();
-
- enum TRegisterSetVersion { ETRegisterSetVersion1 = 1 };
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- TRegisterSetVersion iVersion;
- SCMStructId iId;
- TInt32 iNumRegisters;
- };
-
- /**
- * This class describes a memory dump and will be followed by a TRawData
- */
- class TMemoryDump : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMMemDumpMaxSize = sizeof(TUint32) + sizeof(TUint16) + 2 * sizeof(TUint32) + sizeof(TUint64);
-
- enum TMemDumpVersionVersion { EMemDumpVersion1 = 1 };
-
- TMemoryDump();
-
- //From MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- SCMStructId iId;
- TMemDumpVersionVersion iVersion;
- TUint32 iStartAddress;
-
- TInt64 iPid;
- TInt32 iLength;
- };
-
- /**
- * class to represent a set of code segs corrosponding to a given process
- */
- class TCodeSegmentSet : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMCodeSegSetMaxSize = KMaxProcessName;
-
- TCodeSegmentSet();
-
- enum TCodeSegmentSetVersion { ETCodeSegmentSetVersion1 = 1 };
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- TInt GetMaxSize() const;
-
- SCMStructId iId; /**< Id that uniquely identifies this data */
- TCodeSegmentSetVersion iVersion; /**< Version of this data */
- TInt32 iNumSegs; /**< The number of code segments following this struct that relate to this process ID */
- TInt64 iPid; /**< Process Id that owns the following code segments */
- };
-
- /**
- * class to represent a code segment in the SCM Log
- */
- class TCodeSegment : public MByteStreamSerializable
- {
- public:
-
- static const TInt KMaxSegmentNameSize = KMaxProcessName;
-
- //50 is the sum of the size of members that get serialised
- static const TInt KSCMCodeSegMaxSize = 50 + KMaxSegmentNameSize;
-
- TCodeSegment();
-
- enum TCodeSegmentVersion { ETCodeSegmentVersion1 = 1 };
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- TInt GetMaxSize() const;
-
- SCMStructId iId; /**< Id that uniquely identifies this data */
- TCodeSegmentVersion iVersion; /**< Version of this data */
- TCodeSegType iCodeSegType; /**< @see TCodeSegType */
- TModuleMemoryInfo iCodeSegMemInfo; /**< holds the memory info for this code segment (8 TUint32's)*/
- TBool iXip; /**< If this code segment is XIP */
- TInt32 iNameLength; /**< Length of the name of this code segment name */
- TBuf8<KMaxSegmentNameSize> iName; /**< Name of this code segment */
-
- };
-
- /**
- * This class represents a trace dump in the crash log. It will be immediately followed
- * in the crash log by a TRawData structure
- */
- class TTraceDump : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMTraceDumpMaxSize = sizeof(TUint32) + sizeof(TUint16) + 2 * sizeof(TUint32);
-
- TTraceDump();
-
- enum TTraceDumpVersion { ETraceDumpVersion1 = 1 };
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- SCMStructId iId; /**< Id that uniquely identifies this data */
- TTraceDumpVersion iVersion; /**< Version of this data */
- TInt32 iSizeOfMemory; /**< Size of the trace data that will be dumped in the following Memory Dump */
- TInt32 iNumberOfParts; /**< Number of TRawData structs that will follow */
-
- };
-
- /**
- * This represents variant specific data in the crash log. It will be followed
- * immediately by a TRawData that contains the data
- */
- class TVariantSpecificData : public MByteStreamSerializable
- {
- public:
-
- //sizeof(TUint32) + sizeof(TUint16) + sizeof(TUint32)
- static const TInt KSCMVarSpecMaxSize = 10;
-
- TVariantSpecificData();
-
- enum TVariantSpecificDataVersion { EVariantSpecificDataVersion1 = 1 };
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- SCMStructId iId; /**< Id that uniquely identifies this data */
- TVariantSpecificDataVersion iVersion; /**< Version of this data */
- TUint32 iSize; /**< Size of the raw data (ie the var spec info) that will follow */
- };
-
- /**
- * This represents the Rom Header Data in the crash Log
- */
- class TRomHeaderData : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMRomHdrMaxSize = sizeof(TUint32) + sizeof(TUint16) + sizeof(TUint64) + 2 * sizeof(TUint8) +sizeof(TUint16);
-
- TRomHeaderData();
-
- enum TRomHeaderDataVersion { ERomHeaderDataVersion1 = 1 };
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- SCMStructId iId; /**< Id that uniquely identifies this data */
- TRomHeaderDataVersion iVersion; /**< Version of this data */
- TUint8 iMajorVersion; /**< Major Version of ROM build */
- TUint8 iMinorVersion; /**< Minor Version of ROM build */
- TUint16 iBuildNumber; /**< ROM build number */
- TUint64 iTime; /**< Build time of ROM in miliseconds */
- };
-
- /**
- * This represents the kernel lock info in the crash log
- */
- class TSCMLockData : public MByteStreamSerializable
- {
- public:
-
- static const TInt KSCMLockDataMaxSize = sizeof(TUint32) + 3 * sizeof(TUint16);
-
- TSCMLockData();
-
- // from MByteStreamSerializable
- virtual TInt Serialize(TByteStreamWriter& aWriter);
- virtual TInt Deserialize(TByteStreamReader& aReader);
- virtual TInt GetSize() const;
-
- TInt MutexHoldCount() const;
- void SetMutexHoldCount(TInt aMutexHoldCount);
-
- TInt MutexThreadWaitCount() const;
- void SetMutexThreadWaitCount(TInt aMutexThreadWaitCount);
-
- TInt LockCount() const;
- void SetLockCount(TInt aLockCount);
-
- TBool operator == (const TSCMLockData& aOther) const;
- TBool operator != (const TSCMLockData& aOther) const;
-
- private:
- SCMStructId iId;
- TInt iMutexHoldCount; // if mutex is valid number of holds on the mutex from current thread
- TInt iMutexThreadWaitCount; // if mutex is valid number of threads waiting on the mutex
- TInt iLockCount;
-
- };
-
- /**
- * TScmChecksum class is used to provide a level of sanity checking for the data it processes
- * the check sum produced is not intended to be computationally unique
- * This implementation has been chosen as there are restrictions in the data may only be available
- * in small chunks and the entire data may not be unable to be read (ie comm port implementation)
- * These restrictions rule out the use of more sophisticated checksums that produce a checksum value for
- * an entire block of data
- */
- class TScmChecksum : MByteStreamSerializable
- {
- public:
- TScmChecksum();
-
- void ChecksumBlock(const TUint8* aData, TUint aLen);
- void ChecksumBlock(const TDesC8& aDes);
- TBool operator == (const TScmChecksum& aOther) const;
- TBool operator != (const TScmChecksum& aOther) const;
- void Reset();
-
- // from MByteStreamSerializable
- TInt Serialize(TByteStreamWriter& aWriter);
- TInt Deserialize(TByteStreamReader& aReader);
- TInt GetSize() const;
-
- private:
- /** Total length of all data in bytes*/
- TUint32 iLength;
- /** Sum of all bytes*/
- TUint32 iSum;
- /** Count of Bytes with value 0*/
- TUint32 iZeroCount;
-
- };
-
- /** class to describe a flash block */
- class SCMCrashBlockEntry
- {
- public:
-
- SCMCrashBlockEntry()
- : iBlockNumber(0)
- , iBlockOffset(0)
- , iBlockSize(0)
- , iNext(NULL)
- {
-
- }
-
- SCMCrashBlockEntry(TInt aBlockNumber, TInt aBlockOffset, TInt aBlockSize)
- : iBlockNumber(aBlockNumber)
- , iBlockOffset(aBlockOffset)
- , iBlockSize(aBlockSize)
- , iNext(NULL)
- {
-
- }
-
- /** The offset in bytes to this block from start of flash*/
- TInt iBlockNumber;
- /** The offset in bytes to this block from start of flash*/
- TInt iBlockOffset;
- /** the size of the flash block in bytes */
- TInt iBlockSize;
- /** pointer to next in list*/
- SCMCrashBlockEntry* iNext;
-
- };
-
- /** Because of limitations in flash memory driver available to the
- * system crash monitor - this class is used to describe the locations
- * on flash where crashes will be stored
- * we store 1 crash per block of flash ! This eliminates the
- * need to for the scmonitor to hold memory required for bufering write data to flash
- * class used to describe locations (typically in flash)
- * where
- * holds a linked list of SCMCrashBlockEntry which describe an area we can write to
- */
- class SCMMultiCrashInfo
- {
- public:
-
- /** constructor */
- SCMMultiCrashInfo();
-
- /** destructor */
- ~SCMMultiCrashInfo();
-
- /** add a pointer to a block to the list - takes ownership of block */
- void AddBlock(SCMCrashBlockEntry* aBlockEntry);
-
- /** GetNextBlock returns NULL when no more blocks */
- SCMCrashBlockEntry* GetNextBlock();
-
- /** sets current block to first in list */
- void Reset();
-
- /** clear all entries in the list */
- void ClearList();
-
-
- private:
- SCMCrashBlockEntry* iFirstBlock;
- SCMCrashBlockEntry* iCurrentBlock;
- TInt iSpare;
- };
-
- /**
- * This constant gives us the maximum size of the Core Crash Header which consists of the Crash Info, the Offsets
- * Header and the Core Registers
- */
- static const TInt KMaxCoreHeaderSize = TCrashInfoHeader::KSCMCrashInfoMaxSize //Crash Info - always there
- + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize //offsets header - optional
- + TRegisterSet::KSCMRegisterSetMaxSize //The crash context - always there
- + TRegisterValue::KSCMRegisterValueMaxSize * 37; //could be up to 37 register values
-
- }
-
-#endif //__SCMDATATYPES_H_INCLUDED__
-
-//eof scmdatatypes.h
--- a/kernel/eka/debug/crashMonitor/inc/scmonitor.h Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\include\kernel\scmonitor.h
-// Kernel System crash monitor header file
-//
-// WARNING: This file contains some APIs which are internal and are subject
-// to change without notice. Such APIs should therefore not be used
-// outside the Kernel and Hardware Services package.
-//
-
-/**
- @file
- @internalComponent
-*/
-
-#ifndef __SCMONITOR_H__
-#define __SCMONITOR_H__
-
-#include <plat_priv.h>
-#include <kernel/monitor.h>
-#include <e32des8.h>
-#include <arm.h>
-#include <variant_norflash_layout.h>
-
-#include <scmdatatypes.h>
-#include <scmbytestreamutil.h>
-#include <scmconfig.h>
-#include <scmdatasave.h>
-
-using namespace Debug;
-
-class CrashFlash;
-
-const TInt KFlashAlignment = sizeof(TInt32);
-
-const TInt KFlashEraseAttempts = 10;
-/**
- * System crash monitor responsible for writing crash data to flash in
- * the event of a crash
- */
-class SCMonitor: public Monitor
- {
- public:
- SCMonitor();
- ~SCMonitor();
-
- virtual void Print(const TDesC8& aDes);
- virtual TInt Init2(TAny* aCategory, TInt aReason);
-
- void VariantInit();
- TInt InitFlash();
-
- void StableConstruction();
-
- public:
- CrashFlash* iFlash;
-
- protected:
- void DumpVariantSpecific();
-
- enum TSysCrashLogState
- {
- EUndefined = 0
- };
-
-
- private:
- TInt ProcessCrash(const SCMCrashBlockEntry& aBlockEntry, const TUint aCrashId, TBool aCommit);
- TInt LogProcessMetaData(SCMDataSave::TDumpScope aDumpScope, TUint& aSizeDumped) const;
- TInt LogThreadMetaData(SCMDataSave::TDumpScope aDumpScope, TUint& aSizeDumped) const;
- TInt LogObjectContainers(TObjectType aObjectType, SCMDataSave::TDumpScope aDumpScope, const SCMDataSave::TDataToDump& aDataToDump, TUint& aSizeDumped) const;
- TInt GetNextCrashStartPoint(SCMCrashBlockEntry& aBlockEntry);
- void DoCrash(TAny* aCategory, TInt aReason);
-
- private:
- TInt HelpDumpStacks(DObject* aObject, TObjectType aObjectType, TUint& aSizeDumped, SCMDataSave::TStackType aStkType) const;
- TInt HelpDumpMetaData(DObject* aObject, TObjectType aObjectType, TUint& aSizeDumped) const;
- TInt EraseFlashBlock(const SCMCrashBlockEntry& aBlock);
- TInt EraseEntireFlashPartition();
-
- private:
- SCMDataSave* iDataSave;
- Debug::SCMConfiguration* iScmConfig;
- SCMMultiCrashInfo* iMultiCrashInfo;
- };
-
-
-
-#endif //__SCMONITOR_H__
-//EOF scmonitor.h
--- a/kernel/eka/debug/crashMonitor/inc/scmtrace.h Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// scmdatatypes.h
-//
-// WARNING: This file contains some APIs which are internal and are subject
-// to change without notice. Such APIs should therefore not be used
-// outside the Kernel and Hardware Services package.
-//
-
-
-#ifndef __SCMTRACE_H_INCLUDED__
-#define __SCMTRACE_H_INCLUDED__
-
-#ifdef _DEBUG
- #define __SCMFUNCTIONLOGGING __PRETTY_FUNCTION__
-#else
- #define __SCMFUNCTIONLOGGING ""
-#endif
-
-// logger macro
-#ifdef __KERNEL_MODE__
-
-#include <kernel/kernel.h>
-#include <nk_trace.h>
-
-#define LOG_CONTEXT //__KTRACE_OPT(KALWAYS, Kern::Printf("Context --> <%s>", __SCMFUNCTIONLOGGING));
-#define CLTRACE(s) __KTRACE_OPT(KDEBUGGER, Kern::Printf(s));
-#define CLTRACE1(s, p1) __KTRACE_OPT(KDEBUGGER, Kern::Printf(s, p1));
-#define CLTRACE2(s, p1, p2) __KTRACE_OPT(KDEBUGGER, Kern::Printf(s, p1, p2));
-#define CLTRACE3(s, p1, p2, p3) __KTRACE_OPT(KDEBUGGER, Kern::Printf(s, p1, p2, p3));
-#define CLTRACE4(s, p1, p2, p3, p4) __KTRACE_OPT(KDEBUGGER, Kern::Printf(s, p1, p2, p3, p4));
-#define CLTRACE5(s, p1, p2, p3, p4, p5) __KTRACE_OPT(KDEBUGGER, Kern::Printf(s, p1, p2, p3, p4, p5));
-
-#else
-
-#include <e32debug.h>
-
-#define LOG_CONTEXT RDebug::Printf("Context --> <%s>", __SCMFUNCTIONLOGGING);
-#define CLTRACE(s) RDebug::Printf(s) ;
-#define CLTRACE1(s, p1) RDebug::Printf(s, p1) ;
-#define CLTRACE2(s, p1, p2) RDebug::Printf(s, p1, p2) ;
-#define CLTRACE3(s, p1, p2, p3) RDebug::Printf(s, p1, p2, p3);
-#define CLTRACE4(s, p1, p2, p3, p4) RDebug::Printf(s, p1, p2, p3, p4);
-#define CLTRACE5(s, p1, p2, p3, p4, p5) RDebug::Printf(s, p1, p2, p3, p4, p5);
-
-
-#endif
-
-
-#endif /*__SCMTRACE_H_INCLUDED__*/
--- a/kernel/eka/debug/crashMonitor/src/arm/cscmdatasave.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\kernel\arm\cscmdatasave.cpp
-// SCM - Arm portion
-//
-//
-
-#define __INCLUDE_REG_OFFSETS__ // for SP_R13U in nk_plat.h
-
-
-#include "arm_mem.h"
-#include "nk_plat.h"
-#include <scmdatatypes.h>
-#include <scmdatasave.h>
-
-
-/**
- * Reads the CPU registers at the time of the crash
- * @param aRegs struct to store the resulting CPU registers
- */
-void SCMDataSave::ReadCPURegisters(SFullArmRegSet& aRegs)
- {
- aRegs =*(SFullArmRegSet*)iMonitor->iRegs;
- }
-
-/**
- * Reads the user registers for a given thread - may not be the current thread
- * @param aThread thread whose registers we want to read
- * @param aRegs registers will be written here if available
- * @return KErrArgument if aThread is the current thread or any of the system wide error codes
- */
-TInt SCMDataSave::ReadUserRegisters(DThread* aThread, TArmRegSet& aRegs, TUint32& aAvailableRegs)
- {
- TFileName filename;
- aThread->TraceAppendFullName(filename, EFalse);
-
- //we retrieve the registers differently for the current thread
- if(aThread == &Kern::CurrentThread())
- {
- return KErrArgument;
- }
-
- TUint32* stackPointer = (TUint32*)aThread->iNThread.iSavedSP; //Still need to check pointer somehow
- TUint32* stackTop = (TUint32*)((TUint32)aThread->iNThread.iStackBase +(TUint32)aThread->iNThread.iStackSize);
- TArmReg* out = (TArmReg*)(&aRegs);
-
- //Get a pointer to this threads context table
- NThread::TUserContextType type = aThread->iNThread.UserContextType();
- const TArmContextElement* table = aThread->iNThread.UserContextTables()[type];
-
- aAvailableRegs = 0;
- for(TInt i = 0; i<KArmRegisterCount; ++i)
- {
- TInt value = table[i].iValue;
- TInt type = table[i].iType;
-
- if(type == TArmContextElement::EOffsetFromSp)
- {
- value = stackPointer[value];
- aAvailableRegs |= (1<<i);
- }
- else if(type == TArmContextElement::EOffsetFromStackTop)
- {
- value = stackTop[-value];
- aAvailableRegs |= (1<<i);
- }
- else if(type == TArmContextElement::ESpPlusOffset)
- {
- value = (TInt)(stackPointer + value);
- aAvailableRegs |= (1<<i);
- }
-
- out[i] = value;
- }
-
- return KErrNone;
- }
-
-/**
- * Reads the system registers for a given thread
- * Can not be used on the current thread
- * @param aThread
- * @param aRegs
- * @param aAvailableRegs
- * @return KErrArgument if aThread is the current thread or any of the system wide error codes
- */
-TInt SCMDataSave::ReadSystemRegisters(DThread* aThread, TArmRegSet& aRegs, TUint32& aAvailableRegs)
- {
- if(aThread == &Kern::CurrentThread())
- {
- return KErrArgument;
- }
-
- TFileName filename;
- aThread->TraceAppendFullName(filename, EFalse);
-
- TUint32* stackPointer = (TUint32*)aThread->iNThread.iSavedSP;
- TUint32* stackTop = (TUint32*)((TUint32)aThread->iNThread.iStackBase +(TUint32)aThread->iNThread.iStackSize);
- TArmReg* out = (TArmReg*)(&aRegs);
-
- //Get a pointer to this threads context table
- const TArmContextElement* table = aThread->iNThread.UserContextTables()[NThread::EContextKernel];
-
- aAvailableRegs = 0;
- for(TInt i = 0; i<KArmRegisterCount; ++i)
- {
- TInt value = table[i].iValue;
- TInt type = table[i].iType;
-
- if(type == TArmContextElement::EOffsetFromSp)
- {
- //ensure we are still on the stack
- if(stackPointer + value >= stackTop)
- continue;
-
- value = stackPointer[value];
- aAvailableRegs |= (1<<i);
- }
- else if(type == TArmContextElement::EOffsetFromStackTop)
- {
- //ensure we are still on the stack
- if(stackTop - value < (TUint32*)aThread->iNThread.iStackBase)
- continue;
-
- value = stackTop[-value];
- aAvailableRegs |= (1<<i);
- }
- else if(type == TArmContextElement::ESpPlusOffset)
- {
- value = (TInt)(stackPointer + value);
- aAvailableRegs |= (1<<i);
- }
-
- out[i] = value;
- }
-
- return KErrNone;
- }
-
-//EOF
-
--- a/kernel/eka/debug/crashMonitor/src/crashlogwalker.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,535 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\crashlogwalker.cpp
-// Class to allow us to traverse the crash log generated by System Crash Monitor
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#ifndef __KERNEL_MODE__
-#include <e32std.h>
-#include <e32std_private.h>
-#include <e32base.h>
-#include <e32base_private.h>
-#endif
-
-#include "scmtrace.h"
-#include "crashlogwalker.h"
-
-namespace Debug
- {
- /**
- * Constructor for log walker
- * @param aBuffer The buffer containing the crash data
- */
- TCrashLogWalker::TCrashLogWalker(TDesC8& aBuffer) :
- iBuffer(aBuffer),
- iReader(const_cast<TUint8*>(iBuffer.Ptr()))
- {
- }
-
- /**
- * This reads in the crash header from the buffer from the given start point
- * @param aStartPoint Point to begin reading in buffer
- * @return One of the OS wide codes
- */
- TInt TCrashLogWalker::ReadLogHeader(const TInt aStartPoint)
- {
- iReader.SetPosition(aStartPoint);
-
- TInt err = iCrashHeader.Deserialize(iReader);
- if(err != KErrNone)
- {
- CLTRACE("(TCrashLogWalker::ReadLogHeader) - failed to read crash header");
- return KErrCorrupt;
- }
-
- err = iOffsets.Deserialize(iReader);
- if(err != KErrNone)
- {
- CLTRACE("(TCrashLogWalker::ReadLogHeader) - failed to read offsets");
- return KErrCorrupt;
- }
-
- TRegisterSet set;
- err = set.Deserialize(iReader);
- if(err != KErrNone)
- {
- CLTRACE("(TCrashLogWalker::ReadLogHeader) - failed to read register set");
- return KErrCorrupt;
- }
-
- for(TInt cnt = 0; cnt < set.iNumRegisters; cnt++)
- {
- TRegisterValue val;
- err = val.Deserialize(iReader);
- if(err != KErrNone)
- {
- CLTRACE1("(TCrashLogWalker::ReadLogHeader) - failed to read TRegisterValue cnt = %d", cnt);
- return KErrCorrupt;
- }
-
- HelpAssignRegisterToContext(val);
- }
-
- return VerifyHeader();
- }
-
- /**
- * Getter for the crash context - This is the CPU register set at the time of crash
- * @return Crash Context
- */
- const TRmdArmExcInfo& TCrashLogWalker::GetCrashContext() const
- {
- return iContext;
- }
-
- /**
- * Returns the crash size for the crash that has just been read, provided the
- * reading of the header was succesful.
- * @see ReadLogHeader
- * @return Crash Log size
- */
- TInt TCrashLogWalker::GetCrashSize() const
- {
- return iCrashHeader.iLogSize;
- }
-
- /**
- * Returns the crash ID for the crash that has just been read, provided the
- * reading of the header was succesful.
- * @see ReadLogHeader
- * @return Crash Log ID
- */
- TInt TCrashLogWalker::GetCrashId() const
- {
- return iCrashHeader.iCrashId;
- }
-
- /**
- * Looks at the member crash log header and checks that it is valid.
- * @see ReadLogHeader
- * @return one of the OS wide codes
- */
- TInt TCrashLogWalker::VerifyHeader()
- {
- if(iCrashHeader.iId == ESCMTCrashInfo)
- {
- CLTRACE("TCrashLogWalker::VerifyHeader() OK");
- return KErrNone;
- }
- else
- {
- CLTRACE("TCrashLogWalker::VerifyHeader() FAILED");
- return KErrCorrupt;
- }
- }
-
- /**
- * Updates the buffer being used by the crash walker and resets reader to use
- * the beginning of this
- * @param aBuffer New buffer
- */
- void TCrashLogWalker::UpdateBuffer(TDesC8& aBuffer)
- {
- iBuffer = aBuffer;
-
- //Read from start of this buffer
- iReader = TByteStreamReader(const_cast<TUint8*>(aBuffer.Ptr()));
- }
-
-#ifndef __KERNEL_MODE__
- /**
- * Gets the next data type from the buffer. If this is NULL it means the buffer was too small.
- * Call again with a larger buffer. It assumes the buffer contains valid data and leaves with KErrCorrupt
- * if it isnt. Note for raw data types, the data will be empty. This should be read with GetRawDataTypeL after reseting the reader to the
- * correct position. If you just want to skip a raw data type, move the buffer along the size of (contained in the returned struct)
- *
- * @see GetRawDataTypeL
- * @see UpdateBuffer
- * @param aPos Next position that will be read. If we return NULL, this is the position the next buffer should
- * begin from
- * @param aId ID of the MByteStreamSerializable returned
- * @param buffer size to be used the next time. Unchanged if the current buffer is ok
- * @return MByteStreamSerializable pointer. Ownership is passed to caller. NULL if failed
- * @leave KErrCorrupt if the buffer cant be read
- */
- MByteStreamSerializable* TCrashLogWalker::GetNextDataTypeL(TInt& aPos, SCMStructId& aId, TInt& aBufferSize)
- {
- MByteStreamSerializable* data = NULL;
-
- TInt roomInBuffer = iBuffer.Length() - iReader.CurrentPosition();
- //make sure we have at LEAST 4 bytes in the buffer
- if(roomInBuffer < (TInt)(sizeof(TInt)))
- {
- aBufferSize = sizeof(TInt);
- return NULL;
- }
-
- //this stores the required size in which to deserialize a structure - to make sure
- //there is room in the buffer
- TInt maxSize = 0;
- aPos = iReader.CurrentPosition();
- aBufferSize = iBuffer.Length();
-
- //all these data types are defined by their first byte
- aId = (SCMStructId)iBuffer.Ptr()[iReader.CurrentPosition()];
-
- //ensure we have a valid structure found
- if(aId <= 0 || aId >= ESCMLast)
- {
- //oddness is afoot and the mist of corruption reigns thick
- User::Leave(KErrCorrupt);
- }
-
- switch(aId)
- {
- case ESCMOffsetsHeader:
- {
- data = new TCrashOffsetsHeader();
- maxSize = TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize;
- break;
- }
- case ESCMTCrashInfo:
- {
- data = new TCrashInfoHeader();
- maxSize = TCrashInfoHeader::KSCMCrashInfoMaxSize;
- break;
- }
- case ESCMProcessData:
- {
- data = new TProcessData();
- maxSize = TProcessData::KSCMProcessDataMaxSize;
- break;
- }
- case ESCMThreadData:
- {
- data = new TThreadData();
- maxSize = TThreadData::KSCMThreadDataMaxSize;
- break;
- }
- case ESCMThreadStack:
- {
- data = new TThreadStack();
- maxSize = TThreadStack::KSCMThreadStackMaxSize;
- break;
- }
- case ESCMRegisterValue:
- {
- data = new TRegisterValue();
- maxSize = TRegisterValue::KSCMRegisterValueMaxSize;
- break;
- }
- case ESCMRegisterSet:
- {
- data = new TRegisterSet();
- maxSize = TRegisterSet::KSCMRegisterSetMaxSize;
- break;
- }
- case ESCMMemory:
- {
- data = new TMemoryDump();
- maxSize = TMemoryDump::KSCMMemDumpMaxSize;
- break;
- }
- case ESCMCodeSegSet:
- {
- data = new TCodeSegmentSet();
- maxSize = TCodeSegmentSet::KSCMCodeSegSetMaxSize;
- break;
- }
- case ESCMCodeSeg:
- {
- data = new TCodeSegment();
- maxSize = TCodeSegment::KMaxSegmentNameSize;
- break;
- }
- case ESCMLocks:
- {
- data = new TSCMLockData();
- maxSize = TSCMLockData::KSCMLockDataMaxSize;
- break;
- }
- case ESCMVariantData:
- {
- data = new TVariantSpecificData();
- maxSize = TVariantSpecificData::KSCMVarSpecMaxSize;
- break;
- }
- case ESCMRomHeader:
- {
- data = new TRomHeaderData();
- maxSize = TRomHeaderData::KSCMRomHdrMaxSize;
- break;
- }
- case ESCMRawData:
- {
- data = new TRawData();
-
- //This is a special case. The data in here can be any length, so we need to deserialise it
- //to find this length out. The MAX_SIZE of this class is the max size minus data
- //which is fine if we dont assign the TPtr8.
- if(TRawData::KSCMRawDataMaxSize > roomInBuffer )
- {
- aBufferSize = (maxSize > aBufferSize) ? maxSize : aBufferSize;
-
- if(data)
- delete data;
-
- return NULL;
- }
- else
- {
- data->Deserialize(iReader);
- maxSize = data->GetSize();
-
- aPos = iReader.CurrentPosition();
- return data;
- }
- }
- case ESCMTraceData:
- {
- data = new TTraceDump();
- maxSize = TTraceDump::KSCMTraceDumpMaxSize;
- break;
- }
- default :
- {
- User::Panic(_L("Unexpected Null. Unrecognised Data type from crash log."), KErrGeneral); //Programming error
- }
- }
-
- __ASSERT_ALWAYS((data != NULL), User::Panic(_L("Unexpected Null"), KErrGeneral));
-
- if(maxSize > roomInBuffer )
- {
- //Not enough room in buffer to read this. Tell caller where in the current buffer
- //we were via aPos, and what minimum size buffer should be used next time to allow reading
- aBufferSize = maxSize;
- if(data)
- {
- delete data;
- }
-
- return NULL;
- }
-
- if(!data)
- {
- CLTRACE("Unable to create data structure");
- User::Leave(KErrAbort);
- }
-
- data->Deserialize(iReader);
- aPos = iReader.CurrentPosition();
-
- return data;
- }
-
- /**
- * Assuming the next type in the buffer is a TRawData type, this will return the TRawData
- * types data pointer pointing to the buffer passed via aRawBuf.
- *
- * The difference between this call and GetNextDataTypeL is that GetNextDataTypeL only lets you move along the buffer
- * it doesnt allow you to specify a buffer in which to store the raw data.
- *
- * @see GetNextDataTypeL
- * @return TRawData* This is the TRawData object that holds the data via the buffer passed in. Ownership is passed to the caller
- * @param aPos position in buffer its been found. If we return NULL, this is the position the next buffer should
- * begin from
- * @param aBufferSize Should we return NULL, that means the descriptor passed in was not big enough and should be of at least aBufferSize bytes
- * @param aRawBuf The buffer to store the data refered to by the TRawData returned
- * @param aStartRawPosition The point in the raw data at which we will start to put it into the buffer
- * @leave One of the OS wide codes
- */
- TRawData* TCrashLogWalker::GetRawDataTypeL(TInt& aPos, TInt& aBufferSize, TDes8& aRawBuf, TInt aStartRawPosition)
- {
- //make sure we have at LEAST the size of the struct in the buffer
- if(iBuffer.Length() < TRawData::KSCMRawDataMaxSize)
- {
- aBufferSize = TRawData::KSCMRawDataMaxSize;
- return NULL;
- }
-
- //this stores the required size in which to deserialize a structure - to make sure
- //there is room in the buffer
- aPos = iReader.CurrentPosition();
- aBufferSize = iBuffer.Length();
-
- //all these data types are defined by their first byte
- TInt id = (SCMStructId)iBuffer.Ptr()[iReader.CurrentPosition()];
- if(id != ESCMRawData)
- {
- User::Leave(KErrCorrupt);
- }
-
- //Deserialise once to get the length (this will ignore the data in the absence of a Tptr)
- TRawData* data = new TRawData();
- data->Deserialize(iReader);
-
- //reset reader to where the raw data starts again
- iReader.SetPosition(aPos);
-
- //now we know we have room, deserialize into this descriptor
- aRawBuf.SetMax();
- data->iData.Set(aRawBuf.MidTPtr(0));
- User::LeaveIfError(data->Deserialize(aStartRawPosition, iReader));
-
- return data;
- }
-
-#endif
-
- /**
- * This is a helper function to convert between the two formats of register
- * @param aRegVal Resulting register values
- */
- void TCrashLogWalker::HelpAssignRegisterToContext(const TRegisterValue& aRegVal)
- {
- //only interested in core registers at the moment
- if(aRegVal.iClass != 0 || aRegVal.iSize != 2)
- {
- return;
- }
-
- //Is there a cleverer way to do this with bitmasks and FOFF ?
- switch(aRegVal.iType)
- {
- case 0x0 :
- {
- iContext.iR0 = aRegVal.iValue32;
- break;
- }
- case 0x100 :
- {
- iContext.iR1 = aRegVal.iValue32;
- break;
- }
- case 0x200 :
- {
- iContext.iR2 = aRegVal.iValue32;
- break;
- }
- case 0x300 :
- {
- iContext.iR3 = aRegVal.iValue32;
- break;
- }
- case 0x400 :
- {
- iContext.iR4 = aRegVal.iValue32;
- break;
- }
- case 0x500 :
- {
- iContext.iR5 = aRegVal.iValue32;
- break;
- }
- case 0x600 :
- {
- iContext.iR6 = aRegVal.iValue32;
- break;
- }
- case 0x700 :
- {
- iContext.iR7 = aRegVal.iValue32;
- break;
- }
- case 0x800 :
- {
- iContext.iR8 = aRegVal.iValue32;
- break;
- }
- case 0x900 :
- {
- iContext.iR9 = aRegVal.iValue32;
- break;
- }
- case 0xa00 :
- {
- iContext.iR10 = aRegVal.iValue32;
- break;
- }
- case 0xb00 :
- {
- iContext.iR11 = aRegVal.iValue32;
- break;
- }
- case 0xc00 :
- {
- iContext.iR12 = aRegVal.iValue32;
- break;
- }
- case 0xd00 :
- {
- iContext.iR13 = aRegVal.iValue32;
- break;
- }
- case 0xe00 :
- {
- iContext.iR14 = aRegVal.iValue32;
- break;
- }
- case 0xf00 :
- {
- iContext.iR15 = aRegVal.iValue32;
- break;
- }
- case 0x1000 :
- {
- iContext.iCpsr = aRegVal.iValue32;
- break;
- }
- case 0x1100 :
- {
- iContext.iR13Svc = aRegVal.iValue32;
- break;
- }
- case 0x1200 :
- {
- iContext.iR14Svc = aRegVal.iValue32;
- break;
- }
- default :
- {
- return;
- }
- }
- }
-
- /**
- * Getter for crash header
- * @return header
- */
- const TCrashInfoHeader& TCrashLogWalker::GetCrashHeader() const
- {
- return iCrashHeader;
- }
-
- /**
- * Getter for crash offsets header
- * @return header
- */
- const TCrashOffsetsHeader& TCrashLogWalker::GetOffsetsHeader() const
- {
- return iOffsets;
- }
-
- }
-//eof
-
--- a/kernel/eka/debug/crashMonitor/src/scmbytestreamutil.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmbytestreamutil.cpp
-// some utility classes for writing data to flash buffer
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-
-#include "scmbytestreamutil.h"
-#include "scmtrace.h"
-
-
-
-namespace Debug
- {
- /**
- * TByteStreamBase Constructor
- * @param aBuffer - pointer to buffer that this utility will use
- */
- TByteStreamBase::TByteStreamBase(TUint8* aBuffer)
- : iBuffer(aBuffer)
- , iPos(0)
- {
- }
-
- /**
- * SetPosition
- * @param aBuffer - Sets iPos
- * @return void
- */
- void TByteStreamBase::SetPosition(TInt aPos)
- {
- iPos = aPos;
- }
-
- /**
- * CurrentPosition
- * @param aBuffer - Returns the current value of iPos
- * @return Tint
- */
- TInt TByteStreamBase::CurrentPosition() const
- {
- return iPos;
- }
-
- /**
- * TByteStreamReader Constructor
- * @param aBuffer - pointer to buffer that this utility will use
- */
- TByteStreamReader::TByteStreamReader(TUint8* aBuffer)
- : TByteStreamBase(aBuffer)
- {
- }
-
-
- /**
- * Constructor for TByteStreamWriter
- * @param aBuffer buffer for writing
- * @param aPhysEnabled whether or not physical writing to another media is enabled
- */
- TByteStreamWriter::TByteStreamWriter(TUint8* aBuffer, TBool aPhysEnabled)
- : TByteStreamBase(aBuffer)
- , iPhysEnabled(aPhysEnabled)
- , iBytesWritten(0)
- {
- }
-
- /**
- * Writes a byte to the buffer
- * @param aValue Byte to write
- */
- void TByteStreamWriter::WriteByte(TUint8 aValue)
- {
- if(iBuffer)
- {
- iBuffer[iPos++] = aValue;
- ++iBytesWritten;
- }
- }
-
- /**
- * Resets the byte counter back to zero
- */
- void TByteStreamWriter::ResetBytesWritten()
- {
- iBytesWritten = 0;
- }
-
- /**
- * TCachedByteStreamWriter Constructor
- * @param aBuffer - pointer to buffer that this utility will use
- * @param aCacheSize - suggested length of cache to use if greater than EMaxCache
- * cache length of EMaxCache will be used
- */
- TCachedByteStreamWriter::TCachedByteStreamWriter(TUint8* aCacheBuffer, TInt aCacheSize, TBool aPhysEnabled)
- : TByteStreamWriter(NULL, aPhysEnabled)
- , iCacheSize(aCacheSize)
- , iCacheBuffer(aCacheBuffer)
- , iPhysicalWriter(NULL)
- {
- }
-
-
- /**
- * FlushCache
- * Writes the contents of the cache to buffer amd/or to physical writer implementation
- * if one is currently set
- * @return void
- */
- TInt TCachedByteStreamWriter::FlushCache()
- {
- TInt padCount = iCacheSize - iPos;
- if(padCount > 0)
- {
- for(TInt i=0;i<padCount;i++)
- {
- iCacheBuffer[iPos++] = 0;
- }
- }
-
- if(iPhysEnabled)
- {
- if(iPhysicalWriter) // do we have a writer to send the cache data to
- {
- iPhysicalWriter->DoPhysicalWrite(iCacheBuffer, iBytesWritten, iPos);
- }
- }
-
- iPos = 0;
- return KErrNone;
- }
-
- /**
- * Writes a byte to the cached buffer
- * @param aValue Byte to write
- */
- void TCachedByteStreamWriter::WriteByte(TUint8 aValue)
- {
- if(iPos == iCacheSize)
- {
- FlushCache();
- }
- iCacheBuffer[iPos++] = aValue;
- ++iBytesWritten;
- }
-
- /**
- * CurrentPosition
- * @param aBuffer - need to return the position in buffer plus the write pos into cache
- * @return Tint
- */
- TInt TCachedByteStreamWriter::CurrentPosition() const
- {
- return iBytesWritten;
- }
-
- /**
- * SetWriterImpl
- * @param aPhysicalWriter - sets the physical writer implementation to be used when the cache is flushed
- * pass NULL to remove a previous writer implementation
- * @return void
- */
- void TCachedByteStreamWriter::SetWriterImpl(MPhysicalWriterImpl* aPhysicalWriter)
- {
- iPhysicalWriter = aPhysicalWriter;
- }
- }
-
-//eof
-
--- a/kernel/eka/debug/crashMonitor/src/scmchksum.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,168 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmchksum.cpp
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#include <scmdatatypes.h>
-
-namespace Debug
- {
- /**
- * Constructor
- */
- TScmChecksum::TScmChecksum()
- : iLength(0)
- , iSum(0)
- , iZeroCount(0)
- {
- }
-
- /**
- * ChecksumBlock - calculate checksum values for given data
- * @param aData - the data to checksum
- * @param aLen - the length of the data to checksum
- * @return void
- */
- void TScmChecksum::ChecksumBlock(const TUint8* aData, TUint aLen)
- {
- /**
- *
- * Note there is Symbian CRC implementation to be found in the following
- * \src\cedar\generic\tools\e32tools\elf2e32\source\checksum.h
- * \src\cedar\generic\tools\e32tools\elf2e32\source\checksum.cpp
- * this however may be no good to us
- * as we need to produce a single checksum even though the entire data may be
- * read in different size blocks - and the entire data may not be available
- * (the comm port requirement is for read only )
- * If we do however want to use the CRC then this is the place to insert the code
- */
- if(!aData)
- {
- return;
- }
-
- for(TUint i=0;i<aLen;i++)
- {
- TUint8 val = *(aData+i);
-
- iLength++;
- if(val == 0)
- {
- iZeroCount++;
- }
- else
- {
- iSum += val;
- }
- }
- }
-
- /**
- * ChecksumBlock - calculate checksum values for given data
- * @param aData - descriptor containing the data to checksum
- * @return void
- */
- void TScmChecksum::ChecksumBlock(const TDesC8& aDes)
- {
- ChecksumBlock(aDes.Ptr(), aDes.Length());
- }
-
- /**
- * ChecksumBlock - operator ==
- * @param aOther - the TScmChecksum to compare too
- * @return ETrue is objects match - otherwise EFalse
- */
- TBool TScmChecksum::operator == (const TScmChecksum& aOther) const
- {
- return (iLength == aOther.iLength && iSum == aOther.iSum && iZeroCount == aOther.iZeroCount);
- }
-
- /**
- * ChecksumBlock - operator !=
- * @param aOther - the TScmChecksum to compare too
- * @return EFalse if objects match - otherwise ETrue
- */
- TBool TScmChecksum::operator != (const TScmChecksum& aOther) const
- {
- return !(*this == aOther);
- }
-
- /**
- * GetSize
- * @return size of this object when streamed in bytes
- */
- TInt TScmChecksum::GetSize() const
- {
- return 12;
- }
-
- /**
- * Serialize - writes this object to the supplied byte stream
- * @param aItem - aWriter - the TByteStreamWriter that will be written to
- * @return One of the OS wide codes
- */
- TInt TScmChecksum::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
- aWriter.WriteInt(iLength);
- aWriter.WriteInt(iSum);
- aWriter.WriteInt(iZeroCount);
- TInt sizeWritten = aWriter.CurrentPosition() - startPos;
- if(sizeWritten != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TScmChecksum serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
-
- /**
- * Deserialize - read this objects state from the supplied byte stream
- * @param aItem - aReader - the TByteStreamReader that will be read from
- * @return One of the OS wide codes
- */
- TInt TScmChecksum::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
- // do we need a version check here - will it change ?
- iLength = aReader.ReadInt();
- iSum = aReader.ReadInt();
- iZeroCount = aReader.ReadInt();
-
- TInt sizeRead = aReader.CurrentPosition() - startPos;
- if(sizeRead != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TScmChecksum Deserialization size error");
- return KErrCorrupt;
- }
- return KErrCorrupt;
- }
-
-
- void TScmChecksum::Reset()
- {
- iLength = iSum = iZeroCount = 0;
- }
- }
-//eof
-
--- a/kernel/eka/debug/crashMonitor/src/scmconfig.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,458 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmconfig.cpp
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#include <e32err.h>
-#include <e32const.h>
-#include <e32const_private.h>
-
-#include <scmconfig.h>
-#include <scmconfigitem.h>
-#include <scmdatatypes.h>
-
-namespace Debug
- {
- /**
- * SCMConfiguration constructor
- * Initialises the configuration object to default values
- */
- SCMConfiguration::SCMConfiguration()
- : iConfigList(NULL)
- {
- }
-
- /**
- * SCMConfiguration destructor
- */
- SCMConfiguration::~SCMConfiguration()
- {
- ClearList();
- }
-
- /**
- * Goes to the flash and reads the configuration block and populates the object state
- * accordingly
- * @return one of the system wide error codes
- */
- TInt SCMConfiguration::Deserialize(TByteStreamReader& aReader)
- {
- if( !iConfigList)
- {
- // we need to set up a default configuration to load the data into
- TInt err = SetDefaultConfig();
- if(err != KErrNone)
- {
- CLTRACE1("SCMConfiguration::Deserialize SetDefaultConfig failed err = %d", err);
- return err;
- }
- }
-
- TInt startPos = aReader.CurrentPosition();
-
- TBuf8<10> magicNumbers;
- // try and read the magic numbers - if they dont exist then
- // there is not an scm config there
- const TInt KLen = KScmConfigHeaderString().Length();
- for(TInt i=0;i<KLen;i++)
- {
- TUint8 b = aReader.ReadByte();
- magicNumbers.Append(TChar(b));
- }
-
- if(magicNumbers.Compare(KScmConfigHeaderString()) != 0)
- {
- CLTRACE("No scm, config to read !");
- return KErrNotReady;
- }
-
- TConfigItem* item = iConfigList;
- while(item)
- {
- item->Deserialize(aReader);
- item = item->iNext;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("SCMConfiguration::Deserialize size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * This writes the current configuration object state to flash. This configuration will be used on the next crash
- * @return one of the system wide error codes
- */
- TInt SCMConfiguration::Serialize(TByteStreamWriter& aWriter)
- {
- if( !iConfigList)
- {
- CLTRACE("SCMConfiguration::Serialize ERROR - NO LIST!!");
- return KErrNotReady;
- }
-
- TInt startPos = aWriter.CurrentPosition();
-
- // write the number of crashes and magic numbers
-
- // try and read the magic numbers - if they dont exist then
- // there is not an scm config there
- const TInt KLen = KScmConfigHeaderString().Length();
- const TDesC8& des = KScmConfigHeaderString();
- for(TInt i=0;i<KLen;i++)
- {
- aWriter.WriteByte(des[i]);
- }
-
- TConfigItem* item = iConfigList;
- while(item)
- {
- item->Serialize(aWriter);
- item = item->iNext;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("SCMConfiguration::Serialize size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns entire size of the SCMConfiguration block
- * @return Size
- */
- TInt SCMConfiguration::GetSize() const
- {
- // returns the size of all the config items when serialized to disk / flash
- return (TConfigItem::ELast * iConfigList->GetSize()) + KScmConfigHeaderString().Length();
- }
-
- /**
- * This will return, one at a time, the highest priority.
- * @see ResetToHighestPriority()
- * @param aSizeToDump this will contain the size in bytes of data to dump for this type - 0 means dump all
- * @return Data type to dump
- */
- TConfigItem* SCMConfiguration::GetNextItem()
- {
- if(!iNextItem)
- {
- return NULL;
- }
-
- //get the values we need
- TConfigItem* item = iNextItem;
-
- //Now move iNextItem to be next in the list
- iNextItem = iNextItem->iNext;
- return item;
- }
-
- /**
- * Deletes the linked list
- * @return system wide OS code
- */
- void SCMConfiguration::ClearList()
- {
- if(!iConfigList)
- {
- return;
- }
-
- //all we need to do in here is delete the members of our linked list
- TConfigItem* item = iConfigList;
-
- do{
- TConfigItem* tmp = item->iNext;
- delete item;
- item = tmp;
- }
- while(item != NULL);
-
- iConfigList = NULL;
- }
-
- /**
- * Rather than reading the configuration from the flash, this method sets up the configuration object
- * to a default configuration type
- * @return one of the system wide error codes
- */
- TInt SCMConfiguration::SetDefaultConfig()
- {
- //flush the object first
- ClearList();
-
- //This is a predefined default config - in the future we may have multiple defaults based on use case
- // currently however we use a fixed size list of config items of size TConfigItem::ELast
- // also the TSCMDataType of each item must be unique
-
- for(TInt cnt = TConfigItem::ELast - 1; cnt >= 0; cnt --)
- {
- TInt priority = cnt + 1;
-
- //Lets not do these by default
- if((TConfigItem::TSCMDataType)cnt == TConfigItem::EThreadsUsrStack || (TConfigItem::TSCMDataType)cnt == TConfigItem::EThreadsSvrStack)
- {
- priority = 0;
- }
-
- //set it with the priority of its enum (ie. assume that the enum is listed in its priority - it is)
- //by default dump everything until we run out of space
- TInt err = CreateConfigItem((TConfigItem::TSCMDataType)cnt, priority, 0);
- if(KErrNone != err)
- {
- return err;
- }
- }
-
- return KErrNone;
- }
-
- /**
- * This configures the required data for a given configuration item
- * Note that aSizeToDump is only used in the case of memory dumps such as stacks
- * @param aDataType - Type of data to dump
- * @param aPriority - its priority 0-256. 0 Means do not dump and 256 is highest priority
- * @param aSizeToDump - amount in bytes to dump. Only relevant for memory dumps and ignored when aPriority is 0
- * @return one of the OS wide return codes
- */
- TInt SCMConfiguration::CreateConfigItem(const TConfigItem::TSCMDataType aDataType, const TUint8 aPriority, const TInt32 aSizeToDump)
- {
- //create the config item
- TConfigItem* item = new TConfigItem(aDataType, aPriority, aSizeToDump);
-
- //insert to priority list
- return InsertToList(item);
- }
-
-
- /**
- * ModifyConfigItemPriority - modifies prioity for a given configuration item
- * @param aDataType - The unique type of the config item
- * @param aPriority - its priority 0-256. 0 Means do not dump and 256 is highest priority
- * @return one of the OS wide return codes
- */
- TInt SCMConfiguration::ModifyConfigItemPriority(const TConfigItem::TSCMDataType aDataType, const TUint8 aPriority)
- {
-
- // find the item with the matching data type
- TConfigItem* item = iConfigList;
- while(item)
- {
- if(item->iDataType == aDataType)
- {
- break;
- }
- item = item->iNext;
- }
-
- if(!item)
- {
- return KErrNotFound;
- }
-
- item->iPriority = aPriority;
-
- // now reorder the list according to new priority
- TInt err = RemoveFromList(item);
- if(err != KErrNone)
- {
- return err;
- }
-
- err = InsertToList(item);
-
- if(err != KErrNone)
- {
- return err;
- }
-
- return KErrNone;
- }
-
-/**
- * Removes item from the linked list
- * @param aItem - item to remove
- * @return OS code
- */
-TInt SCMConfiguration::RemoveFromList(TConfigItem* aItem)
- {
- if(!aItem)
- {
- return KErrArgument;
- }
-
- if(!iConfigList)
- {
- return KErrCorrupt; // oops no list to remove
- }
-
-
- if(aItem == iConfigList)
- {
- // special case remove from beginning of list
- iConfigList = iConfigList->iNext;
- return KErrNone;
- }
-
- TConfigItem* item = iConfigList;
- while(item)
- {
- // is the next item the match ?
- if(item->iNext == aItem)
- {
- item->iNext = aItem->iNext;
- return KErrNone;
- }
- item = item->iNext;
- }
-
- return KErrNotFound;
- }
-
-/**
- * Inserts a priority item into the linked list in its correct location
- * @param aItem - item to insert
- * @return OS code
- */
-TInt SCMConfiguration::InsertToList(TConfigItem* aItem)
- {
-
- //if the list is empty, then this is the only item
- if(!iConfigList)
- {
- iConfigList = aItem;
- return KErrNone;
- }
-
- //should it go at the start? special case not covered by while loop
- TConfigItem* temp;
-
- if(aItem->iPriority >= iConfigList->iPriority)
- {
- temp = iConfigList;
- iConfigList = aItem;
- aItem->iNext = temp;
- return KErrNone;
- }
-
- TConfigItem* item = iConfigList;
-
- do{
- //if we get to the end of the list and the item still hasnt been assigned then it must be lowest priority
- if(item->iNext == NULL)
- {
- item->iNext = aItem;
- return KErrNone;
- }
-
- //check if its priority is between these
- if(aItem->iPriority < item->iPriority && aItem->iPriority >= item->iNext->iPriority)
- {
- //insert between these nodes
- temp = item->iNext;
- item->iNext = aItem;
- aItem->iNext = temp;
- return KErrNone;
- }
-
- item = item->iNext;
- }
- while(item != NULL);
-
- //should never get here
- return KErrUnknown;
- }
-
-/**
- * This resets the next item counter back to the highest priority item in the list
- */
-void SCMConfiguration::ResetToHighestPriority()
- {
- //set the next item counter back to the head of the list
- iNextItem = iConfigList;
- }
-
-/**
- * Overloaded == operator
- * @param aOther Item to compare
- * @return
- */
-TBool SCMConfiguration::operator == (const SCMConfiguration& aOther) const
- {
-
- if(!iConfigList && !aOther.iConfigList)
- {
- return ETrue;
- }
-
- if((!iConfigList && aOther.iConfigList) || (iConfigList && !aOther.iConfigList))
- {
- return EFalse;
- }
-
-
- TConfigItem* item1 = iConfigList;
- TConfigItem* item2 = aOther.iConfigList;
-
- while(item1 && item2)
- {
- if(!(*item1 == *item2))
- {
- return EFalse;
- }
-
- item1 = item1->iNext;
- item2 = item2->iNext;
- }
-
- if( item1 != item2) // both should now be null - if not then lists were different lengths
- {
- return EFalse;
- }
-
- return ETrue;
-
- }
-
-/**
- * Getter for the head of the SCMConfig list
- * @return Head of List
- */
-TConfigItem* SCMConfiguration::ConfigList() const
- {
- // returns the head of the list
- return iConfigList;
- }
-} //End of debug namespace
-
-//eof
-
-
-
-
--- a/kernel/eka/debug/crashMonitor/src/scmconfigitem.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,264 +0,0 @@
-// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmconfigitem.cpp
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-#include <e32def.h>
-#include <e32def_private.h>
-
-#include <scmconfigitem.h>
-#include <scmdatatypes.h>
-#include <scmtrace.h>
-
-namespace Debug
- {
-
-/**
- * TConfigItem constructor
- */
-TConfigItem::TConfigItem()
-: iDataType(ELast)
-, iSizeToDump(0)
-, iSpaceRequiredToDump(0)
-, iPriority(0)
-, iNext(NULL)
- {
- }
-
-/**
- * TConfigItem constructor
- * @param aDataType - data type id
- * @param aSizeToDump - size of the config data
- * @param aPriority - priority of this data type (if 0 then not used)
- */
-TConfigItem::TConfigItem(TSCMDataType aDataType, TUint8 aPriority, TInt32 aSizeToDump)
-: iDataType(aDataType)
-, iSizeToDump(aSizeToDump)
-, iPriority(aPriority)
-, iNext(NULL)
- {
- }
-
-/**
- * Serialize - writes this object to the supplied byte stream
- * @param aItem - aWriter - the TByteStreamWriter that will be written to
- * @return one of the OS wide codes
- */
-TInt TConfigItem::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- aWriter.WriteByte((TUint8)iDataType);
- aWriter.WriteInt(iSizeToDump);
- aWriter.WriteByte(iPriority);
-
- TInt sizeWritten = aWriter.CurrentPosition() - startPos;
- if(sizeWritten != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE2("TConfigItem serialization size error sizeWritten %d GetSize() %d", sizeWritten, GetSize());
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
-
-/**
- * Deserialize - read this objects state from the supplied byte stream
- * @param aItem - aReader - the TByteStreamReader that will be read from
- * @return One of the OS wide codes
- */
-TInt TConfigItem::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iDataType = (TSCMDataType) aReader.ReadByte();
- iSizeToDump = aReader.ReadInt();
- iPriority = aReader.ReadByte();
-
- TInt sizeRead = aReader.CurrentPosition() - startPos;
- if(sizeRead != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("(TConfigItem::Deserialize) ERROR size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
-
-/**
- * GetDataType
- * @return data type of this config item
- */
- TConfigItem::TSCMDataType TConfigItem::GetDataType() const
- {
- return iDataType;
- }
-
-/**
- * GetPriority
- * @return priority of this config item (0-255)
- */
-TInt TConfigItem::GetPriority() const
- {
- return iPriority;
- }
-
-/**
- * GetSize
- * @return size to dump in bytes
- */
-TInt TConfigItem::GetSizeToDump() const
- {
- return iSizeToDump;
- }
-
-/**
- * GetSize
- * @return size of this object when streamed in bytes
- */
-TInt TConfigItem::GetSize() const
- {
- return 6;
- }
-
-
-
-/**
- * Returns next item
- * @return Next item
- */
-TConfigItem* TConfigItem::Next() const
- {
- return iNext;
- }
-
- /**
- * Print - displays info about this TConfigItem
- * @return void
- */
- void TConfigItem::Print() const
- {
- CLTRACE3( "(TConfigItem::Print) iDataType = %d iPriority = %d iSizeToDump = %d"
- , iDataType, iPriority, iSizeToDump);
- }
-
- TBool TConfigItem::operator == (const TConfigItem& aOther) const
- {
- return (iDataType == aOther.iDataType && iSizeToDump == aOther.iSizeToDump && iPriority == aOther.iPriority);
- }
-
-/**
- * Sets the space required parameter for this config item
- * @param aSpaceReq Space required
- */
-void TConfigItem::SetSpaceRequired(TUint aSpaceReq)
- {
- iSpaceRequiredToDump = aSpaceReq;
- }
-
-/**
- * Gets the space required to store this config item
- * @return
- */
-TUint TConfigItem::GetSpaceRequired()
- {
- return iSpaceRequiredToDump;
- }
-
-#ifndef __KERNEL_MODE__
-
-// human readable strings for TSCMDataType
-_LIT(KExceptionStacks, "Exception Stacks");
-_LIT(KTraceData, "Trace data");
-_LIT(KProcessCodeSegs, "ProcessCodeSegs");
-_LIT(KThreadsUsrStack, "Threads UserStack");
-_LIT(KThreadsSvrStack, "Threads Supervisor Stack");
-_LIT(KKernelHeap, "Kernel Heap");
-_LIT(KThreadsUsrRegisters, "Threads User Registers");
-_LIT(KThreadsSvrRegisters, "Threads Supervisor Registers");
-_LIT(KProcessMetaData, "Process Meta Data");
-_LIT(KThreadsMetaData, "Threads Meta Data");
-_LIT(KCrashedProcessCodeSegs, "Crashed Process Code Segs");
-_LIT(KCrashedProcessUsrStacks, "Crashed Process' User Stack's");
-_LIT(KCrashedProcessSvrStacks, "Crashed Process' Supervisor Stack's");
-_LIT(KCrashedProcessMetaData, "Crashed Process Meta Data");
-_LIT(KCrashedThreadMetaData, "Crashed Thread Meta Data");
-_LIT(KLocks, "SCM Locks");
-_LIT(KVariantSpecific, "Variant Specific Data");
-_LIT(KRomInfo, "ROM Info");
-_LIT(KUnknown, "Unknown");
-
-/**
- * helper function for converting TSCMDataType enul to human readable form
- */
- const TDesC& TConfigItem::GetSCMConfigOptionText(TConfigItem::TSCMDataType aType)
- {
- switch (aType)
- {
- case TConfigItem::EExceptionStacks:
- return KExceptionStacks;
- case TConfigItem::ETraceData:
- return KTraceData;
- case TConfigItem::EProcessCodeSegs:
- return KProcessCodeSegs();
- case TConfigItem::EThreadsUsrStack:
- return KThreadsUsrStack();
- case TConfigItem::EThreadsSvrStack:
- return KThreadsSvrStack;
- case TConfigItem::EThreadsUsrRegisters:
- return KThreadsUsrRegisters();
- case TConfigItem::EThreadsSvrRegisters:
- return KThreadsSvrRegisters();
- case TConfigItem::EProcessMetaData:
- return KProcessMetaData();
- case TConfigItem::EThreadsMetaData:
- return KThreadsMetaData();
- case TConfigItem::ECrashedProcessCodeSegs:
- return KCrashedProcessCodeSegs();
- case TConfigItem::ECrashedProcessUsrStacks:
- return KCrashedProcessUsrStacks();
- case TConfigItem::ECrashedProcessSvrStacks:
- return KCrashedProcessSvrStacks();
- case TConfigItem::ECrashedProcessMetaData:
- return KCrashedProcessMetaData();
- case TConfigItem::ECrashedThreadMetaData:
- return KCrashedThreadMetaData();
- case TConfigItem::ELocks:
- return KLocks();
- case TConfigItem::EKernelHeap:
- return KKernelHeap();
- case TConfigItem::EVariantSpecificData:
- return KVariantSpecific();
- case TConfigItem::ERomInfo:
- return KRomInfo();
- case TConfigItem::ELast:
- default:
- return KUnknown();
- }
- }
-#endif // ! __KERNEL_MODE__
-}
-
-//eof
-
-
--- a/kernel/eka/debug/crashMonitor/src/scmdatasave.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1266 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmdatasave.cpp
-//
-//
-
-#define __INCLUDE_REG_OFFSETS__ // for SP_R13U in nk_plat.h
-
-#include <omap_dbg.h>
-#include "arm_mem.h"
-#include "nk_plat.h"
-#include <omap_assp.h>
-#include <scmonitor.h>
-#include <scmdatasave.h>
-
-/**
- * @file
- * @internal technology
- */
-
-/**
- * SCMDataSave constructor
- * @param aMonitor - the monitor which has caught the syetem crash this object is saving data for
- * @param aFlash - the flash memory data will be written to, note the CrashFlash interface is
- * rather limited and does not support partial block writes
- * @param aFlashInfo - data describing the structure of the flash data
- */
-EXPORT_C SCMDataSave::SCMDataSave(Monitor* aMonitor, CrashFlash* aFlash)
- : iMonitor(aMonitor)
- ,iFlash(aFlash)
- ,iByteCount(0)
-#ifdef SCM_COMM_OUTPUT
- ,iWriteSelect(EWriteComm) // write data to debug port
-#else
- ,iWriteSelect(EWriteFlash) // write data to flash
-#endif
- ,iPerformChecksum(ETrue) // checksum data
- ,iStartingPointForCrash(0)
- {
- const TInt KCacheSize = 128;
- iFlashCache = HBuf8::New(KCacheSize);
- CLTRACE1("(SCMDataSave) Creating writer with cache size = %d", KCacheSize);
- iWriter = new TCachedByteStreamWriter(const_cast<TUint8*>(iFlashCache->Ptr()), KCacheSize);
- iWriter->SetWriterImpl(this);
- }
-
-/**
- * Destructor
- */
-SCMDataSave::~SCMDataSave()
- {
- delete iFlashCache;
- }
-
-/**
- * Getter for the current byte count. This is the amount of data that has currently
- * been written to given media for this crash log
- * @return The number of bytes written already to given media
- */
-TInt SCMDataSave::GetByteCount()
- {
- return iByteCount;
- }
-
-/**
- * Logs the user stack for a given DThread object if it is available
- * @param aThread - thread whose stack we wish to log
- * @param aSizeDumped Holds the size of the data dumped
- * @return one of the OS codes
- */
-TInt SCMDataSave::LogThreadUserStack(DThread* aThread, TBool aFullStack, TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
- TUint memDumped = 0;
-
- TUint svSp, usrSp;
- iMonitor->GetStackPointers(&(aThread->iNThread), svSp, usrSp );
-
- //first we check for a user stack...
- if (aThread->iUserStackRunAddress && aThread->iUserStackSize)
- {
- //Get data together
- TThreadStack usrStack;
- usrStack.iStackType = TThreadStack::EUsrStack;
- usrStack.iThreadId = (TUint64)aThread->iId;
-
- //map in the user stack
- TUint8* usrStart = (TUint8*)iMonitor->MapAndLocateUserStack(aThread); //What about Demand paging??
- TUint8* usrEnd = (TUint8*)(usrStart + aThread->iUserStackSize);
- if(usrStart)
- {
- TUint8* stackPointer = (TUint8*)usrSp;
-
- //check the stack pointer is in the range of the stack...
- if (stackPointer < usrStart || stackPointer >= usrEnd)
- {
- stackPointer = usrStart;
- }
-
- //log the size of the stack we are dumping
- usrStack.iStackSize = aFullStack || (stackPointer == usrStart) ? usrEnd - usrStart : usrEnd - stackPointer;
- TUint8* dumpFrom = aFullStack ? usrStart : stackPointer;
-
- //write the stack
- aSizeDumped+= usrStack.GetSize();
- usrStack.Serialize(*iWriter);
-
- //now we dump the actual stack
- //if there is a memErr when we read, there isnt much we can do - possibly a bit in the struct to say available/not available?
- //-1 because we dont want to write the byte at usrEnd
- MTRAPD(memErr, LogMemory(dumpFrom, usrStack.iStackSize, aThread, memDumped));
- if(KErrNone != memErr)
- {
- CLTRACE("Failed to log usr stack");
- }
-
- aSizeDumped+= memDumped;
- }
- else
- {
- //write the struct
- aSizeDumped+=usrStack.GetSize();
- usrStack.Serialize(*iWriter);
- }
- }
- return KErrNone;
- }
-
-/**
- * Logs the supervisor stack for a given DThread object
- * @param aThread - thread whose stack we wish to log
- * @param aSizeDumped Holds the size of the data dumped
- * @return one of the system wide codes
- */
-TInt SCMDataSave::LogThreadSupervisorStack(DThread* aThread, TBool aFullStack, TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
- TUint memDumped = 0;
-
- TUint svSp, usrSp;
- iMonitor->GetStackPointers(&(aThread->iNThread), svSp, usrSp );
-
- //now we dump the supervisor stack
- TThreadStack svrStack;
- svrStack.iStackType = TThreadStack::ESvrStack;
- svrStack.iThreadId = (TUint64)aThread->iId;
-
- if (aThread->iSupervisorStack && aThread->iSupervisorStackSize)
- {
- TUint8* svrStart = (TUint8*)aThread->iSupervisorStack;
- TUint8* svrEnd = (TUint8*)(svrStart + aThread->iSupervisorStackSize);
- TUint8* svrStackPointer = (TUint8*)svSp;
-
- //size of stack we are to dump
- svrStack.iStackSize = aFullStack ? svrEnd - svrStart : svrEnd - svrStackPointer;
-
- if(svrStart)
- {
- //check the stack pointer is in the range of the stack...
- if (svrStackPointer < svrStart || svrStackPointer >= svrEnd)
- {
- svrStackPointer = svrStart;
- }
-
- //write struct to flash
- aSizeDumped += svrStack.GetSize();
- svrStack.Serialize(*iWriter);
-
- //now we dump the actual stack
- //if there is a memErr when we read, there isnt much we can do - possibly a bit in the struct to say available/not available?
- MTRAPD(memErr, LogMemory(svrStart, svrStack.iStackSize, aThread, memDumped));
- aSizeDumped += memDumped;
-
- if(KErrNone != memErr)
- {
- CLTRACE("Failed to log supervisor stack");
- }
- }
- else
- {
- //write the struct
- aSizeDumped += svrStack.GetSize();
- svrStack.Serialize(*iWriter);
- }
- }
-
- return KErrNone;
- }
-
-/**
- * Takes a DProcess kernel object and logs its corrosponding code segments
- * @param aProcess
- * @param aSizeDumped Holds the size of the data dumped
- * @return one of the OS wide error codes
- */
-TInt SCMDataSave::LogCodeSegments(DProcess* aProc, TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
-
- //the code segment set for this process
- TCodeSegmentSet segSet;
- segSet.iPid = (TUint64)aProc->iId;
-
- //make sure list mutex is ok
- if(Kern::CodeSegLock()->iHoldCount)
- {
- return KErrCorrupt;
- }
-
- //get code seg list
- SDblQue queue;
- aProc->TraverseCodeSegs(&queue, NULL, DCodeSeg::EMarkDebug, DProcess::ETraverseFlagAdd);
-
- //iterate through the list
- TInt codeSegCnt = 0;
- for(SDblQueLink* codeSegPtr= queue.First(); codeSegPtr!=(SDblQueLink*) (&queue); codeSegPtr=codeSegPtr->iNext)
- {
- //get the code seg
- DEpocCodeSeg* codeSeg = (DEpocCodeSeg*)_LOFF(codeSegPtr,DCodeSeg, iTempLink);
-
- if(codeSeg)
- {
- codeSegCnt++;
- }
- }
-
- if(codeSegCnt == 0)
- {
- return KErrNone;
- }
-
- segSet.iNumSegs = codeSegCnt;
- segSet.Serialize(*iWriter);
- aSizeDumped+=segSet.GetSize();
-
- TModuleMemoryInfo memoryInfo;
-
- //now we write each code segment
- for(SDblQueLink* codeSegPtr= queue.First(); codeSegPtr!=(SDblQueLink*) (&queue); codeSegPtr=codeSegPtr->iNext)
- {
- //get the code seg
- DEpocCodeSeg* codeSeg = (DEpocCodeSeg*)_LOFF(codeSegPtr,DCodeSeg, iTempLink);
-
- if(codeSeg)
- {
- TCodeSegment seg;
- seg.iXip = (codeSeg->iXIP) ? ETrue : EFalse;
-
- //Get the code seg type
- if(codeSeg->IsExe())
- {
- seg.iCodeSegType = EExeCodeSegType;
- }
- else if(codeSeg->IsDll())
- {
- seg.iCodeSegType = EDllCodeSegType;
- }
-
- TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL);
- if(KErrNone == err)
- {
- seg.iCodeSegMemInfo = memoryInfo;
- }
- else
- {
- seg.iCodeSegMemInfo.iCodeSize = 0;
-
- // Still need to indicate it wasnt available somehow
- }
-
- //Get filename
- seg.iNameLength = codeSeg->iFileName->Length();
- seg.iName = *(codeSeg->iFileName);
-
- aSizeDumped+=seg.GetSize();
- seg.Serialize(*iWriter);
- }
- }
-
- //Empty this queue and clear marks
- DCodeSeg::EmptyQueue(queue, DCodeSeg::EMarkDebug);
-
- return KErrNone;
- }
-
-/**
- * This logs the rom version and header information to the crash media
- * @param aSizeDumped amount of data occupied
- * @return one of the OS wide codes
- */
-TInt SCMDataSave::LogRomInfo(TUint& aSizeDumped)
- {
- aSizeDumped = 0;
-
- TRomHeaderData romData;
-
- TRomHeader rHdr = Epoc::RomHeader();
-
- romData.iMajorVersion = rHdr.iVersion.iMajor;
- romData.iMinorVersion = rHdr.iVersion.iMinor;
- romData.iBuildNumber = rHdr.iVersion.iBuild;
- romData.iTime = rHdr.iTime;
-
- TInt err = romData.Serialize(*iWriter);
- if(KErrNone != err)
- {
- return err;
- }
-
- aSizeDumped += romData.GetSize();
-
- return KErrNone;
- }
-
-/**
- * Takes a DProcess kernel object and logs to flash
- * @param aProc
- * @param aSizeDumped Holds the size of the data dumped
- * @return one of the OS wide error codes
- */
-TInt SCMDataSave::LogProcessData(DProcess* aProc, TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
-
- TProcessData procData;
- DCodeSeg* codeSeg = aProc->iCodeSeg;
-
- procData.iPriority = aProc->iPriority;
- procData.iPid = (TUint64)aProc->iId;
-
- //the code segment is not always available
- if(codeSeg)
- {
- procData.iNamesize = codeSeg->iFileName->Length();
- procData.iName = *(codeSeg->iFileName);
- }
-
- aSizeDumped += procData.GetSize();
- procData.Serialize(*iWriter);
-
- return KErrNone;
- }
-
-/**
- * Creates meta data about the crash such as time of crash, exit reason etc. to be logged
- * later on when we have log size.
- * @param aCategory - crash category
- * @param aReason - crash reason
- * @param aSizeDumped Holds the size of the data dumped
- * @return one of the OS wide codes
- */
-TInt SCMDataSave::LogCrashHeader(const TDesC8& aCategory, TInt aReason, TInt aCrashId, TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
-
- //the thread that crashed is the context in which we are running
- DThread* crashedThread = &Kern::CurrentThread();
-
- iCrashInf.iPid = crashedThread->iOwningProcess->iId;
- iCrashInf.iTid = crashedThread->iId;
- iCrashInf.iCrashTime = CrashTime();
- iCrashInf.iExitType = 0; // Not yet done: Exception or Fault - should be in category
- iCrashInf.iExitReason = aReason;
- iCrashInf.iFlashAlign = KFlashAlignment; //record the flash alignment (word aligned for now)
- iCrashInf.iCachedWriterSize = iWriter->GetCacheSize();
-
- iCrashInf.iCategorySize = aCategory.Length();
- iCrashInf.iCategory = aCategory;
- iCrashInf.iCrashId = aCrashId;
-
- iCrashInf.iFlashBlockSize = KCrashLogBlockSize;;
- iCrashInf.iFlashPartitionSize = KCrashLogSize;;
-
- TSuperPage& sp=Kern::SuperPage();
- iCrashInf.iExcCode = sp.iKernelExcId;
-
- //These will be updated with more info at end of crash
- aSizeDumped+=iCrashInf.GetSize();
- iCrashInf.Serialize(*iWriter);
-
- aSizeDumped+=iHdr.GetSize();
- iHdr.Serialize(*iWriter);
-
- CLTRACE1("(SCMDataSave::LogCrashHeader) finished bytes written= %d", iWriter->GetBytesWritten());
- return KErrNone;
- }
-
-/**
- * Logs meta data about a given DThread object
- * @param aThread Thread to dump
- * @param aSizeDumped Holds the size of the data dumped
- * @return
- */
-TInt SCMDataSave::LogThreadData(DThread* aThread, TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
-
- //struct to hold data that gets written to flash
- TThreadData threadData;
-
- threadData.iTid = (TUint64)aThread->iId;
- threadData.iOwnerId = (TUint64)aThread->iOwningProcess->iId;
- threadData.iPriority = aThread->iThreadPriority;
-
- //Get the stack pointers
- TUint svSp, usrSp;
- iMonitor->GetStackPointers(&(aThread->iNThread), svSp, usrSp );
- threadData.iUsrSP = usrSp;
- threadData.iSvcSP = svSp;
-
- //supervisor and user stack details
- threadData.iSvcStack = (TInt32)aThread->iSupervisorStack;
- threadData.iSvcStacksize = aThread->iSupervisorStackSize;
- threadData.iUsrStack = aThread->iUserStackRunAddress;
- threadData.iUsrStacksize = aThread->iUserStackSize;
-
- //currently we can only get the kernels heap
- if(aThread == &Kern::CurrentThread())
- {
- TInt32 heapLoc = 0;
- TInt32 heapSz = 0;
- TInt err = FindKernelHeap(heapLoc,heapSz);
- if(KErrNone == err)
- {
- threadData.iSvcHeap = heapLoc;
- threadData.iSvcHeapSize = heapSz;
- }
- else
- {
- CLTRACE("\tError: Unable to get kernel heap");
- }
- }
-
- //get filename
- TFileName filename;
- aThread->TraceAppendFullName(filename, EFalse);
-
- threadData.iName.Copy(filename);
- threadData.iNamesize = threadData.iName.Length();
-
-
-#ifdef __INCLUDE_NTHREADBASE_DEFINES__
- threadData.iLastCpu = aThread->iNThread.iLastCpu;
-#else
- threadData.iLastCpu = aThread->iNThread.iSpare3;
-#endif
-
- threadData.Serialize(*iWriter);
- aSizeDumped+=threadData.GetSize();
-
- return KErrNone;
- }
-
-/**
- * Logs the arm exception stacks
- * @param aSizeDumped Holds the size of the data dumped
- * @return one of the OS wide codes
- */
-TInt SCMDataSave::LogExceptionStacks(TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
- TUint memDumped = 0;
-
- #if defined(__EPOC32__) && !defined(__CPU_X86)
-
- TStackInfo& stackInfo = Kern::SuperPage().iStackInfo;
-
- TThreadStack irqStack;
- irqStack.iStackType = TThreadStack::EIRQStack;
- irqStack.iStackSize = stackInfo.iIrqStackSize;
-
- aSizeDumped+=irqStack.GetSize();
- irqStack.Serialize(*iWriter);
-
- //now dump the IRQ memory - not much we can do in the event of an error
- MTRAPD(irqErr, LogMemory((TUint8*)stackInfo.iIrqStackBase, stackInfo.iIrqStackSize, &Kern::CurrentThread(), memDumped));
-
- if(KErrNone != irqErr)
- {
- CLTRACE("*****Failed to log IRQ stack");
- }
- aSizeDumped+=memDumped;
-
- //Next, we do the FIQ stack
- TThreadStack fiqStack;
- fiqStack.iStackType = TThreadStack::EFIQStack;
- fiqStack.iStackSize = stackInfo.iFiqStackSize;
-
- aSizeDumped+=fiqStack.GetSize();
- fiqStack.Serialize(*iWriter);
-
- //Now dump the stack itself
- MTRAPD(fiqErr, LogMemory((TUint8*)stackInfo.iFiqStackBase, stackInfo.iFiqStackSize, &Kern::CurrentThread(), memDumped));
-
- if(KErrNone != fiqErr )
- {
- CLTRACE("*****Failed to log FIQ stack");
- }
- aSizeDumped+=memDumped;
-
- #endif
-
- return KErrNone;
- }
-
-/**
- * Logs the CPU Registers at the time of crash
- * @param aSizeDumped Holds the size of the data dumped
- * @return system wide OS code
- */
-TInt SCMDataSave::LogCPURegisters(TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
-
- TInt32 fullSet = 37;
-
- //meta data about the thread set
- TRegisterSet threadSet;
- threadSet.iNumRegisters = fullSet;
-
- aSizeDumped+=threadSet.GetSize();
- threadSet.Serialize(*iWriter);
-
- SFullArmRegSet regSet;
- ReadCPURegisters(regSet);
- TArmReg* regs = (TArmReg*)®Set;
-
- TInt32 cnt = 0;
- for(cnt = 0; cnt < fullSet; cnt++)
- {
- //this is the struct to store the register value in
- TRegisterValue regVal;
- regVal.iType = cnt * 0x100;
- regVal.iValue32 = regs[cnt];
- regVal.iOwnId = Kern::CurrentThread().iId;
-
- aSizeDumped+=regVal.GetSize();
- regVal.Serialize(*iWriter);
- }
-
- return KErrNone;
- }
-
-/**
- * This logs the registers for a given thread to the flash memory
- * @param aThread - thread whose registers we want
- * @param aRegType - type of register set required such as user, supervisor etc
- * @param aSizeDumped Holds the size of the data dumped
- * @return one of the OS return codes
- */
-TInt SCMDataSave::LogRegisters(DThread* aThread, const TRegisterSetType& aRegType, TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
-
- TArmRegSet regs;
- TUint32 availableRegs;
- TInt err;
-
- //for the current thread we do things differently
- if(aThread == &Kern::CurrentThread() && aRegType == EFullCPURegisters)
- {
- err = LogCPURegisters(aSizeDumped);
- return err;
- }
- else if(aThread == &Kern::CurrentThread())
- {
- //only do full cpu reg for the current thread
- return KErrNotSupported;
- }
-
- //Read the appropriate registers
- switch(aRegType)
- {
- case EUserRegisters :
- {
- err = ReadUserRegisters(aThread, regs, availableRegs);
- break;
- }
- case ESupervisorRegisters :
- {
- err = ReadSystemRegisters(aThread, regs, availableRegs);
- break;
- }
- default : return KErrNotSupported;
- }
-
- if(err != KErrNone)
- {
- return err;
- }
-
- //meta data about the thread set
- TRegisterSet threadSet;
-
- //to get the number of registers in advance, we need to count the number of times 1 is set in the bit field of availableRegs
- TUint numR = 0;
- for(TInt cnt =0; cnt< 8*sizeof(availableRegs); cnt++) //cycle through 1 bit at a time
- {
- if(0x1 & (availableRegs>>cnt))
- numR++;
- }
-
- threadSet.iNumRegisters = numR;
-
- if(numR == 0)
- return KErrNone;
-
- threadSet.Serialize(*iWriter);
- aSizeDumped += threadSet.GetSize();
-
- TInt32 currentRegister = 1;
- TArmReg* reg = (TArmReg*)(®s);
-
- for(TInt32 cnt = 0; cnt < KArmRegisterCount; cnt++)
- {
- //look at the unavailable bitmask to see current register is available
- //only write the registers we have values for
- if(currentRegister & availableRegs)
- {
- //this is the struct to store the register value in
- TRegisterValue regVal;
-
- //get register type as per symbian elf docs
- TUint32 registerType;
- err = GetRegisterType(aRegType, cnt, registerType);
- if(err != KErrNone)
- {
- continue;
- }
- regVal.iType = registerType;
- regVal.iOwnId = aThread->iId;
-
- //set value
- regVal.iValue32 = reg[cnt];
-
- aSizeDumped+=regVal.GetSize();
- regVal.Serialize(*iWriter);
- }
-
- currentRegister<<=1;
- }
-
- return KErrNone;
- }
-
-/**
- * This logs memory in the specified area
- * @param aStartAddress - address to start from
- * @param aEndAddress - address to finish
- * @param aThread - process whose memory this is in
- * @param aSizeDumped Holds the size of the data dumped
- * @return one of the system wide codes
- */
-TInt SCMDataSave::LogMemory(const TUint8* aStartAddress, TInt aLength, const DThread* aThread, TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
-
- if(aThread->iOwningProcess != &Kern::CurrentProcess())
- {
- TInt err = iMonitor->SwitchAddressSpace(aThread->iOwningProcess, ETrue);
- if(KErrNone != err)
- {
- return err;
- }
- }
-
- TMemoryDump memDump;
- memDump.iStartAddress = (TUint32)aStartAddress;
- memDump.iLength = aLength;
- memDump.iPid = aThread->iOwningProcess->iId;
-
- aSizeDumped+=memDump.GetSize();
- memDump.Serialize(*iWriter);
-
- if(!aStartAddress)
- {
- return KErrArgument;
- }
-
- TRawData theMemory;
- theMemory.iData.Set(const_cast<TUint8*>(aStartAddress), aLength, aLength);
-
- theMemory.Serialize(*iWriter);
- aSizeDumped+=theMemory.GetSize();
-
- return KErrNone;
- }
-
-/**
- * This logs the locks held by system at time of crash
- * @param aSizeDumped Holds the size of the data dumped
- * @return one of the system wide codes
- */
-TInt SCMDataSave::LogLocks(TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
-
- // get the mutex logs & waits & log via a TLockData object
- TSCMLockData lockData;
-
- const TInt KMaxLockCheck = 20; // so no possibility of infinite loop
-
- TInt lockCount = 0;
- // check for kernel locks -
- for(TInt i=0;i<KMaxLockCheck;i++)
- {
- TBool locked = NKern::KernelLocked(i);
- if(!locked)
- {
- lockData.SetLockCount(lockCount);
- break;
- }
- // found a valid lock for value i increment the clock counter
- lockCount++;
- }
-
- // now mutexes
- DMutex* mutex = Kern::CodeSegLock();
- if(mutex)
- {
- lockData.SetMutexHoldCount(mutex->iHoldCount);
- lockData.SetMutexThreadWaitCount(mutex->iWaitCount);
- }
- else
- {
- // no mutex held set to -1
- lockData.SetMutexHoldCount(0);
- lockData.SetMutexThreadWaitCount(0);
- }
-
- aSizeDumped+=lockData.GetSize();
- TInt err = lockData.Serialize(*iWriter);
-
- return err;
- }
-
-/**
- * Writes the SCM Configuration to the start of the media
- * @param aScmConfig Configuration to write
- * @return one of the system wide codes
- */
-TInt SCMDataSave::LogConfig(SCMConfiguration& aScmConfig)
- {
- iWriter->SetPosition(0);
-
- TInt err = aScmConfig.Serialize(*iWriter);
-
- if( err != KErrNone)
- {
- CLTRACE1("SCMDataSave::LogConfig failed err = %d", err);
- }
-
- return err;
- }
-
-/**
- * Reads the SCM Configuration from the media
- * @param aScmConfig
- * @return one of the system wide codes
- */
-TInt SCMDataSave::ReadConfig(SCMConfiguration& aScmConfig)
- {
- const TInt KBufSize = 135; //Not yet done: Put in header, beside config defn
-
- if( KBufSize < aScmConfig.GetSize())
- {
- CLTRACE2("(SCMDataSave::ReadConfig) ** ERROR Inadequate buffer actual = %d req = %d"
- , KBufSize, aScmConfig.GetSize());
- }
-
- // try and read the configuration
- TBuf8<KBufSize> buf;
- buf.SetLength(KBufSize);
-
- iFlash->SetReadPos(0); // config always at 0
- iFlash->Read(buf);
-
- TByteStreamReader reader(const_cast<TUint8*>(buf.Ptr()));
- TInt err = aScmConfig.Deserialize(reader);
- if(err == KErrNotReady)
- {
- CLTRACE("(SCMDataSave::ReadConfig) no config saved - use default");
- }
- else if(err == KErrNone)
- {
- CLTRACE("(SCMDataSave::ReadConfig) Config read ok");
- }
- else
- {
- CLTRACE1("(SCMDataSave::ReadConfig) error reading config err = %d", err);
- }
-
- return err;
- }
-
-/**
- * This is a look up table to map the register type and number to the symbian elf definition
- * of register type
- * @param aSetType this is the register set type - user, supervisor etc
- * @param aRegNumber this is the number of the register as per TArmRegisters in arm_types.h
- * @param aSizeDumped Holds the size of the data dumped
- * @return One of the OS wide codes
- */
-TInt SCMDataSave::GetRegisterType(const TRegisterSetType& aSetType, TInt32& aRegNumber, TUint32& aRegisterType)
- {
- //validate arguments
- if(aRegNumber < EArmR0 || aRegNumber > EArmFlags)
- {
- return KErrArgument;
- }
-
- //look at what type we are using
- switch(aSetType)
- {
- case EUserRegisters :
- {
- aRegisterType = aRegNumber * 0x100; //for R0 to R16 (CPSR) it just increments in 0x100 from 0x0 to 0x1000
- break;
- }
- case ESupervisorRegisters :
- {
- //same as EUserRegisters except R13 and R14 are different
- if(aRegNumber == EArmSp)
- {
- aRegisterType = 0x1100;
- break;
- }
- else if(aRegNumber == EArmLr)
- {
- aRegisterType = 0x1200;
- break;
- }
- else
- {
- aRegisterType = aRegNumber * 0x100;
- break;
- }
- }
- default : return KErrNotSupported;
- }
-
- return KErrNone;
- }
-
-/**
- * Writes the trace buffer to the crash log.
- * @param aSizeToDump Number of bytes to dump. If this is zero we attempt to write the entire buffer
- * @param aSizeDumped Holds the size of the data dumped
- * @return One of the OS wide codes
- */
-TInt SCMDataSave::LogTraceBuffer(TInt aSizeToDump, TUint& aSizeDumped)
- {
- LOG_CONTEXT
- aSizeDumped = 0;
- TUint memDumped = 0;
-
- TBool dumpAll = (aSizeToDump == 0) ? ETrue : EFalse;
-
- //Because the btrace buffer is a circular one, we need to save it in two parts
- //this corrosponds to how we read it
- TUint8* data;
- TUint sizeOfPartRead;
- TInt spaceRemaining = aSizeToDump;
-
- //This structure will be filled after the first pass and cached so by the time we ARE writing it will
- //contain the data we want
- aSizeDumped+=iTrace.GetSize();
- iTrace.Serialize(*iWriter);
-
- //read first part
- TInt err = BTrace::Control(BTrace::ECtrlCrashReadFirst,&data,&sizeOfPartRead);
-
- while(KErrNone == err && sizeOfPartRead > 0)
- {
- TUint rawSize = 0; //how much of this read data want we to dump
-
- if(dumpAll)
- {
- rawSize = sizeOfPartRead;
- }
- else //Otherwise see what room is left for dumpage
- {
- rawSize = ((sizeOfPartRead + iTrace.iSizeOfMemory) > aSizeToDump) ? spaceRemaining : sizeOfPartRead;
- }
-
- //Only relevant if restricting the dump
- if(spaceRemaining <= 0 && !dumpAll)
- break;
-
- TPtrC8 ptr(data, rawSize);
- err = LogRawData(ptr, memDumped);
- if(KErrNone != err)
- {
- CLTRACE1("Logging Raw data failed - [%d]", err);
- err = BTrace::Control(BTrace::ECtrlCrashReadNext,&data,&sizeOfPartRead);
- continue;
- }
-
- aSizeDumped+=memDumped;
-
- iTrace.iSizeOfMemory += rawSize;
- iTrace.iNumberOfParts++;
- spaceRemaining -= rawSize;
-
- err = BTrace::Control(BTrace::ECtrlCrashReadNext,&data,&sizeOfPartRead);
- }
-
- return KErrNone;
- }
-
-/**
- * Logs the data in a TRawData struct
- * @param aData
- * @param aSizeDumped Holds the size of the data dumped
- * @return One of the OS wide codes
- */
-TInt SCMDataSave::LogRawData(const TDesC8& aData, TUint& aSizeDumped)
- {
- TRawData theData;
- theData.iLength = aData.Length();
- theData.iData.Set(const_cast<TUint8*>(aData.Ptr()), aData.Length(), aData.Length());
-
- aSizeDumped+=theData.GetSize();
- return theData.Serialize(*iWriter);
- }
-
-
-/**
- * Logs the kernels heap and returns the size dumped via aSizeDumped
- * @param aSizeDumped Holds the size of the data dumped
- * @return
- */
-TInt SCMDataSave::LogKernelHeap(TUint& aSizeDumped)
- {
- LOG_CONTEXT
-
- TInt32 heapLoc = 0;
- TInt32 heapSize = 0;
- TInt32 err = FindKernelHeap(heapLoc, heapSize);
- if(KErrNone == err)
- {
- return LogMemory((TUint8*)heapLoc, heapSize, &Kern::CurrentThread(), aSizeDumped);
- }
-
- CLTRACE1("\tCouldnt find the kernel heap: [%d]", err);
- return err;
- }
-
-/**
- * Iterates the object containers and finds the kernel heap
- * @param aHeapLocation Contains the memory location of the kernel heap
- * @param aHeapSize Contains the size of the Heap
- * @return One of the OS wide codes
- */
-TInt SCMDataSave::FindKernelHeap(TInt32& aHeapLocation, TInt32& aHeapSize)
- {
- LOG_CONTEXT
-
- //Get process object container
- DObjectCon* objectContainer = Kern::Containers()[EProcess];
- if(objectContainer == NULL)
- {
- CLTRACE("\tFailed to get object container for the processes");
- return KErrNotFound;
- }
-
- //Must check the mutex on this is ok otherwise the data will be in an inconsistent state
- if(objectContainer->Lock()->iHoldCount)
- {
- CLTRACE("\tChunk Container is in an inconsistant state");
- return KErrCorrupt;
- }
-
- TInt numObjects = objectContainer->Count();
-
- DProcess* kernelProcess = NULL;
- for(TInt cnt = 0; cnt < numObjects; cnt ++)
- {
- DProcess* candidateProcess = (DProcess*)(*objectContainer)[cnt];
-
- //Get the objects name
- TBuf8<KMaxKernelName> name;
- candidateProcess->TraceAppendFullName(name,EFalse);
- if(name == KKernelProcessName)
- {
- kernelProcess = candidateProcess;
- }
- }
- if (!kernelProcess)
- return KErrNotFound;
-
- //Get chunk object container
- objectContainer = Kern::Containers()[EChunk];
- if(objectContainer == NULL)
- {
- CLTRACE("\tFailed to get object container for the chunks");
- return KErrNotFound;
- }
-
- //Must check the mutex on this is ok otherwise the data will be in an inconsistent state
- if(objectContainer->Lock()->iHoldCount)
- {
- CLTRACE("\tChunk Container is in an inconsistant state");
- return KErrCorrupt;
- }
-
- numObjects = objectContainer->Count();
- for(TInt cnt = 0; cnt < numObjects; cnt ++)
- {
- DChunk* candidateHeapChunk = (DChunk*)(*objectContainer)[cnt];
-
- //Get the objects name
- TBuf8<KMaxKernelName> name;
- candidateHeapChunk->TraceAppendFullName(name,EFalse);
-
- if(name == KKernelHeapChunkName)
- {
- aHeapLocation = (TInt32)candidateHeapChunk->Base(kernelProcess);
- aHeapSize = candidateHeapChunk->iSize;
- return KErrNone;
- }
- }
-
- return KErrNotFound;
- }
-
-/**
- * This logs the variant specific descriptor data to the crash log
- * @param aSizeDumped records how much was dumped by this function
- * @return one of the OS wide codes
- */
-TInt SCMDataSave::LogVariantSpecificData(TUint& aSizeDumped)
- {
- LOG_CONTEXT
-
- aSizeDumped = 0;
-
- //Change this descriptor as required for your needs
- _LIT(KVariantSpecificData, "This is the variant specific data. Put your own here");
-
- TVariantSpecificData varData;
- varData.iSize = KVariantSpecificData().Size();
-
- TInt err = varData.Serialize(*iWriter);
- if(KErrNone != err)
- {
- CLTRACE1("\tLogging variant specific data failed with code [%d]", err);
- return err;
- }
- aSizeDumped+=varData.GetSize();
-
- TUint rawDataSize = 0;
- err = LogRawData(KVariantSpecificData(), rawDataSize);
- if(KErrNone != err)
- {
- CLTRACE1("\tLogging variant specific data failed with code [%d]", err);
- return err;
- }
-
- aSizeDumped+=rawDataSize;
-
- return KErrNone;
- }
-
-
-/**
- * This method is the callback used by MPhysicalWriterImpl interface
- * if the TCachedByteStreamWriter is configured to use this interface
- * the callback avoids the need for temp buffers & can interface directly with the
- * flash writer methods
- * @param aData - data to write
- * @param aLen - length of data to write
- * @param aPos - writers internal position
- */
-void SCMDataSave::DoPhysicalWrite(TAny* aData, TInt aPos, TInt aLen)
- {
- if(iPerformChecksum)
- {
- iChecksum.ChecksumBlock((TUint8*)aData, aLen);
- }
-
- if( this->iWriteSelect == EWriteComm)
- {
- WriteUart((TUint8*)aData, aLen);
- }
- else // EWriteFlash
- {
- Write(aData, aLen);
- }
- }
-
-/**
- * Writes data to Flash
- * @param aSomething Pointer to the data
- * @param aSize Size of the data
- */
-void SCMDataSave::Write(const TAny* aSomething, TInt aSize)
- {
- TPtrC8 data((const TUint8 *)aSomething, aSize);
-
- TInt written = 0;
-
- WriteCrashFlash(iByteCount, written, data);
- iByteCount+= written;
- }
-
-/**
- * Writes a descriptor to the crash flash
- * @param aPos Position in flash to write
- * @param aSize Holds the size of the data written after the call
- * @param aBuffer Descriptor to write
- */
-void SCMDataSave::WriteCrashFlash(TInt aPos, TInt& aSize, const TDesC8& aBuffer)
- {
- //Set write position in the flash
- iFlash->SetWritePos(aPos);
- iFlash->Write(aBuffer);
-
- //get bytes written
- aSize += iFlash->BytesWritten();
-
- if(aSize != aBuffer.Length())
- {
- CLTRACE2("(SCMDataSave::WriteCrashFlash) Over the limit aSize = %d aBuffer.Length() = %d",
- aSize, aBuffer.Length());
- }
- }
-
-/**
- * Writes a descriptor via serial
- * @param aDes Descriptor to write
- */
-void SCMDataSave::WriteUart(const TDesC8& aDes)
- {
- WriteUart(aDes.Ptr(), aDes.Length());
- }
-
-/**
- * Writes data via serial
- * @param aData Data to write
- * @param aSize Size of data to write
- */
-void SCMDataSave::WriteUart(const TUint8* aData, TInt aSize)
- {
- OMAP* assp = ((OMAP*)Arch::TheAsic());
- TOmapDbgPrt* dbg = assp->DebugPort();
-
- if (dbg)
- {
- for(TInt i=0;i<aSize;i++)
- {
- dbg->DebugOutput(*(aData+i));
- }
- }
- else
- {
- CLTRACE("SCMDataSave::WriteUart ERROR - dbg was null");
- }
- }
-
-/**
- * Setter for the current number of bytes written for this crash log
- * If aByte is not word aligned, it will be rounded up to be so
- * @param aByte Current bytes written
- */
-void SCMDataSave::SetByteCount(TInt aByte)
- {
- //ensure aligned
- if(aByte % iWriter->GetCacheSize() == 0)
- {
- iByteCount = aByte;
- }
- else
- {
- iByteCount = aByte + (iWriter->GetCacheSize() - (aByte % iWriter->GetCacheSize()));
- }
- }
-
-/**
- * Gets the output target selection
- * @return TScmWriteSelect output target selection
- * @param void
- */
-SCMDataSave::TWriteSelect SCMDataSave::GetWriteSelect()
- {
- return iWriteSelect;
- }
-
-/**
- * Sets the output target selection
- * @return void
- * @param TScmWriteSelect aWriteSelect output target selection
- */
-void SCMDataSave::SetWriteSelect(SCMDataSave::TWriteSelect aWriteSelect)
- {
- iWriteSelect = aWriteSelect;
- }
-
-/**
- * Gets the amount of space remaining for the media of choice
- * @return
- */
-TUint SCMDataSave::SpaceRemaining()
- {
- TInt currentPosition = iWriter->GetBytesWritten() + iStartingPointForCrash;
-
- return MaxLogSize() - currentPosition;
- }
-
-/**
- * To find the max size of a log for a given media
- * @return the max size of a log for a given media
- */
-TUint SCMDataSave::MaxLogSize()
- {
- //see what write media is being used
- switch(GetWriteSelect())
- {
- case EWriteFlash:
- {
- return KMaxCrashLogSize;
- }
- case EWriteComm:
- {
- return 0xFFFFFFFF;
- }
- default:
- {
- return 0;
- }
- }
- }
-
-/**
- * Records the offset in the flash partition where this crash begins
- * @param aStart Offset in flash
- */
-void SCMDataSave::SetCrashStartingPoint(TUint32 aStart)
- {
- iStartingPointForCrash = aStart;
- }
-
-//eof
-
--- a/kernel/eka/debug/crashMonitor/src/scmdatatypes.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1618 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmdatatypes.cpp
-// Core dump server - Data Types for System Crash
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-#include <scmtrace.h>
-#include <scmdatatypes.h>
-#include <scmbytestreamutil.h>
-
-namespace Debug
- {
- /**
- * TCrashOffsetsHeader implementation
- * @internal technology
- */
-
- /**
- * TCrashOffsetsHeader Constructor
- */
- TCrashOffsetsHeader::TCrashOffsetsHeader():
- iId(ESCMOffsetsHeader),
- iVersion(EChVersion1),
- iCTFullRegOffset(0),
- iCTUsrStkOffset(0),
- iCTSvrStkOffset(0),
- iCPMetaOffset(0),
- iCTMetaOffset(0),
- iCPCodeSegOffset(0),
- iSysUsrStkOffset(0),
- iSysSvrStkOffset(0),
- iSysUsrRegOffset(0),
- iSysSvrRegOffset(0),
- iTLstOffset(0),
- iPLstOffset(0),
- iSysCodeSegOffset(0),
- iExcStkOffset(0),
- iTraceOffset(0),
- iScmLocksOffset(0),
- iKernelHeapOffset(0),
- iVarSpecInfOffset(0),
- iRomInfoOffset(0),
- iSpare1(0),
- iSpare2(0),
- iSpare3(0),
- iSpare4(0),
- iSpare5(0),
- iSpare6(0)
- {
- }
-
- /**
- * Writes this class to the specified byte stream
- * @param aWriter Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TCrashOffsetsHeader::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- if(iId != ESCMOffsetsHeader)
- {
- CLTRACE("TCrashOffsetsHeader::Serialize Corrupt ID");
- return KErrCorrupt;
- }
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == EChVersion1)
- {
- // write data v1 format
- aWriter.WriteInt(iCTFullRegOffset); // 4
- aWriter.WriteInt(iCTUsrStkOffset); // 4
- aWriter.WriteInt(iCTSvrStkOffset); // 4
- aWriter.WriteInt(iCPMetaOffset); // 4
- aWriter.WriteInt(iCTMetaOffset); // 4
- aWriter.WriteInt(iCPCodeSegOffset); // 4
- aWriter.WriteInt(iSysUsrStkOffset); // 4
- aWriter.WriteInt(iSysSvrStkOffset); // 4
- aWriter.WriteInt(iSysUsrRegOffset); // 4
- aWriter.WriteInt(iSysSvrRegOffset); // 4
- aWriter.WriteInt(iTLstOffset); // 4
- aWriter.WriteInt(iPLstOffset); // 4
- aWriter.WriteInt(iSysCodeSegOffset); // 4
- aWriter.WriteInt(iExcStkOffset); // 4
- aWriter.WriteInt(iTraceOffset); // 4
- aWriter.WriteInt(iScmLocksOffset); // 4
- aWriter.WriteInt(iKernelHeapOffset); // 4
- aWriter.WriteInt(iVarSpecInfOffset); // 4
- aWriter.WriteInt(iRomInfoOffset); // 4
- }
- else
- {
- CLTRACE("TCrashOffsetsHeader::Serialize Unsupported version");
- }
-
- TInt sizeWritten = aWriter.CurrentPosition() - startPos;
- if(sizeWritten != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TCrashOffsetsHeader serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TCrashOffsetsHeader::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMOffsetsHeader)
- {
- CLTRACE("TCrashOffsetsHeader::Deserialize Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TCrashHeaderVersion)aReader.ReadShort(); //2
-
- if(iVersion == EChVersion1)
- {
- iCTFullRegOffset = aReader.ReadInt(); // 4
- iCTUsrStkOffset = aReader.ReadInt(); // 4
- iCTSvrStkOffset = aReader.ReadInt(); // 4
- iCPMetaOffset = aReader.ReadInt(); // 4
- iCTMetaOffset = aReader.ReadInt(); // 4
- iCPCodeSegOffset = aReader.ReadInt(); // 4
- iSysUsrStkOffset = aReader.ReadInt(); // 4
- iSysSvrStkOffset = aReader.ReadInt(); // 4
- iSysUsrRegOffset = aReader.ReadInt(); // 4
- iSysSvrRegOffset = aReader.ReadInt(); // 4
- iTLstOffset = aReader.ReadInt(); // 4
- iPLstOffset = aReader.ReadInt(); // 4
- iSysCodeSegOffset = aReader.ReadInt();// 4
- iExcStkOffset = aReader.ReadInt(); // 4
- iTraceOffset = aReader.ReadInt(); // 4
- iScmLocksOffset = aReader.ReadInt(); // 4
- iKernelHeapOffset = aReader.ReadInt(); // 4
- iVarSpecInfOffset = aReader.ReadInt(); // 4
- iRomInfoOffset = aReader.ReadInt(); // 4
- }
- else
- {
- CLTRACE("TCrashOffsetsHeader::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TCrashOffsetsHeader deserialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Get the externalised size of this class
- * @return TInt the Size
- */
- TInt TCrashOffsetsHeader::GetSize() const
- {
- // return the size in bytes that this struct uses to serialize - deserialize itself
- if(iVersion == EChVersion1)
- {
- return 82;
- }
- else
- {
- CLTRACE("TCrashOffsetsHeader::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- TBool TCrashOffsetsHeader::operator == (const TCrashOffsetsHeader& aOther) const
- {
- return (iId == aOther.iId &&
- iVersion == aOther.iVersion &&
- iCTFullRegOffset == aOther.iCTFullRegOffset &&
- iCTUsrStkOffset == aOther.iCTUsrStkOffset &&
- iCTSvrStkOffset == aOther.iCTSvrStkOffset &&
- iCPMetaOffset == aOther.iCPMetaOffset &&
- iCTMetaOffset == aOther.iCTMetaOffset &&
- iSysUsrStkOffset == aOther.iSysUsrStkOffset &&
- iSysSvrStkOffset == aOther.iSysSvrStkOffset &&
- iSysUsrRegOffset == aOther.iSysUsrRegOffset &&
- iSysSvrRegOffset == aOther.iSysSvrRegOffset &&
- iTLstOffset == aOther.iTLstOffset &&
- iPLstOffset == aOther.iPLstOffset &&
- iExcStkOffset == aOther.iExcStkOffset &&
- iCPCodeSegOffset == aOther.iCPCodeSegOffset &&
- iSysCodeSegOffset == aOther.iSysCodeSegOffset &&
- iTraceOffset == aOther.iTraceOffset &&
- iScmLocksOffset == aOther.iScmLocksOffset &&
- iVarSpecInfOffset == aOther.iVarSpecInfOffset &&
- iKernelHeapOffset == aOther.iKernelHeapOffset &&
- iRomInfoOffset == aOther.iRomInfoOffset);
- }
-
-
- /**
- * TCrashInfoHeader implementation
- * @internal technology
- */
-
- /**
- * TCrashInfoHeader constructor
- */
- TCrashInfoHeader::TCrashInfoHeader():
- iId(ESCMTCrashInfo),
- iVersion(ECiVersion1),
- iLogSize(0),
- iFlashAlign(0),
- iCachedWriterSize(0),
- iPid(0),
- iTid(0),
- iExitType(0),
- iExitReason(0),
- iExcCode(0),
- iCrashTime(0),
- iCrashId(0),
- iFlashBlockSize(0),
- iFlashPartitionSize(0),
- iCategorySize(0),
- iSpare1(0),
- iSpare2(0)
- {
- TVersion ver(KSCMDataTypesMajorVersion, KSCMDataTypesMinorVersion, KSCMDataTypesBuildNumber);
- iSCMDataTypesVersion = ver;
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TCrashInfoHeader::Serialize(TByteStreamWriter& aWriter)
- {
-
- //CLTRACE("TCrashInfoHeader::Serialize");
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
- if(iId != ESCMTCrashInfo)
- {
- CLTRACE("TCrashInfoHeader::Serialize Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == ECiVersion1)
- {
- // write data v1 format
- aWriter.WriteInt(iLogSize); // 4
- aWriter.WriteByte((TUint8)iFlashAlign); // 1
- aWriter.WriteByte((TUint8)iCachedWriterSize); // 1
- aWriter.WriteInt64(iPid); // 8
- aWriter.WriteInt64(iTid); // 8
- aWriter.WriteInt(iExitType); // 4
- aWriter.WriteInt(iExitReason); // 4
- aWriter.WriteInt(iExcCode); // 4
- aWriter.WriteInt64(iCrashTime); // 8
- aWriter.WriteInt(iCrashId); // 4
- aWriter.WriteInt(iFlashBlockSize); // 4
- aWriter.WriteInt(iFlashPartitionSize); // 4
- aWriter.WriteInt(iSCMDataTypesVersion.iMajor); // 4
- aWriter.WriteInt(iSCMDataTypesVersion.iMinor); // 4
- aWriter.WriteInt(iSCMDataTypesVersion.iBuild); // 4
-
- if(iCategory.Ptr())
- {
- aWriter.WriteInt(iCategory.Length()); // 4
- for(TInt cnt = 0; cnt < iCategory.Length(); cnt++)
- {
- aWriter.WriteByte(iCategory[cnt]); //iCategorySize bytes
- }
- }
- else
- {
- aWriter.WriteInt(0);
- }
- }
- else
- {
- CLTRACE("TCrashInfoHeader::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE2("TCrashInfoHeader::Serialize serialization size error. Wrote [%d] but expected [%d]", endPos - startPos, GetSize());
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TCrashInfoHeader::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt();
- if(iId != ESCMTCrashInfo)
- {
- CLTRACE("TCrashInfoHeader::Deserialize Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TCrashInfoHeaderVersion)aReader.ReadShort(); // 2
-
- if(iVersion == ECiVersion1)
- {
- // read data v1 format
- iLogSize = aReader.ReadInt(); // 4
- iFlashAlign = aReader.ReadByte(); // 1
- iCachedWriterSize = aReader.ReadByte(); // 1
- iPid = aReader.ReadInt64(); // 8
- iTid = aReader.ReadInt64(); // 8
- iExitType = aReader.ReadInt(); // 4
- iExitReason = aReader.ReadInt(); // 4
- iExcCode = aReader.ReadInt(); // 4
- iCrashTime = aReader.ReadInt64(); // 8
- iCrashId = aReader.ReadInt(); // 4
- iFlashBlockSize = aReader.ReadInt(); // 4
- iFlashPartitionSize = aReader.ReadInt(); // 4
- iSCMDataTypesVersion.iMajor = aReader.ReadInt(); // 4
- iSCMDataTypesVersion.iMinor = aReader.ReadInt(); // 4
- iSCMDataTypesVersion.iBuild = aReader.ReadInt(); // 4
-
-
- iCategorySize = aReader.ReadInt(); // 4
-
- if(iCategory.MaxLength() >= (TInt)iCategorySize)
- {
- iCategory.SetLength(0);
-
- for(TUint cnt = 0; cnt < iCategorySize; cnt++)
- {
- iCategory.Append(aReader.ReadByte()); //iCategorySize bytes
- }
- }
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TCrashInfoHeader::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE2("TCrashInfoHeader::Deserialize serialization size error. Read [%d] but expected [%d]", endPos - startPos, GetSize());
- iId = ESCMLast; //unrecognised header
-
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TCrashInfoHeader::GetSize() const
- {
- if(iVersion == ECiVersion1)
- {
- return 76 + iCategory.Length();
- }
- else
- {
- CLTRACE("TCrashInfoHeader::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- TBool TCrashInfoHeader::operator == (const TCrashInfoHeader& aOther) const
- {
- return (
- iId == aOther.iId &&
- iVersion == aOther.iVersion &&
- iLogSize == aOther.iLogSize &&
- iFlashAlign == aOther.iFlashAlign &&
- iCachedWriterSize == aOther.iCachedWriterSize &&
- iPid == aOther.iPid &&
- iTid == aOther.iTid &&
- iExitType == aOther.iExitType &&
- iExitReason == aOther.iExitReason &&
- iCrashTime == aOther.iCrashTime &&
- iCategorySize == aOther.iCategorySize &&
- iCategory == aOther.iCategory &&
- iSCMDataTypesVersion.iMajor == aOther.iSCMDataTypesVersion.iMajor &&
- iSCMDataTypesVersion.iMinor == aOther.iSCMDataTypesVersion.iMinor &&
- iSCMDataTypesVersion.iBuild == aOther.iSCMDataTypesVersion.iBuild);
- }
-
- /**
- * TThreadStack implementation
- * @internal technology
- */
-
-
- /**
- * TThreadStack Constructor
- */
- TThreadStack::TThreadStack():
- iId(ESCMThreadStack),
- iVersion(EStackVersion1),
- iStackType(ELast),
- iThreadId(0),
- iStackSize(0),
- iSpare1(0),
- iSpare2(0)
- {
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TThreadStack::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- if(iId != ESCMThreadStack)
- {
- CLTRACE("TThreadStack::Serialize failed - corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteInt(iId); // 4
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == EStackVersion1)
- {
- // write data v1 format
- aWriter.WriteInt(iStackType); // 4
- aWriter.WriteInt64(iThreadId); // 8
- aWriter.WriteInt(iStackSize); // 4
- }
- else
- {
- CLTRACE("TThreadStack::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TThreadStack::Serialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TThreadStack::GetSize() const
- {
- if(iVersion == EStackVersion1)
- {
- return 22;
- }
- else
- {
- CLTRACE("TThreadStack::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TThreadStack::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMThreadStack)
- {
- CLTRACE("TThreadStack::Deserialize failed Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TThreadStackVersion)aReader.ReadShort(); // 2
-
- if(iVersion == EStackVersion1)
- {
- // read data v1 format
- iStackType = (TThreadStackType)aReader.ReadInt(); // 4
- iThreadId = aReader.ReadInt64(); // 8
- iStackSize = aReader.ReadInt(); // 4
-
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TThreadStack::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TThreadStack::Deserialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * TRegisterValue implementation
- * @internal technology
- */
-
- /**
- * TRegisterValue Constructor
- */
- TRegisterValue::TRegisterValue():
- iId(ESCMRegisterValue),
- iVersion(ERegisterValueVersion1),
- iOwnId(0),
- iType(0),
- iClass(0), //core reg by default
- iSubId(0),
- iSize(2) //default for core registers
- {
- }
-
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TRegisterValue::GetSize() const
- {
- if(iVersion == ERegisterValueVersion1)
- {
- TInt baseSize = 22;
-
- //variant for union
- if(iSize == 0)
- {
- return baseSize + 1;
- }
- else if(iSize == 1)
- {
- return baseSize + 2;
- }
- else if(iSize == 2)
- {
- return baseSize + 4;
- }
- else if(iSize == 3)
- {
- return baseSize + 8;
- }
- else
- {
- CLTRACE("TRegisterValue::GetSize() Corrupt size");
- return 0;
- }
- }
- else
- {
- CLTRACE("TRegisterValue::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TRegisterValue::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- if(iId != ESCMRegisterValue)
- {
- CLTRACE("TRegisterValue::Serialize Error - Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteInt(iId); // 4
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == ERegisterValueVersion1)
- {
- // write data v1 format
- aWriter.WriteInt64(iOwnId); // 8
- aWriter.WriteInt(iType); // 4
- aWriter.WriteByte(iClass); // 1
- aWriter.WriteShort(iSubId); // 2
- aWriter.WriteByte(iSize); // 1
-
- //variant for union
- if(iSize == 0)
- {
- aWriter.WriteByte(iValue8);
- }
- else if(iSize == 1)
- {
- aWriter.WriteShort(iValue16);
- }
- else if(iSize == 2)
- {
- aWriter.WriteInt(iValue32);
- }
- else if(iSize == 3)
- {
- aWriter.WriteInt64(iValue64);
- }
- else
- {
- CLTRACE("TRegisterValue::Serialize() Corrupt size");
- return KErrCorrupt;
- }
- }
- else
- {
- CLTRACE("TRegisterValue::Serialize Unsupported version");
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TRegisterValue::Serialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TRegisterValue::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt();
- if(iId != ESCMRegisterValue)
- {
- CLTRACE("TRegisterValue::Deserialize() ERROR Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TRegisterValueVersion)aReader.ReadShort(); // 2
-
- if(iVersion == ERegisterValueVersion1)
- {
- // read data v1 format
- iOwnId = aReader.ReadInt64(); // 8
- iType = aReader.ReadInt(); // 4
- iClass = aReader.ReadByte(); // 1
- iSubId = aReader.ReadShort(); // 2
- iSize = aReader.ReadByte(); // 1
-
- //variant for union
- if(iSize == 0)
- {
- iValue8 = aReader.ReadByte();
- }
- else if(iSize == 1)
- {
- iValue16 = aReader.ReadShort();
- }
- else if(iSize == 2)
- {
- iValue32 = aReader.ReadInt();
- }
- else if(iSize == 3)
- {
- iValue64 = aReader.ReadInt64();
- }
- else
- {
- CLTRACE("TRegisterValue::Serialize() Corrupt size");
- return KErrCorrupt;
- }
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TRegisterValue::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TRegisterValue::Deserialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
- /**
- * TRegisterSet implementation
- * @internal technology
- */
-
- /**
- * TRegisterSet Constructor
- */
- TRegisterSet::TRegisterSet():
- iVersion(ETRegisterSetVersion1),
- iId(ESCMRegisterSet),
- iNumRegisters(0)
- {
-
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TRegisterSet::GetSize() const
- {
- if(iVersion == ETRegisterSetVersion1)
- {
- return 10;
- }
- else
- {
- CLTRACE("TRegisterSet::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TRegisterSet::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- if(iId != ESCMRegisterSet)
- {
- CLTRACE("TRegisterSet::Serialize Error - Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteInt(iId); // 4
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == ETRegisterSetVersion1)
- {
- // write data v1 format
- aWriter.WriteInt(iNumRegisters); // 4
- }
- else
- {
- CLTRACE("TRegisterSet::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TRegisterSet::Serialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TRegisterSet::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt();
- if(iId != ESCMRegisterSet)
- {
- CLTRACE("TRegisterSet::Deserialize() ERROR Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TRegisterSetVersion)aReader.ReadShort(); // 2
-
- if(iVersion == ETRegisterSetVersion1)
- {
- // read data v1 format
- iNumRegisters = aReader.ReadInt(); // 8
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TRegisterSet::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TRegisterSet::Deserialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * TCodeSegmentSet implementation
- * @internal technology
- */
-
- /**
- * TCodeSegmentSet Constructor
- */
- TCodeSegmentSet::TCodeSegmentSet():
- iId(ESCMCodeSegSet),
- iVersion(ETCodeSegmentSetVersion1),
- iNumSegs(0),
- iPid(0)
- {
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TCodeSegmentSet::GetSize() const
- {
- if(iVersion == ETCodeSegmentSetVersion1)
- {
- return 18;
- }
- else
- {
- CLTRACE("TCodeSegmentSet::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- /**
- * This returns the largest size this class can be
- */
- TInt TCodeSegmentSet::GetMaxSize() const
- {
- return 18;
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TCodeSegmentSet::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- if(iId != ESCMCodeSegSet)
- {
- CLTRACE("TCodeSegmentSet::Serialize Error - Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteInt(iId); // 4
- if(iId != ESCMCodeSegSet)
- {
- CLTRACE("TCodeSegmentSet::Serialize Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == ETCodeSegmentSetVersion1)
- {
- // write data v1 format
- aWriter.WriteInt(iNumSegs); // 4
- aWriter.WriteInt64(iPid); // 8
- }
- else
- {
- CLTRACE("TCodeSegmentSet::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TCodeSegmentSet::Serialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TCodeSegmentSet::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt();
- if(iId != ESCMCodeSegSet)
- {
- CLTRACE("TCodeSegmentSet::Deserialize() ERROR Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TCodeSegmentSetVersion)aReader.ReadShort(); // 2
-
- if(iVersion == ETCodeSegmentSetVersion1)
- {
- // read data v1 format
- iNumSegs = aReader.ReadInt(); // 4
- iPid = aReader.ReadInt64(); // 8
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TRegisterSet::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TRegisterSet::Deserialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
-
- /**
- * TCodeSegment implementation
- * @internal technology
- */
-
- /**
- * TCodeSegment constructor
- */
- TCodeSegment::TCodeSegment():
- iId(ESCMCodeSeg),
- iVersion(ETCodeSegmentVersion1),
- iCodeSegType(EUnknownCodeSegType),
- iXip(0),
- iNameLength(0)
- {
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TCodeSegment::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
- if(iId != ESCMCodeSeg)
- {
- CLTRACE("TCodeSegment::Serialize Error - Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == ETCodeSegmentVersion1)
- {
- // write data v1 format
- aWriter.WriteInt(iCodeSegType);
- aWriter.WriteInt(iCodeSegMemInfo.iCodeBase);
- aWriter.WriteInt(iCodeSegMemInfo.iCodeSize);
- aWriter.WriteInt(iCodeSegMemInfo.iConstDataBase);
- aWriter.WriteInt(iCodeSegMemInfo.iConstDataSize);
- aWriter.WriteInt(iCodeSegMemInfo.iInitialisedDataBase);
- aWriter.WriteInt(iCodeSegMemInfo.iInitialisedDataSize);
- aWriter.WriteInt(iCodeSegMemInfo.iUninitialisedDataBase);
- aWriter.WriteInt(iCodeSegMemInfo.iUninitialisedDataSize);
- aWriter.WriteInt(iXip);
-
- if(iName.Ptr())
- {
- aWriter.WriteInt(iName.Length()); // 4
- for(TInt cnt = 0; cnt < iName.Length(); cnt++)
- {
- aWriter.WriteByte(iName[cnt]); //iCategorySize bytes
- }
- }
- else
- {
- aWriter.WriteInt(0);
- }
- }
- else
- {
- CLTRACE("TCodeSegment::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE2("TCodeSegment::Serialize serialization size error. Wrote [%d] but expected [%d]", endPos - startPos, GetSize());
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TCodeSegment::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt();
- if(iId != ESCMCodeSeg)
- {
- CLTRACE("TCodeSegment::Deserialize Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TCodeSegmentVersion)aReader.ReadShort(); // 2
-
- if(iVersion == ETCodeSegmentVersion1)
- {
- // read data v1 format
- iCodeSegType = (TCodeSegType)aReader.ReadInt();
- iCodeSegMemInfo.iCodeBase = aReader.ReadInt();
- iCodeSegMemInfo.iCodeSize = aReader.ReadInt();
- iCodeSegMemInfo.iConstDataBase = aReader.ReadInt();
- iCodeSegMemInfo.iConstDataSize = aReader.ReadInt();
- iCodeSegMemInfo.iInitialisedDataBase = aReader.ReadInt();
- iCodeSegMemInfo.iInitialisedDataSize = aReader.ReadInt();
- iCodeSegMemInfo.iUninitialisedDataBase = aReader.ReadInt();
- iCodeSegMemInfo.iUninitialisedDataSize = aReader.ReadInt();
- iXip = aReader.ReadInt();
- iNameLength = aReader.ReadInt(); // 4
-
- if(iName.Ptr() && iName.MaxLength() >= iNameLength)
- {
- iName.SetLength(0);
-
- for(TInt cnt = 0; cnt < iNameLength; cnt++)
- {
- iName.Append(aReader.ReadByte()); //iCategorySize bytes
- }
- }
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TCodeSegment::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE2("TCodeSegment::Deserialize serialization size error. Read [%d] but expected [%d]", endPos - startPos, GetSize());
- iId = ESCMLast; //unrecognised header
-
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TCodeSegment::GetSize() const
- {
- if(iVersion == ETCodeSegmentVersion1)
- {
- return 50 + iName.Length();
- }
- else
- {
- CLTRACE("TCodeSegment::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- /**
- * This returns the largest size this class can be
- */
- TInt TCodeSegment::GetMaxSize() const
- {
- return 50 + KMaxSegmentNameSize;
- }
- /**
- * TRawData implementation
- * @internal technology
- */
-
- /**
- * TRawData constructor
- */
- TRawData::TRawData():
- iId(ESCMRawData),
- iVersion(ETRawData1),
- iLength(0),
- iData(NULL, 0)
- {
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TRawData::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
- if(iId != ESCMRawData)
- {
- CLTRACE("TRawData::Serialize Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == ETRawData1)
- {
- if(iData.Ptr())
- {
- aWriter.WriteInt(iData.Length()); // 4
- iLength = iData.Length();
-
- for(TInt cnt = 0; cnt < iData.Length(); cnt++)
- {
- //Kern::Printf("cnt = %d \t\t\t0x%X", cnt, cnt);
- aWriter.WriteByte(iData[cnt]); //iLength bytes
- }
- }
- else
- {
- aWriter.WriteInt(0);
- }
- }
- else
- {
- CLTRACE("TRawData::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE2("TRawData::Serialize serialization size error. Wrote [%d] but expected [%d]", endPos - startPos, GetSize());
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TRawData::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMRawData)
- {
- CLTRACE("TRawData::Deserialize Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TTRawDataVersion)aReader.ReadShort(); // 2
-
- if(iVersion == ETRawData1)
- {
- iLength = aReader.ReadInt(); // 4
-
- if(iData.Ptr())
- {
- //Deserialise as much as we can into this buffer - it may be that the caller doesnt want all of it
- iData.SetLength(0);
- TUint amtToRead = (iData.MaxLength() >= iLength) ? iLength : iData.MaxLength();
-
- for(TUint cnt = 0; cnt < amtToRead; cnt++)
- {
- iData.Append(aReader.ReadByte()); //iCategorySize bytes
- }
-
- //move reader along what we havent read
- aReader.SetPosition(aReader.CurrentPosition() + (iLength - amtToRead));
- }
- else
- {
- aReader.SetPosition(aReader.CurrentPosition() + iLength);
- }
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TRawData::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE2("TRawData::Deserialize serialization size error. Read [%d] but expected [%d]", endPos - startPos, GetSize());
- iId = ESCMLast; //unrecognised header
-
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Same as Deserialise except it only starts copying data into the buffer
- * when it reaches aStartPos bytes into the data
- * @param aStartPos
- * @param aReader
- * @return
- */
- TInt TRawData::Deserialize(TInt aStartPos, TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMRawData)
- {
- CLTRACE("TRawData::Deserialize Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TTRawDataVersion)aReader.ReadShort(); // 2
-
- if(iVersion == ETRawData1)
- {
- iLength = aReader.ReadInt(); // 4
-
- if(iData.Ptr())
- {
- //Deserialise as much as we can into this buffer - it may be that the caller doesnt want all of it
- iData.SetLength(0);
- aReader.SetPosition(aReader.CurrentPosition() + aStartPos);
-
- TUint amtToRead = (iData.MaxLength() >= iLength) ? iLength : iData.MaxLength();
-
- for(TUint cnt = 0; cnt < amtToRead; cnt++)
- {
- iData.Append(aReader.ReadByte()); //iCategorySize bytes
- }
-
- //move reader along what we havent read
- aReader.SetPosition(aReader.CurrentPosition() + (iLength - (amtToRead + aStartPos)));
- }
- else
- {
- aReader.SetPosition(aReader.CurrentPosition() + iLength);
- }
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TRawData::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE2("TRawData::Deserialize serialization size error. Read [%d] but expected [%d]", endPos - startPos, GetSize());
- iId = ESCMLast; //unrecognised header
-
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TRawData::GetSize() const
- {
- if(iVersion == ETRawData1)
- {
- return 10 + iLength;
- }
- else
- {
- CLTRACE("TRawData::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
-
- /**
- * TMemoryDump implementation
- * @internal technology
- */
-
- /**
- * TMemoryDump Constructor
- */
- TMemoryDump::TMemoryDump():
- iId(ESCMMemory),
- iVersion(EMemDumpVersion1),
- iStartAddress(0),
- iPid(0),
- iLength(0)
- {
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TMemoryDump::GetSize() const
- {
- if(iVersion == EMemDumpVersion1)
- {
- return 22;
- }
- else
- {
- CLTRACE("TMemoryDump::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TMemoryDump::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
- if(iId != ESCMMemory)
- {
- CLTRACE("TMemoryDump::Serialize Error - Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == EMemDumpVersion1)
- {
- // write data v1 format
- aWriter.WriteInt(iStartAddress); // 4
- aWriter.WriteInt64(iPid); // 8
- aWriter.WriteInt(iLength); // 4
- }
- else
- {
- CLTRACE("TMemoryDump::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TMemoryDump::Serialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TMemoryDump::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMMemory)
- {
- CLTRACE("TMemoryDump::Deserialize() ERROR Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TMemDumpVersionVersion)aReader.ReadShort(); // 2
-
- if(iVersion == EMemDumpVersion1)
- {
- // read data v1 format
- iStartAddress = aReader.ReadInt(); // 4
- iPid = aReader.ReadInt64(); // 8
- iLength = aReader.ReadInt(); // 4
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TMemoryDump::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TMemoryDump::Deserialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
- /**
- * TTraceDump implementation
- * @internal technology
- */
-
- /**
- * TTraceDump Constructor
- */
- TTraceDump::TTraceDump():
- iId(ESCMTraceData),
- iVersion(ETraceDumpVersion1),
- iSizeOfMemory(0),
- iNumberOfParts(0)
- {
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TTraceDump::GetSize() const
- {
- if(iVersion == ETraceDumpVersion1)
- {
- return 14;
- }
- else
- {
- CLTRACE("TTraceDump::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TTraceDump::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
- if(iId != ESCMTraceData)
- {
- CLTRACE("TTraceDump::Serialize Error - Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == ETraceDumpVersion1)
- {
- // write data v1 format
- aWriter.WriteInt(iSizeOfMemory); // 4
- aWriter.WriteInt(iNumberOfParts); // 4
- }
- else
- {
- CLTRACE("TTraceDump::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TTraceDump::Serialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TTraceDump::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMTraceData)
- {
- CLTRACE("TTraceDump::Deserialize() Error: Corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TTraceDumpVersion)aReader.ReadShort(); // 2
-
- if(iVersion == ETraceDumpVersion1)
- {
- // read data v1 format
- iSizeOfMemory = aReader.ReadInt(); // 4
- iNumberOfParts = aReader.ReadInt(); // 4
-
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TTraceDump::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TTraceDump::Deserialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
- }
-
-//eof
--- a/kernel/eka/debug/crashMonitor/src/scmlockdata.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmlockdata.cpp
-// some utility classes for writing data to flash buffer
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-
-#include <scmdatatypes.h>
-
-namespace Debug
- {
-
- /**
- * TSCMLockData constructor
- * @param none
- */
- TSCMLockData::TSCMLockData()
- : iId(ESCMLocks)
- , iMutexHoldCount(-1)
- , iMutexThreadWaitCount(-1)
- {
- }
-
- /**
- * TSCMLockData Serialize
- * @param aWriter byte stream to use
- * @return N/A
- */
- TInt TSCMLockData::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- if(iId != ESCMLocks)
- {
- CLTRACE("TSCMLockData::Serialize Corrupt ID");
- return KErrCorrupt;
- }
-
- // write id first
- aWriter.WriteInt(iId); // 4
- // 2 counts written as shorts (should be enough range!)
- aWriter.WriteShort((TInt16) iMutexHoldCount); // 2
- aWriter.WriteShort((TInt16) iMutexThreadWaitCount); // 2
- aWriter.WriteShort((TInt16) iLockCount); // 2
-
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TSCMLockData::Serialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return void
- */
- TInt TSCMLockData::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMLocks)
- {
- CLTRACE("TSCMLockData::Deserialize Corrupt ID read");
- return KErrCorrupt;
- }
-
- iMutexHoldCount = (TInt) aReader.ReadShort();
- iMutexThreadWaitCount = (TInt) aReader.ReadShort();
- iLockCount = (TInt) aReader.ReadShort();
-
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- CLTRACE("TSCMLockData::Deserialize size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TSCMLockData::GetSize() const
- {
- return KSCMLockDataMaxSize;
- }
-
- /**
- * MutexHoldCount
- * @param none
- * @return mutex hold count
- */
- TInt TSCMLockData::MutexHoldCount() const
- {
- return iMutexHoldCount;
- }
-
- /**
- * SetMutexHoldCount
- * @param
- * @return
- */
- void TSCMLockData::SetMutexHoldCount(TInt aMutexHoldCount)
- {
- iMutexHoldCount = aMutexHoldCount;
- }
-
- /**
- * MutexThreadWaitCount
- * @param none
- * @return number of threads waiting on held mutex - will only be valid if
- * MutexHoldCount > 0
- */
- TInt TSCMLockData::MutexThreadWaitCount() const
- {
- return iMutexThreadWaitCount;
- }
-
- /**
- * SetMutexThreadWaitCount
- * @param TInt - number of threads waiting on held mutex(es)
- * @return void
- */
- void TSCMLockData::SetMutexThreadWaitCount(TInt aMutexThreadWaitCount)
- {
- iMutexThreadWaitCount = aMutexThreadWaitCount;
- }
-
- /**
- * LockCount
- * @param none
- * @return TIOnt - the lock count
- */
- TInt TSCMLockData::LockCount() const
- {
- return iLockCount;
- }
-
- /**
- * SetLockCount
- * @param TInt - number of locks held
- * @return void
- */
- void TSCMLockData::SetLockCount(TInt aLockCount)
- {
- iLockCount = aLockCount;
- }
-
- TBool TSCMLockData::operator == (const TSCMLockData& aOther) const
- {
- return ( iId == aOther.iId &&
- iMutexHoldCount == aOther.iMutexHoldCount &&
- iMutexThreadWaitCount == aOther.iMutexThreadWaitCount &&
- iLockCount == aOther.iLockCount );
- }
-
- TBool TSCMLockData::operator != (const TSCMLockData& aOther) const
- {
- return !(*this == aOther);
- }
- }
-
-
--- a/kernel/eka/debug/crashMonitor/src/scmmulticrashinfo.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmmulticrashinfo.cpp
-// Class to store info about the crash flash to enable multiple crashes
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#include <scmdatatypes.h>
-
-namespace Debug
- {
- /**
- * constructor
- */
- SCMMultiCrashInfo::SCMMultiCrashInfo()
- : iFirstBlock(NULL)
- , iCurrentBlock(NULL)
- {
- }
-
- /**
- * destructor
- */
- SCMMultiCrashInfo::~SCMMultiCrashInfo()
- {
- ClearList();
- }
-
- /** add a pointer to a block to the list - takes ownership of block
- * @param SCMCrashBlockEntry* aBlockEntry block to add
- */
- void SCMMultiCrashInfo::AddBlock(SCMCrashBlockEntry* aBlockEntry)
- {
- if(aBlockEntry)
- {
- CLTRACE4("SCMMultiCrashInfo::AddBlock iBlockOffset = [%d] [0x%X] iBlockSize = [%d] [0x%X]"
- , aBlockEntry->iBlockOffset,aBlockEntry->iBlockOffset, aBlockEntry->iBlockSize, aBlockEntry->iBlockSize);
- if(!iFirstBlock)
- {
- // adding to empty list
- iFirstBlock = aBlockEntry;
- iCurrentBlock = iFirstBlock;
- }
- else
- {
- SCMCrashBlockEntry* p = iFirstBlock;
- while(p->iNext)
- {
- p = p->iNext;
- }
- p->iNext = aBlockEntry;
- }
- }
- else
- {
- CLTRACE("SCMMultiCrashInfo::AddBlock Adding a NULL block !");
- }
- }
-
-
- /** add a pointer to a block to the list - takes ownership of block
- * @return SCMCrashBlockEntry* returns NULL when no more blocks
- * @param none
- */
- SCMCrashBlockEntry* SCMMultiCrashInfo::GetNextBlock()
- {
- SCMCrashBlockEntry* p = iCurrentBlock;
- if(iCurrentBlock)
- {
- iCurrentBlock = iCurrentBlock->iNext;
- }
- return p;
- }
-
- /**
- * sets current block to first in list
- */
- void SCMMultiCrashInfo::Reset()
- {
- iCurrentBlock = iFirstBlock;
- }
-
- /**
- * Clears all entries in the list
- */
- void SCMMultiCrashInfo::ClearList()
- {
- SCMCrashBlockEntry* p = iFirstBlock;
-
- while(p)
- {
- SCMCrashBlockEntry* tmp = p;
- p = p->iNext;
- delete tmp;
- }
-
- iFirstBlock = iCurrentBlock = NULL;
- }
- }
-
-//eof
-
--- a/kernel/eka/debug/crashMonitor/src/scmonitor.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1032 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmonitor.cpp
-// Core dump server - Kernel side crash monitor
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#include <scmonitor.h>
-#include <kernel/monitor.h>
-#include <assp.h>
-#include <drivers/crashflash.h>
-#include <kernel/klib.h>
-#include <crashlogwalker.h>
-#include <scmconfigitem.h>
-
-#include "scmdatasave.h"
-
-GLDEF_D SCMonitor TheSCMonitor; //global definition of SCMonitor
-
-//keep things 4 byte aligned
-const TInt KRestartType = SCMonitor::ESoftRestart;
-
-/**
-SCMonitor constructor
-*/
-SCMonitor::SCMonitor()
- : iMultiCrashInfo(NULL)
- {
- }
-
-SCMonitor::~SCMonitor()
- {
- delete iMultiCrashInfo;
- }
-
-/**
- Print data to the corresponding output channel. Derived from monitor
- @param aDes the buffer containing the data
- */
-void SCMonitor::Print (const TDesC8& aDes )
- {
- //intended to do nothing
- }
-
-/**
- * Allocates resources for SCMonitor
- * cant fully construct in constructor as we are a kernel extension and resources are limited when we are created
- */
-void SCMonitor::StableConstruction()
- {
- LOG_CONTEXT
- iDataSave = new SCMDataSave(this, TheSCMonitor.iFlash);
-
- //Configuration object for use upon crash
- iScmConfig = new SCMConfiguration();
- TInt err = iScmConfig->SetDefaultConfig();
- if(KErrNone != err)
- {
- CLTRACE1("SCMonitor::StableConstruction - Unable to set default config err = %d", err);
- }
-
-
-#ifdef NO_MULTICRASHINFO
- iMultiCrashInfo = NULL;
-#else
-
- //We need to take a look at the flash map from variant_norflash_layout.h
- iMultiCrashInfo = new SCMMultiCrashInfo();
-
- TUint numberBlocks = KCrashLogSize / KCrashLogBlockSize;
- for(TUint32 cnt = 0; cnt < numberBlocks; cnt++)
- {
- iMultiCrashInfo->AddBlock(new SCMCrashBlockEntry(cnt, cnt * KCrashLogBlockSize, KCrashLogBlockSize));
- }
-#endif
- }
-
-/**
- * Start a secondary DFC queue for the Flash and Init the flash in the variant(h4)
- * @param aAny
- */
-void StartSecondary (TAny* )
- {
- LOG_CONTEXT
- //InitFlash is implemented in the variant as it creates a variant
- //specific derived CrashFlash
- TheSCMonitor.InitFlash ( );
- TheSCMonitor.StableConstruction();
- }
-
-/**
- * Global method to create a dfc queue
- * @param Method to intialise the flash.
- * @param Null
- * @param Gets the address of the supervisor thread DFC queue
- * @param TDfcQ priority number
- * @return a DFC object
- */
-GLDEF_C TDfc StartSecondaryDfc(&StartSecondary, NULL, Kern::SvMsgQue(), KMaxDfcPriority-1);
-
-/**
- * Kernel Main module entry - Own implementation( similar to crash logger)
- * @param aReason reason to enter to the method
- * @return One of the system wide codes
- */
-GLDEF_C TInt KernelModuleEntry(TInt aReason)
- {
- if(aReason==KModuleEntryReasonVariantInit0)
- {
- new(&TheSCMonitor) SCMonitor;
- // We are going to register the system Crash monitor here so that the order
- // the monitor modules are placed in rom is preserved.
- // The monitor is not fully intialised here.
- //the variant target is missing as we still have to finalise on the crash flash
- //implementation. H2 & H4 doesnt support currently.
- LOG_CONTEXT
- CLTRACE("Installing System Crash Monitor");
- Monitor::RegisterMonitorImpl (&TheSCMonitor );
- return KErrNone;
- }
- else if (aReason==KModuleEntryReasonExtensionInit0 )
- {
- return KErrNone;
- }
- else if (aReason==KModuleEntryReasonExtensionInit1 )
- {
- LOG_CONTEXT
- CLTRACE("Enqueing dfc to init crash flash for System Crash Monitor after all modules loaded");
- StartSecondaryDfc.Enque ( );
- return KErrNone;
- }
- return KErrArgument;
- }
-
-/**
- Method to intialize the system crash monitor
- @param aCategory the fault category type
- @param aReason the reason for crash
- @return restart type
- */
-TInt SCMonitor::Init2 (TAny* aCategory, TInt aReason )
- {
- LOG_CONTEXT
- __KTRACE_OPT(KALWAYS, Kern::Printf("\n\nSystem Crash Monitor Launched: To Analyse Crash Produced Use Core Dump Server\n"));
-
- //Start logging the data:
- //Need to lock kernel to access object containers (it technically is anyway, but flag isnt set)
- NKern::Lock();
- DoCrash(aCategory, aReason);
- NKern::Unlock();
-
- __KTRACE_OPT(KALWAYS, Kern::Printf("System Crash Monitor Finished: Log Size = [%d]\n", iDataSave->iCrashInf.iLogSize));
-
- return KRestartType;
- }
-
-/**
- * This is responsible for setting up any structures required for processing of the crash
- * @param aCategory the fault category type
- * @param aReason
- */
-void SCMonitor::DoCrash(TAny* aCategory, TInt aReason )
- {
- // get debug mask
- TInt dbgMask = Kern::SuperPage().iDebugMask[0];
-
- // if we are writing to the comm port then we need to turn off other debug messages
- if( iDataSave->GetWriteSelect() == SCMDataSave::EWriteComm)
- {
- Kern::SuperPage().iDebugMask[0] = 0;
- }
-
- if(!aCategory)
- {
- CLTRACE("\tNULL category retrieved and returning");
- TheSCMonitor.iFlash->EndTransaction();
- return;
- }
-
- iFrame = NULL;
-
- CLTRACE("\tAbout to set category -- note: can occasionaly crash board");
- iFaultCategory = *(const TDesC8*)aCategory; // this crashes the board sometimes
- iFaultReason = aReason;
- Epoc::SetMonitorExceptionHandler ((TLinAddr)HandleException );
-
- // get the first start block
- // will retieve start of flash by default
- SCMCrashBlockEntry block;
- TInt err = GetNextCrashStartPoint(block); // will also attempt to read iScmConfig
-
- if(KErrNone == err)
- {
- CLTRACE2("SCMonitor::DoCrash next crash will be written at blocknumber = %d offset %d"
- , block.iBlockNumber, block.iBlockOffset);
- }
- else
- {
- CLTRACE1("SCMonitor::DoCrash Failed to find a valid block to write to, can not continue. err = [%d]", err);
- return;
- }
-
- TUint crashId = block.iBlockNumber;
- iDataSave->iWriter->ResetBytesWritten();
-
- //Write the crash (1st pass is to gather header data)
- TInt spaceRequired = ProcessCrash(block, crashId, EFalse);
-
- // now do the real write
- // prepare flash for data
- TheSCMonitor.iFlash->StartTransaction();
- TheSCMonitor.iFlash->SetWritePos(block.iBlockOffset);
-
- //write the crash this time
- ProcessCrash(block, crashId, ETrue);
-
- TheSCMonitor.iFlash->EndTransaction();
-
- // restore debug mask
- Kern::SuperPage().iDebugMask[0] = dbgMask;
- }
-
-
-/**
- * This walks the existing crash log and finds out where current crashes finish
- * @param aBlockEntry Block to use. Only valid if KErrNone is returned.
- * @return One of the OS wide codes
- */
-TInt SCMonitor::GetNextCrashStartPoint(SCMCrashBlockEntry& aBlockEntry)
- {
- LOG_CONTEXT
-
- //First thing is to try and read the config
- TBool configFound = (iDataSave->ReadConfig(*iScmConfig) == KErrNone);
-
- if( iMultiCrashInfo)
- {
- /**
- * data save has been configured to use multicrash info to find the next block we are on we need to scan each
- * block to see if it contains a valid header. if we find an empty block in our block list then that is the
- * one we will use if we find no empty blocks then we have no room left
- */
- iMultiCrashInfo->Reset();
- SCMCrashBlockEntry* block = iMultiCrashInfo->GetNextBlock();
- TBool blockFound = EFalse;
-
- //For any crashes in flash, we need to record where they end, so that we can then go to the next
- //block after the one in which it ends
- TInt crashEndPoint = 0;
-
- while(block)
- {
- CLTRACE1("SCMonitor::GetNextCrashStartPoint Processing block number %d", block->iBlockNumber );
-
- //If we have already found our block, we should erase subsequent ones for use
- if(blockFound)
- {
- TInt err = EraseFlashBlock(*block);
- if(err != KErrNone)
- {
- return err;
- }
-
- block = iMultiCrashInfo->GetNextBlock();
- continue;
- }
-
- //is this block before a crash end? if it is, we cant use it as a crash can span multiple blocks
- if(block->iBlockOffset >= crashEndPoint)
- {
- //special condition if we have a config
- TUint startPos = block->iBlockOffset;
- TUint skipBytes = 0;
- if(configFound && block->iBlockOffset == 0)
- {
- startPos+=iScmConfig->GetSize();
-
- //must align to flash for read
- skipBytes = startPos % KFlashAlignment;
- startPos -= skipBytes;
- }
-
- // try and read an info header at these flash coords
- TBuf8<TCrashInfoHeader::KSCMCrashInfoMaxSize + KFlashAlignment> buf;
- buf.SetLength(TCrashInfoHeader::KSCMCrashInfoMaxSize + KFlashAlignment);
-
- CLTRACE1("(SCMonitor::GetNextCrashStartPoint) reading at offset %d", block->iBlockOffset);
-
- TheSCMonitor.iFlash->SetReadPos(startPos);
- TheSCMonitor.iFlash->Read(buf);
-
- // create the buffer applying the offset of bytes skipped
- TByteStreamReader reader(const_cast<TUint8*> (buf.Ptr() + skipBytes));
-
- TCrashInfoHeader header;
- TInt err = header.Deserialize(reader);
-
- if(err == KErrCorrupt)
- {
- CLTRACE2("(SCMonitor::GetNextCrashStartPoint) Found empty block blocknumber %d blockoffset = %d"
- , block->iBlockNumber, block->iBlockOffset);
-
- blockFound = ETrue;
- aBlockEntry = *block;
-
- continue; //Dont get next block, as next run will erase this current block for use
- }
- else
- {
- crashEndPoint = header.iLogSize + startPos;
- CLTRACE3("(SCMonitor::GetNextCrashStartPoint) In block [%d] we found a valid crash header. This crash finishes at [%d] [0x%X]", block->iBlockNumber, crashEndPoint, crashEndPoint);
- }
- }
-
- block = iMultiCrashInfo->GetNextBlock();
- }
-
- if(blockFound)
- {
- return KErrNone;
- }
- else
- {
- //CLTRACE("(SCMonitor::GetNextCrashStartPoint) No available blocks TREATING as NO MULTICRASH INFO will write to default block");
- //In this case should we just overwrite old crashes and return the first block as the comment above suggests
- //return blockFound;
- }
- }
-
- // no multi crash info supplied - use default first block settings
- TInt err = EraseEntireFlashPartition();
- if(err != KErrNone)
- {
- CLTRACE1("Unable to delete area required to log to flash. Aborting. Error - [%d]", err);
- return err;
- }
-
- aBlockEntry = SCMCrashBlockEntry(0,0,0);
- return KErrNone;
- }
-
-/**
- * Handles the processing of the crash
- * @return The size of the crash log (including header) that has been/will be written
- */
-TInt SCMonitor::ProcessCrash(const SCMCrashBlockEntry& aBlock, TUint aCrashId, TBool aCommit)
- {
- LOG_CONTEXT
- CLTRACE5("aBlock.iBlockOffset = [%d] [0x%X] aBlock.iBlockNumber = %d aBlock.iBlockSize = [%d] [0x%X]",
- aBlock.iBlockOffset, aBlock.iBlockOffset, aBlock.iBlockNumber, aBlock.iBlockSize, aBlock.iBlockSize);
-
- // reset writer for start of each crash
- iDataSave->iWriter->ResetBytesWritten();
- TInt logLevel = 0;
-
- if(aCommit)
- {
- logLevel = KALWAYS;
- iDataSave->iWriter->EnablePhysicalWriting();
- }
- else
- {
-#if defined(_DEBUG)
- logLevel = KDEBUGGER;
-#else
- logLevel = KALWAYS; //Doesnt matter, KTRACE OPT is empty for rel builds
- if(logLevel != KALWAYS)
- {
- //This is to avoid warning
- }
-#endif
-
- iDataSave->iWriter->DisablePhysicalWriting();
- }
-
- iDataSave->SetByteCount(aBlock.iBlockOffset);
- if(aBlock.iBlockOffset == 0 && aBlock.iBlockNumber == 0)
- {
- // this is the first crash - we need to save the config here first
- CLTRACE("(SCMonitor::ProcessCrash) - this is block 0 - WRITING CONFIG");
- iDataSave->LogConfig(*iScmConfig);
-
- //Config is not part of crash so reset bytes written
- iDataSave->SetCrashStartingPoint(iDataSave->iWriter->GetBytesWritten());
- }
- else
- {
- iDataSave->SetCrashStartingPoint(aBlock.iBlockOffset);
- }
-
- iDataSave->iWriter->ResetBytesWritten();
-
- TUint32 logSize = 0;
- TUint sizeOfObjectDumped = 0;
-
- TInt err = iDataSave->LogCrashHeader(iFaultCategory, iFaultReason, aCrashId, sizeOfObjectDumped);
- if(KErrNone != err)
- {
- CLTRACE("System Crash Monitor: Failed to create crash info header - (TCrashInfo)");
- return KRestartType;
- }
-
- logSize += sizeOfObjectDumped;
-
- //Now we must read the configuration to use. This is held at the start of our flash partition
- //and managed by the iConfig object
- iScmConfig->ResetToHighestPriority();
-
- //Always want the crash context
- iDataSave->iHdr.iCTFullRegOffset = logSize + iDataSave->GetCrashStartingPoint();
-
- err = iDataSave->LogCPURegisters(sizeOfObjectDumped);
- if(KErrNone != err)
- {
- CLTRACE1("\tError logging full registers = %d", err);
- }
-
- logSize += sizeOfObjectDumped;
-
- CLTRACE("\tAbout to enter processing loop");
- SCMDataSave::TDataToDump dump;
-
- for(;;)
- {
- //now we get each item by priority from the configuration
- TConfigItem* configItem = iScmConfig->GetNextItem();
-
- if(!configItem)
- {
- // end of list
- break;
- }
-
- CLTRACE1("\nLooking at item type [%d]", configItem->GetDataType());
- if(configItem->GetSpaceRequired() > iDataSave->SpaceRemaining())
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\t\tFor Item Type [%d]: Unable to log [0x%X] [%d] bytes because we only have [0x%X] [%d] bytes left", configItem->GetDataType(), configItem->GetSpaceRequired(), configItem->GetSpaceRequired(), iDataSave->SpaceRemaining(), iDataSave->SpaceRemaining()));
- continue;
- }
- else
- {
- CLTRACE1("Will require [%d] bytes for this item", configItem->GetSpaceRequired());
- }
-
- // only interested in logging items with priority > 0
- if( configItem->GetPriority() <= 0)
- {
- CLTRACE1("\tIgnored config item type %d priority 0", configItem->GetDataType());
- continue;
- }
-
- //there are a lot of TUints in the hdr to record where we wrote this item.
- //This will point to the one of interest for this configItem
- TUint32* offsetPointer = NULL;
-
- //now we check the type of data we wish to dump
- switch(configItem->GetDataType())
- {
- case TConfigItem::ECrashedThreadMetaData:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: ECrashedThreadMetaData at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- err = LogThreadMetaData(SCMDataSave::EThreadSpecific, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iCTMetaOffset);
-
- break;
- }
- case TConfigItem::EThreadsMetaData:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EThreadsMetaData at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- //record location we are writing to in the header
- iDataSave->iHdr.iTLstOffset = iDataSave->iWriter->GetBytesWritten();
- err = LogThreadMetaData(SCMDataSave::ESystemWide, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iTLstOffset);
-
- break;
- }
- case TConfigItem::ECrashedProcessMetaData:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: ECrashedProcessMetaData at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- err = LogProcessMetaData(SCMDataSave::EProcessSpecific, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iCPMetaOffset);
-
- break;
- }
- case TConfigItem::EProcessMetaData:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EProcessMetaData at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- err = LogProcessMetaData(SCMDataSave::ESystemWide, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iPLstOffset);
-
- break;
- }
- case TConfigItem::ECrashedProcessUsrStacks:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: ECrashedProcessUsrStacks at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- //define what we wish to dump
- dump.iMetaData = EFalse;
- dump.iCodeSegs = EFalse;
- dump.iStk = SCMDataSave::EUsrStack;
- dump.iReg = SCMDataSave::ERegSetNone;
- err = LogObjectContainers(EThread, SCMDataSave::EProcessSpecific, dump, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iCTUsrStkOffset);
-
- break;
- }
- case TConfigItem::EThreadsUsrStack:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EThreadsUsrStack at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- //define what we wish to dump
- dump.iMetaData = EFalse;
- dump.iCodeSegs = EFalse;
- dump.iStk = SCMDataSave::EUsrStack;
- dump.iReg = SCMDataSave::ERegSetNone;
-
- err = LogObjectContainers(EThread, SCMDataSave::ESystemWide, dump, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iSysSvrStkOffset);
-
- break;
- }
- case TConfigItem::ECrashedProcessSvrStacks:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: ECrashedProcessSvrStacks at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- //define what we wish to dump
- dump.iMetaData = EFalse;
- dump.iCodeSegs = EFalse;
- dump.iStk = SCMDataSave::ESvrStack;
- dump.iReg = SCMDataSave::ERegSetNone;
-
- err = LogObjectContainers(EThread, SCMDataSave::EProcessSpecific, dump, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iCTSvrStkOffset);
-
- break;
- }
- case TConfigItem::EThreadsSvrStack:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EThreadsSvrStack at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- //define what we wish to dump
- dump.iMetaData = EFalse;
- dump.iCodeSegs = EFalse;
- dump.iStk = SCMDataSave::ESvrStack;
- dump.iReg = SCMDataSave::ERegSetNone;
-
- err = LogObjectContainers(EThread, SCMDataSave::ESystemWide, dump, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iSysSvrStkOffset);
-
- break;
- }
- case TConfigItem::EThreadsUsrRegisters:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EThreadsUsrRegisters at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- //define what we wish to dump
- dump.iMetaData = EFalse;
- dump.iCodeSegs = EFalse;
- dump.iStk = SCMDataSave::EStackTypeNone;
- dump.iReg = SCMDataSave::EUserRegisters;
-
- err = LogObjectContainers(EThread, SCMDataSave::ESystemWide, dump, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iSysUsrRegOffset);
-
- break;
- }
- case TConfigItem::EThreadsSvrRegisters:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EThreadsSvrRegisters at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- //define what we wish to dump
- dump.iMetaData = EFalse;
- dump.iCodeSegs = EFalse;
- dump.iStk = SCMDataSave::EStackTypeNone;
- dump.iReg = SCMDataSave::ESupervisorRegisters;
-
- err = LogObjectContainers(EThread, SCMDataSave::ESystemWide, dump, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iSysSvrRegOffset);
-
- break;
- }
- case TConfigItem::EExceptionStacks:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EExceptionStacks at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- err = iDataSave->LogExceptionStacks(sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iExcStkOffset);
-
- break;
- }
- case TConfigItem::ECrashedProcessCodeSegs:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: ECrashedProcessCodeSegs at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- //define what we wish to dump
- dump.iMetaData = EFalse;
- dump.iCodeSegs = ETrue;
- dump.iStk = SCMDataSave::EStackTypeNone;
- dump.iReg = SCMDataSave::ERegSetNone;
-
- err = LogObjectContainers(EProcess, SCMDataSave::EProcessSpecific, dump, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iCPCodeSegOffset);
-
- break;
- }
- case TConfigItem::EProcessCodeSegs:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EProcessCodeSegs at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- //define what we wish to dump
- dump.iMetaData = EFalse;
- dump.iCodeSegs = ETrue;
- dump.iStk = SCMDataSave::EStackTypeNone;
- dump.iReg = SCMDataSave::ERegSetNone;
- err = LogObjectContainers(EProcess, SCMDataSave::ESystemWide, dump, sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iSysCodeSegOffset);
-
- break;
- }
- case TConfigItem::ETraceData:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: ETraceData at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- err = iDataSave->LogTraceBuffer(configItem->GetSizeToDump(), sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iTraceOffset);
-
- break;
- }
- case TConfigItem::ELocks:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: ELocks at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- err = iDataSave->LogLocks(sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iScmLocksOffset);
-
- break;
- }
- case TConfigItem::EKernelHeap:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EKernelHeap at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- err = iDataSave->LogKernelHeap(sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iKernelHeapOffset);
-
- break;
- }
- case TConfigItem::EVariantSpecificData:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: EVariantSpecificData at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- err = iDataSave->LogVariantSpecificData(sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iVarSpecInfOffset);
-
- break;
- }
- case TConfigItem::ERomInfo:
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tDoing: ERomInfo at [%d] offset from [%d]", iDataSave->iWriter->GetBytesWritten(), iDataSave->GetCrashStartingPoint()));
-
- err = iDataSave->LogRomInfo(sizeOfObjectDumped);
- offsetPointer = &(iDataSave->iHdr.iRomInfoOffset);
-
- break;
- }
- //unknown configuration type - something bad is going on
- default: return 0;
- }
-
- if(KErrNone != err)
- {
- __KTRACE_OPT(logLevel, Kern::Printf("\tError logging data: [%d] Type = [%d]", err, aBlock.iBlockOffset));
- continue;
- }
-
- //Set the space required so next time around we will know in advance how much space we need
- configItem->SetSpaceRequired(sizeOfObjectDumped);
-
- //Note: the following steps are only required for the first time we call process crash. The second time,
- //when physical writing is enabled, these will have been written already and so they dont matter
-
- //update the offset and logsize if we are going to dump this item
- TUint32 absoluteLogPos = logSize + iDataSave->GetCrashStartingPoint();
- if(absoluteLogPos+sizeOfObjectDumped < iDataSave->MaxLogSize())
- {
- //now, we must record where in the crash log this item will be dumped
- *offsetPointer = absoluteLogPos;
- logSize += sizeOfObjectDumped;
- }
- }
-
- iDataSave->iCrashInf.iLogSize = logSize;
- iDataSave->iWriter->FlushCache();
-
- return iDataSave->iCrashInf.iLogSize;
- }
-
-/**
- * Logs the meta data for processes
- * @param aCurrentProcess - scope to dump
- * @return one of the OS wide codes
- */
-TInt SCMonitor::LogProcessMetaData(SCMDataSave::TDumpScope aScope, TUint& aSizeDumped) const
- {
- LOG_CONTEXT
-
- SCMDataSave::TDataToDump dump;
- dump.iMetaData = ETrue;
-
- return LogObjectContainers(EProcess, aScope, dump, aSizeDumped);
- }
-
-/**
- *
- * @param aCurrentThread - to only do the current (crashed thread) or to do all the others
- * @return one of the OS wide codes
- */
-TInt SCMonitor::LogThreadMetaData(SCMDataSave::TDumpScope aScope, TUint& aSizeDumped) const
- {
- LOG_CONTEXT
-
- SCMDataSave::TDataToDump dump;
- dump.iMetaData = ETrue;
-
- return LogObjectContainers(EThread, aScope, dump, aSizeDumped);
- }
-
-/**
- * Generic method that looks at all kernel objects of aObjectType
- * @param aObjectType
- * @param aDumpScope - if you wish to dump for the the current process, current thread or entire system
- * @param aDataToDump - data you wish to dump
- * @param aSizeDumped - records how much was dumped
- * @return
- */
-TInt SCMonitor::LogObjectContainers(TObjectType aObjectType, SCMDataSave::TDumpScope aDumpScope, const SCMDataSave::TDataToDump& aDataToDump, TUint& aSizeDumped) const
- {
- aSizeDumped = 0;
-
- if(aObjectType >= ENumObjectTypes)
- {
- return KErrArgument;
- }
-
- //Get the object container for the given object type
- DObjectCon* objectContainer = Kern::Containers()[aObjectType];
- if(objectContainer == NULL)
- {
- CLTRACE("tFailed to get object container");
- return KErrNotFound;
- }
-
- //Must check the mutex on this is ok otherwise the data will be in an inconsistent state
- if(objectContainer->iMutex->iHoldCount)
- {
- CLTRACE("\tObject Container is in an inconsistant state");
- return KErrCorrupt;
- }
-
- TInt numObjects = objectContainer->Count();
- TInt err = KErrNone;
-
- for(TInt cnt = 0; cnt< numObjects; cnt ++)
- {
- DObject* object = (*objectContainer)[cnt];
-
- //Are we interested in the object? scope only relevant for thread and process objects, for others, the scope is implicit
- if(aObjectType == EThread)
- {
- switch(aDumpScope)
- {
- case SCMDataSave::EThreadSpecific :
- {
- //if we are interested in the current thread and this is not it, continue
- if(((DThread*)object) != &Kern::CurrentThread())
- continue;
- break;
- }
- case SCMDataSave::EProcessSpecific :
- {
- //if we are interested in the current proc and this is not it, continue
- if(((DThread*)object)->iOwningProcess != &Kern::CurrentProcess())
- continue;
- break;
- }
- case SCMDataSave::ESystemWide :
- default:
- break;
- }
- }
- else if(aObjectType == EProcess)
- {
- switch(aDumpScope)
- {
- case SCMDataSave::EProcessSpecific :
- {
- if((DProcess*)object != &Kern::CurrentProcess())
- continue;
- break;
- }
- case SCMDataSave::EThreadSpecific : //thread specific process doesnt make sense
- return KErrArgument;
- case SCMDataSave::ESystemWide :
- default:
- break;
- }
- }
-
- //Now we look at the data we have been asked to dump
- if(aDataToDump.iMetaData)
- {
- TUint dumped = 0;
- err = HelpDumpMetaData(object, aObjectType, dumped);
- if(KErrNone != err)
- {
- CLTRACE1("Failed to meta data: [%d]", err);
- return err;
- }
- aSizeDumped += dumped;
- }
-
- if(aDataToDump.iCodeSegs)
- {
- if(aObjectType != EProcess)
- {
- return KErrArgument;
- }
-
- TUint dumped = 0;
- err = iDataSave->LogCodeSegments((DProcess*)object, dumped);
- if(KErrNone != err)
- {
- CLTRACE1("Failed to log code segments: [%d]", err);
- return err;
- }
- aSizeDumped += dumped;
- }
-
- if(aDataToDump.iStk != SCMDataSave::EStackTypeNone)
- {
- TUint dumped = 0;
- err = HelpDumpStacks(object, aObjectType, dumped, aDataToDump.iStk);
- if(KErrNone != err)
- {
- CLTRACE1("Failed to log stacks: [%d]", err);
- return err;
- }
- aSizeDumped += dumped;
- }
-
- if(aDataToDump.iReg != SCMDataSave::ERegSetNone)
- {
- if(aObjectType != EThread)
- {
- return KErrArgument;
- }
- TUint dumped = 0;
- err = iDataSave->LogRegisters((DThread*)object, aDataToDump.iReg, dumped);
- if(KErrNone != err && KErrNotSupported !=err) //we expect to send down a KErrNotSupported when we ask for Full CPU set for the non crashed thread - thats fine
- {
- CLTRACE1("Failed to log registers: [%d]", err);
- return err;
- }
- aSizeDumped += dumped;
- }
- }
-
- return KErrNone;
- }
-
-/**
- * Helper method for dumping stacks. Looks to see what type of stack we want and then calls
- * appropriate method
- * @param aObject The DThread object whose stack we want
- * @param aObjectType The object type of this aObject. Anything other than EThread will give KErrArgument
- * @param aSizeDumped Holds the size of the stack dumped after processing
- * @param aStkType The type of stack to be dumped
- * @see TObjectType
- * @see SCMDataSave::TStackType
- * @return One of the system wide codes
- */
-TInt SCMonitor::HelpDumpStacks(DObject* aObject, TObjectType aObjectType, TUint& aSizeDumped, SCMDataSave::TStackType aStkType) const
- {
- //verify args
- if(aObjectType != EThread)
- {
- return KErrArgument;
- }
-
- switch(aStkType)
- {
- case SCMDataSave::EUsrStack:
- {
- return iDataSave->LogThreadUserStack((DThread*)aObject, ETrue, aSizeDumped);
- }
- case SCMDataSave::ESvrStack:
- {
- return iDataSave->LogThreadSupervisorStack((DThread*)aObject, ETrue, aSizeDumped);
- }
- default: return KErrArgument;
- }
- }
-
-/**
- * Helper method to dump meta data about a DThread or a DProcess object
- * @param aObject DObject to use
- * @param aObjectType Type of DObject. Must be EThread or EProcess
- * @param aSizeDumped Holds the size of the stack dumped after processing
- * @return
- */
-TInt SCMonitor::HelpDumpMetaData(DObject* aObject, TObjectType aObjectType, TUint& aSizeDumped) const
- {
- aSizeDumped = 0;
-
- switch(aObjectType)
- {
- case EThread:
- {
- return iDataSave->LogThreadData((DThread*)aObject, aSizeDumped);
- }
- case EProcess:
- {
- return iDataSave->LogProcessData((DProcess*)aObject, aSizeDumped);
- }
- default: return KErrArgument;
- }
- }
-
-/**
- * Wrapper method around the flash erase block fundtion to determine if the erase was succesful.
- * If the erase was not succesful we can't continue as we cannot write.
- * @param aBlockOffset Block to erase
- * @return One of the OS wide codes
- */
-TInt SCMonitor::EraseFlashBlock(const SCMCrashBlockEntry& aBlock)
- {
- iFlash->StartTransaction();
-
- TInt numAttempts = 0;
- while(numAttempts < KFlashEraseAttempts)
- {
- iFlash->SetWritePos(aBlock.iBlockOffset);
- iFlash->EraseFlashBlock(aBlock.iBlockOffset);
-
- //we will read the flash to make sure that it set the block to all 1's (well not all, just the start)
- TBuf8<sizeof(TUint32)> buf;
- buf.SetLength(sizeof(TUint32));
-
- iFlash->SetReadPos(aBlock.iBlockOffset);
- iFlash->Read(buf);
-
- volatile TUint32* result = (TUint32*)buf.Ptr();
- if(*result == 0xFFFFFFFF)
- {
- __KTRACE_OPT(KALWAYS, Kern::Printf("Erase of block [0x%X] succesful after [%d] attempts", aBlock.iBlockOffset, numAttempts+1))
- iFlash->EndTransaction();
- return KErrNone;
- }
-
- numAttempts++;
-
- //Sometimes a write to the block helps the next erase
- TUint32 bytesWritten = 0;
- while(bytesWritten < aBlock.iBlockSize)
- {
- TBuf8<sizeof(TUint8)> num;
- num.Append(0x0);
- iFlash->Write(num);
- bytesWritten++;
- }
- }
-
- __KTRACE_OPT(KALWAYS, Kern::Printf("After %d attempts, we were unable to erase the flash block at [0x%X]. This could be because "
- "the driver is defective or because the flash has gone past its lifetime. Whatever it is though, "
- "we cannot continue.", KFlashEraseAttempts, aBlock.iBlockOffset));
-
- iFlash->EndTransaction();
- return KErrAbort;
- }
-
-/**
- * This erases each block in the flash partition
- * @return One of the system wide codes
- */
-TInt SCMonitor::EraseEntireFlashPartition()
- {
- if(iMultiCrashInfo)
- {
- iMultiCrashInfo->Reset();
-
- SCMCrashBlockEntry* block = iMultiCrashInfo->GetNextBlock();
- while(block)
- {
- TInt err = EraseFlashBlock(*block);
- if(KErrNone != err)
- {
- return err;
- }
-
- block = iMultiCrashInfo->GetNextBlock();
- }
-
- return KErrNone;
- }
-
- CLTRACE("SCMonitor::EraseEntireFlashPartition() -- No Flash MAP available, trying to use the raw driver to delete.");
- TheSCMonitor.iFlash->EraseLogArea();
-
- return KErrNone;
- }
-
-//eof scmonitor.cpp
-
--- a/kernel/eka/debug/crashMonitor/src/scmprocessdata.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,178 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmprocessdata.cpp
-// Core dump server - Process Data for System Crash
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#include <scmdatatypes.h>
-
-namespace Debug
- {
- /**
- * TProcessData implementation
- * @internal technology
- */
-
- /**
- * TProcessData constructor
- */
- TProcessData::TProcessData()
- :iId(ESCMProcessData)
- ,iVersion(EProcData1)
- ,iPid(0)
- ,iNamesize(0)
- ,iPriority(0)
- ,iSpare1(0)
- ,iSpare2(0)
- ,iSpare3(0)
- {
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return One of the OS wide codes
- */
- TInt TProcessData::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
-
- if(iId != ESCMProcessData)
- {
- CLTRACE("TProcessData::Serialize Corrupt ID");
- return KErrCorrupt;
- }
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == EProcData1)
- {
- // write data v1 format
- aWriter.WriteInt(iPriority); // 4
- aWriter.WriteInt64(iPid); // 8
- if(iName.Ptr())
- {
- aWriter.WriteInt(iName.Length()); // 4
- for(TInt cnt = 0; cnt < iName.Length(); cnt++)
- {
- aWriter.WriteByte(iName[cnt]);
- }
- }
- else
- {
- aWriter.WriteInt(0);
- }
-
-
- }
- else
- {
- CLTRACE("TProcessData::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE2("TProcessData::Serialize serialization size error. Wrote [%d] but expected [%d]", endPos - startPos, GetSize());
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return One of the OS wide codes
- */
- TInt TProcessData::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMProcessData)
- {
- CLTRACE("TProcessData::Deserialize failed - Read corrupt ID");
- return KErrCorrupt;
- }
-
- iVersion = (TProcessDataVersion)aReader.ReadShort(); // 2
-
- if(iVersion == EProcData1)
- {
- // read data v1 format
- iPriority = aReader.ReadInt(); // 4
- iPid = aReader.ReadInt64(); // 8
-
- iNamesize = aReader.ReadInt(); // 4
-
- if(iName.Ptr() && iName.MaxLength() >= (TInt)iNamesize)
- {
- iName.SetLength(0);
-
- for(TUint cnt = 0; cnt < iNamesize; cnt++)
- {
- iName.Append(aReader.ReadByte()); //iCategorySize bytes
- }
- }
-
-
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TProcessData::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TProcessData::Deserialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TProcessData::GetSize() const
- {
- if(iVersion == EProcData1)
- {
- return 22 + iName.Length();
- }
- else
- {
- CLTRACE("TProcessData::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- }
--- a/kernel/eka/debug/crashMonitor/src/scmromdata.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmromdata.cpp
-// Core dump server - ROM Data for System Crash
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#include <scmdatatypes.h>
-
-namespace Debug
- {
- /**
- * TRomHeaderData implementation
- * @internal technology
- */
-
- /**
- * TRomHeaderData constructor
- */
- TRomHeaderData::TRomHeaderData():
- iId(ESCMRomHeader),
- iVersion(ERomHeaderDataVersion1),
- iMajorVersion(0),
- iMinorVersion(0),
- iBuildNumber(0),
- iTime(0)
- {
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return void
- */
- TInt TRomHeaderData::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- if(iId != ESCMRomHeader)
- {
- CLTRACE("TRomHeaderData::Serialize Corrupt ID");
- return KErrCorrupt;
- }
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == ERomHeaderDataVersion1)
- {
- //ROM time
- aWriter.WriteInt64(iTime); // 8
-
- //Now the ROM version
- aWriter.WriteByte(iMajorVersion); // 1
- aWriter.WriteByte(iMinorVersion); // 1
- aWriter.WriteShort(iBuildNumber); // 2
- }
- else
- {
- CLTRACE("TRomHeaderData::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt pos1 = aWriter.CurrentPosition();
- if( pos1 - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TRomHeaderData::Serialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return void
- */
- TInt TRomHeaderData::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMRomHeader)
- {
- CLTRACE("TRomHeaderData::Deserialize Corrupt ID read");
- return KErrCorrupt;
- }
-
- iVersion = (TRomHeaderDataVersion)aReader.ReadShort(); // 2
-
- if(iVersion == ERomHeaderDataVersion1)
- {
- //ROM time
- iTime = aReader.ReadInt64(); // 8
-
- //Now the ROM version
- iMajorVersion = aReader.ReadByte(); // 1
- iMinorVersion = aReader.ReadByte(); // 1
- iBuildNumber = aReader.ReadShort(); // 2
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TRomHeaderData::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt pos1 = aReader.CurrentPosition();
- if( pos1 - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TRomHeaderData::Deserialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TRomHeaderData::GetSize() const
- {
- if(iVersion == ERomHeaderDataVersion1)
- {
- return 18;
- }
- else
- {
- CLTRACE("ERomHeaderDataVersion1::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- }
--- a/kernel/eka/debug/crashMonitor/src/scmthreaddata.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\debug\crashMonitor\src\scmthreaddata.cpp
-// Core dump server - Thread Data for System Crash
-//
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#include <scmdatatypes.h>
-
-namespace Debug
- {
- /**
- * TThreadData implementation
- * @internal technology
- */
-
- /**
- * TThreadData constructor
- */
- TThreadData::TThreadData()
- : iId(ESCMThreadData)
- ,iVersion(EThreadData1)
- ,iPriority(0)
- ,iTid(0)
- ,iOwnerId(0)
- ,iSvcSP(0)
- ,iSvcStack(0)
- ,iSvcStacksize(0)
- ,iUsrSP(0)
- ,iUsrStack(0)
- ,iUsrStacksize(0)
- ,iNamesize(0)
- ,iLastCpu(0)
- ,iSvcHeap(0)
- ,iSvcHeapSize(0)
- {
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return void
- */
- TInt TThreadData::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- if(iId != ESCMThreadData)
- {
- CLTRACE("TThreadData::Serialize Corrupt ID");
- return KErrCorrupt;
- }
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == EThreadData1)
- {
- // write data v1 format
- aWriter.WriteInt(iPriority); // 4
- aWriter.WriteInt64(iTid); // 8
- aWriter.WriteInt64(iOwnerId); // 8
- aWriter.WriteInt(iSvcSP); // 4
- aWriter.WriteInt(iSvcStack); // 4
- aWriter.WriteInt(iSvcStacksize); // 4
- aWriter.WriteInt(iUsrSP); // 4
- aWriter.WriteInt(iUsrStack); // 4
- aWriter.WriteInt(iUsrStacksize); // 4
- aWriter.WriteInt(iLastCpu); // 4
- aWriter.WriteInt(iSvcHeap); // 4
- aWriter.WriteInt(iSvcHeapSize); // 4
- if(iName.Ptr())
- {
- aWriter.WriteInt(iName.Length()); // 4
- for(TInt cnt = 0; cnt < iName.Length(); cnt++)
- {
- aWriter.WriteByte(iName[cnt]);
- }
- }
- else
- {
- aWriter.WriteInt(0);
- }
- }
- else
- {
- CLTRACE("TThreadData::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TThreadData::Serialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return void
- */
- TInt TThreadData::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMThreadData)
- {
- CLTRACE("TThreadData::Deserialize Corrupt ID read");
- return KErrCorrupt;
- }
-
- iVersion = (TThreadDataVersion)aReader.ReadShort(); // 2
-
- if(iVersion == EThreadData1)
- {
- // read data v1 format
- iPriority = aReader.ReadInt(); // 4
- iTid = aReader.ReadInt64(); // 8
- iOwnerId = aReader.ReadInt64(); // 8
- iSvcSP = aReader.ReadInt(); // 4
- iSvcStack = aReader.ReadInt(); // 4
- iSvcStacksize = aReader.ReadInt(); // 4
- iUsrSP = aReader.ReadInt(); // 4
- iUsrStack = aReader.ReadInt(); // 4
- iUsrStacksize = aReader.ReadInt(); // 4
- iLastCpu = aReader.ReadInt(); // 4
- iSvcHeap = aReader.ReadInt(); // 4
- iSvcHeapSize = aReader.ReadInt(); // 4
-
- iNamesize = aReader.ReadInt(); // 4
-
- if(iName.Ptr() && iName.MaxLength() >= (TInt)iNamesize)
- {
- iName.SetLength(0);
-
- for(TUint cnt = 0; cnt < iNamesize; cnt++)
- {
- iName.Append(aReader.ReadByte()); //iNamesize bytes
- }
- }
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TThreadData::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TThreadData::Deserialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TThreadData::GetSize() const
- {
- if(iVersion == EThreadData1)
- {
- return 66 + iName.Length();
- }
- else
- {
- CLTRACE("TThreadData::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- }
--- a/kernel/eka/debug/crashMonitor/src/scmvariantdata.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// e32\kernel\scmvariantdata.cpp
-// Core dump server - Variant Data for System Crash
-//
-//
-
-#include <scmdatatypes.h>
-
-namespace Debug
- {
- /**
- * TVariantSpecificData implementation
- * @internal technology
- */
-
- /**
- * TVariantSpecificData constructor
- */
- TVariantSpecificData::TVariantSpecificData() :
- iId(ESCMVariantData)
- ,iVersion(EVariantSpecificDataVersion1)
- ,iSize(0)
- {
- }
-
- /**
- * Writes this classes data to the specified byte stream
- * @param aWriter byte stream to use
- * @return void
- */
- TInt TVariantSpecificData::Serialize(TByteStreamWriter& aWriter)
- {
- TInt startPos = aWriter.CurrentPosition();
-
- if(iId != ESCMVariantData)
- {
- CLTRACE("TVariantSpecificData::Serialize Corrupt ID");
- return KErrCorrupt;
- }
-
- // ID saved first
- aWriter.WriteInt(iId); // 4
-
- aWriter.WriteShort((TUint16) iVersion); // 2
-
- if(iVersion == EVariantSpecificDataVersion1)
- {
- // write data v1 format
- aWriter.WriteInt(iSize); // 4
- }
- else
- {
- CLTRACE("TVariantSpecificData::Serialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aWriter.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- // error between actual size & real size in data
- CLTRACE("TVariantSpecificData::Serialize serialization size error");
- return KErrCorrupt;
- }
-
- return KErrNone;
- }
-
- /**
- * Reads the classes data from the specified byte stream
- * @param aReader Byte stream to use
- * @return void
- */
- TInt TVariantSpecificData::Deserialize(TByteStreamReader& aReader)
- {
- TInt startPos = aReader.CurrentPosition();
-
- iId = (SCMStructId)aReader.ReadInt(); // 4
- if(iId != ESCMVariantData)
- {
- CLTRACE("TVariantSpecificData::Deserialize Corrupt ID read");
- return KErrCorrupt;
- }
-
- iVersion = (TVariantSpecificDataVersion)aReader.ReadShort(); // 2
-
- if(iVersion == EVariantSpecificDataVersion1)
- {
- // read data v1 format
- iSize = aReader.ReadInt(); // 4
- }
- else
- {
- iId = ESCMLast; //unrecognised header
- CLTRACE("TVariantSpecificData::Deserialize Unsupported version");
- return KErrCorrupt;
- }
-
- TInt endPos = aReader.CurrentPosition();
- if( endPos - startPos != GetSize())
- {
- iId = ESCMLast; //unrecognised header
-
- // error between actual size & real size in data
- CLTRACE("TVariantSpecificData::Deserialize serialization size error");
- return KErrCorrupt;
- }
- return KErrNone;
- }
-
- /**
- * Returns the externalised size of this class
- * @return TInt size
- */
- TInt TVariantSpecificData::GetSize() const
- {
- if(iVersion == EVariantSpecificDataVersion1)
- {
- return 10;
- }
- else
- {
- CLTRACE("TThreadData::GetSize Unsupported version");
- return KErrNotSupported;
- }
- }
-
- }
--- a/kernel/eka/drivers/crashflash/crashflashnor.cpp Wed Oct 20 13:58:28 2010 +0100
+++ b/kernel/eka/drivers/crashflash/crashflashnor.cpp Tue Oct 26 11:12:58 2010 +0100
@@ -64,13 +64,8 @@
return ret;
}
// start writing after the crash log header
-
-#ifdef CDS_CRASH_LOGGER
- iWritePos = 0;
-#else
iWritePos = KCrashLogHeaderSize;
-#endif //CDS_CRASH_LOGGER
-
+
SetReadPos(0);
iWriteTotal = 0;
--- a/kernel/eka/drivers/debug/group/base_e32_drivers_debug.mrp Wed Oct 20 13:58:28 2010 +0100
+++ b/kernel/eka/drivers/debug/group/base_e32_drivers_debug.mrp Tue Oct 26 11:12:58 2010 +0100
@@ -3,7 +3,6 @@
component base_e32_drivers_debug
source \sf\os\kernelhwsrv\kernel\eka\debug
-source \sf\os\kernelhwsrv\kernel\eka\debug\crashMonitor
source \sf\os\kernelhwsrv\kernel\eka\drivers\debug
binary \sf\os\kernelhwsrv\kernel\eka\drivers\debug\group all
--- a/kernel/eka/drivers/debug/group/bld.inf Wed Oct 20 13:58:28 2010 +0100
+++ b/kernel/eka/drivers/debug/group/bld.inf Tue Oct 26 11:12:58 2010 +0100
@@ -25,18 +25,6 @@
BASEDEFAULT
-PRJ_EXPORTS
-
-../../../debug/crashMonitor/inc/scmonitor.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmonitor.h)
-../../../debug/crashMonitor/inc/scmdatatypes.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmdatatypes.h)
-../../../debug/crashMonitor/inc/scmbytestreamutil.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmbytestreamutil.h)
-../../../debug/crashMonitor/inc/scmbytestreamutil.inl SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmbytestreamutil.inl)
-../../../debug/crashMonitor/inc/crashlogwalker.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(crashlogwalker.h)
-../../../debug/crashMonitor/inc/scmconfig.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmconfig.h)
-../../../debug/crashMonitor/inc/scmconfigitem.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmconfigitem.h)
-../../../debug/crashMonitor/inc/scmdatasave.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmdatasave.h)
-../../../debug/crashMonitor/inc/scmtrace.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmtrace.h)
-
PRJ_MMPFILES
../../../debug/trkdummyapp/group/trkdummyapp
@@ -53,11 +41,6 @@
sm_debug_kerneldriver
-#if defined(GENERIC_MARM)
-../../../debug/crashMonitor/group/scmusr_lib
-../../../debug/crashMonitor/group/scmkern_lib
-#endif
-
#endif
#endif
--- a/kernel/eka/include/e32ver.h Wed Oct 20 13:58:28 2010 +0100
+++ b/kernel/eka/include/e32ver.h Tue Oct 26 11:12:58 2010 +0100
@@ -28,7 +28,7 @@
const TInt KE32MajorVersionNumber=2;
const TInt KE32MinorVersionNumber=0;
-const TInt KE32BuildVersionNumber=4012;
+const TInt KE32BuildVersionNumber=4013;
const TInt KMachineConfigurationMajorVersionNumber=1;
const TInt KMachineConfigurationMinorVersionNumber=0;
--- a/kernel/eka/include/kernel/kern_priv.h Wed Oct 20 13:58:28 2010 +0100
+++ b/kernel/eka/include/kernel/kern_priv.h Tue Oct 26 11:12:58 2010 +0100
@@ -471,6 +471,8 @@
public:
friend class Monitor;
friend class Debugger;
+ // Although SCMonitor is outside of the kernel sources, this friend declaration is still required
+ // so that SCMonitor can collect kernel data at crash time
friend class SCMonitor;
friend class Debug::StopModeDebug;
};
--- a/kernel/eka/release.txt Wed Oct 20 13:58:28 2010 +0100
+++ b/kernel/eka/release.txt Tue Oct 26 11:12:58 2010 +0100
@@ -1,3 +1,15 @@
+Version 2.00.4013
+=================
+(Made by fadhliM 20/10/2010)
+
+1. lanerobe
+ 1. ou1cimx1#605369 ENV Reduce T_MSTIM output under SMP
+ 2. ou1cimx1#603584 ENV Fix T_TLS heap handling
+
+2. ferporta
+ 1. ou1cimx1#605542 MCL REQ 428-444, SUB417-65117 SCM outputs RnD system crash Data (MCv1 Data Set) via Kern:Printf on HW110
+
+
Version 2.00.4012
=================
(Made by fadhliM 19/10/2010)
Binary file kernelhwsrv_info/doc_pub/Base_How_To_64bit_File_Server_Client_Porting_Guide.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_64bit_File_Server_File_System_Plugin_Porting_Guide.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_ARMv7_Cache_And_Access_Remapping_-_Design.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Align_Partitions_To_Media_Block_Boundaries_For_Optimised_Performance.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_BTrace.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Configure_Domain_Manager_Policy_DLLs.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Configure_Platform_Security_Settings.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Crash_Logging.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Debug_NONXIP_Problems.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Estart.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_File_Caching.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Handle_Sharing.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_IPC.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Impacts_Of_Demand_Paging_On_Kernel-Side_Code.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_MMC_Direct_Physical_Addressing.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_MMC_Double_Buffering.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Message_Queues.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Migrate_Device_Drivers_to_Paging_Environment.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Migrate_Media_Drivers_To_Support_Demand_Paging.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Migrate_To_Client-Server_V2_APIs.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Persisting_a_Custom_Restart_Reason.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Port_SDIO_Controller_Supplement.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Publish_And_Subscribe.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Share_File_Handles.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_USB_Client_Porting_and_Test.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_USB_Mass_Storage_App.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_USB_Mass_Storage_Double_Buffering.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Use_CFileMan_Test_Framework.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Use_DMA_For_SDIO_Data_Transfers.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_To_VFP_Support.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_How_to_Port_eMMC_Controller.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_Migrating_Media_drivers_DMA.doc has changed
Binary file kernelhwsrv_info/doc_pub/Base_SMP_Driver_Migration_Guide.doc has changed
--- a/kerneltest/e32test/dll/t_tls.cpp Wed Oct 20 13:58:28 2010 +0100
+++ b/kerneltest/e32test/dll/t_tls.cpp Tue Oct 26 11:12:58 2010 +0100
@@ -313,7 +313,6 @@
return __LINE__;
TInt newInitSize = HeapSize(newHeap);
User::SwitchHeap(newHeap);
- tlsHeap->Close();
// Allocate more TLS data
for(TInt i = 0 ; i < 100 ; ++i)
--- a/kerneltest/e32test/group/bld.inf Wed Oct 20 13:58:28 2010 +0100
+++ b/kerneltest/e32test/group/bld.inf Tue Oct 26 11:12:58 2010 +0100
@@ -1038,10 +1038,6 @@
../rm_debug/group/t_trkdummyapp
#endif
-#if defined(MARM_ARMV5)
-../rm_debug/group/t_crashmonitor_lib
-#endif
-
t_stacksize
#if !defined(WINS) && !defined(X86)
--- a/kerneltest/e32test/rm_debug/crashmonitor/t_crashmonitor.cpp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1066 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// Tests the functionality of the SCM Libraries
-//
-//
-
-#include "t_crashmonitor.h"
-
-#include <crashlogwalker.h>
-
-using namespace Debug;
-
-/**
- * Test suite version
- */
-const TVersion testVersion(1,1,0);
-
-
-/**
- * Constructor
- */
-CSCMLibraryClient::CSCMLibraryClient():
- iNonCachedWriter(iBuffer, EFalse),
- iCachedWriter(iBuffer, EFalse),
- iWriter(NULL),
- iReader(iBuffer)
- {
- }
-
-/**
- * First phase constructor
- */
-CSCMLibraryClient* CSCMLibraryClient::NewL()
- {
- CSCMLibraryClient* self = new(ELeave) CSCMLibraryClient();
- self->ConstructL();
- return self;
- }
-
-/**
- * Destructor
- */
-CSCMLibraryClient::~CSCMLibraryClient()
- {
- }
-
-/**
- * ConstructL
- */
-void CSCMLibraryClient::ConstructL()
- {}
-
-
-
-/**
- * Prints usage of this test suite
- */
-void CSCMLibraryClient::PrintUsage()
- {
- test.Printf(_L("Invoke with arguments:\n"));
- test.Printf(_L("-r: run specified tests in reverse order\n"));
- test.Printf(_L("-h: display usage information\n"));
- test.Printf(_L("-v: display version\n"));
- test.Printf(_L("<number>: test number to run, can specify more than one from the following list:\n"));
- test.Printf(_L("Press any key for list...\n"));
- test.Getch();
- // if there are too many of these they won't fit on the screen! Stick another Getch() in if there get too many
- for(TInt i=0; i<KMaxTests; i++)
- {
- test.Printf(_L("%2d: %S\n"), i, &(iTestArray[i].iFunctionName));
- }
- test.Printf(_L("Press any key...\n"));
- test.Getch();
- }
-
-/**
- * Parses arguments from command line
- * @param aMode Argument mode
- * @param aTests Array of tests
- */
-void CSCMLibraryClient::ParseCommandLineL(TUint32& aMode, RArray<TInt>& aTests)
- {
- // get the length of the command line arguments
- TInt argc = User::CommandLineLength();
-
- // allocate a buffer for the command line arguments and extract the data to it
- HBufC* commandLine = HBufC::NewLC(argc);
- TPtr commandLineBuffer = commandLine->Des();
- User::CommandLine(commandLineBuffer);
-
- // reset mode
- aMode = (TTestMode)0;
-
- // create a lexer and read through the command line
- TLex lex(*commandLine);
- while (!lex.Eos())
- {
- // expecting the first character to be a '-'
- if (lex.Get() == '-')
- {
- TChar arg = lex.Get();
- switch (arg)
- {
- case 'v':
- //print out the help
- aMode |= EModeVersion;
- break;
- case 'h':
- //print out the help
- aMode |= EModeHelp;
- break;
- case 'r':
- //store the fact that we want to run in reverse
- aMode |= EModeReverse;
- break;
- default:
- // unknown argument so leave
- User::Leave(KErrArgument);
- }
- }
- else
- {
- lex.UnGet();
- TInt testNumber;
- User::LeaveIfError(lex.Val(testNumber));
- if( (testNumber<0) || (testNumber>=KMaxTests) )
- {
- User::Leave(KErrArgument);
- }
- aTests.AppendL(testNumber);
- }
- lex.SkipSpace();
- }
- // if no tests specified then run them all
- if(aTests.Count() == 0)
- {
- aMode |= EModeAll;
- }
-
- // do clean up
- CleanupStack::PopAndDestroy(commandLine);
- }
-
-/**
- * This will run all tests in the suite
- */
-void CSCMLibraryClient::ClientAppL()
- {
-
- FillArray();
-
- test.Start(_L("ClientAppL"));
-
- RArray<TInt> testsToRun;
- TUint32 testMode = 0;
- ParseCommandLineL(testMode, testsToRun);
-
- //if help or version mode specified then just print out the relevant stuff and quit
- if((testMode & EModeHelp) || (testMode & EModeVersion))
- {
- if(testMode & EModeHelp)
- {
- PrintUsage();
- }
- if(testMode & EModeVersion)
- {
- PrintVersion();
- }
- test.End();
- return;
- }
-
- if(testMode & EModeAll)
- {
- for(TInt i=0; i<KMaxTests; i++)
- {
- testsToRun.AppendL(i);
- }
- }
-
- // if EModeReverse specified then reverse the array elements
- TInt numberOfTests = testsToRun.Count();
- if(testMode & EModeReverse)
- {
- for(TInt i=0; i<(numberOfTests>>1); i++)
- {
- TInt temp = testsToRun[i];
- testsToRun[i] = testsToRun[numberOfTests - (i+1)];
- testsToRun[numberOfTests - (i+1)] = temp;
- }
- }
-
- HelpStartTestTimer();
-
- // first run al tests with non cached writer
- iWriter = &iNonCachedWriter;
- for(TInt i=0; i<numberOfTests; i++)
- {
- RunTest(testsToRun[i]);
- }
-
- iWriter = &iCachedWriter;
- for(TInt i=0; i<numberOfTests; i++)
- {
- RunTest(testsToRun[i]);
- }
-
-
- testsToRun.Close();
-
- HelpStopTestTimer();
-
- ReportPerformance();
-
- test.End();
- }
-
-/**
- * This fills our array of test functions with function pointers to tests
- */
-void CSCMLibraryClient::FillArray()
- {
-
- //iTestArray[0] = new TFunctionData();
- iTestArray[0].iFunctionPtr = &CSCMLibraryClient::TestCheckSum;
- iTestArray[0].iFunctionName = _L("TestCheckSum");
-
- iTestArray[1].iFunctionPtr = &CSCMLibraryClient::TestLockDataSerialization;
- iTestArray[1].iFunctionName = _L("TestLockDataSerialization");
-
- iTestArray[2].iFunctionPtr = &CSCMLibraryClient::TestOffsetsHeaderSerialization;
- iTestArray[2].iFunctionName = _L("TestOffsetsHeaderSerialization");
-
- iTestArray[3].iFunctionPtr = &CSCMLibraryClient::TestInfoHeaderSerialization;
- iTestArray[3].iFunctionName = _L("TestInfoHeaderSerialization");
-
- iTestArray[4].iFunctionPtr = &CSCMLibraryClient::TestRawData;
- iTestArray[4].iFunctionName = _L("TestRawData");
-
- iTestArray[5].iFunctionPtr = &CSCMLibraryClient::TestProcessData;
- iTestArray[5].iFunctionName = _L("TestProcessData");
-
- iTestArray[6].iFunctionPtr = &CSCMLibraryClient::TestThreadData;
- iTestArray[6].iFunctionName = _L("TestThreadData");
-
- iTestArray[7].iFunctionPtr = &CSCMLibraryClient::TestThreadStack;
- iTestArray[7].iFunctionName = _L("TestThreadStack");
-
- iTestArray[8].iFunctionPtr = &CSCMLibraryClient::TestRegisterValue;
- iTestArray[8].iFunctionName = _L("TestRegisterValue");
-
- iTestArray[9].iFunctionPtr = &CSCMLibraryClient::TestRegisterSet;
- iTestArray[9].iFunctionName = _L("TestRegisterSet");
-
- iTestArray[10].iFunctionPtr = &CSCMLibraryClient::TestMemoryDump;
- iTestArray[10].iFunctionName = _L("TestMemoryDump");
-
- iTestArray[11].iFunctionPtr = &CSCMLibraryClient::TestCodeSegmentSet;
- iTestArray[11].iFunctionName = _L("TestCodeSegmentSet");
-
- iTestArray[12].iFunctionPtr = &CSCMLibraryClient::TestCodeSegment;
- iTestArray[12].iFunctionName = _L("TestCodeSegment");
-
- iTestArray[13].iFunctionPtr = &CSCMLibraryClient::TestTraceDump;
- iTestArray[13].iFunctionName = _L("TestTraceDump");
-
- iTestArray[14].iFunctionPtr = &CSCMLibraryClient::TestVariantSpecificData;
- iTestArray[14].iFunctionName = _L("TestVariantSpecificData");
-
- iTestArray[15].iFunctionPtr = &CSCMLibraryClient::TestRomHeaderData;
- iTestArray[15].iFunctionName = _L("TestRomHeaderData");
-
- iTestArray[16].iFunctionPtr = & CSCMLibraryClient::TestSCMLockData;
- iTestArray[16].iFunctionName = _L("TestSCMLockData");
-
- };
-
-/**
- * Entry point for crash monitor tests
- */
-GLDEF_C TInt E32Main()
- {
- TInt ret = KErrNone;
-
- CTrapCleanup* trap = CTrapCleanup::New();
- if (!trap)
- return KErrNoMemory;
-
- test.Title();
- CSCMLibraryClient* tester = CSCMLibraryClient::NewL();
- if (tester != NULL)
- {
- __UHEAP_MARK;
- TRAP(ret,tester->ClientAppL());
- __UHEAP_MARKEND;
-
- delete tester;
- }
-
- delete trap;
- return ret;
- }
-
-/**
- * Runs a given test identified by argument
- * @param aTestNumber Test to run
- */
-void CSCMLibraryClient::RunTest(TInt aTestNumber)
- {
- if( (aTestNumber<0) || (aTestNumber>=KMaxTests) )
- {
- User::Panic(_L("Test number out of range"), aTestNumber);
- }
- __UHEAP_MARK;
-
- if(iTestArray[aTestNumber].iFunctionPtr)
- {
- test.Printf(_L("pre-run test %d"), aTestNumber);
- (this->*(iTestArray[aTestNumber].iFunctionPtr))();
- test.Printf(_L("post-run test %d"), aTestNumber);
- }
-
- __UHEAP_MARKEND;
- }
-
-/**
- * Prints the version of this test suite
- */
-void CSCMLibraryClient::PrintVersion()
- {
- test.Printf(_L("\nt_crashmonitor_lib.exe\nVersion: %S\n"), &(testVersion.Name()));
- test.Printf(_L("Press any key...\n"));
- test.Getch();
- }
-/**
- * Reports performance metrics from all the tests
- */
-void CSCMLibraryClient::ReportPerformance(void)
- {
- test.Printf(_L("\nPerformance\n"));
- test.Printf(_L("========================\n"));
-
-
- // Runtime
- TInt ticks = HelpGetTestTicks();
-#ifndef __WINS__
- test (ticks != 0);
-#endif
- TInt nkTicksPerSecond = HelpTicksPerSecond();
-
-#ifndef __WINS__
- test (nkTicksPerSecond != 0);
-#endif
-
- test.Printf(_L("Total test runtime: %d seconds\n"),ticks/nkTicksPerSecond);
-
- test.Printf(_L("\n"));
- }
-
-/**
- * Returns the number of nanokernel ticks in one second
- * @return Number of nanokernel ticks. 0 if unsuccesful
- */
-TInt CSCMLibraryClient::HelpTicksPerSecond(void)
- {
- TInt nanokernel_tick_period;
- HAL::Get(HAL::ENanoTickPeriod, nanokernel_tick_period);
-
- ASSERT(nanokernel_tick_period != 0);
-
- static const TInt KOneMillion = 1000000;
-
- return KOneMillion/nanokernel_tick_period;
- }
-
-void CSCMLibraryClient::DoWrite(MByteStreamSerializable& aObjectToWrite, TInt aPosition)
- {
- if(iWriter == &iCachedWriter)
- {
- iCachedWriter.SetPosition(aPosition);
- test(aObjectToWrite.Serialize(iCachedWriter) == KErrNone);
- iCachedWriter.FlushCache();
- }
- else if(iWriter == &iNonCachedWriter)
- {
- iNonCachedWriter.SetPosition(aPosition);
- test(aObjectToWrite.Serialize(iNonCachedWriter) == KErrNone);
- }
- else
- {
- // no writer
- test(EFalse);
- }
- }
-
-// BASE granted test id's 2364 to 2394
-
-//---------------------------------------------
-// !@SYMTestCaseID KBASE-T_SCMLIB-2364
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TScmChecksum structure
-//! @SYMTestActions TScmChecksum serialized & then deserialized
-//! @SYMTestExpectedResults TScmChecksum structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestCheckSum()
- {
- test.Next(_L("TestCheckSum\n"));
-
- TScmChecksum chksm1;
- chksm1.Reset();
-
- TInt blocksize1 = 123;
- TInt blocksize2 = 166;
-
- TScmChecksum chksm2;
- chksm2.Reset();
-
- test(ChecksumHelper(chksm1, blocksize1, iBuffer, KBufLen));
- test(ChecksumHelper(chksm2, blocksize2, iBuffer, KBufLen));
-
- test(chksm1 == chksm2);
-
- }
-
-TBool CSCMLibraryClient::ChecksumHelper(TScmChecksum& aChecksum, TUint aBlocksize, TUint8* aBuffer, TUint aBufferLen)
- {
- if( aBlocksize == 0 || aBufferLen == 0 )
- {
- return EFalse;
- }
-
- TInt remaining = aBufferLen;
- TInt pos = 0;
-
- while(remaining > aBlocksize)
- {
- aChecksum.ChecksumBlock(aBuffer + pos, aBlocksize);
- pos += aBlocksize;
- remaining -= aBlocksize;
- }
-
- aChecksum.ChecksumBlock(aBuffer + pos, remaining);
- pos += remaining;
-
- return (pos == aBufferLen);
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2365
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TSCMLockData structure
-//! @SYMTestActions TSCMLockData serialized & then deserialized
-//! @SYMTestExpectedResults TSCMLockData structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestLockDataSerialization()
- {
- test.Next(_L("TestLockDataSerialization\n"));
-
- TSCMLockData lockData1;
-
- //Arbitrary values
- lockData1.SetLockCount(10);
- lockData1.SetMutexHoldCount(17);
- lockData1.SetMutexThreadWaitCount(36);
-
- DoWrite(lockData1);
-
- iReader.SetPosition(0);
- //Test deserialisation works
- TSCMLockData lockData2;
- test(lockData2.Deserialize(iReader) == KErrNone);
-
- //Test we got back the correct object
- test(lockData1 == lockData2);
- }
-
-//---------------------------------------------
-//! //! @SYMTestCaseID KBASE-T_SCMLIB-2366
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TCrashOffsetsHeader structure
-//! @SYMTestActions TCrashOffsetsHeader serialized & then deserialized
-//! @SYMTestExpectedResults TCrashOffsetsHeader structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestOffsetsHeaderSerialization()
- {
- test.Next(_L("TestOffsetsHeaderSer ialization\n"));
-
- TCrashOffsetsHeader header1;
- header1.iCTFullRegOffset = 123;
- header1.iCTUsrStkOffset = 456;
- header1.iCTSvrStkOffset = 789;
- header1.iCPMetaOffset = 1001;
- header1.iCTMetaOffset = 99;
- header1.iCPCodeSegOffset = 1234;
- header1.iSysUsrStkOffset = 3456;
- header1.iSysSvrStkOffset = 255;
- header1.iSysUsrRegOffset = 999;
- header1.iSysSvrRegOffset = 2002;
- header1.iTLstOffset = 3003;
- header1.iPLstOffset = 4004;
- header1.iSysCodeSegOffset = 5005;
- header1.iExcStkOffset = 6006;
- header1.iTraceOffset = 1233;
- header1.iScmLocksOffset = 3421;
- header1.iKernelHeapOffset = 89;
- header1.iVarSpecInfOffset = 0;
- header1.iRomInfoOffset = 123;
-
- DoWrite(header1);
-
- iReader.SetPosition(0);
- TCrashOffsetsHeader header2;
-
- test(header2.Deserialize(iReader) == KErrNone);
-
- test(header2 == header1);
-
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2367
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TCrashInfoHeader structure
-//! @SYMTestActions TCrashInfoHeader serialized & then deserialized
-//! @SYMTestExpectedResults TCrashInfoHeader structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestInfoHeaderSerialization()
- {
- test.Next(_L("TestInfoHeaderSerialization\n"));
-
- TCrashInfoHeader infoHeader1;
- infoHeader1.iLogSize = 5000;
- infoHeader1.iFlashAlign = 4;
- infoHeader1.iCachedWriterSize = 16;
- infoHeader1.iPid = 1001;
- infoHeader1.iTid = 2002;
- infoHeader1.iExitType = 90;
- infoHeader1.iExitReason = 23;
- infoHeader1.iExcCode = 8899;
- infoHeader1.iCrashTime = 12345;
- infoHeader1.iCrashId = 23;
- infoHeader1.iFlashBlockSize = 256 * 1024;
- infoHeader1.iFlashPartitionSize = 1024 * 1024;
-
- TVersion ver(21,43,54);
-
- infoHeader1.iSCMDataTypesVersion = ver;
-
- DoWrite(infoHeader1);
-
- iReader.SetPosition(0);
- TCrashInfoHeader infoHeader2;
-
- test(infoHeader2.Deserialize(iReader) == KErrNone);
-
- test(infoHeader2 == infoHeader1);
-
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2368
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TRawData structure
-//! @SYMTestActions TRawData serialized & then deserialized
-//! @SYMTestExpectedResults TRawData structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestRawData()
- {
- test.Next(_L("TestRawData\n"));
-
- const TInt KLen = 256;
-
- TUint8 data[KLen];
-
- for(TInt i=0;i<KLen;i++)
- {
- data[i] = ((i<<2) % KLen) + i;
- }
-
- TRawData rawData1;
-
- rawData1.iLength = KLen;
- rawData1.iData.Set(const_cast<TUint8*>(data), KLen, KLen);;
-
- DoWrite(rawData1);
-
- TPtr8 p(iBuffer, KBufLen, KBufLen);
- TCrashLogWalker walker(p);
- TInt pos = 0;
- TInt len = 0;
- TRawData* rawData2 = walker.GetRawDataTypeL(pos, len, p, 0);
-
- CleanupStack::PushL(rawData2);
-
- test(rawData1.iLength == rawData2->iLength);
- test(rawData1.iData.Compare(rawData2->iData) == 0);
-
- CleanupStack::PopAndDestroy(rawData2);
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2369
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TProcessData structure
-//! @SYMTestActions TProcessData serialized & then deserialized
-//! @SYMTestExpectedResults TProcessData structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestProcessData()
- {
- test.Next(_L("TestProcessData\n"));
-
- TProcessData procData1;
-
- procData1.iPriority = 99;
- procData1.iPid = MAKE_TINT64(34567,12345);
-
-
- procData1.iName.Zero();
- for(TInt i=0;i<KMaxProcessName;i++)
- {
- procData1.iName.Append( TChar( (i%60) + 32 ));
- }
-
- procData1.iNamesize = KMaxProcessName;
-
- DoWrite(procData1);
-
- TProcessData procData2;
- iReader.SetPosition(0);
-
- test(procData2.Deserialize(iReader) == KErrNone);
- test(procData1.iPriority == procData1.iPriority);
- test(procData1.iPid == procData2.iPid);
- test(procData1.iNamesize == procData2.iNamesize);
- test(procData1.iName.Compare(procData2.iName) == 0);
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2370
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TThreadData structure
-//! @SYMTestActions TThreadData serialized & then deserialized
-//! @SYMTestExpectedResults TThreadData structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestThreadData()
- {
- test.Next(_L("TestThreadData\n"));
-
- TThreadData threadData1;
-
- threadData1.iPriority = 3455;
- threadData1.iTid = MAKE_TINT64(34998,18345);
- threadData1.iOwnerId = MAKE_TINT64(34448,48345);
- threadData1.iSvcSP = 67272;
- threadData1.iSvcStack = 888882;
- threadData1.iSvcStacksize = 4535;
- threadData1.iUsrSP = 892;
- threadData1.iUsrStack = 7727;
- threadData1.iUsrStacksize = 343;
- threadData1.iLastCpu = 12312;
- threadData1.iSvcHeap = 8738;
- threadData1.iSvcHeapSize = 4;
-
- threadData1.iNamesize = TThreadData::KMaxThreadName;
-
- threadData1.iName.Zero();
- for(TInt i=0;i<TThreadData::KMaxThreadName;i++)
- {
- threadData1.iName.Append( TChar( (i%60) + 32 ));
- }
-
-
- DoWrite(threadData1);
-
- iReader.SetPosition(0);
- TThreadData threadData2;
-
- test(threadData2.Deserialize(iReader) == KErrNone);
-
-
- test(threadData1.iPriority == threadData2.iPriority);
- test(threadData1.iTid == threadData2.iTid);
- test(threadData1.iOwnerId == threadData2.iOwnerId);
- test(threadData1.iSvcSP == threadData2.iSvcSP);
- test(threadData1.iSvcStack == threadData2.iSvcStack);
- test(threadData1.iSvcStacksize == threadData2.iSvcStacksize);
- test(threadData1.iUsrSP == threadData2.iUsrSP);
- test(threadData1.iUsrStack == threadData2.iUsrStack);
- test(threadData1.iUsrStacksize == threadData2.iUsrStacksize);
- test(threadData1.iLastCpu == threadData2.iLastCpu);
- test(threadData1.iSvcHeap == threadData2.iSvcHeap);
- test(threadData1.iSvcHeapSize == threadData2.iSvcHeapSize);
- test(threadData1.iNamesize == threadData2.iNamesize);
- test(threadData1.iName.Compare(threadData2.iName) == 0);
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2371
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TThreadStack structure
-//! @SYMTestActions TThreadStack serialized & then deserialized
-//! @SYMTestExpectedResults TThreadStack structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestThreadStack()
- {
- test.Next(_L("TestThreadStack\n"));
-
- TThreadStack threadStack1;
- threadStack1.iStackType = TThreadStack::ESvrStack;
- threadStack1.iThreadId = MAKE_TINT64(774998,17345);
-
- DoWrite(threadStack1);
-
- iReader.SetPosition(0);
- TThreadStack threadStack2;
- test(threadStack2.Deserialize(iReader) == KErrNone);
-
- test(threadStack1.iStackType == threadStack2.iStackType);
- test(threadStack1.iThreadId == threadStack2.iThreadId);
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2372
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TRegisterValue structure
-//! @SYMTestActions TRegisterValue serialized & then deserialized
-//! @SYMTestExpectedResults TRegisterValue structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestRegisterValue()
- {
- test.Next(_L("TestregisterValue\n"));
- TRegisterValue regValue1;
-
- regValue1.iOwnId = MAKE_TINT64(55498,58345);
- regValue1.iType = 3456;
- regValue1.iClass = 45;
- regValue1.iSubId = 5546;
- regValue1.iSize = 2;
-
- DoWrite(regValue1);
-
- iReader.SetPosition(0);
- TRegisterValue regValue2;
- test(regValue2.Deserialize(iReader) == KErrNone);
-
- test(regValue1.iOwnId == regValue2.iOwnId);
- test(regValue1.iType == regValue2.iType);
- test(regValue1.iClass == regValue2.iClass);
- test(regValue1.iSubId == regValue2.iSubId);
- test(regValue1.iSize == regValue2.iSize);
-
- switch(regValue1.iSize)
- {
- case 0:
- test(regValue1.iValue8 == regValue2.iValue8);
- break;
- case 1:
- test(regValue1.iValue16 == regValue2.iValue16);
- break;
- case 2:
- test(regValue1.iValue32 == regValue2.iValue32);
- break;
- case 3:
- test(regValue1.iValue64 == regValue2.iValue64);
- break;
- default:
- test(EFalse);
- break;
- }
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2373
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TRegisterSet structure
-//! @SYMTestActions TRegisterSet serialized & then deserialized
-//! @SYMTestExpectedResults TRegisterSet structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestRegisterSet()
- {
- test.Next(_L("TRegisterSet\n"));
-
- TRegisterSet set1;
- set1.iNumRegisters = 3784;
- DoWrite(set1);
-
- iReader.SetPosition(0);
- TRegisterSet set2;
- test(set2.Deserialize(iReader) == KErrNone);
-
- test(set1.iNumRegisters == set2.iNumRegisters);
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2374
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TMemoryDump structure
-//! @SYMTestActions TMemoryDump serialized & then deserialized
-//! @SYMTestExpectedResults TMemoryDump structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestMemoryDump()
- {
- test.Next(_L("TestMemoryDump\n"));
-
- TMemoryDump memDump1;
- memDump1.iStartAddress = 0x23FACED0;
- memDump1.iPid = MAKE_TINT64(1234, 5678);
- memDump1.iLength = 999;
-
- DoWrite(memDump1);
-
- iReader.SetPosition(0);
- TMemoryDump memDump2;
- test(memDump2.Deserialize(iReader) == KErrNone);
-
- test(memDump1.iStartAddress = memDump2.iStartAddress);
- test(memDump1.iPid = memDump2.iPid);
- test(memDump1.iLength = memDump2.iLength);
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2375
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TCodeSegmentSet structure
-//! @SYMTestActions TCodeSegmentSet serialized & then deserialized
-//! @SYMTestExpectedResults TCodeSegmentSet structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestCodeSegmentSet()
- {
- test.Next(_L("TestCodeSegmentSet\n"));
- TCodeSegmentSet tss1;
-
- tss1.iNumSegs = 45;
- tss1.iPid = MAKE_TINT64(28272,671717);
-
- DoWrite(tss1);
-
- iReader.SetPosition(0);
- TCodeSegmentSet tss2;
- test(tss2.Deserialize(iReader) == KErrNone);
-
- test(tss1.iNumSegs == tss2.iNumSegs);
- test(tss1.iPid == tss2.iPid);
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2376
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TCodeSegment structure
-//! @SYMTestActions TCodeSegment serialized & then deserialized
-//! @SYMTestExpectedResults TCodeSegment structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestCodeSegment()
- {
- test.Next(_L("TestCodeSegment\n"));
-
- TCodeSegment cs1;
- cs1.iCodeSegType = EExeCodeSegType;
- cs1.iCodeSegMemInfo.iCodeBase = 345;
- cs1.iCodeSegMemInfo.iCodeSize = 566;
- cs1.iCodeSegMemInfo.iConstDataBase = 776;
- cs1.iCodeSegMemInfo.iConstDataSize = 626267;
- cs1.iCodeSegMemInfo.iInitialisedDataBase = 873;
- cs1.iCodeSegMemInfo.iInitialisedDataSize = 52625;
- cs1.iCodeSegMemInfo.iUninitialisedDataBase = 3737;
- cs1.iCodeSegMemInfo.iUninitialisedDataSize = 53535;
-
- cs1.iName.Zero();
- for(TInt i=0;i<TCodeSegment::KMaxSegmentNameSize;i++)
- {
- cs1.iName.Append( TChar( (i%60) + 32 ));
- }
-
- cs1.iNameLength = TCodeSegment::KMaxSegmentNameSize;
- cs1.iXip = ETrue;
-
- DoWrite(cs1);
-
- iReader.SetPosition(0);
- TCodeSegment cs2;
- test(cs2.Deserialize(iReader) == KErrNone);
-
- test(cs1.iCodeSegType == cs2.iCodeSegType);
- test(cs1.iCodeSegMemInfo.iCodeBase == cs2.iCodeSegMemInfo.iCodeBase);
- test(cs1.iCodeSegMemInfo.iCodeSize == cs2.iCodeSegMemInfo.iCodeSize);
- test(cs1.iCodeSegMemInfo.iConstDataBase == cs2.iCodeSegMemInfo.iConstDataBase);
- test(cs1.iCodeSegMemInfo.iConstDataSize == cs2.iCodeSegMemInfo.iConstDataSize);
- test(cs1.iCodeSegMemInfo.iInitialisedDataBase == cs2.iCodeSegMemInfo.iInitialisedDataBase);
- test(cs1.iCodeSegMemInfo.iInitialisedDataSize == cs2.iCodeSegMemInfo.iInitialisedDataSize);
- test(cs1.iCodeSegMemInfo.iUninitialisedDataBase == cs2.iCodeSegMemInfo.iUninitialisedDataBase);
- test(cs1.iCodeSegMemInfo.iUninitialisedDataSize == cs2.iCodeSegMemInfo.iUninitialisedDataSize);
-
- test(cs1.iNameLength == cs2.iNameLength);
- test(cs1.iName.Compare(cs2.iName) == 0);
- test(cs1.iXip == cs2.iXip);
-
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2377
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TTraceDump structure
-//! @SYMTestActions TTraceDump serialized & then deserialized
-//! @SYMTestExpectedResults TTraceDump structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestTraceDump()
- {
- test.Next(_L("TestTraceDump\n"));
-
- TTraceDump td1;
- td1.iSizeOfMemory = 378282;
- td1.iNumberOfParts = 440;
-
- DoWrite(td1);
-
- iReader.SetPosition(0);
-
- TTraceDump td2;
- test(td2.Deserialize(iReader) == KErrNone);
- test(td1.iSizeOfMemory == td2.iSizeOfMemory);
- test(td1.iNumberOfParts == td2.iNumberOfParts);
- }
-
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2379
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TVariantSpecificData structure
-//! @SYMTestActions TVariantSpecificData serialized & then deserialized
-//! @SYMTestExpectedResults TVariantSpecificData structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestVariantSpecificData()
- {
- test.Next(_L("TestVariantSpecificData\n"));
- TVariantSpecificData vsd1;
-
- vsd1.iSize = 37372;
- DoWrite(vsd1);
-
- iReader.SetPosition(0);
- TVariantSpecificData vsd2;
- test(vsd2.Deserialize(iReader) == KErrNone);
- }
-
-//---------------------------------------------
-//! @SYMTestCaseID KBASE-T_SCMLIB-2380
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TRomHeaderData structure
-//! @SYMTestActions TRomHeaderData serialized & then deserialized
-//! @SYMTestExpectedResults TRomHeaderData structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestRomHeaderData()
- {
- test.Next(_L("TestRomHeaderData\n"));
-
- TRomHeaderData rhd1;
- rhd1.iMajorVersion = 12;
- rhd1.iMinorVersion = 2;
- rhd1.iBuildNumber = 7828;
- rhd1.iTime = MAKE_TINT64(716171, 62672);
-
- DoWrite(rhd1);
-
- iReader.SetPosition(0);
- TRomHeaderData rhd2;
- test(rhd2.Deserialize(iReader) == KErrNone);
- test(rhd1.iMajorVersion == rhd2.iMajorVersion);
- test(rhd1.iMinorVersion == rhd2.iMinorVersion);
- test(rhd1.iBuildNumber == rhd2.iBuildNumber);
- test(rhd1.iTime == rhd2.iTime);
- }
-
-//---------------------------------------------
-//! //! @SYMTestCaseID KBASE-T_SCMLIB-2381
-//! @SYMTestType
-//! @SYMPREQ PREQ1700
-//! @SYMTestCaseDesc Ensures we can serialise and deserialise the TSCMLockData structure
-//! @SYMTestActions TSCMLockData serialized & then deserialized
-//! @SYMTestExpectedResults <> structure serialized / deserialized ok
-//! @SYMTestPriority High
-//! @SYMTestStatus Implemented
-//---------------------------------------------
-void CSCMLibraryClient::TestSCMLockData()
- {
-
- test.Next(_L("TestSCMLockData\n"));
-
- TSCMLockData ld1;
- ld1.SetMutexHoldCount(3);
- ld1.SetLockCount(4);
- ld1.SetMutexThreadWaitCount(5);
-
- DoWrite(ld1);
-
- iReader.SetPosition(0);
- TSCMLockData ld2;
- test(ld2.Deserialize(iReader) == KErrNone);
-
- test(ld1.MutexHoldCount() == ld2.MutexHoldCount());
- test(ld1.MutexThreadWaitCount() == ld2.MutexThreadWaitCount());
- test(ld1.LockCount() == ld2.LockCount());
- test(ld1 == ld2);
- test(!(ld1 != ld2));
- }
-
-//eof
-
--- a/kerneltest/e32test/rm_debug/crashmonitor/t_crashmonitor.h Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// System Crash Monitor Shared Library tests
-//
-//
-
-/**
- @file
- @internalTechnology
- @released
-*/
-
-#ifndef CRASH_MONITOR
-#define CRASH_MONITOR
-
-#include <e32base.h>
-#include <e32cons.h>
-#include <e32test.h>
-#include <e32cmn.h>
-#include <scmdatatypes.h>
-#include <scmbytestreamutil.h>
-#include <hal.h>
-
-using namespace Debug;
-
-LOCAL_D RTest test(_L("T_CRASHMONITOR_LIB"));
-
-//number of test functions that we have
-const TInt KMaxTests = 25;
-const TUint KBufLen = 52224; // 0.5 meg buffer
-
-class CSCMLibraryClient;
-
-// Create a pointer to function type
-typedef void (CSCMLibraryClient::*testFunction)();
-
-class TFunctionData
- {
-
-public:
- TFunctionData()
- : iFunctionPtr(NULL)
- {
- }
-
- testFunction iFunctionPtr;
- TBuf<40> iFunctionName;
- };
-
-//
-// class CSCMLibraryClient
-//
-// The basic SCM Library Client
-//
-class CSCMLibraryClient : public CBase
- {
-public:
- static CSCMLibraryClient* NewL();
- ~CSCMLibraryClient();
- void ClientAppL();
-
-private:
- CSCMLibraryClient();
- void ConstructL();
-
- TInt TestStartup();
- TInt TestShutdown();
-
- void FillArray();
- void PrintUsage();
- void PrintVersion();
-
- enum TTestMode
- {
- //run all the tests
- EModeAll = 1<<0,
- //run the specified tests in reverse order
- EModeReverse = 1<<1,
- //print out help
- EModeHelp = 1<<2,
- //print out help
- EModeVersion = 1<<3
- };
-
- //Tests
- void TestCheckSum();
-
- void TestLockDataSerialization();
- void TestOffsetsHeaderSerialization();
- void TestInfoHeaderSerialization();
- void TestRawData();
- void TestProcessData();
- void TestThreadData();
- void TestThreadStack();
- void TestRegisterValue();
- void TestRegisterSet();
-
- void TestMemoryDump();
- void TestCodeSegmentSet();
- void TestCodeSegment();
- void TestTraceDump();
- void TestVariantSpecificData();
- void TestRomHeaderData();
- void TestSCMLockData();
-
- void RunTest(TInt aTestNumber);
- void ParseCommandLineL(TUint32& aMode, RArray<TInt>& aTests);
- void HelpStartTestTimer(void) { iStartTick = User::NTickCount(); iStopTick = 0; };
- void HelpStopTestTimer(void) { iStopTick = User::NTickCount(); };
- TInt HelpGetTestTicks(void) { return (iStopTick - iStartTick); };
- TInt HelpTicksPerSecond();
- void ReportPerformance();
-
-private:
- TBool ChecksumHelper(TScmChecksum& aChecksum, TUint aBlocksize, TUint8* aBuffer, TUint aBufferLen);
- void DoWrite(MByteStreamSerializable& aObjectToWrite, TInt aPositon = 0);
-
-
-private:
- TFunctionData iTestArray[KMaxTests];
-
- // Timing information
- TInt iStartTick;
- TInt iStopTick;
-
- TUint8 iBuffer[KBufLen];
-
- TByteStreamWriter iNonCachedWriter;
- TCachedByteStreamWriter iCachedWriter;
-
- TByteStreamWriter* iWriter;
- TByteStreamReader iReader;
- };
-
-#endif // CRASH_MONITOR
--- a/kerneltest/e32test/rm_debug/group/t_crashmonitor_lib.mmp Wed Oct 20 13:58:28 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "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:
-// Tests the functionality of the System Crash Monitor libraries
-//
-
-ALWAYS_BUILD_AS_ARM
-
-targettype exe
-
-SYMBIAN_BASE_SYSTEMINCLUDE(nkern)
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-
-userinclude ../../../../kernel/eka/debug/crashMonitor/inc
-sourcepath ../crashmonitor
-
-source t_crashmonitor.cpp
-
-library euser.lib
-library hal.lib
-staticlibrary scmusr_lib.lib
-
-target t_crashmonitor_lib.exe
-
-UID 0x0 0x4321bbbc
-SECUREID 0x2000B26F
-
-capability none
-
-VENDORID 0x70000001
-
-DEBUGGABLE
-
-SMPSAFE
--- a/kerneltest/e32test/system/t_mstim.cpp Wed Oct 20 13:58:28 2010 +0100
+++ b/kerneltest/e32test/system/t_mstim.cpp Tue Oct 26 11:12:58 2010 +0100
@@ -43,6 +43,8 @@
#include <e32test.h>
#include <e32uid.h>
+#include <e32svr.h>
+#include <u32hal.h>
#include "d_mstim.h"
RTest test(_L("T_MSTIM"));
@@ -92,9 +94,15 @@
// Test millisecond timers
//
{
+ // RTest::Printf and Next are very high latency under SMP, so suppress them
+ const TBool unicore = (UserSvr::HalFunction(EHalGroupKernel, EKernelHalSmpSupported, 0, 0) == KErrNotSupported);
+
// test.SetLogged(EFalse);
test.Title();
+ if (!unicore)
+ test.Printf(_L("Running on a SMP system - output reduced\n"));
+
test.Start(_L("Load test LDD"));
TInt r=User::LoadLogicalDevice(KLddFileName);
TEST(r==KErrNone || r==KErrAlreadyExists);
@@ -117,56 +125,67 @@
r=mstim.StartPeriodicDfc(7,71);
CHECK(r);
- test.Next(_L("Start while started"));
+ if (unicore)
+ test.Next(_L("Start while started"));
TRequestStatus s;
mstim.StartOneShotInt(s,0,100);
User::WaitForRequest(s);
TEST(s==KErrInUse);
- test.Next(_L("One shot interrupt"));
+ if (unicore)
+ test.Next(_L("One shot interrupt"));
mstim.StartOneShotInt(s,2,100);
User::WaitForRequest(s);
TUint fc1=User::NTickCount();
TEST(s==KErrNone);
TInt time=GetOneShotTime(2);
- test.Printf(_L("Took %dms\n"),time);
+ if (unicore)
+ test.Printf(_L("Took %dms\n"),time);
TESTTIME(time,100,102);
- test.Next(_L("One shot DFC"));
+ if (unicore)
+ test.Next(_L("One shot DFC"));
mstim.StartOneShotDfc(s,3,200);
User::WaitForRequest(s);
TUint fc3=User::NTickCount();
TEST(s==KErrNone);
time=GetOneShotTime(3);
- test.Printf(_L("Took %dms\n"),time);
+ if (unicore)
+ test.Printf(_L("Took %dms\n"),time);
TESTTIME(time,200,202);
- test.Next(_L("One shot interrupt again"));
+ if (unicore)
+ test.Next(_L("One shot interrupt again"));
TUint fc2=User::NTickCount();
mstim.StartOneShotIntAgain(s,2,300);
User::WaitForRequest(s);
TEST(s==KErrNone);
TInt time2=GetOneShotTime(2);
- test.Printf(_L("Took %dms, delay %dms\n"),time2,fc2-fc1);
+ if (unicore)
+ test.Printf(_L("Took %dms, delay %dms\n"),time2,fc2-fc1);
time2+=TInt(fc2-fc1);
TESTTIME(time2,295,306);
- test.Next(_L("One shot interrupt again too late"));
+ if (unicore)
+ test.Next(_L("One shot interrupt again too late"));
mstim.StartOneShotIntAgain(s,3,10);
User::WaitForRequest(s);
TEST(s==KErrArgument);
- test.Next(_L("One shot interrupt again"));
+ if (unicore)
+ test.Next(_L("One shot interrupt again"));
fc2=User::NTickCount();
mstim.StartOneShotIntAgain(s,3,300);
User::WaitForRequest(s);
TEST(s==KErrNone);
time=GetOneShotTime(3);
- test.Printf(_L("Took %dms, delay %dms\n"),time,fc2-fc3);
+ if (unicore)
+ test.Printf(_L("Took %dms, delay %dms\n"),time,fc2-fc3);
time+=TInt(fc2-fc3);
TESTTIME(time,295,306);
- test.Printf(_L("Please wait...\n"));
+ if (unicore)
+ test.Printf(_L("Please wait...\n"));
User::After(10000000);
SMsTimerInfo info[8];
@@ -179,7 +198,8 @@
TUint final_count=User::NTickCount();
TInt elapsed=TInt(final_count-init_count);
- test.Printf(_L("Elapsed time %dms\n"),elapsed);
+ if (unicore)
+ test.Printf(_L("Elapsed time %dms\n"),elapsed);
const TInt period[8]={31,32,0,0,7,43,19,71};
for (i=0; i<8; i++)
@@ -188,7 +208,8 @@
if (p==0)
continue;
SMsTimerInfo& z=info[i];
- test.Printf(_L("%1d: min=%-6d max=%-6d avg=%-6d count=%d\n"),i,z.iMin,z.iMax,z.iAvg,z.iCount);
+ if (unicore)
+ test.Printf(_L("%1d: min=%-6d max=%-6d avg=%-6d count=%d\n"),i,z.iMin,z.iMax,z.iAvg,z.iCount);
TInt count=elapsed/p;
TInt cdiff=count-z.iCount;
TEST(cdiff>=0 && cdiff<=2);
@@ -199,7 +220,8 @@
TEST(Abs(z.iAvg-1000*p)<1000);
}
- test.Next(_L("Cancel periodic"));
+ if (unicore)
+ test.Next(_L("Cancel periodic"));
r=mstim.StopPeriodic(7);
CHECK(r);
r=mstim.GetInfo(7,info[7]);
@@ -209,16 +231,19 @@
CHECK(r);
TEST(info[6].iCount==info[7].iCount);
- test.Next(_L("Reuse cancelled"));
+ if (unicore)
+ test.Next(_L("Reuse cancelled"));
mstim.StartOneShotInt(s,7,128);
User::WaitForRequest(s);
TEST(s==KErrNone);
time=GetOneShotTime(7);
- test.Printf(_L("Took %dms\n"),time);
+ if (unicore)
+ test.Printf(_L("Took %dms\n"),time);
TESTTIME(time,128,130);
TRequestStatus s2;
- test.Next(_L("Timed Cancel"));
+ if (unicore)
+ test.Next(_L("Timed Cancel"));
mstim.StartOneShotInt(s,2,128);
mstim.IntCancel(s2,2,130);
User::WaitForRequest(s);
@@ -226,10 +251,12 @@
User::WaitForRequest(s2);
TEST(s2==KErrNone);
time=GetOneShotTime(2);
- test.Printf(_L("Took %dms\n"),time);
+ if (unicore)
+ test.Printf(_L("Took %dms\n"),time);
TESTTIME(time,128,130);
time=GetOneShotTime(7);
- test.Printf(_L("Cancel Took %dms\n"),time);
+ if (unicore)
+ test.Printf(_L("Cancel Took %dms\n"),time);
TESTTIME(time,130,132);
mstim.StartOneShotInt(s,2,128);
@@ -239,38 +266,46 @@
User::WaitForRequest(s2);
TEST(s2==KErrNone);
time=GetOneShotTime(7);
- test.Printf(_L("Cancel Took %dms\n"),time);
+ if (unicore)
+ test.Printf(_L("Cancel Took %dms\n"),time);
TESTTIME(time,126,128);
- test.Next(_L("Reuse cancelled"));
+ if (unicore)
+ test.Next(_L("Reuse cancelled"));
mstim.StartOneShotInt(s,2,64);
User::WaitForRequest(s);
TEST(s==KErrNone);
time=GetOneShotTime(2);
- test.Printf(_L("Took %dms\n"),time);
+ if (unicore)
+ test.Printf(_L("Took %dms\n"),time);
TESTTIME(time,64,66);
#ifdef _DEBUG
- test.Next(_L("Random test"));
+ if (unicore)
+ test.Next(_L("Random test"));
r=mstim.BeginRandomTest();
CHECK(r);
#endif
- test.Printf(_L("Please wait...\n"));
+ if (unicore)
+ test.Printf(_L("Please wait...\n"));
User::After(10000000);
#ifdef _DEBUG
r=mstim.EndRandomTest();
CHECK(r);
- SRandomTestInfo rInfo;
- r=mstim.GetRandomTestInfo(rInfo);
- test.Printf(_L("min error = %d\n"),rInfo.iMin);
- test.Printf(_L("max error = %d\n"),rInfo.iMax);
- test.Printf(_L("xfer cancel = %d\n"),rInfo.iXferC);
- test.Printf(_L("crit cancel = %d\n"),rInfo.iCritC);
- test.Printf(_L("start fails = %d\n"),rInfo.iStartFail);
- test.Printf(_L("debug calls = %d\n"),rInfo.iCallBacks);
- test.Printf(_L("completions = %d\n"),rInfo.iCompletions);
+ if (unicore)
+ {
+ SRandomTestInfo rInfo;
+ r=mstim.GetRandomTestInfo(rInfo);
+ test.Printf(_L("min error = %d\n"),rInfo.iMin);
+ test.Printf(_L("max error = %d\n"),rInfo.iMax);
+ test.Printf(_L("xfer cancel = %d\n"),rInfo.iXferC);
+ test.Printf(_L("crit cancel = %d\n"),rInfo.iCritC);
+ test.Printf(_L("start fails = %d\n"),rInfo.iStartFail);
+ test.Printf(_L("debug calls = %d\n"),rInfo.iCallBacks);
+ test.Printf(_L("completions = %d\n"),rInfo.iCompletions);
+ }
#endif
for (i=0; i<8; i++)
@@ -281,7 +316,8 @@
final_count=User::NTickCount();
elapsed=TInt(final_count-init_count);
- test.Printf(_L("Elapsed time %dms\n"),elapsed);
+ if (unicore)
+ test.Printf(_L("Elapsed time %dms\n"),elapsed);
const TInt period2[8]={31,32,0,0,7,43,19,0};
for (i=0; i<8; i++)
@@ -292,7 +328,8 @@
r=mstim.StopPeriodic(i);
CHECK(r);
SMsTimerInfo& z=info[i];
- test.Printf(_L("%1d: min=%-6d max=%-6d avg=%-6d count=%d\n"),i,z.iMin,z.iMax,z.iAvg,z.iCount);
+ if (unicore)
+ test.Printf(_L("%1d: min=%-6d max=%-6d avg=%-6d count=%d\n"),i,z.iMin,z.iMax,z.iAvg,z.iCount);
TInt count=elapsed/p;
TInt cdiff=count-z.iCount;
TEST(cdiff>=0 && cdiff<=2);
Binary file userlibandfileserver/fileserver/automounter/misc/FS_Automounter_HowTo.doc has changed