@@ -94,8 +94,9 @@ bool RegisterContextUnwind::IsUnwindPlanValidForCurrentPC(
9494 return true ;
9595 }
9696
97- // if m_current_offset <= 0, we've got nothing else to try
98- if (m_current_offset <= 0 )
97+ // If don't have an offset or we're at the start of the function, we've got
98+ // nothing else to try.
99+ if (!m_current_offset || m_current_offset == 0 )
99100 return false ;
100101
101102 // check pc - 1 to see if it's valid
@@ -198,8 +199,8 @@ void RegisterContextUnwind::InitializeZerothFrame() {
198199 m_current_offset_backed_up_one = m_current_offset;
199200 } else {
200201 m_start_pc = m_current_pc;
201- m_current_offset = - 1 ;
202- m_current_offset_backed_up_one = - 1 ;
202+ m_current_offset = std:: nullopt ;
203+ m_current_offset_backed_up_one = std:: nullopt ;
203204 }
204205
205206 // We've set m_frame_type and m_sym_ctx before these calls.
@@ -437,8 +438,8 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
437438 m_frame_type = eNormalFrame;
438439 }
439440 m_all_registers_available = false ;
440- m_current_offset = - 1 ;
441- m_current_offset_backed_up_one = - 1 ;
441+ m_current_offset = std:: nullopt ;
442+ m_current_offset_backed_up_one = std:: nullopt ;
442443 RegisterKind row_register_kind = m_full_unwind_plan_sp->GetRegisterKind ();
443444 if (const UnwindPlan::Row *row =
444445 m_full_unwind_plan_sp->GetRowForFunctionOffset (0 )) {
@@ -569,16 +570,16 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
569570 m_current_offset = pc - m_start_pc.GetLoadAddress (&process->GetTarget ());
570571 m_current_offset_backed_up_one = m_current_offset;
571572 if (decr_pc_and_recompute_addr_range &&
572- m_current_offset_backed_up_one > 0 ) {
573- m_current_offset_backed_up_one-- ;
573+ m_current_offset_backed_up_one != 0 ) {
574+ --*m_current_offset_backed_up_one ;
574575 if (m_sym_ctx_valid) {
575576 m_current_pc.SetLoadAddress (pc - 1 , &process->GetTarget ());
576577 }
577578 }
578579 } else {
579580 m_start_pc = m_current_pc;
580- m_current_offset = - 1 ;
581- m_current_offset_backed_up_one = - 1 ;
581+ m_current_offset = std:: nullopt ;
582+ m_current_offset_backed_up_one = std:: nullopt ;
582583 }
583584
584585 if (IsTrapHandlerSymbol (process, m_sym_ctx)) {
@@ -746,7 +747,7 @@ bool RegisterContextUnwind::BehavesLikeZerothFrame() const {
746747// 2. m_sym_ctx should already be filled in, and
747748// 3. m_current_pc should have the current pc value for this frame
748749// 4. m_current_offset_backed_up_one should have the current byte offset into
749- // the function, maybe backed up by 1, -1 if unknown
750+ // the function, maybe backed up by 1, std::nullopt if unknown
750751
751752UnwindPlanSP RegisterContextUnwind::GetFastUnwindPlanForFrame () {
752753 UnwindPlanSP unwind_plan_sp;
@@ -790,7 +791,7 @@ UnwindPlanSP RegisterContextUnwind::GetFastUnwindPlanForFrame() {
790791// 2. m_sym_ctx should already be filled in, and
791792// 3. m_current_pc should have the current pc value for this frame
792793// 4. m_current_offset_backed_up_one should have the current byte offset into
793- // the function, maybe backed up by 1, -1 if unknown
794+ // the function, maybe backed up by 1, std::nullopt if unknown
794795
795796UnwindPlanSP RegisterContextUnwind::GetFullUnwindPlanForFrame () {
796797 UnwindPlanSP unwind_plan_sp;
0 commit comments