From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 57727 invoked by alias); 7 Oct 2019 09:05:55 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 57473 invoked by uid 89); 7 Oct 2019 09:05:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mail-pl1-f196.google.com Received: from mail-pl1-f196.google.com (HELO mail-pl1-f196.google.com) (209.85.214.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Oct 2019 09:05:51 +0000 Received: by mail-pl1-f196.google.com with SMTP id t10so6548934plr.8 for ; Mon, 07 Oct 2019 02:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Rz+deEp468V3JZdqaDxYwTWkLcrJc6x4WnwfhWMViR8=; b=K4bvVE7u5ITKgKQe+qeGgjqiagGMhrDmiL+uYNi8kkXgNjDZT/vuYDDy9NUZjUipl0 mTQZ8naJ03HdjxI6lX+p0KjiSetcZ2kCkQEhmOixu5zMxqTWOcEqvtNRk+DUKGS2OfXf g7ui3sM4STcMjDLW3GbAtHExJqDbh0tQvKZaZb7DMgpMKJkLlTykx5RbFNyjILqkzRQo fK/37KrDogNpsSc04zGWdHRQT7pMEG3XGRdD/dd2Qso3oA5oodhr+uhHgpJVIefP1/2X kVlTmLZrdgwnrm6wo5AwsCdc8Rztg4/dnJZ6Fp6ZLWqaVazwqQOpemXDRa9jZd2lRaxG qDHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rz+deEp468V3JZdqaDxYwTWkLcrJc6x4WnwfhWMViR8=; b=MuNzqxuJla2/CMmM6EQfNV5BBk4tpLU3Z+NrAMuxSUCEnYKU0kWfCHlzSnTUZMaV9H zgJGU3/AL1+hgjiPgVHFVmKJPuiWTvniuKdZFuTRXW5eByksT6nuLFYLP5bwtksDnvud Et3HQfvImf7AXJ+nhDjpJtWb097Ar/0fVsIsW4Stf6mhN/gB8Rtn9E6PzvULdLX8zheg L+J9l/7sO+Xcs/mdjMlo+17T4SKd78Wmf7qBEBMGQOSjtRpudJ2i4hZ0nMY2FlFdYp7Y 71+opvcFoGqEEV/lE/3nzhspSwqJBh3S7KudA3VfArGOY1ynZBmPtQqSaUqNogSIrZii m11A== X-Gm-Message-State: APjAAAUy22UORvia6au0000xgNWvbtXIvmaIyL6Sbinyp0RFjqE4hpDF enBTuhP7a8mMklLL6i+khHqLfn9ZGXY= X-Google-Smtp-Source: APXvYqwZSfgs0tqcq7HcSZNq2gf9gdLWAe5aW7HiIylmaoYDN4F8CqeB1R9dXwzSLGNyNOiyfUJ2Ig== X-Received: by 2002:a17:902:6b44:: with SMTP id g4mr28706139plt.256.1570439149988; Mon, 07 Oct 2019 02:05:49 -0700 (PDT) Received: from vader.hsd1.wa.comcast.net ([2601:602:8b80:8e0:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id a17sm13855631pfi.178.2019.10.07.02.05.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 02:05:49 -0700 (PDT) From: Omar Sandoval 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 Message-Id: <340240576c11f97cd326f76b7decd9164c74e91e.1570438723.git.osandov@fb.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-q4/txt/msg00010.txt.bz2 From: Omar Sandoval 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 --- 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 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