public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Mark Wielaard <mark@klomp.org>
Cc: elfutils-devel@sourceware.org
Subject: Re: [PATCH 5/5] libdwfl: add interface for evaluating DWARF expressions in a frame
Date: Wed, 30 Oct 2019 23:59:00 -0000	[thread overview]
Message-ID: <20191030235945.GK326591@vader> (raw)
In-Reply-To: <7bb91fd1006b5346013093bfaa6c6981035588e4.camel@klomp.org>

On Wed, Oct 30, 2019 at 02:23:06PM +0100, Mark Wielaard wrote:
> Hi Omar,
> 
> On Mon, 2019-10-07 at 02:05 -0700, Omar Sandoval wrote:
> > libdwfl can evaluate DWARF expressions in order to unwind the stack,
> > but this functionality isn't exposed to clients of the library. Now that
> > the pieces are in place, add dwfl_frame_eval_expr to provide this feature.
> 
> I think this is useful. But same issue as the previous patch that I am
> not sure the error handling is correct for state->frame == NULL.

The change I described for the previous patch should fix that.

> Also this could really use some examples and maybe a small testcase. 
> 
> That would show how to handle DWARF expressions to are simple location
> descriptions (which calculate a location where a value can be found)
> versus implicit location descriptions (e.g. DW_OP_value) versus
> composite location descriptions (e.g. DW_OP_piece).
> 
> It might be that we don't care, because all we care about is whether or
> not we can get a value, but it would validate the interface.
> 
> 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;
}

Later, I plan to use this for location expressions for local variables
that I get out of DWARF.

Thanks,
Omar

  reply	other threads:[~2019-10-30 23:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07  9:05 [PATCH 0/5] libdwfl: expand stack frame interface Omar Sandoval
2019-10-07  9:05 ` [PATCH 1/5] libdwfl: don't bother freeing frames outside of dwfl_thread_getframes Omar Sandoval
2019-10-29 15:55   ` Mark Wielaard
2019-10-29 16:17     ` Omar Sandoval
2019-10-29 16:52       ` Mark Wielaard
2019-10-07  9:05 ` [PATCH 3/5] libdwfl: add interface for attaching to/detaching from threads Omar Sandoval
2019-10-30 12:47   ` Mark Wielaard
2019-10-30 23:49     ` Omar Sandoval
2019-10-31 16:21       ` Mark Wielaard
2019-10-31 17:13         ` Omar Sandoval
2019-10-07  9:05 ` [PATCH 2/5] libdwfl: only use thread->unwound for initial frame Omar Sandoval
2019-10-29 22:20   ` Mark Wielaard
2019-10-07  9:05 ` [PATCH 5/5] libdwfl: add interface for evaluating DWARF expressions in a frame Omar Sandoval
2019-10-30 13:23   ` Mark Wielaard
2019-10-30 23:59     ` Omar Sandoval [this message]
2019-10-31 16:40       ` Mark Wielaard
2019-10-07  9:05 ` [PATCH 4/5] libdwfl: cache Dwfl_Module and Dwarf_Frame for Dwfl_Frame Omar Sandoval
2019-10-30 13:04   ` Mark Wielaard
2019-10-30 23:55     ` Omar Sandoval
2019-10-31 16:29       ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191030235945.GK326591@vader \
    --to=osandov@osandov.com \
    --cc=elfutils-devel@sourceware.org \
    --cc=mark@klomp.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).