================
@@ -53,6 +54,30 @@ 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()) {
+    AddressRange full_range(m_func_file_addr, /*size=*/LLDB_INVALID_ADDRESS);
+    return DWARFExpressionEntry{full_range, always};
+  }
+
+  if (func_load_addr == LLDB_INVALID_ADDRESS)
+    func_load_addr = m_func_file_addr;
+  
+  // translate to file-relative PC
+  lldb::addr_t file_pc = load_addr - func_load_addr + m_func_file_addr;
----------------
UltimateForce21 wrote:

I dug into MathExtras and 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. So I tried to implement the 
signed overflow check into the function. Please let me know if you think it is 
alright. 

https://github.com/llvm/llvm-project/pull/144238
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to