This is the mail archive of the gdb-patches@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]

[RFA] mips-irix SEGV: long doubles are 128 bits long on IRIX


Hello,

I noticed the following SEGV in our testsuite. Here is below how to
reproduce it using the store.c sources in testsuite/gdb.base:

        % gcc -c -g store.c
        % gcc -o store store.o

The following transcript shows how to cause the SEGV:

        (gdb) b wack_doublest
        Breakpoint 1 at 0x1000256c: file store.c, line 125.
        (gdb) run
        Starting program: /[...]/gdb.base/store

        Breakpoint 1, wack_doublest (u=Unhandled dwarf expression opcode 0x93
        ) at store.c:125
        125       register doublest l = u, r = v;
        (gdb) n
        warning: GDB can't find the start of the function at 0x100108d4.

            GDB is unable to find the start of the function at 0x100108d4
        and thus can't determine the size of that function's stack frame.
        This means that GDB may be unable to access that stack frame, or
        the frames below it.
            This problem is most likely caused by an invalid program counter or
        stack pointer.
            However, if you think GDB should simply search farther back
        from 0x100108d4 for code which looks like the beginning of a
        function, you can increase the range of the search using the `set
        heuristic-fence-post' command.
        126       l = add_doublest (l, r);
        (gdb) p l
        zsh: 6356790 segmentation fault (core dumped)  ../../gdb store

We'll ignore the 2 warnings for now ("opcode 0x93" = OP_piece, and
"can't find start of function at 0x..."), and focus on the SEGV.

The problem is that GDB thinks that long double variables are 64 bits
long, but they are in fact 128 bits long. The discrepancy causes GDB
to fail to find the associated format for type doublest (which is
a typedef of long double), and then call floatformat_is_valid() with
a NULL format... See values.c:unpack_double():

      if (!floatformat_is_valid (floatformat_from_type (type), valaddr))
        {
          *invp = 1;
          return 0.0;
        }

The attached patch should fixes the problem (on 032, the SGI compiler
claims that "long double" is not supported on implicitly changes them
into plain "double" types (64bit), while GCC says they are 64bit).

2004-07-21  Joel Brobecker  <brobecker@gnat.com>

        * mips-irix-tdep.c: #include "mips-tdep.h".
        (mips_irix_init_abi): Set size of long double to 128 bits
        for N32 and N64 ABIs.
        * Makefile.in (mips-irix-tdep.o): Add dependency on mips-tdep.h.

Tested on mips-irix, fixes the problem above and many other FAILs.
OK to commit?

As for the 6.2 branch, my guess is that it would need this fix as well.
But I haven't looked at it, because I am already too overloaded with
work. There is also the bfd patch I just submitted, too.

-- 
Joel

Attachment: irix.diff
Description: Text document


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