[llvm-branch-commits] [lldb] r199931 - Allow GUIs that use the LLDB framework to translate "control + char" into strings that can be written into the file handle that will feed the debugger input file.
Greg Clayton
gclayton at apple.com
Thu Jan 23 12:12:00 PST 2014
Author: gclayton
Date: Thu Jan 23 14:11:59 2014
New Revision: 199931
URL: http://llvm.org/viewvc/llvm-project?rev=199931&view=rev
Log:
Allow GUIs that use the LLDB framework to translate "control + char" into strings that can be written into the file handle that will feed the debugger input file.
Most GUIs will create a PTY where the master end is written into and the slave end is given to the debugger as input, output and error. Since pseudo terminals don't have height and width and dont handle CTRL+D and other control characters the same way, we need a way to emulate this.
Modified:
lldb/branches/iohandler/include/lldb/API/SBCommandInterpreter.h
lldb/branches/iohandler/include/lldb/Core/Debugger.h
lldb/branches/iohandler/include/lldb/Core/IOHandler.h
lldb/branches/iohandler/include/lldb/Interpreter/CommandInterpreter.h
lldb/branches/iohandler/scripts/Python/interface/SBCommandInterpreter.i
lldb/branches/iohandler/source/API/SBCommandInterpreter.cpp
lldb/branches/iohandler/source/Core/Debugger.cpp
lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp
Modified: lldb/branches/iohandler/include/lldb/API/SBCommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/API/SBCommandInterpreter.h?rev=199931&r1=199930&r2=199931&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/API/SBCommandInterpreter.h (original)
+++ lldb/branches/iohandler/include/lldb/API/SBCommandInterpreter.h Thu Jan 23 14:11:59 2014
@@ -131,6 +131,26 @@ public:
//----------------------------------------------------------------------
bool
IsActive ();
+
+ //----------------------------------------------------------------------
+ /// Get the string that needs to be written to the debugger stdin file
+ /// handle when a control character is typed.
+ ///
+ /// Some GUI programs will intercept "control + char" sequences and want
+ /// to have them do what normally would happen when using a real
+ /// terminal, so this function allows GUI programs to emulate this
+ /// functionality.
+ ///
+ /// @param[in] ch
+ /// The character that was typed along with the control key
+ ///
+ /// @return
+ /// The string that should be written into the file handle that is
+ /// feeding the input stream for the debugger, or NULL if there is
+ /// no string for this control key.
+ //----------------------------------------------------------------------
+ const char *
+ GetIOHandlerControlSequence(char ch);
protected:
Modified: lldb/branches/iohandler/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Core/Debugger.h?rev=199931&r1=199930&r2=199931&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Core/Debugger.h (original)
+++ lldb/branches/iohandler/include/lldb/Core/Debugger.h Thu Jan 23 14:11:59 2014
@@ -212,6 +212,9 @@ public:
bool
IsTopIOHandler (const lldb::IOHandlerSP& reader_sp);
+ ConstString
+ GetTopIOHandlerControlSequence(char ch);
+
bool
HideTopIOHandler();
Modified: lldb/branches/iohandler/include/lldb/Core/IOHandler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Core/IOHandler.h?rev=199931&r1=199930&r2=199931&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Core/IOHandler.h (original)
+++ lldb/branches/iohandler/include/lldb/Core/IOHandler.h Thu Jan 23 14:11:59 2014
@@ -16,6 +16,7 @@
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/Core/ConstString.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/ValueObjectList.h"
@@ -110,6 +111,12 @@ namespace lldb_private {
return false;
}
+ virtual ConstString
+ GetControlSequence (char ch)
+ {
+ return ConstString();
+ }
+
int
GetInputFD();
@@ -249,6 +256,13 @@ namespace lldb_private {
// that are getting single lines.
}
+
+ virtual ConstString
+ GetControlSequence (char ch)
+ {
+ return ConstString();
+ }
+
protected:
Completion m_completion; // Support for common builtin completions
bool m_io_handler_done;
@@ -277,6 +291,14 @@ namespace lldb_private {
{
}
+ virtual ConstString
+ GetControlSequence (char ch)
+ {
+ if (ch == 'd')
+ return ConstString (m_end_line + "\n");
+ return ConstString();
+ }
+
virtual LineStatus
IOHandlerLinesUpdated (IOHandler &io_handler,
StringList &lines,
@@ -348,6 +370,12 @@ namespace lldb_private {
m_delegate.IOHandlerActivated(*this);
}
+ virtual ConstString
+ GetControlSequence (char ch)
+ {
+ return m_delegate.GetControlSequence (ch);
+ }
+
virtual const char *
GetPrompt ();
@@ -552,13 +580,21 @@ namespace lldb_private {
{
return m_mutex;
}
-
+
bool
IsTop (const lldb::IOHandlerSP &io_handler_sp) const
{
return m_top == io_handler_sp.get();
}
-
+
+ ConstString
+ GetTopIOHandlerControlSequence (char ch)
+ {
+ if (m_top)
+ return m_top->GetControlSequence(ch);
+ return ConstString();
+ }
+
protected:
std::stack<lldb::IOHandlerSP> m_stack;
Modified: lldb/branches/iohandler/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Interpreter/CommandInterpreter.h?rev=199931&r1=199930&r2=199931&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/branches/iohandler/include/lldb/Interpreter/CommandInterpreter.h Thu Jan 23 14:11:59 2014
@@ -476,12 +476,20 @@ protected:
friend class Debugger;
//------------------------------------------------------------------
- // IOHandler::Delegate functions
+ // IOHandlerDelegate functions
//------------------------------------------------------------------
virtual void
IOHandlerInputComplete (IOHandler &io_handler,
std::string &line);
+ virtual ConstString
+ GetControlSequence (char ch)
+ {
+ if (ch == 'd')
+ return ConstString("quit\n");
+ return ConstString();
+ }
+
size_t
GetProcessOutput ();
Modified: lldb/branches/iohandler/scripts/Python/interface/SBCommandInterpreter.i
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/scripts/Python/interface/SBCommandInterpreter.i?rev=199931&r1=199930&r2=199931&view=diff
==============================================================================
--- lldb/branches/iohandler/scripts/Python/interface/SBCommandInterpreter.i (original)
+++ lldb/branches/iohandler/scripts/Python/interface/SBCommandInterpreter.i Thu Jan 23 14:11:59 2014
@@ -78,6 +78,9 @@ public:
bool
IsValid() const;
+ const char *
+ GetIOHandlerControlSequence(char ch);
+
bool
CommandExists (const char *cmd);
Modified: lldb/branches/iohandler/source/API/SBCommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/API/SBCommandInterpreter.cpp?rev=199931&r1=199930&r2=199931&view=diff
==============================================================================
--- lldb/branches/iohandler/source/API/SBCommandInterpreter.cpp (original)
+++ lldb/branches/iohandler/source/API/SBCommandInterpreter.cpp Thu Jan 23 14:11:59 2014
@@ -115,6 +115,14 @@ SBCommandInterpreter::IsActive ()
return false;
}
+const char *
+SBCommandInterpreter::GetIOHandlerControlSequence(char ch)
+{
+ if (m_opaque_ptr)
+ return m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence (ch).GetCString();
+ return NULL;
+}
+
lldb::ReturnStatus
SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnObject &result, bool add_to_history)
{
Modified: lldb/branches/iohandler/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Core/Debugger.cpp?rev=199931&r1=199930&r2=199931&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Core/Debugger.cpp (original)
+++ lldb/branches/iohandler/source/Core/Debugger.cpp Thu Jan 23 14:11:59 2014
@@ -885,6 +885,12 @@ Debugger::IsTopIOHandler (const lldb::IO
}
+ConstString
+Debugger::GetTopIOHandlerControlSequence(char ch)
+{
+ return m_input_reader_stack.GetTopIOHandlerControlSequence (ch);
+}
+
void
Debugger::RunIOHandler (const IOHandlerSP& reader_sp)
{
Modified: lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp?rev=199931&r1=199930&r2=199931&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/branches/iohandler/source/Interpreter/ScriptInterpreterPython.cpp Thu Jan 23 14:11:59 2014
@@ -695,6 +695,15 @@ public:
{
}
+
+ virtual ConstString
+ GetControlSequence (char ch)
+ {
+ if (ch == 'd')
+ return ConstString("quit()\n");
+ return ConstString();
+ }
+
virtual void
Run ()
{
More information about the llvm-branch-commits
mailing list