Pass symbol address to source view.

This commit is contained in:
Bartosz Taudul 2020-03-25 00:07:31 +01:00
parent 1999352004
commit 4c92a2619f
4 changed files with 29 additions and 26 deletions

View File

@ -12,6 +12,7 @@ namespace tracy
SourceView::SourceView( ImFont* font ) SourceView::SourceView( ImFont* font )
: m_font( font ) : m_font( font )
, m_file( nullptr ) , m_file( nullptr )
, m_symAddr( 0 )
, m_data( nullptr ) , m_data( nullptr )
, m_dataSize( 0 ) , m_dataSize( 0 )
, m_targetLine( 0 ) , m_targetLine( 0 )
@ -24,10 +25,11 @@ SourceView::~SourceView()
delete[] m_data; delete[] m_data;
} }
void SourceView::Open( const char* fileName, int line ) void SourceView::Open( const char* fileName, int line, uint64_t symAddr )
{ {
m_targetLine = line; m_targetLine = line;
m_selectedLine = line; m_selectedLine = line;
m_symAddr = symAddr;
if( m_file != fileName ) if( m_file != fileName )
{ {

View File

@ -17,7 +17,7 @@ public:
SourceView( ImFont* font ); SourceView( ImFont* font );
~SourceView(); ~SourceView();
void Open( const char* fileName, int line ); void Open( const char* fileName, int line, uint64_t symAddr );
void Render(); void Render();
private: private:
@ -25,6 +25,7 @@ private:
ImFont* m_font; ImFont* m_font;
const char* m_file; const char* m_file;
uint64_t m_symAddr;
char* m_data; char* m_data;
size_t m_dataSize; size_t m_dataSize;
int m_targetLine; int m_targetLine;

View File

@ -193,10 +193,10 @@ void View::InitTextEditor( ImFont* font )
m_sourceViewFile = nullptr; m_sourceViewFile = nullptr;
} }
void View::SetTextEditorFile( const char* fileName, int line ) void View::SetTextEditorFile( const char* fileName, int line, uint64_t symAddr )
{ {
m_sourceViewFile = fileName; m_sourceViewFile = fileName;
m_sourceView->Open( fileName, line ); m_sourceView->Open( fileName, line, symAddr );
} }
const char* View::ShortenNamespace( const char* name ) const const char* View::ShortenNamespace( const char* name ) const
@ -3596,7 +3596,7 @@ int View::DrawGhostLevel( const Vector<GhostZone>& vec, bool hover, double pxns,
{ {
if( line != 0 ) if( line != 0 )
{ {
SetTextEditorFile( file, line ); SetTextEditorFile( file, line, frame->data[i].symAddr );
} }
} }
else if( !m_zoomAnim.active && ImGui::IsMouseClicked( 2 ) ) else if( !m_zoomAnim.active && ImGui::IsMouseClicked( 2 ) )
@ -6103,7 +6103,7 @@ void DrawZoneTrace( T zone, const std::vector<T>& trace, const Worker& worker, B
{ {
if( frame->line != 0 && SourceFileValid( fileName, worker.GetCaptureTime() ) ) if( frame->line != 0 && SourceFileValid( fileName, worker.GetCaptureTime() ) )
{ {
view.SetTextEditorFile( fileName, frame->line ); view.SetTextEditorFile( fileName, frame->line, 0 );
} }
else else
{ {
@ -6165,7 +6165,7 @@ void DrawZoneTrace( T zone, const std::vector<T>& trace, const Worker& worker, B
{ {
if( frame->line != 0 && SourceFileValid( fileName, worker.GetCaptureTime() ) ) if( frame->line != 0 && SourceFileValid( fileName, worker.GetCaptureTime() ) )
{ {
view.SetTextEditorFile( fileName, frame->line ); view.SetTextEditorFile( fileName, frame->line, 0 );
} }
else else
{ {
@ -6363,7 +6363,7 @@ void View::DrawZoneInfoWindow()
if( ImGui::Button( "Source" ) ) if( ImGui::Button( "Source" ) )
#endif #endif
{ {
SetTextEditorFile( fileName, srcloc.line ); SetTextEditorFile( fileName, srcloc.line, 0 );
} }
if( hilite ) if( hilite )
{ {
@ -6894,7 +6894,7 @@ void View::DrawZoneInfoWindow()
{ {
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) ) if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( fileName, srcloc.line ); SetTextEditorFile( fileName, srcloc.line, 0 );
} }
else else
{ {
@ -7340,7 +7340,7 @@ void View::DrawGpuInfoWindow()
if( ImGui::Button( "Source" ) ) if( ImGui::Button( "Source" ) )
#endif #endif
{ {
SetTextEditorFile( fileName, srcloc.line ); SetTextEditorFile( fileName, srcloc.line, 0 );
} }
if( hilite ) if( hilite )
{ {
@ -7451,7 +7451,7 @@ void View::DrawGpuInfoWindow()
{ {
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) ) if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( fileName, srcloc.line ); SetTextEditorFile( fileName, srcloc.line, 0 );
} }
else else
{ {
@ -8079,7 +8079,7 @@ void View::DrawOptions()
{ {
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) ) if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( fileName, sl.line ); SetTextEditorFile( fileName, sl.line, 0 );
} }
else else
{ {
@ -8153,7 +8153,7 @@ void View::DrawOptions()
{ {
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) ) if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( fileName, sl.line ); SetTextEditorFile( fileName, sl.line, 0 );
} }
else else
{ {
@ -8227,7 +8227,7 @@ void View::DrawOptions()
{ {
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) ) if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( fileName, sl.line ); SetTextEditorFile( fileName, sl.line, 0 );
} }
else else
{ {
@ -8854,7 +8854,7 @@ void View::DrawFindZone()
{ {
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) ) if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( fileName, srcloc.line ); SetTextEditorFile( fileName, srcloc.line, 0 );
} }
else else
{ {
@ -11560,7 +11560,7 @@ void View::DrawStatistics()
{ {
if( SourceFileValid( file, m_worker.GetCaptureTime() ) ) if( SourceFileValid( file, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( file, srcloc.line ); SetTextEditorFile( file, srcloc.line, 0 );
} }
else else
{ {
@ -11779,7 +11779,7 @@ void View::DrawStatistics()
{ {
if( SourceFileValid( file, m_worker.GetCaptureTime() ) ) if( SourceFileValid( file, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( file, line ); SetTextEditorFile( file, line, v->first );
} }
else else
{ {
@ -12058,7 +12058,7 @@ void View::DrawCallstackWindow()
const auto symtxt = m_worker.GetString( sym->file ); const auto symtxt = m_worker.GetString( sym->file );
if( SourceFileValid( symtxt, m_worker.GetCaptureTime() ) ) if( SourceFileValid( symtxt, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( symtxt, sym->line ); SetTextEditorFile( symtxt, sym->line, frame.symAddr );
} }
else else
{ {
@ -12074,7 +12074,7 @@ void View::DrawCallstackWindow()
{ {
if( SourceFileValid( txt, m_worker.GetCaptureTime() ) ) if( SourceFileValid( txt, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( txt, frame.line ); SetTextEditorFile( txt, frame.line, frame.symAddr );
} }
else else
{ {
@ -13181,7 +13181,7 @@ void View::DrawLockInfoWindow()
{ {
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) ) if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( fileName, srcloc.line ); SetTextEditorFile( fileName, srcloc.line, 0 );
} }
else else
{ {
@ -13790,7 +13790,7 @@ void View::DrawSampleParents()
{ {
if( SourceFileValid( callFile, m_worker.GetCaptureTime() ) ) if( SourceFileValid( callFile, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( callFile, symbol->callLine ); SetTextEditorFile( callFile, symbol->callLine, m_sampleParents.symAddr );
} }
} }
TextDisabledUnformatted( "Entry point:" ); TextDisabledUnformatted( "Entry point:" );
@ -13808,7 +13808,7 @@ void View::DrawSampleParents()
{ {
if( SourceFileValid( file, m_worker.GetCaptureTime() ) ) if( SourceFileValid( file, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( file, symbol->line ); SetTextEditorFile( file, symbol->line, m_sampleParents.symAddr );
} }
} }
ImGui::SameLine(); ImGui::SameLine();
@ -14033,7 +14033,7 @@ void View::DrawSampleParents()
const auto symtxt = m_worker.GetString( sym->file ); const auto symtxt = m_worker.GetString( sym->file );
if( SourceFileValid( symtxt, m_worker.GetCaptureTime() ) ) if( SourceFileValid( symtxt, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( symtxt, sym->line ); SetTextEditorFile( symtxt, sym->line, 0 );
} }
else else
{ {
@ -14049,7 +14049,7 @@ void View::DrawSampleParents()
{ {
if( SourceFileValid( txt, m_worker.GetCaptureTime() ) ) if( SourceFileValid( txt, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( txt, frame.line ); SetTextEditorFile( txt, frame.line, 0 );
} }
else else
{ {
@ -15058,7 +15058,7 @@ void View::DrawFrameTreeLevel( const unordered_flat_map<uint64_t, CallstackFrame
{ {
if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) ) if( SourceFileValid( fileName, m_worker.GetCaptureTime() ) )
{ {
SetTextEditorFile( fileName, frame.line ); SetTextEditorFile( fileName, frame.line, 0 );
} }
else else
{ {

View File

@ -80,7 +80,7 @@ public:
static bool Draw(); static bool Draw();
void NotifyRootWindowSize( float w, float h ) { m_rootWidth = w; m_rootHeight = h; } void NotifyRootWindowSize( float w, float h ) { m_rootWidth = w; m_rootHeight = h; }
void SetTextEditorFile( const char* fileName, int line ); void SetTextEditorFile( const char* fileName, int line, uint64_t symAddr );
bool ReconnectRequested() const { return m_reconnectRequested; } bool ReconnectRequested() const { return m_reconnectRequested; }
std::string GetAddress() const { return m_worker.GetAddr(); } std::string GetAddress() const { return m_worker.GetAddr(); }