[lldb] [llvm] Annotate disassembly with register‐resident variable locations (PR #147460)
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 16 05:54:39 PDT 2025
================
@@ -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)
----------------
adrian-prantl wrote:
I think it would be better to use the add with overflow methods from MathExtras here.
https://github.com/llvm/llvm-project/pull/147460
More information about the llvm-commits
mailing list