uint64_t lastPtr = 0;
AllocationInfoSet allocationInfos;
+ uint64_t allocations = 0;
+ uint64_t leakedAllocations = 0;
+ uint64_t temporaryAllocations = 0;
+
while (reader.getLine(cin)) {
if (reader.mode() == 'x') {
reader >> exe;
// trace point, map current output index to parent index
fprintf(stdout, "t %zx %zx\n", ipId, parentIndex);
} else if (reader.mode() == '+') {
+ ++allocations;
+ ++leakedAllocations;
uint64_t size = 0;
TraceIndex traceId;
uint64_t ptr = 0;
cerr << "failed to parse line: " << reader.line() << endl;
continue;
}
+
AllocationIndex index;
if (allocationInfos.add(size, traceId, &index)) {
fprintf(stdout, "a %zx %x\n", size, traceId.index);
lastPtr = ptr;
fprintf(stdout, "+ %x\n", index.index);
} else if (reader.mode() == '-') {
+ --leakedAllocations;
uint64_t ptr = 0;
if (!(reader >> ptr)) {
cerr << "failed to parse line: " << reader.line() << endl;
}
fprintf(stdout, "- %x", allocation.first.index);
if (temporary) {
+ ++temporaryAllocations;
fputs(" 1\n", stdout);
} else {
fputc('\n', stdout);
}
}
+ fprintf(stderr, "heaptrack stats:\n"
+ "\tallocations: \t%lu\n"
+ "\tleaked allocations: \t%lu\n"
+ "\ttemporary allocations:\t%lu\n",
+ allocations, leakedAllocations, temporaryAllocations);
+
return 0;
}