From 8adfd45453709524b35441335ff3a575607da9fe Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 6 Oct 2020 14:50:55 +0200 Subject: [PATCH] Display failure callstack in capture utility. --- capture/build/win32/capture.vcxproj | 2 + capture/build/win32/capture.vcxproj.filters | 6 ++ capture/src/capture.cpp | 71 +++++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/capture/build/win32/capture.vcxproj b/capture/build/win32/capture.vcxproj index 2a9230b3..58616ca3 100644 --- a/capture/build/win32/capture.vcxproj +++ b/capture/build/win32/capture.vcxproj @@ -142,6 +142,7 @@ + @@ -194,6 +195,7 @@ + diff --git a/capture/build/win32/capture.vcxproj.filters b/capture/build/win32/capture.vcxproj.filters index 8b0cc276..e90842af 100644 --- a/capture/build/win32/capture.vcxproj.filters +++ b/capture/build/win32/capture.vcxproj.filters @@ -132,6 +132,9 @@ getopt + + server + @@ -296,5 +299,8 @@ getopt + + server + \ No newline at end of file diff --git a/capture/src/capture.cpp b/capture/src/capture.cpp index 5b4bf436..c2122dec 100644 --- a/capture/src/capture.cpp +++ b/capture/src/capture.cpp @@ -17,6 +17,7 @@ #include "../../server/TracyFileWrite.hpp" #include "../../server/TracyMemory.hpp" #include "../../server/TracyPrint.hpp" +#include "../../server/TracyStackFrames.hpp" #include "../../server/TracyWorker.hpp" #include "../../getopt/getopt.h" @@ -165,6 +166,76 @@ int main( int argc, char** argv ) if( failure != tracy::Worker::Failure::None ) { printf( "\n\033[31;1mInstrumentation failure: %s\033[0m", tracy::Worker::GetFailureString( failure ) ); + auto& fd = worker.GetFailureData(); + if( fd.callstack != 0 ) + { + printf( "\n\033[1mFailure callstack:\033[0m\n" ); + auto& cs = worker.GetCallstack( fd.callstack ); + int fidx = 0; + int bidx = 0; + for( auto& entry : cs ) + { + auto frameData = worker.GetCallstackFrame( entry ); + if( !frameData ) + { + printf( "%3i. %p\n", fidx++, (void*)worker.GetCanonicalPointer( entry ) ); + } + else + { + const auto fsz = frameData->size; + for( uint8_t f=0; fdata[f]; + auto txt = worker.GetString( frame.name ); + + if( fidx == 0 && f != fsz-1 ) + { + auto test = tracy::s_tracyStackFrames; + bool match = false; + do + { + if( strcmp( txt, *test ) == 0 ) + { + match = true; + break; + } + } + while( *++test ); + if( match ) continue; + } + + bidx++; + + if( f == fsz-1 ) + { + printf( "%3i. ", fidx++ ); + } + else + { + printf( "\033[30;1minl. " ); + } + printf( "\033[0;36m%s ", txt ); + txt = worker.GetString( frame.file ); + if( frame.line == 0 ) + { + printf( "\033[33m(%s)", txt ); + } + else + { + printf( "\033[33m(%s:%" PRIu32 ")", txt, frame.line ); + } + if( frameData->imageName.Active() ) + { + printf( "\033[35m %s\033[0m\n", worker.GetString( frameData->imageName ) ); + } + else + { + printf( "\033[0m\n" ); + } + } + } + } + } } printf( "\nFrames: %" PRIu64 "\nTime span: %s\nZones: %s\nElapsed time: %s\nSaving trace...",