Allow restricting displayed allocs by time.

This commit is contained in:
Bartosz Taudul 2018-04-02 16:07:33 +02:00
parent c1aaec32d6
commit e80891e36d
2 changed files with 64 additions and 24 deletions

View File

@ -3826,30 +3826,53 @@ void View::DrawMemory()
m_memInfo.ptrFind = 0; m_memInfo.ptrFind = 0;
m_memInfo.pattern[0] = '\0'; m_memInfo.pattern[0] = '\0';
} }
ImGui::SameLine();
if( m_memInfo.ptrFind != 0 ) ImGui::Checkbox( "Restrict time", &m_memInfo.restrictTime );
ImGui::SameLine();
ImGui::TextDisabled( "(?)" );
if( ImGui::IsItemHovered() )
{ {
std::vector<MemEvent*> match; ImGui::BeginTooltip();
for( auto& v : mem.data ) ImGui::Text( "Don't show allocations beyond end of timeline display." );
{ ImGui::EndTooltip();
if( v->ptr <= m_memInfo.ptrFind && v->ptr + v->size > m_memInfo.ptrFind ) }
{
match.emplace_back( v );
}
}
ImGui::Separator(); ImGui::Separator();
if( match.empty() ) if( ImGui::TreeNodeEx( "Allocations", ImGuiTreeNodeFlags_DefaultOpen ) )
{
if( m_memInfo.ptrFind != 0 )
{ {
ImGui::Text( "Found no allocations at given address" ); std::vector<MemEvent*> match;
} match.reserve( mem.active.size() ); // heuristic
else if( m_memInfo.restrictTime )
{
bool expand = ImGui::TreeNodeEx( "Allocations", ImGuiTreeNodeFlags_DefaultOpen );
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", RealToString( match.size(), true ) );
if( expand )
{ {
for( auto& v : mem.data )
{
if( v->ptr <= m_memInfo.ptrFind && v->ptr + v->size > m_memInfo.ptrFind && v->timeAlloc < m_zvEnd )
{
match.emplace_back( v );
}
}
}
else
{
for( auto& v : mem.data )
{
if( v->ptr <= m_memInfo.ptrFind && v->ptr + v->size > m_memInfo.ptrFind )
{
match.emplace_back( v );
}
}
}
if( match.empty() )
{
ImGui::Text( "Found no allocations at given address" );
}
else
{
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", RealToString( match.size(), true ) );
ListMemData<decltype( match.begin() )>( match.begin(), match.end(), [this]( auto& it ) { ListMemData<decltype( match.begin() )>( match.begin(), match.end(), [this]( auto& it ) {
auto& v = *it; auto& v = *it;
if( v->ptr == m_memInfo.ptrFind ) if( v->ptr == m_memInfo.ptrFind )
@ -3862,9 +3885,9 @@ void View::DrawMemory()
} }
return v; return v;
} ); } );
ImGui::TreePop();
} }
} }
ImGui::TreePop();
} }
ImGui::Separator(); ImGui::Separator();
@ -3872,11 +3895,27 @@ void View::DrawMemory()
{ {
std::vector<MemEvent*> items; std::vector<MemEvent*> items;
items.reserve( mem.active.size() ); items.reserve( mem.active.size() );
for( auto& v : mem.active ) if( m_memInfo.restrictTime )
{ {
items.emplace_back( v.second ); for( auto& v : mem.data )
{
if( v->timeAlloc < m_zvEnd && ( v->timeFree > m_zvEnd || v->timeFree < 0 ) )
{
items.emplace_back( v );
}
}
} }
std::sort( items.begin(), items.end(), []( const auto& lhs, const auto& rhs ) { return lhs->timeAlloc > rhs->timeAlloc; } ); else
{
for( auto& v : mem.active )
{
items.emplace_back( v.second );
}
std::sort( items.begin(), items.end(), []( const auto& lhs, const auto& rhs ) { return lhs->timeAlloc < rhs->timeAlloc; } );
}
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", RealToString( items.size(), true ) );
ListMemData<decltype( items.begin() )>( items.begin(), items.end(), []( auto& v ) { ListMemData<decltype( items.begin() )>( items.begin(), items.end(), []( auto& v ) {
ImGui::Text( "0x%" PRIx64, (*v)->ptr ); ImGui::Text( "0x%" PRIx64, (*v)->ptr );

View File

@ -212,6 +212,7 @@ private:
bool show = false; bool show = false;
char pattern[1024] = {}; char pattern[1024] = {};
uint64_t ptrFind = 0; uint64_t ptrFind = 0;
bool restrictTime = false;
} m_memInfo; } m_memInfo;
}; };