From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24349 invoked by alias); 21 Jul 2004 21:25:25 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24338 invoked from network); 21 Jul 2004 21:25:23 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sourceware.org with SMTP; 21 Jul 2004 21:25:23 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id AE9EE47D91; Wed, 21 Jul 2004 14:25:22 -0700 (PDT) Date: Wed, 21 Jul 2004 21:25:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: [RFA] mips-irix SEGV: long doubles are 128 bits long on IRIX Message-ID: <20040721212522.GP1278@gnat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="KdquIMZPjGJQvRdI" Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2004-07/txt/msg00290.txt.bz2 --KdquIMZPjGJQvRdI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2756 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 * 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 --KdquIMZPjGJQvRdI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="irix.diff" Content-length: 1832 Index: mips-irix-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/mips-irix-tdep.c,v retrieving revision 1.2 diff -u -p -r1.2 mips-irix-tdep.c --- mips-irix-tdep.c 21 Dec 2002 19:58:07 -0000 1.2 +++ mips-irix-tdep.c 21 Jul 2004 21:18:45 -0000 @@ -24,6 +24,7 @@ #include "osabi.h" #include "elf-bfd.h" +#include "mips-tdep.h" static void mips_irix_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect, @@ -80,6 +81,20 @@ static void mips_irix_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + enum mips_abi abi = mips_abi (gdbarch); + + switch (abi) + { + case MIPS_ABI_O32: + break; + case MIPS_ABI_N32: + case MIPS_ABI_N64: + set_gdbarch_long_double_bit (gdbarch, 128); + break; + default: + internal_error (__FILE__, __LINE__, "unexpected ABI"); + } } void Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.595 diff -u -p -r1.595 Makefile.in --- Makefile.in 17 Jul 2004 11:03:46 -0000 1.595 +++ Makefile.in 21 Jul 2004 21:18:56 -0000 @@ -2113,7 +2113,8 @@ mem-break.o: mem-break.c $(defs_h) $(sym $(target_h) minsyms.o: minsyms.c $(defs_h) $(gdb_string_h) $(symtab_h) $(bfd_h) \ $(symfile_h) $(objfiles_h) $(demangle_h) $(value_h) $(cp_abi_h) -mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h) +mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h) \ + $(mips_tdep_h) mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h) mips-linux-tdep.o: mips-linux-tdep.c $(defs_h) $(gdbcore_h) $(target_h) \ $(solib_svr4_h) $(osabi_h) $(mips_tdep_h) $(gdb_string_h) \ --KdquIMZPjGJQvRdI--