[Dwarf-discuss] Request for clarification w.r.t. DW_AT_entry_pc
pogo 59
pogo.work@gmail.com
Thu Oct 10 17:03:16 GMT 2024
Hi Andrew,
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.
If the entry_pc is a constant, then it's an offset from the lowest address
in the range that you find that way.
If the entry_pc is omitted, then it's the lowest address in the range that
you find that way (equivalent to constant zero).
Hope this helps,
--paulr
On Thu, Oct 10, 2024 at 6:28 AM Andrew Burgess via Dwarf-discuss <
dwarf-discuss@lists.dwarfstd.org> wrote:
>
> I'd like to ask for some clarification relating to DW_AT_entry_pc. Here
> is the relevant section from the DWARF-5 spec for reference:
>
>
> 2.18 Entry Address
>
> The entry or first executable instruction generated for an entity, if
> applicable, is often the lowest addressed instruction of a contiguous
> range of instructions. In other cases, the entry address needs to be
> specified explicitly. Any debugging information entry describing an
> entity that has a range of code addresses, which includes compilation
> units, module initialization, subroutines, lexical blocks, try/catch
> blocks, and the like, may have a DW_AT_entry_pc attribute to indicate
> the entry address which is the address of the instruction where
> execution begins within that range of addresses. If the value of the
> DW_AT_entry_pc attribute is of class address that address is the entry
> address; or, if it is of class constant, the value is an unsigned
> integer offset which, when added to the base address of the function,
> gives the entry address.
>
> If no DW_AT_entry_pc attribute is present, then the entry address is
> assumed to be the same as the base address of the containing scope.
>
> I am slightly confused by two parts of this. First, this:
>
> "...if it is of class constant, the value is an unsigned integer
> offset which, when added to the base address of the function, gives
> the entry address."
>
> What does 'of the function' mean in this context? I wonder if this
> possibly means the base address of the DIE which contains the
> DW_AT_entry_pc itself? Or should I be looking up the DIE hierarchy some
> specific DIE type?
>
> Next this:
>
> "If no DW_AT_entry_pc attribute is present, then the entry address is
> assumed to be the same as the base address of the containing scope."
>
> My very literal reading of this is that "containing scope" must be the
> DIE which contains the DIE which is missing the DW_AT_entry_pc, i.e. the
> parent of the DIE we are currently looking at. I got there because
> DW_AT_entry_pc is missing, so nothing contains it. Therefore the only
> thing that can be contained is the DIE we are currently considering.
>
> However, I suspect this might not be the intended meaning. My less
> literal interpretation is that we should use the base address of the DIE
> which is missing the DW_AT_entry_pc.
>
> Any guidance is gratefully received.
>
> Thanks,
> Andrew
>
> --
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dwarfstd.org/pipermail/dwarf-discuss/attachments/20241010/cc00d4f9/attachment-0001.htm>
More information about the Dwarf-discuss
mailing list