Store failure reason strings in Worker.

This commit is contained in:
Bartosz Taudul 2019-01-15 18:42:15 +01:00
parent 3cd97138fc
commit 9944a73444
4 changed files with 16 additions and 21 deletions

View File

@ -182,17 +182,7 @@ int main( int argc, char** argv )
const auto& failure = worker.GetFailureType(); const auto& failure = worker.GetFailureType();
if( failure != tracy::Worker::Failure::None ) if( failure != tracy::Worker::Failure::None )
{ {
printf( "\n\033[31;1mInstrumentation failure: " ); printf( "\n\033[31;1mInstrumentation failure: %s\033[0m", tracy::Worker::GetFailureString( failure ) );
switch( failure )
{
case tracy::Worker::Failure::ZoneStack:
printf( "Invalid order of zone begin and end events." );
break;
default:
printf( "<unknown reason>" );
break;
}
printf( "\033[0m" );
} }
printf( "\nFrames: %" PRIu64 "\nTime span: %s\nZones: %s\nSaving trace...", worker.GetFrameCount( *worker.GetFramesBase() ), TimeToString( worker.GetLastTime() - worker.GetTimeBegin() ), RealToString( worker.GetZoneCount(), true ) ); printf( "\nFrames: %" PRIu64 "\nTime span: %s\nZones: %s\nSaving trace...", worker.GetFrameCount( *worker.GetFramesBase() ), TimeToString( worker.GetLastTime() - worker.GetTimeBegin() ), RealToString( worker.GetZoneCount(), true ) );

View File

@ -469,15 +469,7 @@ bool View::Draw()
ImGui::Text( "Profiling session terminated due to improper instrumentation.\nPlease correct your program and try again." ); ImGui::Text( "Profiling session terminated due to improper instrumentation.\nPlease correct your program and try again." );
ImGui::Text( "Reason:" ); ImGui::Text( "Reason:" );
ImGui::SameLine(); ImGui::SameLine();
switch( failure ) ImGui::Text( "%s", Worker::GetFailureString( failure ) );
{
case Worker::Failure::ZoneStack:
ImGui::Text( "Invalid order of zone begin and end events." );
break;
default:
assert( false );
break;
}
ImGui::Separator(); ImGui::Separator();
if( srcloc.name.active ) if( srcloc.name.active )
{ {

View File

@ -3645,4 +3645,14 @@ void Worker::WriteTimeline( FileWrite& f, const Vector<GpuEvent*>& vec, int64_t&
} }
} }
static const char* s_failureReasons[] = {
"<unknown reason>",
"Invalid order of zone begin and end events."
};
const char* Worker::GetFailureString( Worker::Failure failure )
{
return s_failureReasons[(int)failure];
}
} }

View File

@ -180,7 +180,9 @@ public:
enum class Failure enum class Failure
{ {
None, None,
ZoneStack ZoneStack,
NUM_FAILURES
}; };
Worker( const char* addr ); Worker( const char* addr );
@ -284,6 +286,7 @@ public:
void ClearFailure() { m_failure = Failure::None; } void ClearFailure() { m_failure = Failure::None; }
Failure GetFailureType() const { return m_failure; } Failure GetFailureType() const { return m_failure; }
const FailureData& GetFailureData() const { return m_failureData; } const FailureData& GetFailureData() const { return m_failureData; }
static const char* GetFailureString( Failure failure );
private: private:
void Exec(); void Exec();