Hi Ben,

On Fri, 2025-11-07 at 08:09 -0800, Ben Woodard wrote:
> On 11/7/25 6:58 AM, Mark Wielaard wrote:
> > On Thu, 2025-11-06 at 11:34 -0800, Ben Woodard via Dwarf-discuss wrote:
> > 
> > I think renaming is really confusing. And I think extending to
> > supporting floating point types should be a separate issue that would
> > also look at the other operators.
> > 
> > Maybe a compromise would be to keep DW_OP_mod (and make DW_OP_rem an
> > alias?)
> 
> I would do it the other way around make DW_OP_mod be a legacy alias and 
> call the same operation DW_OP_rem.

I think that is fine, as long as they have the same constant value
(0x1d).

> With Jakub's example, I think that we have a compelling reason to expand 
> the domain of DW_OP_rem (the former DW_OP_mod) to include signed 
> integral types as well as unsigned integral types. His example seems to 
> require the semantics of C99's % operator (truncated division).
> 
> If we do this, then it will be backward compatible. The only thing that 
> we would be changing is the domain over which the current DW_OP_mod 
> operates. We are not changing any of the semantics.

Because the semantics weren't really defined for the expanded domain,
which means e.g. gdb does interpret it differently.

> I'm ambivalent about expanding the domain to floating point values. If 
> someone has a reason for having it work on floating point types, then 
> sure why not. It is a bit of extra code in every consumer but whatever.

And it makes us have to define how floating point values are
represented and pick a specific interpretation of the operations.

> What I really care about is that when we update the description of 
> DW_OP_rem (the operation formerly known asĀ  DW_OP_mod) we specify both 
> the domain of the operator as well as the algorithm used.

I think doing both a renaming and redefining the interpretation of the
operation and domain at the same time is super confusing. Better to
just introduce two new operations for the expanded domain.

> >   Then introduce new DW_OP_modulo (defined using floored
> > division)
> Again I'm personally ambivalent about the need for this. I don't think 
> that it is going to be used very often and I think if we do define it we 
> should consider pushing it into the new DW_OP_extended operation 
> encoding space. This will make its encoding a two byte operation but it 
> will reserve more of the one byte encodings for more frequently used 
> operations.

Sure DW_OP_modulo and DW_OP_remainder could be "extended" operations.

> > and DW_OP_remainder (defined using truncated division)
> > operators that are only to be used with typed DWARF stack values?
> 
> I really do believe that a better approach is to rename and expand the 
> domain of the current DW_OP_mod rather than adding another new special 
> purpose operator.

I disagree. I think just leave DW_OP_mod for legacy operation on the
generic type and have two clearly defined new DW_OP_modulo and
DW_OP_remainder for typed DWARF stack values is much clearer.

Cheers,

Mark
-- 
Dwarf-discuss mailing list
[email protected]
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

Reply via email to