Push detailed callstack to a separate window.

Only show function names (no source files or line numbers) in callstack
tooltip.
This commit is contained in:
Bartosz Taudul 2018-06-20 13:23:08 +02:00
parent 9a5329b97d
commit 15ff98b64a
2 changed files with 46 additions and 4 deletions

View File

@ -198,6 +198,7 @@ View::View( const char* addr )
, m_zoneInfoWindow( nullptr ) , m_zoneInfoWindow( nullptr )
, m_lockHighlight { -1 } , m_lockHighlight { -1 }
, m_gpuInfoWindow( nullptr ) , m_gpuInfoWindow( nullptr )
, m_callstackInfoWindow( 0 )
, m_gpuThread( 0 ) , m_gpuThread( 0 )
, m_gpuStart( 0 ) , m_gpuStart( 0 )
, m_gpuEnd( 0 ) , m_gpuEnd( 0 )
@ -232,6 +233,7 @@ View::View( FileRead& f )
, m_zvScroll( 0 ) , m_zvScroll( 0 )
, m_zoneInfoWindow( nullptr ) , m_zoneInfoWindow( nullptr )
, m_gpuInfoWindow( nullptr ) , m_gpuInfoWindow( nullptr )
, m_callstackInfoWindow( 0 )
, m_gpuThread( 0 ) , m_gpuThread( 0 )
, m_gpuStart( 0 ) , m_gpuStart( 0 )
, m_gpuEnd( 0 ) , m_gpuEnd( 0 )
@ -390,6 +392,7 @@ bool View::DrawImpl()
if( m_showStatistics ) DrawStatistics(); if( m_showStatistics ) DrawStatistics();
if( m_memInfo.show ) DrawMemory(); if( m_memInfo.show ) DrawMemory();
if( m_compare.show ) DrawCompare(); if( m_compare.show ) DrawCompare();
if( m_callstackInfoWindow != 0 ) DrawCallstackWindow();
if( m_zoomAnim.active ) if( m_zoomAnim.active )
{ {
@ -4766,6 +4769,39 @@ void View::DrawStatistics()
ImGui::End(); ImGui::End();
} }
void View::DrawCallstackWindow()
{
bool show = true;
ImGui::Begin( "Callstack", &show );
auto& cs = m_worker.GetCallstack( m_callstackInfoWindow );
int fidx = 0;
for( auto& entry : cs )
{
auto frame = m_worker.GetCallstackFrame( entry );
if( !frame )
{
ImGui::Text( "%i. 0x%" PRIX64, fidx++, entry );
}
else
{
ImGui::Text( "%i. %s", fidx++, m_worker.GetString( frame->name ) );
ImGui::SameLine();
ImGui::PushTextWrapPos( 0.0f );
ImGui::TextDisabled( "(%s:%i)", m_worker.GetString( frame->file ), frame->line );
ImGui::PopTextWrapPos();
}
}
ImGui::End();
if( !show )
{
m_callstackInfoWindow = 0;
}
}
template<class T> template<class T>
void View::ListMemData( T ptr, T end, std::function<const MemEvent*(T&)> DrawAddress ) void View::ListMemData( T ptr, T end, std::function<const MemEvent*(T&)> DrawAddress )
{ {
@ -4926,7 +4962,10 @@ void View::ListMemData( T ptr, T end, std::function<const MemEvent*(T&)> DrawAdd
} }
else else
{ {
ImGui::Text( "[alloc]" ); if( ImGui::SmallButton( "alloc" ) )
{
m_callstackInfoWindow = v->csAlloc;
}
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
{ {
CallstackTooltip( v->csAlloc ); CallstackTooltip( v->csAlloc );
@ -4941,7 +4980,10 @@ void View::ListMemData( T ptr, T end, std::function<const MemEvent*(T&)> DrawAdd
} }
else else
{ {
ImGui::Text( "[free]" ); if( ImGui::SmallButton( "free" ) )
{
m_callstackInfoWindow = v->csFree;
}
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
{ {
CallstackTooltip( v->csFree ); CallstackTooltip( v->csFree );
@ -5583,8 +5625,6 @@ void View::CallstackTooltip( uint32_t idx )
else else
{ {
ImGui::Text( "%i. %s", fidx++, m_worker.GetString( frame->name ) ); ImGui::Text( "%i. %s", fidx++, m_worker.GetString( frame->name ) );
ImGui::SameLine();
ImGui::TextDisabled( "(%s:%i)", m_worker.GetString( frame->file ), frame->line );
} }
} }
ImGui::EndTooltip(); ImGui::EndTooltip();

View File

@ -82,6 +82,7 @@ private:
void DrawStatistics(); void DrawStatistics();
void DrawMemory(); void DrawMemory();
void DrawCompare(); void DrawCompare();
void DrawCallstackWindow();
template<class T> template<class T>
void ListMemData( T ptr, T end, std::function<const MemEvent*(T&)> DrawAddress ); void ListMemData( T ptr, T end, std::function<const MemEvent*(T&)> DrawAddress );
@ -172,6 +173,7 @@ private:
const GpuEvent* m_gpuInfoWindow; const GpuEvent* m_gpuInfoWindow;
const GpuEvent* m_gpuHighlight; const GpuEvent* m_gpuHighlight;
uint64_t m_gpuInfoWindowThread; uint64_t m_gpuInfoWindowThread;
uint32_t m_callstackInfoWindow;
Region m_highlight; Region m_highlight;