Fri May 3 21:09:00 GMT 2019
On Thu, May 02, 2019 at 07:29:33PM +0000, Sasha Da Rocha Pinheiro wrote:
> So why not aÂ DW_OP_constu or DW_OP_consts and then a DW_OP_plus?
Probably because that is multiple operators and less efficiently
encoded. But yes, it would be slightly more "correct" semantically.
In this case however it is for computing (unsigned) addresses (CFA
plus offset) in which case unsigned arithmetic is fine.
> About the Dwarf_Op array we get from dwarf_frame_register(), (which
> are a sequence of Dwarf expressions): are they suppose to be an
> abstraction to all types of dwarf location descriptions? Including
> Single (single and composite) and Location Lists?
In theory yes, it is not a special kind of Dwarf Location
Expression. It should be usable generially, although clearly it
resolves in the context of the CFI (current pc and register values,
memory, etc.). It turns the CFI for getting a register into a Dwarf
Location Expression that you can use to resolve the value of that
> Is there more documentation about dwfl? What does dwfl stand for?
> (dwarf frame library?!)
All documentation is in libdwfl.h for now. I am not sure dwfl
officially stands for anything. But if ebl is the Elf Backend
Library, then dwfl could be the libDW Frontend Library.
> We already have access to the process memory space and registers, so
> would expr_eval be suffice?
Yes, if you are just looking for CFI/Unwinding then that should be
enough. But expr_eval isn't a generic DWARF Expression evaluator so
you cannot simply use it as is for generic DWARF Location Expressions
coming from other parts of DWARF.
> In case of finding the registers values at some PC, would it always
> gives us a single expression (like an address or an offset from a
> In the comment of dwarf_frame_register() in the file libdw.h, there
> is: "Note the last operation is DW_OP_stack_value if there is no
> mutable location but only a computable value." What is a mutable
> location, I didn't find this concept in the Dwarf Debugging
> Information Format v4.
I believe "mutable locations" is what DWARF calls Location
Descriptions, which point to a memory location or register where the
value can be found (and so can be changed in that location). And what
is called a "computable value" is what DWARF calls Implicit Location
Descriptions, which provides a value itself (so there is no real
location that can be changed).
> Also there there is:
> 1057 Â Â For common simple expressions *OPS is OPS_MEM. Â For arbitrary DWARF
> 1058 Â Â expressions in the CFI, *OPS is an internal pointer that can be used as
> 1059 Â Â long as the Dwarf_CFI used to create FRAME remains alive. Â */
> Why simple expression can only have 3 operations? (since Dwarf_Op ops_mem)
> And what's an arbitrary Dwarf expression? What's a non-arbitrary?
It is "common simple expressions" vs "arbitrary expressions". The
interface is made to make memory management easier (for the
implementation of the function). But might be slightly confusing if
you don't know that (you really shouldn't know about the internals).
The idea is that most often the CFI expression can be turned into 1, 2
or 3 DWARF operators. The caller is asked to provide memory to store
those. If the expression is bigger, then a pointer to internal storage
is returned. In both cases you would just use *OPS for the *NOPS
number of operations (in the first case *OPS points to your *MEM_OPS
provided array, in the second case it points to some internal storage.
More information about the Elfutils-devel