2626#include " lldb/Target/Thread.h"
2727#include " lldb/Target/ThreadPlanCallFunction.h"
2828#include " lldb/Target/ThreadPlanRunToAddress.h"
29+ #include " lldb/Target/ThreadPlanStepInstruction.h"
2930#include " lldb/Utility/DataBuffer.h"
3031#include " lldb/Utility/DataBufferHeap.h"
3132#include " lldb/Utility/LLDBLog.h"
@@ -923,15 +924,15 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread &thread,
923924 if (current_symbol != nullptr ) {
924925 std::vector<Address> addresses;
925926
927+ ConstString current_name =
928+ current_symbol->GetMangled ().GetName (Mangled::ePreferMangled);
926929 if (current_symbol->IsTrampoline ()) {
927- ConstString trampoline_name =
928- current_symbol->GetMangled ().GetName (Mangled::ePreferMangled);
929930
930- if (trampoline_name ) {
931+ if (current_name ) {
931932 const ModuleList &images = target_sp->GetImages ();
932933
933934 SymbolContextList code_symbols;
934- images.FindSymbolsWithNameAndType (trampoline_name , eSymbolTypeCode,
935+ images.FindSymbolsWithNameAndType (current_name , eSymbolTypeCode,
935936 code_symbols);
936937 for (const SymbolContext &context : code_symbols) {
937938 Address addr = context.GetFunctionOrSymbolAddress ();
@@ -945,8 +946,8 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread &thread,
945946 }
946947
947948 SymbolContextList reexported_symbols;
948- images.FindSymbolsWithNameAndType (
949- trampoline_name, eSymbolTypeReExported, reexported_symbols);
949+ images.FindSymbolsWithNameAndType (current_name, eSymbolTypeReExported,
950+ reexported_symbols);
950951 for (const SymbolContext &context : reexported_symbols) {
951952 if (context.symbol ) {
952953 Symbol *actual_symbol =
@@ -968,7 +969,7 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread &thread,
968969 }
969970
970971 SymbolContextList indirect_symbols;
971- images.FindSymbolsWithNameAndType (trampoline_name , eSymbolTypeResolver,
972+ images.FindSymbolsWithNameAndType (current_name , eSymbolTypeResolver,
972973 indirect_symbols);
973974
974975 for (const SymbolContext &context : indirect_symbols) {
@@ -1028,6 +1029,23 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread &thread,
10281029 thread_plan_sp = std::make_shared<ThreadPlanRunToAddress>(
10291030 thread, load_addrs, stop_others);
10301031 }
1032+ // One more case we have to consider is "branch islands". These are regular
1033+ // TEXT symbols but their names end in .island plus maybe a .digit suffix.
1034+ // They are to allow arm64 code to branch further than the size of the
1035+ // address slot allows. We just need to single-instruction step in that
1036+ // case.
1037+ static const char *g_branch_island_pattern = " \\ .island\\ .?[0-9]*$" ;
1038+ static RegularExpression g_branch_island_regex (g_branch_island_pattern);
1039+
1040+ bool is_branch_island = g_branch_island_regex.Execute (current_name);
1041+ if (!thread_plan_sp && is_branch_island) {
1042+ thread_plan_sp = std::make_shared<ThreadPlanStepInstruction>(
1043+ thread,
1044+ /* step_over= */ false , /* stop_others */ false , eVoteNoOpinion,
1045+ eVoteNoOpinion);
1046+ LLDB_LOG (log, " Stepping one instruction over branch island: '{0}'." ,
1047+ current_name);
1048+ }
10311049 } else {
10321050 LLDB_LOGF (log, " Could not find symbol for step through." );
10331051 }
0 commit comments