From 02c99fca67fac6579ea96066ec0345ed97d88a19 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 26 Feb 2020 19:01:21 +0100 Subject: [PATCH] Enable display of symbol address in callstack window. --- server/TracyView.cpp | 54 +++++++++++++++++++++++++++++++++----------- server/TracyView.hpp | 2 +- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 26e84ffa..21745d68 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -11121,10 +11121,18 @@ void View::DrawCallstackWindow() ImGui::Begin( "Call stack", &show, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse ); #ifdef TRACY_EXTENDED_FONT - ImGui::Checkbox( ICON_FA_AT " Show frame addresses", &m_showCallstackFrameAddress ); + ImGui::TextUnformatted( ICON_FA_AT " Frame location:" ); #else - ImGui::Checkbox( "Show frame addresses", &m_showCallstackFrameAddress ); + ImGui::Checkbox( "Frame location:" ); #endif + ImGui::SameLine(); + ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); + ImGui::RadioButton( "Source code", &m_showCallstackFrameAddress, 0 ); + ImGui::SameLine(); + ImGui::RadioButton( "Return address", &m_showCallstackFrameAddress, 1 ); + ImGui::SameLine(); + ImGui::RadioButton( "Symbol address", &m_showCallstackFrameAddress, 2 ); + ImGui::PopStyleVar(); auto& cs = m_worker.GetCallstack( m_callstackInfoWindow ); @@ -11238,8 +11246,23 @@ void View::DrawCallstackWindow() ImGui::Indent( indentVal ); } txt = m_worker.GetString( frame.file ); - if( m_showCallstackFrameAddress ) + switch( m_showCallstackFrameAddress ) { + case 0: + if( frame.line == 0 ) + { + TextDisabledUnformatted( txt ); + } + else + { + ImGui::TextDisabled( "%s:%i", txt, frame.line ); + } + if( ImGui::IsItemClicked() ) + { + ImGui::SetClipboardText( txt ); + } + break; + case 1: if( entry.sel == 0 ) { const auto addr = m_worker.GetCanonicalPointer( entry ); @@ -11255,21 +11278,26 @@ void View::DrawCallstackWindow() { ImGui::TextDisabled( "Custom #%" PRIu64, entry.idx ); } - } - else - { - if( frame.line == 0 ) + break; + case 2: + if( entry.sel == 0 ) { - TextDisabledUnformatted( txt ); + ImGui::TextDisabled( "0x%" PRIx64, frame.symAddr ); + if( ImGui::IsItemClicked() ) + { + char tmp[32]; + sprintf( tmp, "0x%" PRIx64, frame.symAddr ); + ImGui::SetClipboardText( tmp ); + } } else { - ImGui::TextDisabled( "%s:%i", txt, frame.line ); - } - if( ImGui::IsItemClicked() ) - { - ImGui::SetClipboardText( txt ); + ImGui::TextDisabled( "Custom #%" PRIu64, entry.idx ); } + break; + default: + assert( false ); + break; } if( ImGui::IsItemClicked( 1 ) ) { diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 0c1d1152..9e9fcb61 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -343,7 +343,7 @@ private: int m_statSort = 0; bool m_statSelf = false; - bool m_showCallstackFrameAddress = false; + int m_showCallstackFrameAddress = 0; bool m_showUnknownFrames = true; bool m_groupChildrenLocations = false; bool m_allocTimeRelativeToZone = true;