Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lldb/include/lldb/Symbol/UnwindPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class UnwindPlan {
isRegisterDereferenced, // FA = [reg]
isDWARFExpression, // FA = eval(dwarf_expr)
isRaSearch, // FA = SP + offset + ???
isConstant, // FA = constant
};

FAValue() : m_value() {}
Expand Down Expand Up @@ -259,6 +260,15 @@ class UnwindPlan {
m_value.expr.length = len;
}

bool IsConstant() const { return m_type == isConstant; }

void SetIsConstant(uint64_t constant) {
m_type = isConstant;
m_value.constant = constant;
}

uint64_t GetConstant() const { return m_value.constant; }

uint32_t GetRegisterNumber() const {
if (m_type == isRegisterDereferenced || m_type == isRegisterPlusOffset)
return m_value.reg.reg_num;
Expand Down Expand Up @@ -329,6 +339,8 @@ class UnwindPlan {
} expr;
// For m_type == isRaSearch
int32_t ra_search_offset;
// For m_type = isConstant
uint64_t constant;
} m_value;
}; // class FAValue

Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Symbol/UnwindPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ operator==(const UnwindPlan::Row::FAValue &rhs) const {
return !memcmp(m_value.expr.opcodes, rhs.m_value.expr.opcodes,
m_value.expr.length);
break;
case isConstant:
return m_value.constant == rhs.m_value.constant;
}
}
return false;
Expand Down Expand Up @@ -214,6 +216,8 @@ void UnwindPlan::Row::FAValue::Dump(Stream &s, const UnwindPlan *unwind_plan,
case isRaSearch:
s.Printf("RaSearch@SP%+d", m_value.ra_search_offset);
break;
case isConstant:
s.Printf("0x%" PRIx64, m_value.constant);
}
}

Expand Down
6 changes: 6 additions & 0 deletions lldb/source/Target/RegisterContextUnwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,12 @@ bool RegisterContextUnwind::ReadFrameAddress(
UnwindLogMsg("No suitable CFA found");
break;
}
case UnwindPlan::Row::FAValue::isConstant: {
address = fa.GetConstant();
address = abi_sp->FixCodeAddress(address);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonmolenda I see a few other places in this file calling the function above (FixCodeAddress). But there are many other places that just take addresses and use them as is to do things like Process:ReadMemory... it makes me wonder whether we should audit those uses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, line 2051:

if (ABISP abi_sp = m_thread.GetProcess()->GetABI())
        address = abi_sp->FixCodeAddress(address);

Now I wonder if this is shadowing the abi_sp variable...

UnwindLogMsg("CFA value set by constant is 0x%" PRIx64, address);
return true;
}
default:
return false;
}
Expand Down
Loading