[Bug gdb/34416] Incorrect loss of sign in 64-bit multiply (e.g.: DW_OP_mul in DWARF evaluation)
tromey at sourceware dot org via Gdb-prs <[email protected]>
| Newsgroups | gmane.comp.gdb.bugs.discuss |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://sourceware.org/bugzilla/show_bug.cgi?id=34416
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
> The signed DW_OP_mul is ending up as a * |b| and not (a * b) because of this.
I believe that, in this context, DW_OP_mul is supposed to be unsigned.
First, the DWARF expression here is not using the "typed" DWARF opcodes.
This means all the types on the stack are the DWARF "generic type".
Then the standard says (see DWARF 5 section 2.5.1.4 "Arithmetic and Logical
Operations"):
> If the type of the operands is the generic type, except as otherwise specified, the
> arithmetic operations perform addressing arithmetic, that is, unsigned arithmetic
> that is performed modulo one plus the largest representable address.
And then specifically:
> The DW_OP_mul operation pops the top two stack entries, multiplies them together, and pushes the result.
The "generic type" is just a pointer-sized integer whose sign is unspecified
(i.e., 2s complement number whose interpretation varies according to the
operation).
Looking at the DWARF expression evaluator, though, leaves me confused,
since apparently the "address type" (which is what gdb calls the generic type,
I guess for historicaly reasons) is signed?
types->dw_types[ndx]
= init_integer_type (alloc, 8 * this->m_addr_size,
0, "<signed DWARF address type>");
That "0" is the "unsigned" flag.
OTOH with 2's complement this shouldn't actually matter.
I guess the thing to do is step through the DWARF expression by hand and try
to figure out where it's going wrong. I tend to doubt that it's DW_OP_mul,
based on the above. It's possible this would turn out to be a compiler bug
as well, hard to say just by reading a complicated expression like that.
--
You are receiving this mail because:
You are on the CC list for the bug.