summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2011-05-03 20:53:11 +0000
committerCaroline Tice <ctice@apple.com>2011-05-03 20:53:11 +0000
commit86a73f90076ae11beb37a1b76ec2e1ee6f945b32 (patch)
tree1e62a2624348596030e77ed2adfd4e38dd796212
parent5583d56ddbe6e9f6e6e0303781eebd8840a86ac2 (diff)
downloadbcm5719-llvm-86a73f90076ae11beb37a1b76ec2e1ee6f945b32.tar.gz
bcm5719-llvm-86a73f90076ae11beb37a1b76ec2e1ee6f945b32.zip
Make the driver listen for asynchronous output, rather than
the IOChannel, so that it can be written out even while the IOChannel is collecting user input. llvm-svn: 130789
-rw-r--r--lldb/tools/driver/Driver.cpp14
-rw-r--r--lldb/tools/driver/IOChannel.cpp32
-rw-r--r--lldb/tools/driver/IOChannel.h1
3 files changed, 27 insertions, 20 deletions
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 5107708e8a2..c3d4015968a 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -1124,7 +1124,9 @@ Driver::MainLoop ()
bool iochannel_thread_exited = false;
listener.StartListeningForEvents (sb_interpreter.GetBroadcaster(),
- SBCommandInterpreter::eBroadcastBitQuitCommandReceived);
+ SBCommandInterpreter::eBroadcastBitQuitCommandReceived |
+ SBCommandInterpreter::eBroadcastBitAsynchronousOutputData |
+ SBCommandInterpreter::eBroadcastBitAsynchronousErrorData);
// Before we handle any options from the command line, we parse the
// .lldbinit file in the user's home directory.
@@ -1234,6 +1236,16 @@ Driver::MainLoop ()
{
if (event_type & SBCommandInterpreter::eBroadcastBitQuitCommandReceived)
done = true;
+ else if (event_type & SBCommandInterpreter::eBroadcastBitAsynchronousErrorData)
+ {
+ const char *data = SBEvent::GetCStringFromEvent (event);
+ m_io_channel_ap->ErrWrite (data, strlen(data), ASYNC);
+ }
+ else if (event_type & SBCommandInterpreter::eBroadcastBitAsynchronousOutputData)
+ {
+ const char *data = SBEvent::GetCStringFromEvent (event);
+ m_io_channel_ap->OutWrite (data, strlen(data), ASYNC);
+ }
}
}
}
diff --git a/lldb/tools/driver/IOChannel.cpp b/lldb/tools/driver/IOChannel.cpp
index 6c2c3d9cc98..4db5affb111 100644
--- a/lldb/tools/driver/IOChannel.cpp
+++ b/lldb/tools/driver/IOChannel.cpp
@@ -171,7 +171,8 @@ IOChannel::IOChannel
m_history_event(),
m_getting_command (false),
m_expecting_prompt (false),
- m_prompt_str ()
+ m_prompt_str (),
+ m_refresh_request_pending (false)
{
assert (m_edit_line);
::el_set (m_edit_line, EL_PROMPT, el_prompt);
@@ -257,6 +258,7 @@ IOChannel::LibeditOutputBytesReceived (void *baton, const void *src, size_t src_
// Make this a member variable.
// static std::string prompt_str;
IOChannel *io_channel = (IOChannel *) baton;
+ IOLocker locker (io_channel->m_output_mutex);
const char *bytes = (const char *) src;
if (io_channel->IsGettingCommand() && io_channel->m_expecting_prompt)
@@ -266,17 +268,19 @@ IOChannel::LibeditOutputBytesReceived (void *baton, const void *src, size_t src_
if (io_channel->m_prompt_str.find (el_prompt(io_channel->m_edit_line)) == 0)
{
io_channel->m_expecting_prompt = false;
+ io_channel->m_refresh_request_pending = false;
io_channel->OutWrite (io_channel->m_prompt_str.c_str(),
io_channel->m_prompt_str.size(), NO_ASYNC);
io_channel->m_prompt_str.clear();
}
- else
- assert (io_channel->m_prompt_str.find (el_prompt(io_channel->m_edit_line)) == std::string::npos);
}
else
{
if (io_channel->m_prompt_str.size() > 0)
io_channel->m_prompt_str.clear();
+ std::string tmp_str (bytes, src_len);
+ if (tmp_str.find (el_prompt (io_channel->m_edit_line)) == 0)
+ io_channel->m_refresh_request_pending = false;
io_channel->OutWrite (bytes, src_len, NO_ASYNC);
}
}
@@ -342,9 +346,7 @@ IOChannel::Run ()
listener.StartListeningForEvents (interpreter_broadcaster,
SBCommandInterpreter::eBroadcastBitResetPrompt |
SBCommandInterpreter::eBroadcastBitThreadShouldExit |
- SBCommandInterpreter::eBroadcastBitQuitCommandReceived |
- SBCommandInterpreter::eBroadcastBitAsynchronousOutputData |
- SBCommandInterpreter::eBroadcastBitAsynchronousErrorData);
+ SBCommandInterpreter::eBroadcastBitQuitCommandReceived);
listener.StartListeningForEvents (*this,
IOChannel::eBroadcastBitThreadShouldExit);
@@ -418,18 +420,6 @@ IOChannel::Run ()
case SBCommandInterpreter::eBroadcastBitQuitCommandReceived:
done = true;
break;
- case SBCommandInterpreter::eBroadcastBitAsynchronousErrorData:
- {
- const char *data = SBEvent::GetCStringFromEvent (event);
- ErrWrite (data, strlen(data), ASYNC);
- }
- break;
- case SBCommandInterpreter::eBroadcastBitAsynchronousOutputData:
- {
- const char *data = SBEvent::GetCStringFromEvent (event);
- OutWrite (data, strlen(data), ASYNC);
- }
- break;
}
}
else if (event.BroadcasterMatchesPtr (this))
@@ -482,7 +472,7 @@ IOChannel::RefreshPrompt ()
{
// If we are not in the middle of getting input from the user, there is no need to
// refresh the prompt.
-
+ IOLocker locker (m_output_mutex);
if (! IsGettingCommand())
return;
@@ -490,7 +480,11 @@ IOChannel::RefreshPrompt ()
if (m_expecting_prompt)
return;
+ if (m_refresh_request_pending)
+ return;
+
::el_set (m_edit_line, EL_REFRESH);
+ m_refresh_request_pending = true;
}
void
diff --git a/lldb/tools/driver/IOChannel.h b/lldb/tools/driver/IOChannel.h
index 886de1b5ba1..9e3f7387437 100644
--- a/lldb/tools/driver/IOChannel.h
+++ b/lldb/tools/driver/IOChannel.h
@@ -122,6 +122,7 @@ private:
bool m_getting_command;
bool m_expecting_prompt;
std::string m_prompt_str; // for accumlating the prompt as it gets written out by editline
+ bool m_refresh_request_pending;
void
HistorySaveLoad (bool save);
OpenPOWER on IntegriCloud