mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 07:54:36 +00:00
Perform source file name substitution.
This commit is contained in:
parent
47cfb4ae35
commit
01d7fefe52
@ -113,6 +113,7 @@
|
||||
<ClCompile Include="..\..\..\nfd\nfd_win.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyBadVersion.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyColor.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyFilesystem.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyMmap.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyPrint.cpp" />
|
||||
|
@ -195,6 +195,9 @@
|
||||
<ClCompile Include="..\..\..\server\TracyColor.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\server\TracyFilesystem.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||
|
17
server/TracyFilesystem.cpp
Normal file
17
server/TracyFilesystem.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "TracyFilesystem.hpp"
|
||||
#include "TracyView.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
bool SourceFileValid( const char* fn, uint64_t olderThan, const View& view )
|
||||
{
|
||||
struct stat buf;
|
||||
if( stat( view.SourceSubstitution( fn ), &buf ) == 0 && ( buf.st_mode & S_IFREG ) != 0 )
|
||||
{
|
||||
return (uint64_t)buf.st_mtime < olderThan;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +1,21 @@
|
||||
#ifndef __TRACYFILESYSTEM_HPP__
|
||||
#define __TRACYFILESYSTEM_HPP__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
class View;
|
||||
|
||||
static inline bool FileExists( const char* fn )
|
||||
{
|
||||
struct stat buf;
|
||||
return stat( fn, &buf ) == 0 && ( buf.st_mode & S_IFREG ) != 0;
|
||||
}
|
||||
|
||||
static inline bool SourceFileValid( const char* fn, uint64_t olderThan )
|
||||
{
|
||||
struct stat buf;
|
||||
if( stat( fn, &buf ) == 0 && ( buf.st_mode & S_IFREG ) != 0 )
|
||||
{
|
||||
return (uint64_t)buf.st_mtime < olderThan;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool SourceFileValid( const char* fn, uint64_t olderThan, const View& view );
|
||||
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
|
||||
return true;
|
||||
}
|
||||
|
||||
void SourceView::Render( const Worker& worker )
|
||||
void SourceView::Render( const Worker& worker, const View& view )
|
||||
{
|
||||
m_highlightAddr.Decay( 0 );
|
||||
m_hoveredLine.Decay( 0 );
|
||||
@ -342,7 +342,7 @@ void SourceView::Render( const Worker& worker )
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSymbolView( worker );
|
||||
RenderSymbolView( worker, view );
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,7 +378,7 @@ void SourceView::RenderSimpleSourceView()
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void SourceView::RenderSymbolView( const Worker& worker )
|
||||
void SourceView::RenderSymbolView( const Worker& worker, const View& view )
|
||||
{
|
||||
assert( m_symAddr != 0 );
|
||||
|
||||
@ -558,16 +558,16 @@ void SourceView::RenderSymbolView( const Worker& worker )
|
||||
switch( m_displayMode )
|
||||
{
|
||||
case DisplaySource:
|
||||
RenderSymbolSourceView( iptotalSrc, ipcountSrc, ipcountAsm, ipmaxSrc, worker );
|
||||
RenderSymbolSourceView( iptotalSrc, ipcountSrc, ipcountAsm, ipmaxSrc, worker, view );
|
||||
break;
|
||||
case DisplayAsm:
|
||||
jumpOut = RenderSymbolAsmView( iptotalAsm, ipcountAsm, ipmaxAsm, worker );
|
||||
jumpOut = RenderSymbolAsmView( iptotalAsm, ipcountAsm, ipmaxAsm, worker, view );
|
||||
break;
|
||||
case DisplayMixed:
|
||||
ImGui::Columns( 2 );
|
||||
RenderSymbolSourceView( iptotalSrc, ipcountSrc, ipcountAsm, ipmaxSrc, worker );
|
||||
RenderSymbolSourceView( iptotalSrc, ipcountSrc, ipcountAsm, ipmaxSrc, worker, view );
|
||||
ImGui::NextColumn();
|
||||
jumpOut = RenderSymbolAsmView( iptotalAsm, ipcountAsm, ipmaxAsm, worker );
|
||||
jumpOut = RenderSymbolAsmView( iptotalAsm, ipcountAsm, ipmaxAsm, worker, view );
|
||||
ImGui::EndColumns();
|
||||
break;
|
||||
default:
|
||||
@ -582,7 +582,7 @@ void SourceView::RenderSymbolView( const Worker& worker )
|
||||
{
|
||||
auto line = sym->line;
|
||||
auto file = line == 0 ? nullptr : worker.GetString( sym->file );
|
||||
if( file && !SourceFileValid( file, worker.GetCaptureTime() ) )
|
||||
if( file && !SourceFileValid( file, worker.GetCaptureTime(), view ) )
|
||||
{
|
||||
file = nullptr;
|
||||
line = 0;
|
||||
@ -620,7 +620,7 @@ static uint32_t GetHotnessColor( uint32_t ipSum, uint32_t maxIpCount )
|
||||
|
||||
}
|
||||
|
||||
void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, unordered_flat_map<uint64_t, uint32_t> ipcountAsm, uint32_t ipmax, const Worker& worker )
|
||||
void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, unordered_flat_map<uint64_t, uint32_t> ipcountAsm, uint32_t ipmax, const Worker& worker, const View& view )
|
||||
{
|
||||
if( m_sourceFiles.empty() )
|
||||
{
|
||||
@ -661,7 +661,7 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<ui
|
||||
SmallColorBox( color );
|
||||
ImGui::SameLine();
|
||||
auto fstr = worker.GetString( StringIdx( v.first ) );
|
||||
if( SourceFileValid( fstr, worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fstr, worker.GetCaptureTime(), view ) )
|
||||
{
|
||||
ImGui::PushID( v.first );
|
||||
if( ImGui::Selectable( fstr, fstr == m_file ) )
|
||||
@ -740,7 +740,7 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<ui
|
||||
SmallColorBox( color );
|
||||
ImGui::SameLine();
|
||||
auto fstr = worker.GetString( StringIdx( v.first ) );
|
||||
if( SourceFileValid( fstr, worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fstr, worker.GetCaptureTime(), view ) )
|
||||
{
|
||||
ImGui::PushID( v.first );
|
||||
if( ImGui::Selectable( fstr, fstr == m_file, ImGuiSelectableFlags_SpanAllColumns ) )
|
||||
@ -880,7 +880,7 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<ui
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, uint32_t ipmax, const Worker& worker )
|
||||
uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, uint32_t ipmax, const Worker& worker, const View& view )
|
||||
{
|
||||
SmallCheckbox( ICON_FA_SEARCH_LOCATION " Relative locations", &m_asmRelative );
|
||||
if( !m_sourceFiles.empty() )
|
||||
@ -919,7 +919,7 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
|
||||
m_targetAddr = 0;
|
||||
ImGui::SetScrollHereY();
|
||||
}
|
||||
RenderAsmLine( line, 0, iptotal, ipmax, worker, jumpOut, maxAddrLen );
|
||||
RenderAsmLine( line, 0, iptotal, ipmax, worker, jumpOut, maxAddrLen, view );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -936,7 +936,7 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
|
||||
{
|
||||
for( auto i=clipper.DisplayStart; i<clipper.DisplayEnd; i++ )
|
||||
{
|
||||
RenderAsmLine( m_asm[i], 0, 0, 0, worker, jumpOut, maxAddrLen );
|
||||
RenderAsmLine( m_asm[i], 0, 0, 0, worker, jumpOut, maxAddrLen, view );
|
||||
insList.emplace_back( m_asm[i].addr );
|
||||
}
|
||||
}
|
||||
@ -947,7 +947,7 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
|
||||
auto& line = m_asm[i];
|
||||
auto it = ipcount.find( line.addr );
|
||||
const auto ipcnt = it == ipcount.end() ? 0 : it->second;
|
||||
RenderAsmLine( line, ipcnt, iptotal, ipmax, worker, jumpOut, maxAddrLen );
|
||||
RenderAsmLine( line, ipcnt, iptotal, ipmax, worker, jumpOut, maxAddrLen, view );
|
||||
insList.emplace_back( line.addr );
|
||||
}
|
||||
}
|
||||
@ -1279,7 +1279,7 @@ void SourceView::RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint
|
||||
draw->AddLine( wpos + ImVec2( 0, ty+2 ), wpos + ImVec2( w, ty+2 ), 0x08FFFFFF );
|
||||
}
|
||||
|
||||
void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, uint32_t ipmax, const Worker& worker, uint64_t& jumpOut, int maxAddrLen )
|
||||
void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, uint32_t ipmax, const Worker& worker, uint64_t& jumpOut, int maxAddrLen, const View& view )
|
||||
{
|
||||
const auto ty = ImGui::GetFontSize();
|
||||
auto draw = ImGui::GetWindowDrawList();
|
||||
@ -1379,7 +1379,7 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
|
||||
SelectLine( srcline, &worker, false );
|
||||
m_displayMode = DisplayMixed;
|
||||
}
|
||||
else if( SourceFileValid( fileName, worker.GetCaptureTime() ) )
|
||||
else if( SourceFileValid( fileName, worker.GetCaptureTime(), view ) )
|
||||
{
|
||||
ParseSource( fileName, &worker );
|
||||
m_targetLine = srcline;
|
||||
|
@ -12,6 +12,7 @@ struct ImFont;
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
class View;
|
||||
class Worker;
|
||||
|
||||
class SourceView
|
||||
@ -51,7 +52,7 @@ public:
|
||||
|
||||
void OpenSource( const char* fileName, int line );
|
||||
void OpenSymbol( const char* fileName, int line, uint64_t baseAddr, uint64_t symAddr, const Worker& worker );
|
||||
void Render( const Worker& worker );
|
||||
void Render( const Worker& worker, const View& view );
|
||||
|
||||
void CalcInlineStats( bool val ) { m_calcInlineStats = val; }
|
||||
|
||||
@ -60,13 +61,13 @@ private:
|
||||
bool Disassemble( uint64_t symAddr, const Worker& worker );
|
||||
|
||||
void RenderSimpleSourceView();
|
||||
void RenderSymbolView( const Worker& worker );
|
||||
void RenderSymbolView( const Worker& worker, const View& view );
|
||||
|
||||
void RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, unordered_flat_map<uint64_t, uint32_t> ipcountAsm, uint32_t ipmax, const Worker& worker );
|
||||
uint64_t RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, uint32_t ipmax, const Worker& worker );
|
||||
void RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, unordered_flat_map<uint64_t, uint32_t> ipcountAsm, uint32_t ipmax, const Worker& worker, const View& view );
|
||||
uint64_t RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, uint32_t ipmax, const Worker& worker, const View& view );
|
||||
|
||||
void RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint32_t iptotal, uint32_t ipmax, const Worker* worker );
|
||||
void RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, uint32_t ipmax, const Worker& worker, uint64_t& jumpOut, int maxAddrLen );
|
||||
void RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, uint32_t ipmax, const Worker& worker, uint64_t& jumpOut, int maxAddrLen, const View& view );
|
||||
|
||||
void SelectLine( uint32_t line, const Worker* worker, bool changeAsmLine = true, uint64_t targetAddr = 0 );
|
||||
void SelectAsmLines( uint32_t file, uint32_t line, const Worker& worker, bool changeAsmLine = true, uint64_t targetAddr = 0 );
|
||||
|
@ -27,12 +27,10 @@
|
||||
#endif
|
||||
|
||||
#include "tracy_pdqsort.h"
|
||||
#include "TracyBadVersion.hpp"
|
||||
#include "TracyColor.hpp"
|
||||
#include "TracyFileRead.hpp"
|
||||
#include "TracyFileWrite.hpp"
|
||||
#include "TracyFilesystem.hpp"
|
||||
#include "TracyImGui.hpp"
|
||||
#include "TracyPopcnt.hpp"
|
||||
#include "TracyPrint.hpp"
|
||||
#include "TracySort.hpp"
|
||||
@ -215,7 +213,7 @@ bool View::ViewDispatch( const char* fileName, int line, uint64_t symAddr )
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( !SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
fileName = nullptr;
|
||||
line = 0;
|
||||
@ -6264,7 +6262,7 @@ void View::DrawZoneInfoWindow()
|
||||
}
|
||||
}
|
||||
const auto fileName = m_worker.GetString( srcloc.file );
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ImGui::SameLine();
|
||||
bool hilite = m_sourceViewFile == fileName;
|
||||
@ -6795,7 +6793,7 @@ void View::DrawZoneInfoWindow()
|
||||
ImGui::PopID();
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSource( fileName, srcloc.line );
|
||||
}
|
||||
@ -7217,7 +7215,7 @@ void View::DrawGpuInfoWindow()
|
||||
}
|
||||
}
|
||||
const auto fileName = m_worker.GetString( srcloc.file );
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ImGui::SameLine();
|
||||
bool hilite = m_sourceViewFile == fileName;
|
||||
@ -7332,7 +7330,7 @@ void View::DrawGpuInfoWindow()
|
||||
ImGui::PopID();
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSource( fileName, srcloc.line );
|
||||
}
|
||||
@ -7908,7 +7906,7 @@ void View::DrawOptions()
|
||||
ImGui::TextDisabled( "(%s) %s:%i", RealToString( l.second->timeline.size() ), fileName, sl.line );
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSource( fileName, sl.line );
|
||||
}
|
||||
@ -7982,7 +7980,7 @@ void View::DrawOptions()
|
||||
ImGui::TextDisabled( "(%s) %s:%i", RealToString( l.second->timeline.size() ), fileName, sl.line );
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSource( fileName, sl.line );
|
||||
}
|
||||
@ -8056,7 +8054,7 @@ void View::DrawOptions()
|
||||
ImGui::TextDisabled( "(%s) %s:%i", RealToString( l.second->timeline.size() ), fileName, sl.line );
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSource( fileName, sl.line );
|
||||
}
|
||||
@ -8627,7 +8625,7 @@ void View::DrawFindZone()
|
||||
ImGui::TextColored( ImVec4( 0.5, 0.5, 0.5, 1 ), "(%s) %s:%i", RealToString( zones.size() ), fileName, srcloc.line );
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSource( fileName, srcloc.line );
|
||||
}
|
||||
@ -11260,7 +11258,7 @@ void View::DrawStatistics()
|
||||
ImGui::TextDisabled( "%s:%i", file, srcloc.line );
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( file, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( file, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSource( file, srcloc.line );
|
||||
}
|
||||
@ -11625,7 +11623,7 @@ void View::DrawStatistics()
|
||||
}
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( file, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( file, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSymbol( file, line, codeAddr, v.symAddr );
|
||||
if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( false );
|
||||
@ -11783,7 +11781,7 @@ void View::DrawStatistics()
|
||||
}
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( file, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( file, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSymbol( file, line, codeAddr, iv.symAddr );
|
||||
if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( true );
|
||||
@ -13078,7 +13076,7 @@ void View::DrawTextEditor()
|
||||
ImGui::SetNextWindowSize( ImVec2( 700, 800 ), ImGuiCond_FirstUseEver );
|
||||
bool show = true;
|
||||
ImGui::Begin( "Source view", &show, ImGuiWindowFlags_NoScrollbar );
|
||||
m_sourceView->Render( m_worker );
|
||||
m_sourceView->Render( m_worker, *this );
|
||||
ImGui::End();
|
||||
if( !show ) m_sourceViewFile = nullptr;
|
||||
}
|
||||
@ -13205,7 +13203,7 @@ void View::DrawLockInfoWindow()
|
||||
ImGui::Text( "%s:%i", fileName, srcloc.line );
|
||||
if( ImGui::IsItemClicked( 1 ) )
|
||||
{
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
|
||||
if( SourceFileValid( fileName, m_worker.GetCaptureTime(), *this ) )
|
||||
{
|
||||
ViewSource( fileName, srcloc.line );
|
||||
}
|
||||
|
@ -10,8 +10,10 @@
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
|
||||
#include "TracyBadVersion.hpp"
|
||||
#include "TracyBuzzAnim.hpp"
|
||||
#include "TracyDecayValue.hpp"
|
||||
#include "TracyImGui.hpp"
|
||||
#include "TracyShortPtr.hpp"
|
||||
#include "TracyTexture.hpp"
|
||||
#include "TracyUserData.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user