Handle total cost updates upon mmap/munmap and physical memory consumption update...
authorRuben Ayrapetyan <r.ayrapetyan@samsung.com>
Thu, 14 Sep 2017 13:29:43 +0000 (16:29 +0300)
committerRuben Ayrapetyan <r.ayrapetyan@samsung.com>
Thu, 14 Sep 2017 13:19:28 +0000 (16:19 +0300)
src/analyze/accumulatedtracedata.cpp
src/analyze/accumulatedtracedata.h
src/analyze/gui/parser.cpp
src/analyze/print/heaptrack_print.cpp

index 1503a8e..8bcdf2e 100644 (file)
@@ -281,6 +281,14 @@ bool AccumulatedTraceData::read(istream& in, const ParsePass pass)
             rangeInfo.setTraceIndex(traceIndex.index);
 
             combineContiguousSimilarRanges();
+
+            if (pass != FirstPass) {
+                auto& allocation = findAllocation(traceIndex);
+
+                assert(allocation.traceIndex == traceIndex);
+
+                handleTotalCostUpdate();
+            }
         } else if (reader.mode() == '/') {
             uint64_t length, ptr;
 
@@ -410,6 +418,8 @@ bool AccumulatedTraceData::read(istream& in, const ParsePass pass)
                     }
                 }
             }
+
+            handleTotalCostUpdate();
         } else if (reader.mode() == 'k') {
             if (!isSmapsChunkInProcess) {
                 cerr << "wrong trace format (smaps data outside of smaps chunk)" << endl;
@@ -483,6 +493,7 @@ bool AccumulatedTraceData::read(istream& in, const ParsePass pass)
                 allocation.malloc.allocated += info.size;
                 ++allocation.malloc.allocations;
 
+                handleTotalCostUpdate();
                 handleAllocation(info, allocationIndex);
             }
 
index 36c1a1a..017f78d 100644 (file)
@@ -251,6 +251,7 @@ struct AccumulatedTraceData
     virtual ~AccumulatedTraceData() = default;
 
     virtual void handleTimeStamp(int64_t oldStamp, int64_t newStamp) = 0;
+    virtual void handleTotalCostUpdate() = 0;
     virtual void handleAllocation(const AllocationInfo& info, const AllocationIndex index) = 0;
     virtual void handleDebuggee(const char* command) = 0;
 
index fe219a4..0c6abf5 100644 (file)
@@ -251,10 +251,13 @@ struct ParserData final : public AccumulatedTraceData
         temporaryChartData.rows << temporary;
     }
 
-    void handleAllocation(const AllocationInfo& info, const AllocationIndex index)
+    void handleTotalCostUpdate()
     {
         maxConsumedSinceLastTimeStamp = max(maxConsumedSinceLastTimeStamp, totalCost.getDisplay()->leaked);
+    }
 
+    void handleAllocation(const AllocationInfo& info, const AllocationIndex index)
+    {
         if (index.index == allocationInfoCounter.size()) {
             allocationInfoCounter.push_back({info, 1});
         } else {
index c798d09..7a620f0 100644 (file)
@@ -464,6 +464,10 @@ struct Printer final : public AccumulatedTraceData
         }
     }
 
+    void handleTotalCostUpdate()
+    {
+    }
+
     void handleAllocation(const AllocationInfo& info, const AllocationIndex /*index*/) override
     {
         if (printHistogram) {