*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
diff --git a/lldb/source/Target/ThreadPlan.cpp b/lldb/source/Target/ThreadPlan.cpp
index f86d10d..6b99747 100644
--- a/lldb/source/Target/ThreadPlan.cpp
+++ b/lldb/source/Target/ThreadPlan.cpp
@@ -15,10 +15,10 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Thread.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConvertEnum.h"
using namespace lldb;
@@ -27,21 +27,14 @@
//----------------------------------------------------------------------
// ThreadPlan constructor
//----------------------------------------------------------------------
-ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vote stop_vote, Vote run_vote)
- : m_thread(thread),
- m_stop_vote(stop_vote),
- m_run_vote(run_vote),
- m_kind(kind),
- m_name(name),
- m_plan_complete_mutex(),
- m_cached_plan_explains_stop(eLazyBoolCalculate),
- m_plan_complete(false),
- m_plan_private(false),
- m_okay_to_discard(true),
- m_is_master_plan(false),
- m_plan_succeeded(true)
-{
- SetID(GetNextID());
+ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
+ Vote stop_vote, Vote run_vote)
+ : m_thread(thread), m_stop_vote(stop_vote), m_run_vote(run_vote),
+ m_kind(kind), m_name(name), m_plan_complete_mutex(),
+ m_cached_plan_explains_stop(eLazyBoolCalculate), m_plan_complete(false),
+ m_plan_private(false), m_okay_to_discard(true), m_is_master_plan(false),
+ m_plan_succeeded(true) {
+ SetID(GetNextID());
}
//----------------------------------------------------------------------
@@ -49,306 +42,249 @@
//----------------------------------------------------------------------
ThreadPlan::~ThreadPlan() = default;
-bool
-ThreadPlan::PlanExplainsStop (Event *event_ptr)
-{
- if (m_cached_plan_explains_stop == eLazyBoolCalculate)
- {
- bool actual_value = DoPlanExplainsStop(event_ptr);
- m_cached_plan_explains_stop = actual_value ? eLazyBoolYes : eLazyBoolNo;
- return actual_value;
+bool ThreadPlan::PlanExplainsStop(Event *event_ptr) {
+ if (m_cached_plan_explains_stop == eLazyBoolCalculate) {
+ bool actual_value = DoPlanExplainsStop(event_ptr);
+ m_cached_plan_explains_stop = actual_value ? eLazyBoolYes : eLazyBoolNo;
+ return actual_value;
+ } else {
+ return m_cached_plan_explains_stop == eLazyBoolYes;
+ }
+}
+
+bool ThreadPlan::IsPlanComplete() {
+ std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
+ return m_plan_complete;
+}
+
+void ThreadPlan::SetPlanComplete(bool success) {
+ std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
+ m_plan_complete = true;
+ m_plan_succeeded = success;
+}
+
+bool ThreadPlan::MischiefManaged() {
+ std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
+ // Mark the plan is complete, but don't override the success flag.
+ m_plan_complete = true;
+ return true;
+}
+
+Vote ThreadPlan::ShouldReportStop(Event *event_ptr) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+ if (m_stop_vote == eVoteNoOpinion) {
+ ThreadPlan *prev_plan = GetPreviousPlan();
+ if (prev_plan) {
+ Vote prev_vote = prev_plan->ShouldReportStop(event_ptr);
+ if (log)
+ log->Printf("ThreadPlan::ShouldReportStop() returning previous thread "
+ "plan vote: %s",
+ GetVoteAsCString(prev_vote));
+ return prev_vote;
}
- else
- {
- return m_cached_plan_explains_stop == eLazyBoolYes;
+ }
+ if (log)
+ log->Printf("ThreadPlan::ShouldReportStop() returning vote: %s",
+ GetVoteAsCString(m_stop_vote));
+ return m_stop_vote;
+}
+
+Vote ThreadPlan::ShouldReportRun(Event *event_ptr) {
+ if (m_run_vote == eVoteNoOpinion) {
+ ThreadPlan *prev_plan = GetPreviousPlan();
+ if (prev_plan)
+ return prev_plan->ShouldReportRun(event_ptr);
+ }
+ return m_run_vote;
+}
+
+bool ThreadPlan::StopOthers() {
+ ThreadPlan *prev_plan;
+ prev_plan = GetPreviousPlan();
+ return (prev_plan == nullptr) ? false : prev_plan->StopOthers();
+}
+
+void ThreadPlan::SetStopOthers(bool new_value) {
+ // SetStopOthers doesn't work up the hierarchy. You have to set the
+ // explicit ThreadPlan you want to affect.
+}
+
+bool ThreadPlan::WillResume(StateType resume_state, bool current_plan) {
+ m_cached_plan_explains_stop = eLazyBoolCalculate;
+
+ if (current_plan) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+ if (log) {
+ RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+ assert(reg_ctx);
+ addr_t pc = reg_ctx->GetPC();
+ addr_t sp = reg_ctx->GetSP();
+ addr_t fp = reg_ctx->GetFP();
+ log->Printf(
+ "%s Thread #%u (0x%p): tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64
+ ", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
+ "plan = '%s', state = %s, stop others = %d",
+ __FUNCTION__, m_thread.GetIndexID(), static_cast<void *>(&m_thread),
+ m_thread.GetID(), static_cast<uint64_t>(pc),
+ static_cast<uint64_t>(sp), static_cast<uint64_t>(fp), m_name.c_str(),
+ StateAsCString(resume_state), StopOthers());
}
+ }
+ return DoWillResume(resume_state, current_plan);
}
-bool
-ThreadPlan::IsPlanComplete ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
- return m_plan_complete;
+lldb::user_id_t ThreadPlan::GetNextID() {
+ static uint32_t g_nextPlanID = 0;
+ return ++g_nextPlanID;
}
-void
-ThreadPlan::SetPlanComplete (bool success)
-{
- std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
- m_plan_complete = true;
- m_plan_succeeded = success;
+void ThreadPlan::DidPush() {}
+
+void ThreadPlan::WillPop() {}
+
+bool ThreadPlan::OkayToDiscard() {
+ return IsMasterPlan() ? m_okay_to_discard : true;
}
-bool
-ThreadPlan::MischiefManaged ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
- // Mark the plan is complete, but don't override the success flag.
- m_plan_complete = true;
+lldb::StateType ThreadPlan::RunState() {
+ if (m_tracer_sp && m_tracer_sp->TracingEnabled() &&
+ m_tracer_sp->SingleStepEnabled())
+ return eStateStepping;
+ else
+ return GetPlanRunState();
+}
+
+bool ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason) {
+ switch (reason) {
+ case eStopReasonWatchpoint:
+ case eStopReasonSignal:
+ case eStopReasonException:
+ case eStopReasonExec:
+ case eStopReasonThreadExiting:
+ case eStopReasonInstrumentation:
return true;
-}
-
-Vote
-ThreadPlan::ShouldReportStop (Event *event_ptr)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
- if (m_stop_vote == eVoteNoOpinion)
- {
- ThreadPlan *prev_plan = GetPreviousPlan ();
- if (prev_plan)
- {
- Vote prev_vote = prev_plan->ShouldReportStop (event_ptr);
- if (log)
- log->Printf ("ThreadPlan::ShouldReportStop() returning previous thread plan vote: %s",
- GetVoteAsCString (prev_vote));
- return prev_vote;
- }
- }
- if (log)
- log->Printf ("ThreadPlan::ShouldReportStop() returning vote: %s", GetVoteAsCString (m_stop_vote));
- return m_stop_vote;
-}
-
-Vote
-ThreadPlan::ShouldReportRun (Event *event_ptr)
-{
- if (m_run_vote == eVoteNoOpinion)
- {
- ThreadPlan *prev_plan = GetPreviousPlan ();
- if (prev_plan)
- return prev_plan->ShouldReportRun (event_ptr);
- }
- return m_run_vote;
-}
-
-bool
-ThreadPlan::StopOthers ()
-{
- ThreadPlan *prev_plan;
- prev_plan = GetPreviousPlan ();
- return (prev_plan == nullptr) ? false : prev_plan->StopOthers();
-}
-
-void
-ThreadPlan::SetStopOthers (bool new_value)
-{
- // SetStopOthers doesn't work up the hierarchy. You have to set the
- // explicit ThreadPlan you want to affect.
-}
-
-bool
-ThreadPlan::WillResume (StateType resume_state, bool current_plan)
-{
- m_cached_plan_explains_stop = eLazyBoolCalculate;
-
- if (current_plan)
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
- if (log)
- {
- RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
- assert (reg_ctx);
- addr_t pc = reg_ctx->GetPC();
- addr_t sp = reg_ctx->GetSP();
- addr_t fp = reg_ctx->GetFP();
- log->Printf("%s Thread #%u (0x%p): tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64 ", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
- "plan = '%s', state = %s, stop others = %d",
- __FUNCTION__, m_thread.GetIndexID(),
- static_cast<void*>(&m_thread), m_thread.GetID(),
- static_cast<uint64_t>(pc), static_cast<uint64_t>(sp),
- static_cast<uint64_t>(fp), m_name.c_str(),
- StateAsCString(resume_state), StopOthers());
- }
- }
- return DoWillResume (resume_state, current_plan);
-}
-
-lldb::user_id_t
-ThreadPlan::GetNextID()
-{
- static uint32_t g_nextPlanID = 0;
- return ++g_nextPlanID;
-}
-
-void
-ThreadPlan::DidPush()
-{
-}
-
-void
-ThreadPlan::WillPop()
-{
-}
-
-bool
-ThreadPlan::OkayToDiscard()
-{
- return IsMasterPlan() ? m_okay_to_discard : true;
-}
-
-lldb::StateType
-ThreadPlan::RunState ()
-{
- if (m_tracer_sp && m_tracer_sp->TracingEnabled() && m_tracer_sp->SingleStepEnabled())
- return eStateStepping;
- else
- return GetPlanRunState();
-}
-
-bool
-ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason)
-{
- switch (reason)
- {
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- case eStopReasonInstrumentation:
- return true;
- default:
- return false;
- }
+ default:
+ return false;
+ }
}
//----------------------------------------------------------------------
// ThreadPlanNull
//----------------------------------------------------------------------
-ThreadPlanNull::ThreadPlanNull (Thread &thread) :
- ThreadPlan (ThreadPlan::eKindNull,
- "Null Thread Plan",
- thread,
- eVoteNoOpinion,
- eVoteNoOpinion)
-{
-}
+ThreadPlanNull::ThreadPlanNull(Thread &thread)
+ : ThreadPlan(ThreadPlan::eKindNull, "Null Thread Plan", thread,
+ eVoteNoOpinion, eVoteNoOpinion) {}
ThreadPlanNull::~ThreadPlanNull() = default;
-void
-ThreadPlanNull::GetDescription (Stream *s,
- lldb::DescriptionLevel level)
-{
- s->PutCString("Null thread plan - thread has been destroyed.");
+void ThreadPlanNull::GetDescription(Stream *s, lldb::DescriptionLevel level) {
+ s->PutCString("Null thread plan - thread has been destroyed.");
}
-bool
-ThreadPlanNull::ValidatePlan (Stream *error)
-{
+bool ThreadPlanNull::ValidatePlan(Stream *error) {
#ifdef LLDB_CONFIGURATION_DEBUG
- fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ fprintf(stderr,
+ "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
#else
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
- if (log)
- log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+ if (log)
+ log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+ m_thread.GetProtocolID());
#endif
- return true;
+ return true;
}
-bool
-ThreadPlanNull::ShouldStop (Event *event_ptr)
-{
+bool ThreadPlanNull::ShouldStop(Event *event_ptr) {
#ifdef LLDB_CONFIGURATION_DEBUG
- fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ fprintf(stderr,
+ "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
#else
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
- if (log)
- log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+ if (log)
+ log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+ m_thread.GetProtocolID());
#endif
- return true;
+ return true;
}
-bool
-ThreadPlanNull::WillStop ()
-{
+bool ThreadPlanNull::WillStop() {
#ifdef LLDB_CONFIGURATION_DEBUG
- fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ fprintf(stderr,
+ "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
#else
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
- if (log)
- log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+ if (log)
+ log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+ m_thread.GetProtocolID());
#endif
- return true;
+ return true;
}
-bool
-ThreadPlanNull::DoPlanExplainsStop (Event *event_ptr)
-{
+bool ThreadPlanNull::DoPlanExplainsStop(Event *event_ptr) {
#ifdef LLDB_CONFIGURATION_DEBUG
- fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ fprintf(stderr,
+ "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
#else
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
- if (log)
- log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+ if (log)
+ log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+ m_thread.GetProtocolID());
#endif
- return true;
+ return true;
}
// The null plan is never done.
-bool
-ThreadPlanNull::MischiefManaged ()
-{
- // The null plan is never done.
+bool ThreadPlanNull::MischiefManaged() {
+// The null plan is never done.
#ifdef LLDB_CONFIGURATION_DEBUG
- fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ fprintf(stderr,
+ "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
#else
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
- if (log)
- log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+ if (log)
+ log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+ m_thread.GetProtocolID());
#endif
- return false;
+ return false;
}
-lldb::StateType
-ThreadPlanNull::GetPlanRunState ()
-{
- // Not sure what to return here. This is a dead thread.
+lldb::StateType ThreadPlanNull::GetPlanRunState() {
+// Not sure what to return here. This is a dead thread.
#ifdef LLDB_CONFIGURATION_DEBUG
- fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ fprintf(stderr,
+ "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
#else
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
- if (log)
- log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION,
- m_thread.GetID(),
- m_thread.GetProtocolID());
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+ if (log)
+ log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+ ", ptid = 0x%" PRIx64 ")",
+ LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+ m_thread.GetProtocolID());
#endif
- return eStateRunning;
+ return eStateRunning;
}