- Fix memory trashing on binaries from GNAT/Ada (workaround GCC PR 35998).

This commit is contained in:
Jan Kratochvil 2008-05-22 23:06:40 +00:00
parent 31a2eafa99
commit 296cce914d
5 changed files with 183 additions and 123 deletions

View File

@ -1,91 +1,6 @@
--- /dev/null 2007-10-25 16:04:06.860116064 -0400
+++ gdb-6.3/gdb/testsuite/gdb.base/gcore-shmid0.c 2007-10-27 14:49:59.000000000 -0400
@@ -0,0 +1,82 @@
+/* Copyright 2007 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/*
+ * Test GDB's handling of gcore for mapping with a name but zero inode.
+ */
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+
+/* We need a backtrace through the stack. */
+
+static void
+initialized (void)
+{
+}
+
+int
+main (void)
+{
+ int sid;
+ unsigned int *addr = (void *) -1L;
+ int try;
+
+ /* The generated SID will cycle with an increment of 32768, try until it
+ * wraps to 0. */
+
+ for (try = 0; addr == (void *) -1L; try++)
+ {
+ assert (try < 0x10000);
+
+ sid = shmget ((key_t) rand (), 0x1000, IPC_CREAT | IPC_EXCL | 0777);
+ if (sid == -1)
+ {
+ printf ("shmget (%d, 0x1000, IPC_CREAT): errno %d\n", 0, errno);
+ exit (1);
+ }
+
+ /* Use SID only if it is 0, retry it otherwise. */
+
+ if (sid == 0)
+ {
+ addr = shmat (sid, NULL, SHM_RND);
+ if (addr == (void *) -1L)
+ {
+ printf ("shmat (%d, NULL, SHM_RND): errno %d\n", sid,
+ errno);
+ exit (1);
+ }
+ }
+ if (shmctl (sid, IPC_RMID, NULL) != 0)
+ {
+ printf ("shmctl (%d, IPC_RMID, NULL): errno %d\n", sid, errno);
+ exit (1);
+ }
+ }
+
+ initialized ();
+
+ return 0;
+}
--- /dev/null 2007-10-25 16:04:06.860116064 -0400
+++ gdb-6.3/gdb/testsuite/gdb.base/gcore-shmid0.exp 2007-10-27 14:50:40.000000000 -0400
@@ -0,0 +1,116 @@
--- /dev/null 2008-05-02 23:36:22.370004160 +0200
+++ gdb-6.8/gdb/testsuite/gdb.base/gcore-shmid0.exp 2008-05-03 22:36:56.000000000 +0200
@@ -0,0 +1,120 @@
+# Copyright 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
@ -107,13 +22,6 @@
+
+# Test GDB's handling of gcore for mapping with a name but zero inode.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+set testfile "gcore-shmid0"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
@ -150,12 +58,23 @@
+}
+
+if { ! [ runto_main ] } then {
+ untested gcore-buffer-overflow.exp
+ untested gcore-shmid0.exp
+ return -1
+}
+
+gdb_breakpoint "initialized"
+gdb_continue_to_breakpoint "initialized"
+gdb_breakpoint "unresolved"
+
+set test "Continue to initialized."
+gdb_test_multiple "continue" $test {
+ -re "Breakpoint .*, initialized .* at .*\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "Breakpoint .*, unresolved .* at .*\r\n$gdb_prompt $" {
+ unsupported $test
+ return -1
+ }
+}
+
+set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore-shmid0.test]
+
@ -202,3 +121,101 @@
+ fail $test
+ }
+}
--- /dev/null 2008-05-02 23:36:22.370004160 +0200
+++ gdb-6.8/gdb/testsuite/gdb.base/gcore-shmid0.c 2008-05-03 22:39:10.000000000 +0200
@@ -0,0 +1,95 @@
+/* Copyright 2007 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/*
+ * Test GDB's handling of gcore for mapping with a name but zero inode.
+ */
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+
+/* We need a backtrace through the stack. */
+
+static void
+initialized (void)
+{
+}
+
+static void
+unresolved (void)
+{
+}
+
+int
+main (void)
+{
+ int sid;
+ unsigned int *addr = (void *) -1L;
+ int try;
+
+ /* The generated SID will cycle with an increment of 32768, try until it
+ * wraps to 0. */
+
+ for (try = 0; addr == (void *) -1L; try++)
+ {
+ /* At least kernel-2.6.25-8.fc9.x86_64 just never returns the value 0 by
+ shmget(2). */
+ if (try > 0x10000)
+ {
+ printf ("Problem no longer reproducible on this kernel (try %d)\n",
+ try);
+ unresolved ();
+ exit (1);
+ }
+
+ sid = shmget ((key_t) rand (), 0x1000, IPC_CREAT | IPC_EXCL | 0777);
+ if (sid == -1)
+ {
+ printf ("shmget (%d, 0x1000, IPC_CREAT): errno %d\n", 0, errno);
+ exit (1);
+ }
+
+ /* Use SID only if it is 0, retry it otherwise. */
+
+ if (sid == 0)
+ {
+ addr = shmat (sid, NULL, SHM_RND);
+ if (addr == (void *) -1L)
+ {
+ printf ("shmat (%d, NULL, SHM_RND): errno %d\n", sid,
+ errno);
+ exit (1);
+ }
+ }
+ if (shmctl (sid, IPC_RMID, NULL) != 0)
+ {
+ printf ("shmctl (%d, IPC_RMID, NULL): errno %d\n", sid, errno);
+ exit (1);
+ }
+ }
+
+ initialized ();
+
+ return 0;
+}

View File

@ -121,26 +121,3 @@
if (args == NULL)
error_no_arg (_("one or more choice numbers"));
2008-04-21 Jan Kratochvil <jan.kratochvil@redhat.com>
Workaround GCC PR ada/35998.
* ada-lang.c (to_fixed_record_type): Error out on invalid length of the
type TYPE0.
--- ./gdb/ada-lang.c 6 Apr 2008 08:56:36 -0000 1.137
+++ ./gdb/ada-lang.c 20 Apr 2008 21:47:05 -0000
@@ -7313,6 +7313,11 @@ to_fixed_record_type (struct type *type0
{
struct type *templ_type;
+ /* GCC PR ada/35998 workaround. */
+ if (TYPE_LENGTH (type0) == 0xffffffff)
+ error (_("Type %s has invalid length -1, check your GCC"),
+ TYPE_NAME (type0));
+
if (TYPE_FLAGS (type0) & TYPE_FLAG_FIXED_INSTANCE)
return type0;

View File

@ -0,0 +1,18 @@
--- ./gdb/dwarf2read.c 4 May 2008 17:27:01 -0000 1.260
+++ ./gdb/dwarf2read.c 4 May 2008 18:26:20 -0000
@@ -6754,7 +6754,14 @@ dwarf2_attr (struct die_info *die, unsig
for (i = 0; i < die->num_attrs; ++i)
{
if (die->attrs[i].name == name)
- return &die->attrs[i];
+ {
+ /* GCC PR ada/35998 workaround. */
+ if (name == DW_AT_byte_size
+ && DW_UNSND (&die->attrs[i]) == 0xffffffff)
+ return NULL;
+
+ return &die->attrs[i];
+ }
if (die->attrs[i].name == DW_AT_specification
|| die->attrs[i].name == DW_AT_abstract_origin)
spec = &die->attrs[i];

View File

@ -778,3 +778,40 @@ diff -u -r1.40 -r1.41
}
static int
2008-05-03 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/dfp-test.exp: Fix random FAIL risk on calling functions.
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/dfp-test.exp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- src/gdb/testsuite/gdb.base/dfp-test.exp 2008/01/30 03:19:26 1.5
+++ src/gdb/testsuite/gdb.base/dfp-test.exp 2008/05/03 21:56:38 1.6
@@ -252,16 +252,16 @@
# Test calling inferior function with DFP arguments or return value.
-send_gdb "call arg0_32 (1.2df, 2.2df, 3.2df, 4.2df, 5.2df, 6.2df)\n"
-gdb_test "backtrace 1" "\n#\[0-9\]+ arg0_32 \\(arg0=1.2, arg1=2.2, arg2=3.2, arg3=4.2, arg4=5.2, arg5=6.2\\).*" "Call function with correct _Decimal32 arguments."
+gdb_test "call arg0_32 (1.2df, 2.2df, 3.2df, 4.2df, 5.2df, 6.2df)" "Breakpoint.*arg0_32.*" "Call function with correct _Decimal32 arguments."
+gdb_test "backtrace 1" "\n#\[0-9\]+ arg0_32 \\(arg0=1.2, arg1=2.2, arg2=3.2, arg3=4.2, arg4=5.2, arg5=6.2\\).*" "Backtrace function with correct _Decimal32 arguments."
gdb_test "finish" " = 1.2" "Correct _Decimal32 return value from called function."
-send_gdb "call arg0_64 (1.2dd, 2.2dd, 3.2dd, 4.2dd, 5.2dd, 6.2dd)\n"
-gdb_test "backtrace 1" "\n#\[0-9\]+ arg0_64 \\(arg0=1.2, arg1=2.2, arg2=3.2, arg3=4.2, arg4=5.2, arg5=6.2\\).*" "Call function with correct _Decimal64 arguments."
+gdb_test "call arg0_64 (1.2dd, 2.2dd, 3.2dd, 4.2dd, 5.2dd, 6.2dd)" "Breakpoint.*arg0_64.*" "Call function with correct _Decimal64 arguments."
+gdb_test "backtrace 1" "\n#\[0-9\]+ arg0_64 \\(arg0=1.2, arg1=2.2, arg2=3.2, arg3=4.2, arg4=5.2, arg5=6.2\\).*" "Backtrace function with correct _Decimal64 arguments."
gdb_test "finish" " = 1.2" "Correct _Decimal64 return value from called function."
-send_gdb "call arg0_128 (1.2dl, 2.2dl, 3.2dl, 4.2dl, 5.2dl, 6.2dl)\n"
-gdb_test "backtrace 1" "\n#\[0-9\]+ arg0_128 \\(arg0=1.2, arg1=2.2, arg2=3.2, arg3=4.2, arg4=5.2, arg5=6.2\\).*" "Call function with correct _Decimal128 arguments."
+gdb_test "call arg0_128 (1.2dl, 2.2dl, 3.2dl, 4.2dl, 5.2dl, 6.2dl)" "Breakpoint.*arg0_128.*" "Call function with correct _Decimal128 arguments."
+gdb_test "backtrace 1" "\n#\[0-9\]+ arg0_128 \\(arg0=1.2, arg1=2.2, arg2=3.2, arg3=4.2, arg4=5.2, arg5=6.2\\).*" "Backtrace function with correct _Decimal128 arguments."
gdb_test "finish" " = 1.2" "Correct _Decimal128 return value from called function."
gdb_test "call decimal_dec128_align (double_val1, dec128_val2, double_val3, double_val4, double_val5, double_val6, double_val7, double_val8, double_val9, double_val10, double_val11, double_val12, double_val13, double_val14)" " = 1" \

View File

@ -13,7 +13,7 @@ Version: 6.8
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 7%{?_with_upstream:.upstream}%{?dist}
Release: 9%{?_with_upstream:.upstream}%{?dist}
License: GPLv3+
Group: Development/Debuggers
@ -355,6 +355,9 @@ Patch316: gdb-6.8-sparc-fix.patch
# Silence memcpy check which returns false positive (sparc64)
Patch317: gdb-6.8-sparc64-silence-memcpy-check.patch
# Fix memory trashing on binaries from GCC Ada (workaround GCC PR 35998).
Patch318: gdb-6.8-gcc35998-ada-memory-trash.patch
BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext
BuildRequires: flex bison sharutils expat-devel
Requires: readline
@ -532,6 +535,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch315 -p1
%patch316 -p1
%patch317 -p1
%patch318 -p1
%patch124 -p1
find -name "*.orig" | xargs rm -f
@ -781,13 +785,20 @@ fi
%endif
%changelog
* Thu May 15 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 6.8-7
* Thu May 22 2008 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.8-9
- Fix memory trashing on binaries from GNAT/Ada (workaround GCC PR 35998).
* Thu May 15 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 6.8-8
- Silence memcpy check which returns false positive (sparc64)
* Thu May 15 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 6.8-6
* Thu May 15 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 6.8-7
- patch from DaveM for sparc/sparc64
- touch up spec to enable sparcv9/sparc64
* Sat May 3 2008 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.8-6
- Fix gdb.base/gcore-shmid0.exp to be unresolved on recent kernels.
- Make the testsuite results of dfp-test.exp more stable.
* Sun Apr 27 2008 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.8-5
- Remove the kernel VDSO workaround (`no loadable ...') (kernel BZ 312011).