Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework CLR reboot #1183

Merged
merged 1 commit into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/CLR/Core/Execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ HRESULT CLR_RT_ExecutionEngine::DeleteInstance()

void CLR_RT_ExecutionEngine::ExecutionEngine_Cleanup()
{
/////////////////////////////////////////////////////////////////////////////////////////////////
// developer notes:
// Most of the following calls are just for pure ceremony and gracefully terminating stuff,
// cleaning collections and such.
// In particular the previous existing calls to Abort threads were completely irrelevant
// because the execution engine wasn't running anymore so whatever code that is on those threads
// there to be executed wouldn't never be executed anyways.
/////////////////////////////////////////////////////////////////////////////////////////////////

NATIVE_PROFILE_CLR_CORE();
m_fShuttingDown = true;

Expand All @@ -228,9 +237,6 @@ void CLR_RT_ExecutionEngine::ExecutionEngine_Cleanup()

m_timerThread = NULL;

AbortAllThreads ( m_threadsReady );
AbortAllThreads ( m_threadsWaiting );

ReleaseAllThreads( m_threadsReady );
ReleaseAllThreads( m_threadsWaiting );
ReleaseAllThreads( m_threadsZombie );
Expand Down
1 change: 0 additions & 1 deletion src/CLR/Include/nanoCLR_Debugging.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ struct CLR_DBG_Commands
static const unsigned int c_EnterBootloader = 1;
static const unsigned int c_ClrOnly = 2;
static const unsigned int c_WaitForDebugger = 4;
static const unsigned int c_NoShutdown = 8;

unsigned int m_flags;
};
Expand Down
14 changes: 9 additions & 5 deletions targets/CMSIS-OS/ChibiOS/nanoCLR/CLRStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,15 @@ struct Settings

void Cleanup()
{
if(!CLR_EE_REBOOT_IS(NoShutdown))
{
// OK to delete execution engine
CLR_RT_ExecutionEngine::DeleteInstance();
}
CLR_RT_ExecutionEngine::DeleteInstance();

memset( &g_CLR_RT_ExecutionEngine, 0, sizeof(g_CLR_RT_ExecutionEngine));
memset( &g_CLR_RT_WellKnownTypes, 0, sizeof(g_CLR_RT_WellKnownTypes));
memset( &g_CLR_RT_WellKnownMethods, 0, sizeof(g_CLR_RT_WellKnownMethods));
memset( &g_CLR_RT_TypeSystem, 0, sizeof(g_CLR_RT_TypeSystem));
memset( &g_CLR_RT_EventCache, 0, sizeof(g_CLR_RT_EventCache));
memset( &g_CLR_RT_GarbageCollector, 0, sizeof(g_CLR_RT_GarbageCollector));
memset( &g_CLR_HW_Hardware, 0, sizeof(g_CLR_HW_Hardware));

m_fInitialized = false;
}
Expand Down
14 changes: 9 additions & 5 deletions targets/FreeRTOS/ESP32_DevKitC/nanoCLR/CLRStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,15 @@ struct Settings

void Cleanup()
{
if(!CLR_EE_REBOOT_IS(NoShutdown))
{
// OK to delete execution engine
CLR_RT_ExecutionEngine::DeleteInstance();
}
CLR_RT_ExecutionEngine::DeleteInstance();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanoframework/esp32-developers this call seems to be preventing a debug session from starting.
I can't get hold on my debugger and I couldn't find the root cause. Just found that this seem to be the offending call by trial and error. Another possibility is that there is nothing wrong with the call and it just takes a bit too much to execute and VS debug provider quits.


memset( &g_CLR_RT_ExecutionEngine, 0, sizeof(g_CLR_RT_ExecutionEngine));
memset( &g_CLR_RT_WellKnownTypes, 0, sizeof(g_CLR_RT_WellKnownTypes));
memset( &g_CLR_RT_WellKnownMethods, 0, sizeof(g_CLR_RT_WellKnownMethods));
memset( &g_CLR_RT_TypeSystem, 0, sizeof(g_CLR_RT_TypeSystem));
memset( &g_CLR_RT_EventCache, 0, sizeof(g_CLR_RT_EventCache));
memset( &g_CLR_RT_GarbageCollector, 0, sizeof(g_CLR_RT_GarbageCollector));
memset( &g_CLR_HW_Hardware, 0, sizeof(g_CLR_HW_Hardware));

m_fInitialized = false;
}
Expand Down
9 changes: 1 addition & 8 deletions targets/os/win32/nanoCLR/CLRStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,22 +394,15 @@ struct Settings

void Cleanup()
{
if(!CLR_EE_REBOOT_IS(NoShutdown))
{
// OK to delete execution engine
CLR_RT_ExecutionEngine::DeleteInstance();
}
CLR_RT_ExecutionEngine::DeleteInstance();

#if defined(_WIN32)
memset( &g_CLR_RT_ExecutionEngine, 0, sizeof(g_CLR_RT_ExecutionEngine));
memset( &g_CLR_RT_WellKnownTypes, 0, sizeof(g_CLR_RT_WellKnownTypes));

memset( &g_CLR_RT_WellKnownMethods, 0, sizeof(g_CLR_RT_WellKnownMethods));
memset( &g_CLR_RT_TypeSystem, 0, sizeof(g_CLR_RT_TypeSystem));
memset( &g_CLR_RT_EventCache, 0, sizeof(g_CLR_RT_EventCache));
memset( &g_CLR_RT_GarbageCollector, 0, sizeof(g_CLR_RT_GarbageCollector));
memset( &g_CLR_HW_Hardware, 0, sizeof(g_CLR_HW_Hardware));
#endif

m_fInitialized = false;
}
Expand Down