Bug 28579 - libdwfl api for accessing registers for a thread frame (full register unwinding)
Summary: libdwfl api for accessing registers for a thread frame (full register unwinding)
Status: ASSIGNED
Alias: None
Product: elfutils
Classification: Unclassified
Component: libdw (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Di Chen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-10 14:07 UTC by Mark Wielaard
Modified: 2022-07-19 14:23 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Submit a Patch for Bug 28579 (1.44 KB, patch)
2022-07-03 14:58 UTC, Di Chen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2021-11-10 14:07:53 UTC
dwfl has most of the infrastructure to keep the full unwind state, including the state of unwound registers per frame using Dwfl_Thread_Callbacks. But there is no public API to access that state, except for the PC (dwfl_frame_pc).

There should be other methods on Dwfl_Frame to access other state.
Comment 1 Di Chen 2022-07-03 14:58:56 UTC
Created attachment 14193 [details]
Submit a Patch for Bug 28579
Comment 2 Mark Wielaard 2022-07-08 22:41:10 UTC
Thanks. This looks nice and simple. Few small comments:

- The dwfl_frame_reg should be in a new ELFUTILS_0.188 { global: dwfl_frame_reg; } ELFUTILS_0.186; section (that is, this symbol is new in ELFUTILS_0.188 which inherits from ELFUTILS_0.186).

- Technically __libdwfl_frame_reg_get failing can be either invalid register or unknown value (if state->regs_set is false). It might make sense to set a different error message if it isn't too much work.

- When using public functions internally we usually use INTUSE (dwfl_frame_reg). Which is an tiny optimization to avoid a plt call. You'll need an INTDECL in libdwflP.h.

- In the unwinder we are only really interested in addresses, which is why we use Dwarf_Addr, but here I think we should use Dwarf_Word as the *val that dwfl_frame_reg returns. Both are really uint64_t, so it doesn't really matter, but it makes it more clear that the caller is responsible for interpreting the register value.
Comment 3 Di Chen 2022-07-19 14:23:48 UTC
Thank you Mark,

I have re-pushed a patch[1] for

1). add dwfl_frame_reg to ELFUTILS_0.188
2). add invalid regno check for dwfl_frame_reg
3). add INTDECL (dwfl_frame_reg)
4). Replace Dwarf_Word with Dwarf_Addr for *val

[1] https://sourceware.org/pipermail/elfutils-devel/2022q3/005206.html