================ @@ -53,6 +54,37 @@ bool DWARFExpressionList::ContainsAddress(lldb::addr_t func_load_addr, return GetExpressionAtAddress(func_load_addr, addr) != nullptr; } +std::optional<DWARFExpressionList::DWARFExpressionEntry> +DWARFExpressionList::GetExpressionEntryAtAddress(lldb::addr_t func_load_addr, + lldb::addr_t load_addr) const { + if (const DWARFExpression *always = GetAlwaysValidExpr()) { + return DWARFExpressionEntry{std::nullopt, always}; + } + + if (func_load_addr == LLDB_INVALID_ADDRESS) + func_load_addr = m_func_file_addr; + + // Guard against underflow when translating a load address back into file space. + if (load_addr < func_load_addr) + return std::nullopt; + + // Guard against overflow. + lldb::addr_t delta = load_addr - func_load_addr; + if (delta > std::numeric_limits<lldb::addr_t>::max() - m_func_file_addr) ---------------- UltimateForce21 wrote:
>From when I dug into MathExtras last time, I found that its `AddOverflow` and >`SubOverflow` helpers are only defined for **signed types**. I they rely on two’s-complement signed overflow semantics and return the truncated signed result. Since `lldb::addr_t` is an **unsigned address,** I think using those helpers would either fail to compile or silently convert to signed semantics. That's why I tried to implement the signed overflow check into the function. https://github.com/llvm/llvm-project/pull/147460 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits