[Dwarf-discuss] PROPOSAL: Constant expressions in locations lists

Michael Eager eager@eagercon.com
Wed May 30 12:30:35 GMT 2007

Hi Roland --

Discussions about proposals for extensions or changes to DWARF are
generally done on the Dwarf Committee mailing list and in our regular
conference call.  We'll consider your comments and suggestions.

The Dwarf Discussion list is primarily for discussion about the DWARF
standard and about different implementations of the standard.
Proposed changes to the standard can be sent to me and the committee
will consider them.  One does not need to be a member of the Dwarf
Committee to propose changes/extensions/clarifications to the standard.

If you wish to be an active member of the Dwarf Standards Committee,
send me an email.

Roland McGrath wrote:
> This was moved to the private mailing list and it doesn't look like there
> has been any traffic about it for a while.  So I don't know what its status is.
> I think the formulation should be adjusted a little from what was proposed.
> The block is often overkill, but I think adding a plethora of
> constant_value[248] and so forth would be a waste of opcodes and needless
> new repetition in decoding.  Instead, I suggest using a special suffix
> operation DW_OP_implicit_value.  It can follow DW_OP_const*, DW_OP_lit*, etc.
> Doing it this way also makes it a natural way to describe more cases.
> (This is why I used DW_OP_implicit_value rather than DW_OP_constant_value.)
> Imagine:
> 	for (int i = 0, j = 0; i < n; ++i, j += 4) {
> 		...
> 	}
> j is optimized away and has no location, but its value is computable, e.g.:
>     "i" location expr: DW_OP_reg0
>     "j" location expr: DW_OP_breg0(0) DW_OP_lit4 DW_OP_mul DW_OP_implicit_value
> (In fact, I think I might prefer DW_OP_computed_value to be more clear.)
> Note that this makes DW_CFA_val_expression redundant with using
> DW_CFA_expression and DW_OP_implicit_value.  If we had contemplated these
> cases earlier, we might have used this instead of adding DW_CFA_val_expression.
> Furthermore, imagine a compiler generating the very same code for:
> 	for (int i[2] = {0,0}; i[0] < n; ++i[0], i[1] += 4) {
> 		...
> 	}
> Now i[0] has a usable location but i[1] does not.  So in the 070512.1
> grammar's terms, this says that the DW_OP_implicit_value suffix in fact
> must be a "simple_location_expression".  This permits i's location to be:
>     DW_OP_reg0 DW_OP_piece(4) \
>     DW_OP_breg0(0) DW_OP_lit4 DW_OP_mul DW_OP_implicit_value DW_OP_piece(4)
> Incidentally, it should be noted that DW_AT_const_value is now redundant
> with a trivial location expression using DW_OP_implicit_value.  Using it
> should be encouraged for the cases it covers, both because of the existing
> practice and because of the simpler and smaller encoding.
> Thanks,
> Roland
> _______________________________________________
> dwarf-discuss mailing list
> dwarf-discuss at lists.dwarfstd.org
> http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org

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

More information about the Dwarf-discuss mailing list