Add logging of the functions used in the coroutine implemntation

This commit is contained in:
Ian McInerney 2021-04-16 17:49:20 +01:00
parent e7798d8f23
commit 43425d7306
3 changed files with 32 additions and 0 deletions

View File

@ -34,6 +34,7 @@ const wxChar* const traceFindReplace = wxT( "KICAD_FIND_REPLACE" );
const wxChar* const kicadTraceCoords = wxT( "KICAD_COORDS" );
const wxChar* const kicadTraceKeyEvent = wxT( "KICAD_KEY_EVENTS" );
const wxChar* const kicadTraceToolStack = wxT( "KICAD_TOOL_STACK" );
const wxChar* const kicadTraceCoroutineStack = wxT( "KICAD_COROUTINE_STACK" );
const wxChar* const traceSchLibMem = wxT( "KICAD_SCH_LIB_MEM" );
const wxChar* const traceFindItem = wxT( "KICAD_FIND_ITEM" );
const wxChar* const traceSchLegacyPlugin = wxT( "KICAD_SCH_LEGACY_PLUGIN" );

View File

@ -46,6 +46,9 @@
#include <memory>
#include <advanced_config.h>
#include <trace_helpers.h>
#include <wx/log.h>
/**
* Implement a coroutine.
*
@ -267,6 +270,9 @@ public:
m_caller.tsan_fiber = __tsan_get_current_fiber();
m_caller.own_tsan_fiber = false;
#endif
wxLogTrace( kicadTraceCoroutineStack, "COROUTINE::Call (from root)" );
ctx.Continue( doCall( &args, aArg ) );
return Running();
@ -283,6 +289,9 @@ public:
bool Call( const COROUTINE& aCor, ArgType aArg )
{
INVOCATION_ARGS args{ INVOCATION_ARGS::FROM_ROUTINE, this, aCor.m_callContext };
wxLogTrace( kicadTraceCoroutineStack, "COROUTINE::Call (from routine)" );
doCall( &args, aArg );
// we will not be asked to continue
@ -307,6 +316,9 @@ public:
m_caller.tsan_fiber = __tsan_get_current_fiber();
m_caller.own_tsan_fiber = false;
#endif
wxLogTrace( kicadTraceCoroutineStack, "COROUTINE::Resume (from root)" );
ctx.Continue( doResume( &args ) );
return Running();
@ -323,6 +335,9 @@ public:
bool Resume( const COROUTINE& aCor )
{
INVOCATION_ARGS args{ INVOCATION_ARGS::FROM_ROUTINE, this, aCor.m_callContext };
wxLogTrace( kicadTraceCoroutineStack, "COROUTINE::Resume (from routine)" );
doResume( &args );
// we will not be asked to continue
@ -379,6 +394,9 @@ private:
m_callee.tsan_fiber = __tsan_create_fiber( 0 );
m_callee.own_tsan_fiber = true;
#endif
wxLogTrace( kicadTraceCoroutineStack, "COROUTINE::doCall" );
m_callee.ctx = libcontext::make_fcontext( sp, stackSize, callerStub );
m_running = true;
@ -417,6 +435,9 @@ private:
// Tell TSAN we are changing fibers to the callee
__tsan_switch_to_fiber( m_callee.tsan_fiber, 0 );
#endif
wxLogTrace( kicadTraceCoroutineStack, "COROUTINE::jumpIn" );
args = reinterpret_cast<INVOCATION_ARGS*>(
libcontext::jump_fcontext( &( m_caller.ctx ), m_callee.ctx,
reinterpret_cast<intptr_t>( args ) )
@ -434,6 +455,9 @@ private:
// Tell TSAN we are changing fibers back to the caller
__tsan_switch_to_fiber( m_caller.tsan_fiber, 0 );
#endif
wxLogTrace( kicadTraceCoroutineStack, "COROUTINE::jumpOut" );
ret = reinterpret_cast<INVOCATION_ARGS*>(
libcontext::jump_fcontext( &( m_callee.ctx ), m_caller.ctx,
reinterpret_cast<intptr_t>( &args ) )

View File

@ -82,6 +82,13 @@ extern const wxChar* const kicadTraceKeyEvent;
*/
extern const wxChar* const kicadTraceToolStack;
/**
* Flag to enable tracing of the coroutine call stack.
*
* Use "KICAD_COROUTINE_STACK" to enable.
*/
extern const wxChar* const kicadTraceCoroutineStack;
/**
* Flag to enable auto save feature debug tracing.
*