<div dir="ltr">Hi Andrew,<div><br></div><div>I agree that the language could be tidied up here, but I'm confident that a lookup of the "containing scope" ought to start with the DIE itself. Normally any DIE describing a code entity (function, lexical block, unit) would itself have a low_pc/high_pc pair or DW_AT_ranges; if it doesn't, you look up the parent chain (the "containing scopes") to find the first DIE with a code range. But you knew that.</div><div><br></div><div>If the entry_pc is a constant, then it's an offset from the lowest address in the range that you find that way.</div><div><br></div><div>If the entry_pc is omitted, then it's the lowest address in the range that you find that way (equivalent to constant zero).</div><div><br></div><div>Hope this helps,</div><div>--paulr</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 10, 2024 at 6:28 AM Andrew Burgess via Dwarf-discuss <<a href="mailto:dwarf-discuss@lists.dwarfstd.org" target="_blank">dwarf-discuss@lists.dwarfstd.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
I'd like to ask for some clarification relating to DW_AT_entry_pc.  Here<br>
is the relevant section from the DWARF-5 spec for reference:<br>
<br>
<br>
  2.18 Entry Address<br>
<br>
  The entry or first executable instruction generated for an entity, if<br>
  applicable, is often the lowest addressed instruction of a contiguous<br>
  range of instructions. In other cases, the entry address needs to be<br>
  specified explicitly.  Any debugging information entry describing an<br>
  entity that has a range of code addresses, which includes compilation<br>
  units, module initialization, subroutines, lexical blocks, try/catch<br>
  blocks, and the like, may have a DW_AT_entry_pc attribute to indicate<br>
  the entry address which is the address of the instruction where<br>
  execution begins within that range of addresses. If the value of the<br>
  DW_AT_entry_pc attribute is of class address that address is the entry<br>
  address; or, if it is of class constant, the value is an unsigned<br>
  integer offset which, when added to the base address of the function,<br>
  gives the entry address.<br>
<br>
  If no DW_AT_entry_pc attribute is present, then the entry address is<br>
  assumed to be the same as the base address of the containing scope.<br>
<br>
I am slightly confused by two parts of this.  First, this:<br>
<br>
  "...if it is of class constant, the value is an unsigned integer<br>
  offset which, when added to the base address of the function, gives<br>
  the entry address."<br>
<br>
What does 'of the function' mean in this context?  I wonder if this<br>
possibly means the base address of the DIE which contains the<br>
DW_AT_entry_pc itself?  Or should I be looking up the DIE hierarchy some<br>
specific DIE type?<br>
<br>
Next this:<br>
<br>
  "If no DW_AT_entry_pc attribute is present, then the entry address is<br>
  assumed to be the same as the base address of the containing scope."<br>
<br>
My very literal reading of this is that "containing scope" must be the<br>
DIE which contains the DIE which is missing the DW_AT_entry_pc, i.e. the<br>
parent of the DIE we are currently looking at.  I got there because<br>
DW_AT_entry_pc is missing, so nothing contains it.  Therefore the only<br>
thing that can be contained is the DIE we are currently considering.<br>
<br>
However, I suspect this might not be the intended meaning.  My less<br>
literal interpretation is that we should use the base address of the DIE<br>
which is missing the DW_AT_entry_pc.<br>
<br>
Any guidance is gratefully received.<br>
<br>
Thanks,<br>
Andrew<br>
<br>
-- <br>
Dwarf-discuss mailing list<br>
<a href="mailto:Dwarf-discuss@lists.dwarfstd.org" target="_blank">Dwarf-discuss@lists.dwarfstd.org</a><br>
<a href="https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss" rel="noreferrer" target="_blank">https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss</a><br>
</blockquote></div>