Files
clang-p2996/lldb/source/Core/StreamAsynchronousIO.cpp
Pavel Labath 4446487d71 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

llvm-svn: 238313
2015-05-27 12:40:32 +00:00

49 lines
1.1 KiB
C++

//===-- StreamBroadcast.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/StreamAsynchronousIO.h"
#include "lldb/lldb-private.h"
#include "lldb/Core/Debugger.h"
using namespace lldb;
using namespace lldb_private;
StreamAsynchronousIO::StreamAsynchronousIO (Debugger &debugger, bool for_stdout) :
Stream (0, 4, eByteOrderBig),
m_debugger (debugger),
m_data (),
m_for_stdout (for_stdout)
{
}
StreamAsynchronousIO::~StreamAsynchronousIO ()
{
// Flush when we destroy to make sure we display the data
Flush();
}
void
StreamAsynchronousIO::Flush ()
{
if (!m_data.empty())
{
m_debugger.PrintAsync (m_data.data(), m_data.size(), m_for_stdout);
m_data = std::move(std::string());
}
}
size_t
StreamAsynchronousIO::Write (const void *s, size_t length)
{
m_data.append ((const char *)s, length);
return length;
}