mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Move memory allocations table drawing to a separate function.
This commit is contained in:
parent
1fa943d109
commit
c4a36398f6
@ -3650,50 +3650,8 @@ void View::DrawStatistics()
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::DrawMemory()
|
template<class T>
|
||||||
{
|
void View::ListMemData( T ptr, T end, std::function<MemEvent*(T&)> DrawAddress )
|
||||||
auto& mem = m_worker.GetMemData();
|
|
||||||
|
|
||||||
ImGui::Begin( "Memory", &m_memInfo.show );
|
|
||||||
|
|
||||||
ImGui::Text( "Total allocations: %-10s Active allocations: %-10s Memory usage: %s bytes", RealToString( mem.data.size(), true ), RealToString( mem.active.size(), true ), RealToString( mem.usage, true ) );
|
|
||||||
|
|
||||||
ImGui::InputText( "", m_memInfo.pattern, 1024 );
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if( ImGui::Button( "Find" ) )
|
|
||||||
{
|
|
||||||
m_memInfo.ptrFind = strtoull( m_memInfo.pattern, nullptr, 0 );
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
if( ImGui::Button( "Clear" ) )
|
|
||||||
{
|
|
||||||
m_memInfo.ptrFind = 0;
|
|
||||||
m_memInfo.pattern[0] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_memInfo.ptrFind != 0 )
|
|
||||||
{
|
|
||||||
std::vector<MemEvent*> match;
|
|
||||||
for( auto& v : mem.data )
|
|
||||||
{
|
|
||||||
if( v->ptr <= m_memInfo.ptrFind && v->ptr + v->size > m_memInfo.ptrFind )
|
|
||||||
{
|
|
||||||
match.emplace_back( v );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::Separator();
|
|
||||||
if( match.empty() )
|
|
||||||
{
|
|
||||||
ImGui::Text( "Found no allocations at given address" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool expand = ImGui::TreeNodeEx( "Allocations", ImGuiTreeNodeFlags_DefaultOpen );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextDisabled( "(%s)", RealToString( match.size(), true ) );
|
|
||||||
if( expand )
|
|
||||||
{
|
{
|
||||||
ImGui::Columns( 6 );
|
ImGui::Columns( 6 );
|
||||||
ImGui::Text( "Address" );
|
ImGui::Text( "Address" );
|
||||||
@ -3728,16 +3686,9 @@ void View::DrawMemory()
|
|||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for( auto& v : match )
|
while( ptr != end )
|
||||||
{
|
{
|
||||||
if( v->ptr == m_memInfo.ptrFind )
|
auto v = DrawAddress( ptr );
|
||||||
{
|
|
||||||
ImGui::Text( "0x%" PRIx64, m_memInfo.ptrFind );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ImGui::Text( "0x%" PRIx64 "+%" PRIu64, v->ptr, m_memInfo.ptrFind - v->ptr );
|
|
||||||
}
|
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::Text( "%s", RealToString( v->size, true ) );
|
ImGui::Text( "%s", RealToString( v->size, true ) );
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
@ -3790,8 +3741,68 @@ void View::DrawMemory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
|
ptr++;
|
||||||
}
|
}
|
||||||
ImGui::EndColumns();
|
ImGui::EndColumns();
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::DrawMemory()
|
||||||
|
{
|
||||||
|
auto& mem = m_worker.GetMemData();
|
||||||
|
|
||||||
|
ImGui::Begin( "Memory", &m_memInfo.show );
|
||||||
|
|
||||||
|
ImGui::Text( "Total allocations: %-10s Active allocations: %-10s Memory usage: %s bytes", RealToString( mem.data.size(), true ), RealToString( mem.active.size(), true ), RealToString( mem.usage, true ) );
|
||||||
|
|
||||||
|
ImGui::InputText( "", m_memInfo.pattern, 1024 );
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
if( ImGui::Button( "Find" ) )
|
||||||
|
{
|
||||||
|
m_memInfo.ptrFind = strtoull( m_memInfo.pattern, nullptr, 0 );
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if( ImGui::Button( "Clear" ) )
|
||||||
|
{
|
||||||
|
m_memInfo.ptrFind = 0;
|
||||||
|
m_memInfo.pattern[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_memInfo.ptrFind != 0 )
|
||||||
|
{
|
||||||
|
std::vector<MemEvent*> match;
|
||||||
|
for( auto& v : mem.data )
|
||||||
|
{
|
||||||
|
if( v->ptr <= m_memInfo.ptrFind && v->ptr + v->size > m_memInfo.ptrFind )
|
||||||
|
{
|
||||||
|
match.emplace_back( v );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
if( match.empty() )
|
||||||
|
{
|
||||||
|
ImGui::Text( "Found no allocations at given address" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool expand = ImGui::TreeNodeEx( "Allocations", ImGuiTreeNodeFlags_DefaultOpen );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextDisabled( "(%s)", RealToString( match.size(), true ) );
|
||||||
|
if( expand )
|
||||||
|
{
|
||||||
|
ListMemData<decltype( match.begin() )>( match.begin(), match.end(), [this]( auto& it ) {
|
||||||
|
auto& v = *it;
|
||||||
|
if( v->ptr == m_memInfo.ptrFind )
|
||||||
|
{
|
||||||
|
ImGui::Text( "0x%" PRIx64, m_memInfo.ptrFind );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::Text( "0x%" PRIx64 "+%" PRIu64, v->ptr, m_memInfo.ptrFind - v->ptr );
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
} );
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define __TRACYVIEW_HPP__
|
#define __TRACYVIEW_HPP__
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -76,6 +77,9 @@ private:
|
|||||||
void DrawStatistics();
|
void DrawStatistics();
|
||||||
void DrawMemory();
|
void DrawMemory();
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void ListMemData( T ptr, T end, std::function<MemEvent*(T&)> DrawAddress );
|
||||||
|
|
||||||
void DrawInfoWindow();
|
void DrawInfoWindow();
|
||||||
void DrawZoneInfoWindow();
|
void DrawZoneInfoWindow();
|
||||||
void DrawGpuInfoWindow();
|
void DrawGpuInfoWindow();
|
||||||
|
Loading…
Reference in New Issue
Block a user