Changeset 154367 in webkit


Ignore:
Timestamp:
Aug 20, 2013 3:25:29 PM (11 years ago)
Author:
Brent Fulgham
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.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r154328 r154367  
     12013-08-20  Brent Fulgham  <bfulgham@apple.com>
     2
     3        <https://webkit.org/b/120090> Report better error messages from WinLauncher/DRT
     4
     5        Reviewed by Tim Horton.
     6
     7        * win/DLLLauncher/DLLLauncherMain.cpp:
     8        (getLastErrorString): New method to convert GetLastError to text.
     9        (wWinMain): Use new error formatter to provide useful diagnostic text to user.
     10
    1112013-08-19  Gustavo Noronha Silva  <gns@gnome.org>
    212
  • trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp

    r153544 r154367  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    149149}
    150150
     151static wstring getLastErrorString(HRESULT hr)
     152{
     153    static const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
     154    static const size_t bufSize = 4096;
     155
     156    wchar_t errorMessage[bufSize];
     157    DWORD len = ::FormatMessageW(kFlags, 0, hr, 0, errorMessage, bufSize, 0);
     158    if (len >= bufSize)
     159        len = bufSize - 1;
     160
     161    errorMessage[len + 1] = 0;
     162
     163    return errorMessage;
     164}
     165
    151166#if USE_CONSOLE_ENTRY_POINT
    152167int main(int argc, const char* argv[])
     
    160175    wchar_t exePath[MAX_PATH];
    161176    if (!::GetModuleFileNameW(0, exePath, _countof(exePath)))
    162         return fatalError(L"Unknown Program", L"Failed to determine name of executable.");
     177        return fatalError(L"Unknown Program", L"Failed to determine name of executable: " + getLastErrorString(::GetLastError()));
    163178
    164179    ::PathRemoveExtensionW(exePath);
     
    172187    wstring dllName = programName + L".dll";
    173188    if (!::PathRemoveFileSpecW(exePath))
    174         return fatalError(programName, L"::PathRemoveFileSpecW failed.");
     189        return fatalError(programName, L"::PathRemoveFileSpecW failed: " + getLastErrorString(::GetLastError()));
    175190    if (!::PathAppendW(exePath, dllName.c_str()))
    176         return fatalError(programName, L"::PathAppendW failed.");
     191        return fatalError(programName, L"::PathAppendW failed: " + getLastErrorString(::GetLastError()));
    177192    HMODULE module = ::LoadLibraryW(exePath);
    178193    if (!module)
    179         return fatalError(programName, L"::LoadLibraryW failed.");
     194        return fatalError(programName, L"::LoadLibraryW failed: \npath=" + wstring(exePath) + L"\n" + getLastErrorString(::GetLastError()));
    180195
    181196#if USE_CONSOLE_ENTRY_POINT
     
    197212    EntryPoint entryPoint = reinterpret_cast<EntryPoint>(::GetProcAddress(module, entryPointName));
    198213    if (!entryPoint)
    199         return fatalError(programName, L"Failed to find dllLauncherEntryPoint function.");
     214        return fatalError(programName, L"Failed to find dllLauncherEntryPoint function: " + getLastErrorString(::GetLastError()));
    200215
    201216#if USE_CONSOLE_ENTRY_POINT
Note: See TracChangeset for help on using the changeset viewer.