mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Add basic lock info window.
This commit is contained in:
parent
ff8c9ab6dc
commit
444d5e20f0
1
NEWS
1
NEWS
@ -18,6 +18,7 @@ v0.5 (xxxx-xx-xx)
|
|||||||
after the connection to the client is terminated.
|
after the connection to the client is terminated.
|
||||||
- Active trace can be discarded.
|
- Active trace can be discarded.
|
||||||
- Call stack capture may be forced through TRACY_CALLSTACK define.
|
- Call stack capture may be forced through TRACY_CALLSTACK define.
|
||||||
|
- Lock info window has been added.
|
||||||
|
|
||||||
v0.4 (2018-10-09)
|
v0.4 (2018-10-09)
|
||||||
-----------------
|
-----------------
|
||||||
|
|||||||
@ -293,6 +293,7 @@ View::View( const char* addr, ImFont* fixedWidth, SetTitleCallback stcb )
|
|||||||
, m_memoryAllocHover( -1 )
|
, m_memoryAllocHover( -1 )
|
||||||
, m_memoryAllocHoverWait( 0 )
|
, m_memoryAllocHoverWait( 0 )
|
||||||
, m_frames( nullptr )
|
, m_frames( nullptr )
|
||||||
|
, m_lockInfoWindow( InvalidId )
|
||||||
, m_gpuThread( 0 )
|
, m_gpuThread( 0 )
|
||||||
, m_gpuStart( 0 )
|
, m_gpuStart( 0 )
|
||||||
, m_gpuEnd( 0 )
|
, m_gpuEnd( 0 )
|
||||||
@ -340,6 +341,7 @@ View::View( FileRead& f, ImFont* fixedWidth, SetTitleCallback stcb )
|
|||||||
, m_memoryAllocHover( -1 )
|
, m_memoryAllocHover( -1 )
|
||||||
, m_memoryAllocHoverWait( 0 )
|
, m_memoryAllocHoverWait( 0 )
|
||||||
, m_frames( m_worker.GetFramesBase() )
|
, m_frames( m_worker.GetFramesBase() )
|
||||||
|
, m_lockInfoWindow( InvalidId )
|
||||||
, m_gpuThread( 0 )
|
, m_gpuThread( 0 )
|
||||||
, m_gpuStart( 0 )
|
, m_gpuStart( 0 )
|
||||||
, m_gpuEnd( 0 )
|
, m_gpuEnd( 0 )
|
||||||
@ -750,6 +752,7 @@ bool View::DrawImpl()
|
|||||||
if( m_showInfo ) DrawInfo();
|
if( m_showInfo ) DrawInfo();
|
||||||
if( m_textEditorFile ) DrawTextEditor();
|
if( m_textEditorFile ) DrawTextEditor();
|
||||||
if( m_goToFrame ) DrawGoToFrame();
|
if( m_goToFrame ) DrawGoToFrame();
|
||||||
|
if( m_lockInfoWindow != InvalidId ) DrawLockInfoWindow();
|
||||||
|
|
||||||
const auto& io = ImGui::GetIO();
|
const auto& io = ImGui::GetIO();
|
||||||
if( m_zoomAnim.active )
|
if( m_zoomAnim.active )
|
||||||
@ -774,6 +777,7 @@ bool View::DrawImpl()
|
|||||||
m_zoneinfoBuzzAnim.Update( io.DeltaTime );
|
m_zoneinfoBuzzAnim.Update( io.DeltaTime );
|
||||||
m_findZoneBuzzAnim.Update( io.DeltaTime );
|
m_findZoneBuzzAnim.Update( io.DeltaTime );
|
||||||
m_optionsLockBuzzAnim.Update( io.DeltaTime );
|
m_optionsLockBuzzAnim.Update( io.DeltaTime );
|
||||||
|
m_lockInfoAnim.Update( io.DeltaTime );
|
||||||
|
|
||||||
return keepOpen;
|
return keepOpen;
|
||||||
}
|
}
|
||||||
@ -3119,6 +3123,11 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
TextFocused( "Lock events:", RealToString( v.second.timeline.size(), true ) );
|
TextFocused( "Lock events:", RealToString( v.second.timeline.size(), true ) );
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
|
|
||||||
|
if( ImGui::IsMouseClicked( 0 ) )
|
||||||
|
{
|
||||||
|
m_lockInfoWindow = v.first;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
@ -7070,6 +7079,71 @@ void View::DrawGoToFrame()
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::DrawLockInfoWindow()
|
||||||
|
{
|
||||||
|
auto it = m_worker.GetLockMap().find( m_lockInfoWindow );
|
||||||
|
assert( it != m_worker.GetLockMap().end() );
|
||||||
|
const auto& lock = it->second;
|
||||||
|
const auto& srcloc = m_worker.GetSourceLocation( lock.srcloc );
|
||||||
|
auto fileName = m_worker.GetString( srcloc.file );
|
||||||
|
|
||||||
|
bool visible = true;
|
||||||
|
ImGui::Begin( "Lock info", &visible, ImGuiWindowFlags_AlwaysAutoResize );
|
||||||
|
ImGui::Text( "Lock #%" PRIu32 ": %s", m_lockInfoWindow, m_worker.GetString( srcloc.function ) );
|
||||||
|
ImGui::TextDisabled( "Location:" );
|
||||||
|
if( m_lockInfoAnim.Match( m_lockInfoWindow ) )
|
||||||
|
{
|
||||||
|
const auto time = m_lockInfoAnim.Time();
|
||||||
|
const auto indentVal = sin( time * 60.f ) * 10.f * time;
|
||||||
|
ImGui::SameLine( 0, ImGui::GetStyle().ItemSpacing.x + indentVal );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
ImGui::Text( "%s:%i", fileName, srcloc.line );
|
||||||
|
if( ImGui::IsItemClicked( 1 ) )
|
||||||
|
{
|
||||||
|
if( FileExists( fileName ) )
|
||||||
|
{
|
||||||
|
SetTextEditorFile( fileName, srcloc.line );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_lockInfoAnim.Enable( m_lockInfoWindow, 0.5f );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch( lock.type )
|
||||||
|
{
|
||||||
|
case LockType::Lockable:
|
||||||
|
TextFocused( "Type:", "lockable" );
|
||||||
|
break;
|
||||||
|
case LockType::SharedLockable:
|
||||||
|
TextFocused( "Type:", "shared lockable" );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
TextFocused( "Lock events:", RealToString( lock.timeline.size(), true ) );
|
||||||
|
ImGui::Separator();
|
||||||
|
const auto threadList = ImGui::TreeNode( "Thread list" );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextDisabled( "(%zu)", lock.threadList.size() );
|
||||||
|
if( threadList )
|
||||||
|
{
|
||||||
|
for( const auto& t : lock.threadList )
|
||||||
|
{
|
||||||
|
ImGui::Text( "%s", m_worker.GetThreadString( t ) );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextDisabled( "(0x%" PRIX64 ")", t );
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
if( !visible ) m_lockInfoWindow = InvalidId;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void View::ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const char* id )
|
void View::ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const char* id )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -64,6 +64,8 @@ private:
|
|||||||
Short
|
Short
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum { InvalidId = 0xFFFFFFFF };
|
||||||
|
|
||||||
void InitTextEditor();
|
void InitTextEditor();
|
||||||
|
|
||||||
const char* ShortenNamespace( const char* name ) const;
|
const char* ShortenNamespace( const char* name ) const;
|
||||||
@ -100,6 +102,7 @@ private:
|
|||||||
void DrawInfo();
|
void DrawInfo();
|
||||||
void DrawTextEditor();
|
void DrawTextEditor();
|
||||||
void DrawGoToFrame();
|
void DrawGoToFrame();
|
||||||
|
void DrawLockInfoWindow();
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const char* id = nullptr );
|
void ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const char* id = nullptr );
|
||||||
@ -228,6 +231,7 @@ private:
|
|||||||
int64_t m_memoryAllocHover;
|
int64_t m_memoryAllocHover;
|
||||||
int m_memoryAllocHoverWait;
|
int m_memoryAllocHoverWait;
|
||||||
const FrameData* m_frames;
|
const FrameData* m_frames;
|
||||||
|
uint32_t m_lockInfoWindow;
|
||||||
|
|
||||||
Region m_highlight;
|
Region m_highlight;
|
||||||
Region m_highlightZoom;
|
Region m_highlightZoom;
|
||||||
@ -258,6 +262,7 @@ private:
|
|||||||
BuzzAnim<const void*> m_zoneinfoBuzzAnim;
|
BuzzAnim<const void*> m_zoneinfoBuzzAnim;
|
||||||
BuzzAnim<int> m_findZoneBuzzAnim;
|
BuzzAnim<int> m_findZoneBuzzAnim;
|
||||||
BuzzAnim<uint32_t> m_optionsLockBuzzAnim;
|
BuzzAnim<uint32_t> m_optionsLockBuzzAnim;
|
||||||
|
BuzzAnim<uint32_t> m_lockInfoAnim;
|
||||||
|
|
||||||
Vector<const ZoneEvent*> m_zoneInfoStack;
|
Vector<const ZoneEvent*> m_zoneInfoStack;
|
||||||
Vector<const GpuEvent*> m_gpuInfoStack;
|
Vector<const GpuEvent*> m_gpuInfoStack;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user