- Fix crash on static method with no parameters.

This commit is contained in:
Jan Kratochvil 2011-01-30 22:10:18 +01:00
parent dedd61bd27
commit a20260859f
2 changed files with 101 additions and 1 deletions

93
gdb-crash-noparam.patch Normal file
View File

@ -0,0 +1,93 @@
http://sourceware.org/ml/gdb-patches/2011-01/msg00559.html
http://sourceware.org/ml/gdb-cvs/2011-01/msg00192.html
### src/gdb/ChangeLog 2011/01/28 16:32:26 1.12516
### src/gdb/ChangeLog 2011/01/29 10:30:19 1.12517
## -1,3 +1,9 @@
+2011-01-29 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix crash.
+ * valops.c (compare_parameters): Verify TYPE_NFIELDS before
+ touching TYPE_FIELD_ARTIFICIAL.
+
2011-01-28 Richard Earnshaw <rearnsha@arm.com>
* MAINTAINERS: Move myself from Responsible Maintainers to Authorized
--- src/gdb/valops.c 2011/01/12 16:10:05 1.265
+++ src/gdb/valops.c 2011/01/29 10:30:19 1.266
@@ -3097,7 +3097,7 @@
{
int start = 0;
- if (TYPE_FIELD_ARTIFICIAL (t1, 0))
+ if (TYPE_NFIELDS (t1) > 0 && TYPE_FIELD_ARTIFICIAL (t1, 0))
++start;
/* If skipping artificial fields, find the first real field
### src/gdb/testsuite/ChangeLog 2011/01/28 16:18:55 1.2563
### src/gdb/testsuite/ChangeLog 2011/01/29 10:30:19 1.2564
## -1,3 +1,8 @@
+2011-01-29 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.cp/noparam.exp: New file.
+ * gdb.cp/noparam.cc: New file.
+
2011-01-28 Pedro Alves <pedro@codesourcery.com>
* gdb.trace/tfile.exp: Test that with no traceframe selected,
--- src/gdb/testsuite/gdb.cp/noparam.cc
+++ src/gdb/testsuite/gdb.cp/noparam.cc 2011-01-30 20:52:48.767554000 +0000
@@ -0,0 +1,29 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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 3 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, see <http://www.gnu.org/licenses/>. */
+
+class C
+{
+public:
+ static void m () {}
+};
+
+int
+main ()
+{
+ C::m ();
+ return 0;
+}
--- src/gdb/testsuite/gdb.cp/noparam.exp
+++ src/gdb/testsuite/gdb.cp/noparam.exp 2011-01-30 20:52:49.056124000 +0000
@@ -0,0 +1,21 @@
+# Copyright 2011 Free Software Foundation, Inc.
+
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+
+if { [prepare_for_testing noparam.exp "noparam" "noparam.cc" {debug c++}] } {
+ return -1
+}
+
+# Check if GDB does not crash.
+gdb_test "p C::m (int)" "no member function matches that type instantiation"

View File

@ -27,7 +27,7 @@ Version: 7.2
# 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: 39%{?_with_upstream:.upstream}%{dist}
Release: 40%{?_with_upstream:.upstream}%{dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
Group: Development/Debuggers
@ -723,6 +723,9 @@ Patch561: gdb-core-threads-3of5.patch
Patch562: gdb-core-threads-4of5.patch
Patch563: gdb-core-threads-5of5.patch
# Fix crash on static method with no parameters.
Patch564: gdb-crash-noparam.patch
BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
Requires: readline%{?_isa}
BuildRequires: readline-devel%{?_isa}
@ -1032,6 +1035,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch561 -p1
%patch562 -p1
%patch563 -p1
%patch564 -p1
%patch390 -p1
%patch393 -p1
@ -1429,6 +1433,9 @@ fi
%endif
%changelog
* Sun Jan 30 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.2-40.fc14
- Fix crash on static method with no parameters.
* Sun Jan 30 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.2-39.fc14
- Display pthread_t for threads even from core files (PR 8210, BZ 673696).