From 9453d67273dc4ac7b37b89a9a22290a624ab1173 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 2 Sep 2020 20:07:03 -0700 Subject: [PATCH] [sim] Output more error details on extension load failure (#2680) --- hal/src/main/native/sim/Extensions.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hal/src/main/native/sim/Extensions.cpp b/hal/src/main/native/sim/Extensions.cpp index 19ab4594fc..c31e771294 100644 --- a/hal/src/main/native/sim/Extensions.cpp +++ b/hal/src/main/native/sim/Extensions.cpp @@ -26,6 +26,7 @@ #define DLOPEN(a) LoadLibraryA(a) #define DLSYM GetProcAddress #define DLCLOSE FreeLibrary +#define DLERROR "error #" << GetLastError() #else #define DELIM ':' #define HTYPE void* @@ -33,6 +34,7 @@ #define DLOPEN(a) dlopen(a, RTLD_LAZY) #define DLSYM dlsym #define DLCLOSE dlclose +#define DLERROR dlerror() #endif namespace hal { @@ -63,14 +65,16 @@ int HAL_LoadOneExtension(const char* library) { #else libraryName += ".so"; #endif - wpi::outs() << "HAL Extensions: Trying modified name: " + wpi::outs() << "HAL Extensions: Load failed: " << DLERROR + << "\nTrying modified name: " << wpi::sys::path::stem(libraryName) << "\n"; wpi::outs().flush(); handle = DLOPEN(libraryName.c_str()); } #endif if (!handle) { - wpi::outs() << "HAL Extensions: Failed to load library\n"; + wpi::outs() << "HAL Extensions: Failed to load library: " << DLERROR + << '\n'; wpi::outs().flush(); return rc; }