forked from OSchip/llvm-project
<rdar://problem/13764135>
The "lldb" driver was interfering with STDOUT and STDERR if the output was over 1024 charcters long. The output was grabbing 1024 characters at a time, before it output the characters, it was writing characters to the screen to clear the current line. This has been fixed. I also fixed the command interpreter from mixing the "(lldb) " prompt in with program output by always manually checking for program output. This was done by having the command interpreter know when it is in the middle of executing a command by setting a bool. This was needed since sometimes when a command would run the target, like with a command like 'expression (int)printf("hello\n")', the process would push a new input reader, and then pop it when it was done. This popping of the input reader would cause the command interpreter to get sent a reactivated message (from the private process state thread) and cause it to ask for another command, even though we were still in the middle of the command ('expression (int)printf("hello\n")'). Now we set a bool to true, run the command and set the bool to false. If we get reactivated while we are in the middle of a command, we don't say we are ready for a new command. This coupled with emitting the STDOUT/STDERR first after each command, followed by the command results, followed by then saying we are ready for a new command, should help cleanup the command line output on all platforms. llvm-svn: 181807
This commit is contained in:
parent
ba6a0960ea
commit
eea37eed5d
|
@ -120,6 +120,7 @@ Driver::Driver () :
|
||||||
m_editline_reader (),
|
m_editline_reader (),
|
||||||
m_io_channel_ap (),
|
m_io_channel_ap (),
|
||||||
m_option_data (),
|
m_option_data (),
|
||||||
|
m_executing_user_command (false),
|
||||||
m_waiting_for_command (false),
|
m_waiting_for_command (false),
|
||||||
m_done(false)
|
m_done(false)
|
||||||
{
|
{
|
||||||
|
@ -775,7 +776,7 @@ Driver::GetProcessSTDOUT ()
|
||||||
size_t total_bytes = 0;
|
size_t total_bytes = 0;
|
||||||
while ((len = m_debugger.GetSelectedTarget().GetProcess().GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0)
|
while ((len = m_debugger.GetSelectedTarget().GetProcess().GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0)
|
||||||
{
|
{
|
||||||
m_io_channel_ap->OutWrite (stdio_buffer, len, ASYNC);
|
m_io_channel_ap->OutWrite (stdio_buffer, len, NO_ASYNC);
|
||||||
total_bytes += len;
|
total_bytes += len;
|
||||||
}
|
}
|
||||||
return total_bytes;
|
return total_bytes;
|
||||||
|
@ -790,7 +791,7 @@ Driver::GetProcessSTDERR ()
|
||||||
size_t total_bytes = 0;
|
size_t total_bytes = 0;
|
||||||
while ((len = m_debugger.GetSelectedTarget().GetProcess().GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0)
|
while ((len = m_debugger.GetSelectedTarget().GetProcess().GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0)
|
||||||
{
|
{
|
||||||
m_io_channel_ap->ErrWrite (stdio_buffer, len, ASYNC);
|
m_io_channel_ap->ErrWrite (stdio_buffer, len, NO_ASYNC);
|
||||||
total_bytes += len;
|
total_bytes += len;
|
||||||
}
|
}
|
||||||
return total_bytes;
|
return total_bytes;
|
||||||
|
@ -1069,17 +1070,28 @@ Driver::HandleIOEvent (const SBEvent &event)
|
||||||
|
|
||||||
// We don't want the result to bypass the OutWrite function in IOChannel, as this can result in odd
|
// We don't want the result to bypass the OutWrite function in IOChannel, as this can result in odd
|
||||||
// output orderings and problems with the prompt.
|
// output orderings and problems with the prompt.
|
||||||
|
|
||||||
|
// Note that we are in the process of executing a command
|
||||||
|
m_executing_user_command = true;
|
||||||
|
|
||||||
m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true);
|
m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true);
|
||||||
|
|
||||||
|
// Note that we are back from executing a user command
|
||||||
|
m_executing_user_command = false;
|
||||||
|
|
||||||
|
// Display any STDOUT/STDERR _prior_ to emitting the command result text
|
||||||
|
GetProcessSTDOUT ();
|
||||||
|
GetProcessSTDERR ();
|
||||||
|
|
||||||
const bool only_if_no_immediate = true;
|
const bool only_if_no_immediate = true;
|
||||||
|
|
||||||
|
// Now emit the command output text from the command we just executed
|
||||||
const size_t output_size = result.GetOutputSize();
|
const size_t output_size = result.GetOutputSize();
|
||||||
|
|
||||||
if (output_size > 0)
|
if (output_size > 0)
|
||||||
m_io_channel_ap->OutWrite (result.GetOutput(only_if_no_immediate), output_size, NO_ASYNC);
|
m_io_channel_ap->OutWrite (result.GetOutput(only_if_no_immediate), output_size, NO_ASYNC);
|
||||||
|
|
||||||
|
// Now emit the command error text from the command we just executed
|
||||||
const size_t error_size = result.GetErrorSize();
|
const size_t error_size = result.GetErrorSize();
|
||||||
|
|
||||||
if (error_size > 0)
|
if (error_size > 0)
|
||||||
m_io_channel_ap->OutWrite (result.GetError(only_if_no_immediate), error_size, NO_ASYNC);
|
m_io_channel_ap->OutWrite (result.GetError(only_if_no_immediate), error_size, NO_ASYNC);
|
||||||
|
|
||||||
|
@ -1149,7 +1161,8 @@ Driver::EditLineInputReaderCallback
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInputReaderReactivate:
|
case eInputReaderReactivate:
|
||||||
driver->ReadyForCommand();
|
if (driver->m_executing_user_command == false)
|
||||||
|
driver->ReadyForCommand();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInputReaderDeactivate:
|
case eInputReaderDeactivate:
|
||||||
|
|
|
@ -162,6 +162,7 @@ private:
|
||||||
lldb::SBInputReader m_editline_reader;
|
lldb::SBInputReader m_editline_reader;
|
||||||
std::unique_ptr<IOChannel> m_io_channel_ap;
|
std::unique_ptr<IOChannel> m_io_channel_ap;
|
||||||
OptionData m_option_data;
|
OptionData m_option_data;
|
||||||
|
bool m_executing_user_command;
|
||||||
bool m_waiting_for_command;
|
bool m_waiting_for_command;
|
||||||
bool m_done;
|
bool m_done;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue