From d242f1c0378508875ffddaaf7f23ef646d7a1649 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Fri, 1 Jun 2012 01:07:02 +0000 Subject: [PATCH] If the Driver's input reader gets an Interrupt and the current command line is empty, then treat that interrupt as an instruction to Stop the process of the currently selected target. llvm-svn: 157790 --- lldb/tools/driver/Driver.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index ec8f26b20c9d..808035f9a962 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -1080,10 +1080,19 @@ Driver::EditLineInputReaderCallback case eInputReaderInterrupt: if (driver->m_io_channel_ap.get() != NULL) { - driver->m_io_channel_ap->OutWrite ("^C\n", 3, NO_ASYNC); - // I wish I could erase the entire input line, but there's no public API for that. - driver->m_io_channel_ap->EraseCharsBeforeCursor(); - driver->m_io_channel_ap->RefreshPrompt(); + SBProcess process = driver->GetDebugger().GetSelectedTarget().GetProcess(); + if (!driver->m_io_channel_ap->EditLineHasCharacters() + && process.IsValid() && process.GetState() == lldb::eStateRunning) + { + process.Stop(); + } + else + { + driver->m_io_channel_ap->OutWrite ("^C\n", 3, NO_ASYNC); + // I wish I could erase the entire input line, but there's no public API for that. + driver->m_io_channel_ap->EraseCharsBeforeCursor(); + driver->m_io_channel_ap->RefreshPrompt(); + } } break;