summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/ThreadPlanStepInstruction.cpp
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Target/ThreadPlanStepInstruction.cpp
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
*** 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
Diffstat (limited to 'lldb/source/Target/ThreadPlanStepInstruction.cpp')
-rw-r--r--lldb/source/Target/ThreadPlanStepInstruction.cpp426
1 files changed, 187 insertions, 239 deletions
diff --git a/lldb/source/Target/ThreadPlanStepInstruction.cpp b/lldb/source/Target/ThreadPlanStepInstruction.cpp
index ccfd52e00e1..6ad6a2343a5 100644
--- a/lldb/source/Target/ThreadPlanStepInstruction.cpp
+++ b/lldb/source/Target/ThreadPlanStepInstruction.cpp
@@ -27,270 +27,218 @@ using namespace lldb_private;
// ThreadPlanStepInstruction: Step over the current instruction
//----------------------------------------------------------------------
-ThreadPlanStepInstruction::ThreadPlanStepInstruction
-(
- Thread &thread,
- bool step_over,
- bool stop_other_threads,
- Vote stop_vote,
- Vote run_vote
-) :
- ThreadPlan (ThreadPlan::eKindStepInstruction, "Step over single instruction", thread, stop_vote, run_vote),
- m_instruction_addr (0),
- m_stop_other_threads (stop_other_threads),
- m_step_over (step_over)
-{
- m_takes_iteration_count = true;
- SetUpState();
+ThreadPlanStepInstruction::ThreadPlanStepInstruction(Thread &thread,
+ bool step_over,
+ bool stop_other_threads,
+ Vote stop_vote,
+ Vote run_vote)
+ : ThreadPlan(ThreadPlan::eKindStepInstruction,
+ "Step over single instruction", thread, stop_vote, run_vote),
+ m_instruction_addr(0), m_stop_other_threads(stop_other_threads),
+ m_step_over(step_over) {
+ m_takes_iteration_count = true;
+ SetUpState();
}
ThreadPlanStepInstruction::~ThreadPlanStepInstruction() = default;
-void
-ThreadPlanStepInstruction::SetUpState()
-{
- m_instruction_addr = m_thread.GetRegisterContext()->GetPC(0);
- 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 != nullptr;
-
- StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
- if (parent_frame_sp)
- m_parent_frame_id = parent_frame_sp->GetStackID();
+void ThreadPlanStepInstruction::SetUpState() {
+ m_instruction_addr = m_thread.GetRegisterContext()->GetPC(0);
+ 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 != nullptr;
+
+ StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
+ if (parent_frame_sp)
+ m_parent_frame_id = parent_frame_sp->GetStackID();
}
-void
-ThreadPlanStepInstruction::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- if (level == lldb::eDescriptionLevelBrief)
- {
- if (m_step_over)
- s->Printf ("instruction step over");
- else
- s->Printf ("instruction step into");
- }
+void ThreadPlanStepInstruction::GetDescription(Stream *s,
+ lldb::DescriptionLevel level) {
+ if (level == lldb::eDescriptionLevelBrief) {
+ if (m_step_over)
+ s->Printf("instruction step over");
else
- {
- s->Printf ("Stepping one instruction past ");
- s->Address(m_instruction_addr, sizeof (addr_t));
- if (!m_start_has_symbol)
- s->Printf(" which has no symbol");
-
- if (m_step_over)
- s->Printf(" stepping over calls");
- else
- s->Printf(" stepping into calls");
- }
+ s->Printf("instruction step into");
+ } else {
+ s->Printf("Stepping one instruction past ");
+ s->Address(m_instruction_addr, sizeof(addr_t));
+ if (!m_start_has_symbol)
+ s->Printf(" which has no symbol");
+
+ if (m_step_over)
+ s->Printf(" stepping over calls");
+ else
+ s->Printf(" stepping into calls");
+ }
}
-bool
-ThreadPlanStepInstruction::ValidatePlan (Stream *error)
-{
- // Since we read the instruction we're stepping over from the thread,
- // this plan will always work.
- return true;
+bool ThreadPlanStepInstruction::ValidatePlan(Stream *error) {
+ // Since we read the instruction we're stepping over from the thread,
+ // this plan will always work.
+ return true;
}
-bool
-ThreadPlanStepInstruction::DoPlanExplainsStop (Event *event_ptr)
-{
- StopInfoSP stop_info_sp = GetPrivateStopInfo ();
- if (stop_info_sp)
- {
- StopReason reason = stop_info_sp->GetStopReason();
- return (reason == eStopReasonTrace || reason == eStopReasonNone);
- }
- return false;
+bool ThreadPlanStepInstruction::DoPlanExplainsStop(Event *event_ptr) {
+ StopInfoSP stop_info_sp = GetPrivateStopInfo();
+ if (stop_info_sp) {
+ StopReason reason = stop_info_sp->GetStopReason();
+ return (reason == eStopReasonTrace || reason == eStopReasonNone);
+ }
+ return false;
}
-bool
-ThreadPlanStepInstruction::IsPlanStale ()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
- StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
- if (cur_frame_id == m_stack_id)
- {
- 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.
- return !m_step_over;
- }
- else
- {
- if (log)
- {
- log->Printf ("ThreadPlanStepInstruction::IsPlanStale - Current frame is older than start frame, plan is stale.");
- }
- return true;
+bool ThreadPlanStepInstruction::IsPlanStale() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+ StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+ if (cur_frame_id == m_stack_id) {
+ 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.
+ return !m_step_over;
+ } else {
+ if (log) {
+ log->Printf("ThreadPlanStepInstruction::IsPlanStale - Current frame is "
+ "older than start frame, plan is stale.");
}
+ return true;
+ }
}
-bool
-ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
-{
- if (m_step_over)
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
- StackFrameSP cur_frame_sp = m_thread.GetStackFrameAtIndex(0);
- if (!cur_frame_sp)
- {
- if (log)
- log->Printf ("ThreadPlanStepInstruction couldn't get the 0th frame, stopping.");
- SetPlanComplete();
- return true;
- }
-
- StackID cur_frame_zero_id = cur_frame_sp->GetStackID();
-
- if (cur_frame_zero_id == m_stack_id || m_stack_id < cur_frame_zero_id)
- {
- if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr)
- {
- if (--m_iteration_count <= 0)
- {
- SetPlanComplete();
- return true;
- }
- else
- {
- // We are still stepping, reset the start pc, and in case we've stepped out,
- // reset the current stack id.
- SetUpState();
- return false;
- }
- }
- else
- return false;
- }
- else
- {
- // We've stepped in, step back out again:
- StackFrame *return_frame = m_thread.GetStackFrameAtIndex(1).get();
- if (return_frame)
- {
- if (return_frame->GetStackID() != m_parent_frame_id || m_start_has_symbol)
- {
- // next-instruction shouldn't step out of inlined functions. But we may have stepped into a
- // real function that starts with an inlined function, and we do want to step out of that...
-
- if (cur_frame_sp->IsInlined())
- {
- StackFrameSP parent_frame_sp = m_thread.GetFrameWithStackID(m_stack_id);
-
- if(parent_frame_sp && parent_frame_sp->GetConcreteFrameIndex() == cur_frame_sp->GetConcreteFrameIndex())
- {
- SetPlanComplete();
- if (log)
- {
- log->Printf("Frame we stepped into is inlined into the frame we were stepping from, stopping.");
- }
- return true;
- }
- }
+bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
+ if (m_step_over) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+ StackFrameSP cur_frame_sp = m_thread.GetStackFrameAtIndex(0);
+ if (!cur_frame_sp) {
+ if (log)
+ log->Printf(
+ "ThreadPlanStepInstruction couldn't get the 0th frame, stopping.");
+ SetPlanComplete();
+ return true;
+ }
- if (log)
- {
- StreamString s;
- s.PutCString ("Stepped in to: ");
- addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
- s.Address (stop_addr, m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
- s.PutCString (" stepping out to: ");
- addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
- s.Address (return_addr, m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
- log->Printf("%s.", s.GetData());
- }
-
- // StepInstruction should probably have the tri-state RunMode, but for now it is safer to
- // run others.
- const bool stop_others = false;
- m_thread.QueueThreadPlanForStepOutNoShouldStop(false,
- nullptr,
- true,
- stop_others,
- eVoteNo,
- eVoteNoOpinion,
- 0);
- return false;
- }
- else
- {
- if (log)
- {
- log->PutCString("The stack id we are stepping in changed, but our parent frame did not when stepping from code with no symbols. "
- "We are probably just confused about where we are, stopping.");
- }
- SetPlanComplete();
- return true;
- }
- }
- else
- {
- if (log)
- log->Printf("Could not find previous frame, stopping.");
- SetPlanComplete();
- return true;
- }
+ StackID cur_frame_zero_id = cur_frame_sp->GetStackID();
+
+ if (cur_frame_zero_id == m_stack_id || m_stack_id < cur_frame_zero_id) {
+ if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr) {
+ if (--m_iteration_count <= 0) {
+ SetPlanComplete();
+ return true;
+ } else {
+ // We are still stepping, reset the start pc, and in case we've
+ // stepped out,
+ // reset the current stack id.
+ SetUpState();
+ return false;
}
- }
- else
- {
- lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC(0);
- if (pc_addr != m_instruction_addr)
- {
- if (--m_iteration_count <= 0)
- {
- SetPlanComplete();
- return true;
- }
- else
- {
- // We are still stepping, reset the start pc, and in case we've stepped in or out,
- // reset the current stack id.
- SetUpState();
- return false;
+ } else
+ return false;
+ } else {
+ // We've stepped in, step back out again:
+ StackFrame *return_frame = m_thread.GetStackFrameAtIndex(1).get();
+ if (return_frame) {
+ if (return_frame->GetStackID() != m_parent_frame_id ||
+ m_start_has_symbol) {
+ // next-instruction shouldn't step out of inlined functions. But we
+ // may have stepped into a
+ // real function that starts with an inlined function, and we do want
+ // to step out of that...
+
+ if (cur_frame_sp->IsInlined()) {
+ StackFrameSP parent_frame_sp =
+ m_thread.GetFrameWithStackID(m_stack_id);
+
+ if (parent_frame_sp &&
+ parent_frame_sp->GetConcreteFrameIndex() ==
+ cur_frame_sp->GetConcreteFrameIndex()) {
+ SetPlanComplete();
+ if (log) {
+ log->Printf("Frame we stepped into is inlined into the frame "
+ "we were stepping from, stopping.");
+ }
+ return true;
}
+ }
+
+ if (log) {
+ StreamString s;
+ s.PutCString("Stepped in to: ");
+ addr_t stop_addr =
+ m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
+ s.Address(stop_addr, m_thread.CalculateTarget()
+ ->GetArchitecture()
+ .GetAddressByteSize());
+ s.PutCString(" stepping out to: ");
+ addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
+ s.Address(return_addr, m_thread.CalculateTarget()
+ ->GetArchitecture()
+ .GetAddressByteSize());
+ log->Printf("%s.", s.GetData());
+ }
+
+ // StepInstruction should probably have the tri-state RunMode, but for
+ // now it is safer to
+ // run others.
+ const bool stop_others = false;
+ m_thread.QueueThreadPlanForStepOutNoShouldStop(
+ false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion, 0);
+ return false;
+ } else {
+ if (log) {
+ log->PutCString(
+ "The stack id we are stepping in changed, but our parent frame "
+ "did not when stepping from code with no symbols. "
+ "We are probably just confused about where we are, stopping.");
+ }
+ SetPlanComplete();
+ return true;
}
- else
- return false;
+ } else {
+ if (log)
+ log->Printf("Could not find previous frame, stopping.");
+ SetPlanComplete();
+ return true;
+ }
}
+ } else {
+ lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC(0);
+ if (pc_addr != m_instruction_addr) {
+ if (--m_iteration_count <= 0) {
+ SetPlanComplete();
+ return true;
+ } else {
+ // We are still stepping, reset the start pc, and in case we've stepped
+ // in or out,
+ // reset the current stack id.
+ SetUpState();
+ return false;
+ }
+ } else
+ return false;
+ }
}
-bool
-ThreadPlanStepInstruction::StopOthers ()
-{
- return m_stop_other_threads;
-}
+bool ThreadPlanStepInstruction::StopOthers() { return m_stop_other_threads; }
-StateType
-ThreadPlanStepInstruction::GetPlanRunState ()
-{
- return eStateStepping;
+StateType ThreadPlanStepInstruction::GetPlanRunState() {
+ return eStateStepping;
}
-bool
-ThreadPlanStepInstruction::WillStop ()
-{
- return true;
-}
+bool ThreadPlanStepInstruction::WillStop() { return true; }
-bool
-ThreadPlanStepInstruction::MischiefManaged ()
-{
- if (IsPlanComplete())
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Completed single instruction step plan.");
- ThreadPlan::MischiefManaged ();
- return true;
- }
- else
- {
- return false;
- }
+bool ThreadPlanStepInstruction::MischiefManaged() {
+ if (IsPlanComplete()) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+ if (log)
+ log->Printf("Completed single instruction step plan.");
+ ThreadPlan::MischiefManaged();
+ return true;
+ } else {
+ return false;
+ }
}
OpenPOWER on IntegriCloud