[Dwarf-discuss] register name operators recap

Jim Blandy jimb
Fri Nov 17 21:57:39 GMT 2006


> Tokens
>
>     OP_ALL:
>         all operators, including DW_OP_reg[0-31], DW_OP_regx,
> DW_OP_piece and DW_OP_bit_piece
>
>     OP_TERMINATOR:
>          DW_OP_piece and DW_OP_bit_piece
>
>     OP_REG:
>          DW_OP_reg[0-31] and DW_OP_regx
>
>     OP_COMP:
>          all operators that can be used in compositions,
>          being all operators other than those in OP_TERMINATOR and OP_REG
>
> Syntax
>
>     start : expression
>
>     expression : subexpression_list
>
>     subexpression_list : <empty>
>                        | subexpression subexpression_list
>
>     subexpression : simple_expression
>                   | composite_expression
>
>     simple_expression : OP_TERMINATOR
>                       | OP_REG
>                       | OP_REG OP_TERMINATOR
>
>     composite_expression : OP_COMP
>                          | OP_COMP OP_TERMINATOR
>                          | OP_COMP composite_expression

I like the idea of actually using a grammar here; the standard text is
definitely trying to hint at one.

I think we have two start symbols in DWARF, one for general
expressions and one for location expressions; which one is permitted
depends on what attribute the expression is the value of.  I think the
grammar would be:

expression: general_op | general_op expression ;

location_expression:
      simple_location_expression         /* complete object in one place */
    | piece_list                         /* object split into pieces */
    ;

simple_location_expression:
      <empty>                            /* optimized out */
    | expression                         /* in memory at address */
    | register_name_op                   /* in register */
    ;

piece_list: piece | piece piece_list ;

piece: simple_location_expression piece_op ;

piece_op: DW_OP_piece | DW_OP_bit_piece ;
register_name_op: DW_OP_reg<n> | DW_OP_regx ;
general_op: (any other DW_OP_ operator) ;

I believe only location expressions can be empty, so 'expression'
doesn't permit an empty expression.





More information about the Dwarf-discuss mailing list