diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 9c0cf1e2..3035e0eb 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -12630,12 +12630,39 @@ void View::DrawInfo() ImGui::TextUnformatted( "Coarse CPU core context switch data" ); ImGui::EndTooltip(); } - TextFocused( "Source file cache:", RealToString( m_worker.GetSourceFileCacheCount() ) ); - if( ImGui::IsItemHovered() ) + if( m_worker.GetSourceFileCacheCount() == 0 ) { - ImGui::BeginTooltip(); - ImGui::TextUnformatted( MemSizeToString( m_worker.GetSourceFileCacheSize() ) ); - ImGui::EndTooltip(); + TextFocused( "Source file cache:", "0" ); + } + else + { + ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] ); + const bool expand = ImGui::TreeNode( "Source file cache:" ); + ImGui::PopStyleColor(); + ImGui::SameLine(); + ImGui::TextUnformatted( RealToString( m_worker.GetSourceFileCacheCount() ) ); + if( ImGui::IsItemHovered() ) + { + ImGui::BeginTooltip(); + ImGui::TextUnformatted( MemSizeToString( m_worker.GetSourceFileCacheSize() ) ); + ImGui::EndTooltip(); + } + if( expand ) + { + auto& cache = m_worker.GetSourceFileCache(); + std::vector vec; + vec.reserve( cache.size() ); + for( auto it = cache.begin(); it != cache.end(); ++it ) vec.emplace_back( it ); + pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return strcmp( lhs->first, rhs->first ) < 0; } ); + for( auto& v : vec ) + { + ImGui::BulletText( v->first ); + if( ImGui::IsItemClicked() ) ViewSource( v->first, 0 ); + ImGui::SameLine(); + ImGui::TextDisabled( "(%s)", MemSizeToString( v->second.len ) ); + } + ImGui::TreePop(); + } } ImGui::TreePop(); } diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 0e7efabb..6677f326 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -457,6 +457,7 @@ public: uint64_t GetPidFromTid( uint64_t tid ) const; const unordered_flat_map& GetCpuThreadData() const { return m_data.cpuThreadData; } void GetCpuUsageAtTime( int64_t time, int& own, int& other ) const; + const unordered_flat_map& GetSourceFileCache() const { return m_data.sourceFileCache; } uint64_t GetSourceFileCacheCount() const { return m_data.sourceFileCache.size(); } uint64_t GetSourceFileCacheSize() const; MemoryBlock GetSourceFileFromCache( const char* file ) const;