-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show statistics by userSize.
- Loading branch information
Showing
5 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <windows.h> | ||
#include "common.h" | ||
#include "BySizeProcessor.h" | ||
|
||
BySizeProcessor::BySizeProcessor() | ||
{ | ||
} | ||
|
||
void BySizeProcessor::Register(ULONG64 ustAddress, | ||
ULONG64 size, ULONG64 address, | ||
ULONG64 userSize, ULONG64 userAddress) | ||
{ | ||
UNREFERENCED_PARAMETER(size); | ||
UNREFERENCED_PARAMETER(address); | ||
UNREFERENCED_PARAMETER(userAddress); | ||
|
||
std::map<ULONG64, SizeRecord>::iterator itr = records_.find(userSize); | ||
if (itr == records_.end()) | ||
{ | ||
SizeRecord record; | ||
record.userSize = userSize; | ||
record.count = 1; | ||
record.ustAddress.insert(ustAddress); | ||
records_[userSize] = record; | ||
} | ||
else | ||
{ | ||
SizeRecord &record = itr->second; | ||
record.count++; | ||
record.ustAddress.insert(ustAddress); | ||
} | ||
} | ||
|
||
void BySizeProcessor::Print() | ||
{ | ||
std::multiset<SizeRecord> sorted; | ||
for (std::map<ULONG64, SizeRecord>::iterator itr = records_.begin(); itr != records_.end(); ++itr) | ||
{ | ||
sorted.insert(itr->second); | ||
} | ||
|
||
if (IsPtr64()) | ||
{ | ||
dprintf(" userSize( count) ust0, ust1,...\n"); | ||
} | ||
else | ||
{ | ||
dprintf("userSize( count) ust0, ust1,...\n"); | ||
} | ||
for (std::multiset<SizeRecord>::reverse_iterator itr = sorted.rbegin(); itr != sorted.rend(); ++itr) | ||
{ | ||
dprintf("%p(%p)", itr->userSize, itr->count); | ||
for (std::set<ULONG64>::iterator itr_ = itr->ustAddress.begin(); itr_ != itr->ustAddress.end(); ++itr_) | ||
{ | ||
dprintf("%p,", *itr_); | ||
} | ||
dprintf("\n"); | ||
} | ||
dprintf("\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include <set> | ||
#include "IProcessor.h" | ||
|
||
class BySizeProcessor : public IProcessor | ||
{ | ||
private: | ||
struct SizeRecord { | ||
ULONG64 userSize; | ||
ULONG64 count; | ||
std::set<ULONG64> ustAddress; | ||
bool operator< (const BySizeProcessor::SizeRecord& rhs) const | ||
{ | ||
return count < rhs.count; | ||
} | ||
}; | ||
|
||
/** | ||
* @brief userSize to SizeRecord map | ||
*/ | ||
std::map<ULONG64, SizeRecord> records_; | ||
|
||
public: | ||
/** | ||
* @brief constructor | ||
*/ | ||
BySizeProcessor(); | ||
|
||
/** | ||
* @copydoc IProcessor::StartHeap() | ||
*/ | ||
void StartHeap(ULONG64 /*heapAddress*/) {} | ||
|
||
/** | ||
* @copydoc IProcessor::Register() | ||
*/ | ||
void Register(ULONG64 ustAddress, | ||
ULONG64 size, ULONG64 address, | ||
ULONG64 userSize, ULONG64 userAddress); | ||
|
||
/** | ||
* @copydoc IProcessor::FinishHeap() | ||
*/ | ||
void FinishHeap(ULONG64 /*heapAddress*/) {} | ||
|
||
/** | ||
* @brief print summary of heap usage | ||
*/ | ||
void Print(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters