Esempio n. 1
0
            // fixes up unassigned field for each "Free" log entry.
            public void FixupLog(Log log)
            {
                Utility.AllocLists li = new Utility.AllocLists();
                int index = log.Count;
                try
                {
                    for (int i = 0; i < index; i++)
                    {
                        LogEntry logentry = log[i];
                        if (logentry.type == 'A')
                        {
                            if (i != logentry.index)
                                System.Diagnostics.Debug.Print("indices don't match: {0} != {1}\n", i, logentry.index);
                            li.Allocate(logentry.address, (int)logentry.index);
                        }
                        else if (logentry.type == 'F')
                        {
                            int idx = li.Free(logentry.address);
                            if (idx > 0)
                            {
                                //  ((LogEntry)log[idx]).allocSize = logentry.allocSize;
                                logentry.category = ((LogEntry)log[idx]).category;
                                logentry.allocator = ((LogEntry)log[idx]).allocator;
                              //  System.Diagnostics.Debug.Assert(((LogEntry)log[idx]).allocSize == logentry.allocSize, "ERROR! Allocated and deleted sizes don't match");
                            }
                            else
                            {
                                // System.Diagnostics.Debug.Print("Missing alloc! For now 'disable' this Free by setting its size and address to 0");
                                ((LogEntry)log[i]).allocSize = ((LogEntry)log[i]).address = 0;
                                //   removeFrees.Add(logentry.index);
                            }
                        }
                    }

                    log.mLogFixed = true;
                }
                catch (System.ArgumentOutOfRangeException)
                {
                    System.Diagnostics.Debug.Print("!!System.ArgumentOutOfRangeException");
                }
            }
Esempio n. 2
0
            public SnapShot(Log log, int index)
            {
                mIndex = index;
                Utility.AllocLists li = new Utility.AllocLists();

                // Play thru allocations till index reached.
                for (int i = 0; i < index; i++)
                {
                    LogEntry logentry = log[i];
                    if (logentry.type == 'A')
                        li.Allocate(logentry.address, i);
                    else if (logentry.type == 'F')
                        li.Free(logentry.address);
                }

                // Now store as an array
                mArray = li.GetArray();
                mSorted = false;
                mAllocListsMutex.WaitOne();
                mAllocListsLastIndex = index;
                mAllocLists = li;
                mAllocListsMutex.ReleaseMutex();
            }
Esempio n. 3
0
            //-------------------------------------------------------------------------
            void PopulateFreeInformation()
            {
                uint rangeStart = 0;
                uint rangeEnd = 0;
                if(mLog.Count > 0)
                {
                    rangeEnd = rangeStart = mLog[0].address;
                }
                Utility.AllocLists al = new Utility.AllocLists();
                for (int i = 0; i < mLog.Count; i++)
                {
                    LogEntry l = mLog[i];
                    if (l.type == 'A')
                    {
                        rangeStart = l.address < rangeStart ? l.address : rangeStart;
                        rangeEnd = (l.address + l.allocSize) > rangeEnd ? (l.address + l.allocSize) : rangeEnd;
                        al.Allocate(l.address, i);
                    }
                    else if (l.type == 'F')
                    {
                        int index = al.Free(l.address);
                        LogEntry logentry = mLog[ index ];
                        //l.alignment = logentry.alignment;
                        l.allocSize = logentry.allocSize;
                        l.nameString = logentry.nameString;
                        l.index = logentry.index;
                    //	l.reqSize = logentry.reqSize;
                        l.category = logentry.category;
                        l.allocator = logentry.allocator;
                    }
                }

                // this is a fix for cases when we don't know the range for heap. Assumption here is that there is only one heap (i.e. Allocator)
                foreach (LogEntryAllocators e in mLog.GetAllocatorList())
                {
                    if(e.mStartAddress == 0 && e.mEndAddress == 0)
                    {
                        e.mStartAddress = rangeStart;
                        e.mEndAddress = rangeEnd;
                    }
                }
            }
Esempio n. 4
0
            public SnapShot(Log log, int index, bool addressSorted)
            {
                if (!log.mLogFixed)
                    FixupLog(log);

                mIndex = index;
                Utility.AllocLists li = new Utility.AllocLists();
                // Play through allocations till index reached.
                for (int i = 0; i < index; i++)
                {
                    LogEntry logentry = log[i];
                    if (logentry.type == 'A')
                    {
                        li.Allocate(logentry.address, (int)logentry.index);
                    }
                    else if (logentry.type == 'F')
                    {
                        int idx = li.Free(logentry.address);
                    }
                }

                // Now store as an array
                if (addressSorted)
                    mArray = li.GetArrayAddressSorted(ref mMaxLogIndex);
                else
                {
                    mArray = li.GetArray(ref mMaxLogIndex);
                    mArray.Sort(new CompareIndices());
                }

                mSorted = false;
                mAllocListsMutex.WaitOne();
                mAllocListsLastIndex = index;
                mAllocLists = li;
                mAllocListsMutex.ReleaseMutex();
            }