From 659c645906c3fe9ec872309b5ac87f34e8cf6ff2 Mon Sep 17 00:00:00 2001 From: Giridhar Trivedi Date: Tue, 18 Jul 2023 00:51:40 +0530 Subject: [PATCH] [Mono] Add coreclr_shutdown to mono (#88594) * [Mono] Add coreclr_shutdown to mono There was a crash seen in netcordbg due to unavailability of coreclr_shutdown in mono. Implemented it for mono. --------- Co-authored-by: Giridhar Trivedi --- src/mono/mono/mini/main-core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/mono/mono/mini/main-core.c b/src/mono/mono/mini/main-core.c index d9e2626..8f26f59 100644 --- a/src/mono/mono/mini/main-core.c +++ b/src/mono/mono/mini/main-core.c @@ -19,6 +19,7 @@ #pragma comment(linker, "/export:coreclr_initialize=_coreclr_initialize@28") #pragma comment(linker, "/export:coreclr_execute_assembly=_coreclr_execute_assembly@24") #pragma comment(linker, "/export:coreclr_shutdown_2=_coreclr_shutdown_2@12") +#pragma comment(linker, "/export:coreclr_shutdown=_coreclr_shutdown@8") #pragma comment(linker, "/export:coreclr_create_delegate=_coreclr_create_delegate@24") #pragma comment(linker, "/export:coreclr_set_error_writer=_coreclr_set_error_writer@4") #undef MONO_API @@ -39,6 +40,7 @@ MONO_API int STDAPICALLTYPE coreclr_execute_assembly (void* hostHandle, unsigned const char* managedAssemblyPath, unsigned int* exitCode); MONO_API int STDAPICALLTYPE coreclr_shutdown_2 (void* hostHandle, unsigned int domainId, int* latchedExitCode); +MONO_API int STDAPICALLTYPE coreclr_shutdown (void* hostHandle, unsigned int domainId); MONO_API int STDAPICALLTYPE coreclr_create_delegate (void* hostHandle, unsigned int domainId, const char* entryPointAssemblyName, const char* entryPointTypeName, const char* entryPointMethodName, @@ -106,6 +108,24 @@ int STDAPICALLTYPE coreclr_shutdown_2 (void* hostHandle, unsigned int domainId, } // +// Shutdown CoreCLR. It unloads the app domain and stops the CoreCLR host. +// +// Parameters: +// hostHandle - Handle of the host +// domainId - Id of the domain +// latchedExitCode - Latched exit code after domain unloaded +// +// Returns: +// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed +// +int STDAPICALLTYPE coreclr_shutdown (void* hostHandle, unsigned int domainId) +{ + int latchedExitCode = 0 ; + return monovm_shutdown (&latchedExitCode); +} + + +// // Create a native callable delegate for a managed method. // // Parameters: -- 2.7.4