Skip to content

Commit

Permalink
[test][ASan][Win] Print more info when LoadLibrary fails
Browse files Browse the repository at this point in the history
Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D118206
  • Loading branch information
aeubanks committed Jan 26, 2022
1 parent cbc623c commit 092f6ae
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 092f6ae

Please sign in to comment.