Author: abidh
Date: Mon Apr 27 10:04:42 2015
New Revision: 235887

URL: http://llvm.org/viewvc/llvm-project?rev=235887&view=rev
Log:
Improve handling of ctrl-c with MSVC.
Currently hitting Ctrl-C in Windows LLDB-MI just exits MI. But according to 
test_lldbmi_stopped_when_interrupt() in TestMiSignal.py Ctrl-C should send a 
SIGINT signal to the inferior.
Patch adds this functionality to Windows so SIGINT is sent on Ctrl-C.

Patch from EwanCrawford. Reviewed in http://reviews.llvm.org/D9248.


Modified:
    lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp
    lldb/trunk/tools/lldb-mi/Platform.cpp

Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp?rev=235887&r1=235886&r2=235887&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp Mon Apr 27 10:04:42 2015
@@ -7,6 +7,12 @@
 //
 
//===----------------------------------------------------------------------===//
 
+// Third Party Headers
+#ifdef _MSC_VER
+#include <Windows.h>
+#endif
+#include <string.h> // For std::strerror()
+
 // In-house headers:
 #include "MICmnStreamStdin.h"
 #include "MICmnStreamStdout.h"
@@ -14,7 +20,6 @@
 #include "MICmnLog.h"
 #include "MIDriver.h"
 #include "MIUtilSingletonHelper.h"
-#include <string.h> // For std::strerror()
 
 //++ 
------------------------------------------------------------------------------------
 // Details: CMICmnStreamStdin constructor.
@@ -206,6 +211,13 @@ CMICmnStreamStdin::ReadLine(CMIUtilStrin
     const MIchar *pText = ::fgets(&m_pCmdBuffer[0], m_constBufferSize, stdin);
     if (pText == nullptr)
     {
+#ifdef _MSC_VER
+        // Was Ctrl-C hit?
+        // On Windows, Ctrl-C gives an ERROR_OPERATION_ABORTED as error on the 
command-line.
+        // The end-of-file indicator is also set, so without this check we 
will exit next if statement.
+        if (::GetLastError() == ERROR_OPERATION_ABORTED)
+            return nullptr;
+#endif
         if (::feof(stdin))
         {
             const bool bForceExit = true;

Modified: lldb/trunk/tools/lldb-mi/Platform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/Platform.cpp?rev=235887&r1=235886&r2=235887&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/Platform.cpp (original)
+++ lldb/trunk/tools/lldb-mi/Platform.cpp Mon Apr 27 10:04:42 2015
@@ -23,7 +23,7 @@ BOOL WINAPI CtrlHandler(DWORD ctrlType)
 {
     if (_ctrlHandler != NULL)
     {
-        _ctrlHandler(0);
+        _ctrlHandler(SIGINT);
         return TRUE;
     }
     return FALSE;


_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to