[compiler-rt] 092f6ae - [test][ASan][Win] Print more info when LoadLibrary fails

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 26 10:33:40 PST 2022


Author: Arthur Eubanks
Date: 2022-01-26T10:33:23-08:00
New Revision: 092f6ae29276f7b71f24744773fe1fda50d872bb

URL: https://github.com/llvm/llvm-project/commit/092f6ae29276f7b71f24744773fe1fda50d872bb
DIFF: https://github.com/llvm/llvm-project/commit/092f6ae29276f7b71f24744773fe1fda50d872bb.diff

LOG: [test][ASan][Win] Print more info when LoadLibrary fails

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D118206

Added: 
    

Modified: 
    compiler-rt/test/asan/TestCases/Windows/dll_host.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
index 2a30a15589f5a..8032201684cd2 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
@@ -59,8 +59,20 @@ int main(int argc, char **argv) {
 
   HMODULE h = LoadLibrary(dll_name);
   if (!h) {
-    printf("Could not load DLL: %s (code: %lu)!\n",
-           dll_name, GetLastError());
+    DWORD err = GetLastError();
+    printf("Could not load DLL: %s (code: %lu)!\n", dll_name, err);
+
+    LPSTR buf;
+
+    FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+                       FORMAT_MESSAGE_IGNORE_INSERTS,
+                   NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0,
+                   NULL);
+
+    printf("Error: %s\n", buf);
+
+    LocalFree(buf);
+
     return 102;
   }
 


        


More information about the llvm-commits mailing list