[Bug gdb/34315] New: [gdb] DW_OP_plus_uconst does not preserve the explicit type of the popped operand
firmiana402 at gmail dot com via Gdb-prs <[email protected]>
| Newsgroups | gmane.comp.gdb.bugs.discuss |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://sourceware.org/bugzilla/show_bug.cgi?id=34315
Bug ID: 34315
Summary: [gdb] DW_OP_plus_uconst does not preserve the explicit
type of the popped operand
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: firmiana402 at gmail dot com
Target Milestone: ---
The DWARF 5 specification requires that DW_OP_plus_uconst preserve the type
of the value popped from the top of the stack.
Section 2.5.1.4 states:
"The DW_OP_plus_uconst operation pops the top stack entry, adds it to the
unsigned LEB128 constant operand interpreted as the same type as the operand
popped from the top of the stack and pushes the result."
In gdb/dwarf2/expr.c, the DW_OP_plus_uconst case of execute_stack_op rebuilds
the result as address_type instead of preserving the explicit type of the
popped operand:
case DW_OP_plus_uconst:
dwarf_require_integral (result_val->type ());
result = value_as_long (result_val);
op_ptr = safe_read_uleb128 (op_ptr, op_end, ®);
result += reg;
result_val = value_from_ulongest (address_type, result);
break;
The issue is the final line:
result_val = value_from_ulongest (address_type, result);
By this point, the original explicitly-typed operand has been discarded, and
the result is reconstructed with address_type. Per the specification,
DW_OP_plus_uconst should interpret the immediate as the same type as the
popped operand and push a result of that same type.
As a result, gdb does not preserve the typed-stack semantics mandated by the
DWARF specification. Subsequent typed operations may then observe an incorrect
type, and either produce wrong results or fail unexpectedly.
--
You are receiving this mail because:
You are on the CC list for the bug.