Chris Lattner | 30fdc8d | 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 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 10 | // C Includes |
| 11 | // C++ Includes |
| 12 | // Other libraries and framework includes |
| 13 | // Project includes |
Eugene Zelenko | e65b2cf | 2015-12-15 01:33:19 +0000 | [diff] [blame] | 14 | #include "lldb/Target/ThreadPlanStepOverRange.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | #include "lldb/Core/Log.h" |
| 16 | #include "lldb/Core/Stream.h" |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 17 | #include "lldb/Symbol/Block.h" |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 18 | #include "lldb/Symbol/CompileUnit.h" |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 19 | #include "lldb/Symbol/Function.h" |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 20 | #include "lldb/Symbol/LineTable.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | #include "lldb/Target/Process.h" |
| 22 | #include "lldb/Target/RegisterContext.h" |
Greg Clayton | 514487e | 2011-02-15 21:59:32 +0000 | [diff] [blame] | 23 | #include "lldb/Target/Target.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 24 | #include "lldb/Target/Thread.h" |
| 25 | #include "lldb/Target/ThreadPlanStepOut.h" |
| 26 | #include "lldb/Target/ThreadPlanStepThrough.h" |
| 27 | |
| 28 | using namespace lldb_private; |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 29 | using namespace lldb; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 30 | |
Jim Ingham | 4b4b247 | 2014-03-13 02:47:14 +0000 | [diff] [blame] | 31 | uint32_t ThreadPlanStepOverRange::s_default_flag_values = 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 32 | |
| 33 | //---------------------------------------------------------------------- |
| 34 | // ThreadPlanStepOverRange: Step through a stack range, either stepping over or into |
| 35 | // based on the value of \a type. |
| 36 | //---------------------------------------------------------------------- |
| 37 | |
| 38 | ThreadPlanStepOverRange::ThreadPlanStepOverRange |
| 39 | ( |
| 40 | Thread &thread, |
| 41 | const AddressRange &range, |
| 42 | const SymbolContext &addr_context, |
Jim Ingham | 4b4b247 | 2014-03-13 02:47:14 +0000 | [diff] [blame] | 43 | lldb::RunMode stop_others, |
| 44 | LazyBool step_out_avoids_code_without_debug_info |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 45 | ) : |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 46 | ThreadPlanStepRange (ThreadPlan::eKindStepOverRange, "Step range stepping over", thread, range, addr_context, stop_others), |
Jim Ingham | 4b4b247 | 2014-03-13 02:47:14 +0000 | [diff] [blame] | 47 | ThreadPlanShouldStopHere (this), |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 48 | m_first_resume(true) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | { |
Jim Ingham | 4b4b247 | 2014-03-13 02:47:14 +0000 | [diff] [blame] | 50 | SetFlagsToDefault(); |
| 51 | SetupAvoidNoDebug(step_out_avoids_code_without_debug_info); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Eugene Zelenko | e65b2cf | 2015-12-15 01:33:19 +0000 | [diff] [blame] | 54 | ThreadPlanStepOverRange::~ThreadPlanStepOverRange() = default; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 55 | |
| 56 | void |
| 57 | ThreadPlanStepOverRange::GetDescription (Stream *s, lldb::DescriptionLevel level) |
| 58 | { |
| 59 | if (level == lldb::eDescriptionLevelBrief) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 60 | { |
Jim Ingham | 2bdbfd5 | 2014-09-29 23:17:18 +0000 | [diff] [blame] | 61 | s->Printf("step over"); |
| 62 | return; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 63 | } |
Jim Ingham | 2bdbfd5 | 2014-09-29 23:17:18 +0000 | [diff] [blame] | 64 | s->Printf ("Stepping over"); |
| 65 | bool printed_line_info = false; |
| 66 | if (m_addr_context.line_entry.IsValid()) |
| 67 | { |
| 68 | s->Printf (" line "); |
| 69 | m_addr_context.line_entry.DumpStopContext (s, false); |
| 70 | printed_line_info = true; |
| 71 | } |
| 72 | |
| 73 | if (!printed_line_info || level == eDescriptionLevelVerbose) |
| 74 | { |
| 75 | s->Printf (" using ranges: "); |
| 76 | DumpRanges(s); |
| 77 | } |
| 78 | |
| 79 | s->PutChar('.'); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Jim Ingham | 4b4b247 | 2014-03-13 02:47:14 +0000 | [diff] [blame] | 82 | void |
| 83 | ThreadPlanStepOverRange::SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info) |
| 84 | { |
| 85 | bool avoid_nodebug = true; |
| 86 | switch (step_out_avoids_code_without_debug_info) |
| 87 | { |
| 88 | case eLazyBoolYes: |
| 89 | avoid_nodebug = true; |
| 90 | break; |
| 91 | case eLazyBoolNo: |
| 92 | avoid_nodebug = false; |
| 93 | break; |
| 94 | case eLazyBoolCalculate: |
| 95 | avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug(); |
| 96 | break; |
| 97 | } |
| 98 | if (avoid_nodebug) |
| 99 | GetFlags().Set (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug); |
| 100 | else |
| 101 | GetFlags().Clear (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug); |
Jim Ingham | 862d1bb | 2014-08-06 01:49:59 +0000 | [diff] [blame] | 102 | // Step Over plans should always avoid no-debug on step in. Seems like you shouldn't |
| 103 | // have to say this, but a tail call looks more like a step in that a step out, so |
| 104 | // we want to catch this case. |
| 105 | GetFlags().Set (ThreadPlanShouldStopHere::eStepInAvoidNoDebug); |
Jim Ingham | 4b4b247 | 2014-03-13 02:47:14 +0000 | [diff] [blame] | 106 | } |
| 107 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | bool |
Daniel Malea | 4b86728 | 2013-09-17 16:35:45 +0000 | [diff] [blame] | 109 | ThreadPlanStepOverRange::IsEquivalentContext(const SymbolContext &context) |
| 110 | { |
Daniel Malea | 4b86728 | 2013-09-17 16:35:45 +0000 | [diff] [blame] | 111 | // Match as much as is specified in the m_addr_context: |
| 112 | // This is a fairly loose sanity check. Note, sometimes the target doesn't get filled |
| 113 | // in so I left out the target check. And sometimes the module comes in as the .o file from the |
| 114 | // inlined range, so I left that out too... |
| 115 | if (m_addr_context.comp_unit) |
| 116 | { |
| 117 | if (m_addr_context.comp_unit == context.comp_unit) |
| 118 | { |
| 119 | if (m_addr_context.function && m_addr_context.function == context.function) |
| 120 | { |
Jim Ingham | 7766c4a | 2016-07-29 18:09:12 +0000 | [diff] [blame] | 121 | // It is okay to return to a different block of a straight function, we only have to |
| 122 | // be more careful if returning from one inlined block to another. |
| 123 | if (m_addr_context.block->GetInlinedFunctionInfo() == nullptr |
| 124 | && context.block->GetInlinedFunctionInfo() == nullptr) |
| 125 | return true; |
| 126 | |
Daniel Malea | 4b86728 | 2013-09-17 16:35:45 +0000 | [diff] [blame] | 127 | if (m_addr_context.block && m_addr_context.block == context.block) |
| 128 | return true; |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | else if (m_addr_context.symbol && m_addr_context.symbol == context.symbol) |
| 133 | { |
| 134 | return true; |
| 135 | } |
| 136 | return false; |
| 137 | } |
| 138 | |
| 139 | bool |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 140 | ThreadPlanStepOverRange::ShouldStop (Event *event_ptr) |
| 141 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 142 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 143 | |
| 144 | if (log) |
| 145 | { |
| 146 | StreamString s; |
Greg Clayton | 514487e | 2011-02-15 21:59:32 +0000 | [diff] [blame] | 147 | s.Address (m_thread.GetRegisterContext()->GetPC(), |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 148 | m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 149 | log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData()); |
| 150 | } |
| 151 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 152 | // If we're out of the range but in the same frame or in our caller's frame |
| 153 | // then we should stop. |
Jim Ingham | 4a58e96 | 2012-10-25 22:30:09 +0000 | [diff] [blame] | 154 | // When stepping out we only stop others if we are forcing running one thread. |
Eugene Zelenko | e65b2cf | 2015-12-15 01:33:19 +0000 | [diff] [blame] | 155 | bool stop_others = (m_stop_others == lldb::eOnlyThisThread); |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 156 | ThreadPlanSP new_plan_sp; |
Jim Ingham | b5c0d1c | 2012-03-01 00:50:50 +0000 | [diff] [blame] | 157 | FrameComparison frame_order = CompareCurrentFrameToStartFrame(); |
| 158 | |
| 159 | if (frame_order == eFrameCompareOlder) |
Jim Ingham | 5822173 | 2010-11-05 00:18:21 +0000 | [diff] [blame] | 160 | { |
| 161 | // If we're in an older frame then we should stop. |
| 162 | // |
| 163 | // A caveat to this is if we think the frame is older but we're actually in a trampoline. |
| 164 | // I'm going to make the assumption that you wouldn't RETURN to a trampoline. So if we are |
| 165 | // in a trampoline we think the frame is older because the trampoline confused the backtracer. |
| 166 | // As below, we step through first, and then try to figure out how to get back out again. |
| 167 | |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 168 | new_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others); |
Jim Ingham | 5822173 | 2010-11-05 00:18:21 +0000 | [diff] [blame] | 169 | |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 170 | if (new_plan_sp && log) |
Jim Ingham | 5822173 | 2010-11-05 00:18:21 +0000 | [diff] [blame] | 171 | log->Printf("Thought I stepped out, but in fact arrived at a trampoline."); |
| 172 | } |
Jim Ingham | b5c0d1c | 2012-03-01 00:50:50 +0000 | [diff] [blame] | 173 | else if (frame_order == eFrameCompareYounger) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 174 | { |
Jim Ingham | b5c0d1c | 2012-03-01 00:50:50 +0000 | [diff] [blame] | 175 | // Make sure we really are in a new frame. Do that by unwinding and seeing if the |
| 176 | // start function really is our start function... |
Daniel Malea | 4b86728 | 2013-09-17 16:35:45 +0000 | [diff] [blame] | 177 | for(uint32_t i = 1;; ++i) |
Jim Ingham | b5c0d1c | 2012-03-01 00:50:50 +0000 | [diff] [blame] | 178 | { |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 179 | StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(i); |
Daniel Malea | 4b86728 | 2013-09-17 16:35:45 +0000 | [diff] [blame] | 180 | if (!older_frame_sp) { |
| 181 | // We can't unwind the next frame we should just get out of here & stop... |
| 182 | break; |
| 183 | } |
| 184 | |
Jim Ingham | b5c0d1c | 2012-03-01 00:50:50 +0000 | [diff] [blame] | 185 | const SymbolContext &older_context = older_frame_sp->GetSymbolContext(eSymbolContextEverything); |
Daniel Malea | 4b86728 | 2013-09-17 16:35:45 +0000 | [diff] [blame] | 186 | if (IsEquivalentContext(older_context)) |
Jim Ingham | b5c0d1c | 2012-03-01 00:50:50 +0000 | [diff] [blame] | 187 | { |
Eugene Zelenko | e65b2cf | 2015-12-15 01:33:19 +0000 | [diff] [blame] | 188 | new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(false, |
| 189 | nullptr, |
| 190 | true, |
| 191 | stop_others, |
| 192 | eVoteNo, |
| 193 | eVoteNoOpinion, |
Jason Molenda | fd4cea5 | 2016-01-08 21:40:11 +0000 | [diff] [blame] | 194 | 0, |
| 195 | true); |
Daniel Malea | 4b86728 | 2013-09-17 16:35:45 +0000 | [diff] [blame] | 196 | break; |
Jim Ingham | b5c0d1c | 2012-03-01 00:50:50 +0000 | [diff] [blame] | 197 | } |
Daniel Malea | 4b86728 | 2013-09-17 16:35:45 +0000 | [diff] [blame] | 198 | else |
Jim Ingham | b5c0d1c | 2012-03-01 00:50:50 +0000 | [diff] [blame] | 199 | { |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 200 | new_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others); |
Jim Ingham | 5beccb2 | 2014-08-05 01:59:20 +0000 | [diff] [blame] | 201 | // If we found a way through, then we should stop recursing. |
| 202 | if (new_plan_sp) |
| 203 | break; |
Jim Ingham | b5c0d1c | 2012-03-01 00:50:50 +0000 | [diff] [blame] | 204 | } |
| 205 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 206 | } |
Jim Ingham | 564d8bc2 | 2012-03-09 04:10:47 +0000 | [diff] [blame] | 207 | else |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 208 | { |
Jim Ingham | 564d8bc2 | 2012-03-09 04:10:47 +0000 | [diff] [blame] | 209 | // If we're still in the range, keep going. |
| 210 | if (InRange()) |
| 211 | { |
| 212 | SetNextBranchBreakpoint(); |
| 213 | return false; |
| 214 | } |
| 215 | |
Jim Ingham | 564d8bc2 | 2012-03-09 04:10:47 +0000 | [diff] [blame] | 216 | if (!InSymbol()) |
| 217 | { |
| 218 | // This one is a little tricky. Sometimes we may be in a stub or something similar, |
| 219 | // in which case we need to get out of there. But if we are in a stub then it's |
| 220 | // likely going to be hard to get out from here. It is probably easiest to step into the |
| 221 | // stub, and then it will be straight-forward to step out. |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 222 | new_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others); |
Jim Ingham | 564d8bc2 | 2012-03-09 04:10:47 +0000 | [diff] [blame] | 223 | } |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 224 | else |
| 225 | { |
| 226 | // The current clang (at least through 424) doesn't always get the address range for the |
| 227 | // DW_TAG_inlined_subroutines right, so that when you leave the inlined range the line table says |
| 228 | // you are still in the source file of the inlining function. This is bad, because now you are missing |
| 229 | // the stack frame for the function containing the inlining, and if you sensibly do "finish" to get |
| 230 | // out of this function you will instead exit the containing function. |
| 231 | // To work around this, we check whether we are still in the source file we started in, and if not assume |
| 232 | // it is an error, and push a plan to get us out of this line and back to the containing file. |
| 233 | |
| 234 | if (m_addr_context.line_entry.IsValid()) |
| 235 | { |
| 236 | SymbolContext sc; |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 237 | StackFrameSP frame_sp = m_thread.GetStackFrameAtIndex(0); |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 238 | sc = frame_sp->GetSymbolContext (eSymbolContextEverything); |
| 239 | if (sc.line_entry.IsValid()) |
| 240 | { |
Ted Woodward | 911d578 | 2016-05-11 22:46:53 +0000 | [diff] [blame] | 241 | if (sc.line_entry.original_file != m_addr_context.line_entry.original_file |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 242 | && sc.comp_unit == m_addr_context.comp_unit |
| 243 | && sc.function == m_addr_context.function) |
| 244 | { |
Bruce Mitchener | 58ef391 | 2015-06-18 05:27:05 +0000 | [diff] [blame] | 245 | // Okay, find the next occurrence of this file in the line table: |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 246 | LineTable *line_table = m_addr_context.comp_unit->GetLineTable(); |
| 247 | if (line_table) |
| 248 | { |
| 249 | Address cur_address = frame_sp->GetFrameCodeAddress(); |
| 250 | uint32_t entry_idx; |
| 251 | LineEntry line_entry; |
| 252 | if (line_table->FindLineEntryByAddress (cur_address, line_entry, &entry_idx)) |
| 253 | { |
| 254 | LineEntry next_line_entry; |
| 255 | bool step_past_remaining_inline = false; |
| 256 | if (entry_idx > 0) |
| 257 | { |
Bruce Mitchener | 58ef391 | 2015-06-18 05:27:05 +0000 | [diff] [blame] | 258 | // We require the previous line entry and the current line entry come |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 259 | // from the same file. |
| 260 | // The other requirement is that the previous line table entry be part of an |
| 261 | // inlined block, we don't want to step past cases where people have inlined |
| 262 | // some code fragment by using #include <source-fragment.c> directly. |
| 263 | LineEntry prev_line_entry; |
| 264 | if (line_table->GetLineEntryAtIndex(entry_idx - 1, prev_line_entry) |
Ted Woodward | 911d578 | 2016-05-11 22:46:53 +0000 | [diff] [blame] | 265 | && prev_line_entry.original_file == line_entry.original_file) |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 266 | { |
| 267 | SymbolContext prev_sc; |
| 268 | Address prev_address = prev_line_entry.range.GetBaseAddress(); |
| 269 | prev_address.CalculateSymbolContext(&prev_sc); |
| 270 | if (prev_sc.block) |
| 271 | { |
| 272 | Block *inlined_block = prev_sc.block->GetContainingInlinedBlock(); |
| 273 | if (inlined_block) |
| 274 | { |
| 275 | AddressRange inline_range; |
| 276 | inlined_block->GetRangeContainingAddress(prev_address, inline_range); |
| 277 | if (!inline_range.ContainsFileAddress(cur_address)) |
| 278 | { |
| 279 | |
| 280 | step_past_remaining_inline = true; |
| 281 | } |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | if (step_past_remaining_inline) |
| 288 | { |
| 289 | uint32_t look_ahead_step = 1; |
| 290 | while (line_table->GetLineEntryAtIndex(entry_idx + look_ahead_step, next_line_entry)) |
| 291 | { |
| 292 | // Make sure we haven't wandered out of the function we started from... |
| 293 | Address next_line_address = next_line_entry.range.GetBaseAddress(); |
| 294 | Function *next_line_function = next_line_address.CalculateSymbolContextFunction(); |
| 295 | if (next_line_function != m_addr_context.function) |
| 296 | break; |
| 297 | |
Ted Woodward | 911d578 | 2016-05-11 22:46:53 +0000 | [diff] [blame] | 298 | if (next_line_entry.original_file == m_addr_context.line_entry.original_file) |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 299 | { |
| 300 | const bool abort_other_plans = false; |
Jim Ingham | 5582808 | 2015-08-14 01:38:21 +0000 | [diff] [blame] | 301 | const RunMode stop_other_threads = RunMode::eAllThreads; |
| 302 | lldb::addr_t cur_pc = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC(); |
| 303 | AddressRange step_range(cur_pc, next_line_address.GetLoadAddress(&GetTarget()) - cur_pc); |
| 304 | |
| 305 | new_plan_sp = m_thread.QueueThreadPlanForStepOverRange (abort_other_plans, |
| 306 | step_range, |
| 307 | sc, |
| 308 | stop_other_threads); |
Jim Ingham | 3bfa753 | 2012-11-06 01:14:52 +0000 | [diff] [blame] | 309 | break; |
| 310 | } |
| 311 | look_ahead_step++; |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 320 | } |
| 321 | |
Jim Ingham | 564d8bc2 | 2012-03-09 04:10:47 +0000 | [diff] [blame] | 322 | // If we get to this point, we're not going to use a previously set "next branch" breakpoint, so delete it: |
| 323 | ClearNextBranchBreakpoint(); |
| 324 | |
Jim Ingham | 4b4b247 | 2014-03-13 02:47:14 +0000 | [diff] [blame] | 325 | |
| 326 | // If we haven't figured out something to do yet, then ask the ShouldStopHere callback: |
| 327 | if (!new_plan_sp) |
| 328 | { |
| 329 | new_plan_sp = CheckShouldStopHereAndQueueStepOut (frame_order); |
| 330 | } |
Jim Ingham | 2bdbfd5 | 2014-09-29 23:17:18 +0000 | [diff] [blame] | 331 | |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 332 | if (!new_plan_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 333 | m_no_more_plans = true; |
| 334 | else |
Jim Ingham | 2bdbfd5 | 2014-09-29 23:17:18 +0000 | [diff] [blame] | 335 | { |
| 336 | // Any new plan will be an implementation plan, so mark it private: |
| 337 | new_plan_sp->SetPrivate(true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 338 | m_no_more_plans = false; |
Jim Ingham | 2bdbfd5 | 2014-09-29 23:17:18 +0000 | [diff] [blame] | 339 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 340 | |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 341 | if (!new_plan_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 342 | { |
| 343 | // For efficiencies sake, we know we're done here so we don't have to do this |
| 344 | // calculation again in MischiefManaged. |
| 345 | SetPlanComplete(); |
| 346 | return true; |
| 347 | } |
| 348 | else |
| 349 | return false; |
| 350 | } |
Jim Ingham | fbbfe6e | 2012-05-01 18:38:37 +0000 | [diff] [blame] | 351 | |
| 352 | bool |
Jim Ingham | 221d51c | 2013-05-08 00:35:16 +0000 | [diff] [blame] | 353 | ThreadPlanStepOverRange::DoPlanExplainsStop (Event *event_ptr) |
Jim Ingham | fbbfe6e | 2012-05-01 18:38:37 +0000 | [diff] [blame] | 354 | { |
| 355 | // For crashes, breakpoint hits, signals, etc, let the base plan (or some plan above us) |
| 356 | // handle the stop. That way the user can see the stop, step around, and then when they |
| 357 | // are done, continue and have their step complete. The exception is if we've hit our |
| 358 | // "run to next branch" breakpoint. |
| 359 | // Note, unlike the step in range plan, we don't mark ourselves complete if we hit an |
| 360 | // unexplained breakpoint/crash. |
| 361 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 362 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); |
Jim Ingham | 60c4118 | 2013-06-04 01:40:51 +0000 | [diff] [blame] | 363 | StopInfoSP stop_info_sp = GetPrivateStopInfo (); |
Jim Ingham | 221d51c | 2013-05-08 00:35:16 +0000 | [diff] [blame] | 364 | bool return_value; |
| 365 | |
Jim Ingham | fbbfe6e | 2012-05-01 18:38:37 +0000 | [diff] [blame] | 366 | if (stop_info_sp) |
| 367 | { |
| 368 | StopReason reason = stop_info_sp->GetStopReason(); |
| 369 | |
Jim Ingham | 9b03fa0 | 2015-07-23 19:55:02 +0000 | [diff] [blame] | 370 | if (reason == eStopReasonTrace) |
Jim Ingham | fbbfe6e | 2012-05-01 18:38:37 +0000 | [diff] [blame] | 371 | { |
Jim Ingham | 221d51c | 2013-05-08 00:35:16 +0000 | [diff] [blame] | 372 | return_value = true; |
Jim Ingham | 9b03fa0 | 2015-07-23 19:55:02 +0000 | [diff] [blame] | 373 | } |
| 374 | else if (reason == eStopReasonBreakpoint) |
| 375 | { |
Eugene Zelenko | e65b2cf | 2015-12-15 01:33:19 +0000 | [diff] [blame] | 376 | return_value = NextRangeBreakpointExplainsStop(stop_info_sp); |
Jim Ingham | 9b03fa0 | 2015-07-23 19:55:02 +0000 | [diff] [blame] | 377 | } |
| 378 | else |
| 379 | { |
Jim Ingham | fbbfe6e | 2012-05-01 18:38:37 +0000 | [diff] [blame] | 380 | if (log) |
| 381 | log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step."); |
Jim Ingham | 221d51c | 2013-05-08 00:35:16 +0000 | [diff] [blame] | 382 | return_value = false; |
Jim Ingham | fbbfe6e | 2012-05-01 18:38:37 +0000 | [diff] [blame] | 383 | } |
| 384 | } |
Jim Ingham | 221d51c | 2013-05-08 00:35:16 +0000 | [diff] [blame] | 385 | else |
| 386 | return_value = true; |
| 387 | |
| 388 | return return_value; |
Jim Ingham | fbbfe6e | 2012-05-01 18:38:37 +0000 | [diff] [blame] | 389 | } |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 390 | |
| 391 | bool |
Jim Ingham | 221d51c | 2013-05-08 00:35:16 +0000 | [diff] [blame] | 392 | ThreadPlanStepOverRange::DoWillResume (lldb::StateType resume_state, bool current_plan) |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 393 | { |
| 394 | if (resume_state != eStateSuspended && m_first_resume) |
| 395 | { |
| 396 | m_first_resume = false; |
| 397 | if (resume_state == eStateStepping && current_plan) |
| 398 | { |
| 399 | // See if we are about to step over an inlined call in the middle of the inlined stack, if so figure |
| 400 | // out its extents and reset our range to step over that. |
| 401 | bool in_inlined_stack = m_thread.DecrementCurrentInlinedDepth(); |
| 402 | if (in_inlined_stack) |
| 403 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 404 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 405 | if (log) |
Jim Ingham | 221d51c | 2013-05-08 00:35:16 +0000 | [diff] [blame] | 406 | log->Printf ("ThreadPlanStepInRange::DoWillResume: adjusting range to the frame at inlined depth %d.", |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 407 | m_thread.GetCurrentInlinedDepth()); |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 408 | StackFrameSP stack_sp = m_thread.GetStackFrameAtIndex(0); |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 409 | if (stack_sp) |
| 410 | { |
| 411 | Block *frame_block = stack_sp->GetFrameBlock(); |
| 412 | lldb::addr_t curr_pc = m_thread.GetRegisterContext()->GetPC(); |
| 413 | AddressRange my_range; |
| 414 | if (frame_block->GetRangeContainingLoadAddress(curr_pc, m_thread.GetProcess()->GetTarget(), my_range)) |
| 415 | { |
| 416 | m_address_ranges.clear(); |
| 417 | m_address_ranges.push_back(my_range); |
| 418 | if (log) |
| 419 | { |
| 420 | StreamString s; |
| 421 | const InlineFunctionInfo *inline_info = frame_block->GetInlinedFunctionInfo(); |
| 422 | const char *name; |
| 423 | if (inline_info) |
Greg Clayton | ddaf6a7 | 2015-07-08 22:32:23 +0000 | [diff] [blame] | 424 | name = inline_info->GetName(frame_block->CalculateSymbolContextFunction()->GetLanguage()).AsCString(); |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 425 | else |
| 426 | name = "<unknown-notinlined>"; |
| 427 | |
| 428 | s.Printf ("Stepping over inlined function \"%s\" in inlined stack: ", name); |
| 429 | DumpRanges(&s); |
| 430 | log->PutCString(s.GetData()); |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | |
Jim Ingham | 221d51c | 2013-05-08 00:35:16 +0000 | [diff] [blame] | 439 | return true; |
Jim Ingham | 513c6bb | 2012-09-01 01:02:41 +0000 | [diff] [blame] | 440 | } |