@@ -442,42 +442,37 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
442
442
// 3) Thunks that retain captured objects in closure invocations.
443
443
// 4) Task switches for async functions.
444
444
445
- ThreadPlanSP new_thread_plan_sp;
446
-
447
445
Log *log (GetLog (LLDBLog::Step));
448
446
StackFrameSP stack_sp = thread.GetStackFrameAtIndex (0 );
449
447
if (!stack_sp)
450
- return new_thread_plan_sp ;
448
+ return nullptr ;
451
449
452
450
SymbolContext sc = stack_sp->GetSymbolContext (eSymbolContextEverything);
453
451
Symbol *symbol = sc.symbol ;
454
452
455
453
if (!symbol)
456
- return new_thread_plan_sp ;
454
+ return nullptr ;
457
455
458
456
// Only do this if you are at the beginning of the thunk function:
459
457
lldb::addr_t cur_addr = thread.GetRegisterContext ()->GetPC ();
460
458
lldb::addr_t symbol_addr =
461
459
symbol->GetAddress ().GetLoadAddress (&thread.GetProcess ()->GetTarget ());
462
460
463
461
if (symbol_addr != cur_addr)
464
- return new_thread_plan_sp ;
462
+ return nullptr ;
465
463
466
- Address target_address;
467
464
const char *symbol_name = symbol->GetMangled ().GetMangledName ().AsCString ();
468
465
469
466
ThunkKind thunk_kind = GetThunkKind (symbol);
470
467
ThunkAction thunk_action = GetThunkAction (thunk_kind);
471
468
472
469
switch (thunk_action) {
473
470
case ThunkAction::Unknown:
474
- return new_thread_plan_sp;
475
- case ThunkAction::AsyncStepIn: {
476
- if (ThreadPlanStepInAsync::NeedsStep (sc)) {
477
- new_thread_plan_sp.reset (new ThreadPlanStepInAsync (thread, sc));
478
- }
479
- return new_thread_plan_sp;
480
- }
471
+ return nullptr ;
472
+ case ThunkAction::AsyncStepIn:
473
+ if (ThreadPlanStepInAsync::NeedsStep (sc))
474
+ return std::make_shared<ThreadPlanStepInAsync>(thread, sc);
475
+ return nullptr ;
481
476
case ThunkAction::GetThunkTarget: {
482
477
swift::Demangle::Context demangle_ctx;
483
478
std::string thunk_target = demangle_ctx.getThunkTarget (symbol_name);
@@ -486,7 +481,7 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
486
481
log->Printf (" Stepped to thunk \" %s\" (kind: %s) but could not "
487
482
" find the thunk target. " ,
488
483
symbol_name, GetThunkKindName (thunk_kind));
489
- return new_thread_plan_sp ;
484
+ return nullptr ;
490
485
}
491
486
if (log)
492
487
log->Printf (
@@ -497,14 +492,15 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
497
492
SymbolContextList sc_list;
498
493
modules.FindFunctionSymbols (ConstString (thunk_target),
499
494
eFunctionNameTypeFull, sc_list);
500
- if (sc_list.GetSize () == 1 ) {
501
- SymbolContext sc ;
502
- sc_list. GetContextAtIndex ( 0 , sc );
503
-
504
- if (sc. symbol )
505
- target_address = sc. symbol -> GetAddress ( );
495
+ if (sc_list.GetSize () == 1 && sc_list[ 0 ]. symbol ) {
496
+ Symbol &thunk_symbol = *sc_list[ 0 ]. symbol ;
497
+ Address target_address = thunk_symbol. GetAddress ( );
498
+ if (target_address. IsValid ())
499
+ return std::make_shared<ThreadPlanRunToAddress>(thread, target_address,
500
+ stop_others );
506
501
}
507
- } break ;
502
+ return nullptr ;
503
+ }
508
504
case ThunkAction::StepIntoConformance: {
509
505
// The TTW symbols encode the protocol conformance requirements
510
506
// and it is possible to go to the AST and get it to replay the
@@ -538,7 +534,7 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
538
534
" find the ProtocolWitness node in the demangled "
539
535
" nodes." ,
540
536
symbol_name);
541
- return new_thread_plan_sp ;
537
+ return nullptr ;
542
538
}
543
539
544
540
size_t num_children = witness_node->getNumChildren ();
@@ -547,7 +543,7 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
547
543
log->Printf (" Stepped into witness thunk \" %s\" but the "
548
544
" ProtocolWitness node doesn't have enough nodes." ,
549
545
symbol_name);
550
- return new_thread_plan_sp ;
546
+ return nullptr ;
551
547
}
552
548
553
549
swift::Demangle::NodePointer function_node = witness_node->getChild (1 );
@@ -557,7 +553,7 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
557
553
log->Printf (" Stepped into witness thunk \" %s\" but could not "
558
554
" find the function in the ProtocolWitness node." ,
559
555
symbol_name);
560
- return new_thread_plan_sp ;
556
+ return nullptr ;
561
557
}
562
558
563
559
// Okay, now find the name of this function.
@@ -576,7 +572,7 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
576
572
log->Printf (" Stepped into witness thunk \" %s\" but could not "
577
573
" find the Function name in the function node." ,
578
574
symbol_name);
579
- return new_thread_plan_sp ;
575
+ return nullptr ;
580
576
}
581
577
582
578
std::string function_name (name_node->getText ());
@@ -585,38 +581,30 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
585
581
log->Printf (" Stepped into witness thunk \" %s\" but the Function "
586
582
" name was empty." ,
587
583
symbol_name);
588
- return new_thread_plan_sp ;
584
+ return nullptr ;
589
585
}
590
586
591
587
// We have to get the address range of the thunk symbol, and make a
592
588
// "step through range stepping in"
593
589
AddressRange sym_addr_range (sc.symbol ->GetAddress (),
594
590
sc.symbol ->GetByteSize ());
595
- new_thread_plan_sp. reset ( new ThreadPlanStepInRange (
591
+ return std::make_shared< ThreadPlanStepInRange> (
596
592
thread, sym_addr_range, sc, function_name.c_str (), eOnlyDuringStepping,
597
- eLazyBoolNo, eLazyBoolNo));
598
- return new_thread_plan_sp;
599
-
600
- } break ;
593
+ eLazyBoolNo, eLazyBoolNo);
594
+ }
601
595
case ThunkAction::StepThrough: {
602
596
if (log)
603
597
log->Printf (" Stepping through thunk: %s kind: %s" , symbol_name,
604
598
GetThunkKindName (thunk_kind));
605
599
AddressRange sym_addr_range (sc.symbol ->GetAddress (),
606
600
sc.symbol ->GetByteSize ());
607
- new_thread_plan_sp.reset (new ThreadPlanStepInRange (
608
- thread, sym_addr_range, sc, nullptr , eOnlyDuringStepping, eLazyBoolNo,
609
- eLazyBoolNo));
610
- return new_thread_plan_sp;
611
- } break ;
601
+ return std::make_shared<ThreadPlanStepInRange>(thread, sym_addr_range, sc,
602
+ nullptr , eOnlyDuringStepping,
603
+ eLazyBoolNo, eLazyBoolNo);
612
604
}
613
-
614
- if (target_address.IsValid ()) {
615
- new_thread_plan_sp.reset (
616
- new ThreadPlanRunToAddress (thread, target_address, stop_others));
617
605
}
618
606
619
- return new_thread_plan_sp ;
607
+ return nullptr ;
620
608
}
621
609
622
610
bool SwiftLanguageRuntime::IsSymbolARuntimeThunk (const Symbol &symbol) {
0 commit comments