diff options
author | Pavel Labath <labath@google.com> | 2015-05-27 12:40:32 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2015-05-27 12:40:32 +0000 |
commit | 2d2f8b0f728b543abc436d90abbc7a6f9244c6c5 (patch) | |
tree | ce58346ab669f38824f55ad606755bc799245085 /lldb/source/Core/IOHandler.cpp | |
parent | ff17e9f4a2c1a943df4d7d4f2d232ca0e974a266 (diff) |
Improve LLDB prompt handling
Summary:
There is an issue in lldb where the command prompt can appear at the wrong time. The partial fix
we have in for this is not working all the time and is introducing unnecessary delays. This
change does:
- Change Process:SyncIOHandler to use integer start id's for synchronization to avoid it being
confused by quick start-stop cycles. I picked this up from a suggested patch by Greg to
lldb-dev.
- coordinates printing of asynchronous text with the iohandlers. This is also based on a
(different) Greg's patch, but I have added stronger synchronization to it to avoid races.
Together, these changes solve the prompt problem for me on linux (both with and without libedit).
I think they should behave similarly on Mac and FreeBSD and I think they will not make matters
worse for windows.
Test Plan: Prompt comes out alright. All tests still pass on linux.
Reviewers: clayborg, emaste, zturner
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D9823
Diffstat (limited to 'lldb/source/Core/IOHandler.cpp')
-rw-r--r-- | lldb/source/Core/IOHandler.cpp | 71 |
1 files changed, 23 insertions, 48 deletions
diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp index b1ee57268ef..9cc280b6d70 100644 --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -169,6 +169,17 @@ IOHandler::WaitForPop () m_popped.WaitForValueEqualTo(true); } +void +IOHandlerStack::PrintAsync (Stream *stream, const char *s, size_t len) +{ + if (stream) + { + Mutex::Locker locker (m_mutex); + if (m_top) + m_top->PrintAsync (stream, s, len); + } +} + IOHandlerConfirm::IOHandlerConfirm (Debugger &debugger, const char *prompt, bool default_response) : @@ -740,47 +751,11 @@ IOHandlerEditline::Run () } void -IOHandlerEditline::Hide () -{ -#ifndef LLDB_DISABLE_LIBEDIT - if (m_editline_ap) - m_editline_ap->Hide(); -#endif -} - - -void -IOHandlerEditline::Refresh () -{ -#ifndef LLDB_DISABLE_LIBEDIT - if (m_editline_ap) - { - m_editline_ap->Refresh(); - } - else if (m_editing) - { -#endif - const char *prompt = GetPrompt(); - if (prompt && prompt[0]) - { - FILE *out = GetOutputFILE(); - if (out) - { - ::fprintf(out, "%s", prompt); - ::fflush(out); - } - } -#ifndef LLDB_DISABLE_LIBEDIT - } -#endif -} - -void IOHandlerEditline::Cancel () { #ifndef LLDB_DISABLE_LIBEDIT if (m_editline_ap) - m_editline_ap->Interrupt (); + m_editline_ap->Cancel (); #endif } @@ -807,6 +782,17 @@ IOHandlerEditline::GotEOF() #endif } +void +IOHandlerEditline::PrintAsync (Stream *stream, const char *s, size_t len) +{ +#ifndef LLDB_DISABLE_LIBEDIT + if (m_editline_ap) + m_editline_ap->PrintAsync(stream, s, len); + else +#endif + IOHandler::PrintAsync(stream, s, len); +} + // we may want curses to be disabled for some builds // for instance, windows #ifndef LLDB_DISABLE_CURSES @@ -5618,17 +5604,6 @@ IOHandlerCursesGUI::~IOHandlerCursesGUI () } void -IOHandlerCursesGUI::Hide () -{ -} - - -void -IOHandlerCursesGUI::Refresh () -{ -} - -void IOHandlerCursesGUI::Cancel () { } |