public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: elfutils-devel@sourceware.org
Subject: [PATCH 5/5] libdwfl: add interface for evaluating DWARF expressions in a frame
Date: Mon, 07 Oct 2019 09:05:00 -0000	[thread overview]
Message-ID: <340240576c11f97cd326f76b7decd9164c74e91e.1570438723.git.osandov@fb.com> (raw)
In-Reply-To: <cover.1570438723.git.osandov@fb.com>

From: Omar Sandoval <osandov@fb.com>

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.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog        |  1 +
 libdw/libdw.map        |  1 +
 libdwfl/ChangeLog      |  2 ++
 libdwfl/frame_unwind.c | 12 ++++++++++++
 libdwfl/libdwfl.h      |  6 ++++++
 5 files changed, 22 insertions(+)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 1a712497..765d51ec 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -5,6 +5,7 @@
 	Add dwfl_detach_thread.
 	Add dwfl_frame_module.
 	Add dwfl_frame_dwarf_frame.
+	Add dwfl_frame_eval_expr.
 
 2019-07-05  Omar Sandoval  <osandov@fb.com>
 
diff --git a/libdw/libdw.map b/libdw/libdw.map
index c1469c4e..d06a29ed 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -376,4 +376,5 @@ ELFUTILS_0.178 {
     dwfl_detach_thread;
     dwfl_frame_module;
     dwfl_frame_dwarf_frame;
+    dwfl_frame_eval_expr;
 } ELFUTILS_0.177;
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index fdb517c9..3689ddd9 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -20,10 +20,12 @@
 	(__libdwfl_frame_unwind): Cache state->mod.
 	(dwfl_frame_module): Add function.
 	(dwfl_frame_dwarf_frame): Add function.
+	(dwfl_frame_eval_expr): Add function.
 	* libdwfl.h (dwfl_attach_thread): Add definition.
 	(dwfl_detach_thread): Add definition.
 	(dwfl_frame_module): Add definition.
 	(dwfl_frame_dwarf_frame): Add definition.
+	(dwfl_frame_eval_expr): Add definition.
 	* libdwflP.h (struct Dwfl_Thread): Update comment for unwound member.
 	Add mod, frame, and bias.
 
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index 9738ca72..4c2df837 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -787,3 +787,15 @@ dwfl_frame_dwarf_frame (Dwfl_Frame *state, Dwarf_Addr *bias)
   *bias = state->bias;
   return state->frame;
 }
+
+bool
+dwfl_frame_eval_expr (Dwfl_Frame *state, const Dwarf_Op *ops, size_t nops,
+		      Dwarf_Addr *result)
+{
+  if (state->frame == NULL)
+    {
+      __libdwfl_seterrno (DWFL_E_NO_DWARF);
+      return false;
+    }
+  return expr_eval (state, state->frame, ops, nops, result, state->bias);
+}
diff --git a/libdwfl/libdwfl.h b/libdwfl/libdwfl.h
index b450816b..90a3e103 100644
--- a/libdwfl/libdwfl.h
+++ b/libdwfl/libdwfl.h
@@ -829,6 +829,12 @@ int dwfl_getthread_frames (Dwfl *dwfl, pid_t tid,
 bool dwfl_frame_pc (Dwfl_Frame *state, Dwarf_Addr *pc, bool *isactivation)
   __nonnull_attribute__ (1, 2);
 
+/* Evaluate a DWARF expression in the context of a frame.  On success, returns
+   true and fills in *RESULT.  On error, returns false. */
+bool dwfl_frame_eval_expr (Dwfl_Frame *state, const Dwarf_Op *ops, size_t nops,
+			   Dwarf_Addr *result)
+  __nonnull_attribute__ (1, 2, 4);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.23.0

  parent reply	other threads:[~2019-10-07  9:05 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 2/5] libdwfl: only use thread->unwound for initial frame Omar Sandoval
2019-10-29 22:20   ` Mark Wielaard
2019-10-07  9:05 ` Omar Sandoval [this message]
2019-10-30 13:23   ` [PATCH 5/5] libdwfl: add interface for evaluating DWARF expressions in a frame Mark Wielaard
2019-10-30 23:59     ` Omar Sandoval
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
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

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=340240576c11f97cd326f76b7decd9164c74e91e.1570438723.git.osandov@fb.com \
    --to=osandov@osandov.com \
    --cc=elfutils-devel@sourceware.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).