diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2015-12-15 01:33:19 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2015-12-15 01:33:19 +0000 |
commit | e65b2cf2975891b83ecbfdc1d92fb89f248129e2 (patch) | |
tree | 02fb044f608cd6da5c3728fd235cc39c304723e0 | |
parent | 162b68d86f36bcb19875d0e83cadecd86380abeb (diff) | |
download | bcm5719-llvm-e65b2cf2975891b83ecbfdc1d92fb89f248129e2.tar.gz bcm5719-llvm-e65b2cf2975891b83ecbfdc1d92fb89f248129e2.zip |
Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/.
Simplify smart pointers checks in conditions. Other minor fixes.
llvm-svn: 255598
-rw-r--r-- | lldb/source/Target/TargetList.cpp | 40 | ||||
-rw-r--r-- | lldb/source/Target/Thread.cpp | 118 | ||||
-rw-r--r-- | lldb/source/Target/ThreadList.cpp | 5 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlan.cpp | 22 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanCallFunction.cpp | 28 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanRunToAddress.cpp | 5 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanShouldStopHere.cpp | 40 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanStepInRange.cpp | 30 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanStepInstruction.cpp | 30 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanStepOut.cpp | 57 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanStepOverRange.cpp | 38 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanStepRange.cpp | 43 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanStepThrough.cpp | 14 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanStepUntil.cpp | 32 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanTracer.cpp | 50 | ||||
-rw-r--r-- | lldb/source/Target/ThreadSpec.cpp | 24 |
17 files changed, 213 insertions, 376 deletions
diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index e8b055c2225..ffec758ac21 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -10,6 +10,8 @@ // C Includes // C++ Includes // Other libraries and framework includes +#include "llvm/ADT/SmallString.h" + // Project includes #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" @@ -27,8 +29,6 @@ #include "lldb/Target/Process.h" #include "lldb/Target/TargetList.h" -#include "llvm/ADT/SmallString.h" - using namespace lldb; using namespace lldb_private; @@ -227,7 +227,7 @@ TargetList::CreateTargetInternal (Debugger &debugger, // since the user may have specified it. if (platform_sp) { - if (platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, NULL)) + if (platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, nullptr)) { platforms.push_back(platform_sp); continue; @@ -237,7 +237,7 @@ TargetList::CreateTargetInternal (Debugger &debugger, // Next check the host platform it if wasn't already checked above if (host_platform_sp && (!platform_sp || host_platform_sp->GetName() != platform_sp->GetName())) { - if (host_platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, NULL)) + if (host_platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, nullptr)) { platforms.push_back(host_platform_sp); continue; @@ -253,7 +253,7 @@ TargetList::CreateTargetInternal (Debugger &debugger, } } - Platform *platform_ptr = NULL; + Platform *platform_ptr = nullptr; bool more_than_one_platforms = false; for (const auto &the_platform_sp : platforms) { @@ -262,7 +262,7 @@ TargetList::CreateTargetInternal (Debugger &debugger, if (platform_ptr->GetName() != the_platform_sp->GetName()) { more_than_one_platforms = true; - platform_ptr = NULL; + platform_ptr = nullptr; break; } } @@ -386,7 +386,6 @@ TargetList::CreateTargetInternal (Debugger &debugger, lldb::TargetSP &target_sp, bool is_dummy_target) { - Timer scoped_timer (__PRETTY_FUNCTION__, "TargetList::CreateTarget (file = '%s', arch = '%s')", user_exe_path, @@ -397,7 +396,7 @@ TargetList::CreateTargetInternal (Debugger &debugger, if (arch.IsValid()) { - if (!platform_sp || !platform_sp->IsCompatibleArchitecture(arch, false, NULL)) + if (!platform_sp || !platform_sp->IsCompatibleArchitecture(arch, false, nullptr)) platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch); } @@ -453,14 +452,14 @@ TargetList::CreateTargetInternal (Debugger &debugger, { FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths()); ModuleSpec module_spec(file, arch); - error = platform_sp->ResolveExecutable (module_spec, - exe_module_sp, - executable_search_paths.GetSize() ? &executable_search_paths : NULL); + error = platform_sp->ResolveExecutable(module_spec, + exe_module_sp, + executable_search_paths.GetSize() ? &executable_search_paths : nullptr); } if (error.Success() && exe_module_sp) { - if (exe_module_sp->GetObjectFile() == NULL) + if (exe_module_sp->GetObjectFile() == nullptr) { if (arch.IsValid()) { @@ -548,13 +547,9 @@ TargetList::DeleteTarget (TargetSP &target_sp) return false; } - TargetSP -TargetList::FindTargetWithExecutableAndArchitecture -( - const FileSpec &exe_file_spec, - const ArchSpec *exe_arch_ptr -) const +TargetList::FindTargetWithExecutableAndArchitecture(const FileSpec &exe_file_spec, + const ArchSpec *exe_arch_ptr) const { Mutex::Locker locker (m_target_list_mutex); TargetSP target_sp; @@ -600,7 +595,6 @@ TargetList::FindTargetWithProcessID (lldb::pid_t pid) const return target_sp; } - TargetSP TargetList::FindTargetWithProcess (Process *process) const { @@ -649,7 +643,7 @@ TargetList::SendAsyncInterrupt (lldb::pid_t pid) if (pid != LLDB_INVALID_PROCESS_ID) { TargetSP target_sp(FindTargetWithProcessID (pid)); - if (target_sp.get()) + if (target_sp) { Process* process = target_sp->GetProcessSP().get(); if (process) @@ -663,7 +657,7 @@ TargetList::SendAsyncInterrupt (lldb::pid_t pid) { // We don't have a valid pid to broadcast to, so broadcast to the target // list's async broadcaster... - BroadcastEvent (Process::eBroadcastBitInterrupt, NULL); + BroadcastEvent(Process::eBroadcastBitInterrupt, nullptr); } return num_async_interrupts_sent; @@ -673,7 +667,7 @@ uint32_t TargetList::SignalIfRunning (lldb::pid_t pid, int signo) { uint32_t num_signals_sent = 0; - Process *process = NULL; + Process *process = nullptr; if (pid == LLDB_INVALID_PROCESS_ID) { // Signal all processes with signal @@ -696,7 +690,7 @@ TargetList::SignalIfRunning (lldb::pid_t pid, int signo) { // Signal a specific process with signal TargetSP target_sp(FindTargetWithProcessID (pid)); - if (target_sp.get()) + if (target_sp) { process = target_sp->GetProcessSP().get(); if (process) diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index fab5afcf4cc..9f9da972660 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -67,13 +67,13 @@ Thread::GetGlobalProperties() static PropertyDefinition g_properties[] = { - { "step-in-avoid-nodebug", OptionValue::eTypeBoolean, true, true, NULL, NULL, "If true, step-in will not stop in functions with no debug information." }, - { "step-out-avoid-nodebug", OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, when step-in/step-out/step-over leave the current frame, they will continue to step out till they come to a function with " + { "step-in-avoid-nodebug", OptionValue::eTypeBoolean, true, true, nullptr, nullptr, "If true, step-in will not stop in functions with no debug information." }, + { "step-out-avoid-nodebug", OptionValue::eTypeBoolean, true, false, nullptr, nullptr, "If true, when step-in/step-out/step-over leave the current frame, they will continue to step out till they come to a function with " "debug information. Passing a frame argument to step-out will override this option." }, - { "step-avoid-regexp", OptionValue::eTypeRegex , true , 0, "^std::", NULL, "A regular expression defining functions step-in won't stop in." }, - { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , 0, NULL, NULL, "A list of libraries that source stepping won't stop in." }, - { "trace-thread", OptionValue::eTypeBoolean, false, false, NULL, NULL, "If true, this thread will single-step and log execution." }, - { NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL } + { "step-avoid-regexp", OptionValue::eTypeRegex , true , 0, "^std::", nullptr, "A regular expression defining functions step-in won't stop in." }, + { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , 0, nullptr, nullptr, "A list of libraries that source stepping won't stop in." }, + { "trace-thread", OptionValue::eTypeBoolean, false, false, nullptr, nullptr, "If true, this thread will single-step and log execution." }, + { nullptr , OptionValue::eTypeInvalid, false, 0 , nullptr, nullptr, nullptr } }; enum { @@ -138,14 +138,14 @@ const RegularExpression * ThreadProperties::GetSymbolsToAvoidRegexp() { const uint32_t idx = ePropertyStepAvoidRegex; - return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex (NULL, idx); + return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(nullptr, idx); } FileSpecList & ThreadProperties::GetLibrariesToAvoid() const { const uint32_t idx = ePropertyStepAvoidLibraries; - OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx); + OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx); assert(option_value); return option_value->GetCurrentValue(); } @@ -154,21 +154,21 @@ bool ThreadProperties::GetTraceEnabledState() const { const uint32_t idx = ePropertyEnableThreadTrace; - return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepInAvoidsNoDebug() const { const uint32_t idx = ePropertyStepInAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepOutAvoidsNoDebug() const { const uint32_t idx = ePropertyStepOutAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0); } //------------------------------------------------------------------ @@ -216,7 +216,7 @@ Thread::ThreadEventData::GetEventDataFromEvent (const Event *event_ptr) if (event_data && event_data->GetFlavor() == ThreadEventData::GetFlavorString()) return static_cast <const ThreadEventData *> (event_ptr->GetData()); } - return NULL; + return nullptr; } ThreadSP @@ -418,7 +418,7 @@ Thread::SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_strea void Thread::FunctionOptimizationWarning (StackFrame *frame) { - if (frame && frame->HasDebugInformation() && GetProcess()->GetWarningsOptimization() == true) + if (frame && frame->HasDebugInformation() && GetProcess()->GetWarningsOptimization()) { SymbolContext sc = frame->GetSymbolContext (eSymbolContextFunction | eSymbolContextModule); GetProcess()->PrintWarningOptimization (sc); @@ -477,7 +477,7 @@ Thread::GetPrivateStopInfo () if (!m_stop_info_sp) { - if (CalculateStopInfo() == false) + if (!CalculateStopInfo()) SetStopInfo (StopInfoSP()); } } @@ -761,7 +761,7 @@ Thread::ShouldResume (StateType resume_state) { need_to_resume = plan_ptr->WillResume(resume_state, true); - while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL) + while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr) { plan_ptr->WillResume (resume_state, false); } @@ -826,7 +826,7 @@ Thread::ShouldStop (Event* event_ptr) // thread caused the process to stop. NOTE: this must take place before // the plan is moved from the current plan stack to the completed plan // stack. - if (ThreadStoppedForAReason() == false) + if (!ThreadStoppedForAReason()) { if (log) log->Printf ("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", pc = 0x%16.16" PRIx64 ", should_stop = 0 (ignore since no stop reason)", @@ -857,7 +857,7 @@ Thread::ShouldStop (Event* event_ptr) // command on internal breakpoints. If a synchronous stop reason says we should not stop, then we don't have to // do any more work on this stop. StopInfoSP private_stop_info (GetPrivateStopInfo()); - if (private_stop_info && private_stop_info->ShouldStopSynchronous(event_ptr) == false) + if (private_stop_info && !private_stop_info->ShouldStopSynchronous(event_ptr)) { if (log) log->Printf ("StopInfo::ShouldStop async callback says we should not stop, returning ShouldStop of false."); @@ -890,7 +890,7 @@ Thread::ShouldStop (Event* event_ptr) // If the current plan doesn't explain the stop, then find one that // does and let it handle the situation. ThreadPlan *plan_ptr = current_plan; - while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL) + while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr) { if (plan_ptr->PlanExplainsStop(event_ptr)) { @@ -913,10 +913,7 @@ Thread::ShouldStop (Event* event_ptr) while ((current_plan = GetCurrentPlan()) != prev_plan_ptr); // Now, if the responsible plan was not "Okay to discard" then we're done, // otherwise we forward this to the next plan in the stack below. - if (plan_ptr->IsMasterPlan() && !plan_ptr->OkayToDiscard()) - done_processing_current_plan = true; - else - done_processing_current_plan = false; + done_processing_current_plan = (plan_ptr->IsMasterPlan() && !plan_ptr->OkayToDiscard()); } else done_processing_current_plan = true; @@ -973,7 +970,7 @@ Thread::ShouldStop (Event* event_ptr) PopPlan(); current_plan = GetCurrentPlan(); - if (current_plan == NULL) + if (current_plan == nullptr) { break; } @@ -1122,10 +1119,7 @@ Thread::ShouldReportRun (Event* event_ptr) bool Thread::MatchesSpec (const ThreadSpec *spec) { - if (spec == NULL) - return true; - - return spec->ThreadPassesBasicTests(*this); + return (spec == nullptr) ? true : spec->ThreadPassesBasicTests(*this); } void @@ -1193,9 +1187,7 @@ Thread::GetCurrentPlan () { // There will always be at least the base plan. If somebody is mucking with a // thread with an empty plan stack, we should assert right away. - if (m_plan_stack.empty()) - return NULL; - return m_plan_stack.back().get(); + return m_plan_stack.empty() ? nullptr : m_plan_stack.back().get(); } ThreadPlanSP @@ -1278,8 +1270,8 @@ Thread::WasThreadPlanDiscarded (ThreadPlan *plan) ThreadPlan * Thread::GetPreviousPlan (ThreadPlan *current_plan) { - if (current_plan == NULL) - return NULL; + if (current_plan == nullptr) + return nullptr; int stack_size = m_completed_plan_stack.size(); for (int i = stack_size - 1; i > 0; i--) @@ -1290,10 +1282,7 @@ Thread::GetPreviousPlan (ThreadPlan *current_plan) if (stack_size > 0 && m_completed_plan_stack[0].get() == current_plan) { - if (m_plan_stack.size() > 0) - return m_plan_stack.back().get(); - else - return NULL; + return GetCurrentPlan(); } stack_size = m_plan_stack.size(); @@ -1302,7 +1291,7 @@ Thread::GetPreviousPlan (ThreadPlan *current_plan) if (current_plan == m_plan_stack[i].get()) return m_plan_stack[i-1].get(); } - return NULL; + return nullptr; } void @@ -1381,10 +1370,10 @@ Thread::DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr) int stack_size = m_plan_stack.size(); - // If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the + // If the input plan is nullptr, discard all plans. Otherwise make sure this plan is in the // stack, and if so discard up to and including it. - if (up_to_plan_ptr == NULL) + if (up_to_plan_ptr == nullptr) { for (int i = stack_size - 1; i > 0; i--) DiscardPlan(); @@ -1488,7 +1477,7 @@ Thread::UnwindInnermostExpression() Error error; int stack_size = m_plan_stack.size(); - // If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the + // If the input plan is nullptr, discard all plans. Otherwise make sure this plan is in the // stack, and if so discard up to and including it. for (int i = stack_size - 1; i > 0; i--) @@ -1613,7 +1602,7 @@ Thread::QueueThreadPlanForStepOut(bool abort_other_plans, frame_idx, step_out_avoids_code_withoug_debug_info)); - if (thread_plan_sp->ValidatePlan(NULL)) + if (thread_plan_sp->ValidatePlan(nullptr)) { QueueThreadPlan (thread_plan_sp, abort_other_plans); return thread_plan_sp; @@ -1645,7 +1634,7 @@ Thread::QueueThreadPlanForStepOutNoShouldStop(bool abort_other_plans, ThreadPlanStepOut *new_plan = static_cast<ThreadPlanStepOut *>(thread_plan_sp.get()); new_plan->ClearShouldStopHereCallbacks(); - if (thread_plan_sp->ValidatePlan(NULL)) + if (thread_plan_sp->ValidatePlan(nullptr)) { QueueThreadPlan (thread_plan_sp, abort_other_plans); return thread_plan_sp; @@ -1660,7 +1649,7 @@ ThreadPlanSP Thread::QueueThreadPlanForStepThrough (StackID &return_stack_id, bool abort_other_plans, bool stop_other_threads) { ThreadPlanSP thread_plan_sp(new ThreadPlanStepThrough (*this, return_stack_id, stop_other_threads)); - if (!thread_plan_sp || !thread_plan_sp->ValidatePlan (NULL)) + if (!thread_plan_sp || !thread_plan_sp->ValidatePlan(nullptr)) return ThreadPlanSP(); QueueThreadPlan (thread_plan_sp, abort_other_plans); @@ -1798,7 +1787,6 @@ Thread::CalculateTarget () if (process_sp) target_sp = process_sp->CalculateTarget(); return target_sp; - } ProcessSP @@ -1914,7 +1902,7 @@ Thread::ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return // FIXME: ValueObject::Cast doesn't currently work correctly, at least not for scalars. // Turn that back on when that works. - if (/* DISABLES CODE */ (0) && sc.function != NULL) + if (/* DISABLES CODE */ (0) && sc.function != nullptr) { Type *function_type = sc.function->GetType(); if (function_type) @@ -2052,7 +2040,7 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx) { ExecutionContext exe_ctx (shared_from_this()); Process *process = exe_ctx.GetProcessPtr(); - if (process == NULL) + if (process == nullptr) return; StackFrameSP frame_sp; @@ -2072,10 +2060,10 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx) FormatEntity::Format(*thread_format, strm, - frame_sp ? &frame_sc : NULL, + frame_sp ? &frame_sc : nullptr, &exe_ctx, - NULL, - NULL, + nullptr, + nullptr, false, false); } @@ -2203,7 +2191,7 @@ Thread::GetStatus (Stream &strm, uint32_t start_frame, uint32_t num_frames, uint const bool show_frame_info = true; - const char *selected_frame_marker = NULL; + const char *selected_frame_marker = nullptr; if (num_frames == 1 || (GetID() != GetProcess()->GetThreadList().GetSelectedThread()->GetID())) strm.IndentMore (); else @@ -2329,7 +2317,7 @@ Thread::GetStackFrameStatus (Stream& strm, Unwind * Thread::GetUnwinder () { - if (m_unwinder_ap.get() == NULL) + if (!m_unwinder_ap) { const ArchSpec target_arch (CalculateTarget()->GetArchitecture ()); const llvm::Triple::ArchType machine = target_arch.GetMachine(); @@ -2408,13 +2396,13 @@ Thread::StepIn (bool source_step, if (source_step && frame_sp && frame_sp->HasDebugInformation ()) { SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); - new_plan_sp = QueueThreadPlanForStepInRange (abort_other_plans, - sc.line_entry, - sc, - NULL, - run_mode, - step_in_avoids_code_without_debug_info, - step_out_avoids_code_without_debug_info); + new_plan_sp = QueueThreadPlanForStepInRange(abort_other_plans, + sc.line_entry, + sc, + nullptr, + run_mode, + step_in_avoids_code_without_debug_info, + step_out_avoids_code_without_debug_info); } else { @@ -2492,13 +2480,13 @@ Thread::StepOut () const bool stop_other_threads = false; const bool abort_other_plans = false; - ThreadPlanSP new_plan_sp(QueueThreadPlanForStepOut (abort_other_plans, - NULL, - first_instruction, - stop_other_threads, - eVoteYes, - eVoteNoOpinion, - 0)); + ThreadPlanSP new_plan_sp(QueueThreadPlanForStepOut(abort_other_plans, + nullptr, + first_instruction, + stop_other_threads, + eVoteYes, + eVoteNoOpinion, + 0)); new_plan_sp->SetIsMasterPlan(true); new_plan_sp->SetOkayToDiscard(false); diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp index 8c416943db0..a34cb0fa143 100644 --- a/lldb/source/Target/ThreadList.cpp +++ b/lldb/source/Target/ThreadList.cpp @@ -6,10 +6,15 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + +// C Includes #include <stdlib.h> +// C++ Includes #include <algorithm> +// Other libraries and framework includes +// Project includes #include "lldb/Core/Log.h" #include "lldb/Core/State.h" #include "lldb/Target/RegisterContext.h" diff --git a/lldb/source/Target/ThreadPlan.cpp b/lldb/source/Target/ThreadPlan.cpp index 78b999bcd2d..24323337acc 100644 --- a/lldb/source/Target/ThreadPlan.cpp +++ b/lldb/source/Target/ThreadPlan.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlan.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlan.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Log.h" #include "lldb/Core/State.h" @@ -48,9 +47,7 @@ ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vo //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -ThreadPlan::~ThreadPlan() -{ -} +ThreadPlan::~ThreadPlan() = default; bool ThreadPlan::PlanExplainsStop (Event *event_ptr) @@ -130,10 +127,7 @@ ThreadPlan::StopOthers () { ThreadPlan *prev_plan; prev_plan = GetPreviousPlan (); - if (prev_plan == NULL) - return false; - else - return prev_plan->StopOthers(); + return (prev_plan == nullptr) ? false : prev_plan->StopOthers(); } void @@ -191,10 +185,7 @@ ThreadPlan::WillPop() bool ThreadPlan::OkayToDiscard() { - if (!IsMasterPlan()) - return true; - else - return m_okay_to_discard; + return IsMasterPlan() ? m_okay_to_discard : true; } lldb::StateType @@ -223,7 +214,6 @@ ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason) } } - //---------------------------------------------------------------------- // ThreadPlanNull //---------------------------------------------------------------------- @@ -237,9 +227,7 @@ ThreadPlanNull::ThreadPlanNull (Thread &thread) : { } -ThreadPlanNull::~ThreadPlanNull () -{ -} +ThreadPlanNull::~ThreadPlanNull() = default; void ThreadPlanNull::GetDescription (Stream *s, diff --git a/lldb/source/Target/ThreadPlanCallFunction.cpp b/lldb/source/Target/ThreadPlanCallFunction.cpp index cf4d0c49d1f..01ca1267dd9 100644 --- a/lldb/source/Target/ThreadPlanCallFunction.cpp +++ b/lldb/source/Target/ThreadPlanCallFunction.cpp @@ -7,13 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlanCallFunction.h" - // C Includes // C++ Includes // Other libraries and framework includes - // Project includes +#include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Address.h" @@ -76,7 +74,7 @@ ThreadPlanCallFunction::ConstructorSetup (Thread &thread, Module *exe_module = GetTarget().GetExecutableModulePointer(); - if (exe_module == NULL) + if (exe_module == nullptr) { m_constructor_errors.Printf ("Can't execute code without an executable module."); if (log) @@ -190,7 +188,6 @@ ThreadPlanCallFunction::ThreadPlanCallFunction(Thread &thread, m_stop_address(LLDB_INVALID_ADDRESS), m_return_type(CompilerType()) { - } ThreadPlanCallFunction::~ThreadPlanCallFunction () @@ -263,7 +260,6 @@ ThreadPlanCallFunction::DoTakedown (bool success) ClearBreakpoints(); if (log && log->GetVerbose()) ReportRegisterState ("Restoring thread state after function call. Restored register state:"); - } else { @@ -312,7 +308,6 @@ ThreadPlanCallFunction::ValidatePlan (Stream *error) return true; } - Vote ThreadPlanCallFunction::ShouldReportStop(Event *event_ptr) { @@ -330,7 +325,7 @@ ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr) // If our subplan knows why we stopped, even if it's done (which would forward the question to us) // we answer yes. - if (m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop(event_ptr)) + if (m_subplan_sp && m_subplan_sp->PlanExplainsStop(event_ptr)) { SetPlanComplete(); return true; @@ -360,8 +355,7 @@ ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr) // We control breakpoints separately from other "stop reasons." So first, // check the case where we stopped for an internal breakpoint, in that case, continue on. // If it is not an internal breakpoint, consult m_ignore_breakpoints. - - + if (stop_reason == eStopReasonBreakpoint) { ProcessSP process_sp (m_thread.CalculateProcess()); @@ -426,15 +420,7 @@ ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr) if (m_real_stop_info_sp && m_real_stop_info_sp->ShouldStopSynchronous(event_ptr)) { SetPlanComplete(false); - if (m_subplan_sp) - { - if (m_unwind_on_error) - return true; - else - return false; - } - else - return false; + return m_subplan_sp ? m_unwind_on_error : false; } else return true; @@ -583,19 +569,17 @@ ThreadPlanCallFunction::SetStopOthers (bool new_value) m_subplan_sp->SetStopOthers(new_value); } - bool ThreadPlanCallFunction::RestoreThreadState() { return GetThread().RestoreThreadStateFromCheckpoint(m_stored_thread_state); } - void ThreadPlanCallFunction::SetReturnValue() { ProcessSP process_sp(m_thread.GetProcess()); - const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL; + const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr; if (abi && m_return_type.IsValid()) { const bool persistent = false; diff --git a/lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp b/lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp index 53fabd2464e..df23edc0fd1 100644 --- a/lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp +++ b/lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp @@ -1,4 +1,4 @@ -//===-- ThreadPlanCallFunctionUsingABI.cpp ------------------------------*- C++ -*-===// +//===-- ThreadPlanCallFunctionUsingABI.cpp ----------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,13 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h" - // C Includes // C++ Includes // Other libraries and framework includes - // Project includes +#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h" #include "lldb/Core/Address.h" #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" @@ -57,10 +55,7 @@ ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI (Thread &thread, m_valid = true; } -ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI() -{ - -} +ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI() = default; void ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s, DescriptionLevel level) @@ -80,7 +75,7 @@ void ThreadPlanCallFunctionUsingABI::SetReturnValue() { ProcessSP process_sp(m_thread.GetProcess()); - const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL; + const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr; // Ask the abi for the return value if (abi) diff --git a/lldb/source/Target/ThreadPlanRunToAddress.cpp b/lldb/source/Target/ThreadPlanRunToAddress.cpp index 3755dd5eceb..18c43dafd7b 100644 --- a/lldb/source/Target/ThreadPlanRunToAddress.cpp +++ b/lldb/source/Target/ThreadPlanRunToAddress.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlanRunToAddress.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlanRunToAddress.h" #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Target/Target.h" @@ -88,7 +87,7 @@ ThreadPlanRunToAddress::SetInitialBreakpoints () { Breakpoint *breakpoint; breakpoint = m_thread.CalculateTarget()->CreateBreakpoint (m_addresses[i], true, false).get(); - if (breakpoint != NULL) + if (breakpoint != nullptr) { m_break_ids[i] = breakpoint->GetID(); breakpoint->SetThreadID(m_thread.GetID()); diff --git a/lldb/source/Target/ThreadPlanShouldStopHere.cpp b/lldb/source/Target/ThreadPlanShouldStopHere.cpp index e89f5d2bde1..88f8db2bd7e 100644 --- a/lldb/source/Target/ThreadPlanShouldStopHere.cpp +++ b/lldb/source/Target/ThreadPlanShouldStopHere.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlanShouldStopHere.h" @@ -15,19 +19,14 @@ using namespace lldb; using namespace lldb_private; -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes - //---------------------------------------------------------------------- // ThreadPlanShouldStopHere constructor //---------------------------------------------------------------------- ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner) : - m_callbacks (), - m_baton (NULL), - m_owner (owner), - m_flags (ThreadPlanShouldStopHere::eNone) + m_callbacks(), + m_baton(nullptr), + m_owner(owner), + m_flags(ThreadPlanShouldStopHere::eNone) { m_callbacks.should_stop_here_callback = ThreadPlanShouldStopHere::DefaultShouldStopHereCallback; m_callbacks.step_from_here_callback = ThreadPlanShouldStopHere::DefaultStepFromHereCallback; @@ -42,12 +41,7 @@ ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner, const Thre SetShouldStopHereCallbacks(callbacks, baton); } -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -ThreadPlanShouldStopHere::~ThreadPlanShouldStopHere() -{ -} +ThreadPlanShouldStopHere::~ThreadPlanShouldStopHere() = default; bool ThreadPlanShouldStopHere::InvokeShouldStopHereCallback (FrameComparison operation) @@ -135,13 +129,13 @@ ThreadPlanShouldStopHere::DefaultStepFromHereCallback (ThreadPlan *current_plan, } if (!return_plan_sp) - return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepOutNoShouldStop (false, - NULL, - true, - stop_others, - eVoteNo, - eVoteNoOpinion, - frame_index); + return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepOutNoShouldStop(false, + nullptr, + true, + stop_others, + eVoteNo, + eVoteNoOpinion, + frame_index); return return_plan_sp; } @@ -154,7 +148,6 @@ ThreadPlanShouldStopHere::QueueStepOutFromHerePlan(lldb_private::Flags &flags, l return_plan_sp = m_callbacks.step_from_here_callback (m_owner, flags, operation, m_baton); } return return_plan_sp; - } lldb::ThreadPlanSP @@ -165,4 +158,3 @@ ThreadPlanShouldStopHere::CheckShouldStopHereAndQueueStepOut (lldb::FrameCompari else return ThreadPlanSP(); } - diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp b/lldb/source/Target/ThreadPlanStepInRange.cpp index a7f5d6746be..3771e210c1a 100644 --- a/lldb/source/Target/ThreadPlanStepInRange.cpp +++ b/lldb/source/Target/ThreadPlanStepInRange.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlanStepInRange.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlanStepInRange.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/Stream.h" @@ -76,9 +75,7 @@ ThreadPlanStepInRange::ThreadPlanStepInRange SetupAvoidNoDebug(step_in_avoids_code_without_debug_info, step_out_avoids_code_without_debug_info); } -ThreadPlanStepInRange::~ThreadPlanStepInRange () -{ -} +ThreadPlanStepInRange::~ThreadPlanStepInRange() = default; void ThreadPlanStepInRange::SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info, @@ -193,11 +190,7 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr) // Stepping through should be done running other threads in general, since we're setting a breakpoint and // continuing. So only stop others if we are explicitly told to do so. - bool stop_others; - if (m_stop_others == lldb::eOnlyThisThread) - stop_others = true; - else - stop_others = false; + bool stop_others = (m_stop_others == lldb::eOnlyThisThread); FrameComparison frame_order = CompareCurrentFrameToStartFrame(); @@ -220,7 +213,6 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr) { log->Printf("Thought I stepped out, but in fact arrived at a trampoline."); } - } else if (frame_order == eFrameCompareEqual && InSymbol()) { @@ -322,7 +314,7 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr) void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) { - if (m_avoid_regexp_ap.get() == NULL) + if (!m_avoid_regexp_ap) m_avoid_regexp_ap.reset (new RegularExpression(name)); m_avoid_regexp_ap->Compile (name); @@ -367,13 +359,13 @@ ThreadPlanStepInRange::FrameMatchesAvoidCriteria () return true; const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get(); - if (avoid_regexp_to_use == NULL) + if (avoid_regexp_to_use == nullptr) avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp(); - if (avoid_regexp_to_use != NULL) + if (avoid_regexp_to_use != nullptr) { SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol); - if (sc.symbol != NULL) + if (sc.symbol != nullptr) { const char *frame_function_name = sc.GetFunctionName(Mangled::ePreferDemangledWithoutArguments).GetCString(); if (frame_function_name) @@ -424,7 +416,7 @@ ThreadPlanStepInRange::DefaultShouldStopHereCallback (ThreadPlan *current_plan, if (step_in_range_plan->m_step_into_target) { SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol); - if (sc.symbol != NULL) + if (sc.symbol != nullptr) { // First try an exact match, since that's cheap with ConstStrings. Then do a strstr compare. if (step_in_range_plan->m_step_into_target == sc.GetFunctionName()) @@ -436,9 +428,9 @@ ThreadPlanStepInRange::DefaultShouldStopHereCallback (ThreadPlan *current_plan, const char *target_name = step_in_range_plan->m_step_into_target.AsCString(); const char *function_name = sc.GetFunctionName().AsCString(); - if (function_name == NULL) + if (function_name == nullptr) should_stop_here = false; - else if (strstr (function_name, target_name) == NULL) + else if (strstr(function_name, target_name) == nullptr) should_stop_here = false; } if (log && !should_stop_here) @@ -543,5 +535,5 @@ ThreadPlanStepInRange::DoWillResume (lldb::StateType resume_state, bool current_ bool ThreadPlanStepInRange::IsVirtualStep() { - return m_virtual_step; + return m_virtual_step; } diff --git a/lldb/source/Target/ThreadPlanStepInstruction.cpp b/lldb/source/Target/ThreadPlanStepInstruction.cpp index 1ce26df78fe..9d7d52167ff 100644 --- a/lldb/source/Target/ThreadPlanStepInstruction.cpp +++ b/lldb/source/Target/ThreadPlanStepInstruction.cpp @@ -7,13 +7,11 @@ // //===----------------------------------------------------------------------===// - -#include "lldb/Target/ThreadPlanStepInstruction.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Target/Process.h" @@ -46,9 +44,7 @@ ThreadPlanStepInstruction::ThreadPlanStepInstruction SetUpState(); } -ThreadPlanStepInstruction::~ThreadPlanStepInstruction () -{ -} +ThreadPlanStepInstruction::~ThreadPlanStepInstruction() = default; void ThreadPlanStepInstruction::SetUpState() @@ -57,7 +53,7 @@ ThreadPlanStepInstruction::SetUpState() StackFrameSP start_frame_sp(m_thread.GetStackFrameAtIndex(0)); m_stack_id = start_frame_sp->GetStackID(); - m_start_has_symbol = start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != NULL; + m_start_has_symbol = start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != nullptr; StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1); if (parent_frame_sp) @@ -103,10 +99,7 @@ ThreadPlanStepInstruction::DoPlanExplainsStop (Event *event_ptr) if (stop_info_sp) { StopReason reason = stop_info_sp->GetStopReason(); - if (reason == eStopReasonTrace || reason == eStopReasonNone) - return true; - else - return false; + return (reason == eStopReasonTrace || reason == eStopReasonNone); } return false; } @@ -118,19 +111,13 @@ ThreadPlanStepInstruction::IsPlanStale () StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID(); if (cur_frame_id == m_stack_id) { - if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr) - return true; - else - return false; + return (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr); } else if (cur_frame_id < m_stack_id) { // If the current frame is younger than the start frame and we are stepping over, then we need to continue, // but if we are doing just one step, we're done. - if (m_step_over) - return false; - else - return true; + return !m_step_over; } else { @@ -222,7 +209,7 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr) // run others. const bool stop_others = false; m_thread.QueueThreadPlanForStepOutNoShouldStop(false, - NULL, + nullptr, true, stop_others, eVoteNo, @@ -248,9 +235,7 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr) SetPlanComplete(); return true; } - } - } else { @@ -308,4 +293,3 @@ ThreadPlanStepInstruction::MischiefManaged () return false; } } - diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp b/lldb/source/Target/ThreadPlanStepOut.cpp index 8ee8d1c4e49..92403cb92ed 100644 --- a/lldb/source/Target/ThreadPlanStepOut.cpp +++ b/lldb/source/Target/ThreadPlanStepOut.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlanStepOut.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Log.h" #include "lldb/Core/Value.h" @@ -53,7 +52,7 @@ ThreadPlanStepOut::ThreadPlanStepOut m_return_bp_id (LLDB_INVALID_BREAK_ID), m_return_addr (LLDB_INVALID_ADDRESS), m_stop_others (stop_others), - m_immediate_step_from_function(NULL) + m_immediate_step_from_function(nullptr) { SetFlagsToDefault(); SetupAvoidNoDebug(step_out_avoids_code_without_debug_info); @@ -80,14 +79,14 @@ ThreadPlanStepOut::ThreadPlanStepOut { // First queue a plan that gets us to this inlined frame, and when we get there we'll queue a second // plan that walks us out of this frame. - m_step_out_to_inline_plan_sp.reset (new ThreadPlanStepOut(m_thread, - NULL, - false, - stop_others, - eVoteNoOpinion, - eVoteNoOpinion, - frame_idx - 1, - eLazyBoolNo)); + m_step_out_to_inline_plan_sp.reset(new ThreadPlanStepOut(m_thread, + nullptr, + false, + stop_others, + eVoteNoOpinion, + eVoteNoOpinion, + frame_idx - 1, + eLazyBoolNo)); static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())->SetShouldStopHereCallbacks(nullptr, nullptr); m_step_out_to_inline_plan_sp->SetPrivate(true); } @@ -96,7 +95,6 @@ ThreadPlanStepOut::ThreadPlanStepOut // If we're already at the inlined frame we're stepping through, then just do that now. QueueInlinedStepPlan(false); } - } else if (return_frame_sp) { @@ -109,7 +107,7 @@ ThreadPlanStepOut::ThreadPlanStepOut return; Breakpoint *return_bp = m_thread.CalculateTarget()->CreateBreakpoint (m_return_addr, true, false).get(); - if (return_bp != NULL) + if (return_bp != nullptr) { return_bp->SetThreadID(m_thread.GetID()); m_return_bp_id = return_bp->GetID(); @@ -125,7 +123,6 @@ ThreadPlanStepOut::ThreadPlanStepOut } } } - } void @@ -231,10 +228,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr) // If the step out plan is done, then we just need to step through the inlined frame. if (m_step_out_to_inline_plan_sp) { - if (m_step_out_to_inline_plan_sp->MischiefManaged()) - return true; - else - return false; + return m_step_out_to_inline_plan_sp->MischiefManaged(); } else if (m_step_through_inline_plan_sp) { @@ -249,10 +243,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr) } else if (m_step_out_further_plan_sp) { - if (m_step_out_further_plan_sp->MischiefManaged()) - return true; - else - return false; + return m_step_out_further_plan_sp->MischiefManaged(); } // We don't explain signals or breakpoints (breakpoints that handle stepping in or @@ -282,10 +273,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr) } else { - if (m_immediate_step_from_id < frame_zero_id) - done = true; - else - done = false; + done = (m_immediate_step_from_id < frame_zero_id); } if (done) @@ -304,7 +292,6 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr) if (site_sp->GetNumberOfOwners() == 1) return true; - } return false; } @@ -359,10 +346,7 @@ ThreadPlanStepOut::ShouldStop (Event *event_ptr) if (!done) { StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID(); - if (frame_zero_id < m_step_out_to_id) - done = false; - else - done = true; + done = !(frame_zero_id < m_step_out_to_id); } // The normal step out computations think we are done, so all we need to do is consult the ShouldStopHere, @@ -409,7 +393,7 @@ ThreadPlanStepOut::DoWillResume (StateType resume_state, bool current_plan) if (current_plan) { Breakpoint *return_bp = m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get(); - if (return_bp != NULL) + if (return_bp != nullptr) return_bp->SetEnabled (true); } return true; @@ -421,7 +405,7 @@ ThreadPlanStepOut::WillStop () if (m_return_bp_id != LLDB_INVALID_BREAK_ID) { Breakpoint *return_bp = m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get(); - if (return_bp != NULL) + if (return_bp != nullptr) return_bp->SetEnabled (false); } @@ -531,7 +515,7 @@ ThreadPlanStepOut::CalculateReturnValue () if (m_return_valobj_sp) return; - if (m_immediate_step_from_function != NULL) + if (m_immediate_step_from_function != nullptr) { CompilerType return_compiler_type = m_immediate_step_from_function->GetCompilerType().GetFunctionReturnType(); if (return_compiler_type) @@ -550,8 +534,5 @@ ThreadPlanStepOut::IsPlanStale() // there's something for us to do. Otherwise, we're stale. StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID(); - if (frame_zero_id < m_step_out_to_id) - return false; - else - return true; + return !(frame_zero_id < m_step_out_to_id); } diff --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp b/lldb/source/Target/ThreadPlanStepOverRange.cpp index 6e7ee57fc82..08655be2439 100644 --- a/lldb/source/Target/ThreadPlanStepOverRange.cpp +++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlanStepOverRange.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlanStepOverRange.h" #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Symbol/Block.h" @@ -52,9 +51,7 @@ ThreadPlanStepOverRange::ThreadPlanStepOverRange SetupAvoidNoDebug(step_out_avoids_code_without_debug_info); } -ThreadPlanStepOverRange::~ThreadPlanStepOverRange () -{ -} +ThreadPlanStepOverRange::~ThreadPlanStepOverRange() = default; void ThreadPlanStepOverRange::GetDescription (Stream *s, lldb::DescriptionLevel level) @@ -111,7 +108,6 @@ ThreadPlanStepOverRange::SetupAvoidNoDebug(LazyBool step_out_avoids_code_without bool ThreadPlanStepOverRange::IsEquivalentContext(const SymbolContext &context) { - // Match as much as is specified in the m_addr_context: // This is a fairly loose sanity check. Note, sometimes the target doesn't get filled // in so I left out the target check. And sometimes the module comes in as the .o file from the @@ -150,14 +146,8 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr) // If we're out of the range but in the same frame or in our caller's frame // then we should stop. // When stepping out we only stop others if we are forcing running one thread. - bool stop_others; - if (m_stop_others == lldb::eOnlyThisThread) - stop_others = true; - else - stop_others = false; - + bool stop_others = (m_stop_others == lldb::eOnlyThisThread); ThreadPlanSP new_plan_sp; - FrameComparison frame_order = CompareCurrentFrameToStartFrame(); if (frame_order == eFrameCompareOlder) @@ -189,13 +179,13 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr) const SymbolContext &older_context = older_frame_sp->GetSymbolContext(eSymbolContextEverything); if (IsEquivalentContext(older_context)) { - new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop (false, - NULL, - true, - stop_others, - eVoteNo, - eVoteNoOpinion, - 0); + new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(false, + nullptr, + true, + stop_others, + eVoteNo, + eVoteNoOpinion, + 0); break; } else @@ -216,7 +206,6 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr) return false; } - if (!InSymbol()) { // This one is a little tricky. Sometimes we may be in a stub or something similar, @@ -283,7 +272,6 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr) step_past_remaining_inline = true; } - } } } @@ -378,10 +366,7 @@ ThreadPlanStepOverRange::DoPlanExplainsStop (Event *event_ptr) } else if (reason == eStopReasonBreakpoint) { - if (NextRangeBreakpointExplainsStop(stop_info_sp)) - return_value = true; - else - return_value = false; + return_value = NextRangeBreakpointExplainsStop(stop_info_sp); } else { @@ -446,4 +431,3 @@ ThreadPlanStepOverRange::DoWillResume (lldb::StateType resume_state, bool curren return true; } - diff --git a/lldb/source/Target/ThreadPlanStepRange.cpp b/lldb/source/Target/ThreadPlanStepRange.cpp index 9bddef3c65a..02667f8236e 100644 --- a/lldb/source/Target/ThreadPlanStepRange.cpp +++ b/lldb/source/Target/ThreadPlanStepRange.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlanStepRange.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlanStepRange.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/Disassembler.h" @@ -31,7 +30,6 @@ using namespace lldb; using namespace lldb_private; - //---------------------------------------------------------------------- // ThreadPlanStepRange: Step through a stack range, either stepping over or into // based on the value of \a type. @@ -221,12 +219,9 @@ ThreadPlanStepRange::InRange () new_context.line_entry.line, s.GetData()); } - } } - } - } if (!ret_value && log) @@ -239,7 +234,7 @@ bool ThreadPlanStepRange::InSymbol() { lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC(); - if (m_addr_context.function != NULL) + if (m_addr_context.function != nullptr) { return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, m_thread.CalculateTarget().get()); } @@ -291,11 +286,7 @@ ThreadPlanStepRange::CompareCurrentFrameToStartFrame() bool ThreadPlanStepRange::StopOthers () { - if (m_stop_others == lldb::eOnlyThisThread - || m_stop_others == lldb::eOnlyDuringStepping) - return true; - else - return false; + return (m_stop_others == lldb::eOnlyThisThread || m_stop_others == lldb::eOnlyDuringStepping); } InstructionList * @@ -308,14 +299,14 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_ { // Some joker added a zero size range to the stepping range... if (m_address_ranges[i].GetByteSize() == 0) - return NULL; + return nullptr; if (!m_instruction_ranges[i]) { //Disassemble the address range given: ExecutionContext exe_ctx (m_thread.GetProcess()); - const char *plugin_name = NULL; - const char *flavor = NULL; + const char *plugin_name = nullptr; + const char *flavor = nullptr; const bool prefer_file_cache = true; m_instruction_ranges[i] = Disassembler::DisassembleRange(GetTarget().GetArchitecture(), plugin_name, @@ -323,18 +314,17 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_ exe_ctx, m_address_ranges[i], prefer_file_cache); - } if (!m_instruction_ranges[i]) - return NULL; + return nullptr; else { // Find where we are in the instruction list as well. If we aren't at an instruction, - // return NULL. In this case, we're probably lost, and shouldn't try to do anything fancy. + // return nullptr. In this case, we're probably lost, and shouldn't try to do anything fancy. insn_offset = m_instruction_ranges[i]->GetInstructionList().GetIndexOfInstructionAtLoadAddress(addr, GetTarget()); if (insn_offset == UINT32_MAX) - return NULL; + return nullptr; else { range_index = i; @@ -343,7 +333,7 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_ } } } - return NULL; + return nullptr; } void @@ -376,7 +366,7 @@ ThreadPlanStepRange::SetNextBranchBreakpoint () size_t pc_index; size_t range_index; InstructionList *instructions = GetInstructionsForAddress (cur_addr, range_index, pc_index); - if (instructions == NULL) + if (instructions == nullptr) return false; else { @@ -511,15 +501,7 @@ ThreadPlanStepRange::MischiefManaged () else { FrameComparison frame_order = CompareCurrentFrameToStartFrame(); - if (frame_order != eFrameCompareOlder) - { - if (m_no_more_plans) - done = true; - else - done = false; - } - else - done = true; + done = (frame_order != eFrameCompareOlder) ? m_no_more_plans : true; } } @@ -536,7 +518,6 @@ ThreadPlanStepRange::MischiefManaged () { return false; } - } bool diff --git a/lldb/source/Target/ThreadPlanStepThrough.cpp b/lldb/source/Target/ThreadPlanStepThrough.cpp index 068d8e6584f..a5346a4cdde 100644 --- a/lldb/source/Target/ThreadPlanStepThrough.cpp +++ b/lldb/source/Target/ThreadPlanStepThrough.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlanStepThrough.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlanStepThrough.h" #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Target/DynamicLoader.h" @@ -39,7 +38,6 @@ ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, StackID &m_stack_i m_return_stack_id (m_stack_id), m_stop_others (stop_others) { - LookForPlanToStepThroughFromCurrentPC(); // If we don't get a valid step through plan, don't bother to set up a backstop. @@ -56,7 +54,7 @@ ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, StackID &m_stack_i { m_backstop_addr = return_frame_sp->GetFrameCodeAddress().GetLoadAddress(m_thread.CalculateTarget().get()); Breakpoint *return_bp = m_thread.GetProcess()->GetTarget().CreateBreakpoint (m_backstop_addr, true, false).get(); - if (return_bp != NULL) + if (return_bp != nullptr) { return_bp->SetThreadID(m_thread.GetID()); m_backstop_bkpt_id = return_bp->GetID(); @@ -137,7 +135,7 @@ ThreadPlanStepThrough::GetDescription (Stream *s, lldb::DescriptionLevel level) bool ThreadPlanStepThrough::ValidatePlan (Stream *error) { - return m_sub_plan_sp.get() != NULL; + return m_sub_plan_sp.get() != nullptr; } bool @@ -147,10 +145,7 @@ ThreadPlanStepThrough::DoPlanExplainsStop (Event *event_ptr) // we won't get asked. The only time we would be the one directly asked this question // is if we hit our backstop breakpoint. - if (HitOurBackstopBreakpoint()) - return true; - else - return false; + return HitOurBackstopBreakpoint(); } bool @@ -289,4 +284,3 @@ ThreadPlanStepThrough::HitOurBackstopBreakpoint() } return false; } - diff --git a/lldb/source/Target/ThreadPlanStepUntil.cpp b/lldb/source/Target/ThreadPlanStepUntil.cpp index a747ee8dc1b..2581fc7b522 100644 --- a/lldb/source/Target/ThreadPlanStepUntil.cpp +++ b/lldb/source/Target/ThreadPlanStepUntil.cpp @@ -6,17 +6,12 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -//m_should_stop - -// -//===----------------------------------------------------------------------===// - -#include "lldb/Target/ThreadPlanStepUntil.h" // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlanStepUntil.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Log.h" #include "lldb/Target/Process.h" @@ -68,7 +63,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil // TODO: add inline functionality m_return_addr = return_frame_sp->GetStackID().GetPC(); Breakpoint *return_bp = target_sp->CreateBreakpoint (m_return_addr, true, false).get(); - if (return_bp != NULL) + if (return_bp != nullptr) { return_bp->SetThreadID(thread_id); m_return_bp_id = return_bp->GetID(); @@ -82,7 +77,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil for (size_t i = 0; i < num_addresses; i++) { Breakpoint *until_bp = target_sp->CreateBreakpoint (address_list[i], true, false).get(); - if (until_bp != NULL) + if (until_bp != nullptr) { until_bp->SetThreadID(thread_id); m_until_points[address_list[i]] = until_bp->GetID(); @@ -206,10 +201,7 @@ ThreadPlanStepUntil::AnalyzeStop() bool done; StackID cur_frame_zero_id; - if (m_stack_id < cur_frame_zero_id) - done = true; - else - done = false; + done = (m_stack_id < cur_frame_zero_id); if (done) { @@ -254,10 +246,7 @@ ThreadPlanStepUntil::AnalyzeStop() SymbolContext stack_context; m_stack_id.GetSymbolContextScope()->CalculateSymbolContext(&stack_context); - if (older_context == stack_context) - done = true; - else - done = false; + done = (older_context == stack_context); } else done = false; @@ -343,14 +332,14 @@ ThreadPlanStepUntil::DoWillResume (StateType resume_state, bool current_plan) if (target_sp) { Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get(); - if (return_bp != NULL) + if (return_bp != nullptr) return_bp->SetEnabled (true); until_collection::iterator pos, end = m_until_points.end(); for (pos = m_until_points.begin(); pos != end; pos++) { Breakpoint *until_bp = target_sp->GetBreakpointByID((*pos).second).get(); - if (until_bp != NULL) + if (until_bp != nullptr) until_bp->SetEnabled (true); } } @@ -369,14 +358,14 @@ ThreadPlanStepUntil::WillStop () if (target_sp) { Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get(); - if (return_bp != NULL) + if (return_bp != nullptr) return_bp->SetEnabled (false); until_collection::iterator pos, end = m_until_points.end(); for (pos = m_until_points.begin(); pos != end; pos++) { Breakpoint *until_bp = target_sp->GetBreakpointByID((*pos).second).get(); - if (until_bp != NULL) + if (until_bp != nullptr) until_bp->SetEnabled (false); } } @@ -386,7 +375,6 @@ ThreadPlanStepUntil::WillStop () bool ThreadPlanStepUntil::MischiefManaged () { - // I'm letting "PlanExplainsStop" do all the work, and just reporting that here. bool done = false; if (IsPlanComplete()) @@ -402,6 +390,4 @@ ThreadPlanStepUntil::MischiefManaged () ThreadPlan::MischiefManaged (); return done; - } - diff --git a/lldb/source/Target/ThreadPlanTracer.cpp b/lldb/source/Target/ThreadPlanTracer.cpp index b1542e0f6a7..e3fcbaaaef7 100644 --- a/lldb/source/Target/ThreadPlanTracer.cpp +++ b/lldb/source/Target/ThreadPlanTracer.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ThreadPlan.h" - // C Includes -#include <string.h> // C++ Includes +#include <cstring> + // Other libraries and framework includes // Project includes +#include "lldb/Target/ThreadPlan.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" @@ -57,8 +57,7 @@ ThreadPlanTracer::ThreadPlanTracer (Thread &thread) : Stream * ThreadPlanTracer::GetLogStream () { - - if (m_stream_sp.get()) + if (m_stream_sp) return m_stream_sp.get(); else { @@ -66,7 +65,7 @@ ThreadPlanTracer::GetLogStream () if (target_sp) return target_sp->GetDebugger().GetOutputFile().get(); } - return NULL; + return nullptr; } void @@ -83,7 +82,6 @@ ThreadPlanTracer::Log() stream->Printf("\n"); stream->Flush(); } - } bool @@ -92,10 +90,7 @@ ThreadPlanTracer::TracerExplainsStop () if (m_enabled && m_single_step) { lldb::StopInfoSP stop_info = m_thread.GetStopInfo(); - if (stop_info->GetStopReason() == eStopReasonTrace) - return true; - else - return false; + return (stop_info->GetStopReason() == eStopReasonTrace); } else return false; @@ -122,8 +117,8 @@ ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread) : Disassembler * ThreadPlanAssemblyTracer::GetDisassembler () { - if (m_disassembler_sp.get() == NULL) - m_disassembler_sp = Disassembler::FindPlugin(m_thread.GetProcess()->GetTarget().GetArchitecture(), NULL, NULL); + if (!m_disassembler_sp) + m_disassembler_sp = Disassembler::FindPlugin(m_thread.GetProcess()->GetTarget().GetArchitecture(), nullptr, nullptr); return m_disassembler_sp.get(); } @@ -143,18 +138,14 @@ ThreadPlanAssemblyTracer::GetIntPointerType() return m_intptr_type; } - - -ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() -{ -} +ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() = default; void ThreadPlanAssemblyTracer::TracingStarted () { RegisterContext *reg_ctx = m_thread.GetRegisterContext().get(); - if (m_register_values.size() == 0) + if (m_register_values.empty()) m_register_values.resize (reg_ctx->GetRegisterCount()); } @@ -211,15 +202,15 @@ ThreadPlanAssemblyTracer::Log () const bool show_address = true; Instruction *instruction = instruction_list.GetInstructionAtIndex(0).get(); const FormatEntity::Entry *disassemble_format = m_thread.GetProcess()->GetTarget().GetDebugger().GetDisassemblyFormat(); - instruction->Dump (stream, - max_opcode_byte_size, - show_address, - show_bytes, - NULL, - NULL, - NULL, - disassemble_format, - 0); + instruction->Dump(stream, + max_opcode_byte_size, + show_address, + show_bytes, + nullptr, + nullptr, + nullptr, + disassemble_format, + 0); } } } @@ -252,8 +243,7 @@ ThreadPlanAssemblyTracer::Log () } } } - - + RegisterValue reg_value; for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount(); reg_num < num_registers; diff --git a/lldb/source/Target/ThreadSpec.cpp b/lldb/source/Target/ThreadSpec.cpp index cb54469ba90..f877f521bd5 100644 --- a/lldb/source/Target/ThreadSpec.cpp +++ b/lldb/source/Target/ThreadSpec.cpp @@ -1,4 +1,4 @@ -//===-- ThreadSpec.cpp ----------------------------------------------*- C++ -*-===// +//===-- ThreadSpec.cpp ------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" @@ -21,7 +25,7 @@ ThreadSpec::ThreadSpec() : { } -ThreadSpec::ThreadSpec (const ThreadSpec &rhs) : +ThreadSpec::ThreadSpec(const ThreadSpec &rhs) : m_index(rhs.m_index), m_tid(rhs.m_tid), m_name(rhs.m_name), @@ -42,19 +46,13 @@ ThreadSpec::operator=(const ThreadSpec &rhs) const char * ThreadSpec::GetName () const { - if (m_name.empty()) - return NULL; - else - return m_name.c_str(); + return m_name.empty() ? nullptr : m_name.c_str(); } const char * ThreadSpec::GetQueueName () const { - if (m_queue_name.empty()) - return NULL; - else - return m_queue_name.c_str(); + return m_queue_name.empty() ? nullptr : m_queue_name.c_str(); } bool @@ -66,6 +64,7 @@ ThreadSpec::TIDMatches (Thread &thread) const lldb::tid_t thread_id = thread.GetID(); return TIDMatches (thread_id); } + bool ThreadSpec::IndexMatches (Thread &thread) const { @@ -74,6 +73,7 @@ ThreadSpec::IndexMatches (Thread &thread) const uint32_t index = thread.GetIndexID(); return IndexMatches (index); } + bool ThreadSpec::NameMatches (Thread &thread) const { @@ -83,6 +83,7 @@ ThreadSpec::NameMatches (Thread &thread) const const char *name = thread.GetName(); return NameMatches (name); } + bool ThreadSpec::QueueNameMatches (Thread &thread) const { @@ -96,7 +97,6 @@ ThreadSpec::QueueNameMatches (Thread &thread) const bool ThreadSpec::ThreadPassesBasicTests (Thread &thread) const { - if (!HasSpecification()) return true; @@ -113,7 +113,6 @@ ThreadSpec::ThreadPassesBasicTests (Thread &thread) const return false; return true; - } bool @@ -121,6 +120,7 @@ ThreadSpec::HasSpecification() const { return (m_index != UINT32_MAX || m_tid != LLDB_INVALID_THREAD_ID || !m_name.empty() || !m_queue_name.empty()); } + void ThreadSpec::GetDescription (Stream *s, lldb::DescriptionLevel level) const { |