Update contrib.
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 // This class define the interface used by the distribution sampler to allocate
25 // a 'bucket' for a given PC value
27 // This also provide a minimual implementation that allocates all samples to 'other'
32 enum {KOtherBucket = 0};
33 enum TOrder {ERandom, EOrdered, ELinear};
35 // the number of buckets (including the 'other' bucket)
36 virtual int Size() const;
37 // map a PC to a bucket
38 virtual int Bucket(PC aPc) const;
40 virtual const char* Name(int aBucket) const;
41 // determine whether the results should be ordered
42 virtual TOrder Ordering() const;
45 class AddressCodeSpace : public CodeSpace
48 enum TType {EAbsolute, ERelative};
50 AddressCodeSpace(PC aBase, PC aLimit, unsigned aBucketSize, TType aType);
53 int Bucket(PC aPc) const;
54 const char* Name(int aBucket) const;
55 TOrder Ordering() const;
58 unsigned iBucketShift;
61 mutable char iBuffer[10];
64 class MappedCodeSpace : public CodeSpace
71 inline Element(PC aBase, PC aLimit, const char* aName)
72 :iBase(aBase), iLimit(aLimit), iName(aName), iBucket(0), iUnloaded(false)
81 typedef std::multimap<PC, Element> Map;
85 IdNames(int aId, int aIndex) : iId(aId), iIndex(aIndex) {}
89 typedef std::multimap<const char*, IdNames> NamesMap;
92 class Partition : public SymbolFile::Parser
94 friend class MappedCodeSpace;
99 inline void Add(PC aBase, PC aLimit, const char* aName)
100 {iCodeSpace->Add(aBase, aLimit, aName);}
101 inline void Done(PC aFirstPc=0, PC aLastPc=0, int aModuleId=0)
102 {iCodeSpace->Done(aFirstPc, aLastPc, aModuleId);}
104 MappedCodeSpace* iCodeSpace;
106 friend class Partition;
109 MappedCodeSpace(const SymbolFile& aSymbols, Partition& aPartition);
110 std::pair<const char*,unsigned> Lookup(PC aPc) const;
112 // MappedCodeSpace();
113 void Add(PC aBase, PC aLimit, const char* aName);
114 void Done(PC aFirstPc, PC aLastPc, int aModuleId);
116 const Element* Find(PC aPc) const;
119 int Bucket(PC aPc) const;
120 const char* Name(int aBucket) const;
123 std::vector<const char*> iNames;
127 class PartitionByFunction : public MappedCodeSpace::Partition
130 PartitionByFunction(const char* aFile, const char* aFunction);
132 void File(const char* aName);
133 bool Symbol(const char* aName, PC aPc, int aLength);
136 const char* iFunction;
140 class PartitionByDll : public MappedCodeSpace::Partition
143 PartitionByDll(const char* aFile)
144 :iMatch(aFile), iLastFile(0), iLastFileAddress(0), iCurrentFile(0)
147 void File(const char* aName);
148 bool Symbol(const char* aName, PC aPc, int aLength);
151 const char* iLastFile;
153 const char* iCurrentFile;