Title: [154367] trunk/Tools
Revision
154367
Author
[email protected]
Date
2013-08-20 15:25:29 -0700 (Tue, 20 Aug 2013)

Log Message

<https://webkit.org/b/120090> Report better error messages from WinLauncher/DRT

Reviewed by Tim Horton.

* win/DLLLauncher/DLLLauncherMain.cpp:
(getLastErrorString): New method to convert GetLastError to text.
(wWinMain): Use new error formatter to provide useful diagnostic text to user.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (154366 => 154367)


--- trunk/Tools/ChangeLog	2013-08-20 22:17:29 UTC (rev 154366)
+++ trunk/Tools/ChangeLog	2013-08-20 22:25:29 UTC (rev 154367)
@@ -1,3 +1,13 @@
+2013-08-20  Brent Fulgham  <[email protected]>
+
+        <https://webkit.org/b/120090> Report better error messages from WinLauncher/DRT
+
+        Reviewed by Tim Horton.
+
+        * win/DLLLauncher/DLLLauncherMain.cpp:
+        (getLastErrorString): New method to convert GetLastError to text.
+        (wWinMain): Use new error formatter to provide useful diagnostic text to user.
+
 2013-08-19  Gustavo Noronha Silva  <[email protected]>
 
         <https://webkit.org/b/120048> [GTK] Add stubs for APIs that went missing in the DOM bindings

Modified: trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp (154366 => 154367)


--- trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp	2013-08-20 22:17:29 UTC (rev 154366)
+++ trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp	2013-08-20 22:25:29 UTC (rev 154367)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -148,6 +148,21 @@
     return false;
 }
 
+static wstring getLastErrorString(HRESULT hr)
+{
+    static const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
+    static const size_t bufSize = 4096;
+
+    wchar_t errorMessage[bufSize];
+    DWORD len = ::FormatMessageW(kFlags, 0, hr, 0, errorMessage, bufSize, 0);
+    if (len >= bufSize)
+        len = bufSize - 1;
+
+    errorMessage[len + 1] = 0;
+
+    return errorMessage;
+}
+
 #if USE_CONSOLE_ENTRY_POINT
 int main(int argc, const char* argv[])
 #else
@@ -159,7 +174,7 @@
     // Get the path of our executable.
     wchar_t exePath[MAX_PATH];
     if (!::GetModuleFileNameW(0, exePath, _countof(exePath)))
-        return fatalError(L"Unknown Program", L"Failed to determine name of executable.");
+        return fatalError(L"Unknown Program", L"Failed to determine name of executable: " + getLastErrorString(::GetLastError()));
 
     ::PathRemoveExtensionW(exePath);
 
@@ -171,12 +186,12 @@
     // Load our corresponding DLL.
     wstring dllName = programName + L".dll";
     if (!::PathRemoveFileSpecW(exePath))
-        return fatalError(programName, L"::PathRemoveFileSpecW failed.");
+        return fatalError(programName, L"::PathRemoveFileSpecW failed: " + getLastErrorString(::GetLastError()));
     if (!::PathAppendW(exePath, dllName.c_str()))
-        return fatalError(programName, L"::PathAppendW failed.");
+        return fatalError(programName, L"::PathAppendW failed: " + getLastErrorString(::GetLastError()));
     HMODULE module = ::LoadLibraryW(exePath);
     if (!module)
-        return fatalError(programName, L"::LoadLibraryW failed.");
+        return fatalError(programName, L"::LoadLibraryW failed: \npath=" + wstring(exePath) + L"\n" + getLastErrorString(::GetLastError()));
 
 #if USE_CONSOLE_ENTRY_POINT
     typedef int (WINAPI*EntryPoint)(int, const char*[]);
@@ -196,7 +211,7 @@
 
     EntryPoint entryPoint = reinterpret_cast<EntryPoint>(::GetProcAddress(module, entryPointName));
     if (!entryPoint)
-        return fatalError(programName, L"Failed to find dllLauncherEntryPoint function.");
+        return fatalError(programName, L"Failed to find dllLauncherEntryPoint function: " + getLastErrorString(::GetLastError()));
 
 #if USE_CONSOLE_ENTRY_POINT
     return entryPoint(argc, argv);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to