================
@@ -407,6 +406,15 @@ CompileUnit *Function::GetCompileUnit() { return 
m_comp_unit; }
 
 const CompileUnit *Function::GetCompileUnit() const { return m_comp_unit; }
 
+Address Function::GetAddress() const {
+  if (m_ranges.empty())
+    return Address();
+  // We're using a (DWARF-like) convention where the base address of the first
+  // interval denotes the entry point of the function. If that turns out to be
+  // insufficient, we can introduce a separate "entry point address" field.
+  return m_ranges[0].GetBaseAddress();
----------------
labath wrote:

There's no guarantee that the function's entry point will be its lowest 
numbered address. DWARF even allows you (via `DW_AT_entry_pc`) to have the 
entry pc point to the middle of a range. I don't think any compiler emits that, 
and lldb doesn't support that right now, but if we wanted to do it, then we'd 
need to have a separate `m_address` field here independent of any range (that's 
what I'm alluding to in that comment).

The "base address for relocation of blocks and variables" use case is totally 
under our control, so we could choose that to be based on the lowest address of 
the function, but that would mean we'd have to have two accessors (and then be 
careful about which one is used where). I think it's better to use the same 
address for both -- and accept the fact that some of the block/variable offsets 
may be negative. (Having written that, I realize this also means that we'd need 
to change the block/variable offsets to signed representations. Right now 
they're unsigned, which I might sort of make this patch a regression for those 
kinds of functions, but given that discontinuous functions are barely supported 
anyway, I'd like to do that separately.) This also fits in nicely with DWARF 
which says that "The base address of the scope for any of the debugging 
information entries listed
above is given by either the DW_AT_low_pc attribute or the first address in the 
first range entry in the list of ranges given by the DW_AT_ranges attribute." 
-- it doesn't care whether the base address is numerically lowest.

Let me know what you think.

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

Reply via email to