Index: .gitignore =================================================================== --- .gitignore +++ .gitignore @@ -15,6 +15,9 @@ *.orig # Byte compiled python modules. *.pyc +*.pyproj +*.sln +*.suo # vim swap files .*.swp .sw? Index: source/Host/windows/ProcessLauncherWindows.cpp =================================================================== --- source/Host/windows/ProcessLauncherWindows.cpp +++ source/Host/windows/ProcessLauncherWindows.cpp @@ -38,6 +38,13 @@ 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; Index: source/lldb.cpp =================================================================== --- source/lldb.cpp +++ source/lldb.cpp @@ -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 @@ -101,6 +102,25 @@ using namespace lldb; using namespace lldb_private; +namespace +{ +#if defined(_MSC_VER) +// Emulates the effect of the user pressing the "retry" button when the abort/retry/ignore +// assertion failure dialog pops up. +static int AvoidMessageBoxHook(int ReportType, char *Message, int *Return) +{ + // FIXME: Do we need to raise a python exception here? Otherwise, if this is being + // run from Python, Python will just exit. It might be possible to allow it to continue + // running other tests. + static const int kRetryButton = 1; + + if (Return) + *Return = kRetryButton; + return TRUE; +} +#endif +} + static void fatal_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag) { Host::SetCrashDescription(reason.c_str()); @@ -118,6 +138,22 @@ 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(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); + + // This will prevent Windows from displaying an abort/retry/ignore dialog box requiring + // user interaction when LLDB asserts. + _CrtSetReportHook(AvoidMessageBoxHook); + } +#endif + Log::Initialize(); HostInfo::Initialize(); Timer::Initialize (); Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -42,6 +42,24 @@ -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 @@ 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}" Index: test/dotest.py =================================================================== --- test/dotest.py +++ test/dotest.py @@ -554,6 +554,10 @@ 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 @@ 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)