@@ -1243,62 +1243,68 @@ bool RegisterContextUnwind::IsTrapHandlerSymbol(
12431243 return false ;
12441244}
12451245
1246- // / Search this stack frame's UnwindPlans for the AbstractRegisterLocation
1247- // / for this register.
1248- // /
1249- // / \param[out] kind
1250- // / Set to the RegisterKind of the UnwindPlan which is the basis for
1251- // / the returned AbstractRegisterLocation; if the location is in terms
1252- // / of another register number, this Kind is needed to interpret it
1253- // / correctly.
1254- // /
1255- // / \return
1256- // / An empty optional indicaTes that there was an error in processing
1257- // / the request.
1258- // /
1259- // / If there is no unwind rule for a volatile (caller-preserved) register,
1260- // / the returned AbstractRegisterLocation will be IsUndefined,
1261- // / indicating that we should stop searching.
1262- // /
1263- // / If there is no unwind rule for a non-volatile (callee-preserved)
1264- // / register, the returned AbstractRegisterLocation will be IsSame.
1265- // / In frame 0, IsSame means get the value from the live register context.
1266- // / Else it means to continue descending down the stack to more-live frames
1267- // / looking for a location/value.
1268- // /
1269- // / If an AbstractRegisterLocation is found in an UnwindPlan, that will
1270- // / be returned, with no consideration of the current ABI rules for
1271- // / registers. Functions using an alternate ABI calling convention
1272- // / will work as long as the UnwindPlans are exhaustive about what
1273- // / registers are volatile/non-volatile.
1246+ // Search this stack frame's UnwindPlans for the AbstractRegisterLocation
1247+ // for this register.
1248+ //
1249+ // \param[in] lldb_regnum
1250+ // The register number (in the eRegisterKindLLDB register numbering)
1251+ // we are searching for.
1252+ //
1253+ // \param[out] kind
1254+ // Set to the RegisterKind of the UnwindPlan which is the basis for
1255+ // the returned AbstractRegisterLocation; if the location is in terms
1256+ // of another register number, this Kind is needed to interpret it
1257+ // correctly.
1258+ //
1259+ // \return
1260+ // An empty optional indicaTes that there was an error in processing
1261+ // the request.
1262+ //
1263+ // If there is no unwind rule for a volatile (caller-preserved) register,
1264+ // the returned AbstractRegisterLocation will be IsUndefined,
1265+ // indicating that we should stop searching.
1266+ //
1267+ // If there is no unwind rule for a non-volatile (callee-preserved)
1268+ // register, the returned AbstractRegisterLocation will be IsSame.
1269+ // In frame 0, IsSame means get the value from the live register context.
1270+ // Else it means to continue descending down the stack to more-live frames
1271+ // looking for a location/value.
1272+ //
1273+ // If an AbstractRegisterLocation is found in an UnwindPlan, that will
1274+ // be returned, with no consideration of the current ABI rules for
1275+ // registers. Functions using an alternate ABI calling convention
1276+ // will work as long as the UnwindPlans are exhaustive about what
1277+ // registers are volatile/non-volatile.
12741278std::optional<UnwindPlan::Row::AbstractRegisterLocation>
12751279RegisterContextUnwind::GetAbstractRegisterLocation (uint32_t lldb_regnum,
12761280 lldb::RegisterKind &kind) {
12771281 RegisterNumber regnum (m_thread, eRegisterKindLLDB, lldb_regnum);
12781282 Log *log = GetLog (LLDBLog::Unwind);
12791283
1284+ kind = eRegisterKindLLDB;
12801285 UnwindPlan::Row::AbstractRegisterLocation unwindplan_regloc;
12811286
12821287 // First, try to find a register location via the FastUnwindPlan
12831288 if (m_fast_unwind_plan_sp) {
12841289 const UnwindPlan::Row *active_row =
12851290 m_fast_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset);
1286- kind = m_fast_unwind_plan_sp->GetRegisterKind ();
12871291 if (regnum.GetAsKind (kind) == LLDB_INVALID_REGNUM) {
12881292 UnwindLogMsg (" could not convert lldb regnum %s (%d) into %d RegisterKind "
12891293 " reg numbering scheme" ,
12901294 regnum.GetName (), regnum.GetAsKind (eRegisterKindLLDB),
12911295 (int )kind);
12921296 return {};
12931297 }
1294- // The architecture default unwind plan marks unknown registers as
1295- // Undefined so that we don't forward them up the stack when a
1296- // jitted stack frame may have overwritten them. But when the
1297- // arch default unwind plan is used as the Fast Unwind Plan, we
1298- // need to recognize this & switch over to the Full Unwind Plan
1299- // to see what unwind rule that (more knowledgeable, probably)
1300- // UnwindPlan has.
1301- if (active_row->GetRegisterInfo (regnum.GetAsKind (kind),
1298+ kind = m_fast_unwind_plan_sp->GetRegisterKind ();
1299+ // The Fast UnwindPlan typically only provides fp & pc as we move up
1300+ // the stack, without requiring additional parsing or memory reads.
1301+ // It may mark all other registers as IsUndefined() because, indicating
1302+ // that it doesn't know if they were spilled to stack or not.
1303+ // If this caSe, for an IsUndefined register, we should continue on
1304+ // to the Full UnwindPlan which may have more accurate information
1305+ // about register locations of all registers.
1306+ if (active_row &&
1307+ active_row->GetRegisterInfo (regnum.GetAsKind (kind),
13021308 unwindplan_regloc) &&
13031309 !unwindplan_regloc.IsUndefined ()) {
13041310 UnwindLogMsg (
0 commit comments