Re: [Dwarf-discuss] Proposal: Error: DW_OP_entry_value description and examples

2023-08-08 Thread Kyle Huey via Dwarf-discuss
On Tue, Aug 8, 2023 at 9:22 AM Metzger, Markus T via Dwarf-discuss <
dwarf-discuss@lists.dwarfstd.org> wrote:

> >### Section 2.5.1.7 Special Operations, p.37
> >
> >The first sentence of the description of DW_OP_entry_value reads:
> >
> >The DW_OP_entry_value operation pushes the value that the described
> >location held upon entering the current subprogram.
> >
> >A DWARF expression does not describe a location, so this should read:
> >
> >The DW_OP_entry_value operation evaluates an expression or register
> >location description as if it had been evaluated upon entering the
> >current subprogram, and pushes the value of the expression or content
> >of the register, respectively.
>
> Aren't register location descriptions the only thing that, given
> appropriate
> unwind rules, can actually be implemented?
>
> Should this be restricted to only allow register location descriptions?
>

There exist debuggers (e.g. Pernosco https://pernos.co/about/overview/)
that are capable of handling non-register location descriptions in the
past, so I would oppose any spec limitation on what DW_OP_entry_value can
evaluate.

- Kyle


> Regards,
> Markus.
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de 
> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
>
> --
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
>
-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss


Re: [Dwarf-discuss] Proposal: Error: DW_OP_entry_value description and examples

2023-08-08 Thread Jakub Jelinek via Dwarf-discuss
On Tue, Aug 08, 2023 at 04:21:57PM +, Metzger, Markus T via Dwarf-discuss 
wrote:
> >### Section 2.5.1.7 Special Operations, p.37
> >
> >The first sentence of the description of DW_OP_entry_value reads:
> >
> >The DW_OP_entry_value operation pushes the value that the described
> >location held upon entering the current subprogram.
> >
> >A DWARF expression does not describe a location, so this should read:
> >
> >The DW_OP_entry_value operation evaluates an expression or register
> >location description as if it had been evaluated upon entering the
> >current subprogram, and pushes the value of the expression or content
> >of the register, respectively.
> 
> Aren't register location descriptions the only thing that, given appropriate
> unwind rules, can actually be implemented?

No.  It is certainly the most common one and the reason why the special case
exists.
But, one can also e.g. DW_OP_entry_value >
if it is in a reg which has either size that doesn't fit into address size
or is e.g. floating point, or it should be able to describe a stack slot,
say if calling conventions pass first 6 integer arguments in registers and
then stack, one should be still able to note that it is constant 42 pushed
into that stack slot.

There are two different uses of DW_OP_entry_value.  One is to find matching
expression in the call site if it can be located and use DW_AT_call_value of
that, obviously for that the comparison doesn't compare the values but what
contains the value.  Say for DW_OP_entry_value  if the register
currently contains value 42 one doesn't search in call site for something
that also evaluates to value 42, but one that is the register 5.  For stack
slot addresses, one should compare the addresses though.  And then the other
way is the remember at function starts the value (so one evaluates the DWARF
expression to get the value there) and remembers it under that (register 5,
memory address 0x14958ab3454, and the like).

> Should this be restricted to only allow register location descriptions?

No.

Jakub

-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss


Re: [Dwarf-discuss] Proposal: Error: DW_OP_entry_value description and examples

2023-08-08 Thread Metzger, Markus T via Dwarf-discuss
>### Section 2.5.1.7 Special Operations, p.37
>
>The first sentence of the description of DW_OP_entry_value reads:
>
>The DW_OP_entry_value operation pushes the value that the described
>location held upon entering the current subprogram.
>
>A DWARF expression does not describe a location, so this should read:
>
>The DW_OP_entry_value operation evaluates an expression or register
>location description as if it had been evaluated upon entering the
>current subprogram, and pushes the value of the expression or content
>of the register, respectively.

Aren't register location descriptions the only thing that, given appropriate
unwind rules, can actually be implemented?

Should this be restricted to only allow register location descriptions?

Regards,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de 
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss


[Dwarf-discuss] Proposal: Error: DW_OP_entry_value description and examples

2023-08-08 Thread Robinson, Paul via Dwarf-discuss
# Error: DW_OP_entry_value description and examples

## Overview

DW_OP_entry_value provides a way to compute a value as if the value
had been computed on entry to the current subprogram. Its operand is
either a DWARF expression, which assumes nothing is already on the
DWARF stack and leaves one value on the DWARF stack; or, it is a
register location description, and the content of the register (as it
was on entry to the subprogram) is implicitly read and pushed on the
DWARF stack. The register location description is simply a more compact 
representation of the common case of reading a register; for example, 
the producer can emit "DW_OP_reg1" instead of "DW_OP_breg1 0" with the 
same result.

However, the description and examples aren't completely consistent, and
in some cases are wrong. This proposal corrects the language and examples.

## Proposed Changes

### Section 2.5.1.7 Special Operations, p.37

The first sentence of the description of DW_OP_entry_value reads:

The DW_OP_entry_value operation pushes the value that the described
location held upon entering the current subprogram.

A DWARF expression does not describe a location, so this should read:

The DW_OP_entry_value operation evaluates an expression or register
location description as if it had been evaluated upon entering the
current subprogram, and pushes the value of the expression or content
of the register, respectively.

### Appendix D.1.3, pp.291-292

There are six examples of DW_OP_entry_value, some of which are not
consistent with the description and some of which are just plain wrong.
The six examples are:

DW_OP_entry_value 2 DW_OP_breg1 0
DW_OP_entry_value 1 DW_OP_reg1
DW_OP_entry_value 2 DW_OP_breg1 0 DW_OP_stack_value
DW_OP_entry_value 1 DW_OP_reg1 DW_OP_stack_value
DW_OP_entry_value 3 DW_OP_breg4 16 DW_OP_deref DW_OP_stack_value
DW_OP_entry_value 1 DW_OP_reg5 DW_OP_plus_uconst 16

The first two illustrate the smaller expression allowed by the special
case for a register location description; they are fine.

The third is just wrong and should be deleted. DW_OP_stack_value converts
a memory location description into a value, but what precedes it is not
a memory location description. Without the stack_value, it's identical to
the first example.

The fourth is just wrong and should be deleted. DW_OP_reg1 names a register
but pushes nothing on the stack, so DW_OP_stack_value is incorrect; and
without that, it's identical to the second example.

The fifth should not have DW_OP_stack_value at the end; the expression
already leaves a value on the stack.

The sixth is incorrectly using DW_OP_reg5, which is allowed in a location
description but not in a simple DWARF expression. The expression could be:
DW_OP_entry_value 2 DW_OP_breg5 16

The textual description of the sixth example should also be revised.
Currently it reads:
The address of the memory location is calculated by adding 16 to the
value contained in register 5 upon erringing the current subprogram.
Note that unlike the previous DW_OP_entry_value examples, this one
does not end with DW_OP_stack_value.

This should be changed to:
Add 16 to the value register 5 had upon entering the current subprogram
and push the result.

(The italicized text after the sixth example should be removed entirely;
there is no reason ever to use DW_OP_stack_value in these expressions.)

-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss