summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2014-05-02 00:45:31 +0000
committerGreg Clayton <gclayton@apple.com>2014-05-02 00:45:31 +0000
commitf0066ad07fadc7c1386c65572e6d988dfd26610d (patch)
treebb4ae7aeedcca4c081697032a493465a2d21d42a /lldb/source/Interpreter
parent34a38d8efbde085814bbbb5d1d7c7fcb15897e42 (diff)
downloadbcm5719-llvm-f0066ad07fadc7c1386c65572e6d988dfd26610d.tar.gz
bcm5719-llvm-f0066ad07fadc7c1386c65572e6d988dfd26610d.zip
Fixed CTRL+C related issues:
- CTRL+C wasn't clearing the command in lldb - CTRL+C doesn't work in python macros in lldb - Ctrl+C no longer interrupts the running process that you attach to <rdar://problem/15949205> <rdar://problem/16778652> <rdar://problem/16774411> llvm-svn: 207816
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp19
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp37
2 files changed, 45 insertions, 11 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index aa400aa7ce7..929fbfb29c4 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -44,6 +44,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Timer.h"
@@ -3051,6 +3052,24 @@ CommandInterpreter::IOHandlerInputComplete (IOHandler &io_handler, std::string &
}
}
+bool
+CommandInterpreter::IOHandlerInterrupt (IOHandler &io_handler)
+{
+ ExecutionContext exe_ctx (GetExecutionContext());
+ Process *process = exe_ctx.GetProcessPtr();
+
+ if (process)
+ {
+ StateType state = process->GetState();
+ if (StateIsRunningState(state))
+ {
+ process->Halt();
+ return true; // Don't do any updating when we are running
+ }
+ }
+ return false;
+}
+
void
CommandInterpreter::GetLLDBCommandsFromIOHandler (const char *prompt,
IOHandlerDelegate &delegate,
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index eb2e33b9f45..da84353fed4 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -93,6 +93,13 @@ ScriptInterpreterPython::Locker::DoAcquireLock()
m_GILState = PyGILState_Ensure();
if (log)
log->Printf("Ensured PyGILState. Previous state = %slocked\n", m_GILState == PyGILState_UNLOCKED ? "un" : "");
+
+ // we need to save the thread state when we first start the command
+ // because we might decide to interrupt it while some action is taking
+ // place outside of Python (e.g. printing to screen, waiting for the network, ...)
+ // in that case, _PyThreadState_Current will be NULL - and we would be unable
+ // to set the asynchronous exception - not a desirable situation
+ m_python_interpreter->SetThreadState (_PyThreadState_Current);
return true;
}
@@ -781,10 +788,27 @@ public:
}
- virtual void
+ virtual bool
Interrupt ()
{
-
+ Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SCRIPT));
+
+ PyThreadState* state = _PyThreadState_Current;
+ if (!state)
+ state = m_python->GetThreadState();
+ if (state)
+ {
+ long tid = state->thread_id;
+ _PyThreadState_Current = state;
+ int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt);
+ if (log)
+ log->Printf("ScriptInterpreterPython::NonInteractiveInputReaderCallback, eInputReaderInterrupt, tid = %ld, num_threads = %d, state = %p",
+ tid,num_threads,state);
+ }
+ else if (log)
+ log->Printf("ScriptInterpreterPython::NonInteractiveInputReaderCallback, eInputReaderInterrupt, state = NULL");
+
+ return false;
}
virtual void
@@ -2433,15 +2457,6 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function,
SynchronicityHandler synch_handler(debugger_sp,
synchronicity);
- // we need to save the thread state when we first start the command
- // because we might decide to interrupt it while some action is taking
- // place outside of Python (e.g. printing to screen, waiting for the network, ...)
- // in that case, _PyThreadState_Current will be NULL - and we would be unable
- // to set the asynchronous exception - not a desirable situation
- m_command_thread_state = _PyThreadState_Current;
-
- //PythonInputReaderManager py_input(this);
-
ret_val = g_swig_call_command (impl_function,
m_dictionary_name.c_str(),
debugger_sp,
OpenPOWER on IntegriCloud