comparison lldb/source/Target/ThreadPlanStepInRange.cpp @ 173:0572611fdcc8 llvm10 llvm12

reorgnization done
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 11:55:54 +0900
parents 1d019706d866
children 2e18cbf3894f
comparison
equal deleted inserted replaced
172:9fbae9c8bf63 173:0572611fdcc8
67 67
68 void ThreadPlanStepInRange::SetupAvoidNoDebug( 68 void ThreadPlanStepInRange::SetupAvoidNoDebug(
69 LazyBool step_in_avoids_code_without_debug_info, 69 LazyBool step_in_avoids_code_without_debug_info,
70 LazyBool step_out_avoids_code_without_debug_info) { 70 LazyBool step_out_avoids_code_without_debug_info) {
71 bool avoid_nodebug = true; 71 bool avoid_nodebug = true;
72 72 Thread &thread = GetThread();
73 switch (step_in_avoids_code_without_debug_info) { 73 switch (step_in_avoids_code_without_debug_info) {
74 case eLazyBoolYes: 74 case eLazyBoolYes:
75 avoid_nodebug = true; 75 avoid_nodebug = true;
76 break; 76 break;
77 case eLazyBoolNo: 77 case eLazyBoolNo:
78 avoid_nodebug = false; 78 avoid_nodebug = false;
79 break; 79 break;
80 case eLazyBoolCalculate: 80 case eLazyBoolCalculate:
81 avoid_nodebug = m_thread.GetStepInAvoidsNoDebug(); 81 avoid_nodebug = thread.GetStepInAvoidsNoDebug();
82 break; 82 break;
83 } 83 }
84 if (avoid_nodebug) 84 if (avoid_nodebug)
85 GetFlags().Set(ThreadPlanShouldStopHere::eStepInAvoidNoDebug); 85 GetFlags().Set(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
86 else 86 else
92 break; 92 break;
93 case eLazyBoolNo: 93 case eLazyBoolNo:
94 avoid_nodebug = false; 94 avoid_nodebug = false;
95 break; 95 break;
96 case eLazyBoolCalculate: 96 case eLazyBoolCalculate:
97 avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug(); 97 avoid_nodebug = thread.GetStepOutAvoidsNoDebug();
98 break; 98 break;
99 } 99 }
100 if (avoid_nodebug) 100 if (avoid_nodebug)
101 GetFlags().Set(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug); 101 GetFlags().Set(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
102 else 102 else
143 bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) { 143 bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
144 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); 144 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
145 145
146 if (log) { 146 if (log) {
147 StreamString s; 147 StreamString s;
148 DumpAddress( 148 DumpAddress(s.AsRawOstream(), GetThread().GetRegisterContext()->GetPC(),
149 s.AsRawOstream(), m_thread.GetRegisterContext()->GetPC(), 149 GetTarget().GetArchitecture().GetAddressByteSize());
150 m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
151 LLDB_LOGF(log, "ThreadPlanStepInRange reached %s.", s.GetData()); 150 LLDB_LOGF(log, "ThreadPlanStepInRange reached %s.", s.GetData());
152 } 151 }
153 152
154 if (IsPlanComplete()) 153 if (IsPlanComplete())
155 return true; 154 return true;
178 177
179 bool stop_others = (m_stop_others == lldb::eOnlyThisThread); 178 bool stop_others = (m_stop_others == lldb::eOnlyThisThread);
180 179
181 FrameComparison frame_order = CompareCurrentFrameToStartFrame(); 180 FrameComparison frame_order = CompareCurrentFrameToStartFrame();
182 181
182 Thread &thread = GetThread();
183 if (frame_order == eFrameCompareOlder || 183 if (frame_order == eFrameCompareOlder ||
184 frame_order == eFrameCompareSameParent) { 184 frame_order == eFrameCompareSameParent) {
185 // If we're in an older frame then we should stop. 185 // If we're in an older frame then we should stop.
186 // 186 //
187 // A caveat to this is if we think the frame is older but we're actually 187 // A caveat to this is if we think the frame is older but we're actually
188 // in a trampoline. 188 // in a trampoline.
189 // I'm going to make the assumption that you wouldn't RETURN to a 189 // I'm going to make the assumption that you wouldn't RETURN to a
190 // trampoline. So if we are in a trampoline we think the frame is older 190 // trampoline. So if we are in a trampoline we think the frame is older
191 // because the trampoline confused the backtracer. 191 // because the trampoline confused the backtracer.
192 m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough( 192 m_sub_plan_sp = thread.QueueThreadPlanForStepThrough(
193 m_stack_id, false, stop_others, m_status); 193 m_stack_id, false, stop_others, m_status);
194 if (!m_sub_plan_sp) { 194 if (!m_sub_plan_sp) {
195 // Otherwise check the ShouldStopHere for step out: 195 // Otherwise check the ShouldStopHere for step out:
196 m_sub_plan_sp = 196 m_sub_plan_sp =
197 CheckShouldStopHereAndQueueStepOut(frame_order, m_status); 197 CheckShouldStopHereAndQueueStepOut(frame_order, m_status);
231 ClearNextBranchBreakpoint(); 231 ClearNextBranchBreakpoint();
232 232
233 // We may have set the plan up above in the FrameIsOlder section: 233 // We may have set the plan up above in the FrameIsOlder section:
234 234
235 if (!m_sub_plan_sp) 235 if (!m_sub_plan_sp)
236 m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough( 236 m_sub_plan_sp = thread.QueueThreadPlanForStepThrough(
237 m_stack_id, false, stop_others, m_status); 237 m_stack_id, false, stop_others, m_status);
238 238
239 if (log) { 239 if (log) {
240 if (m_sub_plan_sp) 240 if (m_sub_plan_sp)
241 LLDB_LOGF(log, "Found a step through plan: %s", 241 LLDB_LOGF(log, "Found a step through plan: %s",
252 // If we've stepped in and we are going to stop here, check to see if we 252 // If we've stepped in and we are going to stop here, check to see if we
253 // were asked to run past the prologue, and if so do that. 253 // were asked to run past the prologue, and if so do that.
254 254
255 if (!m_sub_plan_sp && frame_order == eFrameCompareYounger && 255 if (!m_sub_plan_sp && frame_order == eFrameCompareYounger &&
256 m_step_past_prologue) { 256 m_step_past_prologue) {
257 lldb::StackFrameSP curr_frame = m_thread.GetStackFrameAtIndex(0); 257 lldb::StackFrameSP curr_frame = thread.GetStackFrameAtIndex(0);
258 if (curr_frame) { 258 if (curr_frame) {
259 size_t bytes_to_skip = 0; 259 size_t bytes_to_skip = 0;
260 lldb::addr_t curr_addr = m_thread.GetRegisterContext()->GetPC(); 260 lldb::addr_t curr_addr = thread.GetRegisterContext()->GetPC();
261 Address func_start_address; 261 Address func_start_address;
262 262
263 SymbolContext sc = curr_frame->GetSymbolContext(eSymbolContextFunction | 263 SymbolContext sc = curr_frame->GetSymbolContext(eSymbolContextFunction |
264 eSymbolContextSymbol); 264 eSymbolContextSymbol);
265 265
266 if (sc.function) { 266 if (sc.function) {
267 func_start_address = sc.function->GetAddressRange().GetBaseAddress(); 267 func_start_address = sc.function->GetAddressRange().GetBaseAddress();
268 if (curr_addr == 268 if (curr_addr == func_start_address.GetLoadAddress(&GetTarget()))
269 func_start_address.GetLoadAddress(
270 m_thread.CalculateTarget().get()))
271 bytes_to_skip = sc.function->GetPrologueByteSize(); 269 bytes_to_skip = sc.function->GetPrologueByteSize();
272 } else if (sc.symbol) { 270 } else if (sc.symbol) {
273 func_start_address = sc.symbol->GetAddress(); 271 func_start_address = sc.symbol->GetAddress();
274 if (curr_addr == 272 if (curr_addr == func_start_address.GetLoadAddress(&GetTarget()))
275 func_start_address.GetLoadAddress(
276 m_thread.CalculateTarget().get()))
277 bytes_to_skip = sc.symbol->GetPrologueByteSize(); 273 bytes_to_skip = sc.symbol->GetPrologueByteSize();
278 } 274 }
279 275
280 if (bytes_to_skip == 0 && sc.symbol) { 276 if (bytes_to_skip == 0 && sc.symbol) {
281 TargetSP target = m_thread.CalculateTarget(); 277 const Architecture *arch = GetTarget().GetArchitecturePlugin();
282 const Architecture *arch = target->GetArchitecturePlugin();
283 if (arch) { 278 if (arch) {
284 Address curr_sec_addr; 279 Address curr_sec_addr;
285 target->GetSectionLoadList().ResolveLoadAddress(curr_addr, 280 GetTarget().GetSectionLoadList().ResolveLoadAddress(curr_addr,
286 curr_sec_addr); 281 curr_sec_addr);
287 bytes_to_skip = arch->GetBytesToSkip(*sc.symbol, curr_sec_addr); 282 bytes_to_skip = arch->GetBytesToSkip(*sc.symbol, curr_sec_addr);
288 } 283 }
289 } 284 }
290 285
291 if (bytes_to_skip != 0) { 286 if (bytes_to_skip != 0) {
292 func_start_address.Slide(bytes_to_skip); 287 func_start_address.Slide(bytes_to_skip);
293 log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP); 288 log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP);
294 LLDB_LOGF(log, "Pushing past prologue "); 289 LLDB_LOGF(log, "Pushing past prologue ");
295 290
296 m_sub_plan_sp = m_thread.QueueThreadPlanForRunToAddress( 291 m_sub_plan_sp = thread.QueueThreadPlanForRunToAddress(
297 false, func_start_address, true, m_status); 292 false, func_start_address, true, m_status);
298 } 293 }
299 } 294 }
300 } 295 }
301 } 296 }
484 479
485 bool ThreadPlanStepInRange::DoWillResume(lldb::StateType resume_state, 480 bool ThreadPlanStepInRange::DoWillResume(lldb::StateType resume_state,
486 bool current_plan) { 481 bool current_plan) {
487 m_virtual_step = false; 482 m_virtual_step = false;
488 if (resume_state == eStateStepping && current_plan) { 483 if (resume_state == eStateStepping && current_plan) {
484 Thread &thread = GetThread();
489 // See if we are about to step over a virtual inlined call. 485 // See if we are about to step over a virtual inlined call.
490 bool step_without_resume = m_thread.DecrementCurrentInlinedDepth(); 486 bool step_without_resume = thread.DecrementCurrentInlinedDepth();
491 if (step_without_resume) { 487 if (step_without_resume) {
492 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); 488 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
493 LLDB_LOGF(log, 489 LLDB_LOGF(log,
494 "ThreadPlanStepInRange::DoWillResume: returning false, " 490 "ThreadPlanStepInRange::DoWillResume: returning false, "
495 "inline_depth: %d", 491 "inline_depth: %d",
496 m_thread.GetCurrentInlinedDepth()); 492 thread.GetCurrentInlinedDepth());
497 SetStopInfo(StopInfo::CreateStopReasonToTrace(m_thread)); 493 SetStopInfo(StopInfo::CreateStopReasonToTrace(thread));
498 494
499 // FIXME: Maybe it would be better to create a InlineStep stop reason, but 495 // FIXME: Maybe it would be better to create a InlineStep stop reason, but
500 // then 496 // then
501 // the whole rest of the world would have to handle that stop reason. 497 // the whole rest of the world would have to handle that stop reason.
502 m_virtual_step = true; 498 m_virtual_step = true;