[Dwarf-Discuss] Default Location List Entry Issue 130121.1

Michael Eager eager@eagercon.com
Thu Apr 3 15:26:13 GMT 2014


On 04/03/14 01:51, Mark Wielaard wrote:
> On Wed, 2014-04-02 at 08:35 -0700, Michael Eager wrote:
>> Perhaps you are confused by the following from Section 2.6 (which I think
>> is unambiguous):
>>
>>      1. Single location descriptions, which are a language independent
>>         representation of addressing rules of arbitrary complexity built
>>         from DWARF expressions and/or other DWARF operations specific to
>>         describing locations. They are sufficient for describing the location
>>         of any object as long as its lifetime is either static or the same as
>>         the lexical block that owns it, and it does not move during its lifetime.
>>
>> You seem to have interpreted "either/or" in the second sentence to mean "and".
>
> You are correct that I am confused about this definition. Not because of
> the either/or but about how to express the choices in DWARF. I don't
> understand how for a DWARF Data Object DIE I express whether a) its
> lifetime is static or b) the lifetime is the same as the lexical block
> that owns it.

Consider a lexical block or function in C which has the following:

A data object X which is defined as
   static int X;
would have a static lifetime.  It is created when the program is loaded
and is valid for the entire duration that the program runs.

Another data object Y is defined as
   register int Y;
would (most likely) be allocated to a register.  This object is created
when the lexical block or function is entered and is destroyed when the
function exits.  Its location would only be valid while the execution PC
is located within the range specified by the low_pc/high_pc of the enclosing
lexical block.

Both of these objects can be described as a simple location expression.
There may be other ways to describe these objects using location lists,
perhaps with a default, but there is no compelling reason to do this.

When you are interpreting the DWARF description for an object, you can
only determine whether a location expression is valid by interpreting it.
At different times during a program's execution, a location expression may
be valid and at other times it may be invalid.  If the location is dependent
on values which are dependent on the lexical block (e.g., a register value
which is only valid within the block, or an offset from the stack frame)
then the location expression is only valid if the execution PC is within
the lexical block (for a register value) or if the frame can be found by
walking the stack (for the offset case).  If the expression doesn't require
information dependent on the lexical block (i.e., the object has static
lifetime), then it is always valid.

> I assume that a "static lifetime" means the single location description
> of the Data Object DIE is valid for all address ranges. And I assume a
> "lifetime that is the same as the lexical block that owns it" means that
> the ranges for which the single location description is valid are the
> same as the ranges of the owning Program Scope DIE of the Data Object
> DIE.

Correct.

Although "lifetime of a object" is a term of art in computer science, I
think that it is well defined and understood.  We'll revisit using this
terminology when we edit the DWARF Version 5 standard prior to releasing
a public draft.


-- 
Michael Eager	 eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077




More information about the Dwarf-discuss mailing list