[Bug gdb/34363] New: [gdb] gdb ignores the DW_OP_regval_type base type operand inside DW_OP_entry_value

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=34363

            Bug ID: 34363
           Summary: [gdb] gdb ignores the DW_OP_regval_type base type
                    operand inside DW_OP_entry_value
           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: ---

DW_OP_entry_value matches its nested register block with
dwarf_block_to_dwarf_reg in gdb/dwarf2/expr.c, 
whose contract is documented as:

    /* If BLOCK contains DW_FORM_block* with single DW_OP_reg* return the
       DWARF register number.  Otherwise return -1.  */

In practice the function accepts more than a single DW_OP_reg*: it also matches
DW_OP_regval_type / DW_OP_GNU_regval_type (and DW_OP_regx). Accepting the typed
register form is fine per DWARF, but DW_OP_regval_type is handled incompletely.
Its branch reads the register operand and then merely skips the type operand
with gdb_skip_leb128, and the function returns only the register number:

    if (*buf == DW_OP_regval_type || *buf == DW_OP_GNU_regval_type)
      {
        buf++;
        buf = gdb_read_uleb128 (buf, buf_end, &dwarf_reg);
        if (buf == NULL)
          return -1;
        buf = gdb_skip_leb128 (buf, buf_end);
        if (buf == NULL)
          return -1;
      }
    ...
    return dwarf_reg;

The caller then uses the result as a plain register value
(CALL_SITE_PARAMETER_DWARF_REG). In DWARF the second operand of
DW_OP_regval_type is the base type the register contents are to be interpreted
as; dropping it means a typed, possibly narrower entry value is materialized as
the untyped full register value, silently changing the meaning of an expression
GDB has otherwise accepted.

This leaves DW_OP_regval_type half-supported: accepted, but stripped of the
operand that defines it. It should be handled one way or the other — either
reject the DW_OP_regval_type / DW_OP_GNU_regval_type form (consistent with the
"single DW_OP_reg*" contract the comment already states), or support it fully
by
applying the base type to the register value.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.