Skip to content

Commit c9f44cd

Browse files
committed
RegisterContextLLDB::GetFullUnwindPlanForFrame has four verbose
logging messages that are written the same, making it difficult to know for certain which code path was taken based on a logfile. Add some words to make each unique. Right now the ordering for finding a FullUnwindPlan (ignoring fallback unwind plan logic) is 1. If this is a _sigtramp like function, try eh_frame which is hand written on darwin systems to account for finding the saved register context correctly. 2. Ask the DynamicLoader if eh_frame should be preferred for this frame. Some binaries on the system may have hand-written eh_frame and the DynamicLoader is the source for this. (primarily this is for hand-written assembly in the objc runtime, and we tell lldb to trust that for functions in libobjc.dylib.) 3. if 0th frame, use GetUnwindPlanAtNonCallSite plan. 4. GetUnwindPlanAtCallSite {for 0th or any other} 5. GetUnwindPlanAtNonCallSite {now for non-0th frames, only if not from a compiler? hm.} 6. GetUnwindPlanArchitectureDefaultAtFunctionEntry if we're on the first instruction 7. Architectural default unwind plan ABI::CreateDefaultUnwindPlan I'm moving #6 -- DefaultAtFunctionEntry -- up to between #3 and #4, where we're already doing things specific to the zeroth frame. If we're on the zeroth frame and the GetUnwindPlanAtNonCallSite plan has failed for some reason, and we're on the first instruction, we should definitely use DefaultAtFunctionEntry instead of any other unwind plan. If we're trying to step out of some rando function on the system that we couldn't assembly instruction inspect, this is sufficient for us to step out of it. llvm-svn: 359847
1 parent a0ac5af commit c9f44cd

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp

+24-18
Original file line numberDiff line numberDiff line change
@@ -883,10 +883,27 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
883883
m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp;
884884
}
885885
}
886-
UnwindLogMsgVerbose("frame uses %s for full UnwindPlan",
886+
UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because this "
887+
"is the non-call site unwind plan and this is a "
888+
"zeroth frame",
887889
unwind_plan_sp->GetSourceName().GetCString());
888890
return unwind_plan_sp;
889891
}
892+
893+
// If we're on the first instruction of a function, and we have an
894+
// architectural default UnwindPlan for the initial instruction of a
895+
// function, use that.
896+
if (m_current_offset == 0) {
897+
unwind_plan_sp =
898+
func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry(
899+
m_thread);
900+
if (unwind_plan_sp) {
901+
UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because we are at "
902+
"the first instruction of a function",
903+
unwind_plan_sp->GetSourceName().GetCString());
904+
return unwind_plan_sp;
905+
}
906+
}
890907
}
891908

892909
// Typically this is unwind info from an eh_frame section intended for
@@ -897,7 +914,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
897914
}
898915
int valid_offset = -1;
899916
if (IsUnwindPlanValidForCurrentPC(unwind_plan_sp, valid_offset)) {
900-
UnwindLogMsgVerbose("frame uses %s for full UnwindPlan",
917+
UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because this "
918+
"is the call-site unwind plan",
901919
unwind_plan_sp->GetSourceName().GetCString());
902920
return unwind_plan_sp;
903921
}
@@ -934,30 +952,18 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
934952
}
935953

936954
if (IsUnwindPlanValidForCurrentPC(unwind_plan_sp, valid_offset)) {
937-
UnwindLogMsgVerbose("frame uses %s for full UnwindPlan",
955+
UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because we "
956+
"failed to find a call-site unwind plan that would work",
938957
unwind_plan_sp->GetSourceName().GetCString());
939958
return unwind_plan_sp;
940959
}
941960

942-
// If we're on the first instruction of a function, and we have an
943-
// architectural default UnwindPlan for the initial instruction of a
944-
// function, use that.
945-
if (m_current_offset_backed_up_one == 0) {
946-
unwind_plan_sp =
947-
func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry(
948-
m_thread);
949-
if (unwind_plan_sp) {
950-
UnwindLogMsgVerbose("frame uses %s for full UnwindPlan",
951-
unwind_plan_sp->GetSourceName().GetCString());
952-
return unwind_plan_sp;
953-
}
954-
}
955-
956961
// If nothing else, use the architectural default UnwindPlan and hope that
957962
// does the job.
958963
if (arch_default_unwind_plan_sp)
959964
UnwindLogMsgVerbose(
960-
"frame uses %s for full UnwindPlan",
965+
"frame uses %s for full UnwindPlan because we are falling back "
966+
"to the arch default plan",
961967
arch_default_unwind_plan_sp->GetSourceName().GetCString());
962968
else
963969
UnwindLogMsg(

0 commit comments

Comments
 (0)