[Dwarf-discuss] Constant expressions in locations lists

Jim Blandy jimb@red-bean.com
Fri Mar 9 01:19:49 GMT 2007


On 3/8/07, David Anderson <davea42 at earthlink.net> wrote:
> I don't mean to be difficult, I just don't get it. Sorry.
> I'm sure a complete description of what you mean by types
> would answer my questions, and I'm happy to wait for such if
> this notion gets general interest (and if it does not get
> general interest, then it's moot).

What's really going on here is that an overall grammar for location
expressions and a type system for location expressions are just two
different ways of describing exactly the same set of constraints.  If
your type system is simple enough (and the one Cary had in mind is, if
I understood), then you can actually just express it in the grammar,
and get "syntax error" instead of "type error".  In the
implementation, you'd certainly handle either one as if they were
grammatical constraints; no need to complicate the interpreter.  It's
just a question of how you'd like to say it.

The last time we talked about this, people posted a few different
grammars.  I think they were equivalent, modulo typos; my favorite was
this one (assume 'FOO *' means 'zero or more FOOs' and 'FOO +' means
'one or more FOOs')

location_operator: <any DW_OP_regN or DW_OP_regx>;
normal_operator: <any other DW_OP_ operator>;

dwarf_expression: normal_operator *;

nonempty_dwarf_expression: normal_operator +;

dwarf_simple_location: /* empty --- optimized out */
                     | location_operator   /* in register */
                     | nonempty_dwarf_expression    /* in memory */
                     ;

dwarf_location_expression: dwarf_simple_location
                | piece +
                ;

dwarf_piece: dwarf_simple_location DW_OP_piece N
           | dwarf_simple_location DW_OP_bit_piece N
           ;

I like this because the symbols correspond closely to the terms or
concepts currently used in the spec.  The dwarf_expression symbol
expands to well-formed plain expressions (as for DW_AT_byte_size, for
example), and dwarf_location_expression expands to well-formed DWARF
location expressions.




More information about the Dwarf-discuss mailing list