diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 4ff59d3bf969..349605d1fb1c 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -37,11 +37,9 @@ #include "lldb/Target/ThreadPlanStepRange.h" #include "lldb/Target/ThreadPlanStepInRange.h" - using namespace lldb; using namespace lldb_private; - //------------------------------------------------------------------------- // CommandObjectThreadBacktrace //------------------------------------------------------------------------- @@ -58,7 +56,7 @@ public: { } - ~CommandObjectIterateOverThreads() override {} + ~CommandObjectIterateOverThreads() override = default; bool DoExecute (Args& command, CommandReturnObject &result) override @@ -112,7 +110,6 @@ public: result.SetStatus (eReturnStatusFailed); return false; } - } for (uint32_t i = 0; i < num_args; i++) @@ -128,7 +125,6 @@ public: } protected: - // Override this to do whatever you need to do for one thread. // // If you return false, the iteration will stop, otherwise it will proceed. @@ -141,7 +137,6 @@ protected: ReturnStatus m_success_return = eReturnStatusSuccessFinishResult; bool m_add_return = true; - }; //------------------------------------------------------------------------- @@ -151,11 +146,9 @@ protected: class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads { public: - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { @@ -163,9 +156,7 @@ public: OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -206,7 +197,6 @@ public: default: error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); break; - } return error; } @@ -236,22 +226,20 @@ public: }; CommandObjectThreadBacktrace (CommandInterpreter &interpreter) : - CommandObjectIterateOverThreads (interpreter, - "thread backtrace", - "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.", - NULL, - eCommandRequiresProcess | - eCommandRequiresThread | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused ), + CommandObjectIterateOverThreads(interpreter, + "thread backtrace", + "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.", + nullptr, + eCommandRequiresProcess | + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options(interpreter) { } - ~CommandObjectThreadBacktrace() override - { - } + ~CommandObjectThreadBacktrace() override = default; Options * GetOptions () override @@ -317,10 +305,10 @@ protected: OptionDefinition CommandObjectThreadBacktrace::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, "How many frames to display (-1 for all)"}, -{ LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace"}, -{ LLDB_OPT_SET_1, false, "extended", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Show the extended backtrace, if available"}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "How many frames to display (-1 for all)"}, +{ LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace"}, +{ LLDB_OPT_SET_1, false, "extended", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Show the extended backtrace, if available"}, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; enum StepScope @@ -332,11 +320,9 @@ enum StepScope class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed { public: - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options (interpreter) { @@ -344,9 +330,7 @@ public: OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -383,19 +367,16 @@ public: break; case 'c': - { - m_step_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); - if (m_step_count == UINT32_MAX) - error.SetErrorStringWithFormat ("invalid step count '%s'", option_arg); - break; - } + m_step_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); + if (m_step_count == UINT32_MAX) + error.SetErrorStringWithFormat ("invalid step count '%s'", option_arg); break; + case 'C': - { - m_class_name.clear(); - m_class_name.assign(option_arg); - } + m_class_name.clear(); + m_class_name.assign(option_arg); break; + case 'm': { OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; @@ -413,24 +394,20 @@ public: break; } break; + case 'r': - { - m_avoid_regexp.clear(); - m_avoid_regexp.assign(option_arg); - } + m_avoid_regexp.clear(); + m_avoid_regexp.assign(option_arg); break; case 't': - { - m_step_in_target.clear(); - m_step_in_target.assign(option_arg); - - } + m_step_in_target.clear(); + m_step_in_target.assign(option_arg); break; + default: error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); break; - } return error; } @@ -444,7 +421,7 @@ public: // Check if we are in Non-Stop mode lldb::TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget(); - if (target_sp.get() != nullptr && target_sp->GetNonStopModeEnabled()) + if (target_sp && target_sp->GetNonStopModeEnabled()) m_run_mode = eOnlyThisThread; m_avoid_regexp.clear(); @@ -505,9 +482,7 @@ public: m_arguments.push_back (arg); } - ~CommandObjectThreadStepWithTypeAndScope () override - { - } + ~CommandObjectThreadStepWithTypeAndScope() override = default; Options * GetOptions () override @@ -523,12 +498,12 @@ protected: bool synchronous_execution = m_interpreter.GetSynchronous(); const uint32_t num_threads = process->GetThreadList().GetSize(); - Thread *thread = NULL; + Thread *thread = nullptr; if (command.GetArgumentCount() == 0) { thread = process->GetThreadList().GetSelectedThread().get(); - if (thread == NULL) + if (thread == nullptr) { result.AppendError ("no selected thread in process"); result.SetStatus (eReturnStatusFailed); @@ -546,7 +521,7 @@ protected: return false; } thread = process->GetThreadList().FindThreadByIndexID(step_thread_idx).get(); - if (thread == NULL) + if (thread == nullptr) { result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", step_thread_idx, num_threads); @@ -588,12 +563,7 @@ protected: if (m_options.m_run_mode == eAllThreads) bool_stop_other_threads = false; else if (m_options.m_run_mode == eOnlyDuringStepping) - { - if (m_step_type == eStepTypeOut || m_step_type == eStepTypeScripted) - bool_stop_other_threads = false; - else - bool_stop_other_threads = true; - } + bool_stop_other_threads = (m_step_type != eStepTypeOut && m_step_type != eStepTypeScripted); else bool_stop_other_threads = true; @@ -639,7 +609,6 @@ protected: } else new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads); - } else if (m_step_type == eStepTypeOver) { @@ -655,7 +624,6 @@ protected: new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (true, abort_other_plans, bool_stop_other_threads); - } else if (m_step_type == eStepTypeTrace) { @@ -667,14 +635,14 @@ protected: } else if (m_step_type == eStepTypeOut) { - new_plan_sp = thread->QueueThreadPlanForStepOut (abort_other_plans, - NULL, - false, - bool_stop_other_threads, - eVoteYes, - eVoteNoOpinion, - thread->GetSelectedFrameIndex(), - m_options.m_step_out_avoid_no_debug); + new_plan_sp = thread->QueueThreadPlanForStepOut(abort_other_plans, + nullptr, + false, + bool_stop_other_threads, + eVoteYes, + eVoteNoOpinion, + thread->GetSelectedFrameIndex(), + m_options.m_step_out_avoid_no_debug); } else if (m_step_type == eStepTypeScripted) { @@ -705,7 +673,6 @@ protected: } } - process->GetThreadList().SetSelectedThreadByID (thread->GetID()); const uint32_t iohandler_id = process->GetIOHandlerID(); @@ -757,7 +724,7 @@ g_tri_running_mode[] = { eOnlyThisThread, "this-thread", "Run only this thread"}, { eAllThreads, "all-threads", "Run all threads"}, { eOnlyDuringStepping, "while-stepping", "Run only this thread while stepping"}, -{ 0, NULL, NULL } +{ 0, nullptr, nullptr } }; static OptionEnumValueElement @@ -765,24 +732,23 @@ g_duo_running_mode[] = { { eOnlyThisThread, "this-thread", "Run only this thread"}, { eAllThreads, "all-threads", "Run all threads"}, -{ 0, NULL, NULL } +{ 0, nullptr, nullptr } }; OptionDefinition CommandObjectThreadStepWithTypeAndScope::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "step-in-avoids-no-debug", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "A boolean value that sets whether stepping into functions will step over functions with no debug information."}, -{ LLDB_OPT_SET_1, false, "step-out-avoids-no-debug", 'A', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "A boolean value, if true stepping out of functions will continue to step out till it hits a function with debug information."}, -{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 1, eArgTypeCount, "How many times to perform the stepping operation - currently only supported for step-inst and next-inst."}, -{ LLDB_OPT_SET_1, false, "end-linenumber", 'e', OptionParser::eRequiredArgument, NULL, NULL, 1, eArgTypeLineNum, "The line at which to stop stepping - defaults to the next line and only supported for step-in and step-over."}, -{ LLDB_OPT_SET_1, false, "run-mode", 'm', OptionParser::eRequiredArgument, NULL, g_tri_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread."}, -{ LLDB_OPT_SET_1, false, "step-over-regexp", 'r', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeRegularExpression, "A regular expression that defines function names to not to stop at when stepping in."}, -{ LLDB_OPT_SET_1, false, "step-in-target", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFunctionName, "The name of the directly called function step in should stop at when stepping into."}, -{ LLDB_OPT_SET_2, false, "python-class", 'C', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonClass, "The name of the class that will manage this step - only supported for Scripted Step."}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_1, false, "step-in-avoids-no-debug", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "A boolean value that sets whether stepping into functions will step over functions with no debug information."}, +{ LLDB_OPT_SET_1, false, "step-out-avoids-no-debug", 'A', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "A boolean value, if true stepping out of functions will continue to step out till it hits a function with debug information."}, +{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 1, eArgTypeCount, "How many times to perform the stepping operation - currently only supported for step-inst and next-inst."}, +{ LLDB_OPT_SET_1, false, "end-linenumber", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 1, eArgTypeLineNum, "The line at which to stop stepping - defaults to the next line and only supported for step-in and step-over."}, +{ LLDB_OPT_SET_1, false, "run-mode", 'm', OptionParser::eRequiredArgument, nullptr, g_tri_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread."}, +{ LLDB_OPT_SET_1, false, "step-over-regexp", 'r', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeRegularExpression, "A regular expression that defines function names to not to stop at when stepping in."}, +{ LLDB_OPT_SET_1, false, "step-in-target", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFunctionName, "The name of the directly called function step in should stop at when stepping into."}, +{ LLDB_OPT_SET_2, false, "python-class", 'C', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonClass, "The name of the class that will manage this step - only supported for Scripted Step."}, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; - //------------------------------------------------------------------------- // CommandObjectThreadContinue //------------------------------------------------------------------------- @@ -790,16 +756,15 @@ CommandObjectThreadStepWithTypeAndScope::CommandOptions::g_option_table[] = class CommandObjectThreadContinue : public CommandObjectParsed { public: - CommandObjectThreadContinue (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "thread continue", - "Continue execution of one or more threads in an active process.", - NULL, - eCommandRequiresThread | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused) + CommandObjectParsed(interpreter, + "thread continue", + "Continue execution of one or more threads in an active process.", + nullptr, + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused) { CommandArgumentEntry arg; CommandArgumentData thread_idx_arg; @@ -815,17 +780,14 @@ public: m_arguments.push_back (arg); } - - ~CommandObjectThreadContinue () override - { - } + ~CommandObjectThreadContinue() override = default; bool DoExecute (Args& command, CommandReturnObject &result) override { bool synchronous_execution = m_interpreter.GetSynchronous (); - if (!m_interpreter.GetDebugger().GetSelectedTarget().get()) + if (!m_interpreter.GetDebugger().GetSelectedTarget()) { result.AppendError ("invalid target, create a debug target using the 'target create' command"); result.SetStatus (eReturnStatusFailed); @@ -833,7 +795,7 @@ public: } Process *process = m_exe_ctx.GetProcessPtr(); - if (process == NULL) + if (process == nullptr) { result.AppendError ("no process exists. Cannot continue"); result.SetStatus (eReturnStatusFailed); @@ -852,7 +814,7 @@ public: Mutex::Locker locker (process->GetThreadList().GetMutex()); const uint32_t num_threads = process->GetThreadList().GetSize(); std::vector resume_threads; - for (uint32_t i=0; iGetThreadList().GetThreadAtIndex(idx).get(); std::vector::iterator this_thread_pos = find(resume_threads.begin(), resume_threads.end(), thread); @@ -901,7 +863,7 @@ public: if (this_thread_pos != resume_threads.end()) { resume_threads.erase(this_thread_pos); - if (resume_threads.size() > 0) + if (!resume_threads.empty()) result.AppendMessageWithFormat ("%u, ", thread->GetIndexID()); else result.AppendMessageWithFormat ("%u ", thread->GetIndexID()); @@ -925,14 +887,14 @@ public: Mutex::Locker locker (process->GetThreadList().GetMutex()); const uint32_t num_threads = process->GetThreadList().GetSize(); Thread *current_thread = process->GetThreadList().GetSelectedThread().get(); - if (current_thread == NULL) + if (current_thread == nullptr) { result.AppendError ("the process doesn't have a current thread"); result.SetStatus (eReturnStatusFailed); return false; } // Set the actions that the threads should each take when resuming - for (uint32_t idx=0; idxGetThreadList().GetThreadAtIndex(idx).get(); if (thread == current_thread) @@ -948,7 +910,6 @@ public: } } - StreamString stream; Error error; if (synchronous_execution) @@ -989,7 +950,6 @@ public: return result.Succeeded(); } - }; //------------------------------------------------------------------------- @@ -999,7 +959,6 @@ public: class CommandObjectThreadUntil : public CommandObjectParsed { public: - class CommandOptions : public Options { public: @@ -1015,9 +974,7 @@ public: OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -1036,23 +993,19 @@ public: } break; case 't': - { m_thread_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_INDEX32); if (m_thread_idx == LLDB_INVALID_INDEX32) { error.SetErrorStringWithFormat ("invalid thread index '%s'", option_arg); } - } - break; + break; case 'f': - { m_frame_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_FRAME_ID); if (m_frame_idx == LLDB_INVALID_FRAME_ID) { error.SetErrorStringWithFormat ("invalid frame index '%s'", option_arg); } - } - break; + break; case 'm': { OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; @@ -1070,7 +1023,6 @@ public: default: error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); break; - } return error; } @@ -1102,14 +1054,14 @@ public: }; CommandObjectThreadUntil (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "thread until", - "Run the current or specified thread until it reaches a given line number or address or leaves the current function.", - NULL, - eCommandRequiresThread | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused ), + CommandObjectParsed(interpreter, + "thread until", + "Run the current or specified thread until it reaches a given line number or address or leaves the current function.", + nullptr, + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options (interpreter) { CommandArgumentEntry arg; @@ -1126,10 +1078,7 @@ public: m_arguments.push_back (arg); } - - ~CommandObjectThreadUntil () override - { - } + ~CommandObjectThreadUntil() override = default; Options * GetOptions () override @@ -1144,7 +1093,7 @@ protected: bool synchronous_execution = m_interpreter.GetSynchronous (); Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - if (target == NULL) + if (target == nullptr) { result.AppendError ("invalid target, create a debug target using the 'target create' command"); result.SetStatus (eReturnStatusFailed); @@ -1152,15 +1101,14 @@ protected: } Process *process = m_exe_ctx.GetProcessPtr(); - if (process == NULL) + if (process == nullptr) { result.AppendError ("need a valid process to step"); result.SetStatus (eReturnStatusFailed); - } else { - Thread *thread = NULL; + Thread *thread = nullptr; std::vector line_numbers; if (command.GetArgumentCount() >= 1) @@ -1187,7 +1135,6 @@ protected: return false; } - if (m_options.m_thread_idx == LLDB_INVALID_THREAD_ID) { thread = process->GetThreadList().GetSelectedThread().get(); @@ -1197,7 +1144,7 @@ protected: thread = process->GetThreadList().FindThreadByIndexID(m_options.m_thread_idx).get(); } - if (thread == NULL) + if (thread == nullptr) { const uint32_t num_threads = process->GetThreadList().GetSize(); result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", @@ -1210,9 +1157,8 @@ protected: const bool abort_other_plans = false; StackFrame *frame = thread->GetStackFrameAtIndex(m_options.m_frame_idx).get(); - if (frame == NULL) + if (frame == nullptr) { - result.AppendErrorWithFormat ("Frame index %u is out of range for thread %u.\n", m_options.m_frame_idx, m_options.m_thread_idx); @@ -1226,11 +1172,11 @@ protected: { // Finally we got here... Translate the given line number to a bunch of addresses: SymbolContext sc(frame->GetSymbolContext (eSymbolContextCompUnit)); - LineTable *line_table = NULL; + LineTable *line_table = nullptr; if (sc.comp_unit) line_table = sc.comp_unit->GetLineTable(); - if (line_table == NULL) + if (line_table == nullptr) { result.AppendErrorWithFormat ("Failed to resolve the line table for frame %u of thread index %u.\n", m_options.m_frame_idx, m_options.m_thread_idx); @@ -1285,7 +1231,7 @@ protected: all_in_function = false; } - if (address_list.size() == 0) + if (address_list.empty()) { if (all_in_function) result.AppendErrorWithFormat ("No line entries matching until target.\n"); @@ -1314,11 +1260,8 @@ protected: m_options.m_thread_idx); result.SetStatus (eReturnStatusFailed); return false; - } - - process->GetThreadList().SetSelectedThreadByID (m_options.m_thread_idx); StreamString stream; @@ -1356,20 +1299,18 @@ protected: } CommandOptions m_options; - }; OptionDefinition CommandObjectThreadUntil::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0"}, -{ LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation"}, -{ LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, NULL, g_duo_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping this one"}, -{ LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Run until we reach the specified address, or leave the function - can be specified multiple times."}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0"}, +{ LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation"}, +{ LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, nullptr, g_duo_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping this one"}, +{ LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Run until we reach the specified address, or leave the function - can be specified multiple times."}, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; - //------------------------------------------------------------------------- // CommandObjectThreadSelect //------------------------------------------------------------------------- @@ -1377,16 +1318,15 @@ CommandObjectThreadUntil::CommandOptions::g_option_table[] = class CommandObjectThreadSelect : public CommandObjectParsed { public: - CommandObjectThreadSelect (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "thread select", - "Select a thread as the currently active thread.", - NULL, - eCommandRequiresProcess | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused ) + CommandObjectParsed(interpreter, + "thread select", + "Select a thread as the currently active thread.", + nullptr, + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ) { CommandArgumentEntry arg; CommandArgumentData thread_idx_arg; @@ -1402,17 +1342,14 @@ public: m_arguments.push_back (arg); } - - ~CommandObjectThreadSelect () override - { - } + ~CommandObjectThreadSelect() override = default; protected: bool DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); - if (process == NULL) + if (process == nullptr) { result.AppendError ("no process"); result.SetStatus (eReturnStatusFailed); @@ -1428,7 +1365,7 @@ protected: uint32_t index_id = StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0); Thread *new_thread = process->GetThreadList().FindThreadByIndexID(index_id).get(); - if (new_thread == NULL) + if (new_thread == nullptr) { result.AppendErrorWithFormat ("invalid thread #%s.\n", command.GetArgumentAtIndex(0)); result.SetStatus (eReturnStatusFailed); @@ -1440,10 +1377,8 @@ protected: return result.Succeeded(); } - }; - //------------------------------------------------------------------------- // CommandObjectThreadList //------------------------------------------------------------------------- @@ -1451,8 +1386,6 @@ protected: class CommandObjectThreadList : public CommandObjectParsed { public: - - CommandObjectThreadList (CommandInterpreter &interpreter): CommandObjectParsed (interpreter, "thread list", @@ -1465,9 +1398,7 @@ public: { } - ~CommandObjectThreadList() override - { - } + ~CommandObjectThreadList() override = default; protected: bool @@ -1497,31 +1428,17 @@ protected: class CommandObjectThreadInfo : public CommandObjectIterateOverThreads { public: - - CommandObjectThreadInfo (CommandInterpreter &interpreter) : - CommandObjectIterateOverThreads (interpreter, - "thread info", - "Show an extended summary of information about thread(s) in a process.", - "thread info", - eCommandRequiresProcess | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused), - m_options (interpreter) - { - m_add_return = false; - } - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options (interpreter) { OptionParsingStarting (); } + ~CommandOptions() override = default; + void OptionParsingStarting () override { @@ -1529,10 +1446,6 @@ public: m_json_stopinfo = false; } - ~CommandOptions () override - { - } - Error SetOptionValue (uint32_t option_idx, const char *option_arg) override { @@ -1551,7 +1464,6 @@ public: default: return Error("invalid short option character '%c'", short_option); - } return error; } @@ -1568,16 +1480,28 @@ public: static OptionDefinition g_option_table[]; }; + CommandObjectThreadInfo (CommandInterpreter &interpreter) : + CommandObjectIterateOverThreads (interpreter, + "thread info", + "Show an extended summary of information about thread(s) in a process.", + "thread info", + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused), + m_options (interpreter) + { + m_add_return = false; + } + + ~CommandObjectThreadInfo() override = default; + Options * GetOptions () override { return &m_options; } - ~CommandObjectThreadInfo () override - { - } - bool HandleOneThread (Thread &thread, CommandReturnObject &result) override { @@ -1592,19 +1516,17 @@ public: } CommandOptions m_options; - }; OptionDefinition CommandObjectThreadInfo::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "json",'j', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display the thread info in JSON format."}, - { LLDB_OPT_SET_ALL, false, "stop-info",'s', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display the extended stop info in JSON format."}, + { LLDB_OPT_SET_ALL, false, "json",'j', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display the thread info in JSON format."}, + { LLDB_OPT_SET_ALL, false, "stop-info",'s', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display the extended stop info in JSON format."}, - { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } + { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; - //------------------------------------------------------------------------- // CommandObjectThreadReturn //------------------------------------------------------------------------- @@ -1615,7 +1537,6 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options (interpreter), m_from_expression (false) @@ -1624,9 +1545,7 @@ public: OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -1651,7 +1570,6 @@ public: default: error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); break; - } return error; } @@ -1677,12 +1595,6 @@ public: // Instance variables to hold the values for command options. }; - Options * - GetOptions () override - { - return &m_options; - } - CommandObjectThreadReturn (CommandInterpreter &interpreter) : CommandObjectRaw (interpreter, "thread return", @@ -1707,16 +1619,17 @@ public: // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg); - - } - - ~CommandObjectThreadReturn() override - { - } - -protected: + ~CommandObjectThreadReturn() override = default; + + Options * + GetOptions() override + { + return &m_options; + } + +protected: bool DoExecute (const char *command, CommandReturnObject &result) override { @@ -1785,7 +1698,6 @@ protected: result.AppendErrorWithFormat("Unknown error evaluating result expression."); result.SetStatus (eReturnStatusFailed); return false; - } } @@ -1805,13 +1717,13 @@ protected: } CommandOptions m_options; - }; + OptionDefinition CommandObjectThreadReturn::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Return from the innermost expression evaluation."}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Return from the innermost expression evaluation."}, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -1824,13 +1736,14 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options (interpreter) { OptionParsingStarting (); } + ~CommandOptions() override = default; + void OptionParsingStarting () override { @@ -1841,10 +1754,6 @@ public: m_force = false; } - ~CommandOptions () override - { - } - Error SetOptionValue (uint32_t option_idx, const char *option_arg) override { @@ -1878,10 +1787,8 @@ public: case 'r': m_force = true; break; - default: return Error("invalid short option character '%c'", short_option); - } return error; } @@ -1901,12 +1808,6 @@ public: static OptionDefinition g_option_table[]; }; - Options * - GetOptions () override - { - return &m_options; - } - CommandObjectThreadJump (CommandInterpreter &interpreter) : CommandObjectParsed (interpreter, "thread jump", @@ -1920,12 +1821,15 @@ public: { } - ~CommandObjectThreadJump() override + ~CommandObjectThreadJump() override = default; + + Options * + GetOptions() override { + return &m_options; } protected: - bool DoExecute (Args& args, CommandReturnObject &result) override { RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext(); @@ -1992,44 +1896,43 @@ protected: CommandOptions m_options; }; + OptionDefinition CommandObjectThreadJump::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, + { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "Specifies the source file to jump to."}, - { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum, + { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum, "Specifies the line number to jump to."}, - { LLDB_OPT_SET_2, true, "by", 'b', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, + { LLDB_OPT_SET_2, true, "by", 'b', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "Jumps by a relative line offset from the current line."}, - { LLDB_OPT_SET_3, true, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, + { LLDB_OPT_SET_3, true, "address", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Jumps to a specific address."}, { LLDB_OPT_SET_1| LLDB_OPT_SET_2| - LLDB_OPT_SET_3, false, "force",'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,"Allows the PC to leave the current function."}, + LLDB_OPT_SET_3, false, "force",'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,"Allows the PC to leave the current function."}, - { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } + { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- // Next are the subcommands of CommandObjectMultiwordThreadPlan //------------------------------------------------------------------------- - //------------------------------------------------------------------------- // CommandObjectThreadPlanList //------------------------------------------------------------------------- + class CommandObjectThreadPlanList : public CommandObjectIterateOverThreads { public: - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { @@ -2037,9 +1940,7 @@ public: OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -2050,19 +1951,14 @@ public: switch (short_option) { case 'i': - { m_internal = true; - } - break; + break; case 'v': - { m_verbose = true; - } - break; + break; default: error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); break; - } return error; } @@ -2090,23 +1986,21 @@ public: }; CommandObjectThreadPlanList (CommandInterpreter &interpreter) : - CommandObjectIterateOverThreads (interpreter, - "thread plan list", - "Show thread plans for one or more threads. If no threads are specified, show the " - "currently selected thread. Use the thread-index \"all\" to see all threads.", - NULL, - eCommandRequiresProcess | - eCommandRequiresThread | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused ), + CommandObjectIterateOverThreads(interpreter, + "thread plan list", + "Show thread plans for one or more threads. If no threads are specified, show the " + "currently selected thread. Use the thread-index \"all\" to see all threads.", + nullptr, + eCommandRequiresProcess | + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options(interpreter) { } - ~CommandObjectThreadPlanList () override - { - } + ~CommandObjectThreadPlanList() override = default; Options * GetOptions () override @@ -2126,32 +2020,33 @@ protected: thread.DumpThreadPlans (&strm, desc_level, m_options.m_internal, true); return true; } + CommandOptions m_options; }; OptionDefinition CommandObjectThreadPlanList::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display more information about the thread plans"}, -{ LLDB_OPT_SET_1, false, "internal", 'i', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display internal as well as user thread plans"}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display more information about the thread plans"}, +{ LLDB_OPT_SET_1, false, "internal", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display internal as well as user thread plans"}, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; class CommandObjectThreadPlanDiscard : public CommandObjectParsed { public: CommandObjectThreadPlanDiscard (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "thread plan discard", - "Discards thread plans up to and including the plan passed as the command argument." - "Only user visible plans can be discarded, use the index from \"thread plan list\"" - " without the \"-i\" argument.", - NULL, - eCommandRequiresProcess | - eCommandRequiresThread | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused ) + CommandObjectParsed(interpreter, + "thread plan discard", + "Discards thread plans up to and including the plan passed as the command argument." + "Only user visible plans can be discarded, use the index from \"thread plan list\"" + " without the \"-i\" argument.", + nullptr, + eCommandRequiresProcess | + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ) { CommandArgumentEntry arg; CommandArgumentData plan_index_arg; @@ -2167,7 +2062,7 @@ public: m_arguments.push_back (arg); } - ~CommandObjectThreadPlanDiscard () override {} + ~CommandObjectThreadPlanDiscard() override = default; bool DoExecute (Args& args, CommandReturnObject &result) override @@ -2230,9 +2125,7 @@ public: LoadSubCommand ("discard", CommandObjectSP (new CommandObjectThreadPlanDiscard (interpreter))); } - ~CommandObjectMultiwordThreadPlan () override {} - - + ~CommandObjectMultiwordThreadPlan() override = default; }; //------------------------------------------------------------------------- @@ -2257,15 +2150,15 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter & interpreter, "thread step-in", "Source level single step in specified thread (current thread, if none specified).", - NULL, + nullptr, eStepTypeInto, eStepScopeSource))); - + LoadSubCommand ("step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( interpreter, "thread step-out", "Finish executing the function of the currently selected frame and return to its call site in specified thread (current thread, if none specified).", - NULL, + nullptr, eStepTypeOut, eStepScopeSource))); @@ -2273,7 +2166,7 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter & interpreter, "thread step-over", "Source level single step in specified thread (current thread, if none specified), stepping over calls.", - NULL, + nullptr, eStepTypeOver, eStepScopeSource))); @@ -2281,7 +2174,7 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter & interpreter, "thread step-inst", "Single step one instruction in specified thread (current thread, if none specified).", - NULL, + nullptr, eStepTypeTrace, eStepScopeInstruction))); @@ -2289,7 +2182,7 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter & interpreter, "thread step-inst-over", "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.", - NULL, + nullptr, eStepTypeTraceOver, eStepScopeInstruction))); @@ -2297,15 +2190,11 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter & interpreter, "thread step-scripted", "Step as instructed by the script class passed in the -C option.", - NULL, + nullptr, eStepTypeScripted, eStepScopeSource))); LoadSubCommand ("plan", CommandObjectSP (new CommandObjectMultiwordThreadPlan(interpreter))); } -CommandObjectMultiwordThread::~CommandObjectMultiwordThread () -{ -} - - +CommandObjectMultiwordThread::~CommandObjectMultiwordThread() = default;