imgtools/imglib/symbolutil/bsymutil.h
changeset 695 46ca13b54f56
equal deleted inserted replaced
694:c3fbb20e86f0 695:46ca13b54f56
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __BSYMUTIL_H__
       
    19 #define __BSYMUTIL_H__
       
    20 
       
    21 #include <e32std.h>
       
    22 #include <vector>
       
    23 #include <string>
       
    24 
       
    25 using namespace std;
       
    26 
       
    27 const int BSYM_PAGE_SIZE = 4096;
       
    28 
       
    29 const int MaxSize = 4*1024*1024;
       
    30 const TUint16 BsymMajorVer = 3;
       
    31 const TUint16 BsymMinorVer = 0;
       
    32 struct TBsymHeader {
       
    33 	char iMagic[4]; // 'B','S','Y','M' always big-endian
       
    34 	char iMajorVer[2]; // always big-endian, currently 3
       
    35 	char iMinorVer[2]; // always big-endian, currently 0.
       
    36 	char iEndiannessFlag;
       
    37 	char iCompressionFlag;
       
    38 	char iReservered[2];
       
    39 	TUint32 iDbgUnitOffset;
       
    40 	TUint32 iDbgUnitCount;
       
    41 	TUint32 iSymbolOffset;
       
    42 	TUint32 iSymbolCount;
       
    43 	TUint32 iStringTableOffset;
       
    44 	TUint32 iStringTableBytes;
       
    45 	TUint32 iCompressedSize;
       
    46 	TUint32 iUncompressSize;
       
    47 	TUint32 iCompressInfoOffset;
       
    48 };
       
    49 struct TDbgUnitEntry {
       
    50 	TUint32 iCodeAddress;
       
    51 	TUint32 iCodeSymbolCount;
       
    52 	TUint32 iDataAddress;
       
    53 	TUint32 iDataSymbolCount;
       
    54 	TUint32 iBssAddress;
       
    55 	TUint32 iBssSymbolCount;
       
    56 	TUint32 iPCNameOffset;
       
    57 	TUint32 iDevNameOffset;
       
    58 	TUint32 iStartSymbolIndex;
       
    59 	TDbgUnitEntry()
       
    60 	{
       
    61 		iCodeAddress =0;
       
    62 		iCodeSymbolCount =0;
       
    63 		iDataAddress =0;
       
    64 		iDataSymbolCount =0;
       
    65 		iBssAddress =0;
       
    66 		iBssSymbolCount =0;
       
    67 		iPCNameOffset =0;
       
    68 		iDevNameOffset =0;
       
    69 		iStartSymbolIndex =0;
       
    70 	}
       
    71 	void Reset()
       
    72 	{
       
    73 		iCodeAddress =0;
       
    74 		iCodeSymbolCount =0;
       
    75 		iDataAddress =0;
       
    76 		iDataSymbolCount =0;
       
    77 		iBssAddress =0;
       
    78 		iBssSymbolCount =0;
       
    79 		iPCNameOffset =0;
       
    80 		iDevNameOffset =0;
       
    81 		iStartSymbolIndex =0;
       
    82 	}
       
    83 };
       
    84 struct TDbgUnitPCEntry {
       
    85 	TDbgUnitEntry iDbgUnitEntry;
       
    86 	string iPCName;
       
    87 	string iDevName;
       
    88 };
       
    89 struct TSymbolEntry {
       
    90 	TUint32 iAddress;
       
    91 	TUint32 iLength;
       
    92 	TUint32 iScopeNameOffset;
       
    93 	TUint32 iNameOffset;
       
    94 	TUint32 iSecNameOffset;
       
    95 	TSymbolEntry()
       
    96 	{
       
    97 		iAddress =0;
       
    98 		iLength =0;
       
    99 		iScopeNameOffset =0;
       
   100 		iNameOffset =0;
       
   101 		iSecNameOffset =0;
       
   102 	}
       
   103 };
       
   104 
       
   105 struct TSymbolPCEntry {
       
   106 	TSymbolEntry iSymbolEntry;
       
   107 	string iScopeName;
       
   108 	string iName;
       
   109 	string iSecName;
       
   110 };
       
   111 
       
   112 struct TPageInfo {
       
   113 	TUint32 iPageStartOffset;
       
   114 	TUint32 iPageDataSize;
       
   115 };
       
   116 
       
   117 struct TCompressedHeaderInfo
       
   118 {
       
   119 	TUint32 iPageSize;
       
   120 	TUint32 iTotalPageNumber;
       
   121 	TPageInfo iPages[1];
       
   122 };
       
   123 
       
   124 typedef vector<TDbgUnitPCEntry> TDbgUnitEntrySet;
       
   125 typedef vector<TSymbolPCEntry> TSymbolPCEntrySet;
       
   126 typedef vector<string> StringList;
       
   127 
       
   128 struct MapFileInfo
       
   129 {
       
   130 	TDbgUnitPCEntry iDbgUnitPCEntry;
       
   131 	TSymbolPCEntrySet iSymbolPCEntrySet;
       
   132 };
       
   133 
       
   134 typedef vector<MapFileInfo> MapFileInfoSet;
       
   135 class ByteOrderUtil
       
   136 {
       
   137 public:
       
   138 	static bool IsLittleEndian()
       
   139 	{
       
   140 		union {
       
   141 			unsigned int a;
       
   142 			unsigned char b;
       
   143 		} c;
       
   144 		c.a = 1;
       
   145 		return (c.b == 1);
       
   146 	}
       
   147 };
       
   148 
       
   149 class MemoryWriter
       
   150 {
       
   151 public:
       
   152 	MemoryWriter();
       
   153 	~MemoryWriter();
       
   154 	int WriteBytes(const char* pChar, int size);
       
   155 	TUint32 GetOffset();
       
   156 	char* GetDataPointer();
       
   157 	bool ExtendMemory();
       
   158 	bool SetOffset(TUint32 aOffset);
       
   159 	void AddEmptyString();
       
   160 	TUint32 AddString(const string& aStr);
       
   161 	TUint32 AddScopeName(const string& aStr);
       
   162 	void SetStringTableStart(TUint32 aOffset);
       
   163 	TUint32 GetStringTableStart();
       
   164 private:
       
   165 	char* iChar;
       
   166 	TUint32 iOffset;
       
   167 	TUint32 iStringTableStart;
       
   168 	string iLastScopeName;
       
   169 	TUint32 iLastScopeNameOffset;
       
   170 	TUint32 iTotalSize;
       
   171 };
       
   172 #endif