@@ -708,7 +708,7 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
708708 m_source_manager_up(), m_source_file_cache(),
709709 m_command_interpreter_up(
710710 std::make_unique<CommandInterpreter>(*this , false )),
711- m_input_reader_stack (), m_instance_name(), m_loaded_plugins(),
711+ m_io_handler_stack (), m_instance_name(), m_loaded_plugins(),
712712 m_event_handler_thread(), m_io_handler_thread(),
713713 m_sync_broadcaster(nullptr , " lldb.debugger.sync" ),
714714 m_forward_listener_sp(), m_clear_once() {
@@ -870,41 +870,41 @@ ExecutionContext Debugger::GetSelectedExecutionContext() {
870870}
871871
872872void Debugger::DispatchInputInterrupt () {
873- std::lock_guard<std::recursive_mutex> guard (m_input_reader_stack .GetMutex ());
874- IOHandlerSP reader_sp (m_input_reader_stack .Top ());
873+ std::lock_guard<std::recursive_mutex> guard (m_io_handler_stack .GetMutex ());
874+ IOHandlerSP reader_sp (m_io_handler_stack .Top ());
875875 if (reader_sp)
876876 reader_sp->Interrupt ();
877877}
878878
879879void Debugger::DispatchInputEndOfFile () {
880- std::lock_guard<std::recursive_mutex> guard (m_input_reader_stack .GetMutex ());
881- IOHandlerSP reader_sp (m_input_reader_stack .Top ());
880+ std::lock_guard<std::recursive_mutex> guard (m_io_handler_stack .GetMutex ());
881+ IOHandlerSP reader_sp (m_io_handler_stack .Top ());
882882 if (reader_sp)
883883 reader_sp->GotEOF ();
884884}
885885
886886void Debugger::ClearIOHandlers () {
887887 // The bottom input reader should be the main debugger input reader. We do
888888 // not want to close that one here.
889- std::lock_guard<std::recursive_mutex> guard (m_input_reader_stack .GetMutex ());
890- while (m_input_reader_stack .GetSize () > 1 ) {
891- IOHandlerSP reader_sp (m_input_reader_stack .Top ());
889+ std::lock_guard<std::recursive_mutex> guard (m_io_handler_stack .GetMutex ());
890+ while (m_io_handler_stack .GetSize () > 1 ) {
891+ IOHandlerSP reader_sp (m_io_handler_stack .Top ());
892892 if (reader_sp)
893893 PopIOHandler (reader_sp);
894894 }
895895}
896896
897897void Debugger::ExecuteIOHandlers () {
898898 while (true ) {
899- IOHandlerSP reader_sp (m_input_reader_stack .Top ());
899+ IOHandlerSP reader_sp (m_io_handler_stack .Top ());
900900 if (!reader_sp)
901901 break ;
902902
903903 reader_sp->Run ();
904904
905905 // Remove all input readers that are done from the top of the stack
906906 while (true ) {
907- IOHandlerSP top_reader_sp = m_input_reader_stack .Top ();
907+ IOHandlerSP top_reader_sp = m_io_handler_stack .Top ();
908908 if (top_reader_sp && top_reader_sp->GetIsDone ())
909909 PopIOHandler (top_reader_sp);
910910 else
@@ -915,33 +915,42 @@ void Debugger::ExecuteIOHandlers() {
915915}
916916
917917bool Debugger::IsTopIOHandler (const lldb::IOHandlerSP &reader_sp) {
918- return m_input_reader_stack .IsTop (reader_sp);
918+ return m_io_handler_stack .IsTop (reader_sp);
919919}
920920
921921bool Debugger::CheckTopIOHandlerTypes (IOHandler::Type top_type,
922922 IOHandler::Type second_top_type) {
923- return m_input_reader_stack .CheckTopIOHandlerTypes (top_type, second_top_type);
923+ return m_io_handler_stack .CheckTopIOHandlerTypes (top_type, second_top_type);
924924}
925925
926926void Debugger::PrintAsync (const char *s, size_t len, bool is_stdout) {
927927 lldb_private::StreamFile &stream =
928928 is_stdout ? GetOutputStream () : GetErrorStream ();
929- m_input_reader_stack .PrintAsync (&stream, s, len);
929+ m_io_handler_stack .PrintAsync (&stream, s, len);
930930}
931931
932932ConstString Debugger::GetTopIOHandlerControlSequence (char ch) {
933- return m_input_reader_stack .GetTopIOHandlerControlSequence (ch);
933+ return m_io_handler_stack .GetTopIOHandlerControlSequence (ch);
934934}
935935
936936const char *Debugger::GetIOHandlerCommandPrefix () {
937- return m_input_reader_stack .GetTopIOHandlerCommandPrefix ();
937+ return m_io_handler_stack .GetTopIOHandlerCommandPrefix ();
938938}
939939
940940const char *Debugger::GetIOHandlerHelpPrologue () {
941- return m_input_reader_stack .GetTopIOHandlerHelpPrologue ();
941+ return m_io_handler_stack .GetTopIOHandlerHelpPrologue ();
942942}
943943
944- void Debugger::RunIOHandler (const IOHandlerSP &reader_sp) {
944+ bool Debugger::RemoveIOHandler (const IOHandlerSP &reader_sp) {
945+ return PopIOHandler (reader_sp);
946+ }
947+
948+ void Debugger::RunIOHandlerAsync (const IOHandlerSP &reader_sp,
949+ bool cancel_top_handler) {
950+ PushIOHandler (reader_sp, cancel_top_handler);
951+ }
952+
953+ void Debugger::RunIOHandlerSync (const IOHandlerSP &reader_sp) {
945954 PushIOHandler (reader_sp);
946955
947956 IOHandlerSP top_reader_sp = reader_sp;
@@ -954,7 +963,7 @@ void Debugger::RunIOHandler(const IOHandlerSP &reader_sp) {
954963 }
955964
956965 while (true ) {
957- top_reader_sp = m_input_reader_stack .Top ();
966+ top_reader_sp = m_io_handler_stack .Top ();
958967 if (top_reader_sp && top_reader_sp->GetIsDone ())
959968 PopIOHandler (top_reader_sp);
960969 else
@@ -970,8 +979,8 @@ void Debugger::AdoptTopIOHandlerFilesIfInvalid(FileSP &in, StreamFileSP &out,
970979 // input reader's in/out/err streams, or fall back to the debugger file
971980 // handles, or we fall back onto stdin/stdout/stderr as a last resort.
972981
973- std::lock_guard<std::recursive_mutex> guard (m_input_reader_stack .GetMutex ());
974- IOHandlerSP top_reader_sp (m_input_reader_stack .Top ());
982+ std::lock_guard<std::recursive_mutex> guard (m_io_handler_stack .GetMutex ());
983+ IOHandlerSP top_reader_sp (m_io_handler_stack .Top ());
975984 // If no STDIN has been set, then set it appropriately
976985 if (!in || !in->IsValid ()) {
977986 if (top_reader_sp)
@@ -1009,17 +1018,17 @@ void Debugger::PushIOHandler(const IOHandlerSP &reader_sp,
10091018 if (!reader_sp)
10101019 return ;
10111020
1012- std::lock_guard<std::recursive_mutex> guard (m_input_reader_stack .GetMutex ());
1021+ std::lock_guard<std::recursive_mutex> guard (m_io_handler_stack .GetMutex ());
10131022
10141023 // Get the current top input reader...
1015- IOHandlerSP top_reader_sp (m_input_reader_stack .Top ());
1024+ IOHandlerSP top_reader_sp (m_io_handler_stack .Top ());
10161025
10171026 // Don't push the same IO handler twice...
10181027 if (reader_sp == top_reader_sp)
10191028 return ;
10201029
10211030 // Push our new input reader
1022- m_input_reader_stack .Push (reader_sp);
1031+ m_io_handler_stack .Push (reader_sp);
10231032 reader_sp->Activate ();
10241033
10251034 // Interrupt the top input reader to it will exit its Run() function and let
@@ -1035,23 +1044,23 @@ bool Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp) {
10351044 if (!pop_reader_sp)
10361045 return false ;
10371046
1038- std::lock_guard<std::recursive_mutex> guard (m_input_reader_stack .GetMutex ());
1047+ std::lock_guard<std::recursive_mutex> guard (m_io_handler_stack .GetMutex ());
10391048
10401049 // The reader on the stop of the stack is done, so let the next read on the
10411050 // stack refresh its prompt and if there is one...
1042- if (m_input_reader_stack .IsEmpty ())
1051+ if (m_io_handler_stack .IsEmpty ())
10431052 return false ;
10441053
1045- IOHandlerSP reader_sp (m_input_reader_stack .Top ());
1054+ IOHandlerSP reader_sp (m_io_handler_stack .Top ());
10461055
10471056 if (pop_reader_sp != reader_sp)
10481057 return false ;
10491058
10501059 reader_sp->Deactivate ();
10511060 reader_sp->Cancel ();
1052- m_input_reader_stack .Pop ();
1061+ m_io_handler_stack .Pop ();
10531062
1054- reader_sp = m_input_reader_stack .Top ();
1063+ reader_sp = m_io_handler_stack .Top ();
10551064 if (reader_sp)
10561065 reader_sp->Activate ();
10571066
0 commit comments