This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb/860: dwarf2cfi get_reg is non-portable


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]