zturner updated this revision to Diff 51090. zturner added a comment. Update with context
http://reviews.llvm.org/D18287 Files: tools/driver/Driver.cpp tools/driver/Platform.cpp tools/driver/Platform.h tools/lldb-mi/CMakeLists.txt tools/lldb-mi/Platform.cpp tools/lldb-mi/Platform.h
Index: tools/lldb-mi/Platform.h =================================================================== --- tools/lldb-mi/Platform.h +++ tools/lldb-mi/Platform.h @@ -10,12 +10,10 @@ #if defined(_MSC_VER) -// this will stop signal.h being included -#define _INC_SIGNAL - #include <io.h> #include <eh.h> #include <inttypes.h> +#include <signal.h> #include <lldb/Host/windows/Windows.h> #include <lldb/Host/HostGetOpt.h> @@ -73,18 +71,13 @@ // CODETAG_IOR_SIGNALS // signal.h -#define SIGINT 2 // Terminal interrupt signal #define SIGQUIT 3 // Terminal quit signal #define SIGKILL 9 // Kill (cannot be caught or ignored) #define SIGPIPE 13 // Write on a pipe with no one to read it #define SIGCONT 18 // Continue executing, if stopped. #define SIGTSTP 20 // Terminal stop signal #define SIGSTOP 23 // Stop executing (cannot be caught or ignored) #define SIGWINCH 28 // (== SIGVTALRM) -#define SIG_DFL ((sighandler_t)-1) // Default handler -#define SIG_IGN ((sighandler_t)-2) // Ignored - -extern sighandler_t signal(int sig, sighandler_t); #else Index: tools/lldb-mi/Platform.cpp =================================================================== --- tools/lldb-mi/Platform.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//===-- Platform.cpp --------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// this file is only relevant for Visual C++ -#if defined(_MSC_VER) - -#include <process.h> -#include <assert.h> - -#include "Platform.h" - -// the control handler or SIGINT handler -static sighandler_t _ctrlHandler = NULL; - -// the default console control handler -BOOL WINAPI CtrlHandler(DWORD ctrlType) -{ - if (_ctrlHandler != NULL) - { - _ctrlHandler(SIGINT); - return TRUE; - } - return FALSE; -} - -sighandler_t -signal(int sig, sighandler_t sigFunc) -{ - switch (sig) - { - case (SIGINT): - { - _ctrlHandler = sigFunc; - SetConsoleCtrlHandler(CtrlHandler, TRUE); - } - break; - default: - assert(!"Not implemented!"); - } - return 0; -} - -#endif Index: tools/lldb-mi/CMakeLists.txt =================================================================== --- tools/lldb-mi/CMakeLists.txt +++ tools/lldb-mi/CMakeLists.txt @@ -73,7 +73,6 @@ MIUtilString.cpp MIUtilThreadBaseStd.cpp MIUtilVariant.cpp - Platform.cpp ) if ( CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD" ) Index: tools/driver/Platform.h =================================================================== --- tools/driver/Platform.h +++ tools/driver/Platform.h @@ -13,11 +13,11 @@ #if defined( _WIN32 ) // this will stop signal.h being included - #define _INC_SIGNAL #include "lldb/Host/HostGetOpt.h" #include <io.h> #if defined( _MSC_VER ) #include <eh.h> + #include <signal.h> #endif #include <inttypes.h> #include "lldb/Host/windows/windows.h" @@ -37,17 +37,6 @@ // ioctls.h #define TIOCGWINSZ 0x5413 - - // signal handler function pointer type - typedef void(*sighandler_t)(int); - - // signal.h - #define SIGINT 2 - // default handler - #define SIG_DFL ( (sighandler_t) -1 ) - // ignored - #define SIG_IGN ( (sighandler_t) -2 ) - // signal.h #define SIGPIPE 13 #define SIGCONT 18 @@ -80,7 +69,6 @@ }; typedef long pid_t; #define snprintf _snprintf - extern sighandler_t signal( int sig, sighandler_t ); #define PATH_MAX MAX_PATH #endif Index: tools/driver/Platform.cpp =================================================================== --- tools/driver/Platform.cpp +++ tools/driver/Platform.cpp @@ -16,21 +16,6 @@ #include "Platform.h" -// the control handler or SIGINT handler -static sighandler_t _ctrlHandler = NULL; - -// the default console control handler -BOOL -WINAPI CtrlHandler (DWORD ctrlType) -{ - if ( _ctrlHandler != NULL ) - { - _ctrlHandler( 0 ); - return TRUE; - } - return FALSE; -} - int ioctl (int d, int request, ...) { @@ -84,29 +69,4 @@ return -1; } -#ifdef _MSC_VER -sighandler_t -signal (int sig, sighandler_t sigFunc) -{ - switch ( sig ) - { - case ( SIGINT ): - { - _ctrlHandler = sigFunc; - SetConsoleCtrlHandler( CtrlHandler, TRUE ); - } - break; - case ( SIGPIPE ): - case ( SIGWINCH ): - case ( SIGTSTP ): - case ( SIGCONT ): - // ignore these for now - break; - default: - assert( !"Not implemented!" ); - } - return 0; -} -#endif - #endif Index: tools/driver/Driver.cpp =================================================================== --- tools/driver/Driver.cpp +++ tools/driver/Driver.cpp @@ -1310,11 +1310,13 @@ SBHostOS::ThreadCreated ("<lldb.driver.main-thread>"); + signal(SIGINT, sigint_handler); +#ifndef _MSC_VER signal (SIGPIPE, SIG_IGN); signal (SIGWINCH, sigwinch_handler); - signal (SIGINT, sigint_handler); signal (SIGTSTP, sigtstp_handler); signal (SIGCONT, sigcont_handler); +#endif // Create a scope for driver so that the driver object will destroy itself // before SBDebugger::Terminate() is called.
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits