mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 01:04:36 +00:00
Fix crash when trying to open unavailable source file.
This commit is contained in:
parent
ce1c744de9
commit
8e9a701277
@ -415,6 +415,11 @@ void SourceView::OpenSymbol( const char* fileName, int line, uint64_t baseAddr,
|
|||||||
Disassemble( baseAddr, worker );
|
Disassemble( baseAddr, worker );
|
||||||
SelectLine( line, &worker, true, symAddr );
|
SelectLine( line, &worker, true, symAddr );
|
||||||
|
|
||||||
|
SelectViewMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SourceView::SelectViewMode()
|
||||||
|
{
|
||||||
if( !m_lines.empty() )
|
if( !m_lines.empty() )
|
||||||
{
|
{
|
||||||
if( !m_asm.empty() )
|
if( !m_asm.empty() )
|
||||||
@ -453,7 +458,8 @@ void SourceView::ParseSource( const char* fileName, const Worker& worker, const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE* f = fopen( view.SourceSubstitution( fileName ), "rb" );
|
FILE* f = fopen( view.SourceSubstitution( fileName ), "rb" );
|
||||||
assert( f );
|
if( f )
|
||||||
|
{
|
||||||
fseek( f, 0, SEEK_END );
|
fseek( f, 0, SEEK_END );
|
||||||
sz = ftell( f );
|
sz = ftell( f );
|
||||||
fseek( f, 0, SEEK_SET );
|
fseek( f, 0, SEEK_SET );
|
||||||
@ -467,7 +473,14 @@ void SourceView::ParseSource( const char* fileName, const Worker& worker, const
|
|||||||
m_data = m_dataBuf;
|
m_data = m_dataBuf;
|
||||||
fclose( f );
|
fclose( f );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_file = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_file )
|
||||||
|
{
|
||||||
m_tokenizer.Reset();
|
m_tokenizer.Reset();
|
||||||
auto txt = m_data;
|
auto txt = m_data;
|
||||||
for(;;)
|
for(;;)
|
||||||
@ -490,6 +503,7 @@ void SourceView::ParseSource( const char* fileName, const Worker& worker, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsJumpConditionalX86( const char* op )
|
static bool IsJumpConditionalX86( const char* op )
|
||||||
@ -1093,6 +1107,7 @@ void SourceView::RenderSymbolView( const Worker& worker, View& view )
|
|||||||
ParseSource( file, worker, view );
|
ParseSource( file, worker, view );
|
||||||
m_targetLine = line;
|
m_targetLine = line;
|
||||||
SelectLine( line, &worker, true );
|
SelectLine( line, &worker, true );
|
||||||
|
SelectViewMode();
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
@ -2552,7 +2567,7 @@ void SourceView::RenderAsmLine( AsmLine& line, uint32_t ipcnt, uint32_t iptotal,
|
|||||||
ParseSource( fileName, worker, view );
|
ParseSource( fileName, worker, view );
|
||||||
m_targetLine = srcline;
|
m_targetLine = srcline;
|
||||||
SelectLine( srcline, &worker, false );
|
SelectLine( srcline, &worker, false );
|
||||||
m_displayMode = DisplayMixed;
|
SelectViewMode();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -145,6 +145,8 @@ private:
|
|||||||
void ParseSource( const char* fileName, const Worker& worker, const View& view );
|
void ParseSource( const char* fileName, const Worker& worker, const View& view );
|
||||||
bool Disassemble( uint64_t symAddr, const Worker& worker );
|
bool Disassemble( uint64_t symAddr, const Worker& worker );
|
||||||
|
|
||||||
|
void SelectViewMode();
|
||||||
|
|
||||||
void RenderSimpleSourceView();
|
void RenderSimpleSourceView();
|
||||||
void RenderSymbolView( const Worker& worker, View& view );
|
void RenderSymbolView( const Worker& worker, View& view );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user