This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
gdb/860: dwarf2cfi get_reg is non-portable
- From: malachi000 at hotmail dot com
- To: gdb-gnats at sources dot redhat dot com
- Date: 2 Dec 2002 23:06:19 -0000
- Subject: gdb/860: dwarf2cfi get_reg is non-portable
- Reply-to: malachi000 at hotmail dot com
>Number: 860
>Category: gdb
>Synopsis: dwarf2cfi get_reg is non-portable
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Dec 02 15:08:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: malachi000@hotmail.com
>Release: 5.2
>Organization:
>Environment:
Solaris 2.5/2.8 host with any little endian target
>Description:
In dwarf2cfi.c, the function get_reg takes a char* as its first argument. In most cases, this buffer is cast to a CORE_ADDR by the caller. If the endianness of the target doesn't match that of the host, it is a problem. Reading memory and registers is defined to return data in *target* format, and will result in corrupted register values on a cross-endian build.
See "Fix" for suggested solution.
>How-To-Repeat:
>Fix:
Change the type of get_reg to:
static ULONGEST get_reg (struct context *context, int regnum)
... and create a local buffer reg[sizeof (ULONGEST)]
... read in the data to the buffer and perform:
extract_unsigned_integer (reg, REGISTER_RAW_SIZE(regnum))
... and return that value (except for case REG_CTX_VALUE which is already stored in host-endianness).
>Release-Note:
>Audit-Trail:
>Unformatted: