mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Make source location display optional.
This commit is contained in:
parent
39cb9f4a32
commit
d3c278cb02
@ -30,6 +30,7 @@ SourceView::SourceView( ImFont* font )
|
|||||||
, m_codeLen( 0 )
|
, m_codeLen( 0 )
|
||||||
, m_highlightAddr( 0 )
|
, m_highlightAddr( 0 )
|
||||||
, m_asmRelative( false )
|
, m_asmRelative( false )
|
||||||
|
, m_asmShowSourceLocation( true )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,6 +292,10 @@ void SourceView::Render( const Worker& worker )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SmallCheckbox( ICON_FA_SEARCH_LOCATION " Relative locations", &m_asmRelative );
|
SmallCheckbox( ICON_FA_SEARCH_LOCATION " Relative locations", &m_asmRelative );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::SameLine();
|
||||||
|
SmallCheckbox( ICON_FA_FILE_IMPORT " Show source locations", &m_asmShowSourceLocation );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t jumpOut = 0;
|
uint64_t jumpOut = 0;
|
||||||
@ -499,53 +504,56 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
|
|||||||
buf[16] = '\0';
|
buf[16] = '\0';
|
||||||
TextDisabledUnformatted( buf );
|
TextDisabledUnformatted( buf );
|
||||||
|
|
||||||
const auto stw = ImGui::CalcTextSize( " " ).x;
|
if( m_asmShowSourceLocation )
|
||||||
ImGui::SameLine();
|
|
||||||
uint32_t srcline;
|
|
||||||
const auto srcidx = worker.GetLocationForAddress( line.addr, srcline );
|
|
||||||
if( srcline != 0 )
|
|
||||||
{
|
{
|
||||||
const auto fileName = worker.GetString( srcidx );
|
const auto stw = ImGui::CalcTextSize( " " ).x;
|
||||||
const auto fileColor = GetHsvColor( srcidx.Idx(), 0 );
|
|
||||||
SmallColorBox( fileColor );
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
const auto lineString = RealToString( srcline );
|
uint32_t srcline;
|
||||||
const auto linesz = strlen( lineString );
|
const auto srcidx = worker.GetLocationForAddress( line.addr, srcline );
|
||||||
char buf[32];
|
if( srcline != 0 )
|
||||||
const auto fnsz = strlen( fileName );
|
|
||||||
if( fnsz < 32 - 8 )
|
|
||||||
{
|
{
|
||||||
sprintf( buf, "%s:%i", fileName, srcline );
|
const auto fileName = worker.GetString( srcidx );
|
||||||
|
const auto fileColor = GetHsvColor( srcidx.Idx(), 0 );
|
||||||
|
SmallColorBox( fileColor );
|
||||||
|
ImGui::SameLine();
|
||||||
|
const auto lineString = RealToString( srcline );
|
||||||
|
const auto linesz = strlen( lineString );
|
||||||
|
char buf[32];
|
||||||
|
const auto fnsz = strlen( fileName );
|
||||||
|
if( fnsz < 32 - 8 )
|
||||||
|
{
|
||||||
|
sprintf( buf, "%s:%i", fileName, srcline );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf( buf, "...%s:%i", fileName+fnsz-(32-3-1-8), srcline );
|
||||||
|
}
|
||||||
|
const auto bufsz = strlen( buf );
|
||||||
|
TextDisabledUnformatted( buf );
|
||||||
|
if( ImGui::IsItemHovered() )
|
||||||
|
{
|
||||||
|
if( m_font ) ImGui::PopFont();
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
ImGui::Text( "%s:%i", fileName, srcline );
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
if( m_font ) ImGui::PushFont( m_font );
|
||||||
|
if( !m_lines.empty() && m_file == fileName && ImGui::IsItemClicked() )
|
||||||
|
{
|
||||||
|
m_currentAddr = line.addr;
|
||||||
|
m_targetLine = srcline;
|
||||||
|
m_selectedLine = srcline;
|
||||||
|
m_showAsm = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::SameLine( 0, 0 );
|
||||||
|
ImGui::ItemSize( ImVec2( stw * ( 32 - bufsz ), ty ), 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf( buf, "...%s:%i", fileName+fnsz-(32-3-1-8), srcline );
|
SmallColorBox( 0 );
|
||||||
|
ImGui::SameLine( 0, 0 );
|
||||||
|
ImGui::ItemSize( ImVec2( stw * 32, ty ), 0 );
|
||||||
}
|
}
|
||||||
const auto bufsz = strlen( buf );
|
|
||||||
TextDisabledUnformatted( buf );
|
|
||||||
if( ImGui::IsItemHovered() )
|
|
||||||
{
|
|
||||||
if( m_font ) ImGui::PopFont();
|
|
||||||
ImGui::BeginTooltip();
|
|
||||||
ImGui::Text( "%s:%i", fileName, srcline );
|
|
||||||
ImGui::EndTooltip();
|
|
||||||
if( m_font ) ImGui::PushFont( m_font );
|
|
||||||
if( !m_lines.empty() && m_file == fileName && ImGui::IsItemClicked() )
|
|
||||||
{
|
|
||||||
m_currentAddr = line.addr;
|
|
||||||
m_targetLine = srcline;
|
|
||||||
m_selectedLine = srcline;
|
|
||||||
m_showAsm = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::SameLine( 0, 0 );
|
|
||||||
ImGui::ItemSize( ImVec2( stw * ( 32 - bufsz ), ty ), 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SmallColorBox( 0 );
|
|
||||||
ImGui::SameLine( 0, 0 );
|
|
||||||
ImGui::ItemSize( ImVec2( stw * 32, ty ), 0 );
|
|
||||||
}
|
}
|
||||||
ImGui::SameLine( 0, ty );
|
ImGui::SameLine( 0, ty );
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ private:
|
|||||||
uint32_t m_codeLen;
|
uint32_t m_codeLen;
|
||||||
DecayValue<uint64_t> m_highlightAddr;
|
DecayValue<uint64_t> m_highlightAddr;
|
||||||
bool m_asmRelative;
|
bool m_asmRelative;
|
||||||
|
bool m_asmShowSourceLocation;
|
||||||
|
|
||||||
std::vector<Line> m_lines;
|
std::vector<Line> m_lines;
|
||||||
std::vector<AsmLine> m_asm;
|
std::vector<AsmLine> m_asm;
|
||||||
|
Loading…
Reference in New Issue
Block a user