Implement hiding external stack frames.

This commit is contained in:
Bartosz Taudul 2024-02-27 02:03:33 +01:00
parent a1aa87df87
commit 77f8ec0b2f
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 63 additions and 9 deletions

View File

@ -489,6 +489,7 @@ private:
bool m_statHideUnknown = true; bool m_statHideUnknown = true;
bool m_showAllSymbols = false; bool m_showAllSymbols = false;
int m_showCallstackFrameAddress = 0; int m_showCallstackFrameAddress = 0;
bool m_showExternalFrames = false;
bool m_showUnknownFrames = true; bool m_showUnknownFrames = true;
bool m_statSeparateInlines = false; bool m_statSeparateInlines = false;
bool m_statShowAddress = false; bool m_statShowAddress = false;

View File

@ -10,6 +10,14 @@
namespace tracy namespace tracy
{ {
static bool IsFrameExternal( const char* filename, const char* image )
{
if( strncmp( filename, "/usr/", 5 ) == 0 || strncmp( filename, "/lib/", 5 ) == 0 || strcmp( filename, "[unknown]" ) == 0 ) return true;
if( strncmp( filename, "C:\\Program Files\\", 17 ) == 0 || strncmp( filename, "d:\\a01\\_work\\", 13 ) == 0 ) return true;
if( !image ) return false;
return strncmp( image, "/usr/", 5 ) == 0 || strncmp( image, "/lib/", 5 ) == 0 || strncmp( image, "/lib64/", 7 ) == 0 || strcmp( image, "<kernel>" ) == 0;
}
void View::DrawCallstackWindow() void View::DrawCallstackWindow()
{ {
bool show = true; bool show = true;
@ -97,6 +105,12 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton )
ImGui::SetClipboardText( s.str().c_str() ); ImGui::SetClipboardText( s.str().c_str() );
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
SmallCheckbox( "External frames", &m_showExternalFrames );
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
ImGui::TextUnformatted( ICON_FA_AT " Frame location:" ); ImGui::TextUnformatted( ICON_FA_AT " Frame location:" );
ImGui::SameLine(); ImGui::SameLine();
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
@ -138,6 +152,7 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton )
ImGui::TableSetupColumn( "Image" ); ImGui::TableSetupColumn( "Image" );
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
bool external = false;
int fidx = 0; int fidx = 0;
int bidx = 0; int bidx = 0;
for( auto& entry : cs ) for( auto& entry : cs )
@ -145,6 +160,11 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton )
auto frameData = m_worker.GetCallstackFrame( entry ); auto frameData = m_worker.GetCallstackFrame( entry );
if( !frameData ) if( !frameData )
{ {
if( !m_showExternalFrames )
{
external = true;
continue;
}
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text( "%i", fidx++ ); ImGui::Text( "%i", fidx++ );
@ -181,6 +201,33 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton )
if( match ) continue; if( match ) continue;
} }
auto filename = m_worker.GetString( frame.file );
auto image = frameData->imageName.Active() ? m_worker.GetString( frameData->imageName ) : nullptr;
if( IsFrameExternal( filename, image ) )
{
if( !m_showExternalFrames )
{
if( f == fsz-1 ) fidx++;
external = true;
continue;
}
}
else
{
if( external )
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::PushFont( m_smallFont );
TextDisabledUnformatted( "external" );
ImGui::PopFont();
ImGui::TableNextColumn();
TextDisabledUnformatted( "\xe2\x80\xa6" );
external = false;
}
}
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
bidx++; bidx++;
@ -230,14 +277,13 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton )
indentVal = sin( time * 60.f ) * 10.f * time; indentVal = sin( time * 60.f ) * 10.f * time;
ImGui::Indent( indentVal ); ImGui::Indent( indentVal );
} }
txt = m_worker.GetString( frame.file );
switch( m_showCallstackFrameAddress ) switch( m_showCallstackFrameAddress )
{ {
case 0: case 0:
TextDisabledUnformatted( LocationToString( txt, frame.line ) ); TextDisabledUnformatted( LocationToString( filename, frame.line ) );
if( ImGui::IsItemClicked() ) if( ImGui::IsItemClicked() )
{ {
ImGui::SetClipboardText( LocationToString( txt, frame.line ) ); ImGui::SetClipboardText( LocationToString( filename, frame.line ) );
} }
break; break;
case 1: case 1:
@ -308,7 +354,7 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton )
} }
else else
{ {
DrawSourceTooltip( txt, frame.line ); DrawSourceTooltip( filename, frame.line );
} }
if( ImGui::IsItemClicked( 1 ) ) if( ImGui::IsItemClicked( 1 ) )
{ {
@ -330,7 +376,7 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton )
} }
else else
{ {
if( !ViewDispatch( txt, frame.line, frame.symAddr ) ) if( !ViewDispatch( filename, frame.line, frame.symAddr ) )
{ {
m_callstackBuzzAnim.Enable( bidx, 0.5f ); m_callstackBuzzAnim.Enable( bidx, 0.5f );
} }
@ -343,13 +389,20 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton )
} }
ImGui::PopTextWrapPos(); ImGui::PopTextWrapPos();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if( frameData->imageName.Active() ) if( image ) TextDisabledUnformatted( image );
{
TextDisabledUnformatted( m_worker.GetString( frameData->imageName ) );
}
} }
} }
} }
if( external )
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::PushFont( m_smallFont );
TextDisabledUnformatted( "external" );
ImGui::PopFont();
ImGui::TableNextColumn();
TextDisabledUnformatted( "\xe2\x80\xa6" );
}
ImGui::EndTable(); ImGui::EndTable();
} }
} }