This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [PATCH 5/5] libdwfl: add interface for evaluating DWARF expressions in a frame
On Wed, 2019-10-30 at 16:59 -0700, Omar Sandoval wrote:
> On Wed, Oct 30, 2019 at 02:23:06PM +0100, Mark Wielaard wrote:
> > Having some examples/testcases would also show how/where to get the
> > DWARF expressions to use with this new function.
>
> Sounds good, I'll put some examples/test cases together. FWIW, I'm using
> it in drgn to get register values like so:
>
> LIBDRGN_PUBLIC struct drgn_error *
> drgn_stack_frame_register(struct drgn_stack_frame frame,
> enum drgn_register_number regno, uint64_t *ret)
> {
> const Dwarf_Op op = { .atom = DW_OP_regx, .number = regno, };
> Dwarf_Addr value;
>
> if (!dwfl_frame_eval_expr(frame.trace->frames[frame.i], &op, 1, &value))
> return drgn_error_libdwfl();
> *ret = value;
> return NULL;
> }
O! I hadn't even thought of that. Funny using it with "hand
constructed" DWARF expressions.
> Later, I plan to use this for location expressions for local variables
> that I get out of DWARF.
Yes, that was what I assumed you were using it for already.
I think it will work for that. But it would be nice to have some
code/example that actually does it.
Thanks,
Mark