Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- ThreadPlanStepOverRange.cpp -----------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/Target/ThreadPlanStepOverRange.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | |
| 17 | #include "lldb/lldb-private-log.h" |
| 18 | #include "lldb/Core/Log.h" |
| 19 | #include "lldb/Core/Stream.h" |
| 20 | #include "lldb/Target/Process.h" |
| 21 | #include "lldb/Target/RegisterContext.h" |
| 22 | #include "lldb/Target/Thread.h" |
| 23 | #include "lldb/Target/ThreadPlanStepOut.h" |
| 24 | #include "lldb/Target/ThreadPlanStepThrough.h" |
| 25 | |
| 26 | using namespace lldb_private; |
| 27 | |
| 28 | |
| 29 | //---------------------------------------------------------------------- |
| 30 | // ThreadPlanStepOverRange: Step through a stack range, either stepping over or into |
| 31 | // based on the value of \a type. |
| 32 | //---------------------------------------------------------------------- |
| 33 | |
| 34 | ThreadPlanStepOverRange::ThreadPlanStepOverRange |
| 35 | ( |
| 36 | Thread &thread, |
| 37 | const AddressRange &range, |
| 38 | const SymbolContext &addr_context, |
| 39 | lldb::RunMode stop_others, |
| 40 | bool okay_to_discard |
| 41 | ) : |
Jim Ingham | 5a47e8b | 2010-06-19 04:45:32 +0000 | [diff] [blame] | 42 | ThreadPlanStepRange (ThreadPlan::eKindStepOverRange, "Step range stepping over", thread, range, addr_context, stop_others) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 43 | { |
| 44 | SetOkayToDiscard (okay_to_discard); |
| 45 | } |
| 46 | |
| 47 | ThreadPlanStepOverRange::~ThreadPlanStepOverRange () |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | void |
| 52 | ThreadPlanStepOverRange::GetDescription (Stream *s, lldb::DescriptionLevel level) |
| 53 | { |
| 54 | if (level == lldb::eDescriptionLevelBrief) |
| 55 | s->Printf("step over"); |
| 56 | else |
| 57 | { |
| 58 | s->Printf ("stepping through range (stepping over functions): "); |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 59 | m_address_range.Dump (s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | |
| 63 | bool |
| 64 | ThreadPlanStepOverRange::ShouldStop (Event *event_ptr) |
| 65 | { |
| 66 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); |
| 67 | |
| 68 | if (log) |
| 69 | { |
| 70 | StreamString s; |
| 71 | s.Address (m_thread.GetRegisterContext()->GetPC(), m_thread.GetProcess().GetAddressByteSize()); |
| 72 | log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData()); |
| 73 | } |
| 74 | |
| 75 | // If we're still in the range, keep going. |
| 76 | if (InRange()) |
| 77 | return false; |
| 78 | |
| 79 | // If we're out of the range but in the same frame or in our caller's frame |
| 80 | // then we should stop. |
| 81 | // When stepping out we only step if we are forcing running one thread. |
| 82 | bool stop_others; |
| 83 | if (m_stop_others == lldb::eOnlyThisThread) |
| 84 | stop_others = true; |
| 85 | else |
| 86 | stop_others = false; |
| 87 | |
| 88 | ThreadPlan* new_plan = NULL; |
| 89 | |
| 90 | if (FrameIsOlder()) |
| 91 | return true; |
| 92 | else if (FrameIsYounger()) |
| 93 | { |
| 94 | new_plan = m_thread.QueueThreadPlanForStepOut (false, NULL, true, stop_others, lldb::eVoteNo, lldb::eVoteNoOpinion); |
| 95 | } |
| 96 | else if (!InSymbol()) |
| 97 | { |
| 98 | // This one is a little tricky. Sometimes we may be in a stub or something similar, |
| 99 | // in which case we need to get out of there. But if we are in a stub then it's |
| 100 | // likely going to be hard to get out from here. It is probably easiest to step into the |
| 101 | // stub, and then it will be straight-forward to step out. |
| 102 | new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others); |
| 103 | } |
| 104 | |
| 105 | if (new_plan == NULL) |
| 106 | m_no_more_plans = true; |
| 107 | else |
| 108 | m_no_more_plans = false; |
| 109 | |
| 110 | if (new_plan == NULL) |
| 111 | { |
| 112 | // For efficiencies sake, we know we're done here so we don't have to do this |
| 113 | // calculation again in MischiefManaged. |
| 114 | SetPlanComplete(); |
| 115 | return true; |
| 116 | } |
| 117 | else |
| 118 | return false; |
| 119 | } |