From a6faf851f49c7d50e92b16ff9d2e7c02790dd0f8 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 14 Jan 2020 22:27:00 -0800 Subject: [PATCH] [lldb/CommandInterpreter] Remove flag that's always true (NFC) The 'asynchronously' argument to both GetLLDBCommandsFromIOHandler and GetPythonCommandsFromIOHandler is true for all call sites. This commit simplifies the API by dropping it and giving the baton a default argument. --- lldb/include/lldb/Interpreter/CommandInterpreter.h | 5 +++-- lldb/source/Commands/CommandObjectBreakpointCommand.cpp | 1 - lldb/source/Commands/CommandObjectCommands.cpp | 7 ++----- lldb/source/Commands/CommandObjectTarget.cpp | 8 ++------ lldb/source/Commands/CommandObjectType.cpp | 2 -- lldb/source/Commands/CommandObjectWatchpointCommand.cpp | 1 - lldb/source/Interpreter/CommandInterpreter.cpp | 16 ++++------------ .../ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 4 ++-- 8 files changed, 13 insertions(+), 31 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 13bde72..d08951e 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -428,13 +428,14 @@ public: void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread, CommandInterpreterRunOptions &options); + void GetLLDBCommandsFromIOHandler(const char *prompt, IOHandlerDelegate &delegate, - bool asynchronously, void *baton); + void *baton = nullptr); void GetPythonCommandsFromIOHandler(const char *prompt, IOHandlerDelegate &delegate, - bool asynchronously, void *baton); + void *baton = nullptr); const char *GetCommandPrefix(); diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index 551d0ac..bbd2ca5 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -256,7 +256,6 @@ are no syntax errors may indicate that a function was declared but never called. m_interpreter.GetLLDBCommandsFromIOHandler( "> ", // Prompt *this, // IOHandlerDelegate - true, // Run IOHandler in async mode &bp_options_vec); // Baton for the "io_handler" that will be passed back // into our IOHandlerDelegate functions } diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 1796b6b..388db6f 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1650,11 +1650,8 @@ protected: if (m_options.m_class_name.empty()) { if (m_options.m_funct_name.empty()) { m_interpreter.GetPythonCommandsFromIOHandler( - " ", // Prompt - *this, // IOHandlerDelegate - true, // Run IOHandler in async mode - nullptr); // Baton for the "io_handler" that will be passed back - // into our IOHandlerDelegate functions + " ", // Prompt + *this); // IOHandlerDelegate } else { CommandObjectSP new_cmd(new CommandObjectPythonFunction( m_interpreter, m_cmd_name, m_options.m_funct_name, diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 8a5f75a..8738e85 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -4686,12 +4686,8 @@ protected: new_hook_sp->GetID()); } else { m_stop_hook_sp = new_hook_sp; - m_interpreter.GetLLDBCommandsFromIOHandler( - "> ", // Prompt - *this, // IOHandlerDelegate - true, // Run IOHandler in async mode - nullptr); // Baton for the "io_handler" that will be passed back - // into our IOHandlerDelegate functions + m_interpreter.GetLLDBCommandsFromIOHandler("> ", // Prompt + *this); // IOHandlerDelegate } result.SetStatus(eReturnStatusSuccessFinishNoResult); diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index d24f911..87c107c 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -1332,7 +1332,6 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary( m_interpreter.GetPythonCommandsFromIOHandler( " ", // Prompt *this, // IOHandlerDelegate - true, // Run IOHandler in async mode options); // Baton for the "io_handler" that will be passed back into // our IOHandlerDelegate functions result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -2232,7 +2231,6 @@ bool CommandObjectTypeSynthAdd::Execute_HandwritePython( m_interpreter.GetPythonCommandsFromIOHandler( " ", // Prompt *this, // IOHandlerDelegate - true, // Run IOHandler in async mode options); // Baton for the "io_handler" that will be passed back into our // IOHandlerDelegate functions result.SetStatus(eReturnStatusSuccessFinishNoResult); diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp index 4cc74e7..1b83e88 100644 --- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp @@ -243,7 +243,6 @@ are no syntax errors may indicate that a function was declared but never called. m_interpreter.GetLLDBCommandsFromIOHandler( "> ", // Prompt *this, // IOHandlerDelegate - true, // Run IOHandler in async mode wp_options); // Baton for the "io_handler" that will be passed back into // our IOHandlerDelegate functions } diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 7c2739f..1ee8050 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2839,8 +2839,7 @@ bool CommandInterpreter::IOHandlerInterrupt(IOHandler &io_handler) { } void CommandInterpreter::GetLLDBCommandsFromIOHandler( - const char *prompt, IOHandlerDelegate &delegate, bool asynchronously, - void *baton) { + const char *prompt, IOHandlerDelegate &delegate, void *baton) { Debugger &debugger = GetDebugger(); IOHandlerSP io_handler_sp( new IOHandlerEditline(debugger, IOHandler::Type::CommandList, @@ -2855,16 +2854,12 @@ void CommandInterpreter::GetLLDBCommandsFromIOHandler( if (io_handler_sp) { io_handler_sp->SetUserData(baton); - if (asynchronously) - debugger.PushIOHandler(io_handler_sp); - else - debugger.RunIOHandler(io_handler_sp); + debugger.PushIOHandler(io_handler_sp); } } void CommandInterpreter::GetPythonCommandsFromIOHandler( - const char *prompt, IOHandlerDelegate &delegate, bool asynchronously, - void *baton) { + const char *prompt, IOHandlerDelegate &delegate, void *baton) { Debugger &debugger = GetDebugger(); IOHandlerSP io_handler_sp( new IOHandlerEditline(debugger, IOHandler::Type::PythonCode, @@ -2879,10 +2874,7 @@ void CommandInterpreter::GetPythonCommandsFromIOHandler( if (io_handler_sp) { io_handler_sp->SetUserData(baton); - if (asynchronously) - debugger.PushIOHandler(io_handler_sp); - else - debugger.RunIOHandler(io_handler_sp); + debugger.PushIOHandler(io_handler_sp); } } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 1bb3cde..06e0d5bf 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1248,14 +1248,14 @@ void ScriptInterpreterPythonImpl::CollectDataForBreakpointCommandCallback( CommandReturnObject &result) { m_active_io_handler = eIOHandlerBreakpoint; m_debugger.GetCommandInterpreter().GetPythonCommandsFromIOHandler( - " ", *this, true, &bp_options_vec); + " ", *this, &bp_options_vec); } void ScriptInterpreterPythonImpl::CollectDataForWatchpointCommandCallback( WatchpointOptions *wp_options, CommandReturnObject &result) { m_active_io_handler = eIOHandlerWatchpoint; m_debugger.GetCommandInterpreter().GetPythonCommandsFromIOHandler( - " ", *this, true, wp_options); + " ", *this, wp_options); } Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallbackFunction( -- 2.7.4