mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-14 04:01:48 +00:00
Allow restricting displayed allocs by time.
This commit is contained in:
parent
c1aaec32d6
commit
e80891e36d
@ -3826,10 +3826,36 @@ void View::DrawMemory()
|
|||||||
m_memInfo.ptrFind = 0;
|
m_memInfo.ptrFind = 0;
|
||||||
m_memInfo.pattern[0] = '\0';
|
m_memInfo.pattern[0] = '\0';
|
||||||
}
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Checkbox( "Restrict time", &m_memInfo.restrictTime );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextDisabled( "(?)" );
|
||||||
|
if( ImGui::IsItemHovered() )
|
||||||
|
{
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
ImGui::Text( "Don't show allocations beyond end of timeline display." );
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
if( ImGui::TreeNodeEx( "Allocations", ImGuiTreeNodeFlags_DefaultOpen ) )
|
||||||
|
{
|
||||||
if( m_memInfo.ptrFind != 0 )
|
if( m_memInfo.ptrFind != 0 )
|
||||||
{
|
{
|
||||||
std::vector<MemEvent*> match;
|
std::vector<MemEvent*> match;
|
||||||
|
match.reserve( mem.active.size() ); // heuristic
|
||||||
|
if( m_memInfo.restrictTime )
|
||||||
|
{
|
||||||
|
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 )
|
for( auto& v : mem.data )
|
||||||
{
|
{
|
||||||
if( v->ptr <= m_memInfo.ptrFind && v->ptr + v->size > m_memInfo.ptrFind )
|
if( v->ptr <= m_memInfo.ptrFind && v->ptr + v->size > m_memInfo.ptrFind )
|
||||||
@ -3837,19 +3863,16 @@ void View::DrawMemory()
|
|||||||
match.emplace_back( v );
|
match.emplace_back( v );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
|
||||||
if( match.empty() )
|
if( match.empty() )
|
||||||
{
|
{
|
||||||
ImGui::Text( "Found no allocations at given address" );
|
ImGui::Text( "Found no allocations at given address" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool expand = ImGui::TreeNodeEx( "Allocations", ImGuiTreeNodeFlags_DefaultOpen );
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "(%s)", RealToString( match.size(), true ) );
|
ImGui::TextDisabled( "(%s)", RealToString( match.size(), true ) );
|
||||||
if( expand )
|
|
||||||
{
|
|
||||||
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,21 +3885,37 @@ void View::DrawMemory()
|
|||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
} );
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if( ImGui::TreeNode( "Active allocations" ) )
|
if( ImGui::TreeNode( "Active allocations" ) )
|
||||||
{
|
{
|
||||||
std::vector<MemEvent*> items;
|
std::vector<MemEvent*> items;
|
||||||
items.reserve( mem.active.size() );
|
items.reserve( mem.active.size() );
|
||||||
|
if( m_memInfo.restrictTime )
|
||||||
|
{
|
||||||
|
for( auto& v : mem.data )
|
||||||
|
{
|
||||||
|
if( v->timeAlloc < m_zvEnd && ( v->timeFree > m_zvEnd || v->timeFree < 0 ) )
|
||||||
|
{
|
||||||
|
items.emplace_back( v );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for( auto& v : mem.active )
|
for( auto& v : mem.active )
|
||||||
{
|
{
|
||||||
items.emplace_back( v.second );
|
items.emplace_back( v.second );
|
||||||
}
|
}
|
||||||
std::sort( items.begin(), items.end(), []( const auto& lhs, const auto& rhs ) { return lhs->timeAlloc > rhs->timeAlloc; } );
|
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 );
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user