diff --git a/vvp/main.cc b/vvp/main.cc index a452fcd33..4f436589a 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -450,12 +450,18 @@ int main(int argc, char*argv[]) modpath_delete(); vpi_handle_delete(); udp_defns_delete(); - load_module_delete(); island_delete(); signal_pool_delete(); vvp_net_pool_delete(); ufunc_pool_delete(); #endif +/* + * Unload the VPI modules. This is essential for MinGW, to ensure + * dump files are flushed before the main process terminates, as + * the DLL termination code is called after all remaining open + * files are automatically closed. +*/ + load_module_delete(); return vvp_return_value; } diff --git a/vvp/vpi_modules.cc b/vvp/vpi_modules.cc index 7997ff24b..7e509a19b 100644 --- a/vvp/vpi_modules.cc +++ b/vvp/vpi_modules.cc @@ -20,18 +20,14 @@ # include "config.h" # include "vpi_priv.h" # include "ivl_dlfcn.h" -#ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" -#endif # include # include # include # include -#ifdef CHECK_WITH_VALGRIND static ivl_dll_t*dll_list = 0; static unsigned dll_list_cnt = 0; -#endif typedef void (*vlog_startup_routines_t)(void); @@ -55,7 +51,6 @@ unsigned vpip_module_path_cnt = 0 #endif ; -#ifdef CHECK_WITH_VALGRIND void load_module_delete(void) { for (unsigned idx = 0; idx < dll_list_cnt; idx += 1) { @@ -65,7 +60,6 @@ void load_module_delete(void) dll_list = 0; dll_list_cnt = 0; } -#endif void vpip_load_module(const char*name) { @@ -162,12 +156,10 @@ void vpip_load_module(const char*name) return; } -#ifdef CHECK_WITH_VALGRIND /* Add the dll to the list so it can be closed when we are done. */ dll_list_cnt += 1; dll_list = (ivl_dll_t*)realloc(dll_list, dll_list_cnt*sizeof(ivl_dll_t)); dll_list[dll_list_cnt-1] = dll; -#endif vpi_mode_flag = VPI_MODE_REGISTER; vlog_startup_routines_t*routines = (vlog_startup_routines_t*)table;