Add a method to disable the Windows crash / assert dialogs.

When running the test suite on Windows, we can't have Windows popping
up dialogs when LLDB crashes in native code because it will hang
the test suite.  This patch silences those dialogs by checking an
environment variable at startup and configuring Windows based on
its value.

This patch also adds an environment variable to force inferiors to
never spawn in their own console window.  This is useful to prevent
new window spawm when running the test suite.

Reviewed by: Scott Graham

Differential Revision: http://reviews.llvm.org/D6628

llvm-svn: 224137
This commit is contained in:
Zachary Turner 2014-12-12 18:10:52 +00:00
parent 59aaa6c06b
commit 555a7a6ad2
5 changed files with 57 additions and 1 deletions

3
lldb/.gitignore vendored
View File

@ -15,6 +15,9 @@
*.orig
# Byte compiled python modules.
*.pyc
*.pyproj
*.sln
*.suo
# vim swap files
.*.swp
.sw?

View File

@ -38,6 +38,13 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info, Erro
startupinfo.hStdInput = stdin_handle;
startupinfo.hStdOutput = stdout_handle;
const char *hide_console_var = getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
if (hide_console_var && llvm::StringRef(hide_console_var).equals_lower("true"))
{
startupinfo.dwFlags |= STARTF_USESHOWWINDOW;
startupinfo.wShowWindow = SW_HIDE;
}
DWORD flags = CREATE_NEW_CONSOLE;
if (launch_info.GetFlags().Test(eLaunchFlagDebug))
flags |= DEBUG_ONLY_THIS_PROCESS;

View File

@ -83,6 +83,7 @@
#endif
#if defined (_WIN32)
#include "lldb/Host/windows/windows.h"
#include "Plugins/Process/Windows/DynamicLoaderWindows.h"
#include "Plugins/Process/Windows/ProcessWindows.h"
#endif
@ -118,6 +119,25 @@ lldb_private::Initialize ()
if (!g_inited)
{
g_inited = true;
#if defined(_MSC_VER)
const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
if (disable_crash_dialog_var && llvm::StringRef(disable_crash_dialog_var).equals_lower("true"))
{
// This will prevent Windows from displaying a dialog box requiring user interaction when
// LLDB crashes. This is mostly useful when automating LLDB, for example via the test
// suite, so that a crash in LLDB does not prevent completion of the test suite.
::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
}
#endif
Log::Initialize();
HostInfo::Initialize();
Timer::Initialize ();

View File

@ -42,6 +42,24 @@ set(LLDB_TEST_COMMON_ARGS
-u CFLAGS
)
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
set(LLDB_TEST_DEBUG_TEST_CRASHES
0
CACHE BOOL "(Windows only) Enables debugging of tests in the test suite by showing the crash dialog when lldb crashes")
set(LLDB_TEST_HIDE_CONSOLE_WINDOWS
1
CACHE BOOL "(Windows only) Hides the console window for an inferior when it is launched through the test suite")
if (LLDB_TEST_DEBUG_TEST_CRASHES)
set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --enable-crash-dialog)
endif()
if (NOT LLDB_TEST_HIDE_CONSOLE_WINDOWS)
set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --show-inferior-console)
endif()
endif()
add_python_test_target(check-lldb-single
${LLDB_SOURCE_DIR}/test/dotest.py
"${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
@ -51,7 +69,7 @@ add_python_test_target(check-lldb-single
set(LLDB_DOSEP_ARGS -o;\"-q;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}\")
# If tests crash cause LLDB to crash, or things are otherwise unstable, or if machine-parsable
# output is desired (i.e. in continuous integration contexts) check-lldb-sep is a better target.
# output is desired (i.e. in continuous integration contexts) check-lldb-single is a better target.
add_python_test_target(check-lldb
${LLDB_SOURCE_DIR}/test/dosep.py
"${LLDB_DOSEP_ARGS}"

View File

@ -554,6 +554,10 @@ def parseOptionsAndInitTestdirs():
X('-v', 'Do verbose mode of unittest framework (print out each test case invocation)')
X('-w', 'Insert some wait time (currently 0.5 sec) between consecutive test cases')
X('-T', 'Obtain and dump svn information for this checkout of LLDB (off by default)')
group.add_argument('--enable-crash-dialog', dest='disable_crash_dialog', action='store_false', help='(Windows only) When LLDB crashes, display the Windows crash dialog.')
group.add_argument('--show-inferior-console', dest='hide_inferior_console', action='store_false', help='(Windows only) When launching an inferior, dont hide its console window.')
group.set_defaults(disable_crash_dialog=True)
group.set_defaults(hide_inferior_console=True)
# Remove the reference to our helper function
del X
@ -775,6 +779,10 @@ def parseOptionsAndInitTestdirs():
if args.sharp:
count = args.sharp
if sys.platform.startswith('win32'):
os.environ['LLDB_DISABLE_CRASH_DIALOG'] = str(args.disable_crash_dialog)
os.environ['LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE'] = str(args.hide_inferior_console)
if do_help == True:
usage(parser)