@@ -82,14 +82,13 @@ RegisterContextUnwind::RegisterContextUnwind(Thread &thread,
82
82
}
83
83
84
84
bool RegisterContextUnwind::IsUnwindPlanValidForCurrentPC (
85
- lldb::UnwindPlanSP unwind_plan_sp, int &valid_pc_offset ) {
85
+ lldb::UnwindPlanSP unwind_plan_sp) {
86
86
if (!unwind_plan_sp)
87
87
return false ;
88
88
89
89
// check if m_current_pc is valid
90
90
if (unwind_plan_sp->PlanValidAtAddress (m_current_pc)) {
91
91
// yes - current offset can be used as is
92
- valid_pc_offset = m_current_offset;
93
92
return true ;
94
93
}
95
94
@@ -101,8 +100,6 @@ bool RegisterContextUnwind::IsUnwindPlanValidForCurrentPC(
101
100
Address pc_minus_one (m_current_pc);
102
101
pc_minus_one.SetOffset (m_current_pc.GetOffset () - 1 );
103
102
if (unwind_plan_sp->PlanValidAtAddress (pc_minus_one)) {
104
- // *valid_pc_offset = m_current_offset - 1;
105
- valid_pc_offset = m_current_pc.GetOffset () - 1 ;
106
103
return true ;
107
104
}
108
105
@@ -514,9 +511,12 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
514
511
} else if (!addr_range.GetBaseAddress ().IsValid () ||
515
512
addr_range.GetBaseAddress ().GetSection () != m_current_pc.GetSection () ||
516
513
addr_range.GetBaseAddress ().GetOffset () != m_current_pc.GetOffset ()) {
517
- // If our "current" pc isn't the start of a function, no need
518
- // to decrement and recompute.
519
- decr_pc_and_recompute_addr_range = false ;
514
+ // If our "current" pc isn't the start of a function, decrement the pc
515
+ // if we're up the stack.
516
+ if (m_behaves_like_zeroth_frame)
517
+ decr_pc_and_recompute_addr_range = false ;
518
+ else
519
+ decr_pc_and_recompute_addr_range = true ;
520
520
} else if (IsTrapHandlerSymbol (process, m_sym_ctx)) {
521
521
// Signal dispatch may set the return address of the handler it calls to
522
522
// point to the first byte of a return trampoline (like __kernel_rt_sigreturn),
@@ -636,9 +636,9 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
636
636
}
637
637
} else {
638
638
m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
639
- int valid_offset = - 1 ;
640
- if ( IsUnwindPlanValidForCurrentPC (m_full_unwind_plan_sp, valid_offset)) {
641
- active_row = m_full_unwind_plan_sp-> GetRowForFunctionOffset (valid_offset );
639
+ if ( IsUnwindPlanValidForCurrentPC (m_full_unwind_plan_sp)) {
640
+ active_row = m_full_unwind_plan_sp-> GetRowForFunctionOffset (
641
+ m_current_offset_backed_up_one );
642
642
row_register_kind = m_full_unwind_plan_sp->GetRegisterKind ();
643
643
PropagateTrapHandlerFlagFromUnwindPlan (m_full_unwind_plan_sp);
644
644
if (active_row.get () && log) {
@@ -1007,8 +1007,7 @@ UnwindPlanSP RegisterContextUnwind::GetFullUnwindPlanForFrame() {
1007
1007
unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (
1008
1008
process->GetTarget (), m_thread);
1009
1009
}
1010
- int valid_offset = -1 ;
1011
- if (IsUnwindPlanValidForCurrentPC (unwind_plan_sp, valid_offset)) {
1010
+ if (IsUnwindPlanValidForCurrentPC (unwind_plan_sp)) {
1012
1011
UnwindLogMsgVerbose (" frame uses %s for full UnwindPlan because this "
1013
1012
" is the call-site unwind plan" ,
1014
1013
unwind_plan_sp->GetSourceName ().GetCString ());
@@ -1047,7 +1046,7 @@ UnwindPlanSP RegisterContextUnwind::GetFullUnwindPlanForFrame() {
1047
1046
}
1048
1047
}
1049
1048
1050
- if (IsUnwindPlanValidForCurrentPC (unwind_plan_sp, valid_offset )) {
1049
+ if (IsUnwindPlanValidForCurrentPC (unwind_plan_sp)) {
1051
1050
UnwindLogMsgVerbose (" frame uses %s for full UnwindPlan because we "
1052
1051
" failed to find a call-site unwind plan that would work" ,
1053
1052
unwind_plan_sp->GetSourceName ().GetCString ());
@@ -1313,7 +1312,8 @@ RegisterContextUnwind::SavedLocationForRegister(
1313
1312
LLDB_REGNUM_GENERIC_PC);
1314
1313
1315
1314
UnwindPlan::RowSP active_row =
1316
- m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset);
1315
+ m_full_unwind_plan_sp->GetRowForFunctionOffset (
1316
+ m_current_offset_backed_up_one);
1317
1317
unwindplan_registerkind = m_full_unwind_plan_sp->GetRegisterKind ();
1318
1318
1319
1319
if (got_new_full_unwindplan && active_row.get () && log) {
@@ -1770,7 +1770,8 @@ bool RegisterContextUnwind::TryFallbackUnwindPlan() {
1770
1770
m_full_unwind_plan_sp = m_fallback_unwind_plan_sp;
1771
1771
1772
1772
UnwindPlan::RowSP active_row =
1773
- m_fallback_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset);
1773
+ m_fallback_unwind_plan_sp->GetRowForFunctionOffset (
1774
+ m_current_offset_backed_up_one);
1774
1775
1775
1776
if (active_row &&
1776
1777
active_row->GetCFAValue ().GetValueType () !=
0 commit comments