[Dwarf-Discuss] PROPOSAL: Constant expressions in location lists

Jim Blandy jimb@red-bean.com
Sun Jan 6 09:17:37 GMT 2008

On Jan 5, 2008 11:59 PM, Roland McGrath <roland at redhat.com> wrote:
> > The DW_OP_constant_value suggestion would help with the former, but
> > not the latter.  (What you wrote makes me think you have the latter in
> > mind.)
> Frank referred to my proposal in http://lists.dwarfstd.org/htdig.cgi/dwarf-discuss-dwarfstd.org/2007-May/000478.html
> This handles the general case by computing values (or values of pieces)
> with arbitrary DWARF expressions.  Compile-time constants are a degenerate
> case where those expressions use only const*/lit* ops.

I misread that proposal, I guess.

Are you very sure you want to use DWARF expressions to compute
source-language values?  To be honest, it doesn't seem like a great
idea to me.  I don't know what kinds of values your compiler (GCC, I
assume) could potentially need to express this way, but in the general
case those will be some gnarly DWARF expressions to produce.  It seems
to me the problem's not less hard than targeting a new architecture.
We could add an operator analogous to DW_OP_pick that stores a value
at a given depth on the stack, to get random access to the stack; that
might make code generation a bit easier.  I suppose you could use
DW_OP_call* to call "library" expressions from a library to do things
like long long division.

But this seems like a case where the compiler folks (i.e. you) are
offering to bend over backwards to make only a minimal change to the
DWARF standard, but the result will be something difficult for
producers to actually emit.

It would seem much cleaner to simply represent source language
expressions as DIE trees.  Every source-level debugger already has the
machinery to evaluate those.  Their semantics are as well-defined as
the language itself.

In what form does GCC have these rematerializeable values?  As source
expressions or something close to that?  Or are they in RTL (GCC's
machine-level intermediate language, for folks who don't know GCC) so
producing DWARF expressions is no worse than targeting a new processor
back end?

More information about the Dwarf-discuss mailing list