[Bug gdb/34365] New: [gdb] at least 17 typed DWARF operators share a base-type check that ignores DW_AT_bit_size
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=34365
Bug ID: 34365
Summary: [gdb] at least 17 typed DWARF operators share a
base-type check that ignores DW_AT_bit_size
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 typed binary and relational DWARF operators all gate on one helper,
base_types_equal_p in gdb/dwarf2/expr.c, which compares only type code,
signedness, and byte length:
/* Return true iff the types T1 and T2 are "the same". This only does
checks that might reasonably be needed to compare DWARF base
types. */
static bool
base_types_equal_p (struct type *t1, struct type *t2)
{
if (t1->code () != t2->code ())
return false;
if (t1->is_unsigned () != t2->is_unsigned ())
return false;
return t1->length () == t2->length ();
}
The function's own comment says it does the checks "that might reasonably be
needed to compare DWARF base types" — but it omits DW_AT_bit_size, which is
itself one of those properties. A base type's bit size is exactly what
distinguishes GCC's _BitInt(31) from _BitInt(32): both are DW_TAG_base_type
DIEs
that agree on type code, signedness, and byte length (4-byte signed), and
differ
only in DW_AT_bit_size (31 vs 32). base_types_equal_p returns true for them, so
an expression that combines the two is accepted instead of being rejected as a
type mismatch.
GDB already records this property: type->bit_size () returns the logical bit
size, and type->bit_size_differs_p () identifies exactly the case where it
differs from the byte size, so the check has the information it needs and
simply
does not use it.
The check gates the entire typed binary/relational operator group in
execute_stack_op:
if (!base_types_equal_p (first->type (), second->type ()))
error (_("Incompatible types on DWARF stack"));
so all of these operators inherit the weak comparison. That is at least 17
opcodes, all gated by this single check:
DW_OP_and, DW_OP_div, DW_OP_minus, DW_OP_mod, DW_OP_mul, DW_OP_or,
DW_OP_plus, DW_OP_shl, DW_OP_shr, DW_OP_shra, DW_OP_xor,
DW_OP_le, DW_OP_ge, DW_OP_eq, DW_OP_lt, DW_OP_gt, DW_OP_ne
--
You are receiving this mail because:
You are on the CC list for the bug.