diff --git a/0001-Make-c-exp.y-work-with-Bison-3.8.patch b/0001-Make-c-exp.y-work-with-Bison-3.8.patch index 5c9f630d3878ea2a6fa22b7a374ddebe25303900..31c0d891ec28c17ef1501ec802299b9e570fdc50 100644 --- a/0001-Make-c-exp.y-work-with-Bison-3.8.patch +++ b/0001-Make-c-exp.y-work-with-Bison-3.8.patch @@ -18,20 +18,20 @@ Change-Id: I3cbf2f317630bb72810b00f2d9b2c4b99fa812ad 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/c-exp.y b/gdb/c-exp.y -index 3403a85..d17f104 100644 +index 93b10f0..396bd6a 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y -@@ -166,7 +166,7 @@ static void check_parameter_typelist (std::vector *); - static void write_destructor_name (struct parser_state *par_state, - struct stoken); +@@ -167,7 +167,7 @@ static struct stoken operator_stoken (const char *); + static struct stoken typename_stoken (const char *); + static void check_parameter_typelist (std::vector *); -#ifdef YYBISON +#if defined(YYBISON) && YYBISON < 30800 static void c_print_token (FILE *file, int type, YYSTYPE value); #define YYPRINT(FILE, TYPE, VALUE) c_print_token (FILE, TYPE, VALUE) #endif -@@ -3311,7 +3311,7 @@ c_parse (struct parser_state *par_state) - return yyparse (); +@@ -3446,7 +3446,7 @@ c_parse (struct parser_state *par_state) + return result; } -#ifdef YYBISON @@ -40,5 +40,6 @@ index 3403a85..d17f104 100644 /* This is called via the YYPRINT macro when parser debugging is enabled. It prints a token's value. */ -- -2.32.0 +2.30.0 + diff --git a/0001-adjust-include-order-to-avoid-gnulib-error.patch b/0001-adjust-include-order-to-avoid-gnulib-error.patch deleted file mode 100644 index 753bf8b43a389b3e8eace1903c05e957a99a8bbb..0000000000000000000000000000000000000000 --- a/0001-adjust-include-order-to-avoid-gnulib-error.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 8488c357ce4fc309d49c7b0224cf9574b68e8116 Mon Sep 17 00:00:00 2001 -From: Kevin Buettner -Date: Thu, 18 Feb 2021 22:46:58 -0700 -Subject: [PATCH] amd64-linux-siginfo.c: Adjust include order to avoid gnulib - error - -On Fedora rawhide, after updating to glibc-2.33, I'm seeing the -following build failure: - - CXX nat/amd64-linux-siginfo.o -In file included from /usr/include/bits/sigstksz.h:24, - from /usr/include/signal.h:315, - from ../gnulib/import/signal.h:52, - from /ironwood1/sourceware-git/rawhide-gnulib/bld/../../worktree-gnulib/gdbserver/../gdb/nat/amd64-linux-siginfo.c:20: -../gnulib/import/unistd.h:663:3: error: #error "Please include config.h first." - 663 | #error "Please include config.h first." - | ^~~~~ - -glibc-2.33 has changed signal.h to now include which, -in turn, includes . For a gdb build, this causes the gnulib -version of unistd.h to be pulled in first. The build failure shown -above happens because gnulib's config.h has not been included before -the include of . - -The fix is simple - we just rearrange the order of the header file -includes to make sure that gdbsupport/commondefs.h is included before -attempting to include signal.h. Note that gdbsupport/commondefs.h -includes . - -Build and regression tested on Fedora 33. On Fedora rawhide, GDB -builds again. - ---- a/gdb/nat/amd64-linux-siginfo.c -+++ b/gdb/nat/amd64-linux-siginfo.c -@@ -17,8 +17,8 @@ - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - --#include - #include "gdbsupport/common-defs.h" -+#include - #include "amd64-linux-siginfo.h" - - #define GDB_SI_SIZE 128 --- -2.27.0 diff --git a/gdb-9.2.tar.xz b/gdb-11.1.tar.xz similarity index 67% rename from gdb-9.2.tar.xz rename to gdb-11.1.tar.xz index 45c82f8603527b34338db5f4b3475f168f0feeb0..9cf1969468d03d0ffda22df1edd56b0e263468b0 100644 Binary files a/gdb-9.2.tar.xz and b/gdb-11.1.tar.xz differ diff --git a/gdb-6.3-attach-see-vdso-test.patch b/gdb-6.3-attach-see-vdso-test.patch index 635bb0d8f518e209e45a6c9a07c01e008887fd95..daba42fbc5e076f46b4d62221f02f72edb901307 100644 --- a/gdb-6.3-attach-see-vdso-test.patch +++ b/gdb-6.3-attach-see-vdso-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-attach-see-vdso-test.patch + +;; Test kernel VDSO decoding while attaching to an i386 process. +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/attach-see-vdso.c b/gdb/testsuite/gdb.base/attach-see-vdso.c new file mode 100644 --- /dev/null @@ -16,7 +24,7 @@ new file mode 100644 + 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. */ @@ -32,19 +40,19 @@ diff --git a/gdb/testsuite/gdb.base/attach-see-vdso.exp b/gdb/testsuite/gdb.base new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/attach-see-vdso.exp -@@ -0,0 +1,72 @@ +@@ -0,0 +1,77 @@ +# Copyright 2007 + +# 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. @@ -56,6 +64,11 @@ new file mode 100644 + return 0 +} + ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 ++} ++ +set testfile "attach-see-vdso" +set srcfile ${testfile}.c +set binfile [standard_output_file ${testfile}] @@ -96,12 +109,12 @@ new file mode 100644 +gdb_test "bt" "#0 *0x\[0-9a-f\]* in \[^?\].*" "backtrace decodes VDSO" + +# Exit and detach the process. -+ ++ +gdb_exit + +# Make sure we don't leave a process around to confuse +# the next test run (and prevent the compile by keeping +# the text file busy), in case the "set should_exit" didn't +# work. -+ ++ +remote_exec build "kill -9 ${testpid}" diff --git a/gdb-6.3-bz140532-ppc-unwinding-test.patch b/gdb-6.3-bz140532-ppc-unwinding-test.patch index fe29989731dcd821a5351b1945ef9e2b22703684..2e38a262e7b2718186e818e8b0cd02573be734be 100644 --- a/gdb-6.3-bz140532-ppc-unwinding-test.patch +++ b/gdb-6.3-bz140532-ppc-unwinding-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-bz140532-ppc-unwinding-test.patch + +;; Update PPC unwinding patches to their upstream variants (BZ 140532). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S new file mode 100644 --- /dev/null @@ -16,7 +24,7 @@ new file mode 100644 + 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. */ @@ -99,7 +107,7 @@ new file mode 100644 + 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. */ @@ -202,7 +210,7 @@ new file mode 100644 + 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. */ @@ -229,15 +237,15 @@ new file mode 100644 +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Test unwinding fixes of the PPC platform, specifically on the coping with BCL +# jump of the PIE code. diff --git a/gdb-6.3-bz202689-exec-from-pthread-test.patch b/gdb-6.3-bz202689-exec-from-pthread-test.patch index ef49932e5c965a33523879f3fc75bb1af344fc7a..74684ddddd593175bab85af8cd609e59a47a18e1 100644 --- a/gdb-6.3-bz202689-exec-from-pthread-test.patch +++ b/gdb-6.3-bz202689-exec-from-pthread-test.patch @@ -1,3 +1,15 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-bz202689-exec-from-pthread-test.patch + +;; Testcase for exec() from threaded program (BZ 202689). +;;=fedoratest + +2007-01-17 Jan Kratochvil + + * gdb.threads/threaded-exec.exp, gdb.threads/threaded-exec.c: New files. + diff --git a/gdb/testsuite/gdb.threads/threaded-exec.c b/gdb/testsuite/gdb.threads/threaded-exec.c new file mode 100644 --- /dev/null @@ -61,15 +73,15 @@ new file mode 100644 +# 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. */ ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu diff --git a/gdb-6.3-focus-cmd-prev-test.patch b/gdb-6.3-focus-cmd-prev-test.patch index b50dad3d8b2faeac9cd9417e6a0d95d3ca89bc33..27c85f1201bda6f22baf31c5cff4d3638e04068f 100644 --- a/gdb-6.3-focus-cmd-prev-test.patch +++ b/gdb-6.3-focus-cmd-prev-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-focus-cmd-prev-test.patch + +;; Test a crash on `focus cmd', `focus prev' commands. +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/focus-cmd-prev.exp b/gdb/testsuite/gdb.base/focus-cmd-prev.exp new file mode 100644 --- /dev/null diff --git a/gdb-6.3-gstack-20050411.patch b/gdb-6.3-gstack-20050411.patch index 982f885a62d041d74b5ab4cb8f00dfde7cbccf59..9fa2e7d1be6deb67d5d64df6f90b7bd93d62ed45 100644 --- a/gdb-6.3-gstack-20050411.patch +++ b/gdb-6.3-gstack-20050411.patch @@ -1,7 +1,22 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Andrew Cagney +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-gstack-20050411.patch + +;; Add a wrapper script to GDB that implements pstack using the +;; --readnever option. +;;=push + +2004-11-23 Andrew Cagney + + * Makefile.in (uninstall-gstack, install-gstack): New rules, add + to install and uninstall. + * gstack.sh, gstack.1: New files. + diff --git a/gdb/Makefile.in b/gdb/Makefile.in --- a/gdb/Makefile.in +++ b/gdb/Makefile.in -@@ -1768,7 +1768,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force +@@ -1753,7 +1753,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force install: all @$(MAKE) $(FLAGS_TO_PASS) install-only @@ -10,7 +25,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in transformed_name=`t='$(program_transform_name)'; \ echo gdb | sed -e "$$t"` ; \ if test "x$$transformed_name" = x; then \ -@@ -1817,7 +1817,25 @@ install-guile: +@@ -1802,7 +1802,25 @@ install-guile: install-python: $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb @@ -37,7 +52,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in transformed_name=`t='$(program_transform_name)'; \ echo gdb | sed -e $$t` ; \ if test "x$$transformed_name" = x; then \ -@@ -1840,6 +1858,18 @@ uninstall: force $(CONFIG_UNINSTALL) +@@ -1825,6 +1843,18 @@ uninstall: force $(CONFIG_UNINSTALL) fi @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do @@ -52,7 +67,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in + fi ; \ + rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \ + $(DESTDIR)$(man1dir)/$$transformed_name.1 -+ ++ # The C++ name parser can be built standalone for testing. test-cp-name-parser.o: cp-name-parser.c $(COMPILE) -DTEST_CPNAMES cp-name-parser.c @@ -94,7 +109,7 @@ new file mode 100644 + +# Run GDB, strip out unwanted noise. +# --readnever is no longer used since .gdb_index is now in use. -+$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <&1 | ++$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <&1 | +set width 0 +set height 0 +set pagination no @@ -138,7 +153,7 @@ new file mode 100644 + /* Use the most simple notification not to get caught by attach on exiting + the function. */ + write (1, msg, strlen (msg)); -+ ++ + for (;;); +} + diff --git a/gdb-6.3-inferior-notification-20050721.patch b/gdb-6.3-inferior-notification-20050721.patch index 22592764deab7d6ed6cfef6aedad3d831dd20093..894ef798775280ab4e4042985b88b4ca2644bbc2 100644 --- a/gdb-6.3-inferior-notification-20050721.patch +++ b/gdb-6.3-inferior-notification-20050721.patch @@ -1,3 +1,22 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jeff Johnston +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-inferior-notification-20050721.patch + +;; Notify observers that the inferior has been created +;;=fedoratest + +2005-07-21 Jeff Johnston + + * gdb.base/attach-32.exp: New test for attaching in 32-bit + mode on 64-bit systems. + * gdb.base/attach-32.c: Ditto. + * gdb.base/attach-32b.c: Ditto. + +2007-12-26 Jan Kratochvil + + * gdb.base/attach-32.exp: Fix forgotten $GDBFLAGS as set. + diff --git a/gdb/testsuite/gdb.base/attach-32.c b/gdb/testsuite/gdb.base/attach-32.c new file mode 100644 --- /dev/null @@ -27,19 +46,19 @@ diff --git a/gdb/testsuite/gdb.base/attach-32.exp b/gdb/testsuite/gdb.base/attac new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/attach-32.exp -@@ -0,0 +1,245 @@ +@@ -0,0 +1,246 @@ +# Copyright 2005 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 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. @@ -53,14 +72,15 @@ new file mode 100644 +# +# Setting the magic bit in the target app should work. I added a +# "kill", and also a test for the R3 register warning. JB -+if { ![istarget "x86_64*-*linux*"] ++if { ![istarget "x86_64*-*linux*"] + && ![istarget "powerpc64*-*linux*"]} { + return 0 +} + +# are we on a target board -+if [is_remote target] then { -+ return 0 ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 +} + +set testfile "attach-32" @@ -102,10 +122,10 @@ new file mode 100644 + global subdir + global timeout + global testpid -+ ++ + # Verify that we can "see" the variable "should_exit" in the + # program, and that it is zero. -+ ++ + gdb_test "print should_exit" " = 0" "after attach-32, print should_exit" + + # Verify that we can modify the variable "should_exit" in the @@ -148,12 +168,12 @@ new file mode 100644 + # the next test run (and prevent the compile by keeping + # the text file busy), in case the "set should_exit" didn't + # work. -+ ++ + remote_exec build "kill -9 ${testpid}" + + # Start the program running and then wait for a bit, to be sure + # that it can be attached to. -+ ++ + set testpid [eval exec $binfile &] + exec sleep 2 + if { [istarget "*-*-cygwin*"] } { @@ -165,7 +185,7 @@ new file mode 100644 + # Verify that we can attach to the process, and find its a.out + # when we're cd'd to some directory that doesn't contain the + # a.out. (We use the source path set by the "dir" command.) -+ ++ + gdb_test "dir ${objdir}/${subdir}" "Source directories searched: .*" \ + "set source path" + @@ -198,7 +218,7 @@ new file mode 100644 + gdb_test "y" "" "$test" + } + } -+ ++ + # Another "don't leave a process around" + remote_exec build "kill -9 ${testpid}" +} @@ -207,9 +227,9 @@ new file mode 100644 + global gdb_prompt + global binfile2 + global testpid -+ ++ + # See if other registers are problems -+ ++ + set test "info other register" + gdb_test_multiple "i r r3" "$test" { + -re "warning: reading register.*$gdb_prompt $" { @@ -221,12 +241,12 @@ new file mode 100644 + } + + # Get rid of the process -+ ++ + gdb_test "p should_exit = 1" + gdb_test "c" {\[Inferior .* exited normally\]} -+ ++ + # Be paranoid -+ ++ + remote_exec build "kill -9 ${testpid}" +} + diff --git a/gdb-6.3-inheritancetest-20050726.patch b/gdb-6.3-inheritancetest-20050726.patch index c3007ea2858c8170e79123cbbee1f66cde525e19..6e12c826cd02e313351a5480314877469a80eadd 100644 --- a/gdb-6.3-inheritancetest-20050726.patch +++ b/gdb-6.3-inheritancetest-20050726.patch @@ -1,8 +1,23 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jeff Johnston +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-inheritancetest-20050726.patch + +;; Verify printing of inherited members test +;;=fedoratest + +2005-07-26 Jeff Johnston + + * gdb.cp/b146835.exp: New testcase. + * gdb.cp/b146835.cc: Ditto. + * gdb.cp/b146835b.cc: Ditto. + * gdb.cp/b146835.h: Ditto. + diff --git a/gdb/testsuite/gdb.cp/b146835.cc b/gdb/testsuite/gdb.cp/b146835.cc new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/b146835.cc -@@ -0,0 +1,32 @@ +@@ -0,0 +1,31 @@ +#include "b146835.h" +#include + @@ -34,7 +49,6 @@ new file mode 100644 + F f; + f.foo(); +} -+ diff --git a/gdb/testsuite/gdb.cp/b146835.exp b/gdb/testsuite/gdb.cp/b146835.exp new file mode 100644 --- /dev/null @@ -56,7 +70,7 @@ new file mode 100644 +# +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Check that GDB can properly print an inherited member variable +# (Bugzilla 146835) diff --git a/gdb-6.3-mapping-zero-inode-test.patch b/gdb-6.3-mapping-zero-inode-test.patch index 92a5c1aadd6ac7c7c1602c213f820eb61f41b604..32b62d52e3a45e81eef6fee7d696a2486fe2e3d8 100644 --- a/gdb-6.3-mapping-zero-inode-test.patch +++ b/gdb-6.3-mapping-zero-inode-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-mapping-zero-inode-test.patch + +;; Test GCORE for shmid 0 shared memory mappings. +;;=fedoratest: But it is broken anyway, sometimes the case being tested is not reproducible. + diff --git a/gdb/testsuite/gdb.base/gcore-shmid0.c b/gdb/testsuite/gdb.base/gcore-shmid0.c new file mode 100644 --- /dev/null @@ -142,15 +150,15 @@ new file mode 100644 +# 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. ++# 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. + diff --git a/gdb-6.3-rh-testversion-20041202.patch b/gdb-6.3-rh-testversion-20041202.patch new file mode 100644 index 0000000000000000000000000000000000000000..7ee68e439780d3a2621d9d195d4d6e0ca83bcdbe --- /dev/null +++ b/gdb-6.3-rh-testversion-20041202.patch @@ -0,0 +1,38 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Elena Zannoni +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-rh-testversion-20041202.patch + +;; Match the Fedora's version info. +;;=fedora + +2003-02-24 Elena Zannoni + + * gdb.gdb/selftest.exp: Add matching on specific Red Hat only version + string. + +diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp +--- a/gdb/testsuite/gdb.gdb/selftest.exp ++++ b/gdb/testsuite/gdb.gdb/selftest.exp +@@ -53,6 +53,9 @@ proc test_with_self { } { + -re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" { + pass "printed version with cast" + } ++ -re ".\[0-9\]+ = .(Fedora|Red Hat Enterprise Linux) \[\\(\\)0-9.a-z\\-\]+.*$gdb_prompt $" { ++ pass "printed version Fedora or Red Hat Enterprise Linux only" ++ } + } + + # start the "xgdb" process +diff --git a/gdb/top.c b/gdb/top.c +--- a/gdb/top.c ++++ b/gdb/top.c +@@ -2195,7 +2195,7 @@ init_gdb_version_vars (void) + struct internalvar *major_version_var = create_internalvar ("_gdb_major"); + struct internalvar *minor_version_var = create_internalvar ("_gdb_minor"); + int vmajor = 0, vminor = 0, vrevision = 0; +- sscanf (version, "%d.%d.%d", &vmajor, &vminor, &vrevision); ++ sscanf (version, "Fedora %d.%d.%d", &vmajor, &vminor, &vrevision); + set_internalvar_integer (major_version_var, vmajor); + set_internalvar_integer (minor_version_var, vminor + (vrevision > 0)); + } diff --git a/gdb-6.3-test-dtorfix-20050121.patch b/gdb-6.3-test-dtorfix-20050121.patch index ad8676a11b6ae771b1109931431a13b4f9818e64..01c0d560a6fa65aa22b25b258a8e05bf5d551558 100644 --- a/gdb-6.3-test-dtorfix-20050121.patch +++ b/gdb-6.3-test-dtorfix-20050121.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-test-dtorfix-20050121.patch + +;; Test support of multiple destructors just like multiple constructors +;;=fedoratest + diff --git a/gdb/testsuite/gdb.cp/constructortest.cc b/gdb/testsuite/gdb.cp/constructortest.cc new file mode 100644 --- /dev/null @@ -123,7 +131,7 @@ new file mode 100644 +# +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Check that GDB can break at multiple forms of constructors. + @@ -152,7 +160,7 @@ new file mode 100644 +# Break on the various forms of the A::A constructor. +# " (2 locations)" is displayed depending on G++ version. +gdb_test "break A\:\:A" "Breakpoint 2 at .*" "breaking on A::A" -+ ++ +# Verify that we break for the A constructor two times +# Once for new A and once for new B +gdb_continue_to_breakpoint "First line A" diff --git a/gdb-6.3-test-movedir-20050125.patch b/gdb-6.3-test-movedir-20050125.patch index 828cc24292d52d6099adb0298e715f2ff2be94ec..31fbc60486e85e301e361d7c846df2ddc938903d 100644 --- a/gdb-6.3-test-movedir-20050125.patch +++ b/gdb-6.3-test-movedir-20050125.patch @@ -1,8 +1,22 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Elena Zannoni +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-test-movedir-20050125.patch + +;; Fix to support executable moving +;;=fedoratest + +2005-01-25 Elena Zannoni + + * gdb.base/move-dir.exp: New test. + * gdb.base/move-dir.c: Ditto. + * gdb.base/move-dir.h: Ditto. + diff --git a/gdb/testsuite/gdb.base/move-dir.c b/gdb/testsuite/gdb.base/move-dir.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/move-dir.c -@@ -0,0 +1,10 @@ +@@ -0,0 +1,9 @@ +#include +#include +#include "move-dir.h" @@ -12,7 +26,6 @@ new file mode 100644 + printf ("%s\n", hw);; + other(); +} -+ diff --git a/gdb/testsuite/gdb.base/move-dir.exp b/gdb/testsuite/gdb.base/move-dir.exp new file mode 100644 --- /dev/null @@ -25,15 +38,15 @@ new file mode 100644 +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +set testfile "move-dir" +set srcfile ${testfile}.c @@ -79,11 +92,10 @@ diff --git a/gdb/testsuite/gdb.base/move-dir.h b/gdb/testsuite/gdb.base/move-dir new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/move-dir.h -@@ -0,0 +1,7 @@ +@@ -0,0 +1,6 @@ +#include + +void other() { + const char* ostring = "other"; + printf ("%s\n", ostring);; +} -+ diff --git a/gdb-6.3-test-pie-20050107.patch b/gdb-6.3-test-pie-20050107.patch deleted file mode 100644 index 6d24c5249145371df3e6b3dbb6945eba4bd5d1f6..0000000000000000000000000000000000000000 --- a/gdb-6.3-test-pie-20050107.patch +++ /dev/null @@ -1,2019 +0,0 @@ -diff --git a/gdb/testsuite/gdb.pie/attach.c b/gdb/testsuite/gdb.pie/attach.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pie/attach.c -@@ -0,0 +1,20 @@ -+/* This program is intended to be started outside of gdb, and then -+ attached to by gdb. Thus, it simply spins in a loop. The loop -+ is exited when & if the variable 'should_exit' is non-zero. (It -+ is initialized to zero in this program, so the loop will never -+ exit unless/until gdb sets the variable to non-zero.) -+ */ -+#include -+ -+int should_exit = 0; -+ -+int main () -+{ -+ int local_i = 0; -+ -+ while (! should_exit) -+ { -+ local_i++; -+ } -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.pie/attach.exp b/gdb/testsuite/gdb.pie/attach.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pie/attach.exp -@@ -0,0 +1,416 @@ -+# Copyright 1997, 1999, 2002 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 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. */ -+ -+# On HP-UX 11.0, this test is causing a process running the program -+# "attach" to be left around spinning. Until we figure out why, I am -+# commenting out the test to avoid polluting tiamat (our 11.0 nightly -+# test machine) with these processes. RT -+# -+# Setting the magic bit in the target app should work. I added a -+# "kill", and also a test for the R3 register warning. JB -+if { [istarget "hppa*-*-hpux*"] } { -+ return 0 -+} -+ -+# are we on a target board -+if [is_remote target] then { -+ return 0 -+} -+ -+set testfile "attach" -+set srcfile ${testfile}.c -+set srcfile2 ${testfile}2.c -+set binfile [standard_output_file ${testfile}] -+set binfile2 [standard_output_file ${testfile}2] -+set escapedbinfile [string_to_regexp [standard_output_file ${testfile}]] -+set cleanupfile [standard_output_file ${testfile}.awk] -+ -+#execute_anywhere "rm -f ${binfile} ${binfile2}" -+remote_exec build "rm -f ${binfile} ${binfile2}" -+# For debugging this test -+# -+#log_user 1 -+ -+# Clean out any old files from past runs. -+# -+remote_exec build "${cleanupfile}" -+ -+# build the first test case -+# -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags= -fpie -pie"}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+# Build the in-system-call test -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug "additional_flags= -fpie -pie"}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+if [get_compiler_info ${binfile}] { -+ return -1 -+} -+ -+proc do_attach_tests {} { -+ global gdb_prompt -+ global binfile -+ global escapedbinfile -+ global srcfile -+ global testfile -+ global subdir -+ global timeout -+ -+ # Start the program running and then wait for a bit, to be sure -+ # that it can be attached to. -+ # -+ set testpid [eval exec $binfile &] -+ exec sleep 2 -+ -+ # Verify that we cannot attach to nonsense. -+ # -+ send_gdb "attach abc\n" -+ gdb_expect { -+ -re ".*Illegal process-id: abc.*$gdb_prompt $"\ -+ {pass "attach to nonsense is prohibited"} -+ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\ -+ { -+ # Response expected from /proc-based systems. -+ pass "attach to nonsense is prohibited" -+ } -+ -re "Attaching to.*$gdb_prompt $"\ -+ {fail "attach to nonsense is prohibited (bogus pid allowed)"} -+ -re "$gdb_prompt $" {fail "attach to nonsense is prohibited"} -+ timeout {fail "(timeout) attach to nonsense is prohibited"} -+ } -+ -+ # Verify that we cannot attach to what appears to be a valid -+ # process ID, but is a process that doesn't exist. Traditionally, -+ # most systems didn't have a process with ID 0, so we take that as -+ # the default. However, there are a few exceptions. -+ # -+ set boguspid 0 -+ if { [istarget "*-*-*bsd*"] } { -+ # In FreeBSD 5.0, PID 0 is used for "swapper". Use -1 instead -+ # (which should have the desired effect on any version of -+ # FreeBSD, and probably other *BSD's too). -+ set boguspid -1 -+ } -+ send_gdb "attach $boguspid\n" -+ gdb_expect { -+ -re "Attaching to.*, process $boguspid.*No such process.*$gdb_prompt $"\ -+ { -+ # Response expected on ptrace-based systems (i.e. HP-UX 10.20). -+ pass "attach to nonexistent process is prohibited" -+ } -+ -re "Attaching to.*, process $boguspid failed.*Hint.*$gdb_prompt $"\ -+ { -+ # Response expected on ttrace-based systems (i.e. HP-UX 11.0). -+ pass "attach to nonexistent process is prohibited" -+ } -+ -re "Attaching to.*, process $boguspid.*denied.*$gdb_prompt $"\ -+ {pass "attach to nonexistent process is prohibited"} -+ -re "Attaching to.*, process $boguspid.*not permitted.*$gdb_prompt $"\ -+ {pass "attach to nonexistent process is prohibited"} -+ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\ -+ { -+ # Response expected from /proc-based systems. -+ pass "attach to nonexistent process is prohibited" -+ } -+ -re "$gdb_prompt $" {fail "attach to nonexistent process is prohibited"} -+ timeout { -+ fail "(timeout) attach to nonexistent process is prohibited" -+ } -+ } -+ -+ # Verify that we can attach to the process by first giving its -+ # executable name via the file command, and using attach with -+ # the process ID. -+ # -+ # (Actually, the test system appears to do this automatically -+ # for us. So, we must also be prepared to be asked if we want -+ # to discard an existing set of symbols.) -+ # -+ send_gdb "file $binfile\n" -+ gdb_expect { -+ -re "Load new symbol table from.*y or n.*$" { -+ send_gdb "y\n" -+ gdb_expect { -+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\ -+ {pass "(re)set file, before attach1"} -+ -re "$gdb_prompt $" {fail "(re)set file, before attach1"} -+ timeout {fail "(timeout) (re)set file, before attach1"} -+ } -+ } -+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\ -+ {pass "set file, before attach1"} -+ -re "$gdb_prompt $" {fail "set file, before attach1"} -+ timeout {fail "(timeout) set file, before attach1"} -+ } -+ -+ send_gdb "attach $testpid\n" -+ gdb_expect { -+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\ -+ {pass "attach1, after setting file"} -+ -re "$gdb_prompt $" {fail "attach1, after setting file"} -+ timeout {fail "(timeout) attach1, after setting file"} -+ } -+ -+ # Verify that we can "see" the variable "should_exit" in the -+ # program, and that it is zero. -+ # -+ send_gdb "print should_exit\n" -+ gdb_expect { -+ -re ".* = 0.*$gdb_prompt $"\ -+ {pass "after attach1, print should_exit"} -+ -re "$gdb_prompt $" {fail "after attach1, print should_exit"} -+ timeout {fail "(timeout) after attach1, print should_exit"} -+ } -+ -+ # Detach the process. -+ # -+ send_gdb "detach\n" -+ gdb_expect { -+ -re "Detaching from program: .*$escapedbinfile.*$gdb_prompt $"\ -+ {pass "attach1 detach"} -+ -re "$gdb_prompt $" {fail "attach1 detach"} -+ timeout {fail "(timeout) attach1 detach"} -+ } -+ -+ # Wait a bit for gdb to finish detaching -+ # -+ exec sleep 5 -+ -+ # Purge the symbols from gdb's brain. (We want to be certain -+ # the next attach, which won't be preceded by a "file" command, -+ # is really getting the executable file without our help.) -+ # -+ set old_timeout $timeout -+ set timeout 15 -+ send_gdb "file\n" -+ gdb_expect { -+ -re ".*gdb internal error.*$" { -+ fail "Internal error, prob. Memory corruption" -+ } -+ -re "No executable file now.*Discard symbol table.*y or n.*$" { -+ send_gdb "y\n" -+ gdb_expect { -+ -re "No symbol file now.*$gdb_prompt $"\ -+ {pass "attach1, purging symbols after detach"} -+ -re "$gdb_prompt $" {fail "attach1, purging symbols after detach"} -+ timeout {fail "(timeout) attach1, purging symbols after detach"} -+ } -+ } -+ -re "$gdb_prompt $" {fail "attach1, purging file after detach"} -+ timeout { -+ fail "(timeout) attach1, purging file after detach" -+ } -+ } -+ set timeout $old_timeout -+ -+ # Verify that we can attach to the process just by giving the -+ # process ID. -+ # -+ send_gdb "attach $testpid\n" -+ gdb_expect { -+ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\ -+ {pass "attach2"} -+ -re "$gdb_prompt $" {fail "attach2"} -+ timeout {fail "(timeout) attach2"} -+ } -+ -+ # Verify that we can modify the variable "should_exit" in the -+ # program. -+ # -+ send_gdb "set should_exit=1\n" -+ gdb_expect { -+ -re "$gdb_prompt $" {pass "after attach2, set should_exit"} -+ timeout {fail "(timeout) after attach2, set should_exit"} -+ } -+ -+ # Verify that the modification really happened. -+ # -+ send_gdb "tbreak 19\n" -+ gdb_expect { -+ -re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $"\ -+ {pass "after attach2, set tbreak postloop"} -+ -re "$gdb_prompt $" {fail "after attach2, set tbreak postloop"} -+ timeout {fail "(timeout) after attach2, set tbreak postloop"} -+ } -+ send_gdb "continue\n" -+ gdb_expect { -+ -re "main.*at.*$srcfile:19.*$gdb_prompt $"\ -+ {pass "after attach2, reach tbreak postloop"} -+ -re "$gdb_prompt $" {fail "after attach2, reach tbreak postloop"} -+ timeout {fail "(timeout) after attach2, reach tbreak postloop"} -+ } -+ -+ # Allow the test process to exit, to cleanup after ourselves. -+ # -+ gdb_test "continue" {\[Inferior .* exited normally\]} "after attach2, exit" -+ -+ # Make sure we don't leave a process around to confuse -+ # the next test run (and prevent the compile by keeping -+ # the text file busy), in case the "set should_exit" didn't -+ # work. -+ # -+ remote_exec build "kill -9 ${testpid}" -+ # Start the program running and then wait for a bit, to be sure -+ # that it can be attached to. -+ # -+ set testpid [eval exec $binfile &] -+ exec sleep 2 -+ -+ # Verify that we can attach to the process, and find its a.out -+ # when we're cd'd to some directory that doesn't contain the -+ # a.out. (We use the source path set by the "dir" command.) -+ # -+ send_gdb "dir [file dirname [standard_output_file ${testfile}]]\n" -+ gdb_expect { -+ -re ".*Source directories searched: .*$gdb_prompt $"\ -+ {pass "set source path"} -+ -re "$gdb_prompt $" {fail "set source path"} -+ timeout {fail "(timeout) set source path"} -+ } -+ -+ send_gdb "cd /tmp\n" -+ gdb_expect { -+ -re ".*Working directory /tmp.*$gdb_prompt $"\ -+ {pass "cd away from process' a.out"} -+ -re "$gdb_prompt $" {fail "cd away from process' a.out"} -+ timeout {fail "(timeout) cd away from process' a.out"} -+ } -+ -+ # Explicitly flush out any knowledge of the previous attachment. -+ send_gdb "symbol\n" -+ gdb_expect { -+ -re ".*Discard symbol table from.*y or n. $"\ -+ {send_gdb "y\n" -+ gdb_expect { -+ -re ".*No symbol file now.*$gdb_prompt $"\ -+ {pass "before attach3, flush symbols"} -+ -re "$gdb_prompt $" {fail "before attach3, flush symbols"} -+ timeout {fail "(timeout) before attach3, flush symbols"} -+ } -+ } -+ -re ".*No symbol file now.*$gdb_prompt $"\ -+ {pass "before attach3, flush symbols"} -+ -re "$gdb_prompt $" {fail "before attach3, flush symbols"} -+ timeout {fail "(timeout) before attach3, flush symbols"} -+ } -+ send_gdb "exec\n" -+ gdb_expect { -+ -re ".*No executable file now.*$gdb_prompt $"\ -+ {pass "before attach3, flush exec"} -+ -re "$gdb_prompt $" {fail "before attach3, flush exec"} -+ timeout {fail "(timeout) before attach3, flush exec"} -+ } -+ -+ send_gdb "attach $testpid\n" -+ gdb_expect { -+ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\ -+ {pass "attach when process' a.out not in cwd"} -+ -re "$gdb_prompt $" {fail "attach when process' a.out not in cwd"} -+ timeout {fail "(timeout) attach when process' a.out not in cwd"} -+ } -+ -+ send_gdb "kill\n" -+ gdb_expect { -+ -re ".*Kill the program being debugged.*y or n. $"\ -+ {send_gdb "y\n" -+ gdb_expect { -+ -re "$gdb_prompt $" {pass "after attach3, exit"} -+ timeout {fail "(timeout) after attach3, exit"} -+ } -+ } -+ -re "$gdb_prompt $" {fail "after attach3, exit"} -+ timeout {fail "(timeout) after attach3, exit"} -+ } -+ -+ # Another "don't leave a process around" -+ remote_exec build "kill -9 ${testpid}" -+} -+ -+proc do_call_attach_tests {} { -+ global gdb_prompt -+ global binfile2 -+ -+ # Start the program running and then wait for a bit, to be sure -+ # that it can be attached to. -+ # -+ set testpid [eval exec $binfile2 &] -+ exec sleep 2 -+ -+ # Attach -+ # -+ gdb_test "file $binfile2" ".*" "force switch to gdb64, if necessary" -+ send_gdb "attach $testpid\n" -+ gdb_expect { -+ -re ".*warning: reading register.*I.*O error.*$gdb_prompt $" { -+ fail "attach call, read register 3 error" -+ } -+ -re "Attaching to.*process $testpid.*$gdb_prompt $" { -+ # libc is relocated, not relocated, therefore not printed. -+ pass "attach call" -+ } -+ -re "$gdb_prompt $" {fail "attach call"} -+ timeout {fail "(timeout) attach call"} -+ } -+ -+ # See if other registers are problems -+ # -+ send_gdb "i r r3\n" -+ gdb_expect { -+ -re ".*warning: reading register.*$gdb_prompt $" { -+ pass "CHFts23490: known bug" -+ } -+ -re ".*r3.*$gdb_prompt $" { -+ pass "Bug fixed, Yayyy!" -+ } -+ timeout { fail "timeout on info reg" } -+ } -+ -+ # Get rid of the process -+ # -+ gdb_test "p should_exit = 1" ".*" -+ gdb_test "c" {\[Inferior .* exited normally\]} -+ -+ # Be paranoid -+ # -+ remote_exec build "kill -9 ${testpid}" -+ -+} -+ -+ -+# Start with a fresh gdb -+# -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+# This is a test of gdb's ability to attach to a running process. -+# -+do_attach_tests -+ -+# Test attaching when the target is inside a system call -+# -+gdb_exit -+gdb_start -+ -+gdb_reinitialize_dir $srcdir/$subdir -+do_call_attach_tests -+ -+return 0 -diff --git a/gdb/testsuite/gdb.pie/attach2.c b/gdb/testsuite/gdb.pie/attach2.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pie/attach2.c -@@ -0,0 +1,24 @@ -+/* This program is intended to be started outside of gdb, and then -+ attached to by gdb. Thus, it simply spins in a loop. The loop -+ is exited when & if the variable 'should_exit' is non-zero. (It -+ is initialized to zero in this program, so the loop will never -+ exit unless/until gdb sets the variable to non-zero.) -+ */ -+#include -+#include -+#include -+ -+int should_exit = 0; -+ -+int main () -+{ -+ int local_i = 0; -+ -+ sleep( 10 ); /* System call causes register fetch to fail */ -+ /* This is a known HPUX "feature" */ -+ while (! should_exit) -+ { -+ local_i++; -+ } -+ return (0); -+} -diff --git a/gdb/testsuite/gdb.pie/break.c b/gdb/testsuite/gdb.pie/break.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pie/break.c -@@ -0,0 +1,146 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 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 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. -+ -+ Please email any bugs, comments, and/or additions to this file to: -+ bug-gdb@prep.ai.mit.edu */ -+ -+#ifdef vxworks -+ -+# include -+ -+/* VxWorks does not supply atoi. */ -+static int -+atoi (z) -+ char *z; -+{ -+ int i = 0; -+ -+ while (*z >= '0' && *z <= '9') -+ i = i * 10 + (*z++ - '0'); -+ return i; -+} -+ -+/* I don't know of any way to pass an array to VxWorks. This function -+ can be called directly from gdb. */ -+ -+vxmain (arg) -+char *arg; -+{ -+ char *argv[2]; -+ -+ argv[0] = ""; -+ argv[1] = arg; -+ main (2, argv, (char **) 0); -+} -+ -+#else /* ! vxworks */ -+# include -+# include -+#endif /* ! vxworks */ -+ -+#ifdef PROTOTYPES -+extern int marker1 (void); -+extern int marker2 (int a); -+extern void marker3 (char *a, char *b); -+extern void marker4 (long d); -+#else -+extern int marker1 (); -+extern int marker2 (); -+extern void marker3 (); -+extern void marker4 (); -+#endif -+ -+/* -+ * This simple classical example of recursion is useful for -+ * testing stack backtraces and such. -+ */ -+ -+#ifdef PROTOTYPES -+int factorial(int); -+ -+int -+main (int argc, char **argv, char **envp) -+#else -+int -+main (argc, argv, envp) -+int argc; -+char *argv[], **envp; -+#endif -+{ -+#ifdef usestubs -+ set_debug_traps(); /* set breakpoint 5 here */ -+ breakpoint(); -+#endif -+ if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */ -+ fprintf (stderr, "usage: factorial \n"); -+ return 1; -+ } -+ printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */ -+ /* set breakpoint 12 here */ -+ marker1 (); /* set breakpoint 11 here */ -+ marker2 (43); /* set breakpoint 20 here */ -+ marker3 ("stack", "trace"); /* set breakpoint 21 here */ -+ marker4 (177601976L); -+ argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */ -+ return argc; /* set breakpoint 10 here */ -+} -+ -+#ifdef PROTOTYPES -+int factorial (int value) -+#else -+int factorial (value) -+int value; -+#endif -+{ -+ if (value > 1) { /* set breakpoint 7 here */ -+ value *= factorial (value - 1); -+ } -+ return (value); /* set breakpoint 19 here */ -+} -+ -+#ifdef PROTOTYPES -+int multi_line_if_conditional (int a, int b, int c) -+#else -+int multi_line_if_conditional (a, b, c) -+ int a, b, c; -+#endif -+{ -+ if (a /* set breakpoint 3 here */ -+ && b -+ && c) -+ return 0; -+ else -+ return 1; -+} -+ -+#ifdef PROTOTYPES -+int multi_line_while_conditional (int a, int b, int c) -+#else -+int multi_line_while_conditional (a, b, c) -+ int a, b, c; -+#endif -+{ -+ while (a /* set breakpoint 4 here */ -+ && b -+ && c) -+ { -+ a--, b--, c--; -+ } -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.pie/break.exp b/gdb/testsuite/gdb.pie/break.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pie/break.exp -@@ -0,0 +1,954 @@ -+# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, -+# 2000, 2002, 2003, 2004 -+# 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 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. -+ -+# Please email any bugs, comments, and/or additions to this file to: -+# bug-gdb@prep.ai.mit.edu -+ -+# This file was written by Rob Savoye. (rob@cygnus.com) -+ -+# Test the same stuff but with PIE executables -+ -+set testfile "break" -+set srcfile ${testfile}.c -+set srcfile1 ${testfile}1.c -+set binfile [standard_output_file ${testfile}] -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+if [get_compiler_info ${binfile}] { -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if [target_info exists gdb_stub] { -+ gdb_step_for_stub; -+} -+# -+# test simple breakpoint setting commands -+# -+ -+# Test deleting all breakpoints when there are none installed, -+# GDB should not prompt for confirmation. -+# Note that gdb-init.exp provides a "delete_breakpoints" proc -+# for general use elsewhere. -+ -+send_gdb "delete breakpoints\n" -+gdb_expect { -+ -re "Delete all breakpoints.*$" { -+ send_gdb "y\n" -+ gdb_expect { -+ -re "$gdb_prompt $" { -+ fail "Delete all breakpoints when none (unexpected prompt)" -+ } -+ timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" } -+ } -+ } -+ -re ".*$gdb_prompt $" { pass "Delete all breakpoints when none" } -+ timeout { fail "Delete all breakpoints when none (timeout)" } -+} -+ -+# -+# test break at function -+# -+gdb_test "break main" \ -+ "Breakpoint.*at.* file .*$srcfile, line.*" \ -+ "breakpoint function" -+ -+# -+# test break at quoted function -+# -+gdb_test "break \"marker2\"" \ -+ "Breakpoint.*at.* file .*$srcfile1, line.*" \ -+ "breakpoint quoted function" -+ -+# -+# test break at function in file -+# -+gdb_test "break $srcfile:factorial" \ -+ "Breakpoint.*at.* file .*$srcfile, line.*" \ -+ "breakpoint function in file" -+ -+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] -+ -+# -+# test break at line number -+# -+# Note that the default source file is the last one whose source text -+# was printed. For native debugging, before we've executed the -+# program, this is the file containing main, but for remote debugging, -+# it's wherever the processor was stopped when we connected to the -+# board. So, to be sure, we do a list command. -+# -+gdb_test "list main" \ -+ ".*main \\(argc, argv, envp\\).*" \ -+ "use `list' to establish default source file" -+gdb_test "break $bp_location1" \ -+ "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \ -+ "breakpoint line number" -+ -+# -+# test duplicate breakpoint -+# -+gdb_test "break $bp_location1" \ -+ "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \ -+ "breakpoint duplicate" -+ -+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] -+ -+# -+# test break at line number in file -+# -+gdb_test "break $srcfile:$bp_location2" \ -+ "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \ -+ "breakpoint line number in file" -+ -+set bp_location3 [gdb_get_line_number "set breakpoint 3 here"] -+set bp_location4 [gdb_get_line_number "set breakpoint 4 here"] -+ -+# -+# Test putting a break at the start of a multi-line if conditional. -+# Verify the breakpoint was put at the start of the conditional. -+# -+gdb_test "break multi_line_if_conditional" \ -+ "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \ -+ "breakpoint at start of multi line if conditional" -+ -+gdb_test "break multi_line_while_conditional" \ -+ "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \ -+ "breakpoint at start of multi line while conditional" -+ -+set bp_location5 [gdb_get_line_number "set breakpoint 5 here"] -+set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] -+ -+# -+# check to see what breakpoints are set -+# -+if [target_info exists gdb_stub] { -+ set main_line $bp_location5 -+} else { -+ set main_line $bp_location6 -+} -+ -+set proto "" -+ -+set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] -+set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] -+set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] -+ -+# Test a pending breakpoint in PIE executable does not crash later GDB. -+gdb_breakpoint "non_existent_function" allow-pending -+ -+gdb_test "info break" \ -+ "Num\[ \]+Type\[ \]+Disp Enb Address\[ \]+What.* -+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.* -+\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:($bp_location8|$bp_location9).* -+\[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:$bp_location7.* -+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* -+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* -+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.* -+\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.* -+\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4.* -+\[0-9\]+\[\t \]+breakpoint keep y.* *non_existent_function" \ -+ "breakpoint info" -+ -+# FIXME: The rest of this test doesn't work with anything that can't -+# handle arguments. -+# Huh? There doesn't *appear* to be anything that passes arguments -+# below. -+if [istarget "mips-idt-*"] then { -+ return -+} -+ -+# -+# run until the breakpoint at main is hit. For non-stubs-using targets. -+# -+if ![target_info exists use_gdb_stub] { -+ if [istarget "*-*-vxworks*"] then { -+ send_gdb "run vxmain \"2\"\n" -+ set timeout 120 -+ verbose "Timeout is now $timeout seconds" 2 -+ } else { -+ send_gdb "run\n" -+ } -+ gdb_expect { -+ -re "The program .* has been started already.*y or n. $" { -+ send_gdb "y\n" -+ exp_continue -+ } -+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\ -+ { pass "run until function breakpoint" } -+ -re ".*$gdb_prompt $" { fail "run until function breakpoint" } -+ timeout { fail "run until function breakpoint (timeout)" } -+ } -+} else { -+ if ![target_info exists gdb_stub] { -+ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue" -+ } -+} -+ -+# -+# run until the breakpoint at a line number -+# -+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \ -+ "run until breakpoint set at a line number" -+ -+# -+# Run until the breakpoint set in a function in a file -+# -+for {set i 6} {$i >= 1} {incr i -1} { -+ gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \ -+ "run until file:function($i) breakpoint" -+} -+ -+# -+# Run until the breakpoint set at a quoted function -+# -+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \ -+ "run until quoted breakpoint" -+# -+# run until the file:function breakpoint at a line number in a file -+# -+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \ -+ "run until file:linenum breakpoint" -+ -+# Test break at offset +1 -+set bp_location10 [gdb_get_line_number "set breakpoint 10 here"] -+ -+gdb_test "break +1" \ -+ "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \ -+ "breakpoint offset +1" -+ -+# Check to see if breakpoint is hit when stepped onto -+ -+gdb_test "step" \ -+ ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \ -+ "step onto breakpoint" -+ -+# -+# delete all breakpoints so we can start over, course this can be a test too -+# -+delete_breakpoints -+ -+# -+# test temporary breakpoint at function -+# -+ -+gdb_test "tbreak main" "reakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function" -+ -+# -+# test break at function in file -+# -+ -+gdb_test "tbreak $srcfile:factorial" "reakpoint.*at.* file .*$srcfile, line.*" \ -+ "Temporary breakpoint function in file" -+ -+# -+# test break at line number -+# -+send_gdb "tbreak $bp_location1\n" -+gdb_expect { -+ -re "reakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } -+ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } -+ timeout { fail "breakpoint line number #1 (timeout)" } -+} -+ -+gdb_test "tbreak $bp_location6" "reakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2" -+ -+# -+# test break at line number in file -+# -+send_gdb "tbreak $srcfile:$bp_location2\n" -+gdb_expect { -+ -re "reakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } -+ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } -+ timeout { fail "Temporary breakpoint line number in file #1 (timeout)" } -+} -+ -+set bp_location11 [gdb_get_line_number "set breakpoint 11 here"] -+gdb_test "tbreak $srcfile:$bp_location11" "reakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2" -+ -+# -+# check to see what breakpoints are set (temporary this time) -+# -+gdb_test "info break" "Num.*Type.*Disp Enb Address.*What.*\[\r\n\] -+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\] -+\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:$bp_location7.*\[\r\n\] -+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\] -+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\] -+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\] -+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \ -+ "Temporary breakpoint info" -+ -+ -+#*********** -+ -+# Verify that catchpoints for fork, vfork and exec don't trigger -+# inappropriately. (There are no calls to those system functions -+# in this test program.) -+# -+if ![runto_main] then { fail "break tests suppressed" } -+ -+send_gdb "catch\n" -+gdb_expect { -+ -re "Catch requires an event name.*$gdb_prompt $"\ -+ {pass "catch requires an event name"} -+ -re "$gdb_prompt $"\ -+ {fail "catch requires an event name"} -+ timeout {fail "(timeout) catch requires an event name"} -+} -+ -+ -+set name "set catch fork, never expected to trigger" -+send_gdb "catch fork\n" -+gdb_expect { -+ -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $" -+ {pass $name} -+ -re "Catch of fork not yet implemented.*$gdb_prompt $" -+ {pass $name} -+ -re "$gdb_prompt $" -+ {fail $name} -+ timeout {fail "(timeout) $name"} -+} -+ -+ -+set name "set catch vfork, never expected to trigger" -+send_gdb "catch vfork\n" -+ -+# If we are on HP-UX 10.20, we expect an error message to be -+# printed if we type "catch vfork" at the gdb gdb_prompt. This is -+# because on HP-UX 10.20, we cannot catch vfork events. -+ -+if [istarget "hppa*-hp-hpux10.20"] then { -+ gdb_expect { -+ -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $" -+ {pass $name} -+ -re "$gdb_prompt $" -+ {fail $name} -+ timeout {fail "(timeout) $name"} -+ } -+} else { -+ gdb_expect { -+ -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $" -+ {pass $name} -+ -re "Catch of vfork not yet implemented.*$gdb_prompt $" -+ {pass $name} -+ -re "$gdb_prompt $" -+ {fail $name} -+ timeout {fail "(timeout) $name"} -+ } -+} -+ -+set name "set catch exec, never expected to trigger" -+send_gdb "catch exec\n" -+gdb_expect { -+ -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $" -+ {pass $name} -+ -re "Catch of exec not yet implemented.*$gdb_prompt $" -+ {pass $name} -+ -re "$gdb_prompt $" {fail $name} -+ timeout {fail "(timeout) $name"} -+} -+ -+# Verify that GDB responds gracefully when asked to set a breakpoint -+# on a nonexistent source line. -+# -+gdb_test_no_output "set breakpoint pending off" -+gdb_test "break 999" \ -+ "No line 999 in the current file." \ -+ "break on non-existent source line" -+ -+# Run to the desired default location. If not positioned here, the -+# tests below don't work. -+# -+gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1" -+ -+ -+# Verify that GDB allows one to just say "break", which is treated -+# as the "default" breakpoint. Note that GDB gets cute when printing -+# the informational message about other breakpoints at the same -+# location. We'll hit that bird with this stone too. -+# -+send_gdb "break\n" -+gdb_expect { -+ -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\ -+ {pass "break on default location, 1st time"} -+ -re "$gdb_prompt $"\ -+ {fail "break on default location, 1st time"} -+ timeout {fail "(timeout) break on default location, 1st time"} -+} -+ -+send_gdb "break\n" -+gdb_expect { -+ -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ -+ {pass "break on default location, 2nd time"} -+ -re "$gdb_prompt $"\ -+ {fail "break on default location, 2nd time"} -+ timeout {fail "(timeout) break on default location, 2nd time"} -+} -+ -+send_gdb "break\n" -+gdb_expect { -+ -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ -+ {pass "break on default location, 3rd time"} -+ -re "$gdb_prompt $"\ -+ {fail "break on default location, 3rd time"} -+ timeout {fail "(timeout) break on default location, 3rd time"} -+} -+ -+send_gdb "break\n" -+gdb_expect { -+ -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ -+ {pass "break on default location, 4th time"} -+ -re "$gdb_prompt $"\ -+ {fail "break on default location, 4th time"} -+ timeout {fail "(timeout) break on default location, 4th time"} -+} -+ -+# Verify that a "silent" breakpoint can be set, and that GDB is indeed -+# "silent" about its triggering. -+# -+if ![runto_main] then { fail "break tests suppressed" } -+ -+send_gdb "break $bp_location1\n" -+gdb_expect { -+ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\ -+ {pass "set to-be-silent break bp_location1"} -+ -re "$gdb_prompt $"\ -+ {fail "set to-be-silent break bp_location1"} -+ timeout {fail "(timeout) set to-be-silent break bp_location1"} -+} -+ -+send_gdb "commands $expect_out(1,string)\n" -+send_gdb "silent\n" -+send_gdb "end\n" -+gdb_expect { -+ -re ".*$gdb_prompt $"\ -+ {pass "set silent break bp_location1"} -+ timeout {fail "(timeout) set silent break bp_location1"} -+} -+ -+send_gdb "info break $expect_out(1,string)\n" -+gdb_expect { -+ -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\ -+ {pass "info silent break bp_location1"} -+ -re "$gdb_prompt $"\ -+ {fail "info silent break bp_location1"} -+ timeout {fail "(timeout) info silent break bp_location1"} -+} -+send_gdb "continue\n" -+gdb_expect { -+ -re "Continuing.\r\n$gdb_prompt $"\ -+ {pass "hit silent break bp_location1"} -+ -re "$gdb_prompt $"\ -+ {fail "hit silent break bp_location1"} -+ timeout {fail "(timeout) hit silent break bp_location1"} -+} -+send_gdb "bt\n" -+gdb_expect { -+ -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\ -+ {pass "stopped for silent break bp_location1"} -+ -re "$gdb_prompt $"\ -+ {fail "stopped for silent break bp_location1"} -+ timeout {fail "(timeout) stopped for silent break bp_location1"} -+} -+ -+# Verify that GDB can at least parse a breakpoint with the -+# "thread" keyword. (We won't attempt to test here that a -+# thread-specific breakpoint really triggers appropriately. -+# The gdb.threads subdirectory contains tests for that.) -+# -+set bp_location12 [gdb_get_line_number "set breakpoint 12 here"] -+send_gdb "break $bp_location12 thread 999\n" -+gdb_expect { -+ -re "Unknown thread 999.*$gdb_prompt $"\ -+ {pass "thread-specific breakpoint on non-existent thread disallowed"} -+ -re "$gdb_prompt $"\ -+ {fail "thread-specific breakpoint on non-existent thread disallowed"} -+ timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"} -+} -+ -+gdb_test "break $bp_location12 thread foo" \ -+ "Invalid thread ID: foo" \ -+ "thread-specific breakpoint on bogus thread ID disallowed" -+ -+# Verify that GDB responds gracefully to a breakpoint command with -+# trailing garbage. -+# -+send_gdb "break $bp_location12 foo\n" -+gdb_expect { -+ -re "malformed linespec error: unexpected string, \"foo\"\r\n$gdb_prompt $"\ -+ {pass "breakpoint with trailing garbage disallowed"} -+ -re "$gdb_prompt $"\ -+ {fail "breakpoint with trailing garbage disallowed"} -+ timeout {fail "(timeout) breakpoint with trailing garbage disallowed"} -+} -+ -+# Verify that GDB responds gracefully to a "clear" command that has -+# no matching breakpoint. (First, get us off the current source line, -+# which we know has a breakpoint.) -+# -+send_gdb "next\n" -+gdb_expect { -+ -re ".*$gdb_prompt $"\ -+ {pass "step over breakpoint"} -+ timeout {fail "(timeout) step over breakpoint"} -+} -+send_gdb "clear 81\n" -+gdb_expect { -+ -re "No breakpoint at 81..*$gdb_prompt $"\ -+ {pass "clear line has no breakpoint disallowed"} -+ -re "$gdb_prompt $"\ -+ {fail "clear line has no breakpoint disallowed"} -+ timeout {fail "(timeout) clear line has no breakpoint disallowed"} -+} -+send_gdb "clear\n" -+gdb_expect { -+ -re "No breakpoint at this line..*$gdb_prompt $"\ -+ {pass "clear current line has no breakpoint disallowed"} -+ -re "$gdb_prompt $"\ -+ {fail "clear current line has no breakpoint disallowed"} -+ timeout {fail "(timeout) clear current line has no breakpoint disallowed"} -+} -+ -+# Verify that we can set and clear multiple breakpoints. -+# -+# We don't test that it deletes the correct breakpoints. We do at -+# least test that it deletes more than one breakpoint. -+# -+gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1" -+gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2" -+gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*} -+ -+# Verify that a breakpoint can be set via a convenience variable. -+# -+send_gdb "set \$foo=$bp_location11\n" -+gdb_expect { -+ -re "$gdb_prompt $"\ -+ {pass "set convenience variable \$foo to bp_location11"} -+ timeout {fail "(timeout) set convenience variable \$foo to bp_location11"} -+} -+send_gdb "break \$foo\n" -+gdb_expect { -+ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\ -+ {pass "set breakpoint via convenience variable"} -+ -re "$gdb_prompt $"\ -+ {fail "set breakpoint via convenience variable"} -+ timeout {fail "(timeout) set breakpoint via convenience variable"} -+} -+ -+# Verify that GDB responds gracefully to an attempt to set a -+# breakpoint via a convenience variable whose type is not integer. -+# -+send_gdb "set \$foo=81.5\n" -+gdb_expect { -+ -re "$gdb_prompt $"\ -+ {pass "set convenience variable \$foo to 81.5"} -+ timeout {fail "(timeout) set convenience variable \$foo to 81.5"} -+} -+send_gdb "break \$foo\n" -+gdb_expect { -+ -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\ -+ {pass "set breakpoint via non-integer convenience variable disallowed"} -+ -re "$gdb_prompt $"\ -+ {fail "set breakpoint via non-integer convenience variable disallowed"} -+ timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"} -+} -+ -+# Verify that we can set and trigger a breakpoint in a user-called function. -+# -+send_gdb "break marker2\n" -+gdb_expect { -+ -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\ -+ {pass "set breakpoint on to-be-called function"} -+ -re "$gdb_prompt $"\ -+ {fail "set breakpoint on to-be-called function"} -+ timeout {fail "(timeout) set breakpoint on to-be-called function"} -+} -+send_gdb "print marker2(99)\n" -+gdb_expect { -+ -re "The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.marker2$proto. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.\r\n$gdb_prompt $"\ -+ {pass "hit breakpoint on called function"} -+ -re "$gdb_prompt $"\ -+ {fail "hit breakpoint on called function"} -+ timeout {fail "(timeout) hit breakpoint on called function"} -+} -+ -+# As long as we're stopped (breakpointed) in a called function, -+# verify that we can successfully backtrace & such from here. -+# -+# In this and the following test, the _sr4export check apparently is needed -+# for hppa*-*-hpux. -+# -+send_gdb "bt\n" -+gdb_expect { -+ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\ -+ {pass "backtrace while in called function"} -+ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\ -+ {pass "backtrace while in called function"} -+ -re "$gdb_prompt $"\ -+ {fail "backtrace while in called function"} -+ timeout {fail "(timeout) backtrace while in called function"} -+} -+ -+# Return from the called function. For remote targets, it's important to do -+# this before runto_main, which otherwise may silently stop on the dummy -+# breakpoint inserted by GDB at the program's entry point. -+# -+send_gdb "finish\n" -+gdb_expect { -+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\ -+ {pass "finish from called function"} -+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\ -+ {pass "finish from called function"} -+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\ -+ {pass "finish from called function"} -+ -re "$gdb_prompt $"\ -+ {fail "finish from called function"} -+ timeout {fail "(timeout) finish from called function"} -+} -+ -+# Verify that GDB responds gracefully to a "finish" command with -+# arguments. -+# -+if ![runto_main] then { fail "break tests suppressed" } -+ -+send_gdb "finish 123\n" -+gdb_expect { -+ -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\ -+ {pass "finish with arguments disallowed"} -+ -re "$gdb_prompt $"\ -+ {fail "finish with arguments disallowed"} -+ timeout {fail "(timeout) finish with arguments disallowed"} -+} -+ -+# Verify that GDB responds gracefully to a request to "finish" from -+# the outermost frame. On a stub that never exits, this will just -+# run to the stubs routine, so we don't get this error... Thus the -+# second condition. -+# -+ -+send_gdb "finish\n" -+gdb_expect { -+ -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\ -+ {pass "finish from outermost frame disallowed"} -+ -re "Run till exit from.*\r\n$gdb_prompt $" { -+ pass "finish from outermost frame disallowed" -+ } -+ -re "$gdb_prompt $"\ -+ {fail "finish from outermost frame disallowed"} -+ timeout {fail "(timeout) finish from outermost frame disallowed"} -+} -+ -+# Verify that we can explicitly ask GDB to stop on all shared library -+# events, and that it does so. -+# -+if [istarget "hppa*-*-hpux*"] then { -+ if ![runto_main] then { fail "break tests suppressed" } -+ -+ send_gdb "set stop-on-solib-events 1\n" -+ gdb_expect { -+ -re "$gdb_prompt $"\ -+ {pass "set stop-on-solib-events"} -+ timeout {fail "(timeout) set stop-on-solib-events"} -+ } -+ -+ send_gdb "run\n" -+ gdb_expect { -+ -re ".*Start it from the beginning.*y or n. $"\ -+ {send_gdb "y\n" -+ gdb_expect { -+ -re ".*Stopped due to shared library event.*$gdb_prompt $"\ -+ {pass "triggered stop-on-solib-events"} -+ -re "$gdb_prompt $"\ -+ {fail "triggered stop-on-solib-events"} -+ timeout {fail "(timeout) triggered stop-on-solib-events"} -+ } -+ } -+ -re "$gdb_prompt $"\ -+ {fail "rerun for stop-on-solib-events"} -+ timeout {fail "(timeout) rerun for stop-on-solib-events"} -+ } -+ -+ send_gdb "set stop-on-solib-events 0\n" -+ gdb_expect { -+ -re "$gdb_prompt $"\ -+ {pass "reset stop-on-solib-events"} -+ timeout {fail "(timeout) reset stop-on-solib-events"} -+ } -+} -+ -+# Hardware breakpoints are unsupported on HP-UX. Verify that GDB -+# gracefully responds to requests to create them. -+# -+if [istarget "hppa*-*-hpux*"] then { -+ if ![runto_main] then { fail "break tests suppressed" } -+ -+ send_gdb "hbreak\n" -+ gdb_expect { -+ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\ -+ {pass "hw breaks disallowed"} -+ -re "$gdb_prompt $"\ -+ {fail "hw breaks disallowed"} -+ timeout {fail "(timeout) hw breaks disallowed"} -+ } -+ -+ send_gdb "thbreak\n" -+ gdb_expect { -+ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\ -+ {pass "temporary hw breaks disallowed"} -+ -re "$gdb_prompt $"\ -+ {fail "temporary hw breaks disallowed"} -+ timeout {fail "(timeout) temporary hw breaks disallowed"} -+ } -+} -+ -+#******** -+ -+ -+# -+# Test "next" over recursive function call. -+# -+ -+proc test_next_with_recursion {} { -+ global gdb_prompt -+ global decimal -+ global binfile -+ -+ if [target_info exists use_gdb_stub] { -+ # Reload the program. -+ delete_breakpoints -+ gdb_load ${binfile}; -+ } else { -+ # FIXME: should be using runto -+ gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y" -+ -+ delete_breakpoints -+ } -+ -+ gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial" -+ -+ # Run until we call factorial with 6 -+ -+ if [istarget "*-*-vxworks*"] then { -+ send_gdb "run vxmain \"6\"\n" -+ } else { -+ gdb_run_cmd -+ } -+ gdb_expect { -+ -re "Break.* factorial .value=6. .*$gdb_prompt $" {} -+ -re ".*$gdb_prompt $" { -+ fail "run to factorial(6)"; -+ gdb_suppress_tests; -+ } -+ timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests } -+ } -+ -+ # Continue until we call factorial recursively with 5. -+ -+ if [gdb_test "continue" \ -+ "Continuing.*Break.* factorial .value=5. .*" \ -+ "continue to factorial(5)"] then { gdb_suppress_tests } -+ -+ # Do a backtrace just to confirm how many levels deep we are. -+ -+ if [gdb_test "backtrace" \ -+ "#0\[ \t\]+ factorial .value=5..*" \ -+ "backtrace from factorial(5)"] then { gdb_suppress_tests } -+ -+ # Now a "next" should position us at the recursive call, which -+ # we will be performing with 4. -+ -+ if [gdb_test "next" \ -+ ".* factorial .value - 1.;.*" \ -+ "next to recursive call"] then { gdb_suppress_tests } -+ -+ # Disable the breakpoint at the entry to factorial by deleting them all. -+ # The "next" should run until we return to the next line from this -+ # recursive call to factorial with 4. -+ # Buggy versions of gdb will stop instead at the innermost frame on -+ # the line where we are trying to "next" to. -+ -+ delete_breakpoints -+ -+ if [istarget "mips*tx39-*"] { -+ set timeout 60 -+ } -+ # We used to set timeout here for all other targets as well. This -+ # is almost certainly wrong. The proper timeout depends on the -+ # target system in use, and how we communicate with it, so there -+ # is no single value appropriate for all targets. The timeout -+ # should be established by the Dejagnu config file(s) for the -+ # board, and respected by the test suite. -+ # -+ # For example, if I'm running GDB over an SSH tunnel talking to a -+ # portmaster in California talking to an ancient 68k board running -+ # a crummy ROM monitor (a situation I can only wish were -+ # hypothetical), then I need a large timeout. But that's not the -+ # kind of knowledge that belongs in this file. -+ -+ gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \ -+ "next over recursive call" -+ -+ # OK, we should be back in the same stack frame we started from. -+ # Do a backtrace just to confirm. -+ -+ set result [gdb_test "backtrace" \ -+ "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \ -+ "backtrace from factorial(5.1)"] -+ if { $result != 0 } { gdb_suppress_tests } -+ -+ if [target_info exists gdb,noresults] { gdb_suppress_tests } -+ gdb_continue_to_end "recursive next test" -+ gdb_stop_suppressing_tests; -+} -+ -+test_next_with_recursion -+ -+ -+#******** -+ -+# build a new file with optimization enabled so that we can try breakpoints -+# on targets with optimized prologues -+ -+set binfileo2 [standard_output_file ${testfile}o2] -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+if [get_compiler_info ${binfileo2}] { -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfileo2} -+ -+if [target_info exists gdb_stub] { -+ gdb_step_for_stub; -+} -+ -+# -+# test break at function -+# -+gdb_test "break main" \ -+ "Breakpoint.*at.* file .*$srcfile, line.*" \ -+ "breakpoint function, optimized file" -+ -+# -+# test break at function -+# -+gdb_test "break marker4" \ -+ "Breakpoint.*at.* file .*$srcfile1, line.*" \ -+ "breakpoint small function, optimized file" -+ -+# -+# run until the breakpoint at main is hit. For non-stubs-using targets. -+# -+if ![target_info exists use_gdb_stub] { -+ if [istarget "*-*-vxworks*"] then { -+ send_gdb "run vxmain \"2\"\n" -+ set timeout 120 -+ verbose "Timeout is now $timeout seconds" 2 -+ } else { -+ send_gdb "run\n" -+ } -+ gdb_expect { -+ -re "The program .* has been started already.*y or n. $" { -+ send_gdb "y\n" -+ exp_continue -+ } -+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\ -+ { pass "run until function breakpoint, optimized file" } -+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\ -+ { pass "run until function breakpoint, optimized file (code motion)" } -+ -re ".*$gdb_prompt $" { fail "run until function breakpoint, optimized file" } -+ timeout { fail "run until function breakpoint, optimized file (timeout)" } -+ } -+} else { -+ if ![target_info exists gdb_stub] { -+ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file" -+ } -+} -+ -+# -+# run until the breakpoint at a small function -+# -+ -+# -+# Add a second pass pattern. The behavior differs here between stabs -+# and dwarf for one-line functions. Stabs preserves two line symbols -+# (one before the prologue and one after) with the same line number, -+# but dwarf regards these as duplicates and discards one of them. -+# Therefore the address after the prologue (where the breakpoint is) -+# has no exactly matching line symbol, and GDB reports the breakpoint -+# as if it were in the middle of a line rather than at the beginning. -+ -+set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1] -+set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] -+send_gdb "continue\n" -+gdb_expect { -+ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { -+ pass "run until breakpoint set at small function, optimized file" -+ } -+ -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { -+ pass "run until breakpoint set at small function, optimized file" -+ } -+ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" { -+ # marker4() is defined at line 46 when compiled with -DPROTOTYPES -+ pass "run until breakpoint set at small function, optimized file (line bp_location14)" -+ } -+ -re ".*$gdb_prompt " { -+ fail "run until breakpoint set at small function, optimized file" -+ } -+ timeout { -+ fail "run until breakpoint set at small function, optimized file (timeout)" -+ } -+} -+ -+ -+# Reset the default arguments for VxWorks -+if [istarget "*-*-vxworks*"] { -+ set timeout 10 -+ verbose "Timeout is now $timeout seconds" 2 -+ send_gdb "set args main\n" -+ gdb_expect -re ".*$gdb_prompt $" {} -+} -diff --git a/gdb/testsuite/gdb.pie/break1.c b/gdb/testsuite/gdb.pie/break1.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pie/break1.c -@@ -0,0 +1,44 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 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 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. -+ -+ Please email any bugs, comments, and/or additions to this file to: -+ bug-gdb@prep.ai.mit.edu */ -+ -+/* The code for this file was extracted from the gdb testsuite -+ testcase "break.c". */ -+ -+/* The following functions do nothing useful. They are included -+ simply as places to try setting breakpoints at. They are -+ explicitly "one-line functions" to verify that this case works -+ (some versions of gcc have or have had problems with this). -+ -+ These functions are in a separate source file to prevent an -+ optimizing compiler from inlining them and optimizing them away. */ -+ -+#ifdef PROTOTYPES -+int marker1 (void) { return (0); } /* set breakpoint 15 here */ -+int marker2 (int a) { return (1); } /* set breakpoint 8 here */ -+void marker3 (char *a, char *b) {} /* set breakpoint 17 here */ -+void marker4 (long d) {} /* set breakpoint 14 here */ -+#else -+int marker1 () { return (0); } /* set breakpoint 16 here */ -+int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */ -+void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */ -+void marker4 (d) long d; {} /* set breakpoint 13 here */ -+#endif -diff --git a/gdb/testsuite/gdb.pie/corefile.exp b/gdb/testsuite/gdb.pie/corefile.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pie/corefile.exp -@@ -0,0 +1,233 @@ -+# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 -+# 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 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. -+ -+# This file was written by Fred Fish. (fnf@cygnus.com) -+ -+# are we on a target board -+if ![isnative] then { -+ return -+} -+ -+set testfile "coremaker" -+set srcfile ${testfile}.c -+set binfile [standard_output_file ${testfile}] -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-fpie -pie"}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+# Create and source the file that provides information about the compiler -+# used to compile the test case. -+if [get_compiler_info ${binfile}] { -+ return -1; -+} -+ -+# Create a core file named "corefile" rather than just "core", to -+# avoid problems with sys admin types that like to regularly prune all -+# files named "core" from the system. -+# -+# Arbitrarily try setting the core size limit to "unlimited" since -+# this does not hurt on systems where the command does not work and -+# allows us to generate a core on systems where it does. -+# -+# Some systems append "core" to the name of the program; others append -+# the name of the program to "core"; still others (like Linux, as of -+# May 2003) create cores named "core.PID". In the latter case, we -+# could have many core files lying around, and it may be difficult to -+# tell which one is ours, so let's run the program in a subdirectory. -+set found 0 -+set coredir [standard_output_file coredir.[getpid]] -+file mkdir $coredir -+catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\"" -+# remote_exec host "${binfile}" -+foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" { -+ if [remote_file build exists $i] { -+ remote_exec build "mv $i [standard_output_file corefile]" -+ set found 1 -+ } -+} -+# Check for "core.PID". -+if { $found == 0 } { -+ set names [glob -nocomplain -directory $coredir core.*] -+ if {[llength $names] == 1} { -+ set corefile [file join $coredir [lindex $names 0]] -+ remote_exec build "mv $corefile [standard_output_file corefile]" -+ set found 1 -+ } -+} -+if { $found == 0 } { -+ # The braindamaged HPUX shell quits after the ulimit -c above -+ # without executing ${binfile}. So we try again without the -+ # ulimit here if we didn't find a core file above. -+ # Oh, I should mention that any "braindamaged" non-Unix system has -+ # the same problem. I like the cd bit too, it's really neat'n stuff. -+ catch "system \"(cd [file dirname [standard_output_file ${binfile}]]; ${binfile}; true) >/dev/null 2>&1\"" -+ foreach i "[standard_output_file core] [standard_output_file core.coremaker.c] ${binfile}.core" { -+ if [remote_file build exists $i] { -+ remote_exec build "mv $i [standard_output_file corefile]" -+ set found 1 -+ } -+ } -+} -+ -+# Try to clean up after ourselves. -+remote_file build delete [file join $coredir coremmap.data] -+remote_exec build "rmdir $coredir" -+ -+if { $found == 0 } { -+ warning "can't generate a core file - core tests suppressed - check ulimit -c" -+ return 0 -+} -+ -+# -+# Test that we can simply startup with a "-core=corefile" command line arg -+# and recognize that the core file is a valid, usable core file. -+# To do this, we must shutdown the currently running gdb and restart -+# with the -core args. We can't use gdb_start because it looks for -+# the first gdb prompt, and the message we are looking for occurs -+# before the first prompt. Also, we can't include GDBFLAGS because -+# if it is empty, this confuses gdb with an empty argument that it -+# grumbles about (said grumbling currently being ignored in gdb_start). -+# **FIXME** -+# -+# Another problem is that on some systems (solaris for example), there -+# is apparently a limit on the length of a fully specified path to -+# the coremaker executable, at about 80 chars. For this case, consider -+# it a pass, but note that the program name is bad. -+ -+gdb_exit -+if $verbose>1 then { -+ send_user "Spawning $GDB -nw $GDBFLAGS -core=[standard_output_file corefile]\n" -+} -+ -+set oldtimeout $timeout -+set timeout [expr "$timeout + 60"] -+verbose "Timeout is now $timeout seconds" 2 -+eval "spawn $GDB -nw $GDBFLAGS -core=[standard_output_file corefile]" -+expect { -+ -re "Couldn't find .* registers in core file.*$gdb_prompt $" { -+ fail "args: -core=corefile (couldn't find regs)" -+ } -+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -+ pass "args: -core=corefile" -+ } -+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -+ pass "args: -core=corefile (with bad program name)" -+ } -+ -re ".*registers from core file: File in wrong format.* $" { -+ fail "args: -core=corefile (could not read registers from core file)" -+ } -+ -re ".*$gdb_prompt $" { fail "args: -core=corefile" } -+ timeout { fail "(timeout) starting with -core" } -+} -+ -+ -+# -+# Test that startup with both an executable file and -core argument. -+# See previous comments above, they are still applicable. -+# -+ -+close; -+ -+if $verbose>1 then { -+ send_user "Spawning $GDB -nw $GDBFLAGS $binfile -core=[standard_output_file corefile]\n" -+} -+ -+ -+eval "spawn $GDB -nw $GDBFLAGS $binfile -core=[standard_output_file corefile]"; -+expect { -+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -+ pass "args: execfile -core=corefile" -+ } -+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -+ pass "args: execfile -core=corefile (with bad program name)" -+ } -+ -re ".*registers from core file: File in wrong format.* $" { -+ fail "args: execfile -core=corefile (could not read registers from core file)" -+ } -+ -re ".*$gdb_prompt $" { fail "args: execfile -core=corefile" } -+ timeout { fail "(timeout) starting with -core" } -+} -+set timeout $oldtimeout -+verbose "Timeout is now $timeout seconds" 2 -+ -+close; -+ -+# Now restart normally. -+ -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+# Test basic corefile recognition via core-file command. -+ -+send_gdb "core-file [standard_output_file corefile]\n" -+gdb_expect { -+ -re ".* program is being debugged already.*y or n. $" { -+ # gdb_load may connect us to a gdbserver. -+ send_gdb "y\n" -+ exp_continue; -+ } -+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -+ pass "core-file command" -+ } -+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -+ pass "core-file command (with bad program name)" -+ } -+ -re ".*registers from core file: File in wrong format.* $" { -+ fail "core-file command (could not read registers from core file)" -+ } -+ -re ".*$gdb_prompt $" { fail "core-file command" } -+ timeout { fail "(timeout) core-file command" } -+} -+ -+# Test correct mapping of corefile sections by printing some variables. -+ -+gdb_test "print coremaker_data" "\\\$$decimal = 202" -+gdb_test "print coremaker_bss" "\\\$$decimal = 10" -+gdb_test "print coremaker_ro" "\\\$$decimal = 201" -+ -+gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}" -+ -+# Somehow we better test the ability to read the registers out of the core -+# file correctly. I don't think the other tests do this. -+ -+gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp" -+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp" -+ -+# Test ability to read mmap'd data -+ -+gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap data in core file" -+setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*" -+set test "accessing mmapped data in core file" -+gdb_test_multiple "x/8bd buf2" "$test" { -+ -re ".*:.*0.*1.*2.*3.*4.*5.*6.*7.*$gdb_prompt $" { -+ pass "$test" -+ } -+ -re "0x\[f\]*:.*Cannot access memory at address 0x\[f\]*.*$gdb_prompt $" { -+ fail "$test (mapping failed at runtime)" -+ } -+ -re "0x.*:.*Cannot access memory at address 0x.*$gdb_prompt $" { -+ fail "$test (mapping address not found in core file)" -+ } -+} -+ -+# test reinit_frame_cache -+ -+gdb_load ${binfile} -+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)" -+ -+gdb_test "core" "No core file now." -diff --git a/gdb/testsuite/gdb.pie/coremaker.c b/gdb/testsuite/gdb.pie/coremaker.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pie/coremaker.c -@@ -0,0 +1,142 @@ -+/* Copyright 1992, 1993, 1994, 1995, 1996, 1999 -+ 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. */ -+ -+/* Simple little program that just generates a core dump from inside some -+ nested function calls. */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#ifndef __STDC__ -+#define const /**/ -+#endif -+ -+#define MAPSIZE (8 * 1024) -+ -+/* Don't make these automatic vars or we will have to walk back up the -+ stack to access them. */ -+ -+char *buf1; -+char *buf2; -+ -+int coremaker_data = 1; /* In Data section */ -+int coremaker_bss; /* In BSS section */ -+ -+const int coremaker_ro = 201; /* In Read-Only Data section */ -+ -+/* Note that if the mapping fails for any reason, we set buf2 -+ to -1 and the testsuite notices this and reports it as -+ a failure due to a mapping error. This way we don't have -+ to test for specific errors when running the core maker. */ -+ -+void -+mmapdata () -+{ -+ int j, fd; -+ -+ /* Allocate and initialize a buffer that will be used to write -+ the file that is later mapped in. */ -+ -+ buf1 = (char *) malloc (MAPSIZE); -+ for (j = 0; j < MAPSIZE; ++j) -+ { -+ buf1[j] = j; -+ } -+ -+ /* Write the file to map in */ -+ -+ fd = open ("coremmap.data", O_CREAT | O_RDWR, 0666); -+ if (fd == -1) -+ { -+ perror ("coremmap.data open failed"); -+ buf2 = (char *) -1; -+ return; -+ } -+ write (fd, buf1, MAPSIZE); -+ -+ /* Now map the file into our address space as buf2 */ -+ -+ buf2 = (char *) mmap (0, MAPSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); -+ if (buf2 == (char *) -1) -+ { -+ perror ("mmap failed"); -+ return; -+ } -+ -+ /* Verify that the original data and the mapped data are identical. -+ If not, we'd rather fail now than when trying to access the mapped -+ data from the core file. */ -+ -+ for (j = 0; j < MAPSIZE; ++j) -+ { -+ if (buf1[j] != buf2[j]) -+ { -+ fprintf (stderr, "mapped data is incorrect"); -+ buf2 = (char *) -1; -+ return; -+ } -+ } -+} -+ -+void -+func2 () -+{ -+ int coremaker_local[5]; -+ int i; -+ -+#ifdef SA_FULLDUMP -+ /* Force a corefile that includes the data section for AIX. */ -+ { -+ struct sigaction sa; -+ -+ sigaction (SIGABRT, (struct sigaction *)0, &sa); -+ sa.sa_flags |= SA_FULLDUMP; -+ sigaction (SIGABRT, &sa, (struct sigaction *)0); -+ } -+#endif -+ -+ /* Make sure that coremaker_local doesn't get optimized away. */ -+ for (i = 0; i < 5; i++) -+ coremaker_local[i] = i; -+ coremaker_bss = 0; -+ for (i = 0; i < 5; i++) -+ coremaker_bss += coremaker_local[i]; -+ coremaker_data = coremaker_ro + 1; -+ abort (); -+} -+ -+void -+func1 () -+{ -+ func2 (); -+} -+ -+int main () -+{ -+ mmapdata (); -+ func1 (); -+ return 0; -+} -+ diff --git a/gdb-6.3-test-self-20050110.patch b/gdb-6.3-test-self-20050110.patch deleted file mode 100644 index d9a7eb38e76993f0825bce031324b4606598d097..0000000000000000000000000000000000000000 --- a/gdb-6.3-test-self-20050110.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp ---- a/gdb/testsuite/lib/selftest-support.exp -+++ b/gdb/testsuite/lib/selftest-support.exp -@@ -151,18 +151,18 @@ proc do_self_tests {function body} { - } - - # Remove any old copy lying around. -- remote_file host delete $xgdb -+ #remote_file host delete $xgdb - - gdb_start -- set file [remote_download host $GDB_FULLPATH $xgdb] -+ #set file [remote_download host $GDB_FULLPATH $xgdb] - -- set result [selftest_setup $file $function] -+ set result [selftest_setup $GDB_FULLPATH $function] - if {$result == 0} then { - set result [uplevel $body] - } - - gdb_exit -- catch "remote_file host delete $file" -+ #catch "remote_file host delete $file" - - if {$result < 0} then { - warning "Couldn't test self" diff --git a/gdb-6.3-threaded-watchpoints2-20050225.patch b/gdb-6.3-threaded-watchpoints2-20050225.patch index dc11e5fc37cae75c82664acd6c65f726fef7a863..42b5260ec96b2de8e43290877c787e4a68d93f93 100644 --- a/gdb-6.3-threaded-watchpoints2-20050225.patch +++ b/gdb-6.3-threaded-watchpoints2-20050225.patch @@ -1,8 +1,60 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jeff Johnston +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.3-threaded-watchpoints2-20050225.patch + +;; Test sibling threads to set threaded watchpoints for x86 and x86-64 +;;=fedoratest + +2005-02-28 Jeff Johnston + + * config/i386/nm-linux.h: Change dr register routines to + accept a ptid_t first argument. Change all calling macros + to default the inferior_ptid for the first argument. + (i386_linux_insert_watchpoint): New prototype. + (i386_linux_remove_watchpoint, i386_linux_insert_hw_breakpoint): Ditto. + (i386_linux_remove_hw_breakpoint): Ditto. + (target_insert_watchpoint, target_remove_watchpoint): Undef and + override. + (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Ditto. + * config/i386/nm-linux64.h: Ditto except add amd64 versions of + the watchpoint/hw-breakpoint insert/remove routines. + * i386-nat.c: Include "inferior.h" to define inferior_ptid. + * i386-linux-nat.c: Change all dr get/set routines to accept + ptid_t as first argument and to use this argument to determine + the tid for PTRACE. + (i386_linux_set_debug_regs_for_thread): New function. + (i386_linux_sync_debug_registers_callback): Ditto. + (i386_linux_sync_debug_registers_across_threads): Ditto. + (i386_linux_insert_watchpoint, i386_linux_remove_watchpoint): Ditto. + (i386_linux_hw_breakpoint, i386_linux_remove_hw_breakpoint): Ditto. + (i386_linux_new_thread): Ditto. + (_initialize_i386_linux_nat): Ditto. + * amd64-linux-nat.c: Change all dr get/set routines to accept + ptid_t as first argument and to use this argument to determine + the tid for PTRACE. + (amd64_linux_set_debug_regs_for_thread): New function. + (amd64_linux_sync_debug_registers_callback): Ditto. + (amd64_linux_sync_debug_registers_across_threads): Ditto. + (amd64_linux_insert_watchpoint, amd64_linux_remove_watchpoint): Ditto. + (amd64_linux_hw_breakpoint, amd64_linux_remove_hw_breakpoint): Ditto. + (amd64_linux_new_thread): Ditto. + (_initialize_amd64_linux_nat): Register linux new thread observer. + * testsuite/gdb.threads/watchthreads-threaded.c: New test case. + * testsuite/gdb.threads/watchthreads-threaded.exp: Ditto. + +[ With recent upstream GDB (6.8) reduced only to the testcase. ] + +[ It was called watchthreads2.{exp,c} before but it conflicted with FSF GDB new + testcase of the same name. ] + +FIXME: The testcase does not expects multiple watchpoints hits per one stop. + diff --git a/gdb/testsuite/gdb.threads/watchthreads-threaded.c b/gdb/testsuite/gdb.threads/watchthreads-threaded.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.threads/watchthreads-threaded.c -@@ -0,0 +1,66 @@ +@@ -0,0 +1,65 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc. @@ -20,8 +72,8 @@ new file mode 100644 + 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. -+ ++ Boston, MA 02111-1307, USA. ++ + This file is copied from schedlock.c. */ + +#include @@ -68,7 +120,6 @@ new file mode 100644 + + pthread_exit(NULL); +} -+ diff --git a/gdb/testsuite/gdb.threads/watchthreads-threaded.exp b/gdb/testsuite/gdb.threads/watchthreads-threaded.exp new file mode 100644 --- /dev/null @@ -90,7 +141,7 @@ new file mode 100644 +# +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Check that GDB can support multiple watchpoints across threads. + @@ -161,9 +212,9 @@ new file mode 100644 + { set args_2 1; set test_flag 1 } + -re "Hardware watchpoint 4: args\\\[3\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*watchthreads-threaded.c:$init_line.*$gdb_prompt $" + { set args_3 1; set test_flag 1 } -+ -re "Hardware watchpoint 3: args\\\[2\\\].*Old value = $args_2.*New value = [expr $args_2+1].*in thread_function \\\(arg=0x2\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $" ++ -re "Hardware watchpoint 3: args\\\[2\\\].*Old value = $args_2.*New value = [expr $args_2+1].*thread_function \\\(arg=0x2\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $" + { set args_2 [expr $args_2+1]; set test_flag 1 } -+ -re "Hardware watchpoint 4: args\\\[3\\\].*Old value = $args_3.*New value = [expr $args_3+1].*in thread_function \\\(arg=0x3\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $" ++ -re "Hardware watchpoint 4: args\\\[3\\\].*Old value = $args_3.*New value = [expr $args_3+1].*thread_function \\\(arg=0x3\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $" + { set args_3 [expr $args_3+1]; set test_flag 1 } + } + # If we fail above, don't bother continuing loop @@ -180,7 +231,7 @@ new file mode 100644 +# Verify that we hit first watchpoint in child thread. +set message "watchpoint on args\[2\] hit in thread" +if { $args_2 > 1 } { -+ pass $message ++ pass $message +} else { + fail $message +} @@ -188,15 +239,15 @@ new file mode 100644 +# Verify that we hit second watchpoint in child thread. +set message "watchpoint on args\[3\] hit in thread" +if { $args_3 > 1 } { -+ pass $message ++ pass $message +} else { -+ fail $message ++ fail $message +} + +# Verify that all watchpoint hits are accounted for. +set message "combination of threaded watchpoints = 30 + initial values" +if { [expr $args_2+$args_3] == [expr [expr 30+$init_args_2]+$init_args_3] } { -+ pass $message ++ pass $message +} else { -+ fail $message ++ fail $message +} diff --git a/gdb-6.5-BEA-testsuite.patch b/gdb-6.5-BEA-testsuite.patch index 19075e0cc3485d90031103574ce40b19f4412330..a15cec2ec793d0711ebbfd7dcd553934415c9dc0 100644 --- a/gdb-6.5-BEA-testsuite.patch +++ b/gdb-6.5-BEA-testsuite.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-BEA-testsuite.patch + +;; Improved testsuite results by the testsuite provided by the courtesy of BEA. +;;=fedoratest: For upstream it should be rewritten as a dejagnu test, the test of no "??" was useful. + diff --git a/gdb/testsuite/gdb.threads/threadcrash.c b/gdb/testsuite/gdb.threads/threadcrash.c new file mode 100644 --- /dev/null @@ -22,14 +30,14 @@ new file mode 100644 + * gdb. Inside gdb, you should be able to do something like this: + * + * (gdb) t a a bt -+ * ++ * + * Thread 7 (process 4352): + * #0 0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6 + * #1 0x001ba5ff in sleep () from /lib/tls/libc.so.6 + * #2 0x080488a2 in makeSyscall (ignored=0x0) at threadcrash.c:118 + * #3 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 + * #4 0x001ed19a in clone () from /lib/tls/libc.so.6 -+ * ++ * + * Thread 6 (process 4353): + * #0 0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6 + * #1 0x001ba5ff in sleep () from /lib/tls/libc.so.6 @@ -40,7 +48,7 @@ new file mode 100644 + * #5 0x08048a51 in makeSyscallFromSighandler (ignored=0x0) at threadcrash.c:204 + * #6 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 + * #7 0x001ed19a in clone () from /lib/tls/libc.so.6 -+ * ++ * + * Thread 5 (process 4354): + * #0 0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6 + * #1 0x001ba5ff in sleep () from /lib/tls/libc.so.6 @@ -51,12 +59,12 @@ new file mode 100644 + * #5 0x080489e2 in makeSyscallFromAltSighandler (ignored=0x0) at threadcrash.c:190 + * #6 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 + * #7 0x001ed19a in clone () from /lib/tls/libc.so.6 -+ * ++ * + * Thread 4 (process 4355): + * #0 spin (ignored=0x0) at threadcrash.c:242 + * #1 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 + * #2 0x001ed19a in clone () from /lib/tls/libc.so.6 -+ * ++ * + * Thread 3 (process 4356): + * #0 spinningSighandler (signo=12, info=0xb4de46f0, context=0xb4de4770) at threadcrash.c:180 + * #1 @@ -64,7 +72,7 @@ new file mode 100644 + * #3 0x08048b2f in spinFromSighandler (ignored=0x0) at threadcrash.c:232 + * #4 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 + * #5 0x001ed19a in clone () from /lib/tls/libc.so.6 -+ * ++ * + * Thread 2 (process 4357): + * #0 spinningAltSighandler (signo=14, info=0x959ee50, context=0x959eed0) at threadcrash.c:156 + * #1 @@ -72,7 +80,7 @@ new file mode 100644 + * #3 0x08048ac0 in spinFromAltSighandler (ignored=0x0) at threadcrash.c:218 + * #4 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 + * #5 0x001ed19a in clone () from /lib/tls/libc.so.6 -+ * ++ * + * Thread 1 (process 4351): + * #0 0x08048cf3 in main (argc=1, argv=0xbfff9d74) at threadcrash.c:273 + * (gdb) @@ -99,11 +107,11 @@ new file mode 100644 + int result; + stack_t altstack; + stack_t oldaltstack; -+ ++ + memset(&action, 0, sizeof(action)); + memset(&altstack, 0, sizeof(altstack)); + memset(&oldaltstack, 0, sizeof(oldaltstack)); -+ ++ + if (onAltstack) { + altstack.ss_sp = malloc(SIGSTKSZ); + assert(altstack.ss_sp != NULL); @@ -113,9 +121,9 @@ new file mode 100644 + assert(result == 0); + assert(oldaltstack.ss_flags == SS_DISABLE); + } -+ ++ + sigemptyset(&sigset); -+ ++ + action.sa_handler = NULL; + action.sa_sigaction = handler; + action.sa_mask = sigset; @@ -123,7 +131,7 @@ new file mode 100644 + if (onAltstack) { + action.sa_flags |= SA_ONSTACK; + } -+ ++ + result = sigaction(signo, &action, NULL); + assert(result == 0); +} @@ -149,10 +157,10 @@ new file mode 100644 +static int onAltstack(void) { + stack_t stack; + int result; -+ ++ + result = sigaltstack(NULL, &stack); + assert(result == 0); -+ ++ + return stack.ss_flags & SS_ONSTACK; +} + @@ -160,11 +168,11 @@ new file mode 100644 + (void)signo; + (void)info; + (void)context; -+ ++ + if (!onAltstack()) { + printf("%s() not running on altstack!\n", __FUNCTION__); + } -+ ++ + sleep(42); +} + @@ -172,11 +180,11 @@ new file mode 100644 + (void)signo; + (void)info; + (void)context; -+ ++ + if (!onAltstack()) { + printf("%s() not running on altstack!\n", __FUNCTION__); + } -+ ++ + while (1); +} + @@ -184,11 +192,11 @@ new file mode 100644 + (void)signo; + (void)info; + (void)context; -+ ++ + if (onAltstack()) { + printf("%s() running on altstack!\n", __FUNCTION__); + } -+ ++ + sleep(42); +} + @@ -196,73 +204,73 @@ new file mode 100644 + (void)signo; + (void)info; + (void)context; -+ ++ + if (onAltstack()) { + printf("%s() running on altstack!\n", __FUNCTION__); + } -+ ++ + while (1); +} + +static void *makeSyscallFromAltSighandler(void *ignored) { + (void)ignored; -+ ++ + int result; -+ ++ + installAlthandler(SIGSYSCALL_ALT, syscallingAltSighandler); -+ ++ + result = pthread_kill(pthread_self(), SIGSYSCALL_ALT); + assert(result == 0); -+ ++ + fprintf(stderr, "%s: returning\n", __FUNCTION__); + return NULL; +} + +static void *makeSyscallFromSighandler(void *ignored) { + (void)ignored; -+ ++ + int result; -+ ++ + installNormalHandler(SIGSYSCALL, syscallingSighandler); -+ ++ + result = pthread_kill(pthread_self(), SIGSYSCALL); + assert(result == 0); -+ ++ + fprintf(stderr, "%s: returning\n", __FUNCTION__); + return NULL; +} + +static void *spinFromAltSighandler(void *ignored) { + (void)ignored; -+ ++ + int result; -+ ++ + installAlthandler(SIGSPIN_ALT, spinningAltSighandler); -+ ++ + result = pthread_kill(pthread_self(), SIGSPIN_ALT); + assert(result == 0); -+ ++ + fprintf(stderr, "%s: returning\n", __FUNCTION__); + return NULL; +} + +static void *spinFromSighandler(void *ignored) { + (void)ignored; -+ ++ + int result; -+ ++ + installNormalHandler(SIGSPIN, spinningSighandler); -+ ++ + result = pthread_kill(pthread_self(), SIGSPIN); + assert(result == 0); -+ ++ + fprintf(stderr, "%s: returning\n", __FUNCTION__); + return NULL; +} + +static void *spin(void *ignored) { + (void)ignored; -+ ++ + while (1); + + fprintf(stderr, "%s: returning\n", __FUNCTION__); @@ -273,7 +281,7 @@ new file mode 100644 + int result; + pthread_t thread; + volatile int bad; -+ ++ + result = pthread_create(&thread, NULL, makeSyscall, NULL); + assert(result == 0); + result = pthread_create(&thread, NULL, makeSyscallFromSighandler, NULL); @@ -286,10 +294,10 @@ new file mode 100644 + assert(result == 0); + result = pthread_create(&thread, NULL, spinFromAltSighandler, NULL); + assert(result == 0); -+ ++ + // Give threads some time to get going + sleep(3); -+ ++ + // Crash + bad = *(int*)7; + @@ -301,7 +309,7 @@ new file mode 100644 + Keep it late to ensure persistency in the registers. */ + bad = (int) argc; + bad = (unsigned long) argv; -+ ++ + return 0; +} diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp @@ -472,27 +480,27 @@ new file mode 100644 +# Verify that $LOG contains all information we want +function verifyLog() { + local FAILURES=0 -+ ++ + mustNotHave '??' || ((FAILURES++)) + mustHaveCorrectAmount 11 threadcrash.c: || ((FAILURES++)) -+ ++ + mustHaveSevenThreads || ((FAILURES++)) + mustHaveSequence sleep "makeSyscall (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence sleep "syscallingSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) + mustHaveSequence pthread_kill "makeSyscallFromSighandler (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence sleep "syscallingAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) + mustHaveSequence pthread_kill "makeSyscallFromAltSighandler (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence Thread "spin (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence "spinningSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) + mustHaveSequence pthread_kill "spinFromSighandler (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence "spinningAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) + mustHaveSequence pthread_kill "spinFromAltSighandler (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence Thread "main (argc=1, argv=" || ((FAILURES++)) + + return $FAILURES @@ -569,7 +577,7 @@ new file mode 100644 + fail + fi + pass -+ ++ + # Verify that we got a core file from gcore + set_test gdb gcore did not create a core file + if [ ! -r core* ] ; then @@ -754,27 +762,27 @@ new file mode 100644 +# Verify that $LOG contains all information we want +function verifyLog() { + local FAILURES=0 -+ ++ + mustNotHave '??' || ((FAILURES++)) + mustHaveCorrectAmount 12 threadcrash.c: || ((FAILURES++)) -+ ++ + mustHaveSevenThreads || ((FAILURES++)) + mustHaveSequence sleep "makeSyscall (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence sleep "syscallingSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) + mustHaveSequence pthread_kill "makeSyscallFromSighandler (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence sleep "syscallingAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) + mustHaveSequence pthread_kill "makeSyscallFromAltSighandler (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence Thread "spin (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence "spinningSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) + mustHaveSequence pthread_kill "spinFromSighandler (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence "spinningAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) + mustHaveSequence pthread_kill "spinFromAltSighandler (ignored=" || ((FAILURES++)) -+ ++ + mustHaveSequence Thread "main (argc=1, argv=" || ((FAILURES++)) + + return $FAILURES @@ -836,7 +844,7 @@ new file mode 100644 + ((FAILURES++)) + echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE when creating gcore file + fi -+ ++ + # Verify that we got a core file from gcore + if [ ! -r core* ] ; then + echo >> /dev/stderr ERROR: gdb gcore did not create a core file diff --git a/gdb-6.5-bz109921-DW_AT_decl_file-test.patch b/gdb-6.5-bz109921-DW_AT_decl_file-test.patch index 95899d6fb348e3cc46e0fbae0367b63fa9d45c29..8d03e3f11690f7bc930e926fa2bcd53cfd6fca35 100644 --- a/gdb-6.5-bz109921-DW_AT_decl_file-test.patch +++ b/gdb-6.5-bz109921-DW_AT_decl_file-test.patch @@ -1,3 +1,29 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-bz109921-DW_AT_decl_file-test.patch + +;; Find symbols properly at their original (included) file (BZ 109921). +;;=fedoratest + +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=109921 + +It is duplicite to its upstream variant: +http://sourceware.org/ml/gdb-cvs/2007-01/msg00157.html +http://sourceware.org/ml/gdb-patches/2007-01/msg00434.html +2007-01-21 Jan Kratochvil + Daniel Jacobowitz + + * gdb.base/included.c, gdb.base/included.exp, + gdb.base/included.h: New files. + +------------------------------------------------------------------------------ + +2007-01-09 Jan Kratochvil + + * gdb.dwarf2/dw2-included.exp, gdb.dwarf2/dw2-included.c, + gdb.dwarf2/dw2-included.h: New files. + diff --git a/gdb/testsuite/gdb.dwarf2/dw2-included.c b/gdb/testsuite/gdb.dwarf2/dw2-included.c new file mode 100644 --- /dev/null @@ -16,7 +42,7 @@ new file mode 100644 + 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, @@ -40,12 +66,12 @@ new file mode 100644 +# 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. @@ -60,7 +86,7 @@ new file mode 100644 + && ![istarget *-*-openbsd*] + && ![istarget arm-*-eabi*] + && ![istarget powerpc-*-eabi*]} { -+ return 0 ++ return 0 +} + +set testfile "dw2-included" @@ -99,7 +125,7 @@ new file mode 100644 + 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, diff --git a/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch b/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch index 4fdd93774a57ffd4e5558e95f36bd8625522f17c..304aa38490fac088721aba7fb69ac0d9ee085897 100644 --- a/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch +++ b/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch @@ -1,17 +1,60 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch + +;; Support TLS symbols (+`errno' suggestion if no pthread is found) (BZ 185337). +;;=push+jan: It should be replaced by Infinity project. + +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337 + +2008-02-24 Jan Kratochvil + + Port to GDB-6.8pre. + +currently for trivial nonthreaded helloworld with no debug info up to -ggdb2 you +will get: + (gdb) p errno + [some error] + +* with -ggdb2 and less "errno" in fact does not exist anywhere as it was + compiled to "(*__errno_location ())" and the macro definition is not present. + Unfortunately gdb will find the TLS symbol and it will try to access it but + as the program has been compiled without -lpthread the TLS base register + (%gs on i386) is not setup and it will result in: + Cannot access memory at address 0x8 + +Attached suggestion patch how to deal with the most common "errno" symbol +for the most common under-ggdb3 compiled programs. + +Original patch hooked into target_translate_tls_address. But its inferior +call invalidates `struct frame *' in the callers - RH BZ 690908. + +https://bugzilla.redhat.com/show_bug.cgi?id=1166549 + +2007-11-03 Jan Kratochvil + + * ./gdb/dwarf2read.c (read_partial_die, dwarf2_linkage_name): Prefer + DW_AT_MIPS_linkage_name over DW_AT_name now only for non-C. + +glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug: + <81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location + <81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location + diff --git a/gdb/printcmd.c b/gdb/printcmd.c --- a/gdb/printcmd.c +++ b/gdb/printcmd.c -@@ -1214,6 +1214,10 @@ print_command_1 (const char *args, int voidprint) +@@ -1306,6 +1306,10 @@ process_print_command_args (const char *args, value_print_options *print_opts, if (exp != nullptr && *exp) { + /* '*((int *(*) (void)) __errno_location) ()' is incompatible with + function descriptors. */ -+ if (target_has_execution && strcmp (exp, "errno") == 0) ++ if (target_has_execution () && strcmp (exp, "errno") == 0) + exp = "*(*(int *(*)(void)) __errno_location) ()"; - expression_up expr = parse_expression (exp); - val = evaluate_expression (expr.get ()); - } + /* VOIDPRINT is true to indicate that we do want to print a void + value, so invert it for parse_expression. */ + expression_up expr = parse_expression (exp, nullptr, !voidprint); diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.c b/gdb/testsuite/gdb.dwarf2/dw2-errno.c new file mode 100644 --- /dev/null diff --git a/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch b/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch index fcebc27d2f077b9de012a088cb105c9eb8fcaf81..db4229d8ae48b149b8c6b3a679aa05fe8624b450 100644 --- a/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch +++ b/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch @@ -1,3 +1,13 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch + +;; Test sideeffects of skipping ppc .so libs trampolines (BZ 218379). +;;=fedoratest + +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379 + diff --git a/gdb/testsuite/gdb.base/step-over-trampoline.c b/gdb/testsuite/gdb.base/step-over-trampoline.c new file mode 100644 --- /dev/null @@ -16,7 +26,7 @@ new file mode 100644 + 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. @@ -35,22 +45,27 @@ diff --git a/gdb/testsuite/gdb.base/step-over-trampoline.exp b/gdb/testsuite/gdb new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/step-over-trampoline.exp -@@ -0,0 +1,54 @@ +@@ -0,0 +1,59 @@ +# Copyright 2006 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 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 ++} + +if $tracelevel then { + strace $tracelevel diff --git a/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch b/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch deleted file mode 100644 index 557fe6a8d3abb849709ec91652ef85ed0407f414..0000000000000000000000000000000000000000 --- a/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/gdb/symtab.c b/gdb/symtab.c ---- a/gdb/symtab.c -+++ b/gdb/symtab.c -@@ -3166,6 +3166,13 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) - msymbol->linkage_name ()); */ - ; - /* fall through */ -+ /* `msymbol' trampoline may be located before its .text symbol -+ but this text symbol may be the address we were looking for. -+ Avoid `find_pc_sect_line'<->`find_pc_line' infinite loop. -+ Red Hat Bug 218379. */ -+ else if (BMSYMBOL_VALUE_ADDRESS (mfunsym) == pc) -+ warning ("In stub for %s (0x%s); interlocked, please submit the binary to http://bugzilla.redhat.com", msymbol.minsym->linkage_name (), paddress (target_gdbarch (), pc)); -+ /* fall through */ - else - return find_pc_line (BMSYMBOL_VALUE_ADDRESS (mfunsym), 0); - } diff --git a/gdb-6.5-bz243845-stale-testing-zombie-test.patch b/gdb-6.5-bz243845-stale-testing-zombie-test.patch index 8fc7412cf802e0d4a9b526bae3b7e2940799e91c..2d62949ae1a96d56c8adb49b1b2d4a14244b5f8e 100644 --- a/gdb-6.5-bz243845-stale-testing-zombie-test.patch +++ b/gdb-6.5-bz243845-stale-testing-zombie-test.patch @@ -1,27 +1,36 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-bz243845-stale-testing-zombie-test.patch + +;; Test leftover zombie process (BZ 243845). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/tracefork-zombie.exp b/gdb/testsuite/gdb.base/tracefork-zombie.exp new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/tracefork-zombie.exp -@@ -0,0 +1,75 @@ +@@ -0,0 +1,76 @@ +# Copyright 2007 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 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. */ + +# are we on a target board -+if [is_remote target] then { -+ return 0 ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 +} + +# Start the program running and then wait for a bit, to be sure diff --git a/gdb-6.5-gcore-buffer-limit-test.patch b/gdb-6.5-gcore-buffer-limit-test.patch index d8cd495e27e33dfae90e3b0fa0adffbaf563c602..07ba1e97cdf3204d7fce7954544d702155ac15ce 100644 --- a/gdb-6.5-gcore-buffer-limit-test.patch +++ b/gdb-6.5-gcore-buffer-limit-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-gcore-buffer-limit-test.patch + +;; Test gcore memory and time requirements for large inferiors. +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/gcore-excessive-memory.c b/gdb/testsuite/gdb.base/gcore-excessive-memory.c new file mode 100644 --- /dev/null @@ -16,7 +24,7 @@ new file mode 100644 + 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. @@ -32,7 +40,7 @@ new file mode 100644 +int main() +{ + void *mem; -+ ++ + mem = malloc (MEGS * 1024ULL * 1024ULL); + + for (;;) @@ -44,22 +52,27 @@ diff --git a/gdb/testsuite/gdb.base/gcore-excessive-memory.exp b/gdb/testsuite/g new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/gcore-excessive-memory.exp -@@ -0,0 +1,94 @@ +@@ -0,0 +1,99 @@ +# Copyright 2008 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 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 ++} + +set testfile gcore-excessive-memory +set srcfile ${testfile}.c diff --git a/gdb-6.5-ia64-libunwind-leak-test.patch b/gdb-6.5-ia64-libunwind-leak-test.patch index d9393175964f2556f3d0836ef5fe792cbbc2371b..6efdca9ef72fff6b47e67893bcb27bed4ae051ba 100644 --- a/gdb-6.5-ia64-libunwind-leak-test.patch +++ b/gdb-6.5-ia64-libunwind-leak-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-ia64-libunwind-leak-test.patch + +;; Test ia64 memory leaks of the code using libunwind. +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/unwind-leak.c b/gdb/testsuite/gdb.base/unwind-leak.c new file mode 100644 --- /dev/null @@ -16,7 +24,7 @@ new file mode 100644 + 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. @@ -36,22 +44,27 @@ diff --git a/gdb/testsuite/gdb.base/unwind-leak.exp b/gdb/testsuite/gdb.base/unw new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/unwind-leak.exp -@@ -0,0 +1,83 @@ +@@ -0,0 +1,88 @@ +# Copyright 2007 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 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 ++} + +set testfile unwind-leak +set srcfile ${testfile}.c @@ -96,7 +109,7 @@ new file mode 100644 +verbose -log "cycles = $cycles, permit_kb = $permit_kb" + +set fail 0 -+set test "breakpoint stop/continue cycles" ++set test "breakpoint stop/continue cycles" +for {set i $cycles} {$i > 0} {set i [expr {$i - 1}]} { + gdb_test_multiple "continue" $test { + -re "Breakpoint 2, main .*alarm .*.*${gdb_prompt} $" { diff --git a/gdb-6.5-last-address-space-byte-test.patch b/gdb-6.5-last-address-space-byte-test.patch index 005204e71f54ce841327fa2557a5f8c5abcc8a02..e99d81185339a1a2ee7467c91eb9992d1b7efd6e 100644 --- a/gdb-6.5-last-address-space-byte-test.patch +++ b/gdb-6.5-last-address-space-byte-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-last-address-space-byte-test.patch + +;; Testcase for deadlocking on last address space byte; for corrupted backtraces. +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/largecore-last-address-lock.exp b/gdb/testsuite/gdb.base/largecore-last-address-lock.exp new file mode 100644 --- /dev/null @@ -9,15 +17,15 @@ new file mode 100644 +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +if $tracelevel then { + strace $tracelevel diff --git a/gdb-6.5-missed-trap-on-step-test.patch b/gdb-6.5-missed-trap-on-step-test.patch index 82e2291e9be9510f588539562f92c8a42fa07976..0ad8ad1a170ba1a2baa24ac7e248a218943b2fc5 100644 --- a/gdb-6.5-missed-trap-on-step-test.patch +++ b/gdb-6.5-missed-trap-on-step-test.patch @@ -1,3 +1,14 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-missed-trap-on-step-test.patch + +;; Test hiding unexpected breakpoints on intentional step commands. +;;=fedoratest + +Fix has been committed to: + gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch + diff --git a/gdb/testsuite/gdb.base/watchpoint-during-step.c b/gdb/testsuite/gdb.base/watchpoint-during-step.c new file mode 100644 --- /dev/null @@ -16,7 +27,7 @@ new file mode 100644 + 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. @@ -44,15 +55,15 @@ new file mode 100644 +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +set testfile watchpoint-during-step +set srcfile ${testfile}.c diff --git a/gdb-6.5-readline-long-line-crash-test.patch b/gdb-6.5-readline-long-line-crash-test.patch index 51bc7fda9692b62e61204ad9369bf7db7b682a6b..087f9163b7c23cbd66bcfb00a20f07c2ae07f7c9 100644 --- a/gdb-6.5-readline-long-line-crash-test.patch +++ b/gdb-6.5-readline-long-line-crash-test.patch @@ -1,23 +1,33 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-readline-long-line-crash-test.patch + +;; Fix readline segfault on excessively long hand-typed lines. +;;=fedoratest + +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196 + diff --git a/gdb/testsuite/gdb.base/readline-overflow.exp b/gdb/testsuite/gdb.base/readline-overflow.exp new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/readline-overflow.exp -@@ -0,0 +1,104 @@ +@@ -0,0 +1,96 @@ +# Copyright 2006 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 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu @@ -36,20 +46,12 @@ new file mode 100644 + +global env + -+save_vars { env(INPUTRC) env(GDBHISTFILE) env(HISTSIZE) TERM timeout } { ++save_vars { env(GDBHISTFILE) env(HISTSIZE) TERM timeout } { + # The arrow key test relies on the standard VT100 bindings, so + # make sure that an appropriate terminal is selected. The same + # bug doesn't show up if we use ^P / ^N instead. + setenv TERM vt100 + -+ # Don't let a .inputrc file or an existing setting of INPUTRC mess up -+ # the test results. Even if /dev/null doesn't exist on the particular -+ # platform, the readline library will use the default setting just by -+ # failing to open the file. OTOH, opening /dev/null successfully will -+ # also result in the default settings being used since nothing will be -+ # read from this file. -+ set env(INPUTRC) "/dev/null" -+ + set timeout 600 + + set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history" diff --git a/gdb-6.5-section-num-fixup-test.patch b/gdb-6.5-section-num-fixup-test.patch index 22d492020757b938b009d46cd3932be682ec23d1..2fa3995c78206c1da8bec4898dd8792348787d1d 100644 --- a/gdb-6.5-section-num-fixup-test.patch +++ b/gdb-6.5-section-num-fixup-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-section-num-fixup-test.patch + +;; Test a crash on libraries missing the .text section. +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/datalib-lib.c b/gdb/testsuite/gdb.base/datalib-lib.c new file mode 100644 --- /dev/null @@ -16,7 +24,7 @@ new file mode 100644 + 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. @@ -43,7 +51,7 @@ new file mode 100644 + 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. @@ -60,22 +68,27 @@ diff --git a/gdb/testsuite/gdb.base/datalib.exp b/gdb/testsuite/gdb.base/datalib new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/datalib.exp -@@ -0,0 +1,51 @@ +@@ -0,0 +1,56 @@ +# Copyright 2008 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 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 ++} + +set testfile datalib +set srcfilemain ${testfile}-main.c diff --git a/gdb-6.5-sharedlibrary-path.patch b/gdb-6.5-sharedlibrary-path.patch index 4cd88aa7d3be2af4e6af7f328347f3de0c8d1150..360e5d3adcd3a1b3187012495903798d38a573d5 100644 --- a/gdb-6.5-sharedlibrary-path.patch +++ b/gdb-6.5-sharedlibrary-path.patch @@ -1,8 +1,39 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-sharedlibrary-path.patch + +;; Fix TLS symbols resolving for shared libraries with a relative pathname. +;; The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'. +;;=fedoratest: One should recheck if it is really fixed upstream. + +If you provided some relative path to the shared library, such as with + export LD_LIBRARY_PATH=. +then gdb would fail to match the shared library name during the TLS lookup. + +Dropped the workaround/fix for gdb-6.8.50.20081128 - is it still needed? + +The testsuite needs `gdb-6.3-bz146810-solib_absolute_prefix_is_empty.patch'. +The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'. + +2006-09-01 Jan Kratochvil + + * solib-svr4.c (svr4_fetch_objfile_link_map): Match even absolute + requested pathnames to the internal loaded relative pathnames. + +2007-10-16 Jan Kratochvil + + Port to GDB-6.7. + +2008-02-27 Jan Kratochvil + + Port to gdb-6.7.50.20080227. + diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-main.c b/gdb/testsuite/gdb.threads/tls-sepdebug-main.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.threads/tls-sepdebug-main.c -@@ -0,0 +1,25 @@ +@@ -0,0 +1,31 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2006 Free Software Foundation, Inc. @@ -16,7 +47,7 @@ new file mode 100644 + 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. @@ -24,9 +55,15 @@ new file mode 100644 + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + ++#include ++ ++extern __thread int var; ++ +int main() +{ -+ return 0; ++ /* Ensure we link against pthreads even with --as-needed. */ ++ pthread_testcancel(); ++ return var; +} diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c new file mode 100644 @@ -46,7 +83,7 @@ new file mode 100644 + 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. @@ -59,22 +96,29 @@ diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.thre new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp -@@ -0,0 +1,87 @@ +@@ -0,0 +1,94 @@ +# Copyright 2006 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 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# This test uses gdb_exit and gdb_start, which are not supported ++# on non-extended-remote sessions. ++if {[use_gdb_stub]} { ++ untested "skipping test because of stub" ++ return 0 ++} + +if $tracelevel then { + strace $tracelevel @@ -127,22 +171,22 @@ new file mode 100644 + gdb_exit + gdb_start + ###gdb_reinitialize_dir $srcdir/$subdir -+ ++ + gdb_test "set env LD_LIBRARY_PATH=$ld_library_path" \ + "" \ + "set env LD_LIBRARY_PATH is $name" -+ ++ + gdb_load ${binmainfile} -+ ++ + # For C programs, "start" should stop in main(). -+ ++ + gdb_test "start" \ + "main \\(\\) at .*${srcmainfile}.*" \ + "start" -+ ++ + # Check for: Cannot find shared library `/usr/lib/debug/lib/libc-2.4.90.so.debug' in dynamic linker's load module list + # as happens with TLS variables and `separate_debug_objfile_backlink'. -+ ++ + gdb_test "print var" \ + "\\\$1 = \[0-9\].*" \ + "print TLS variable from a shared library with $name-directory separate debug info file" diff --git a/gdb-6.6-buildid-locate-core-as-arg.patch b/gdb-6.6-buildid-locate-core-as-arg.patch deleted file mode 100644 index c24a59c145c10a03de1eaa6027dff1c7c98a02f0..0000000000000000000000000000000000000000 --- a/gdb-6.6-buildid-locate-core-as-arg.patch +++ /dev/null @@ -1,133 +0,0 @@ -diff --git a/gdb/exec.c b/gdb/exec.c ---- a/gdb/exec.c -+++ b/gdb/exec.c -@@ -18,6 +18,8 @@ - along with this program. If not, see . */ - - #include "defs.h" -+#include "arch-utils.h" -+#include "exceptions.h" - #include "frame.h" - #include "inferior.h" - #include "target.h" -@@ -345,12 +347,27 @@ exec_file_attach (const char *filename, int from_tty) - - if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) - { -+ int is_core; -+ -+ /* If the user accidentally did "gdb core", print a useful -+ error message. Check it only after bfd_object has been checked as -+ a valid executable may get recognized for example also as -+ "trad-core". */ -+ is_core = bfd_check_format (exec_bfd, bfd_core); -+ - /* Make sure to close exec_bfd, or else "run" might try to use - it. */ - exec_close (); -- error (_("\"%s\": not in executable format: %s"), -- scratch_pathname, -- gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); -+ -+ if (is_core != 0) -+ throw_error (IS_CORE_ERROR, -+ _("\"%s\" is a core file.\n" -+ "Please specify an executable to debug."), -+ scratch_pathname); -+ else -+ error (_("\"%ss\": not in executable format: %s"), -+ scratch_pathname, -+ gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); - } - - if (build_section_table (exec_bfd, §ions, §ions_end)) -diff --git a/gdb/gdbsupport/common-exceptions.h b/gdb/gdbsupport/common-exceptions.h ---- a/gdb/gdbsupport/common-exceptions.h -+++ b/gdb/gdbsupport/common-exceptions.h -@@ -106,6 +106,9 @@ enum errors { - "_ERROR" is appended to the name. */ - MAX_COMPLETIONS_REACHED_ERROR, - -+ /* Attempt to load a core file as executable. */ -+ IS_CORE_ERROR, -+ - /* Add more errors here. */ - NR_ERRORS - }; -diff --git a/gdb/main.c b/gdb/main.c ---- a/gdb/main.c -+++ b/gdb/main.c -@@ -467,6 +467,34 @@ struct cmdarg - char *string; - }; - -+/* Call exec_file_attach. If it detected FILENAME is a core file call -+ core_file_command. Print the original exec_file_attach error only if -+ core_file_command failed to find a matching executable. */ -+ -+static void -+exec_or_core_file_attach (const char *filename, int from_tty) -+{ -+ gdb_assert (exec_bfd == NULL); -+ -+ try -+ { -+ exec_file_attach (filename, from_tty); -+ } -+ catch (gdb_exception_error &e) -+ { -+ if (e.error == IS_CORE_ERROR) -+ { -+ core_file_command ((char *) filename, from_tty); -+ -+ /* Iff the core file found its executable suppress the error message -+ from exec_file_attach. */ -+ if (exec_bfd != NULL) -+ return; -+ } -+ throw_exception (std::move (e)); -+ } -+} -+ - static void - captured_main_1 (struct captured_main_args *context) - { -@@ -907,6 +935,8 @@ captured_main_1 (struct captured_main_args *context) - { - symarg = argv[optind]; - execarg = argv[optind]; -+ if (optind + 1 == argc && corearg == NULL) -+ corearg = argv[optind]; - optind++; - } - -@@ -1063,12 +1093,25 @@ captured_main_1 (struct captured_main_args *context) - && symarg != NULL - && strcmp (execarg, symarg) == 0) - { -+ catch_command_errors_const_ftype *func; -+ -+ /* Call exec_or_core_file_attach only if the file was specified as -+ a command line argument (and not an a command line option). */ -+ if (corearg != NULL && strcmp (corearg, execarg) == 0) -+ { -+ func = exec_or_core_file_attach; -+ corearg = NULL; -+ } -+ else -+ func = exec_file_attach; -+ - /* The exec file and the symbol-file are the same. If we can't - open it, better only print one error message. -- catch_command_errors returns non-zero on success! */ -- ret = catch_command_errors (exec_file_attach, execarg, -- !batch_flag); -- if (ret != 0) -+ catch_command_errors returns non-zero on success! -+ Do not load EXECARG as a symbol file if it has been already processed -+ as a core file. */ -+ ret = catch_command_errors (func, execarg, !batch_flag); -+ if (ret != 0 && core_bfd == NULL) - ret = catch_command_errors (symbol_file_add_main_adapter, - symarg, !batch_flag); - } diff --git a/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch b/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch index 8b682329c1da68fb84aad7ab74eea3f1955fddad..985cb6a5d99839e96fd0464d5b359a77e49f98c5 100644 --- a/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch +++ b/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch @@ -1,3 +1,30 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: + gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch + +;; Fix 'gdb gives highly misleading error when debuginfo pkg is present, +;; but not corresponding binary pkg' (RH BZ 981154). +;;=push+jan + +Comments by Sergio Durigan Junior : + + This is the fix for RH BZ #981154 + + It is mainly a testcase addition, but a minor fix in the gdb/build-id.c + file was also needed. + + gdb/build-id.c was added by: + + commit dc294be54c96414035eed7d53dafdea0a6f31a72 + Author: Tom Tromey + Date: Tue Oct 8 19:56:15 2013 +0000 + + and had a little thinko there. The variable 'filename' needs to be set to + NULL after it is free'd, otherwise the code below thinks that it is still + valid and doesn't print the necessary warning ("Try: yum install ..."). + diff --git a/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp b/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp new file mode 100644 --- /dev/null diff --git a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch index b9c925f6a085c040479a4d410ee172e9a1e5c73a..c86ec6baf6ff64570a2de97e5ad7cd2aeaa346de 100644 --- a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch +++ b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch @@ -1,7 +1,15 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch + +;; Workaround librpm BZ 643031 due to its unexpected exit() calls (BZ 642879). +;;=push+jan + diff --git a/gdb/build-id.c b/gdb/build-id.c --- a/gdb/build-id.c +++ b/gdb/build-id.c -@@ -709,6 +709,19 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return) +@@ -708,6 +708,19 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return) #include #endif diff --git a/gdb-6.6-buildid-locate-rpm-scl.patch b/gdb-6.6-buildid-locate-rpm-scl.patch index e4583749211cc87b406320c5ad8d5305f935c8b5..1dc3ac48b3f890097055372d833228a5253ba4b7 100644 --- a/gdb-6.6-buildid-locate-rpm-scl.patch +++ b/gdb-6.6-buildid-locate-rpm-scl.patch @@ -1,7 +1,18 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.6-buildid-locate-rpm-scl.patch + +;; [SCL] Skip deprecated .gdb_index warning for Red Hat built files (BZ 953585). +;;=push+jan + +warning: Skipping deprecated .gdb_index section +https://bugzilla.redhat.com/show_bug.cgi?id=953585 + diff --git a/gdb/build-id.c b/gdb/build-id.c --- a/gdb/build-id.c +++ b/gdb/build-id.c -@@ -743,7 +743,11 @@ static int missing_rpm_list_entries; +@@ -742,7 +742,11 @@ static int missing_rpm_list_entries; /* Returns the count of newly added rpms. */ static int @@ -13,7 +24,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c { static int rpm_init_done = 0; rpmts ts; -@@ -850,7 +854,11 @@ missing_rpm_enlist (const char *filename) +@@ -849,7 +853,11 @@ missing_rpm_enlist (const char *filename) mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0); if (mi != NULL) { @@ -25,7 +36,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c { Header h; char *debuginfo, **slot, *s, *s2; -@@ -968,6 +976,37 @@ missing_rpm_enlist (const char *filename) +@@ -967,6 +975,37 @@ missing_rpm_enlist (const char *filename) xfree (debuginfo); count++; } @@ -63,7 +74,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c rpmdbFreeIterator_p (mi); } -@@ -977,6 +1016,20 @@ missing_rpm_enlist (const char *filename) +@@ -976,6 +1015,20 @@ missing_rpm_enlist (const char *filename) return count; } @@ -84,10 +95,10 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c static bool missing_rpm_list_compar (const char *ap, const char *bp) { -diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -3497,6 +3497,16 @@ read_gdb_index_from_buffer (struct objfile *objfile, +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -2801,6 +2801,16 @@ read_gdb_index_from_buffer (const char *filename, "set use-deprecated-index-sections on". */ if (version < 6 && !deprecated_ok) { @@ -104,7 +115,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c static int warning_printed = 0; if (!warning_printed) { -@@ -3508,6 +3518,10 @@ to use the section anyway."), +@@ -2812,6 +2822,10 @@ to use the section anyway."), warning_printed = 1; } return 0; diff --git a/gdb-6.6-buildid-locate-rpm.patch b/gdb-6.6-buildid-locate-rpm.patch index a8477209a4276e0f349ad370a5b801e135f4381f..4693f432d2c5de2945091cf146c3d057c9c47d36 100644 --- a/gdb-6.6-buildid-locate-rpm.patch +++ b/gdb-6.6-buildid-locate-rpm.patch @@ -1,3 +1,10 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.6-buildid-locate-rpm.patch + +;;=push+jan + diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4 --- a/gdb/aclocal.m4 +++ b/gdb/aclocal.m4 @@ -7,7 +14,7 @@ diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4 +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) -+# ++# +# Copyright © 2004 Scott James Remnant . +# +# This program is free software; you can redistribute it and/or modify @@ -126,11 +133,11 @@ diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4 +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then -+ AC_MSG_RESULT([no]) ++ AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` -+ else ++ else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs @@ -147,7 +154,7 @@ diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4 +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then -+ AC_MSG_RESULT([no]) ++ AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full @@ -233,10 +240,10 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c #include "gdbcmd.h" #include "gdbcore.h" +#include "inferior.h" - #include "libbfd.h" #include "objfiles.h" #include "observable.h" -@@ -698,8 +699,374 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return) + #include "symfile.h" +@@ -697,8 +698,374 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return) return result; } @@ -329,7 +336,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c + + /* Already failed the initialization before? */ + if (init_tried) -+ return 0; ++ return 0; + init_tried = 1; + +#ifdef DLOPEN_LIBRPM @@ -612,7 +619,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c avoidance. */ struct missing_filepair -@@ -753,11 +1120,17 @@ missing_filepair_change (void) +@@ -752,11 +1119,17 @@ missing_filepair_change (void) /* All their memory came just from missing_filepair_OBSTACK. */ missing_filepair_hash = NULL; } @@ -630,7 +637,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c missing_filepair_change (); } -@@ -824,14 +1197,38 @@ debug_print_missing (const char *binary, const char *debug) +@@ -823,14 +1196,38 @@ debug_print_missing (const char *binary, const char *debug) *slot = missing_filepair; @@ -679,9 +686,9 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c diff --git a/gdb/config.in b/gdb/config.in --- a/gdb/config.in +++ b/gdb/config.in -@@ -36,6 +36,9 @@ - /* Define to BFD's default target vector. */ - #undef DEFAULT_BFD_VEC +@@ -39,6 +39,9 @@ + /* Handle .ctf type-info sections */ + #undef ENABLE_LIBCTF +/* librpm version specific library name to dlopen. */ +#undef DLOPEN_LIBRPM @@ -689,7 +696,7 @@ diff --git a/gdb/config.in b/gdb/config.in /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS -@@ -245,6 +248,9 @@ +@@ -246,6 +249,9 @@ /* Define if you have the mpfr library. */ #undef HAVE_LIBMPFR @@ -702,7 +709,7 @@ diff --git a/gdb/config.in b/gdb/config.in diff --git a/gdb/configure b/gdb/configure --- a/gdb/configure +++ b/gdb/configure -@@ -761,6 +761,11 @@ CODESIGN_CERT +@@ -771,6 +771,11 @@ PKG_CONFIG HAVE_NATIVE_GCORE_TARGET TARGET_OBS subdirs @@ -714,7 +721,7 @@ diff --git a/gdb/configure b/gdb/configure GDB_DATADIR DEBUGDIR MAKEINFO_EXTRA_FLAGS -@@ -864,6 +869,7 @@ with_gdb_datadir +@@ -876,6 +881,7 @@ with_gdb_datadir with_relocated_sources with_auto_load_dir with_auto_load_safe_path @@ -722,42 +729,34 @@ diff --git a/gdb/configure b/gdb/configure enable_targets enable_64_bit_bfd enable_gdbmi -@@ -926,6 +932,11 @@ CCC - CPP - MAKEINFO - MAKEINFOFLAGS -+PKG_CONFIG -+PKG_CONFIG_PATH -+PKG_CONFIG_LIBDIR +@@ -953,6 +959,8 @@ PKG_CONFIG_PATH + PKG_CONFIG_LIBDIR + DEBUGINFOD_CFLAGS + DEBUGINFOD_LIBS +RPM_CFLAGS +RPM_LIBS YACC YFLAGS XMKMF' -@@ -1598,6 +1609,8 @@ Optional Packages: - [--with-auto-load-dir] - --without-auto-load-safe-path +@@ -1625,6 +1633,8 @@ Optional Packages: do not restrict auto-loaded files locations + --with-debuginfod Enable debuginfo lookups with debuginfod + (auto/yes/no) + --with-rpm query rpm database for missing debuginfos (yes/no, + def. auto=librpm.so) --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets --with-curses use the curses library instead of the termcap library -@@ -1661,6 +1674,13 @@ Some influential environment variables: - MAKEINFO Parent configure detects if it is of sufficient version. - MAKEINFOFLAGS - Parameters for MAKEINFO. -+ PKG_CONFIG path to pkg-config utility -+ PKG_CONFIG_PATH -+ directories to add to pkg-config's search path -+ PKG_CONFIG_LIBDIR -+ path overriding pkg-config's built-in search path +@@ -1705,6 +1715,8 @@ Some influential environment variables: + C compiler flags for DEBUGINFOD, overriding pkg-config + DEBUGINFOD_LIBS + linker flags for DEBUGINFOD, overriding pkg-config + RPM_CFLAGS C compiler flags for RPM, overriding pkg-config + RPM_LIBS linker flags for RPM, overriding pkg-config YACC The `Yet Another Compiler Compiler' implementation to use. Defaults to the first program found out of: `bison -y', `byacc', `yacc'. -@@ -6587,6 +6607,494 @@ _ACEOF +@@ -6616,6 +6628,494 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5 $as_echo "$with_auto_load_safe_path" >&6; } @@ -1149,7 +1148,7 @@ diff --git a/gdb/configure b/gdb/configure + + +if test $pkg_failed = yes; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -1167,7 +1166,7 @@ diff --git a/gdb/configure b/gdb/configure + + HAVE_LIBRPM=false +elif test $pkg_failed = untried; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + HAVE_LIBRPM=false +else @@ -1255,7 +1254,7 @@ diff --git a/gdb/configure b/gdb/configure diff --git a/gdb/configure.ac b/gdb/configure.ac --- a/gdb/configure.ac +++ b/gdb/configure.ac -@@ -144,6 +144,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, +@@ -153,6 +153,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, [Directories safe to hold auto-loaded files.]) AC_MSG_RESULT([$with_auto_load_safe_path]) @@ -1451,7 +1450,7 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac + fi + fi +fi -+ ++ AC_CONFIG_SUBDIRS(testsuite) # Check whether to support alternative target configurations @@ -1459,9 +1458,9 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -41,6 +41,7 @@ - #include "ser-event.h" - #include "gdb_select.h" + #include "gdbsupport/gdb_select.h" #include "gdbsupport/gdb-sigmask.h" + #include "async-event.h" +#include "symfile.h" /* readline include files. */ @@ -1475,7 +1474,7 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c /* Do not call the python hook on an explicit prompt change as passed to this function, as this forms a secondary/local prompt, IE, displayed but not set. */ -@@ -772,7 +775,10 @@ command_line_handler (gdb::unique_xmalloc_ptr &&rl) +@@ -773,7 +776,10 @@ command_line_handler (gdb::unique_xmalloc_ptr &&rl) command_handler (cmd); if (ui->prompt_state != PROMPTED) @@ -1490,12 +1489,11 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c diff --git a/gdb/symfile.h b/gdb/symfile.h --- a/gdb/symfile.h +++ b/gdb/symfile.h -@@ -542,6 +542,8 @@ extern void generic_load (const char *args, int from_tty); +@@ -342,6 +342,7 @@ extern void generic_load (const char *args, int from_tty); /* build-id support. */ extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr); extern void debug_print_missing (const char *binary, const char *debug); +extern void debug_flush_missing (void); -+#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file") - - /* From dwarf2read.c */ + #define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file") + /* From minidebug.c. */ diff --git a/gdb-6.6-buildid-locate-solib-missing-ids.patch b/gdb-6.6-buildid-locate-solib-missing-ids.patch index e34856cd6066ba4de4b00f98785e3f45b4e8b9cf..7dd4fb1688a8dabdaee7b5aaf3b5a711e467c2e0 100644 --- a/gdb-6.6-buildid-locate-solib-missing-ids.patch +++ b/gdb-6.6-buildid-locate-solib-missing-ids.patch @@ -1,7 +1,20 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.6-buildid-locate-solib-missing-ids.patch + +;; Fix loading of core files without build-ids but with build-ids in executables. +;; Load strictly build-id-checked core files only if no executable is specified +;; (Jan Kratochvil, RH BZ 1339862). +;;=push+jan + +gdb returns an incorrect back trace when applying a debuginfo +https://bugzilla.redhat.com/show_bug.cgi?id=1339862 + diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c -@@ -1346,14 +1346,27 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, +@@ -1350,14 +1350,28 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, } { @@ -25,13 +38,14 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c + not do any build-id checking of the libraries. There may be missing + build-ids dumped in the core file and we would map all the libraries + to the only existing file loaded that time - the executable. */ -+ if (symfile_objfile != NULL -+ && (symfile_objfile->flags & OBJF_BUILD_ID_CORE_LOADED) != 0) ++ if (current_program_space->symfile_object_file != NULL ++ && (current_program_space->symfile_object_file->flags ++ & OBJF_BUILD_ID_CORE_LOADED) != 0) + build_id = build_id_addr_get (li->l_ld); if (build_id != NULL) { char *name, *build_id_filename; -@@ -1368,23 +1381,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, +@@ -1372,23 +1386,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, xfree (name); } else @@ -47,8 +61,8 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c - instead) if the on-disk files no longer match the - running program version. */ - -- if (symfile_objfile != NULL -- && (symfile_objfile->flags +- if (current_program_space->symfile_object_file != NULL +- && (current_program_space->symfile_object_file->flags - & OBJF_BUILD_ID_CORE_LOADED) != 0) - newobj->so_name[0] = 0; - } diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch index 86cd307362dfa532b5e986283fba0d331c982998..e9ee3428de30f7f3503445204820ffec50998e80 100644 --- a/gdb-6.6-buildid-locate.patch +++ b/gdb-6.6-buildid-locate.patch @@ -1,7 +1,15 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.6-buildid-locate.patch + +;; New locating of the matching binaries from the pure core file (build-id). +;;=push+jan + diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h -@@ -127,7 +127,7 @@ static inline char * +@@ -115,7 +115,7 @@ static inline char * bfd_strdup (const char *str) { size_t len = strlen (str) + 1; @@ -13,7 +21,7 @@ diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h diff --git a/bfd/libbfd.h b/bfd/libbfd.h --- a/bfd/libbfd.h +++ b/bfd/libbfd.h -@@ -132,7 +132,7 @@ static inline char * +@@ -120,7 +120,7 @@ static inline char * bfd_strdup (const char *str) { size_t len = strlen (str) + 1; @@ -25,7 +33,7 @@ diff --git a/bfd/libbfd.h b/bfd/libbfd.h diff --git a/gdb/build-id.c b/gdb/build-id.c --- a/gdb/build-id.c +++ b/gdb/build-id.c -@@ -24,13 +24,71 @@ +@@ -24,13 +24,70 @@ #include "gdbsupport/gdb_vecs.h" #include "symfile.h" #include "objfiles.h" @@ -38,7 +46,6 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c +#include "gdb_bfd.h" +#include "gdbcmd.h" #include "gdbcore.h" -+#include "libbfd.h" +#include "objfiles.h" +#include "observable.h" +#include "symfile.h" @@ -98,7 +105,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c { if (!bfd_check_format (abfd, bfd_object) && !bfd_check_format (abfd, bfd_core)) -@@ -43,6 +101,348 @@ build_id_bfd_get (bfd *abfd) +@@ -43,6 +100,348 @@ build_id_bfd_get (bfd *abfd) return NULL; } @@ -447,7 +454,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c /* See build-id.h. */ int -@@ -51,7 +451,7 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check) +@@ -51,7 +450,7 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check) const struct bfd_build_id *found; int retval = 0; @@ -456,7 +463,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c if (found == NULL) warning (_("File \"%s\" has no build-id, file skipped"), -@@ -66,56 +466,159 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check) +@@ -66,56 +465,159 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check) return retval; } @@ -533,18 +540,18 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c + /* There can be multiple build-id symlinks pointing to real files + with the same build-id (such as hard links). Some of the real + files may not be installed. */ - -- /* We expect to be silent on the non-existing files. */ -- gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget, -1); ++ + string_appendf (link, ".%u", seqno); + } +- /* We expect to be silent on the non-existing files. */ +- gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget); ++ ret_link = link; + - if (debug_bfd == NULL) - { - if (separate_debug_file_debug) - printf_unfiltered (_(" no, unable to open.\n")); -+ ret_link = link; -+ + struct stat statbuf_trash; + + /* `access' automatically dereferences LINK. */ @@ -567,11 +574,11 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c + + continue; + } - -- return {}; ++ + /* We expect to be silent on the non-existing files. */ + gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget, -1); -+ + +- return {}; + if (debug_bfd == NULL) + { + if (separate_debug_file_debug) @@ -643,7 +650,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c } /* Common code for finding BFDs of a given build-id. This function -@@ -124,7 +627,7 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len, +@@ -124,7 +626,7 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len, static gdb_bfd_ref_ptr build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, @@ -652,7 +659,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c { /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will cause "/.build-id/..." lookups. */ -@@ -147,16 +650,17 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, +@@ -147,16 +649,17 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, if (size > 0) { size--; @@ -673,7 +680,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c if (debug_bfd != NULL) return debug_bfd; -@@ -170,7 +674,8 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, +@@ -170,7 +673,8 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, if (strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) != 0) { link = gdb_sysroot + link; @@ -683,7 +690,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c if (debug_bfd != NULL) return debug_bfd; } -@@ -179,38 +684,208 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, +@@ -179,38 +683,208 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, return {}; } @@ -692,7 +699,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c +{ + gdb_bfd_ref_ptr abfd; + char *result; -+ ++ + abfd = build_id_to_exec_bfd (build_id->size, build_id->data, link_return); + if (abfd == NULL) + return NULL; @@ -883,7 +890,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c + char *build_id_filename_cstr = NULL; gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size, - build_id->data)); -+ build_id->data, ++ build_id->data, + (!build_id_filename_return ? NULL : &build_id_filename_cstr))); + if (build_id_filename_return) + { @@ -899,15 +906,15 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c /* Prevent looping on a stripped .debug file. */ if (abfd != NULL && filename_cmp (bfd_get_filename (abfd.get ()), -@@ -223,3 +898,21 @@ find_separate_debug_file_by_buildid (struct objfile *objfile) +@@ -223,3 +897,22 @@ find_separate_debug_file_by_buildid (struct objfile *objfile) return std::string (); } + -+extern void _initialize_build_id (void); ++void _initialize_build_id (); + +void -+_initialize_build_id (void) ++_initialize_build_id () +{ + add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose, + _("\ @@ -919,7 +926,8 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c + show_build_id_verbose, + &setlist, &showlist); + -+ gdb::observers::executable_changed.attach (debug_print_executable_changed); ++ gdb::observers::executable_changed.attach (debug_print_executable_changed, ++ "build-id"); +} diff --git a/gdb/build-id.h b/gdb/build-id.h --- a/gdb/build-id.h @@ -943,7 +951,7 @@ diff --git a/gdb/build-id.h b/gdb/build-id.h extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len, - const bfd_byte *build_id); + const bfd_byte *build_id, -+ char **link_return); ++ char **link_return = NULL); + +extern char *build_id_to_filename (const struct bfd_build_id *build_id, + char **link_return); @@ -971,9 +979,9 @@ diff --git a/gdb/build-id.h b/gdb/build-id.h diff --git a/gdb/coffread.c b/gdb/coffread.c --- a/gdb/coffread.c +++ b/gdb/coffread.c -@@ -709,7 +709,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) +@@ -710,7 +710,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) /* Try to add separate debug file if no symbols table found. */ - if (!objfile_has_partial_symbols (objfile)) + if (!objfile->has_partial_symbols ()) { - std::string debugfile = find_separate_debug_file_by_buildid (objfile); + std::string debugfile = find_separate_debug_file_by_buildid (objfile, @@ -995,8 +1003,8 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c #include "inferior.h" #include "infrun.h" #include "symtab.h" -@@ -322,6 +326,8 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg) - inferior_ptid = ptid; /* Yes, make it current. */ +@@ -356,6 +360,8 @@ add_to_thread_list (asection *asect, asection *reg_sect) + switch_to_thread (thr); /* Yes, make it current. */ } +static bool build_id_core_loads = true; @@ -1004,7 +1012,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c /* Issue a message saying we have no core to debug, if FROM_TTY. */ static void -@@ -358,19 +364,25 @@ core_file_command (const char *filename, int from_tty) +@@ -392,19 +398,26 @@ core_file_command (const char *filename, int from_tty) static void locate_exec_from_corefile_build_id (bfd *abfd, int from_tty) { @@ -1024,18 +1032,19 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c exec_file_attach (bfd_get_filename (execbfd.get ()), from_tty); symbol_file_add_main (bfd_get_filename (execbfd.get ()), symfile_add_flag (from_tty ? SYMFILE_VERBOSE : 0)); -+ if (symfile_objfile != NULL) -+ symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED; ++ if (current_program_space->symfile_object_file != NULL) ++ current_program_space->symfile_object_file->flags |= ++ OBJF_BUILD_ID_CORE_LOADED; } + else + debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename); } /* See gdbcore.h. */ -@@ -998,4 +1010,11 @@ void - _initialize_corelow (void) - { - add_target (core_target_info, core_target_open, filename_completer); +@@ -1209,4 +1222,11 @@ _initialize_corelow () + maintenance_print_core_file_backed_mappings, + _("Print core file's file-backed mappings."), + &maintenanceprintlist); + + add_setshow_boolean_cmd ("build-id-core-loads", class_files, + &build_id_core_loads, _("\ @@ -1047,7 +1056,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo -@@ -20862,6 +20862,27 @@ information files. +@@ -21415,6 +21415,27 @@ information files. @end table @@ -1075,10 +1084,10 @@ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo @cindex @code{.gnu_debuglink} sections @cindex debug link sections A debug link is a special section of the executable file named -diff --git a/gdb/dwarf-index-cache.c b/gdb/dwarf-index-cache.c ---- a/gdb/dwarf-index-cache.c -+++ b/gdb/dwarf-index-cache.c -@@ -94,7 +94,7 @@ index_cache::store (struct dwarf2_per_objfile *dwarf2_per_objfile) +diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c +--- a/gdb/dwarf2/index-cache.c ++++ b/gdb/dwarf2/index-cache.c +@@ -95,7 +95,7 @@ index_cache::store (dwarf2_per_objfile *per_objfile) return; /* Get build id of objfile. */ @@ -1087,7 +1096,7 @@ diff --git a/gdb/dwarf-index-cache.c b/gdb/dwarf-index-cache.c if (build_id == nullptr) { if (debug_index_cache) -@@ -112,7 +112,8 @@ index_cache::store (struct dwarf2_per_objfile *dwarf2_per_objfile) +@@ -113,7 +113,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile) if (dwz != nullptr) { @@ -1097,28 +1106,19 @@ diff --git a/gdb/dwarf-index-cache.c b/gdb/dwarf-index-cache.c if (dwz_build_id == nullptr) { -diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -2718,7 +2718,7 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile) - } - - if (dwz_bfd == NULL) -- dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid); -+ dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid, NULL); - - if (dwz_bfd == NULL) - error (_("could not find '.gnu_debugaltlink' file for %s"), -@@ -6276,7 +6276,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner) +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -5447,7 +5447,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner) static gdb::array_view - get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_objfile *dwarf2_obj) + get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) { - const bfd_build_id *build_id = build_id_bfd_get (obj->obfd); + const bfd_build_id *build_id = build_id_bfd_shdr_get (obj->obfd); if (build_id == nullptr) return {}; -@@ -6289,7 +6289,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_objfile *dwarf2_obj) +@@ -5460,7 +5460,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) static gdb::array_view get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz) { @@ -1130,7 +1130,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c diff --git a/gdb/elfread.c b/gdb/elfread.c --- a/gdb/elfread.c +++ b/gdb/elfread.c -@@ -1299,7 +1299,9 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) +@@ -1272,7 +1272,9 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) && objfile->separate_debug_objfile == NULL && objfile->separate_debug_objfile_backlink == NULL) { @@ -1141,35 +1141,61 @@ diff --git a/gdb/elfread.c b/gdb/elfread.c if (debugfile.empty ()) debugfile = find_separate_debug_file_by_debuglink (objfile); -@@ -1311,8 +1313,12 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) - symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (), - symfile_flags, objfile); +@@ -1287,7 +1289,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) + else + { + has_dwarf2 = false; +- const struct bfd_build_id *build_id = build_id_bfd_get (objfile->obfd); ++ const struct bfd_build_id *build_id = build_id_bfd_shdr_get (objfile->obfd); + + if (build_id != nullptr) + { +@@ -1312,6 +1314,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) + has_dwarf2 = true; + } + } ++ /* Check if any separate debug info has been extracted out. */ ++ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink") ++ != NULL) ++ debug_print_missing (objfile_name (objfile), build_id_filename.get ()); + } } -- else -- has_dwarf2 = false; -+ /* Check if any separate debug info has been extracted out. */ -+ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink") -+ != NULL) -+ debug_print_missing (objfile_name (objfile), build_id_filename.get ()); -+ else -+ has_dwarf2 = false; } +diff --git a/gdb/exec.c b/gdb/exec.c +--- a/gdb/exec.c ++++ b/gdb/exec.c +@@ -237,7 +237,7 @@ validate_exec_file (int from_tty) + current_exec_file = get_exec_file (0); + + const bfd_build_id *exec_file_build_id +- = build_id_bfd_get (current_program_space->exec_bfd ()); ++ = build_id_bfd_shdr_get (current_program_space->exec_bfd ()); + if (exec_file_build_id != nullptr) + { + /* Prepend the target prefix, to force gdb_bfd_open to open the +@@ -250,7 +250,7 @@ validate_exec_file (int from_tty) + if (abfd != nullptr) + { + const bfd_build_id *target_exec_file_build_id +- = build_id_bfd_get (abfd.get ()); ++ = build_id_bfd_shdr_get (abfd.get ()); - /* Read the CTF section only if there is no DWARF info. */ + if (target_exec_file_build_id != nullptr) + { diff --git a/gdb/objfiles.h b/gdb/objfiles.h --- a/gdb/objfiles.h +++ b/gdb/objfiles.h -@@ -627,6 +627,10 @@ struct objfile - htab_up static_links; +@@ -812,6 +812,10 @@ struct objfile + bool skip_jit_symbol_lookup = false; }; +/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */ + +#define OBJF_BUILD_ID_CORE_LOADED static_cast(1 << 12) + - /* Declarations for functions defined in objfiles.c */ + /* A deleter for objfile. */ - extern struct gdbarch *get_objfile_arch (const struct objfile *); + struct objfile_deleter diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -1202,7 +1228,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c static struct link_map_offsets *svr4_fetch_link_map_offsets (void); static int svr4_have_link_map_offsets (void); -@@ -1344,9 +1345,51 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, +@@ -1348,9 +1349,51 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, continue; } @@ -1244,8 +1270,8 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c + instead) if the on-disk files no longer match the + running program version. */ + -+ if (symfile_objfile != NULL -+ && (symfile_objfile->flags ++ if (current_program_space->symfile_object_file != NULL ++ && (current_program_space->symfile_object_file->flags + & OBJF_BUILD_ID_CORE_LOADED) != 0) + newobj->so_name[0] = 0; + } @@ -1257,12 +1283,24 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c /* If this entry has no name, or its name matches the name for the main executable, don't include it in the list. */ +diff --git a/gdb/source.c b/gdb/source.c +--- a/gdb/source.c ++++ b/gdb/source.c +@@ -1178,7 +1178,7 @@ open_source_file (struct symtab *s) + srcpath += s->filename; + } + +- const struct bfd_build_id *build_id = build_id_bfd_get (ofp->obfd); ++ const struct bfd_build_id *build_id = build_id_bfd_shdr_get (ofp->obfd); + + /* Query debuginfod for the source file. */ + if (build_id != nullptr && !srcpath.empty ()) diff --git a/gdb/symfile.h b/gdb/symfile.h --- a/gdb/symfile.h +++ b/gdb/symfile.h -@@ -532,12 +532,17 @@ void expand_symtabs_matching - void map_symbol_filenames (symbol_filename_ftype *fun, void *data, - int need_fullname); +@@ -332,12 +332,18 @@ bool expand_symtabs_matching + void map_symbol_filenames (gdb::function_view fun, + bool need_fullname); + /* Target-agnostic function to load the sections of an executable into memory. @@ -1274,14 +1312,15 @@ diff --git a/gdb/symfile.h b/gdb/symfile.h +/* build-id support. */ +extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr); +extern void debug_print_missing (const char *binary, const char *debug); ++#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file") + - /* From dwarf2read.c */ + /* From minidebug.c. */ - /* Names for a dwarf2 debugging section. The field NORMAL is the normal + extern gdb_bfd_ref_ptr find_separate_debug_file_in_section (struct objfile *); diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp --- a/gdb/testsuite/gdb.base/corefile.exp +++ b/gdb/testsuite/gdb.base/corefile.exp -@@ -311,3 +311,33 @@ gdb_test_multiple "core-file $corefile" $test { +@@ -343,3 +343,33 @@ gdb_test_multiple "core-file $corefile" $test { pass $test } } @@ -1315,6 +1354,19 @@ diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefi + gdb_test "info files" "Local exec file:\r\n\[ \t\]*`[string_to_regexp $debugdir/$buildid]', file type .*" + pass $wholetest +} +diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp +--- a/gdb/testsuite/gdb.base/gdbinit-history.exp ++++ b/gdb/testsuite/gdb.base/gdbinit-history.exp +@@ -185,7 +185,8 @@ proc test_empty_history_filename { } { + global env + global gdb_prompt + +- set common_history [list "set height 0" "set width 0"] ++ set common_history [list "set height 0" "set width 0" \ ++ "set build-id-verbose 0"] + + set test_dir [standard_output_file history_test] + remote_exec host "mkdir -p $test_dir" diff --git a/gdb/testsuite/gdb.base/new-ui-pending-input.exp b/gdb/testsuite/gdb.base/new-ui-pending-input.exp --- a/gdb/testsuite/gdb.base/new-ui-pending-input.exp +++ b/gdb/testsuite/gdb.base/new-ui-pending-input.exp @@ -1329,7 +1381,17 @@ diff --git a/gdb/testsuite/gdb.base/new-ui-pending-input.exp b/gdb/testsuite/gdb diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp -@@ -1891,6 +1891,17 @@ proc default_gdb_start { } { +@@ -130,7 +130,8 @@ if ![info exists INTERNAL_GDBFLAGS] { + "-nx" \ + "-data-directory $BUILD_DATA_DIRECTORY" \ + {-iex "set height 0"} \ +- {-iex "set width 0"}]] ++ {-iex "set width 0"} \ ++ {-iex "set build-id-verbose 0"}]] + } + + # The variable gdb_prompt is a regexp which matches the gdb prompt. +@@ -2130,6 +2131,17 @@ proc default_gdb_start { } { } } @@ -1350,7 +1412,7 @@ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp -@@ -309,6 +309,16 @@ proc default_mi_gdb_start { args } { +@@ -322,6 +322,16 @@ proc default_mi_gdb_start { args } { warning "Couldn't set the width to 0." } } diff --git a/gdb-6.6-bz229517-gcore-without-terminal.patch b/gdb-6.6-bz229517-gcore-without-terminal.patch index 1b7756eab9a268436190ac7f3644104d80bad283..2c127cc68e40db18da3438230d87d35ece3831cc 100644 --- a/gdb-6.6-bz229517-gcore-without-terminal.patch +++ b/gdb-6.6-bz229517-gcore-without-terminal.patch @@ -1,3 +1,19 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.6-bz229517-gcore-without-terminal.patch + +;; Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517). +;;=fedoratest + +2007-04-22 Jan Kratochvil + + * gdb_gcore.sh: Redirect GDB from ` + + * gdb.base/gcorebg.exp, gdb.base/gcorebg.c: New files. + diff --git a/gdb/testsuite/gdb.base/gcorebg.c b/gdb/testsuite/gdb.base/gcorebg.c new file mode 100644 --- /dev/null @@ -63,15 +79,15 @@ new file mode 100644 +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu diff --git a/gdb-6.6-bz230000-power6-disassembly-test.patch b/gdb-6.6-bz230000-power6-disassembly-test.patch index cf225239ec93a54ee2ada99fd6a1541e4ca050c4..2b361476f7a7340964f9d30b312fd601607dcd71 100644 --- a/gdb-6.6-bz230000-power6-disassembly-test.patch +++ b/gdb-6.6-bz230000-power6-disassembly-test.patch @@ -1,3 +1,17 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.6-bz230000-power6-disassembly-test.patch + +;; Testcase for PPC Power6/DFP instructions disassembly (BZ 230000). +;;=fedoratest + +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=230000 + +The original testcase + https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=230000#c1 +requires too recent GCC. + diff --git a/gdb/testsuite/gdb.arch/powerpc-power6.exp b/gdb/testsuite/gdb.arch/powerpc-power6.exp new file mode 100644 --- /dev/null @@ -17,7 +31,7 @@ new file mode 100644 +# +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Test PowerPC Power6 instructions disassembly. + diff --git a/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch b/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch index b1d405ae29b52335f8094b6848088b86e67c2881..4faef133568b0bf12a6a57da2ebd785a0326f073 100644 --- a/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch +++ b/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch @@ -1,3 +1,16 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch + +;; Support for stepping over PPC atomic instruction sequences (BZ 237572). +;;=fedoratest + +2007-06-25 Jan Kratochvil + + * gdb.threads/atomic-seq-threaded.c, + gdb.threads/atomic-seq-threaded.exp: New files. + diff --git a/gdb/testsuite/gdb.threads/atomic-seq-threaded.c b/gdb/testsuite/gdb.threads/atomic-seq-threaded.c new file mode 100644 --- /dev/null @@ -16,7 +29,7 @@ new file mode 100644 + 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., 51 Franklin Street, Fifth Floor, Boston, @@ -189,12 +202,12 @@ new file mode 100644 +# 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. */ diff --git a/gdb-6.6-testsuite-timeouts.patch b/gdb-6.6-testsuite-timeouts.patch index 9634bec8347d92ab4e1f1948238f710a5ce9bb2e..a89631335b84631a82669e584899215a833e4213 100644 --- a/gdb-6.6-testsuite-timeouts.patch +++ b/gdb-6.6-testsuite-timeouts.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.6-testsuite-timeouts.patch + +;; Avoid too long timeouts on failing cases of "annota1.exp annota3.exp". +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp diff --git a/gdb-6.7-charsign-test.patch b/gdb-6.7-charsign-test.patch index 5a5531692d8e1b30fade8f014fa4c91832d19521..1a663900e7101b00df8ca75d0c90223732ddc226 100644 --- a/gdb-6.7-charsign-test.patch +++ b/gdb-6.7-charsign-test.patch @@ -1,3 +1,23 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.7-charsign-test.patch + +;; Fix displaying of numeric char arrays as strings (BZ 224128). +;;=fedoratest: But it is failing anyway, one should check the behavior more. + +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=224128 + +2007-01-25 Jan Kratochvil + + * gdb.base/charsign.exp, gdb.base/charsign.c: New files. + [ stripped ] + +2007-10-19 Jan Kratochvil + + Port to GDB-6.7 - only the testcase left, patch has been reverted, + char-vectors restricted. + diff --git a/gdb/testsuite/gdb.base/charsign.c b/gdb/testsuite/gdb.base/charsign.c new file mode 100644 --- /dev/null @@ -16,7 +36,7 @@ new file mode 100644 + 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. @@ -51,15 +71,15 @@ new file mode 100644 +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +set testfile charsign +set srcfile ${testfile}.c diff --git a/gdb-6.7-ppc-clobbered-registers-O2-test.patch b/gdb-6.7-ppc-clobbered-registers-O2-test.patch index 832b9499b0ac5a8a9ae98b04d53b3b1468e9966a..08ee2f9f79eb685601bc2deab5e59d60c6781e4a 100644 --- a/gdb-6.7-ppc-clobbered-registers-O2-test.patch +++ b/gdb-6.7-ppc-clobbered-registers-O2-test.patch @@ -1,3 +1,26 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.7-ppc-clobbered-registers-O2-test.patch + +;; Test PPC hiding of call-volatile parameter register. +;;=fedoratest + +2007-11-04 Jan Kratochvil + + * gdb.arch/ppc-clobbered-registers-O2.exp: `powerpc64' changed to + `powerpc*'. + +Testcase for: + +http://sourceware.org/ml/gdb-patches/2007-09/msg00228.html + +2007-10-21 Luis Machado + + * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): New function. + * (rs6000_gdbarch_init): Install ppc_dwarf2_frame_init_reg as + default dwarf2_frame_set_init_reg function. + diff --git a/gdb/testsuite/gdb.arch/ppc-clobbered-registers-O2.c b/gdb/testsuite/gdb.arch/ppc-clobbered-registers-O2.c new file mode 100644 --- /dev/null diff --git a/gdb-6.7-testsuite-stable-results.patch b/gdb-6.7-testsuite-stable-results.patch index 64ef4d34966f29c55596dd0276b75ba40d11c8e4..0eca1a740be05885051dd1591568f32458558ea7 100644 --- a/gdb-6.7-testsuite-stable-results.patch +++ b/gdb-6.7-testsuite-stable-results.patch @@ -1,7 +1,34 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.7-testsuite-stable-results.patch + +;; Testsuite fixes for more stable/comparable results. +;;=fedoratest + +gdb/testsuite/gdb.base/fileio.c: +gdb/testsuite/gdb.base/fileio.exp: +2007-12-08 Jan Kratochvil + + * gdb.base/fileio.c (ROOTSUBDIR): New macro. + (main): CHDIR into ROOTSUBDIR. CHOWN ROOTSUBDIR and CHDIR into + ROOTSUBDIR if we are being run as root. + * gdb.base/fileio.exp: Change the startup and finish cleanup. + Change the test file reference to be into the `fileio.dir' directory. + +sources/gdb/testsuite/gdb.base/dump.exp: +Found on RHEL-5.s390x. + +gdb-6.8.50.20090209/gdb/testsuite/gdb.base/auxv.exp: +random FAIL: gdb.base/auxv.exp: matching auxv data from live and gcore + +gdb-6.8.50.20090209/gdb/testsuite/gdb.base/annota1.exp: +frames-invalid can happen asynchronously. + diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c --- a/gdb/testsuite/gdb.base/fileio.c +++ b/gdb/testsuite/gdb.base/fileio.c -@@ -560,6 +560,28 @@ strerrno (int err) +@@ -559,6 +559,28 @@ strerrno (int err) int main () { diff --git a/gdb-6.8-bz442765-threaded-exec-test.patch b/gdb-6.8-bz442765-threaded-exec-test.patch index a2d3d8f83201c08805f588133e8b906d9f3642f4..90685c7dfbcba8ce5e3a247f1d1ba781f05d707f 100644 --- a/gdb-6.8-bz442765-threaded-exec-test.patch +++ b/gdb-6.8-bz442765-threaded-exec-test.patch @@ -1,3 +1,13 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.8-bz442765-threaded-exec-test.patch + +;; Test various forms of threads tracking across exec() (BZ 442765). +;;=fedoratest + +Test various forms of threads tracking across exec(2). + diff --git a/gdb/testsuite/gdb.threads/threaded-exec.c b/gdb/testsuite/gdb.threads/threaded-exec.c --- a/gdb/testsuite/gdb.threads/threaded-exec.c +++ b/gdb/testsuite/gdb.threads/threaded-exec.c @@ -165,7 +175,7 @@ diff --git a/gdb/testsuite/gdb.threads/threaded-exec.exp b/gdb/testsuite/gdb.thr +gdb_load ${binfile_nothreads} -gdb_run_cmd -+gdb_run_cmd ${binfile_nothreads} ${binfile_threads} 0 ++gdb_run_cmd [list ${binfile_nothreads} ${binfile_threads} 0] gdb_test_multiple {} "Program exited" { -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" { diff --git a/gdb-6.8-bz466901-backtrace-full-prelinked.patch b/gdb-6.8-bz466901-backtrace-full-prelinked.patch index 78725fd0863ad720d230fcfea52af89cea319a14..39d8947589241084ab82bab251edfb343bf0d341 100644 --- a/gdb-6.8-bz466901-backtrace-full-prelinked.patch +++ b/gdb-6.8-bz466901-backtrace-full-prelinked.patch @@ -1,3 +1,13 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.8-bz466901-backtrace-full-prelinked.patch + +;; Fix resolving of variables at locations lists in prelinked libs (BZ 466901). +;;=fedoratest + +Fix resolving of variables at locations lists in prelinked libs (BZ 466901). + diff --git a/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S new file mode 100644 --- /dev/null @@ -373,12 +383,12 @@ new file mode 100644 +# 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. @@ -392,7 +402,7 @@ new file mode 100644 + && ![istarget *-*-elf*] + && ![istarget *-*-openbsd*]) + || (![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"])} { -+ return 0 ++ return 0 +} + +set testfile "dw2-loclist-prelinked" diff --git a/gdb-6.8-quit-never-aborts.patch b/gdb-6.8-quit-never-aborts.patch deleted file mode 100644 index d6e87c65285209d243ee5994e15a1408687499cd..0000000000000000000000000000000000000000 --- a/gdb-6.8-quit-never-aborts.patch +++ /dev/null @@ -1,63 +0,0 @@ -diff --git a/gdb/defs.h b/gdb/defs.h ---- a/gdb/defs.h -+++ b/gdb/defs.h -@@ -168,6 +168,10 @@ extern void default_quit_handler (void); - /* Flag that function quit should call quit_force. */ - extern volatile int sync_quit_force_run; - -+#ifdef NEED_DETACH_SIGSTOP -+extern int quit_flag_cleanup; -+#endif -+ - extern void quit (void); - - /* Helper for the QUIT macro. */ -diff --git a/gdb/extension.c b/gdb/extension.c ---- a/gdb/extension.c -+++ b/gdb/extension.c -@@ -823,6 +823,11 @@ check_quit_flag (void) - int i, result = 0; - const struct extension_language_defn *extlang; - -+#ifdef NEED_DETACH_SIGSTOP -+ if (quit_flag_cleanup) -+ return 0; -+#endif -+ - ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang) - { - if (extlang->ops->check_quit_flag != NULL) -diff --git a/gdb/top.c b/gdb/top.c ---- a/gdb/top.c -+++ b/gdb/top.c -@@ -1703,7 +1703,13 @@ quit_force (int *exit_arg, int from_tty) - - qt.from_tty = from_tty; - -+#ifndef NEED_DETACH_SIGSTOP - /* We want to handle any quit errors and exit regardless. */ -+#else -+ /* We want to handle any quit errors and exit regardless but we should never -+ get user-interrupted to properly detach the inferior. */ -+ quit_flag_cleanup = 1; -+#endif - - /* Get out of tfind mode, and kill or detach all inferiors. */ - try -diff --git a/gdb/utils.c b/gdb/utils.c ---- a/gdb/utils.c -+++ b/gdb/utils.c -@@ -102,6 +102,13 @@ static std::chrono::steady_clock::duration prompt_for_continue_wait_time; - - static bool debug_timestamp = false; - -+#ifdef NEED_DETACH_SIGSTOP -+/* Nonzero means we are already processing the quitting cleanups and we should -+ no longer get aborted. */ -+ -+int quit_flag_cleanup; -+#endif -+ - /* True means that strings with character values >0x7F should be printed - as octal escapes. False means just print the value (e.g. it's an - international character, and the terminal or window can cope.) */ diff --git a/gdb-archer-next-over-throw-cxx-exec.patch b/gdb-archer-next-over-throw-cxx-exec.patch index 9afd7d79f46d101d5a84a4544e0f9d24da8be001..ba71cd3a2da95679fe22bf2ecff1b03e75616f69 100644 --- a/gdb-archer-next-over-throw-cxx-exec.patch +++ b/gdb-archer-next-over-throw-cxx-exec.patch @@ -1,3 +1,14 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-archer-next-over-throw-cxx-exec.patch + +;; Fix follow-exec for C++ programs (bugreported by Martin Stransky). +;;=fedoratest + +Archer-upstreamed: +http://sourceware.org/ml/archer/2010-q2/msg00031.html + diff --git a/gdb/testsuite/gdb.cp/cxxexec.cc b/gdb/testsuite/gdb.cp/cxxexec.cc new file mode 100644 --- /dev/null diff --git a/gdb-archer-pie-addons-keep-disabled.patch b/gdb-archer-pie-addons-keep-disabled.patch deleted file mode 100644 index 0f8a3516aae7bdd178c3731da8c89ab3a1a82c3d..0000000000000000000000000000000000000000 --- a/gdb-archer-pie-addons-keep-disabled.patch +++ /dev/null @@ -1,95 +0,0 @@ -diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c ---- a/gdb/breakpoint.c -+++ b/gdb/breakpoint.c -@@ -15396,6 +15396,51 @@ static struct cmd_list_element *enablebreaklist = NULL; - - cmd_list_element *commands_cmd_element = nullptr; - -+void -+breakpoints_relocate (struct objfile *objfile, struct section_offsets *delta) -+{ -+ struct bp_location *bl, **blp_tmp; -+ int changed = 0; -+ -+ gdb_assert (objfile->separate_debug_objfile_backlink == NULL); -+ -+ ALL_BP_LOCATIONS (bl, blp_tmp) -+ { -+ struct obj_section *osect; -+ -+ /* BL->SECTION can be correctly NULL for breakpoints with multiple -+ locations expanded through symtab. */ -+ -+ ALL_OBJFILE_OSECTIONS (objfile, osect) -+ { -+ CORE_ADDR relocated_address; -+ CORE_ADDR delta_offset; -+ -+ delta_offset = ANOFFSET (delta, osect->the_bfd_section->index); -+ if (delta_offset == 0) -+ continue; -+ relocated_address = bl->address + delta_offset; -+ -+ if (obj_section_addr (osect) <= relocated_address -+ && relocated_address < obj_section_endaddr (osect)) -+ { -+ if (bl->inserted) -+ remove_breakpoint (bl); -+ -+ bl->address += delta_offset; -+ bl->requested_address += delta_offset; -+ -+ changed = 1; -+ } -+ } -+ } -+ -+ if (changed) -+ std::sort (bp_locations, bp_locations + bp_locations_count, -+ bp_location_is_less_than); -+} -+ -+void _initialize_breakpoint (void); - void - _initialize_breakpoint (void) - { -diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h ---- a/gdb/breakpoint.h -+++ b/gdb/breakpoint.h -@@ -1696,6 +1696,9 @@ extern const char *ep_parse_optional_if_clause (const char **arg); - UIOUT iff debugging multiple threads. */ - extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout); - -+extern void breakpoints_relocate (struct objfile *objfile, -+ struct section_offsets *delta); -+ - /* Print the specified breakpoint. */ - extern void print_breakpoint (breakpoint *bp); - -diff --git a/gdb/objfiles.c b/gdb/objfiles.c ---- a/gdb/objfiles.c -+++ b/gdb/objfiles.c -@@ -816,6 +816,11 @@ objfile_relocate1 (struct objfile *objfile, - obj_section_addr (s)); - } - -+ /* Final call of breakpoint_re_set can keep breakpoint locations disabled if -+ their addresses match. */ -+ if (objfile->separate_debug_objfile_backlink == NULL) -+ breakpoints_relocate (objfile, delta); -+ - /* Data changed. */ - return 1; - } -diff --git a/gdb/value.c b/gdb/value.c ---- a/gdb/value.c -+++ b/gdb/value.c -@@ -2840,7 +2840,7 @@ value_static_field (struct type *type, int fieldno) - case FIELD_LOC_KIND_PHYSADDR: - retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno), - TYPE_FIELD_STATIC_PHYSADDR (type, fieldno) -- + (TYPE_OBJFILE (type) == NULL ? 0 : TYPE_OBJFILE (type)->section_offsets[SECT_OFF_TEXT (TYPE_OBJFILE (type))])); -+ + (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type))))); - break; - case FIELD_LOC_KIND_PHYSNAME: - { diff --git a/gdb-archer-pie-addons.patch b/gdb-archer-pie-addons.patch deleted file mode 100644 index 934bb2fd02f057374a8d6f88965bf512aeba7367..0000000000000000000000000000000000000000 --- a/gdb-archer-pie-addons.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h ---- a/gdb/gdbtypes.h -+++ b/gdb/gdbtypes.h -@@ -516,6 +516,7 @@ enum field_loc_kind - { - FIELD_LOC_KIND_BITPOS, /**< bitpos */ - FIELD_LOC_KIND_ENUMVAL, /**< enumval */ -+ /* This address is unrelocated by the objfile's ANOFFSET. */ - FIELD_LOC_KIND_PHYSADDR, /**< physaddr */ - FIELD_LOC_KIND_PHYSNAME, /**< physname */ - FIELD_LOC_KIND_DWARF_BLOCK /**< dwarf_block */ -@@ -566,6 +567,7 @@ union field_location - field. Otherwise, physname is the mangled label of the - static field. */ - -+ /* This address is unrelocated by the objfile's ANOFFSET. */ - CORE_ADDR physaddr; - const char *physname; - -@@ -1474,6 +1476,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); - #define FIELD_ENUMVAL_LVAL(thisfld) ((thisfld).loc.enumval) - #define FIELD_ENUMVAL(thisfld) (FIELD_ENUMVAL_LVAL (thisfld) + 0) - #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname) -+/* This address is unrelocated by the objfile's ANOFFSET. */ - #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr) - #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block) - #define SET_FIELD_BITPOS(thisfld, bitpos) \ -@@ -1485,6 +1488,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); - #define SET_FIELD_PHYSNAME(thisfld, name) \ - (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME, \ - FIELD_STATIC_PHYSNAME (thisfld) = (name)) -+/* This address is unrelocated by the objfile's ANOFFSET. */ - #define SET_FIELD_PHYSADDR(thisfld, addr) \ - (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \ - FIELD_STATIC_PHYSADDR (thisfld) = (addr)) -@@ -1501,6 +1505,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); - #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n)) - #define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL (TYPE_FIELD (thistype, n)) - #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n)) -+/* This address is unrelocated by the objfile's ANOFFSET. */ - #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n)) - #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n)) - #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n)) -diff --git a/gdb/value.c b/gdb/value.c ---- a/gdb/value.c -+++ b/gdb/value.c -@@ -2839,7 +2839,8 @@ value_static_field (struct type *type, int fieldno) - { - case FIELD_LOC_KIND_PHYSADDR: - retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno), -- TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)); -+ TYPE_FIELD_STATIC_PHYSADDR (type, fieldno) -+ + (TYPE_OBJFILE (type) == NULL ? 0 : TYPE_OBJFILE (type)->section_offsets[SECT_OFF_TEXT (TYPE_OBJFILE (type))])); - break; - case FIELD_LOC_KIND_PHYSNAME: - { diff --git a/gdb-archer-vla-tests.patch b/gdb-archer-vla-tests.patch deleted file mode 100644 index 7b9057ae325a1c8c1356c970390238bc233a17c9..0000000000000000000000000000000000000000 --- a/gdb-archer-vla-tests.patch +++ /dev/null @@ -1,3730 +0,0 @@ -diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp ---- a/gdb/testsuite/gdb.ada/packed_array.exp -+++ b/gdb/testsuite/gdb.ada/packed_array.exp -@@ -53,5 +53,11 @@ gdb_test_multiple "$test" "$test" { - # are. Observed with (FSF GNU Ada 4.5.3 20110124). - xfail $test - } -+ -re "= \\(\\)\[\r\n\]+$gdb_prompt $" { -+ # archer-jankratochvil-vla resolves it as a dynamic type resolved as an -+ # empty array [0..-1]. -+ # DW_AT_upper_bound : (DW_OP_fbreg: -48; DW_OP_deref) -+ xfail $test -+ } - } - -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S -@@ -0,0 +1,358 @@ -+ .file "x86_64-vla-pointer.c" -+ .text -+.Ltext0: -+ .globl foo -+ .type foo, @function -+foo: -+.LFB0: -+ .file 1 "gdb.arch/x86_64-vla-pointer.c" -+ # gdb.arch/x86_64-vla-pointer.c:22 -+ .loc 1 22 0 -+ .cfi_startproc -+# BLOCK 2 seq:0 -+# PRED: ENTRY (FALLTHRU) -+ pushq %rbp -+ .cfi_def_cfa_offset 16 -+ .cfi_offset 6, -16 -+ movq %rsp, %rbp -+ .cfi_def_cfa_register 6 -+ pushq %rbx -+ subq $56, %rsp -+ .cfi_offset 3, -24 -+ movl %edi, -52(%rbp) -+ # gdb.arch/x86_64-vla-pointer.c:22 -+ .loc 1 22 0 -+ movq %rsp, %rax -+ movq %rax, %rsi -+ # gdb.arch/x86_64-vla-pointer.c:23 -+ .loc 1 23 0 -+ movl -52(%rbp), %eax -+ movslq %eax, %rdx -+ subq $1, %rdx -+ movq %rdx, -32(%rbp) -+ movslq %eax, %rdx -+ movq %rdx, %r8 -+ movl $0, %r9d -+ # gdb.arch/x86_64-vla-pointer.c:24 -+ .loc 1 24 0 -+ movslq %eax, %rdx -+ movq %rdx, %rcx -+ movl $0, %ebx -+ cltq -+ movl $16, %edx -+ subq $1, %rdx -+ addq %rdx, %rax -+ movl $16, %ebx -+ movl $0, %edx -+ divq %rbx -+ imulq $16, %rax, %rax -+ subq %rax, %rsp -+ movq %rsp, %rax -+ addq $0, %rax -+ movq %rax, -40(%rbp) -+ # gdb.arch/x86_64-vla-pointer.c:27 -+ .loc 1 27 0 -+ movl $0, -20(%rbp) -+# SUCC: 4 [100.0%] -+ jmp .L2 -+# BLOCK 3 seq:1 -+# PRED: 4 -+.L3: -+ # gdb.arch/x86_64-vla-pointer.c:28 -+ .loc 1 28 0 discriminator 3 -+ movl -20(%rbp), %eax -+ movl %eax, %ecx -+ movq -40(%rbp), %rdx -+ movl -20(%rbp), %eax -+ cltq -+ movb %cl, (%rdx,%rax) -+# SUCC: 4 (FALLTHRU,DFS_BACK) -+ # gdb.arch/x86_64-vla-pointer.c:27 -+ .loc 1 27 0 discriminator 3 -+ addl $1, -20(%rbp) -+# BLOCK 4 seq:2 -+# PRED: 3 (FALLTHRU,DFS_BACK) 2 [100.0%] -+.L2: -+ # gdb.arch/x86_64-vla-pointer.c:27 -+ .loc 1 27 0 is_stmt 0 discriminator 1 -+ movl -20(%rbp), %eax -+ cmpl -52(%rbp), %eax -+# SUCC: 3 5 (FALLTHRU) -+ jl .L3 -+# BLOCK 5 seq:3 -+# PRED: 4 (FALLTHRU) -+ # gdb.arch/x86_64-vla-pointer.c:30 -+ .loc 1 30 0 is_stmt 1 -+ movq -40(%rbp), %rax -+ movb $0, (%rax) -+ movq %rsi, %rsp -+ # gdb.arch/x86_64-vla-pointer.c:31 -+ .loc 1 31 0 -+ nop -+ movq -8(%rbp), %rbx -+ leave -+ .cfi_def_cfa 7, 8 -+# SUCC: EXIT [100.0%] -+ ret -+ .cfi_endproc -+.LFE0: -+ .size foo, .-foo -+.Letext0: -+ .section .debug_info,"",@progbits -+.Ldebug_info0: -+ .long 0xa5 # Length of Compilation Unit Info -+ .value 0x4 # DWARF version number -+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section -+ .byte 0x8 # Pointer Size (in bytes) -+ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit) -+ .long .LASF3 # DW_AT_producer: "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g" -+ .byte 0xc # DW_AT_language -+ .long .LASF4 # DW_AT_name: "gdb.arch/x86_64-vla-pointer.c" -+ .long .LASF5 # DW_AT_comp_dir: "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite" -+ .quad .Ltext0 # DW_AT_low_pc -+ .quad .Letext0-.Ltext0 # DW_AT_high_pc -+ .long .Ldebug_line0 # DW_AT_stmt_list -+ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram) -+ # DW_AT_external -+ .ascii "foo\0" # DW_AT_name -+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) -+ .byte 0x15 # DW_AT_decl_line -+ # DW_AT_prototyped -+ .quad .LFB0 # DW_AT_low_pc -+ .quad .LFE0-.LFB0 # DW_AT_high_pc -+ .uleb128 0x1 # DW_AT_frame_base -+ .byte 0x9c # DW_OP_call_frame_cfa -+ # DW_AT_GNU_all_call_sites -+ .long 0x80 # DW_AT_sibling -+ .uleb128 0x3 # (DIE (0x4a) DW_TAG_formal_parameter) -+ .long .LASF6 # DW_AT_name: "size" -+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) -+ .byte 0x15 # DW_AT_decl_line -+ .long 0x80 # DW_AT_type -+ .uleb128 0x3 # DW_AT_location -+ .byte 0x91 # DW_OP_fbreg -+ .sleb128 -68 -+ .uleb128 0x4 # (DIE (0x59) DW_TAG_typedef) -+ .long .LASF7 # DW_AT_name: "array_t" -+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) -+ .byte 0x17 # DW_AT_decl_line -+ .long 0x87 # DW_AT_type -+ .uleb128 0x5 # (DIE (0x64) DW_TAG_variable) -+ .long .LASF0 # DW_AT_name: "array" -+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) -+ .byte 0x18 # DW_AT_decl_line -+ .long 0x59 # DW_AT_type -+ .uleb128 0x3 # DW_AT_location -+ .byte 0x91 # DW_OP_fbreg -+ .sleb128 -56 -+ .byte 0x6 # DW_OP_deref -+ .uleb128 0x6 # (DIE (0x73) DW_TAG_variable) -+ .ascii "i\0" # DW_AT_name -+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) -+ .byte 0x19 # DW_AT_decl_line -+ .long 0x80 # DW_AT_type -+ .uleb128 0x2 # DW_AT_location -+ .byte 0x91 # DW_OP_fbreg -+ .sleb128 -36 -+ .byte 0 # end of children of DIE 0x2d -+ .uleb128 0x7 # (DIE (0x80) DW_TAG_base_type) -+ .byte 0x4 # DW_AT_byte_size -+ .byte 0x5 # DW_AT_encoding -+ .ascii "int\0" # DW_AT_name -+ .uleb128 0x8 # (DIE (0x87) DW_TAG_array_type) -+ .long 0xa1 # DW_AT_type -+ .long 0x9a # DW_AT_sibling -+ .uleb128 0x9 # (DIE (0x90) DW_TAG_subrange_type) -+ .long 0x9a # DW_AT_type -+ .uleb128 0x3 # DW_AT_upper_bound -+ .byte 0x91 # DW_OP_fbreg -+ .sleb128 -48 -+ .byte 0x6 # DW_OP_deref -+ .byte 0 # end of children of DIE 0x87 -+ .uleb128 0xa # (DIE (0x9a) DW_TAG_base_type) -+ .byte 0x8 # DW_AT_byte_size -+ .byte 0x7 # DW_AT_encoding -+ .long .LASF1 # DW_AT_name: "sizetype" -+ .uleb128 0xa # (DIE (0xa1) DW_TAG_base_type) -+ .byte 0x1 # DW_AT_byte_size -+ .byte 0x6 # DW_AT_encoding -+ .long .LASF2 # DW_AT_name: "char" -+ .byte 0 # end of children of DIE 0xb -+ .section .debug_abbrev,"",@progbits -+.Ldebug_abbrev0: -+ .uleb128 0x1 # (abbrev code) -+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit) -+ .byte 0x1 # DW_children_yes -+ .uleb128 0x25 # (DW_AT_producer) -+ .uleb128 0xe # (DW_FORM_strp) -+ .uleb128 0x13 # (DW_AT_language) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3 # (DW_AT_name) -+ .uleb128 0xe # (DW_FORM_strp) -+ .uleb128 0x1b # (DW_AT_comp_dir) -+ .uleb128 0xe # (DW_FORM_strp) -+ .uleb128 0x11 # (DW_AT_low_pc) -+ .uleb128 0x1 # (DW_FORM_addr) -+ .uleb128 0x12 # (DW_AT_high_pc) -+ .uleb128 0x7 # (DW_FORM_data8) -+ .uleb128 0x10 # (DW_AT_stmt_list) -+ .uleb128 0x17 # (DW_FORM_sec_offset) -+ .byte 0 -+ .byte 0 -+ .uleb128 0x2 # (abbrev code) -+ .uleb128 0x2e # (TAG: DW_TAG_subprogram) -+ .byte 0x1 # DW_children_yes -+ .uleb128 0x3f # (DW_AT_external) -+ .uleb128 0x19 # (DW_FORM_flag_present) -+ .uleb128 0x3 # (DW_AT_name) -+ .uleb128 0x8 # (DW_FORM_string) -+ .uleb128 0x3a # (DW_AT_decl_file) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3b # (DW_AT_decl_line) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x27 # (DW_AT_prototyped) -+ .uleb128 0x19 # (DW_FORM_flag_present) -+ .uleb128 0x11 # (DW_AT_low_pc) -+ .uleb128 0x1 # (DW_FORM_addr) -+ .uleb128 0x12 # (DW_AT_high_pc) -+ .uleb128 0x7 # (DW_FORM_data8) -+ .uleb128 0x40 # (DW_AT_frame_base) -+ .uleb128 0x18 # (DW_FORM_exprloc) -+ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites) -+ .uleb128 0x19 # (DW_FORM_flag_present) -+ .uleb128 0x1 # (DW_AT_sibling) -+ .uleb128 0x13 # (DW_FORM_ref4) -+ .byte 0 -+ .byte 0 -+ .uleb128 0x3 # (abbrev code) -+ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter) -+ .byte 0 # DW_children_no -+ .uleb128 0x3 # (DW_AT_name) -+ .uleb128 0xe # (DW_FORM_strp) -+ .uleb128 0x3a # (DW_AT_decl_file) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3b # (DW_AT_decl_line) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x49 # (DW_AT_type) -+ .uleb128 0x13 # (DW_FORM_ref4) -+ .uleb128 0x2 # (DW_AT_location) -+ .uleb128 0x18 # (DW_FORM_exprloc) -+ .byte 0 -+ .byte 0 -+ .uleb128 0x4 # (abbrev code) -+ .uleb128 0x16 # (TAG: DW_TAG_typedef) -+ .byte 0 # DW_children_no -+ .uleb128 0x3 # (DW_AT_name) -+ .uleb128 0xe # (DW_FORM_strp) -+ .uleb128 0x3a # (DW_AT_decl_file) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3b # (DW_AT_decl_line) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x49 # (DW_AT_type) -+ .uleb128 0x13 # (DW_FORM_ref4) -+ .byte 0 -+ .byte 0 -+ .uleb128 0x5 # (abbrev code) -+ .uleb128 0x34 # (TAG: DW_TAG_variable) -+ .byte 0 # DW_children_no -+ .uleb128 0x3 # (DW_AT_name) -+ .uleb128 0xe # (DW_FORM_strp) -+ .uleb128 0x3a # (DW_AT_decl_file) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3b # (DW_AT_decl_line) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x49 # (DW_AT_type) -+ .uleb128 0x13 # (DW_FORM_ref4) -+ .uleb128 0x2 # (DW_AT_location) -+ .uleb128 0x18 # (DW_FORM_exprloc) -+ .byte 0 -+ .byte 0 -+ .uleb128 0x6 # (abbrev code) -+ .uleb128 0x34 # (TAG: DW_TAG_variable) -+ .byte 0 # DW_children_no -+ .uleb128 0x3 # (DW_AT_name) -+ .uleb128 0x8 # (DW_FORM_string) -+ .uleb128 0x3a # (DW_AT_decl_file) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3b # (DW_AT_decl_line) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x49 # (DW_AT_type) -+ .uleb128 0x13 # (DW_FORM_ref4) -+ .uleb128 0x2 # (DW_AT_location) -+ .uleb128 0x18 # (DW_FORM_exprloc) -+ .byte 0 -+ .byte 0 -+ .uleb128 0x7 # (abbrev code) -+ .uleb128 0x24 # (TAG: DW_TAG_base_type) -+ .byte 0 # DW_children_no -+ .uleb128 0xb # (DW_AT_byte_size) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3e # (DW_AT_encoding) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3 # (DW_AT_name) -+ .uleb128 0x8 # (DW_FORM_string) -+ .byte 0 -+ .byte 0 -+ .uleb128 0x8 # (abbrev code) -+ .uleb128 0x1 # (TAG: DW_TAG_array_type) -+ .byte 0x1 # DW_children_yes -+ .uleb128 0x49 # (DW_AT_type) -+ .uleb128 0x13 # (DW_FORM_ref4) -+ .uleb128 0x1 # (DW_AT_sibling) -+ .uleb128 0x13 # (DW_FORM_ref4) -+ .byte 0 -+ .byte 0 -+ .uleb128 0x9 # (abbrev code) -+ .uleb128 0x21 # (TAG: DW_TAG_subrange_type) -+ .byte 0 # DW_children_no -+ .uleb128 0x49 # (DW_AT_type) -+ .uleb128 0x13 # (DW_FORM_ref4) -+ .uleb128 0x2f # (DW_AT_upper_bound) -+ .uleb128 0x18 # (DW_FORM_exprloc) -+ .byte 0 -+ .byte 0 -+ .uleb128 0xa # (abbrev code) -+ .uleb128 0x24 # (TAG: DW_TAG_base_type) -+ .byte 0 # DW_children_no -+ .uleb128 0xb # (DW_AT_byte_size) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3e # (DW_AT_encoding) -+ .uleb128 0xb # (DW_FORM_data1) -+ .uleb128 0x3 # (DW_AT_name) -+ .uleb128 0xe # (DW_FORM_strp) -+ .byte 0 -+ .byte 0 -+ .byte 0 -+ .section .debug_aranges,"",@progbits -+ .long 0x2c # Length of Address Ranges Info -+ .value 0x2 # DWARF Version -+ .long .Ldebug_info0 # Offset of Compilation Unit Info -+ .byte 0x8 # Size of Address -+ .byte 0 # Size of Segment Descriptor -+ .value 0 # Pad to 16 byte boundary -+ .value 0 -+ .quad .Ltext0 # Address -+ .quad .Letext0-.Ltext0 # Length -+ .quad 0 -+ .quad 0 -+ .section .debug_line,"",@progbits -+.Ldebug_line0: -+ .section .debug_str,"MS",@progbits,1 -+.LASF4: -+ .string "gdb.arch/x86_64-vla-pointer.c" -+.LASF7: -+ .string "array_t" -+.LASF3: -+ .string "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g" -+.LASF2: -+ .string "char" -+.LASF1: -+ .string "sizetype" -+.LASF5: -+ .string "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite" -+.LASF6: -+ .string "size" -+.LASF0: -+ .string "array" -+ .ident "GCC: (GNU) 6.2.1 20160916 (Red Hat 6.2.1-2)" -+ .section .note.GNU-stack,"",@progbits -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c -@@ -0,0 +1,45 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 . */ -+ -+#if 0 -+ -+void -+foo (int size) -+{ -+ typedef char array_t[size]; -+ array_t array; -+ int i; -+ -+ for (i = 0; i < size; i++) -+ array[i] = i; -+ -+ array[0] = 0; /* break-here */ -+} -+ -+#else -+ -+void foo (int size); -+ -+int -+main (void) -+{ -+ foo (26); -+ foo (78); -+ return 0; -+} -+ -+#endif -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp -@@ -0,0 +1,65 @@ -+# Copyright 2009 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 . -+ -+if ![istarget "x86_64-*-*"] then { -+ verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64." -+ return -+} -+ -+set testfile x86_64-vla-pointer -+set srcasmfile ${testfile}-foo.S -+set srcfile ${testfile}.c -+set binfile [standard_output_file ${testfile}] -+set binobjfile [standard_output_file ${testfile}-foo.o] -+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] { -+ untested x86_64-vla-pointer -+ return -1 -+} -+ -+gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"] -+ -+gdb_continue_to_breakpoint "break-here" -+ -+gdb_test "whatis array" "type = array_t" "first: whatis array" -+gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "first: whatis array_t" -+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" -+ -+gdb_test "whatis *array" "type = char" "first: whatis *array" -+gdb_test "ptype *array" "type = char" "first: ptype *array" -+ -+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" -+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" -+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" -+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" -+ -+gdb_continue_to_breakpoint "break_here" -+ -+gdb_test "whatis array" "type = array_t" "second: whatis array" -+gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "second: whatis array_t" -+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array" -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S -@@ -0,0 +1,455 @@ -+ .file "x86_64-vla-typedef.c" -+ .section .debug_abbrev,"",@progbits -+.Ldebug_abbrev0: -+ .section .debug_info,"",@progbits -+.Ldebug_info0: -+ .section .debug_line,"",@progbits -+.Ldebug_line0: -+ .text -+.Ltext0: -+.globl foo -+ .type foo, @function -+foo: -+.LFB2: -+ .file 1 "x86_64-vla-typedef.c" -+ .loc 1 22 0 -+ pushq %rbp -+.LCFI0: -+ movq %rsp, %rbp -+.LCFI1: -+ subq $64, %rsp -+.LCFI2: -+ movl %edi, -36(%rbp) -+ .loc 1 22 0 -+ movq %rsp, %rax -+ movq %rax, -48(%rbp) -+ .loc 1 23 0 -+ movl -36(%rbp), %edx -+ movslq %edx,%rax -+ subq $1, %rax -+ movq %rax, -24(%rbp) -+ .loc 1 24 0 -+ movslq %edx,%rax -+ addq $15, %rax -+ addq $15, %rax -+ shrq $4, %rax -+ salq $4, %rax -+ subq %rax, %rsp -+ movq %rsp, -56(%rbp) -+ movq -56(%rbp), %rax -+ addq $15, %rax -+ shrq $4, %rax -+ salq $4, %rax -+ movq %rax, -56(%rbp) -+ movq -56(%rbp), %rax -+ movq %rax, -16(%rbp) -+ .loc 1 27 0 -+ movl $0, -4(%rbp) -+ jmp .L2 -+.L3: -+ .loc 1 28 0 -+ movl -4(%rbp), %esi -+ movl -4(%rbp), %eax -+ movl %eax, %ecx -+ movq -16(%rbp), %rdx -+ movslq %esi,%rax -+ movb %cl, (%rdx,%rax) -+ .loc 1 27 0 -+ addl $1, -4(%rbp) -+.L2: -+ movl -4(%rbp), %eax -+ cmpl -36(%rbp), %eax -+ jl .L3 -+ .loc 1 30 0 -+ .globl break_here -+break_here: -+ movq -16(%rbp), %rax -+ movb $0, (%rax) -+ movq -48(%rbp), %rsp -+ .loc 1 31 0 -+ leave -+ ret -+.LFE2: -+ .size foo, .-foo -+ .section .debug_frame,"",@progbits -+.Lframe0: -+ .long .LECIE0-.LSCIE0 -+.LSCIE0: -+ .long 0xffffffff -+ .byte 0x1 -+ .string "" -+ .uleb128 0x1 -+ .sleb128 -8 -+ .byte 0x10 -+ .byte 0xc -+ .uleb128 0x7 -+ .uleb128 0x8 -+ .byte 0x90 -+ .uleb128 0x1 -+ .align 8 -+.LECIE0: -+.LSFDE0: -+ .long .LEFDE0-.LASFDE0 -+.LASFDE0: -+ .long .Lframe0 -+ .quad .LFB2 -+ .quad .LFE2-.LFB2 -+ .byte 0x4 -+ .long .LCFI0-.LFB2 -+ .byte 0xe -+ .uleb128 0x10 -+ .byte 0x86 -+ .uleb128 0x2 -+ .byte 0x4 -+ .long .LCFI1-.LCFI0 -+ .byte 0xd -+ .uleb128 0x6 -+ .align 8 -+.LEFDE0: -+ .section .eh_frame,"a",@progbits -+.Lframe1: -+ .long .LECIE1-.LSCIE1 -+.LSCIE1: -+ .long 0x0 -+ .byte 0x1 -+ .string "zR" -+ .uleb128 0x1 -+ .sleb128 -8 -+ .byte 0x10 -+ .uleb128 0x1 -+ .byte 0x3 -+ .byte 0xc -+ .uleb128 0x7 -+ .uleb128 0x8 -+ .byte 0x90 -+ .uleb128 0x1 -+ .align 8 -+.LECIE1: -+.LSFDE1: -+ .long .LEFDE1-.LASFDE1 -+.LASFDE1: -+ .long .LASFDE1-.Lframe1 -+ .long .LFB2 -+ .long .LFE2-.LFB2 -+ .uleb128 0x0 -+ .byte 0x4 -+ .long .LCFI0-.LFB2 -+ .byte 0xe -+ .uleb128 0x10 -+ .byte 0x86 -+ .uleb128 0x2 -+ .byte 0x4 -+ .long .LCFI1-.LCFI0 -+ .byte 0xd -+ .uleb128 0x6 -+ .align 8 -+.LEFDE1: -+ .text -+.Letext0: -+ .section .debug_loc,"",@progbits -+.Ldebug_loc0: -+.LLST0: -+ .quad .LFB2-.Ltext0 -+ .quad .LCFI0-.Ltext0 -+ .value 0x2 -+ .byte 0x77 -+ .sleb128 8 -+ .quad .LCFI0-.Ltext0 -+ .quad .LCFI1-.Ltext0 -+ .value 0x2 -+ .byte 0x77 -+ .sleb128 16 -+ .quad .LCFI1-.Ltext0 -+ .quad .LFE2-.Ltext0 -+ .value 0x2 -+ .byte 0x76 -+ .sleb128 16 -+ .quad 0x0 -+ .quad 0x0 -+ .section .debug_info -+ .long .Ldebug_end - .Ldebug_start -+.Ldebug_start: -+ .value 0x2 -+ .long .Ldebug_abbrev0 -+ .byte 0x8 -+ .uleb128 0x1 -+ .long .LASF2 -+ .byte 0x1 -+ .long .LASF3 -+ .long .LASF4 -+ .quad .Ltext0 -+ .quad .Letext0 -+ .long .Ldebug_line0 -+ .uleb128 0x2 -+ .byte 0x1 -+ .string "foo" -+ .byte 0x1 -+ .byte 0x16 -+ .byte 0x1 -+ .quad .LFB2 -+ .quad .LFE2 -+ .long .LLST0 -+ .long 0x83 -+ .uleb128 0x3 -+ .long .LASF5 -+ .byte 0x1 -+ .byte 0x15 -+ .long 0x83 -+ .byte 0x2 -+ .byte 0x91 -+ .sleb128 -52 -+.Ltag_typedef: -+ .uleb128 0x4 -+ .long .LASF6 -+ .byte 0x1 -+ .byte 0x17 -+ .long .Ltag_array_type - .debug_info -+ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ -+ .long .LASF0 -+ .byte 0x1 -+ .byte 0x18 -+#if 1 -+ .long .Ltag_typedef - .debug_info -+#else -+ /* Debugging only: Skip the typedef indirection. */ -+ .long .Ltag_array_type - .debug_info -+#endif -+ /* DW_AT_location: DW_FORM_block1: start */ -+ .byte 0x3 -+ .byte 0x91 -+ .sleb128 -32 -+#if 0 -+ .byte 0x6 /* DW_OP_deref */ -+#else -+ .byte 0x96 /* DW_OP_nop */ -+#endif -+ /* DW_AT_location: DW_FORM_block1: end */ -+ .uleb128 0x6 -+ .string "i" -+ .byte 0x1 -+ .byte 0x19 -+ .long 0x83 -+ .byte 0x2 -+ .byte 0x91 -+ .sleb128 -20 -+ .byte 0x0 -+ .uleb128 0x7 -+ .byte 0x4 -+ .byte 0x5 -+ .string "int" -+.Ltag_array_type: -+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ -+ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */ -+ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */ -+1: /* DW_AT_data_location: DW_FORM_block1: start */ -+ .byte 2f - 3f /* length */ -+3: -+ .byte 0x97 /* DW_OP_push_object_address */ -+ .byte 0x6 /* DW_OP_deref */ -+2: /* DW_AT_data_location: DW_FORM_block1: end */ -+ .uleb128 0x9 -+ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */ -+ .byte 0x3 -+ .byte 0x91 -+ .sleb128 -40 -+ .byte 0x6 -+ .byte 0x0 -+ .uleb128 0xa -+ .byte 0x8 -+ .byte 0x7 -+ .uleb128 0xb -+ .byte 0x1 -+ .byte 0x6 -+ .long .LASF1 -+ .byte 0x0 -+.Ldebug_end: -+ .section .debug_abbrev -+ .uleb128 0x1 -+ .uleb128 0x11 -+ .byte 0x1 -+ .uleb128 0x25 -+ .uleb128 0xe -+ .uleb128 0x13 -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x1b -+ .uleb128 0xe -+ .uleb128 0x11 -+ .uleb128 0x1 -+ .uleb128 0x12 -+ .uleb128 0x1 -+ .uleb128 0x10 -+ .uleb128 0x6 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x2 -+ .uleb128 0x2e -+ .byte 0x1 -+ .uleb128 0x3f -+ .uleb128 0xc -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x27 -+ .uleb128 0xc -+ .uleb128 0x11 -+ .uleb128 0x1 -+ .uleb128 0x12 -+ .uleb128 0x1 -+ .uleb128 0x40 -+ .uleb128 0x6 -+ .uleb128 0x1 -+ .uleb128 0x13 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0x5 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x4 -+ .uleb128 0x16 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x5 -+ .uleb128 0x34 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x6 -+ .uleb128 0x34 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x7 -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ -+ .uleb128 0x1 -+ .byte 0x1 -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x1 /* DW_AT_sibling */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x50 /* DW_AT_data_location */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x9 -+ .uleb128 0x21 -+ .byte 0x0 -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x2f -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0xa -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0xe -+ .byte 0x0 -+ .byte 0x0 -+ .byte 0x0 -+ .section .debug_pubnames,"",@progbits -+ .long 0x16 -+ .value 0x2 -+ .long .Ldebug_info0 -+ .long 0xa8 -+ .long 0x2d -+ .string "foo" -+ .long 0x0 -+ .section .debug_aranges,"",@progbits -+ .long 0x2c -+ .value 0x2 -+ .long .Ldebug_info0 -+ .byte 0x8 -+ .byte 0x0 -+ .value 0x0 -+ .value 0x0 -+ .quad .Ltext0 -+ .quad .Letext0-.Ltext0 -+ .quad 0x0 -+ .quad 0x0 -+ .section .debug_str,"MS",@progbits,1 -+.LASF0: -+ .string "array" -+.LASF5: -+ .string "size" -+.LASF3: -+ .string "x86_64-vla-typedef.c" -+.LASF6: -+ .string "array_t" -+.LASF1: -+ .string "char" -+.LASF4: -+ .string "gdb.arch" -+.LASF2: -+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" -+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" -+ .section .note.GNU-stack,"",@progbits -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c -@@ -0,0 +1,45 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 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 . */ -+ -+#if 0 -+ -+void -+foo (int size) -+{ -+ typedef char array_t[size]; -+ array_t array; -+ int i; -+ -+ for (i = 0; i < size; i++) -+ array[i] = i; -+ -+ array[0] = 0; /* break-here */ -+} -+ -+#else -+ -+void foo (int size); -+ -+int -+main (void) -+{ -+ foo (26); -+ foo (78); -+ return 0; -+} -+ -+#endif -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp -@@ -0,0 +1,64 @@ -+# Copyright 2009 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 . -+ -+# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate. -+ -+if ![istarget "x86_64-*-*"] then { -+ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64." -+ return -+} -+ -+set testfile x86_64-vla-typedef -+set srcasmfile ${testfile}-foo.S -+set srcfile ${testfile}.c -+set binfile [standard_output_file ${testfile}] -+set binobjfile [standard_output_file ${testfile}-foo.o] -+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] { -+ untested x86_64-vla-typedef -+ return -1 -+} -+ -+gdb_breakpoint "break_here" -+ -+gdb_continue_to_breakpoint "break_here" -+ -+gdb_test "whatis array" "type = array_t" "first: whatis array" -+ -+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" -+ -+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" -+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" -+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" -+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" -+ -+gdb_continue_to_breakpoint "break_here" -+ -+gdb_test "whatis array" "type = array_t" "second: whatis array" -+ -+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array" -diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c ---- a/gdb/testsuite/gdb.base/arrayidx.c -+++ b/gdb/testsuite/gdb.base/arrayidx.c -@@ -17,6 +17,13 @@ - - int array[] = {1, 2, 3, 4}; - -+#ifdef __GNUC__ -+struct -+ { -+ int a[0]; -+ } unbound; -+#endif -+ - int - main (void) - { -diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp ---- a/gdb/testsuite/gdb.base/arrayidx.exp -+++ b/gdb/testsuite/gdb.base/arrayidx.exp -@@ -49,4 +49,12 @@ gdb_test "print array" \ - "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \ - "print array with array-indexes on" - -- -+set test "p unbound.a == &unbound.a\[0\]" -+gdb_test_multiple $test $test { -+ -re " = 1\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" { -+ unsupported "$test (no GCC)" -+ } -+} -diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/internal-var-field-address.c -@@ -0,0 +1,20 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 . */ -+ -+struct { -+ int field; -+} staticstruct = { 1 }; -diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp -@@ -0,0 +1,26 @@ -+# Copyright 2009 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 . -+ -+set test internal-var-field-address -+set binfile ${test}.x -+if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "[standard_output_file ${binfile}]" object {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+clean_restart $binfile -+ -+gdb_test {set $varstruct = staticstruct} -+gdb_test {p $varstruct.field} " = 1" -diff --git a/gdb/testsuite/gdb.base/vla-frame.c b/gdb/testsuite/gdb.base/vla-frame.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla-frame.c -@@ -0,0 +1,31 @@ -+/* 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 . */ -+ -+#include -+ -+int -+main (int argc, char **argv) -+{ -+ char s[2 + argc]; -+ void (*f) (char *) = 0; -+ -+ memset (s, 0, sizeof (s)); -+ s[0] = 'X'; -+ -+ f (s); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/vla-frame.exp b/gdb/testsuite/gdb.base/vla-frame.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla-frame.exp -@@ -0,0 +1,38 @@ -+# 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 . -+ -+set testfile vla-frame -+set executable ${testfile} -+ -+if { [prepare_for_testing ${testfile}.exp ${executable}] } { -+ return -1 -+} -+ -+if ![runto_main] { -+ return -1 -+} -+ -+set test "continue" -+gdb_test_multiple $test $test { -+ -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "\r\n$gdb_prompt $" { -+ untested ${testfile}.exp -+ return -+ } -+} -+ -+gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*" -diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla-overflow.c -@@ -0,0 +1,30 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 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 . */ -+ -+#include -+ -+int -+main (int argc, char **argv) -+{ -+ int array[argc]; -+ -+ array[0] = array[0]; -+ -+ abort (); -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla-overflow.exp -@@ -0,0 +1,109 @@ -+# Copyright 2008 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 . -+ -+# We could crash in: -+# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69 -+# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97 -+# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL)); -+# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496 -+# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156 -+# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206 -+# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430 -+# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840 -+# ... -+# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292 -+# ... -+# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273 -+ -+set testfile vla-overflow -+set shfile [standard_output_file ${testfile}-gdb.sh] -+set srcfile ${testfile}.c -+set binfile [standard_output_file ${testfile}] -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+set f [open "|getconf PAGESIZE" "r"] -+gets $f pagesize -+close $f -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+set pid_of_gdb [exp_pid -i [board_info host fileid]] -+ -+if { [runto_main] < 0 } { -+ untested vla-overflow -+ return -1 -+} -+ -+# Get the GDB memory size when we stay at main. -+ -+proc memory_v_pages_get {} { -+ global pid_of_gdb pagesize -+ set fd [open "/proc/$pid_of_gdb/statm"] -+ gets $fd line -+ close $fd -+ # number of pages of virtual memory -+ scan $line "%d" drs -+ return $drs -+} -+ -+set pages_found [memory_v_pages_get] -+ -+# s390x with glibc-debuginfo.s390x installed used approx. 16MB. -+set mb_reserve 40 -+verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve" -+set kb_found [expr $pages_found * $pagesize / 1024] -+set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024] -+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit" -+ -+# Create the ulimit wrapper. -+set f [open $shfile "w"] -+puts $f "#! /bin/sh" -+puts $f "ulimit -v $kb_permit" -+puts $f "exec $GDB \"\$@\"" -+close $f -+remote_exec host "chmod +x $shfile" -+ -+gdb_exit -+set GDBold $GDB -+set GDB "$shfile" -+gdb_start -+set GDB $GDBold -+ -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+set pid_of_gdb [exp_pid -i [board_info host fileid]] -+ -+# Check the size again after the second run. -+# We must not stop in main as it would cache `array' and never crash later. -+ -+gdb_run_cmd -+ -+verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" -+ -+gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()" -+ -+verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" -+ -+# `abort' can get expressed as `*__GI_abort'. -+gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()" -+ -+verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" -diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla.c -@@ -0,0 +1,55 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 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 . */ -+ -+#include -+ -+void -+marker (void) -+{ -+} -+ -+void -+bar (char *a, char *b, char *c, int size) -+{ -+ memset (a, '1', size); -+ memset (b, '2', size); -+ memset (c, '3', 48); -+} -+ -+void -+foo (int size) -+{ -+ char temp1[size]; -+ char temp3[48]; -+ -+ temp1[size - 1] = '\0'; -+ { -+ char temp2[size]; -+ -+ bar (temp1, temp2, temp3, size); -+ -+ marker (); /* break-here */ -+ } -+} -+ -+int -+main (void) -+{ -+ foo (26); -+ foo (78); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla.exp -@@ -0,0 +1,62 @@ -+# Copyright 2008 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 . -+ -+set testfile vla -+set srcfile ${testfile}.c -+set binfile [standard_output_file ${testfile}] -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] { -+ untested vla -+ return -1 -+} -+ -+gdb_breakpoint [gdb_get_line_number "break-here"] -+ -+gdb_continue_to_breakpoint "break-here" -+ -+gdb_test "whatis temp1" "type = char \\\[26\\\]" "first: whatis temp1" -+gdb_test "whatis temp2" "type = char \\\[26\\\]" "first: whatis temp2" -+gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3" -+ -+gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1" -+gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2" -+gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3" -+ -+gdb_test "p temp1" " = '1' " "first: print temp1" -+gdb_test "p temp2" " = '2' " "first: print temp2" -+gdb_test "p temp3" " = '3' " "first: print temp3" -+ -+gdb_continue_to_breakpoint "break-here" -+ -+gdb_test "whatis temp1" "type = char \\\[78\\\]" "second: whatis temp1" -+gdb_test "whatis temp2" "type = char \\\[78\\\]" "second: whatis temp2" -+gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3" -+ -+gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1" -+gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2" -+gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3" -+ -+gdb_test "p temp1" " = '1' " "second: print temp1" -+gdb_test "p temp2" " = '2' " "second: print temp2" -+gdb_test "p temp3" " = '3' " "second: print temp3" -diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/gdb9593.cc -@@ -0,0 +1,180 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008, 2009 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 . -+ */ -+#include -+ -+using namespace std; -+ -+class NextOverThrowDerivates -+{ -+ -+public: -+ -+ -+ // Single throw an exception in this function. -+ void function1() -+ { -+ throw 20; -+ } -+ -+ // Throw an exception in another function. -+ void function2() -+ { -+ function1(); -+ } -+ -+ // Throw an exception in another function, but handle it -+ // locally. -+ void function3 () -+ { -+ { -+ try -+ { -+ function1 (); -+ } -+ catch (...) -+ { -+ cout << "Caught and handled function1 exception" << endl; -+ } -+ } -+ } -+ -+ void rethrow () -+ { -+ try -+ { -+ function1 (); -+ } -+ catch (...) -+ { -+ throw; -+ } -+ } -+ -+ void finish () -+ { -+ // We use this to test that a "finish" here does not end up in -+ // this frame, but in the one above. -+ try -+ { -+ function1 (); -+ } -+ catch (int x) -+ { -+ } -+ function1 (); // marker for until -+ } -+ -+ void until () -+ { -+ function1 (); -+ function1 (); // until here -+ } -+ -+}; -+NextOverThrowDerivates next_cases; -+ -+ -+int main () -+{ -+ try -+ { -+ next_cases.function1 (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ try -+ { -+ next_cases.function2 (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ try -+ { -+ // This is duplicated so we can next over one but step into -+ // another. -+ next_cases.function2 (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ next_cases.function3 (); -+ -+ try -+ { -+ next_cases.rethrow (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ try -+ { -+ // Another duplicate so we can test "finish". -+ next_cases.function2 (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ // Another test for "finish". -+ try -+ { -+ next_cases.finish (); -+ } -+ catch (...) -+ { -+ } -+ -+ // Test of "until". -+ try -+ { -+ next_cases.finish (); -+ } -+ catch (...) -+ { -+ } -+ -+ // Test of "until" with an argument. -+ try -+ { -+ next_cases.until (); -+ } -+ catch (...) -+ { -+ } -+ -+ // Test of "advance". -+ try -+ { -+ next_cases.until (); -+ } -+ catch (...) -+ { -+ } -+} -+ -diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/gdb9593.exp -@@ -0,0 +1,182 @@ -+# Copyright 2008, 2009 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 . -+ -+ -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+if { [skip_cplus_tests] } { continue } -+ -+set testfile "gdb9593" -+set srcfile ${testfile}.cc -+set binfile [standard_output_file $testfile] -+ -+# Create and source the file that provides information about the compiler -+# used to compile the test case. -+if [get_compiler_info "c++"] { -+ untested gdb9593.exp -+ return -1 -+} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { -+ untested gdb9593.exp -+ return -1 -+} -+ -+# Some targets can't do function calls, so don't even bother with this -+# test. -+if [target_info exists gdb,cannot_call_functions] { -+ setup_xfail "*-*-*" 9593 -+ fail "This target can not call functions" -+ continue -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] then { -+ perror "couldn't run to main" -+ continue -+} -+ -+# See whether we have the needed unwinder hooks. -+set ok 1 -+gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" { -+ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" { -+ pass "check for unwinder hook" -+ } -+ -re "No symbol .* in current context.\r\n$gdb_prompt $" { -+ # Pass the test so we don't get bogus fails in the results. -+ pass "check for unwinder hook" -+ set ok 0 -+ } -+} -+if {!$ok} { -+ untested gdb9593.exp -+ return -1 -+} -+ -+# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593 -+ -+gdb_test "next" \ -+ ".*catch (...).*" \ -+ "next over a throw 1" -+ -+gdb_test "next" \ -+ ".*next_cases.function2.*" \ -+ "next past catch 1" -+ -+gdb_test "next" \ -+ ".*catch (...).*" \ -+ "next over a throw 2" -+ -+gdb_test "next" \ -+ ".*next_cases.function2.*" \ -+ "next past catch 2" -+ -+gdb_test "step" \ -+ ".*function1().*" \ -+ "step into function2 1" -+ -+gdb_test "next" \ -+ ".*catch (...).*" \ -+ "next over a throw 3" -+ -+gdb_test "next" \ -+ ".*next_cases.function3.*" \ -+ "next past catch 3" -+ -+gdb_test "next" \ -+ ".*next_cases.rethrow.*" \ -+ "next over a throw 4" -+ -+gdb_test "next" \ -+ ".*catch (...).*" \ -+ "next over a rethrow" -+ -+gdb_test "next" \ -+ ".*next_cases.function2.*" \ -+ "next after a rethrow" -+ -+gdb_test "step" \ -+ ".*function1().*" \ -+ "step into function2 2" -+ -+gdb_test "finish" \ -+ ".*catch (...).*" \ -+ "finish 1" -+ -+gdb_test "next" \ -+ ".*next_cases.finish ().*" \ -+ "next past catch 4" -+ -+gdb_test "step" \ -+ ".*function1 ().*" \ -+ "step into finish method" -+ -+gdb_test "finish" \ -+ ".*catch (...).*" \ -+ "finish 2" -+ -+gdb_test "next" \ -+ ".*next_cases.finish ().*" \ -+ "next past catch 5" -+ -+gdb_test "step" \ -+ ".*function1 ().*" \ -+ "step into finish, for until" -+ -+gdb_test "until" \ -+ ".*function1 ().*" \ -+ "until with no argument 1" -+ -+set line [gdb_get_line_number "marker for until" $testfile.cc] -+ -+gdb_test "until $line" \ -+ ".*function1 ().*" \ -+ "next past catch 6" -+ -+gdb_test "until" \ -+ ".*catch (...).*" \ -+ "until with no argument 2" -+ -+set line [gdb_get_line_number "until here" $testfile.cc] -+ -+gdb_test "next" \ -+ ".*next_cases.until ().*" \ -+ "next past catch 6" -+ -+gdb_test "step" \ -+ ".*function1 ().*" \ -+ "step into until" -+ -+gdb_test "until $line" \ -+ ".*catch (...).*" \ -+ "until-over-throw" -+ -+gdb_test "next" \ -+ ".*next_cases.until ().*" \ -+ "next past catch 7" -+ -+gdb_test "step" \ -+ ".*function1 ().*" \ -+ "step into until, for advance" -+ -+gdb_test "advance $line" \ -+ ".*catch (...).*" \ -+ "advance-over-throw" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S -@@ -0,0 +1,246 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2010 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 . */ -+ -+/* Debug information */ -+ -+/* We will `break *main' at the very first instruction. */ -+#define main_length 1 -+ -+ .section .data -+vardata: -+ /* See DW_OP_lit3 + 1 (0-based). */ -+ .string "seennotseen" -+ -+ .section .debug_info -+.Lcu1_begin: -+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ -+.Lcu1_start: -+ .2byte 2 /* DWARF version number */ -+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ -+ .byte 4 /* Pointer Size (in bytes) */ -+ -+ /* CU die */ -+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ -+ .4byte .Lproducer /* DW_AT_producer */ -+ /* Use C++ to exploit a bug in parsing DW_AT_name "". */ -+ .byte 4 /* DW_AT_language (C++) - */ -+ .4byte main /* DW_AT_low_pc */ -+ .byte main_length /* DW_AT_high_pc */ -+ -+.Larray_type: -+ .uleb128 2 /* Abbrev: DW_TAG_array_type */ -+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ -+ -+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ -+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 0 /* DW_AT_lower_bound */ -+ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */ -+ .byte 0 /* End of children of die */ -+ -+ /* DW_AT_upper_bound is referencing an optimized-out variable. */ -+.Larrayb_type: -+ .uleb128 2 /* Abbrev: DW_TAG_array_type */ -+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ -+ -+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ -+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 0 /* DW_AT_lower_bound */ -+ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */ -+ .byte 0 /* End of children of die */ -+ -+ /* DW_AT_upper_bound is referencing register. */ -+.Larrayreg_type: -+ .uleb128 2 /* Abbrev: DW_TAG_array_type */ -+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ -+ -+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type with block */ -+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 0 /* DW_AT_lower_bound */ -+ .byte 2f - 1f /* DW_AT_upper_bound */ -+1: .byte 0x50 /* DW_OP_reg0 */ -+2: -+ .byte 0 /* End of children of die */ -+ -+.Luint_type: -+ .uleb128 4 /* Abbrev: DW_TAG_base_type */ -+ .4byte .Luint_str /* DW_AT_name */ -+ .byte 4 /* DW_AT_byte_size */ -+ .byte 7 /* DW_AT_encoding */ -+ -+.Lchar_type: -+ .uleb128 4 /* Abbrev: DW_TAG_base_type */ -+ .4byte .Lchar_str /* DW_AT_name */ -+ .byte 1 /* DW_AT_byte_size */ -+ .byte 6 /* DW_AT_encoding */ -+ -+.Llen_var: -+ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */ -+ .byte 1 /* DW_AT_artificial */ -+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ -+ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */ -+ -+ /* optimized-out variable for b_string. */ -+.Llenb_var: -+ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */ -+ .byte 1 /* DW_AT_artificial */ -+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ -+ -+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ -+ .string "a_string" /* DW_AT_name */ -+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 2f - 1f /* DW_AT_location */ -+1: .byte 3 /* DW_OP_addr */ -+ .4byte vardata /* */ -+2: -+ -+ /* DW_AT_upper_bound is referencing an optimized-out variable. */ -+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ -+ .string "b_string" /* DW_AT_name */ -+ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 2f - 1f /* DW_AT_location */ -+1: .byte 3 /* DW_OP_addr */ -+ .4byte vardata /* */ -+2: -+ -+ /* DW_AT_upper_bound is referencing register. */ -+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ -+ .string "reg_string" /* DW_AT_name */ -+ .4byte .Larrayreg_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 2f - 1f /* DW_AT_location */ -+1: .byte 3 /* DW_OP_addr */ -+ .4byte vardata /* */ -+2: -+ -+ .byte 0 /* End of children of CU */ -+.Lcu1_end: -+ -+ .section .debug_loc -+.Lloclist: -+.Llen_loclist: -+ .4byte 0 # Location list begin address -+ .4byte main_length # Location list end address -+ .value 2f-1f # Location expression size -+1: .byte 0x33 # DW_OP_lit3 -+ .byte 0x9f # DW_OP_stack_value -+2: -+ .quad 0x0 # Location list terminator begin (*.LLST2) -+ .quad 0x0 # Location list terminator end (*.LLST2) -+ -+ .section .debug_abbrev -+.Ldebug_abbrev0: -+ .uleb128 1 /* Abbrev code */ -+ .uleb128 0x11 /* DW_TAG_compile_unit */ -+ .byte 0x1 /* has_children */ -+ .uleb128 0x25 /* DW_AT_producer */ -+ .uleb128 0xe /* DW_FORM_strp */ -+ .uleb128 0x13 /* DW_AT_language */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x11 /* DW_AT_low_pc */ -+ .uleb128 0x1 /* DW_FORM_addr */ -+ .uleb128 0x12 /* DW_AT_high_pc */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 2 /* Abbrev code */ -+ .uleb128 0x1 /* TAG: DW_TAG_array_type */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 3 /* Abbrev code */ -+ .uleb128 0x21 /* DW_TAG_subrange_type */ -+ .byte 0x0 /* no children */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x22 /* DW_AT_lower_bound */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x2f /* DW_AT_upper_bound */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 4 /* Abbrev code */ -+ .uleb128 0x24 /* DW_TAG_base_type */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0xe /* DW_FORM_strp */ -+ .uleb128 0xb /* DW_AT_byte_size */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x3e /* DW_AT_encoding */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 5 /* Abbrev code */ -+ .uleb128 0x34 /* DW_TAG_variable */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x34 /* DW_AT_artificial */ -+ .uleb128 0x0c /* DW_FORM_flag */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x02 /* DW_AT_location */ -+ .uleb128 0x06 /* DW_FORM_data4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 6 /* Abbrev code */ -+ .uleb128 0x34 /* DW_TAG_variable */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x2 /* DW_AT_location */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 7 /* Abbrev code */ -+ .uleb128 0x34 /* DW_TAG_variable */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x34 /* DW_AT_artificial */ -+ .uleb128 0x0c /* DW_FORM_flag */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 8 /* Abbrev code */ -+ .uleb128 0x21 /* DW_TAG_subrange_type with block */ -+ .byte 0x0 /* no children */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x22 /* DW_AT_lower_bound */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x2f /* DW_AT_upper_bound */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .byte 0x0 /* Terminator */ -+ -+/* String table */ -+ .section .debug_str -+.Lproducer: -+ .string "GNU C 3.3.3" -+.Lchar_str: -+ .string "char" -+.Luint_str: -+ .string "unsigned int" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp -@@ -0,0 +1,66 @@ -+# Copyright 2010 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 . -+ -+# Test printing variable with dynamic bounds which reference a different -+# (artificial in the GCC case) variable containing loclist as its location. -+# This testcase uses value (not address) of the referenced variable: -+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762 -+ -+# This test can only be run on targets which support DWARF-2 and use gas. -+# For now pick a sampling of likely targets. -+if {![istarget *-*-linux*] -+ && ![istarget *-*-gnu*] -+ && ![istarget *-*-elf*] -+ && ![istarget *-*-openbsd*] -+ && ![istarget arm-*-eabi*] -+ && ![istarget powerpc-*-eabi*]} { -+ return 0 -+} -+ -+set testfile dw2-bound-loclist -+if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } { -+ return -1 -+} -+ -+# Verify it behaves at least as an unbound array without inferior. -+ -+# FIXME: FSF GDB crashes due to !has_stack_frames (). -+# But in practice that should not happen. -+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762 -+#set test "p a_string" -+#gdb_test_multiple $test $test { -+# -re " = 0x\[0-9a-f\]+ \"seennotseen\"\r\n$gdb_prompt $" { -+# pass $test -+# } -+# -re "No registers\\.\r\n$gdb_prompt $" { -+# kfail "vlaregression" $test -+# } -+#} -+# -+#gdb_test "ptype a_string" {type = char \[variable length\]} -+ -+# Not runto_main as dw2-bound-loclist.S handles only the first byte of main. -+if ![runto "*main"] { -+ return -1 -+} -+ -+gdb_test "p a_string" { = "seen"} -+gdb_test "ptype a_string" {type = char \[4\]} -+ -+gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"} -+gdb_test "ptype b_string" {type = char \[\]} -+ -+# The register contains unpredictable value - the array size. -+gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]} -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c -@@ -0,0 +1,42 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2004 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 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. */ -+ -+ -+/* The function `func1' traced into must have debug info on offset > 0; -+ (DW_UNSND (attr)). This is the reason of `func0' existence. */ -+ -+void -+func0(int a, int b) -+{ -+} -+ -+/* `func1' being traced into must have some arguments to dump. */ -+ -+void -+func1(int a, int b) -+{ -+ func0 (a,b); -+} -+ -+int -+main(void) -+{ -+ func1 (1, 2); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp -@@ -0,0 +1,79 @@ -+# Copyright 2006 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 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. -+ -+# Minimal DWARF-2 unit test -+ -+# This test can only be run on targets which support DWARF-2. -+# For now pick a sampling of likely targets. -+if {![istarget *-*-linux*] -+ && ![istarget *-*-gnu*] -+ && ![istarget *-*-elf*] -+ && ![istarget *-*-openbsd*] -+ && ![istarget arm-*-eabi*] -+ && ![istarget powerpc-*-eabi*]} { -+ return 0 -+} -+ -+set testfile "dw2-stripped" -+set srcfile ${testfile}.c -+set binfile [standard_output_file ${testfile}.x] -+ -+remote_exec build "rm -f ${binfile}" -+ -+# get the value of gcc_compiled -+if [get_compiler_info ${binfile}] { -+ return -1 -+} -+ -+# This test can only be run on gcc as we use additional_flags=FIXME -+if {$gcc_compiled == 0} { -+ return 0 -+} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } { -+ return -1 -+} -+ -+remote_exec build "objcopy -R .debug_loc ${binfile}" -+set strip_output [remote_exec build "objdump -h ${binfile}"] -+ -+set test "stripping test file preservation" -+if [ regexp ".debug_info " $strip_output] { -+ pass "$test (.debug_info preserved)" -+} else { -+ fail "$test (.debug_info got also stripped)" -+} -+ -+set test "stripping test file functionality" -+if [ regexp ".debug_loc " $strip_output] { -+ fail "$test (.debug_loc still present)" -+} else { -+ pass "$test (.debug_loc stripped)" -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+# For C programs, "start" should stop in main(). -+ -+gdb_test "start" \ -+ ".*main \\(\\) at .*" \ -+ "start" -+gdb_test "step" \ -+ "func.* \\(.*\\) at .*" \ -+ "step" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S -@@ -0,0 +1,83 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 . */ -+ -+/* Debug information */ -+ -+ .section .debug_info -+.Lcu1_begin: -+ /* CU header */ -+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ -+.Lcu1_start: -+ .2byte 2 /* DWARF Version */ -+ .4byte .Labbrev1_begin /* Offset into abbrev section */ -+ .byte 4 /* Pointer size */ -+ -+ /* CU die */ -+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ -+ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */ -+ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */ -+ .byte 1 /* DW_AT_language (C) */ -+ -+.Ltype_uchar: -+ .uleb128 2 /* Abbrev: DW_TAG_structure_type */ -+ .ascii "some_struct\0" /* DW_AT_name */ -+ -+ .uleb128 3 /* Abbrev: DW_TAG_member */ -+ .ascii "field\0" /* DW_AT_name */ -+ .byte 0 /* DW_AT_data_member_location */ -+ -+ .byte 0 /* End of children of some_struct */ -+ -+ .byte 0 /* End of children of CU */ -+ -+.Lcu1_end: -+ -+/* Abbrev table */ -+ .section .debug_abbrev -+.Labbrev1_begin: -+ .uleb128 1 /* Abbrev code */ -+ .uleb128 0x11 /* DW_TAG_compile_unit */ -+ .byte 1 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x25 /* DW_AT_producer */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x13 /* DW_AT_language */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 2 /* Abbrev code */ -+ .uleb128 0x13 /* DW_TAG_structure_type */ -+ .byte 1 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 3 /* Abbrev code */ -+ .uleb128 0x0d /* DW_TAG_member */ -+ .byte 0 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x38 /* DW_AT_data_member_location */ -+ .uleb128 0x0b /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp -@@ -0,0 +1,37 @@ -+# Copyright 2009 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 . -+ -+# This test can only be run on targets which support DWARF-2 and use gas. -+# For now pick a sampling of likely targets. -+if {![istarget *-*-linux*] -+ && ![istarget *-*-gnu*] -+ && ![istarget *-*-elf*] -+ && ![istarget *-*-openbsd*] -+ && ![istarget arm-*-eabi*] -+ && ![istarget powerpc-*-eabi*]} { -+ return 0 -+} -+ -+set testfile "dw2-struct-member-data-location" -+set srcfile ${testfile}.S -+set binfile ${testfile}.x -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "[standard_output_file ${binfile}]" object {nodebug}] != "" } { -+ return -1 -+} -+ -+clean_restart $binfile -+ -+gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S -@@ -0,0 +1,121 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2012 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 . */ -+ -+/* Debug information */ -+ -+ .section .data -+vardata: -+ .rept 129 -+ .ascii "x" -+ .endr -+ .ascii "UNSEEN\0" -+ -+ .section .debug_info -+.Lcu1_begin: -+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ -+.Lcu1_start: -+ .2byte 2 /* DWARF version number */ -+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ -+ .byte 4 /* Pointer Size (in bytes) */ -+ -+ /* CU die */ -+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ -+ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ -+ .byte 2 /* DW_AT_language (C) - */ -+ -+.Larray_type: -+ .uleb128 2 /* Abbrev: DW_TAG_array_type */ -+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ -+ -+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */ -+ .byte 0 /* DW_AT_lower_bound */ -+ .byte 128 /* DW_AT_upper_bound */ -+ -+ .byte 0 /* End of children of die */ -+ -+.Lchar_type: -+ .uleb128 4 /* Abbrev: DW_TAG_base_type */ -+ .ascii "char\0" /* DW_AT_name */ -+ .byte 1 /* DW_AT_byte_size */ -+ .byte 6 /* DW_AT_encoding */ -+ -+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ -+ .ascii "notype_string\0" /* DW_AT_name */ -+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 2f - 1f /* DW_AT_location */ -+1: .byte 3 /* DW_OP_addr */ -+ .4byte vardata /* */ -+2: -+ -+ .byte 0 /* End of children of CU */ -+.Lcu1_end: -+ -+ .section .debug_abbrev -+.Ldebug_abbrev0: -+ .uleb128 1 /* Abbrev code */ -+ .uleb128 0x11 /* DW_TAG_compile_unit */ -+ .byte 0x1 /* has_children */ -+ .uleb128 0x25 /* DW_AT_producer */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x13 /* DW_AT_language */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 2 /* Abbrev code */ -+ .uleb128 0x1 /* TAG: DW_TAG_array_type */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 4 /* Abbrev code */ -+ .uleb128 0x24 /* DW_TAG_base_type */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0xb /* DW_AT_byte_size */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x3e /* DW_AT_encoding */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 6 /* Abbrev code */ -+ .uleb128 0x34 /* DW_TAG_variable */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x2 /* DW_AT_location */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 8 /* Abbrev code */ -+ .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */ -+ .byte 0x0 /* no children */ -+ .uleb128 0x22 /* DW_AT_lower_bound */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x2f /* DW_AT_upper_bound */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .byte 0x0 /* Terminator */ -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp -@@ -0,0 +1,39 @@ -+# Copyright 2012 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 . -+load_lib dwarf.exp -+ -+# https://bugzilla.redhat.com/show_bug.cgi?id=806920 -+# read_subrange_type reinitialization -+# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without -+# specified DW_AT_type, present only in XLF produced code. -+ -+# This test can only be run on targets which support DWARF-2 and use gas. -+if {![dwarf2_support]} { -+ return 0 -+} -+ -+set testfile dw2-subrange-no-type -+set srcfile ${testfile}.S -+set executable ${testfile}.x -+set binfile [standard_output_file ${executable}] -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { -+ return -1 -+} -+ -+clean_restart $executable -+ -+gdb_test "ptype notype_string" {type = char \[129\]} -+gdb_test "p notype_string" " = 'x' " -diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp -@@ -0,0 +1,42 @@ -+# Copyright 2009 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 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. -+ -+# This file was written by Jan Kratochvil . -+ -+# This file is part of the gdb testsuite. Array element stride must not be -+# specified in the number of elements but in a number of bytes instead. -+# Original problem: -+# (gdb) p c40pt(1) -+# $1 = '0-hello', ' ' -+# (gdb) p c40pt(2) -+# warning: Fortran array stride not divisible by the element size -+ -+set testfile dwarf-stride -+set srcfile ${testfile}.f90 -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { -+ return -1 -+} -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_breakpoint [gdb_get_line_number "break-here"] -+gdb_continue_to_breakpoint "break-here" ".*break-here.*" -+gdb_test "p c40pt(1)" " = '0-hello.*" -+gdb_test "p c40pt(2)" " = '1-hello.*" -diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 -@@ -0,0 +1,40 @@ -+! Copyright 2009 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 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. -+! -+! File written by Alan Matsuoka. -+ -+program repro -+ -+ type small_stride -+ character*40 long_string -+ integer small_pad -+ end type small_stride -+ -+ type(small_stride), dimension (20), target :: unpleasant -+ character*40, pointer, dimension(:):: c40pt -+ -+ integer i -+ -+ do i = 0,19 -+ unpleasant(i+1)%small_pad = i+1 -+ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello' -+ end do -+ -+ c40pt => unpleasant%long_string -+ -+ print *, c40pt ! break-here -+ -+end program repro -diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic.exp -@@ -0,0 +1,154 @@ -+# Copyright 2007 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 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. -+ -+# This file was written by Jan Kratochvil . -+ -+# This file is part of the gdb testsuite. It contains tests for dynamically -+# allocated Fortran arrays. -+# It depends on the GCC dynamic Fortran arrays DWARF support: -+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244 -+ -+set testfile "dynamic" -+set srcfile ${testfile}.f90 -+set binfile [standard_output_file ${testfile}] -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { -+ untested "Couldn't compile ${srcfile}" -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_breakpoint [gdb_get_line_number "varx-init"] -+gdb_continue_to_breakpoint "varx-init" -+ -+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5 -+# Do not: gdb_test "p varx" "\\$\[0-9\]* = " "p varx unallocated" -+# Do not: gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx unallocated" -+# Do not: gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) unallocated" -+# Do not: gdb_test "p varx(1,5,17)=1" {no such vector element \(vector not allocated\)} "p varx(1,5,17)=1 unallocated" -+# Do not: gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) unallocated" -+ -+gdb_breakpoint [gdb_get_line_number "varx-allocated"] -+gdb_continue_to_breakpoint "varx-allocated" -+# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...) -+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4), allocatable \\(6,5:15,17:28\\)" "ptype varx allocated" -+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. -+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated" -+ -+gdb_breakpoint [gdb_get_line_number "varx-filled"] -+gdb_continue_to_breakpoint "varx-filled" -+gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6" -+gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7" -+gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8" -+gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9" -+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5 -+# Do not: gdb_test "p varv" "\\$\[0-9\]* = " "p varv unassociated" -+# Do not: gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv unassociated" -+ -+set test "output varx" -+gdb_test_multiple $test $test { -+ -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" { -+ pass $test -+ } -+} -+ -+gdb_breakpoint [gdb_get_line_number "varv-associated"] -+gdb_continue_to_breakpoint "varv-associated" -+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated" -+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated" -+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. -+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated" -+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4), allocatable \\(6,5:15,17:28\\)" "ptype varx with varv associated" -+# Intel Fortran Compiler 10.1.008 uses the pointer type. -+gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated" -+ -+gdb_breakpoint [gdb_get_line_number "varv-filled"] -+gdb_continue_to_breakpoint "varv-filled" -+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled" -+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled" -+ -+gdb_breakpoint [gdb_get_line_number "varv-deassociated"] -+gdb_continue_to_breakpoint "varv-deassociated" -+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. -+gdb_test "p varv" "\\$\[0-9\]* = (|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated" -+gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv deassociated" -+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated" -+gdb_test "p varv(1,5,17)" {no such vector element \(vector not associated\)} -+gdb_test "ptype varv(1,5,17)" {no such vector element \(vector not associated\)} -+ -+gdb_breakpoint [gdb_get_line_number "varx-deallocated"] -+gdb_continue_to_breakpoint "varx-deallocated" -+gdb_test "p varx" "\\$\[0-9\]* = " "p varx deallocated" -+gdb_test "ptype varx" {type = real\(kind=4\), allocatable \(:,:,:\)} "ptype varx deallocated" -+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated" -+gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) deallocated" -+gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) deallocated" -+ -+gdb_breakpoint [gdb_get_line_number "vary-passed"] -+gdb_continue_to_breakpoint "vary-passed" -+# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...) -+gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)" -+ -+gdb_breakpoint [gdb_get_line_number "vary-filled"] -+gdb_continue_to_breakpoint "vary-filled" -+gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)" -+gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8" -+gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9" -+gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10" -+# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...) -+gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)" -+ -+gdb_breakpoint [gdb_get_line_number "varw-almostfilled"] -+gdb_continue_to_breakpoint "varw-almostfilled" -+gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)" -+gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1" -+# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...) -+gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled" -+# "up" works with GCC but other Fortran compilers may copy the values into the -+# outer function only on the exit of the inner function. -+# We need both variants as depending on the arch we optionally may still be -+# executing the caller line or not after `finish'. -+gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))" -+gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3" -+gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6" -+gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5" -+gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1" -+ -+gdb_breakpoint [gdb_get_line_number "varz-almostfilled"] -+gdb_continue_to_breakpoint "varz-almostfilled" -+# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not. -+gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" -+# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7) -+# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7. -+gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?" -+gdb_test "p varz" "\\$\[0-9\]* = \\(\\)" -+gdb_test "p vart" "\\$\[0-9\]* = \\(\\)" -+gdb_test "p varz(3)" "\\$\[0-9\]* = 4" -+# maps to foo::vary(1,1) -+gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8" -+# maps to foo::vary(2,2) -+gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9" -+# maps to foo::vary(1,3) -+gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10" -diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic.f90 -@@ -0,0 +1,98 @@ -+! Copyright 2007 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 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . -+ -+subroutine baz -+ real, target, allocatable :: varx (:, :, :) -+ real, pointer :: varv (:, :, :) -+ real, target :: varu (1, 2, 3) -+ logical :: l -+ allocate (varx (1:6, 5:15, 17:28)) ! varx-init -+ l = allocated (varx) -+ varx(:, :, :) = 6 ! varx-allocated -+ varx(1, 5, 17) = 7 -+ varx(2, 6, 18) = 8 -+ varx(6, 15, 28) = 9 -+ varv => varx ! varx-filled -+ l = associated (varv) -+ varv(3, 7, 19) = 10 ! varv-associated -+ varv => null () ! varv-filled -+ l = associated (varv) -+ deallocate (varx) ! varv-deassociated -+ l = allocated (varx) -+ varu(:, :, :) = 10 ! varx-deallocated -+ allocate (varv (1:6, 5:15, 17:28)) -+ l = associated (varv) -+ varv(:, :, :) = 6 -+ varv(1, 5, 17) = 7 -+ varv(2, 6, 18) = 8 -+ varv(6, 15, 28) = 9 -+ deallocate (varv) -+ l = associated (varv) -+ varv => varu -+ varv(1, 1, 1) = 6 -+ varv(1, 2, 3) = 7 -+ l = associated (varv) -+end subroutine baz -+subroutine foo (vary, varw) -+ real :: vary (:, :) -+ real :: varw (:, :, :) -+ vary(:, :) = 4 ! vary-passed -+ vary(1, 1) = 8 -+ vary(2, 2) = 9 -+ vary(1, 3) = 10 -+ varw(:, :, :) = 5 ! vary-filled -+ varw(1, 1, 1) = 6 -+ varw(2, 2, 2) = 7 ! varw-almostfilled -+end subroutine foo -+subroutine bar (varz, vart) -+ real :: varz (*) -+ real :: vart (2:11, 7:*) -+ varz(1:3) = 4 -+ varz(2) = 5 ! varz-almostfilled -+ vart(2,7) = vart(2,7) -+end subroutine bar -+program test -+ interface -+ subroutine foo (vary, varw) -+ real :: vary (:, :) -+ real :: varw (:, :, :) -+ end subroutine -+ end interface -+ interface -+ subroutine bar (varz, vart) -+ real :: varz (*) -+ real :: vart (2:11, 7:*) -+ end subroutine -+ end interface -+ real :: x (10, 10), y (5), z(8, 8, 8) -+ x(:,:) = 1 -+ y(:) = 2 -+ z(:,:,:) = 3 -+ call baz -+ call foo (x, z(2:6, 4:7, 6:8)) -+ call bar (y, x) -+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort -+ if (x (1, 3) .ne. 10) call abort -+ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort -+ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort -+ call foo (transpose (x), z) -+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort -+ if (x (3, 1) .ne. 10) call abort -+end -diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/string.exp -@@ -0,0 +1,59 @@ -+# Copyright 2008 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 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. -+ -+# This file was written by Jan Kratochvil . -+ -+# This file is part of the gdb testsuite. It contains tests for Fortran -+# strings with dynamic length. -+ -+set testfile "string" -+set srcfile ${testfile}.f90 -+set binfile [standard_output_file ${testfile}] -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { -+ untested "Couldn't compile ${srcfile}" -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_breakpoint [gdb_get_line_number "var-init"] -+gdb_continue_to_breakpoint "var-init" -+gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)" -+gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)" -+gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)" -+gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)" -+gdb_test "ptype *e" "Attempt to take contents of a non-pointer value." -+gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)" -+gdb_test "p c" "\\$\[0-9\]* = 'c'" -+gdb_test "p d" "\\$\[0-9\]* = 'd '" -+gdb_test "p e" "\\$\[0-9\]* = 'g '" -+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)" -+gdb_test "p *e" "Attempt to take contents of a non-pointer value." -+gdb_test "p *f" "Attempt to take contents of a non-pointer value." -+ -+gdb_breakpoint [gdb_get_line_number "var-finish"] -+gdb_continue_to_breakpoint "var-finish" -+gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set" -+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set" -diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/string.f90 -@@ -0,0 +1,37 @@ -+! Copyright 2008 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 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . -+ -+subroutine foo (e, f) -+ character (len=1) :: c -+ character (len=8) :: d -+ character (len=*) :: e -+ character (len=*) :: f (1:7, 8:10) -+ c = 'c' -+ d = 'd' -+ e = 'e' ! var-init -+ f = 'f' -+ f(1,9) = 'f2' -+ c = 'c' ! var-finish -+end subroutine foo -+ character (len=4) :: g, h (1:7, 8:10) -+ g = 'g' -+ h = 'h' -+ call foo (g, h) -+end -diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/subrange.exp -@@ -0,0 +1,72 @@ -+# 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 . -+ -+if { [skip_fortran_tests] } { return -1 } -+ -+set testfile "subrange" -+set srcfile ${testfile}.f90 -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { -+ return -1 -+} -+ -+if ![runto MAIN__] { -+ perror "Couldn't run to MAIN__" -+ continue -+} -+ -+# Depending on the compiler version being used, the name of the 4-byte integer -+# and real types can be printed differently. For instance, gfortran-4.1 uses -+# "int4" whereas gfortran-4.3 uses "int(kind=4)". -+set int4 "(int4|integer\\(kind=4\\))" -+ -+gdb_breakpoint [gdb_get_line_number "break-static"] -+gdb_continue_to_breakpoint "break-static" ".*break-static.*" -+ -+foreach var {a alloc ptr} { -+ global pf_prefix -+ set old_prefix $pf_prefix -+ lappend pf_prefix "$var:" -+ -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "p $var (2, 2:3)" { = \(22, 32\)} -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "p $var (2:3, 3)" { = \(32, 33\)} -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "p $var (1, 2:)" { = \(21, 31\)} -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "p $var (2, :2)" { = \(12, 22\)} -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "p $var (3, 2:2)" { = \(23\)} -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)" -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "p $var (4, :)" { = \(14, 24, 34\)} -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)} -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)" -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "p $var (:)" "Wrong number of subscripts" -+ setup_kfail "*-*-*" "vlaregression/9999" -+ gdb_test "p $var (:, :, :)" "Wrong number of subscripts" -+ -+ set pf_prefix $old_prefix -+} -+ -+gdb_test_no_output {set $a=a} -+delete_breakpoints -+gdb_unload -+setup_kfail "*-*-*" "vlaregression/9999" -+gdb_test {p $a (3, 2:2)} { = \(23\)} -diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/subrange.f90 -@@ -0,0 +1,28 @@ -+! 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 . -+ -+program test -+ integer, target :: a (4, 3) -+ integer, allocatable :: alloc (:, :) -+ integer, pointer :: ptr (:, :) -+ do 1 i = 1, 4 -+ do 1 j = 1, 3 -+ a (i, j) = j * 10 + i -+1 continue -+ allocate (alloc (4, 3)) -+ alloc = a -+ ptr => a -+ write (*,*) a ! break-static -+end -diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c -@@ -0,0 +1,26 @@ -+/* Copyright 2011 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 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 . */ -+ -+int -+main (int argc, char **argv) -+{ -+ char vla[argc]; -+ -+ vla[0] = 0; /* break-here */ -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp -@@ -0,0 +1,57 @@ -+# 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 . -+ -+load_lib mi-support.exp -+set MIFLAGS "-i=mi2" -+ -+gdb_exit -+if [mi_gdb_start] { -+ continue -+} -+ -+set testfile "mi2-var-stale-type" -+set srcfile ${testfile}.c -+set binfile [standard_output_file ${testfile}] -+if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { -+ return -1 -+} -+ -+mi_delete_breakpoints -+mi_gdb_reinitialize_dir $srcdir/$subdir -+mi_gdb_load ${binfile} -+ -+mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \ -+ {\^done} \ -+ "maintenance set internal-error quit yes" -+ -+mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \ -+ {\^done} \ -+ "maintenance set internal-error corefile yes" -+ -+set line [gdb_get_line_number "break-here"] -+set func "main" -+ -+mi_gdb_test "-break-insert -t $srcfile:$line" \ -+ "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",fullname=\".*\",line=\"$line\",\[^\r\n\]*,original-location=\".*\"\}" \ -+ "breakpoint at $func" -+ -+if { [mi_run_cmd] < 0 } { -+ return -1 -+} -+mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla" -+ -+mi_create_varobj "vla" "vla" "create local variable vla" -+ -+mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *" -diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/array-from-register-func.c -@@ -0,0 +1,22 @@ -+/* This file is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 . */ -+ -+int -+func (int *arr) -+{ -+ return arr[0]; -+} -diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/array-from-register.c -@@ -0,0 +1,28 @@ -+/* This file is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 . */ -+ -+extern int func (int *arr); -+ -+int -+main (void) -+{ -+ int arr[] = { 42 }; -+ -+ func (arr); -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/array-from-register.exp -@@ -0,0 +1,33 @@ -+# Copyright 2009 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 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. -+# -+# This file is part of the gdb testsuite. -+ -+if { [prepare_for_testing array-from-register.exp "array-from-register" \ -+ {array-from-register.c array-from-register-func.c} \ -+ {debug optimize=-O2}] } { -+ return -1 -+} -+ -+if ![runto func] then { -+ return -1 -+} -+ -+gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+" -+ -+# Seen regression: -+# Address requested for identifier "arr" which is in register $rdi -+gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42" -diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/fortran-string.exp -@@ -0,0 +1,39 @@ -+# Copyright 2009 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 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. -+ -+# This file was written by Jan Kratochvil . -+ -+# Test GDB can cope with Fortran strings having their length present in a CPU -+# register. With -O0 the string length is passed on the stack. To make this -+# test meaningful the follow assertion should pass. It is not being checked -+# here as the "_s" symbol is compiler dependent: -+# (gdb) info address _s -+# Symbol "_s" is a variable in register XX. -+ -+set test fortran-string -+set srcfile ${test}.f90 -+if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f90 additional_flags=-O2}] } { -+ return -1 -+} -+ -+if ![runto $srcfile:[gdb_get_line_number "s = s"]] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_test "frame" ".*s='foo'.*" -+gdb_test "ptype s" "type = character\\*3" -+gdb_test "p s" "\\$\[0-9\]* = 'foo'" -diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/fortran-string.f90 -@@ -0,0 +1,28 @@ -+! Copyright 2009 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 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . -+ -+ subroutine f(s) -+ character*(*) s -+ s = s -+ end -+ -+ program main -+ call f ('foo') -+ end -diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pascal/arrays.exp -@@ -0,0 +1,104 @@ -+# Copyright 2008, 2009 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 . -+ -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+load_lib "pascal.exp" -+ -+set testfile "arrays" -+set srcfile ${testfile}.pas -+set binfile [standard_output_file ${testfile}$EXEEXT] -+ -+# These tests only work with fpc, using the -gw3 compile-option -+pascal_init -+if { $pascal_compiler_is_fpc != 1 } { -+ return -1 -+} -+ -+# Detect if the fpc version is below 2.3.0 -+set fpc_generates_dwarf_for_dynamic_arrays 1 -+if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} { -+ set fpc_generates_dwarf_for_dynamic_arrays 0 -+} -+ -+ -+if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } { -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] -+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] -+ -+ -+if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { -+ pass "setting breakpoint 1" -+} -+if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { -+ pass "setting breakpoint 2" -+} -+ -+# Verify that "start" lands inside the right procedure. -+if { [gdb_start_cmd] < 0 } { -+ untested start -+ return -1 -+} -+ -+gdb_test "" ".* at .*${srcfile}.*" "start" -+ -+gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" -+ -+gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type" -+gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer" -+ -+gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint" -+ -+gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char" -+gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type" -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char" -+ -diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.pascal/arrays.pas -@@ -0,0 +1,82 @@ -+{ -+ Copyright 2008, 2009 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 . -+} -+ -+program arrays; -+ -+{$mode objfpc}{$h+} -+ -+uses sysutils; -+ -+type TStatArrInt= array[0..11] of integer; -+ TDynArrInt= array of integer; -+ TStatArrStr= array[0..12] of string; -+ TDynArrStr= array of string; -+ TDynArrChar = array of char; -+ TStatArrChar = array [0..11] of char; -+ -+ TStat2dArrInt = array[0..11,0..4] of integer; -+ -+var StatArrInt: TStatArrInt; -+ StatArrInt_: Array[0..11] of integer; -+ DynArrInt: TDynArrInt; -+ DynArrInt_: Array of integer; -+ StatArrStr: TStatArrStr; -+ DynArrStr: TDynArrStr; -+ StatArrChar: TStatArrChar; -+ DynArrChar: TDynArrChar; -+ -+ Stat2dArrInt: TStat2dArrInt; -+ -+ s: string; -+ -+ i,j : integer; -+ -+begin -+ for i := 0 to 11 do -+ begin -+ StatArrInt[i]:= i+50; -+ StatArrInt_[i]:= i+50; -+ StatArrChar[i]:= chr(ord('a')+i); -+ for j := 0 to 4 do -+ Stat2dArrInt[i,j]:=i+j; -+ end; -+ writeln(StatArrInt_[0]); -+ writeln(StatArrInt[0]); { set breakpoint 1 here } -+ writeln(StatArrChar[0]); -+ writeln(Stat2dArrInt[0,0]); -+ -+ setlength(DynArrInt,13); -+ setlength(DynArrInt_,13); -+ setlength(DynArrStr,13); -+ setlength(DynArrChar,13); -+ for i := 0 to 12 do -+ begin -+ DynArrInt[i]:= i+50; -+ DynArrInt_[i]:= i+50; -+ DynArrChar[i]:= chr(ord('a')+i); -+ StatArrStr[i]:='str'+inttostr(i); -+ DynArrStr[i]:='dstr'+inttostr(i); -+ end; -+ writeln(DynArrInt_[1]); -+ writeln(DynArrInt[1]); -+ writeln(DynArrStr[1]); -+ writeln(StatArrStr[1]); -+ writeln(DynArrChar[1]); -+ -+ s := 'test'#0'string'; -+ writeln(s); { set breakpoint 2 here } -+end. -diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp ---- a/gdb/testsuite/lib/gdb.exp -+++ b/gdb/testsuite/lib/gdb.exp -@@ -170,6 +170,11 @@ proc gdb_unload {} { - send_gdb "y\n" answer - exp_continue - } -+ -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\ -+ { send_gdb "y\n" -+ verbose "\t\tUnloading symbols for program being debugged" -+ exp_continue -+ } - -re "Discard symbol table from .*y or n.*$" { - send_gdb "y\n" answer - exp_continue -diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp ---- a/gdb/testsuite/lib/pascal.exp -+++ b/gdb/testsuite/lib/pascal.exp -@@ -37,6 +37,9 @@ proc pascal_init {} { - global pascal_compiler_is_fpc - global gpc_compiler - global fpc_compiler -+ global fpcversion_major -+ global fpcversion_minor -+ global fpcversion_release - global env - - if { $pascal_init_done == 1 } { -@@ -64,6 +67,20 @@ proc pascal_init {} { - set pascal_compiler_is_fpc 1 - verbose -log "Free Pascal compiler found" - } -+ -+ # Detect the fpc-version -+ if { $pascal_compiler_is_fpc == 1 } { -+ set fpcversion_major 1 -+ set fpcversion_minor 0 -+ set fpcversion_release 0 -+ set fpcversion [ remote_exec host $fpc_compiler "-iV" ] -+ if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] { -+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major -+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor -+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release -+ } -+ verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release" -+ } - } - set pascal_init_done 1 - } diff --git a/gdb-archer.patch b/gdb-archer.patch deleted file mode 100644 index e457fbfd735ff56a4ae16d20963b647e4408a856..0000000000000000000000000000000000000000 --- a/gdb-archer.patch +++ /dev/null @@ -1,171 +0,0 @@ -diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in ---- a/gdb/data-directory/Makefile.in -+++ b/gdb/data-directory/Makefile.in -@@ -80,6 +80,7 @@ PYTHON_FILE_LIST = \ - gdb/unwinder.py \ - gdb/xmethod.py \ - gdb/command/__init__.py \ -+ gdb/command/ignore_errors.py \ - gdb/command/explore.py \ - gdb/command/backtrace.py \ - gdb/command/frame_filters.py \ -@@ -92,6 +93,7 @@ PYTHON_FILE_LIST = \ - gdb/function/as_string.py \ - gdb/function/caller_is.py \ - gdb/function/strfns.py \ -+ gdb/function/in_scope.py \ - gdb/printer/__init__.py \ - gdb/printer/bound_registers.py - -diff --git a/gdb/gdb-gdb.gdb.in b/gdb/gdb-gdb.gdb.in ---- a/gdb/gdb-gdb.gdb.in -+++ b/gdb/gdb-gdb.gdb.in -@@ -1,5 +1,15 @@ - echo Setting up the environment for debugging gdb.\n - -+# Set up the Python library and "require" command. -+python -+from os.path import abspath -+gdb.datadir = abspath ('@srcdir@/python/lib') -+gdb.pythonlibdir = gdb.datadir -+gdb.__path__ = [gdb.datadir + '/gdb'] -+sys.path.insert(0, gdb.datadir) -+end -+source @srcdir@/python/lib/gdb/__init__.py -+ - if !$gdb_init_done - set variable $gdb_init_done = 1 - -diff --git a/gdb/python/lib/gdb/command/ignore_errors.py b/gdb/python/lib/gdb/command/ignore_errors.py -new file mode 100644 ---- /dev/null -+++ b/gdb/python/lib/gdb/command/ignore_errors.py -@@ -0,0 +1,37 @@ -+# Ignore errors in user commands. -+ -+# Copyright (C) 2008 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 . -+ -+import gdb -+ -+class IgnoreErrorsCommand (gdb.Command): -+ """Execute a single command, ignoring all errors. -+Only one-line commands are supported. -+This is primarily useful in scripts.""" -+ -+ def __init__ (self): -+ super (IgnoreErrorsCommand, self).__init__ ("ignore-errors", -+ gdb.COMMAND_OBSCURE, -+ # FIXME... -+ gdb.COMPLETE_COMMAND) -+ -+ def invoke (self, arg, from_tty): -+ try: -+ gdb.execute (arg, from_tty) -+ except: -+ pass -+ -+IgnoreErrorsCommand () -diff --git a/gdb/python/lib/gdb/function/in_scope.py b/gdb/python/lib/gdb/function/in_scope.py -new file mode 100644 ---- /dev/null -+++ b/gdb/python/lib/gdb/function/in_scope.py -@@ -0,0 +1,47 @@ -+# In-scope function. -+ -+# Copyright (C) 2008 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 . -+ -+import gdb -+ -+class InScope (gdb.Function): -+ """Return True if all the given variables or macros are in scope. -+Takes one argument for each variable name to be checked.""" -+ -+ def __init__ (self): -+ super (InScope, self).__init__ ("in_scope") -+ -+ def invoke (self, *vars): -+ if len (vars) == 0: -+ raise (TypeError, "in_scope takes at least one argument") -+ -+ # gdb.Value isn't hashable so it can't be put in a map. -+ # Convert to string first. -+ wanted = set (map (lambda x: x.string (), vars)) -+ found = set () -+ block = gdb.selected_frame ().block () -+ while block: -+ for sym in block: -+ if (sym.is_argument or sym.is_constant -+ or sym.is_function or sym.is_variable): -+ if sym.name in wanted: -+ found.add (sym.name) -+ -+ block = block.superblock -+ -+ return wanted == found -+ -+InScope () -diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp ---- a/gdb/testsuite/gdb.python/py-frame.exp -+++ b/gdb/testsuite/gdb.python/py-frame.exp -@@ -95,6 +95,8 @@ gdb_test "python print ('result = %s' % f0.read_var ('a'))" " = 1" "test Frame.r - - gdb_test "python print ('result = %s' % (gdb.selected_frame () == f1))" " = True" "test gdb.selected_frame" - -+gdb_test "python print ('result = %s' % (f0.block ()))" "" "test Frame.block" -+ - # Can read SP register. - gdb_test "python print ('result = %s' % (gdb.selected_frame ().read_register ('sp') == gdb.parse_and_eval ('\$sp')))" \ - " = True" \ -diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp ---- a/gdb/testsuite/gdb.python/py-value.exp -+++ b/gdb/testsuite/gdb.python/py-value.exp -@@ -419,6 +419,15 @@ proc test_value_after_death {} { - "print value's type" - } - -+# Regression test for a cast failure. The bug was that if we cast a -+# value to its own type, gdb could crash. This happened because we -+# could end up double-freeing a struct value. -+proc test_cast_regression {} { -+ gdb_test "python v = gdb.Value(5)" "" "create value for cast test" -+ gdb_test "python v = v.cast(v.type)" "" "cast value for cast test" -+ gdb_test "python print(v)" "5" "print value for cast test" -+} -+ - # Regression test for invalid subscript operations. The bug was that - # the type of the value was not being checked before allowing a - # subscript operation to proceed. -@@ -606,6 +615,7 @@ test_value_in_inferior - test_value_from_buffer - test_inferior_function_call - test_value_after_death -+test_cast_regression - - # Test either C or C++ values. - diff --git a/gdb-attach-fail-reasons-5of5.patch b/gdb-attach-fail-reasons-5of5.patch deleted file mode 100644 index 89e1953451ffb85a0d9a7f0fcd16ba5c044297b5..0000000000000000000000000000000000000000 --- a/gdb-attach-fail-reasons-5of5.patch +++ /dev/null @@ -1,312 +0,0 @@ -diff --git a/gdb/config.in b/gdb/config.in ---- a/gdb/config.in -+++ b/gdb/config.in -@@ -251,6 +251,9 @@ - /* Define if librpm library is being used. */ - #undef HAVE_LIBRPM - -+/* Define to 1 if you have the `selinux' library (-lselinux). */ -+#undef HAVE_LIBSELINUX -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_LIBUNWIND_IA64_H - -@@ -386,6 +389,9 @@ - /* Define to 1 if you have the `scm_new_smob' function. */ - #undef HAVE_SCM_NEW_SMOB - -+/* Define to 1 if you have the header file. */ -+#undef HAVE_SELINUX_SELINUX_H -+ - /* Define to 1 if you have the `setlocale' function. */ - #undef HAVE_SETLOCALE - -diff --git a/gdb/configure b/gdb/configure ---- a/gdb/configure -+++ b/gdb/configure -@@ -16434,6 +16434,64 @@ cat >>confdefs.h <<_ACEOF - _ACEOF - - -+for ac_header in selinux/selinux.h -+do : -+ ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default" -+if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then : -+ cat >>confdefs.h <<_ACEOF -+#define HAVE_SELINUX_SELINUX_H 1 -+_ACEOF -+ -+fi -+ -+done -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_get_boolean_active in -lselinux" >&5 -+$as_echo_n "checking for security_get_boolean_active in -lselinux... " >&6; } -+if test "${ac_cv_lib_selinux_security_get_boolean_active+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lselinux $LIBS" -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char security_get_boolean_active (); -+int -+main () -+{ -+return security_get_boolean_active (); -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_selinux_security_get_boolean_active=yes -+else -+ ac_cv_lib_selinux_security_get_boolean_active=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_security_get_boolean_active" >&5 -+$as_echo "$ac_cv_lib_selinux_security_get_boolean_active" >&6; } -+if test "x$ac_cv_lib_selinux_security_get_boolean_active" = x""yes; then : -+ cat >>confdefs.h <<_ACEOF -+#define HAVE_LIBSELINUX 1 -+_ACEOF -+ -+ LIBS="-lselinux $LIBS" -+ -+fi -+ -+ - - # Support for --with-sysroot is a copy of GDB_AC_WITH_DIR, - # except that the argument to --with-sysroot is optional. -diff --git a/gdb/configure.ac b/gdb/configure.ac ---- a/gdb/configure.ac -+++ b/gdb/configure.ac -@@ -1964,6 +1964,10 @@ case $host_os in - esac - AC_DEFINE_UNQUOTED(GDBINIT,"$gdbinit",[The .gdbinit filename.]) - -+dnl Check security_get_boolean_active availability. -+AC_CHECK_HEADERS(selinux/selinux.h) -+AC_CHECK_LIB(selinux, security_get_boolean_active) -+ - dnl Handle optional features that can be enabled. - - # Support for --with-sysroot is a copy of GDB_AC_WITH_DIR, -diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in ---- a/gdb/gdbserver/config.in -+++ b/gdb/gdbserver/config.in -@@ -125,6 +125,9 @@ - /* Define to 1 if you have the `dl' library (-ldl). */ - #undef HAVE_LIBDL - -+/* Define to 1 if you have the `selinux' library (-lselinux). */ -+#undef HAVE_LIBSELINUX -+ - /* Define if the target supports branch tracing. */ - #undef HAVE_LINUX_BTRACE - -@@ -210,6 +213,9 @@ - /* Define to 1 if you have the `pwrite' function. */ - #undef HAVE_PWRITE - -+/* Define to 1 if you have the header file. */ -+#undef HAVE_SELINUX_SELINUX_H -+ - /* Define to 1 if you have the `setns' function. */ - #undef HAVE_SETNS - -diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure ---- a/gdb/gdbserver/configure -+++ b/gdb/gdbserver/configure -@@ -9398,6 +9398,64 @@ if $want_ipa ; then - fi - fi - -+for ac_header in selinux/selinux.h -+do : -+ ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default" -+if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then : -+ cat >>confdefs.h <<_ACEOF -+#define HAVE_SELINUX_SELINUX_H 1 -+_ACEOF -+ -+fi -+ -+done -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_get_boolean_active in -lselinux" >&5 -+$as_echo_n "checking for security_get_boolean_active in -lselinux... " >&6; } -+if test "${ac_cv_lib_selinux_security_get_boolean_active+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lselinux $LIBS" -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char security_get_boolean_active (); -+int -+main () -+{ -+return security_get_boolean_active (); -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_selinux_security_get_boolean_active=yes -+else -+ ac_cv_lib_selinux_security_get_boolean_active=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_security_get_boolean_active" >&5 -+$as_echo "$ac_cv_lib_selinux_security_get_boolean_active" >&6; } -+if test "x$ac_cv_lib_selinux_security_get_boolean_active" = x""yes; then : -+ cat >>confdefs.h <<_ACEOF -+#define HAVE_LIBSELINUX 1 -+_ACEOF -+ -+ LIBS="-lselinux $LIBS" -+ -+fi -+ -+ - - - -diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac ---- a/gdb/gdbserver/configure.ac -+++ b/gdb/gdbserver/configure.ac -@@ -465,6 +465,10 @@ if $want_ipa ; then - fi - fi - -+dnl Check security_get_boolean_active availability. -+AC_CHECK_HEADERS(selinux/selinux.h) -+AC_CHECK_LIB(selinux, security_get_boolean_active) -+ - AC_SUBST(GDBSERVER_DEPFILES) - AC_SUBST(GDBSERVER_LIBS) - AC_SUBST(srv_xmlbuiltin) -diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c ---- a/gdb/gdbserver/linux-low.c -+++ b/gdb/gdbserver/linux-low.c -@@ -968,7 +968,16 @@ linux_ptrace_fun () - { - if (ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0, - (PTRACE_TYPE_ARG4) 0) < 0) -- trace_start_error_with_name ("ptrace"); -+ { -+ int save_errno = errno; -+ -+ std::string msg (linux_ptrace_create_warnings ()); -+ -+ msg += _("Cannot trace created process"); -+ -+ errno = save_errno; -+ trace_start_error_with_name (msg.c_str ()); -+ } - - if (setpgid (0, 0) < 0) - trace_start_error_with_name ("setpgid"); -diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c ---- a/gdb/linux-nat.c -+++ b/gdb/linux-nat.c -@@ -1092,7 +1092,16 @@ linux_nat_target::create_inferior (const char *exec_file, - /* Make sure we report all signals during startup. */ - pass_signals ({}); - -- inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty); -+ try -+ { -+ inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty); -+ } -+ catch (const gdb_exception_error &ex) -+ { -+ std::string result = linux_ptrace_create_warnings (); -+ -+ throw_error (ex.error, "%s%s", result.c_str (), ex.message->c_str ()); -+ } - } - - /* Callback for linux_proc_attach_tgid_threads. Attach to PTID if not -diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c ---- a/gdb/nat/linux-ptrace.c -+++ b/gdb/nat/linux-ptrace.c -@@ -25,6 +25,10 @@ - #include - #endif - -+#ifdef HAVE_SELINUX_SELINUX_H -+# include -+#endif /* HAVE_SELINUX_SELINUX_H */ -+ - /* Stores the ptrace options supported by the running kernel. - A value of -1 means we did not check for features yet. A value - of 0 means there are no supported features. */ -@@ -50,6 +54,8 @@ linux_ptrace_attach_fail_reason (pid_t pid) - "terminated"), - (int) pid); - -+ result += linux_ptrace_create_warnings (); -+ - return result; - } - -@@ -586,6 +592,25 @@ linux_ptrace_init_warnings (void) - linux_ptrace_test_ret_to_nx (); - } - -+/* Print all possible reasons we could fail to create a traced process. */ -+ -+std::string -+linux_ptrace_create_warnings () -+{ -+ std::string result; -+ -+#ifdef HAVE_LIBSELINUX -+ /* -1 is returned for errors, 0 if it has no effect, 1 if PTRACE_ATTACH is -+ forbidden. */ -+ if (security_get_boolean_active ("deny_ptrace") == 1) -+ string_appendf (result, -+ _("the SELinux boolean 'deny_ptrace' is enabled, " -+ "you can disable this process attach protection by: " -+ "(gdb) shell sudo setsebool deny_ptrace=0\n")); -+#endif /* HAVE_LIBSELINUX */ -+ return result; -+} -+ - /* Extract extended ptrace event from wait status. */ - - int -diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h ---- a/gdb/nat/linux-ptrace.h -+++ b/gdb/nat/linux-ptrace.h -@@ -184,6 +184,7 @@ extern std::string linux_ptrace_attach_fail_reason (pid_t pid); - extern std::string linux_ptrace_attach_fail_reason_string (ptid_t ptid, int err); - - extern void linux_ptrace_init_warnings (void); -+extern std::string linux_ptrace_create_warnings (); - extern void linux_check_ptrace_features (void); - extern void linux_enable_event_reporting (pid_t pid, int attached); - extern void linux_disable_event_reporting (pid_t pid); diff --git a/gdb-btrobust.patch b/gdb-btrobust.patch deleted file mode 100644 index 6d857da9d9bdee32d5d76c027afcbe948f42f55b..0000000000000000000000000000000000000000 --- a/gdb-btrobust.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c ---- a/gdb/python/py-framefilter.c -+++ b/gdb/python/py-framefilter.c -@@ -1204,6 +1204,7 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, - htab_eq_pointer, - NULL)); - -+ int count_printed = 0; - while (true) - { - gdbpy_ref<> item (PyIter_Next (iterable.get ())); -@@ -1212,8 +1213,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, - { - if (PyErr_Occurred ()) - { -- gdbpy_print_stack_or_quit (); -- return EXT_LANG_BT_ERROR; -+ gdbpy_print_stack (); -+ return count_printed > 0 ? EXT_LANG_BT_ERROR : EXT_LANG_BT_NO_FILTERS; - } - break; - } -@@ -1245,7 +1246,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, - /* Do not exit on error printing a single frame. Print the - error and continue with other frames. */ - if (success == EXT_LANG_BT_ERROR) -- gdbpy_print_stack_or_quit (); -+ gdbpy_print_stack (); -+ count_printed++; - } - - return success; diff --git a/gdb-bz1219747-attach-kills.patch b/gdb-bz1219747-attach-kills.patch deleted file mode 100644 index c4e7d2ba916999dd9681cb2992641a653144a25d..0000000000000000000000000000000000000000 --- a/gdb-bz1219747-attach-kills.patch +++ /dev/null @@ -1,99 +0,0 @@ -diff --git a/gdb/main.c b/gdb/main.c ---- a/gdb/main.c -+++ b/gdb/main.c -@@ -1148,7 +1148,10 @@ captured_main_1 (struct captured_main_args *context) - { - ret = catch_command_errors (attach_command, pid_or_core_arg, - !batch_flag); -- if (ret == 0) -+ if (ret == 0 -+ /* attach_command could succeed partially and core_file_command -+ would try to kill it. */ -+ && !have_inferiors ()) - ret = catch_command_errors (core_file_command, - pid_or_core_arg, - !batch_flag); -diff --git a/gdb/testsuite/gdb.base/attach-kills.c b/gdb/testsuite/gdb.base/attach-kills.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/attach-kills.c -@@ -0,0 +1,25 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2015 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 . */ -+ -+#include -+ -+int -+main (void) -+{ -+ sleep (600); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/attach-kills.exp b/gdb/testsuite/gdb.base/attach-kills.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/attach-kills.exp -@@ -0,0 +1,49 @@ -+# Copyright (C) 2015 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 . -+ -+if { ![can_spawn_for_attach] } { -+ return 0 -+} -+ -+standard_testfile -+ -+if { [build_executable ${testfile}.exp $testfile] == -1 } { -+ return -1 -+} -+ -+# Start the program running and then wait for a bit, to be sure -+# that it can be attached to. -+ -+set test_spawn_id [spawn_wait_for_attach $binfile] -+set testpid [spawn_id_get_pid $test_spawn_id] -+ -+remote_exec target "cp -pf -- $binfile $binfile-copy" -+remote_exec target "rm -f -- $binfile" -+ -+set test "start gdb" -+set res [gdb_spawn_with_cmdline_opts \ -+ "-iex \"set height 0\" -iex \"set width 0\" /DoEsNoTeXySt $testpid"] -+if { $res != 0} { -+ fail "$test (spawn)" -+ kill_wait_spawned_process $test_spawn_id -+ return -1 -+} -+gdb_test_multiple "" $test { -+ -re "\r\nAttaching to .*\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+ -+kill_wait_spawned_process $test_spawn_id diff --git a/gdb-bz533176-fortran-omp-step.patch b/gdb-bz533176-fortran-omp-step.patch deleted file mode 100644 index 1f93fb71bd1f7d24f29e59ff9ab22c53a3e47a1e..0000000000000000000000000000000000000000 --- a/gdb-bz533176-fortran-omp-step.patch +++ /dev/null @@ -1,101 +0,0 @@ -diff --git a/gdb/infrun.c b/gdb/infrun.c ---- a/gdb/infrun.c -+++ b/gdb/infrun.c -@@ -6453,6 +6453,16 @@ process_event_stop_test (struct execution_control_state *ecs) - - if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL) - { -+ struct symbol *stop_fn = find_pc_function (stop_pc); -+ struct minimal_symbol *stopf = lookup_minimal_symbol_by_pc (stop_pc).minsym; -+ -+ if ((stop_fn == NULL -+ || strstr (stop_fn->linkage_name (), ".omp_fn.") == NULL) -+ /* gcc-4.7.2-9.fc19.x86_64 uses a new format. */ -+ && (stopf == NULL -+ || strstr (stopf->linkage_name (), "._omp_fn.") == NULL)) -+{ /* ".omp_fn." */ -+ - /* We're doing a "next". - - Normal (forward) execution: set a breakpoint at the -@@ -6486,6 +6496,7 @@ process_event_stop_test (struct execution_control_state *ecs) - - keep_going (ecs); - return; -+} /* ".omp_fn." */ - } - - /* If we are in a function call trampoline (a stub between the -diff --git a/gdb/testsuite/gdb.fortran/omp-step.exp b/gdb/testsuite/gdb.fortran/omp-step.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/omp-step.exp -@@ -0,0 +1,31 @@ -+# Copyright 2009 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 . -+ -+set testfile "omp-step" -+set srcfile ${testfile}.f90 -+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90 additional_flags=-fopenmp}] } { -+ return -1 -+} -+ -+if ![runto [gdb_get_line_number "start-here"]] { -+ perror "Couldn't run to start-here" -+ return 0 -+} -+ -+gdb_test "next" {!\$omp parallel} "step closer" -+gdb_test "next" {a\(omp_get_thread_num\(\) \+ 1\) = 1} "step into omp" -+ -+gdb_breakpoint [gdb_get_line_number "success"] -+gdb_continue_to_breakpoint "success" ".*success.*" -diff --git a/gdb/testsuite/gdb.fortran/omp-step.f90 b/gdb/testsuite/gdb.fortran/omp-step.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/omp-step.f90 -@@ -0,0 +1,32 @@ -+! Copyright 2009 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 . -+ -+ use omp_lib -+ integer nthreads, i, a(1000) -+ nthreads = omp_get_num_threads() -+ if (nthreads .gt. 1000) call abort -+ -+ do i = 1, nthreads -+ a(i) = 0 -+ end do -+ print *, "start-here" -+!$omp parallel -+ a(omp_get_thread_num() + 1) = 1 -+!$omp end parallel -+ do i = 1, nthreads -+ if (a(i) .ne. 1) call abort -+ end do -+ print *, "success" -+ end diff --git a/gdb-bz601887-dwarf4-rh-test.patch b/gdb-bz601887-dwarf4-rh-test.patch index ebf5edae94ab5ce22ecde0335929b1606d139007..966c986e9ecea136b335943454e80ff7a13f03f8 100644 --- a/gdb-bz601887-dwarf4-rh-test.patch +++ b/gdb-bz601887-dwarf4-rh-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-bz601887-dwarf4-rh-test.patch + +;; Backport DWARF-4 support (BZ 601887, Tom Tromey). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S new file mode 100644 --- /dev/null @@ -225,11 +233,11 @@ new file mode 100644 + && ![istarget *-*-openbsd*] + && ![istarget arm-*-eabi*] + && ![istarget powerpc-*-eabi*]} { -+ return 0 ++ return 0 +} + +if {![istarget x86_64-*]} { -+ return 0 ++ return 0 +} + +set testfile "rh-dwarf4-x86_64" diff --git a/gdb-bz634108-solib_address.patch b/gdb-bz634108-solib_address.patch index 691573db8199e2b29b6289809f4808133761e2e9..58b473f23f8d3702214a3495235f2c0aa3b2b368 100644 --- a/gdb-bz634108-solib_address.patch +++ b/gdb-bz634108-solib_address.patch @@ -1,3 +1,15 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-bz634108-solib_address.patch + +;; Verify GDB Python built-in function gdb.solib_address exists (BZ # 634108). +;;=fedoratest + +Fix gdb.solib_address (fix by Phil Muldoon). + +s/solib_address/solib_name/ during upstreaming. + diff --git a/gdb/testsuite/gdb.python/rh634108-solib_address.exp b/gdb/testsuite/gdb.python/rh634108-solib_address.exp new file mode 100644 --- /dev/null @@ -26,4 +38,4 @@ new file mode 100644 +# Skip all tests if Python scripting is not enabled. +if { [skip_python_tests] } { continue } + -+gdb_test "python print gdb.solib_name(-1)" "None" "gdb.solib_name exists" ++gdb_test "python print (gdb.solib_name(-1))" "None" "gdb.solib_name exists" diff --git a/gdb-ccache-workaround.patch b/gdb-ccache-workaround.patch index 1860870dac13c3620aaac2458e5872b0c70ac5de..802fa2b35d777b6bdff1ba7e4b54472a354615d0 100644 --- a/gdb-ccache-workaround.patch +++ b/gdb-ccache-workaround.patch @@ -1,8 +1,16 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-ccache-workaround.patch + +;; Workaround ccache making lineno non-zero for command-line definitions. +;;=fedoratest: ccache is rarely used and it is even fixed now. + diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp --- a/gdb/testsuite/gdb.base/macscp.exp +++ b/gdb/testsuite/gdb.base/macscp.exp -@@ -25,6 +25,14 @@ if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } { - lappend options additional_flags=-g3 +@@ -27,6 +27,14 @@ if { [test_compiler_info "gcc-*"] } { + lappend options additional_flags=-fdebug-macro } +# Workaround ccache making lineno non-zero for command-line definitions. diff --git a/gdb-container-rh-pkg.patch b/gdb-container-rh-pkg.patch index 730b9ddecbe7daff45ab3577b2cb9874b5ecb39d..0996495d581c2607e164891585b91d2ae6696cfb 100644 --- a/gdb-container-rh-pkg.patch +++ b/gdb-container-rh-pkg.patch @@ -1,7 +1,15 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-container-rh-pkg.patch + +;; Add messages suggesting more recent RHEL gdbserver (RH BZ 1321114). +;;=fedora + diff --git a/gdb/remote.c b/gdb/remote.c --- a/gdb/remote.c +++ b/gdb/remote.c -@@ -13916,7 +13916,17 @@ remote_target::pid_to_exec_file (int pid) +@@ -14290,7 +14290,17 @@ remote_target::pid_to_exec_file (int pid) char *annex = NULL; if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE) @@ -18,5 +26,5 @@ diff --git a/gdb/remote.c b/gdb/remote.c + return NULL; + } - inf = find_inferior_pid (pid); + inferior *inf = find_inferior_pid (this, pid); if (inf == NULL) diff --git a/gdb-core-open-vdso-warning.patch b/gdb-core-open-vdso-warning.patch index 798a8c2a0d25373dbb432ffb4bc94f43f230b1be..f58d8be89125870d015e15ecc9d0ee715d93b4af 100644 --- a/gdb-core-open-vdso-warning.patch +++ b/gdb-core-open-vdso-warning.patch @@ -1,3 +1,21 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-core-open-vdso-warning.patch + +;; Fix GNU/Linux core open: Can't read pathname for load map: Input/output error. +;; Fix regression of undisplayed missing shared libraries caused by a fix for. +;;=fedoratest: It should be in glibc: libc-alpha: <20091004161706.GA27450@.*> + +http://sourceware.org/ml/gdb-patches/2009-10/msg00142.html +Subject: [patch] Fix GNU/Linux core open: Can't read pathname for load map: Input/output error. + +[ New patch variant. ] + +commit 7d760051ffb8a23cdc51342d4e6243fbc462f73f +Author: Ulrich Weigand +Date: Wed Sep 25 11:52:50 2013 +0000 + diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp --- a/gdb/testsuite/gdb.base/solib-symbol.exp +++ b/gdb/testsuite/gdb.base/solib-symbol.exp diff --git a/gdb-dts-rhel6-python-compat.patch b/gdb-dts-rhel6-python-compat.patch deleted file mode 100644 index 90a1c66cfc78d24c901414a110eac4199b63c366..0000000000000000000000000000000000000000 --- a/gdb-dts-rhel6-python-compat.patch +++ /dev/null @@ -1,305 +0,0 @@ -diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in ---- a/gdb/data-directory/Makefile.in -+++ b/gdb/data-directory/Makefile.in -@@ -71,6 +71,8 @@ PYTHON_FILE_LIST = \ - gdb/__init__.py \ - gdb/FrameDecorator.py \ - gdb/FrameIterator.py \ -+ gdb/FrameWrapper.py \ -+ gdb/backtrace.py \ - gdb/frames.py \ - gdb/printing.py \ - gdb/prompt.py \ -@@ -79,6 +81,7 @@ PYTHON_FILE_LIST = \ - gdb/xmethod.py \ - gdb/command/__init__.py \ - gdb/command/explore.py \ -+ gdb/command/backtrace.py \ - gdb/command/frame_filters.py \ - gdb/command/pretty_printers.py \ - gdb/command/prompt.py \ -diff --git a/gdb/python/lib/gdb/FrameWrapper.py b/gdb/python/lib/gdb/FrameWrapper.py -new file mode 100644 ---- /dev/null -+++ b/gdb/python/lib/gdb/FrameWrapper.py -@@ -0,0 +1,122 @@ -+# Wrapper API for frames. -+ -+# Copyright (C) 2008, 2009 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 . -+ -+import gdb -+ -+# FIXME: arguably all this should be on Frame somehow. -+class FrameWrapper: -+ def __init__ (self, frame): -+ self.frame = frame; -+ -+ def write_symbol (self, stream, sym, block): -+ if len (sym.linkage_name): -+ nsym, is_field_of_this = gdb.lookup_symbol (sym.linkage_name, block) -+ if nsym.addr_class != gdb.SYMBOL_LOC_REGISTER: -+ sym = nsym -+ -+ stream.write (sym.print_name + "=") -+ try: -+ val = self.read_var (sym) -+ if val != None: -+ val = str (val) -+ # FIXME: would be nice to have a more precise exception here. -+ except RuntimeError as text: -+ val = text -+ if val == None: -+ stream.write ("???") -+ else: -+ stream.write (str (val)) -+ -+ def print_frame_locals (self, stream, func): -+ -+ try: -+ block = self.frame.block() -+ except RuntimeError: -+ block = None -+ -+ while block != None: -+ if block.is_global or block.is_static: -+ break -+ -+ for sym in block: -+ if sym.is_argument: -+ continue; -+ -+ self.write_symbol (stream, sym, block) -+ stream.write ('\n') -+ -+ def print_frame_args (self, stream, func): -+ -+ try: -+ block = self.frame.block() -+ except RuntimeError: -+ block = None -+ -+ while block != None: -+ if block.function != None: -+ break -+ block = block.superblock -+ -+ first = True -+ for sym in block: -+ if not sym.is_argument: -+ continue; -+ -+ if not first: -+ stream.write (", ") -+ -+ self.write_symbol (stream, sym, block) -+ first = False -+ -+ # FIXME: this should probably just be a method on gdb.Frame. -+ # But then we need stream wrappers. -+ def describe (self, stream, full): -+ if self.type () == gdb.DUMMY_FRAME: -+ stream.write (" \n") -+ elif self.type () == gdb.SIGTRAMP_FRAME: -+ stream.write (" \n") -+ else: -+ sal = self.find_sal () -+ pc = self.pc () -+ name = self.name () -+ if not name: -+ name = "??" -+ if pc != sal.pc or not sal.symtab: -+ stream.write (" 0x%08x in" % pc) -+ stream.write (" " + name + " (") -+ -+ func = self.function () -+ self.print_frame_args (stream, func) -+ -+ stream.write (")") -+ -+ if sal.symtab and sal.symtab.filename: -+ stream.write (" at " + sal.symtab.filename) -+ stream.write (":" + str (sal.line)) -+ -+ if not self.name () or (not sal.symtab or not sal.symtab.filename): -+ lib = gdb.solib_name (pc) -+ if lib: -+ stream.write (" from " + lib) -+ -+ stream.write ("\n") -+ -+ if full: -+ self.print_frame_locals (stream, func) -+ -+ def __getattr__ (self, name): -+ return getattr (self.frame, name) -diff --git a/gdb/python/lib/gdb/backtrace.py b/gdb/python/lib/gdb/backtrace.py -new file mode 100644 ---- /dev/null -+++ b/gdb/python/lib/gdb/backtrace.py -@@ -0,0 +1,42 @@ -+# Filtering backtrace. -+ -+# Copyright (C) 2008, 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 . -+ -+import gdb -+import itertools -+ -+# Our only exports. -+__all__ = ['push_frame_filter', 'create_frame_filter'] -+ -+old_frame_filter = None -+ -+def push_frame_filter (constructor): -+ """Register a new backtrace filter class with the 'backtrace' command. -+The filter will be passed an iterator as an argument. The iterator -+will return gdb.Frame-like objects. The filter should in turn act as -+an iterator returning such objects.""" -+ global old_frame_filter -+ if old_frame_filter == None: -+ old_frame_filter = constructor -+ else: -+ old_frame_filter = lambda iterator, filter = frame_filter: constructor (filter(iterator)) -+ -+def create_frame_filter (iter): -+ global old_frame_filter -+ if old_frame_filter is None: -+ return iter -+ return old_frame_filter (iter) -+ -diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py -new file mode 100644 ---- /dev/null -+++ b/gdb/python/lib/gdb/command/backtrace.py -@@ -0,0 +1,106 @@ -+# New backtrace command. -+ -+# Copyright (C) 2008, 2009, 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 . -+ -+import gdb -+import gdb.backtrace -+import itertools -+from gdb.FrameIterator import FrameIterator -+from gdb.FrameWrapper import FrameWrapper -+import sys -+ -+class ReverseBacktraceParameter (gdb.Parameter): -+ """The new-backtrace command can show backtraces in 'reverse' order. -+This means that the innermost frame will be printed last. -+Note that reverse backtraces are more expensive to compute.""" -+ -+ set_doc = "Enable or disable reverse backtraces." -+ show_doc = "Show whether backtraces will be printed in reverse order." -+ -+ def __init__(self): -+ gdb.Parameter.__init__ (self, "reverse-backtrace", -+ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN) -+ # Default to compatibility with gdb. -+ self.value = False -+ -+class FilteringBacktrace (gdb.Command): -+ """Print backtrace of all stack frames, or innermost COUNT frames. -+With a negative argument, print outermost -COUNT frames. -+Use of the 'full' qualifier also prints the values of the local variables. -+Use of the 'raw' qualifier avoids any filtering by loadable modules. -+""" -+ -+ def __init__ (self): -+ # FIXME: this is not working quite well enough to replace -+ # "backtrace" yet. -+ gdb.Command.__init__ (self, "new-backtrace", gdb.COMMAND_STACK) -+ self.reverse = ReverseBacktraceParameter() -+ -+ def reverse_iter (self, iter): -+ result = [] -+ for item in iter: -+ result.append (item) -+ result.reverse() -+ return result -+ -+ def final_n (self, iter, x): -+ result = [] -+ for item in iter: -+ result.append (item) -+ return result[x:] -+ -+ def invoke (self, arg, from_tty): -+ i = 0 -+ count = 0 -+ filter = True -+ full = False -+ -+ for word in arg.split (" "): -+ if word == '': -+ continue -+ elif word == 'raw': -+ filter = False -+ elif word == 'full': -+ full = True -+ else: -+ count = int (word) -+ -+ # FIXME: provide option to start at selected frame -+ # However, should still number as if starting from newest -+ newest_frame = gdb.newest_frame() -+ iter = itertools.imap (FrameWrapper, -+ FrameIterator (newest_frame)) -+ if filter: -+ iter = gdb.backtrace.create_frame_filter (iter) -+ -+ # Now wrap in an iterator that numbers the frames. -+ iter = itertools.izip (itertools.count (0), iter) -+ -+ # Reverse if the user wanted that. -+ if self.reverse.value: -+ iter = self.reverse_iter (iter) -+ -+ # Extract sub-range user wants. -+ if count < 0: -+ iter = self.final_n (iter, count) -+ elif count > 0: -+ iter = itertools.islice (iter, 0, count) -+ -+ for pair in iter: -+ sys.stdout.write ("#%-2d" % pair[0]) -+ pair[1].describe (sys.stdout, full) -+ -+FilteringBacktrace() diff --git a/gdb-fedora-libncursesw.patch b/gdb-fedora-libncursesw.patch index a0f32776de9634294358486be4c1190ab18eaff1..10710b9e86518deb17956947d8bda0dcdca33b39 100644 --- a/gdb-fedora-libncursesw.patch +++ b/gdb-fedora-libncursesw.patch @@ -1,7 +1,18 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-fedora-libncursesw.patch + +;; Force libncursesw over libncurses to match the includes (RH BZ 1270534). +;;=push+jan + +Fedora: Force libncursesw over libncurses to match the includes. +https://bugzilla.redhat.com/show_bug.cgi?id=1270534 + diff --git a/gdb/configure b/gdb/configure --- a/gdb/configure +++ b/gdb/configure -@@ -9375,6 +9375,7 @@ if test x"$prefer_curses" = xyes; then +@@ -9544,6 +9544,7 @@ if test x"$prefer_curses" = xyes; then # search /usr/local/include, if ncurses is installed in /usr/local. A # default installation of ncurses on alpha*-dec-osf* will lead to such # a situation. @@ -9,7 +20,7 @@ diff --git a/gdb/configure b/gdb/configure { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing waddstr" >&5 $as_echo_n "checking for library containing waddstr... " >&6; } if ${ac_cv_search_waddstr+:} false; then : -@@ -9399,7 +9400,7 @@ return waddstr (); +@@ -9568,7 +9569,7 @@ return waddstr (); return 0; } _ACEOF @@ -18,7 +29,7 @@ diff --git a/gdb/configure b/gdb/configure if test -z "$ac_lib"; then ac_res="none required" else -@@ -9473,6 +9474,7 @@ case $host_os in +@@ -9642,6 +9643,7 @@ case $host_os in esac # These are the libraries checked by Readline. @@ -26,7 +37,7 @@ diff --git a/gdb/configure b/gdb/configure { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5 $as_echo_n "checking for library containing tgetent... " >&6; } if ${ac_cv_search_tgetent+:} false; then : -@@ -9497,7 +9499,7 @@ return tgetent (); +@@ -9666,7 +9668,7 @@ return tgetent (); return 0; } _ACEOF @@ -38,7 +49,7 @@ diff --git a/gdb/configure b/gdb/configure diff --git a/gdb/configure.ac b/gdb/configure.ac --- a/gdb/configure.ac +++ b/gdb/configure.ac -@@ -717,7 +717,8 @@ if test x"$prefer_curses" = xyes; then +@@ -736,7 +736,8 @@ if test x"$prefer_curses" = xyes; then # search /usr/local/include, if ncurses is installed in /usr/local. A # default installation of ncurses on alpha*-dec-osf* will lead to such # a situation. @@ -48,7 +59,7 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac if test "$ac_cv_search_waddstr" != no; then curses_found=yes -@@ -759,7 +760,8 @@ case $host_os in +@@ -778,7 +779,8 @@ case $host_os in esac # These are the libraries checked by Readline. diff --git a/gdb-fortran-frame-string.patch b/gdb-fortran-frame-string.patch index fc91c97851ff4536e19f432417639d934083dafb..4bdd0593fee88636e9c521e54892427d22937536 100644 --- a/gdb-fortran-frame-string.patch +++ b/gdb-fortran-frame-string.patch @@ -1,3 +1,33 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-fortran-frame-string.patch + +;; Display Fortran strings in backtraces. +;;=fedoratest + +http://sourceware.org/ml/gdb-patches/2014-07/msg00709.html + +Hi, + +for Fortran it fixes displaying normal strings also in frames/backtraces: + +(gdb) frame +-> + +The patch is simple and I do not see why it should not be this way. + +For C/C++ TYPE_CODE_STRING is not used. I am not aware of Pascal but that +language is currently not really much supported in GDB anyway. + +This was a part of my archer/jankratochvil/vla branch but it is not a part of +the Intel VLA patchset as it in fact is completely unrelated to "VLA". + +No regressions on {x86_64,x86_64-m32,i686}-fedora22pre-linux-gnu. + +Thanks, +Jan + diff --git a/gdb/testsuite/gdb.fortran/fortran-frame-string.exp b/gdb/testsuite/gdb.fortran/fortran-frame-string.exp new file mode 100644 --- /dev/null @@ -9,15 +39,15 @@ new file mode 100644 +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +standard_testfile .f90 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { @@ -37,7 +67,7 @@ new file mode 100644 + +# Fix rejected upstream: +# https://sourceware.org/ml/gdb-patches/2014-07/msg00768.html -+setup_kfail "rejected" *-*-* ++setup_kfail "rejected" *-*-* +gdb_test "frame" { \(s='foo', .*} diff --git a/gdb/testsuite/gdb.fortran/fortran-frame-string.f90 b/gdb/testsuite/gdb.fortran/fortran-frame-string.f90 new file mode 100644 diff --git a/gdb-glibc-strstr-workaround.patch b/gdb-glibc-strstr-workaround.patch index 5b9fbaac84eaa5bca194cc5f80541c7a8d4e74b6..da9c5de76422deb9af34c2a33518052576365166 100644 --- a/gdb-glibc-strstr-workaround.patch +++ b/gdb-glibc-strstr-workaround.patch @@ -1,8 +1,16 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-glibc-strstr-workaround.patch + +;; Workaround PR libc/14166 for inferior calls of strstr. +;;=fedoratest: Compatibility with RHELs (unchecked which ones). + diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp -@@ -0,0 +1,115 @@ +@@ -0,0 +1,119 @@ +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -48,6 +56,10 @@ new file mode 100644 + untested "$test (no DWARF)" + return 0 + } ++ -re "type = \\(\\)\r\n$gdb_prompt $" { ++ untested "$test (no DWARF)" ++ return 0 ++ } +} + +set addr "" @@ -116,5 +128,5 @@ new file mode 100644 + } +} + -+gdb_test {print strstr("abc","b")} { = 0x[0-9a-f]+ "bc"} -+gdb_test {print strstr("def","e")} { = 0x[0-9a-f]+ "ef"} ++gdb_test {print (char *)strstr("abc","b")} { = 0x[0-9a-f]+ "bc"} ++gdb_test {print (char *)strstr("def","e")} { = 0x[0-9a-f]+ "ef"} diff --git a/gdb-gnat-dwarf-crash-3of3.patch b/gdb-gnat-dwarf-crash-3of3.patch deleted file mode 100644 index 08d63298c5bc1c96d22e25d3b27640a9cd027f90..0000000000000000000000000000000000000000 --- a/gdb-gnat-dwarf-crash-3of3.patch +++ /dev/null @@ -1,195 +0,0 @@ -diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -10657,6 +10657,13 @@ private: - static void - process_die (struct die_info *die, struct dwarf2_cu *cu) - { -+ if (die->in_process) -+ { -+ complaint (_("DIE at 0x%s attempted to be processed twice"), -+ sect_offset_str (die->sect_off)); -+ return; -+ } -+ - process_die_scope scope (die, cu); - - switch (die->tag) -diff --git a/gdb/infrun.c b/gdb/infrun.c ---- a/gdb/infrun.c -+++ b/gdb/infrun.c -@@ -601,6 +601,13 @@ holding the child stopped. Try \"set detach-on-fork\" or \ - target_pid_to_str (process_ptid).c_str ()); - } - -+#ifdef NEED_DETACH_SIGSTOP -+ /* We should check PID_WAS_STOPPED and detach it stopped accordingly. -+ In this point of code it cannot be 1 as we would not get FORK -+ executed without CONTINUE first which resets PID_WAS_STOPPED. -+ We would have to first TARGET_STOP and WAITPID it as with running -+ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */ -+#endif - target_detach (parent_inf, 0); - } - -diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c ---- a/gdb/linux-nat.c -+++ b/gdb/linux-nat.c -@@ -189,6 +189,12 @@ struct linux_nat_target *linux_target; - /* Does the current host support PTRACE_GETREGSET? */ - enum tribool have_ptrace_getregset = TRIBOOL_UNKNOWN; - -+#ifdef NEED_DETACH_SIGSTOP -+/* PID of the inferior stopped by SIGSTOP before attaching (or zero). */ -+static pid_t pid_was_stopped; -+ -+#endif -+ - static unsigned int debug_linux_nat; - static void - show_debug_linux_nat (struct ui_file *file, int from_tty, -@@ -1030,6 +1036,9 @@ linux_nat_post_attach_wait (ptid_t ptid, int *signalled) - if (debug_linux_nat) - fprintf_unfiltered (gdb_stdlog, - "LNPAW: Attaching to a stopped process\n"); -+#ifdef NEED_DETACH_SIGSTOP -+ pid_was_stopped = ptid.pid (); -+#endif - - /* The process is definitely stopped. It is in a job control - stop, unless the kernel predates the TASK_STOPPED / -@@ -1361,6 +1370,25 @@ get_detach_signal (struct lwp_info *lp) - return gdb_signal_to_host (signo); - } - -+#ifdef NEED_DETACH_SIGSTOP -+ /* Workaround RHEL-5 kernel which has unreliable PTRACE_DETACH, SIGSTOP (that -+ many TIDs are left unstopped). See RH Bug 496732. */ -+ if (lp->ptid.pid () == pid_was_stopped) -+ { -+ int err; -+ -+ errno = 0; -+ err = kill_lwp (lp->ptid.lwp (), SIGSTOP); -+ if (debug_linux_nat) -+ { -+ fprintf_unfiltered (gdb_stdlog, -+ "SC: lwp kill %d %s\n", -+ err, -+ errno ? safe_strerror (errno) : "ERRNO-OK"); -+ } -+ } -+ -+#endif - return 0; - } - -@@ -1509,6 +1537,10 @@ linux_nat_target::detach (inferior *inf, int from_tty) - detach_one_lwp (main_lwp, &signo); - - detach_success (inf); -+ -+#ifdef NEED_DETACH_SIGSTOP -+ pid_was_stopped = 0; -+#endif - } - } - -@@ -1766,6 +1798,16 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo) - return; - } - -+#ifdef NEED_DETACH_SIGSTOP -+ /* At this point, we are going to resume the inferior and if we -+ have attached to a stopped process, we no longer should leave -+ it as stopped if the user detaches. PTID variable has PID set to LWP -+ while we need to check the real PID here. */ -+ -+ if (!step && lp && pid_was_stopped == lp->ptid.pid ()) -+ pid_was_stopped = 0; -+ -+#endif - if (resume_many) - iterate_over_lwps (ptid, [=] (struct lwp_info *info) - { -@@ -3770,6 +3812,10 @@ linux_nat_target::mourn_inferior () - - /* Let the arch-specific native code know this process is gone. */ - linux_target->low_forget_process (pid); -+#ifdef NEED_DETACH_SIGSTOP -+ -+ pid_was_stopped = 0; -+#endif - } - - /* Convert a native/host siginfo object, into/from the siginfo in the -diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp ---- a/gdb/testsuite/gdb.threads/attach-stopped.exp -+++ b/gdb/testsuite/gdb.threads/attach-stopped.exp -@@ -56,7 +56,65 @@ proc corefunc { threadtype } { - gdb_reinitialize_dir $srcdir/$subdir - gdb_load ${binfile} - -- # Verify that we can attach to the stopped process. -+ # Verify that we can attach to the process by first giving its -+ # executable name via the file command, and using attach with the -+ # process ID. -+ -+ set test "$threadtype: set file, before attach1 to stopped process" -+ gdb_test_multiple "file $binfile" "$test" { -+ -re "Load new symbol table from.*y or n. $" { -+ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \ -+ "$test (re-read)" -+ } -+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" { -+ pass "$test" -+ } -+ } -+ -+ set test "$threadtype: attach1 to stopped, after setting file" -+ gdb_test_multiple "attach $testpid" "$test" { -+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" { -+ pass "$test" -+ } -+ } -+ -+ # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there. -+ if {[string equal $threadtype threaded]} { -+ gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: attach1 to stopped bt" -+ } else { -+ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach1 to stopped bt" -+ } -+ -+ # Exit and detach the process. -+ -+ gdb_exit -+ -+ # Avoid some race: -+ sleep 2 -+ -+ if [catch {open /proc/${testpid}/status r} fileid] { -+ set line2 "NOTFOUND" -+ } else { -+ gets $fileid line1; -+ gets $fileid line2; -+ close $fileid; -+ } -+ -+ set test "$threadtype: attach1, exit leaves process stopped" -+ if {[string match "*(stopped)*" $line2]} { -+ pass $test -+ } else { -+ fail $test -+ } -+ -+ # At this point, the process should still be stopped -+ -+ gdb_start -+ gdb_reinitialize_dir $srcdir/$subdir -+ gdb_load ${binfile} -+ -+ # Verify that we can attach to the process just by giving the -+ # process ID. - - set test "$threadtype: attach2 to stopped, after setting file" - gdb_test_multiple "attach $testpid" "$test" { diff --git a/gdb-jit-reader-multilib.patch b/gdb-jit-reader-multilib.patch deleted file mode 100644 index af690e392caf81ca098f5ef7c1cfd37cd53b6543..0000000000000000000000000000000000000000 --- a/gdb-jit-reader-multilib.patch +++ /dev/null @@ -1,38 +0,0 @@ -diff --git a/gdb/configure b/gdb/configure ---- a/gdb/configure -+++ b/gdb/configure -@@ -9694,10 +9694,12 @@ _ACEOF - - - --if test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then -- TARGET_PTR="unsigned long" --elif test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then -+# Try to keep TARGET_PTR the same across archs so that jit-reader.h file -+# content is the same for multilib distributions. -+if test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then - TARGET_PTR="unsigned long long" -+elif test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then -+ TARGET_PTR="unsigned long" - elif test "x${ac_cv_sizeof_unsigned___int128}" = "x16"; then - TARGET_PTR="unsigned __int128" - else -diff --git a/gdb/configure.ac b/gdb/configure.ac ---- a/gdb/configure.ac -+++ b/gdb/configure.ac -@@ -808,10 +808,12 @@ AC_CHECK_SIZEOF(unsigned long long) - AC_CHECK_SIZEOF(unsigned long) - AC_CHECK_SIZEOF(unsigned __int128) - --if test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then -- TARGET_PTR="unsigned long" --elif test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then -+# Try to keep TARGET_PTR the same across archs so that jit-reader.h file -+# content is the same for multilib distributions. -+if test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then - TARGET_PTR="unsigned long long" -+elif test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then -+ TARGET_PTR="unsigned long" - elif test "x${ac_cv_sizeof_unsigned___int128}" = "x16"; then - TARGET_PTR="unsigned __int128" - else diff --git a/gdb-libexec-add-index.patch b/gdb-libexec-add-index.patch index a48671eef36541e51d9e77073f085e8c07699317..19f6b5489a21ab67a96acdbaf0b9b25326a5400c 100644 --- a/gdb-libexec-add-index.patch +++ b/gdb-libexec-add-index.patch @@ -1,3 +1,16 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-libexec-add-index.patch + +;; Fix gdb-headless /usr/bin/ executables (BZ 1390251). +;; +;; Also, make /usr/bin/gdb.minimal be the default GDB used, if it's +;; present. For rationale, see: +;; +;; https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot +;;=fedora + diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh --- a/gdb/contrib/gdb-add-index.sh +++ b/gdb/contrib/gdb-add-index.sh diff --git a/gdb-lineno-makeup-test.patch b/gdb-lineno-makeup-test.patch index 0a4df7a53e71d13612de7c80f6c846bcfe1c0bed..4b96286bcf9fb3ba6180561c6c81c4a6d19fd78b 100644 --- a/gdb-lineno-makeup-test.patch +++ b/gdb-lineno-makeup-test.patch @@ -1,3 +1,19 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-lineno-makeup-test.patch + +;; Testcase for "Do not make up line information" fix by Daniel Jacobowitz. +;;=fedoratest + +New testcase for: +https://bugzilla.redhat.com/show_bug.cgi?id=466222 + (for the first / customer recommended fix) +and the upstream fix: +http://sourceware.org/ml/gdb-patches/2006-11/msg00253.html + [rfc] Do not make up line information +http://sourceware.org/ml/gdb-cvs/2006-11/msg00127.html + diff --git a/gdb/testsuite/gdb.base/lineno-makeup-func.c b/gdb/testsuite/gdb.base/lineno-makeup-func.c new file mode 100644 --- /dev/null @@ -48,10 +64,10 @@ new file mode 100644 + +/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number + information (.debug_line) so we cannot use an external object file. -+ ++ + It must not be just a label as it would alias on the next function even for + correct GDB. Therefore some stub data must be placed there. -+ ++ + We need to provide a real stub function body as at least s390 + (s390_analyze_prologue) would skip the whole body till reaching `main'. */ + diff --git a/gdb-linux_perf-bundle.patch b/gdb-linux_perf-bundle.patch index 1a9a8ca7b63dbb72a411359082df8617758f35c5..e3ce1a3443a24107cddfe6ba7310a6f72a180572 100644 --- a/gdb-linux_perf-bundle.patch +++ b/gdb-linux_perf-bundle.patch @@ -1,27 +1,11 @@ -diff --git a/gdb/configure b/gdb/configure ---- a/gdb/configure -+++ b/gdb/configure -@@ -11905,7 +11905,7 @@ else - - #include - #ifndef PERF_ATTR_SIZE_VER5 --# error -+// error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL - #endif - - _ACEOF -diff --git a/gdb/configure.ac b/gdb/configure.ac ---- a/gdb/configure.ac -+++ b/gdb/configure.ac -@@ -1414,7 +1414,7 @@ else - AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ - #include - #ifndef PERF_ATTR_SIZE_VER5 --# error -+// error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL - #endif - ]])], [perf_event=yes], [perf_event=no]) - if test "$perf_event" != yes; then +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-linux_perf-bundle.patch + +;; [dts+el7] [x86*] Bundle linux_perf.h for libipt (RH BZ 1256513). +;;=fedora + diff --git a/gdb/gdb.c b/gdb/gdb.c --- a/gdb/gdb.c +++ b/gdb/gdb.c @@ -226,3 +210,15 @@ diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h struct target_ops; #if HAVE_LINUX_PERF_EVENT_H +diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4 +--- a/gdbsupport/common.m4 ++++ b/gdbsupport/common.m4 +@@ -135,7 +135,7 @@ AC_DEFUN([GDB_AC_COMMON], [ + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ + #include + #ifndef PERF_ATTR_SIZE_VER5 +- # error ++ // error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL + #endif + ]])], [perf_event=yes], [perf_event=no]) + if test "$perf_event" != yes; then diff --git a/gdb-moribund-utrace-workaround.patch b/gdb-moribund-utrace-workaround.patch deleted file mode 100644 index 8f23f01cb6867069294da785a2952272f8feee4e..0000000000000000000000000000000000000000 --- a/gdb-moribund-utrace-workaround.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c ---- a/gdb/breakpoint.c -+++ b/gdb/breakpoint.c -@@ -11904,6 +11904,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode) - traps we can no longer explain. */ - - old_loc->events_till_retirement = 3 * (thread_count () + 1); -+ /* Red Hat Bug 590623. */ -+ old_loc->events_till_retirement *= 10; - old_loc->owner = NULL; - - moribund_locations.push_back (old_loc); diff --git a/gdb-opcodes-clflushopt-test.patch b/gdb-opcodes-clflushopt-test.patch index 2bad272dabd9744af4014232a96ac9fcba403e7b..f95999e9cfcba50d9266d42bef5edece0a076348 100644 --- a/gdb-opcodes-clflushopt-test.patch +++ b/gdb-opcodes-clflushopt-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-opcodes-clflushopt-test.patch + +;; Test clflushopt instruction decode (for RH BZ 1262471). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.arch/amd64-clflushopt.S b/gdb/testsuite/gdb.arch/amd64-clflushopt.S new file mode 100644 --- /dev/null diff --git a/gdb-physname-pr11734-test.patch b/gdb-physname-pr11734-test.patch index 3cc05382708ed25e5f13923f0b74dcd1f88350d0..835e18c99bf91bb2c8dfc9205a10bf077f610500 100644 --- a/gdb-physname-pr11734-test.patch +++ b/gdb-physname-pr11734-test.patch @@ -1,8 +1,18 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-physname-pr11734-test.patch + +;; Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz). +;;=fedoratest + +http://sourceware.org/ml/gdb-patches/2010-12/msg00263.html + diff --git a/gdb/testsuite/gdb.cp/pr11734-1.cc b/gdb/testsuite/gdb.cp/pr11734-1.cc new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734-1.cc -@@ -0,0 +1,30 @@ +@@ -0,0 +1,29 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -32,12 +42,11 @@ new file mode 100644 + p->foo (); + return 0; +} -+ diff --git a/gdb/testsuite/gdb.cp/pr11734-2.cc b/gdb/testsuite/gdb.cp/pr11734-2.cc new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734-2.cc -@@ -0,0 +1,27 @@ +@@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -64,12 +73,11 @@ new file mode 100644 +pr11734::foo(void) +{ +} -+ diff --git a/gdb/testsuite/gdb.cp/pr11734-3.cc b/gdb/testsuite/gdb.cp/pr11734-3.cc new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734-3.cc -@@ -0,0 +1,27 @@ +@@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -96,12 +104,11 @@ new file mode 100644 +pr11734::foo (int a) +{ +} -+ diff --git a/gdb/testsuite/gdb.cp/pr11734-4.cc b/gdb/testsuite/gdb.cp/pr11734-4.cc new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734-4.cc -@@ -0,0 +1,27 @@ +@@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -128,7 +135,6 @@ new file mode 100644 +pr11734::foo (char *a) +{ +} -+ diff --git a/gdb/testsuite/gdb.cp/pr11734.exp b/gdb/testsuite/gdb.cp/pr11734.exp new file mode 100644 --- /dev/null @@ -193,7 +199,7 @@ diff --git a/gdb/testsuite/gdb.cp/pr11734.h b/gdb/testsuite/gdb.cp/pr11734.h new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734.h -@@ -0,0 +1,28 @@ +@@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -221,4 +227,3 @@ new file mode 100644 + void foo (int); + void foo (char *); +}; -+ diff --git a/gdb-physname-pr12273-test.patch b/gdb-physname-pr12273-test.patch index a419749d6cede21cfdeca957466f661bc65ae9c4..6c943ad89e9c451bc88dd577b94cc8c6f3af2fdd 100644 --- a/gdb-physname-pr12273-test.patch +++ b/gdb-physname-pr12273-test.patch @@ -1,3 +1,13 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-physname-pr12273-test.patch + +;; Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz). +;;=fedoratest + +http://sourceware.org/ml/gdb-patches/2010-12/msg00264.html + diff --git a/gdb/testsuite/gdb.cp/pr12273.cc b/gdb/testsuite/gdb.cp/pr12273.cc new file mode 100644 --- /dev/null diff --git a/gdb-ppc-power7-test.patch b/gdb-ppc-power7-test.patch index 7293aba529018c5750c71bc117d974a0fa0e818a..c8b22cf0c29bc4229605a97e961eb5f19d5bf0c3 100644 --- a/gdb-ppc-power7-test.patch +++ b/gdb-ppc-power7-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-ppc-power7-test.patch + +;; Test power7 ppc disassembly. +;;=fedoratest + diff --git a/gdb/testsuite/gdb.arch/powerpc-power7rh.exp b/gdb/testsuite/gdb.arch/powerpc-power7rh.exp new file mode 100644 --- /dev/null @@ -17,7 +25,7 @@ new file mode 100644 +# +# 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Test PowerPC Power7 instructions disassembly. + @@ -40,7 +48,7 @@ new file mode 100644 +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${objfile} -+ ++ + +# Disassemble the function. + diff --git a/gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch b/gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch index 9ceeba0a383b8bf623b1271870ce420ad83d13ae..20e5f7555428dccccb6a64cf82bc5e42d918f7ef 100644 --- a/gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch +++ b/gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch + +;; Testcase for `Setting solib-absolute-prefix breaks vDSO' (BZ 818343). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c b/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c new file mode 100644 --- /dev/null diff --git a/gdb-rhbz-853071-update-manpages.patch b/gdb-rhbz-853071-update-manpages.patch new file mode 100644 index 0000000000000000000000000000000000000000..7ceb67e793d23305549c5007acaef6aee5f707ba --- /dev/null +++ b/gdb-rhbz-853071-update-manpages.patch @@ -0,0 +1,258 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Bruno Larsen +Date: Tue, 9 Nov 2021 14:07:26 -0300 +Subject: gdb-rhbz-853071-update-manpages.patch + +;; Backport manpage update + +[gdb/doc]: Updated manpages to be consistent with help + +Updated manpages to be consistent with help information provided by the +binary. The main changes are: + +* Making all long-form options have '--', instead of a single '-'; +* added most of the missing options to the manpage; +* removed the information about using '+' instead of '-', since it + doesn't seem to be supported anymore. + +This also fixes 2 upstream bugs: +* https://sourceware.org/bugzilla/show_bug.cgi?id=23965; by adding +--args to the manpage +* https://sourceware.org/bugzilla/show_bug.cgi?id=10619; by adding the +double dashes + +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -47030,14 +47030,7 @@ switch (die->tag) + @c man title gdb The GNU Debugger + + @c man begin SYNOPSIS gdb +-gdb [@option{-help}] [@option{-nh}] [@option{-nx}] [@option{-q}] +-[@option{-batch}] [@option{-cd=}@var{dir}] [@option{-f}] +-[@option{-b}@w{ }@var{bps}] +- [@option{-tty=}@var{dev}] [@option{-s} @var{symfile}] +-[@option{-e}@w{ }@var{prog}] [@option{-se}@w{ }@var{prog}] +-[@option{-c}@w{ }@var{core}] [@option{-p}@w{ }@var{procID}] +- [@option{-x}@w{ }@var{cmds}] [@option{-d}@w{ }@var{dir}] +-[@var{prog}|@var{prog} @var{procID}|@var{prog} @var{core}] ++gdb [OPTIONS] [@var{prog}|@var{prog} @var{procID}|@var{prog} @var{core}] + @c man end + + @c man begin DESCRIPTION gdb +@@ -47101,8 +47094,8 @@ Here are some of the most frequently needed @value{GDBN} commands: + + @c pod2man highlights the right hand side of the @item lines. + @table @env +-@item break [@var{file}:]@var{function} +-Set a breakpoint at @var{function} (in @var{file}). ++@item break [@var{file}:][@var{function}|@var{line}] ++Set a breakpoint at @var{function} or @var{line} (in @var{file}). + + @item run [@var{arglist}] + Start your program (with @var{arglist}, if specified). +@@ -47150,72 +47143,91 @@ as the @code{gdb} entry in the @code{info} program. + Any arguments other than options specify an executable + file and core file (or process ID); that is, the first argument + encountered with no +-associated option flag is equivalent to a @option{-se} option, and the second, ++associated option flag is equivalent to a @option{--se} option, and the second, + if any, is equivalent to a @option{-c} option if it's the name of a file. + Many options have +-both long and short forms; both are shown here. The long forms are also ++both long and abbreviated forms; both are shown here. The long forms are also + recognized if you truncate them, so long as enough of the option is +-present to be unambiguous. (If you prefer, you can flag option +-arguments with @option{+} rather than @option{-}, though we illustrate the +-more usual convention.) ++present to be unambiguous. ++ ++The abbreviated forms are shown here with @samp{-} and long forms are shown ++with @samp{--} to reflect how they are shown in @option{--help}. However, ++@value{GDBN} recognizes all of the following conventions for most options: ++ ++@table @code ++@item --option=@var{value} ++@item --option @var{value} ++@item -option=@var{value} ++@item -option @var{value} ++@item --o=@var{value} ++@item --o @var{value} ++@item -o=@var{value} ++@item -o @var{value} ++@end table + + All the options and command line arguments you give are processed + in sequential order. The order makes a difference when the @option{-x} + option is used. + + @table @env +-@item -help ++@item --help + @itemx -h + List all options, with brief explanations. + +-@item -symbols=@var{file} ++@item --symbols=@var{file} + @itemx -s @var{file} +-Read symbol table from file @var{file}. ++Read symbol table from @var{file}. + +-@item -write ++@item --write + Enable writing into executable and core files. + +-@item -exec=@var{file} ++@item --exec=@var{file} + @itemx -e @var{file} +-Use file @var{file} as the executable file to execute when ++Use @var{file} as the executable file to execute when + appropriate, and for examining pure data in conjunction with a core + dump. + +-@item -se=@var{file} +-Read symbol table from file @var{file} and use it as the executable ++@item --se=@var{file} ++Read symbol table from @var{file} and use it as the executable + file. + +-@item -core=@var{file} ++@item --core=@var{file} + @itemx -c @var{file} +-Use file @var{file} as a core dump to examine. ++Use @var{file} as a core dump to examine. + +-@item -command=@var{file} ++@item --command=@var{file} + @itemx -x @var{file} +-Execute @value{GDBN} commands from file @var{file}. ++Execute @value{GDBN} commands from @var{file}. + ++@item --eval-command=@var{command} + @item -ex @var{command} + Execute given @value{GDBN} @var{command}. + +-@item -directory=@var{directory} ++@item --init-eval-command=@var{command} ++@item -iex ++Execute @value{GDBN} @var{command} before loading the inferior. ++ ++@item --directory=@var{directory} + @itemx -d @var{directory} + Add @var{directory} to the path to search for source files. + +-@item -nh ++@item --nh + Do not execute commands from @file{~/.config/gdb/gdbinit}, + @file{~/.gdbinit}, @file{~/.config/gdb/gdbearlyinit}, or + @file{~/.gdbearlyinit} + +-@item -nx ++@item --nx + @itemx -n + Do not execute commands from any @file{.gdbinit} or + @file{.gdbearlyinit} initialization files. + +-@item -quiet ++@item --quiet ++@item --silent + @itemx -q + ``Quiet''. Do not print the introductory and copyright messages. These + messages are also suppressed in batch mode. + +-@item -batch ++@item --batch + Run in batch mode. Exit with status @code{0} after processing all the command + files specified with @option{-x} (and @file{.gdbinit}, if not inhibited). + Exit with nonzero status if an error occurs in executing the @value{GDBN} +@@ -47233,11 +47245,71 @@ Program exited normally. + (which is ordinarily issued whenever a program running under @value{GDBN} control + terminates) is not issued when running in batch mode. + +-@item -cd=@var{directory} ++@item --batch-silent ++Run in batch mode, just like @option{--batch}, but totally silent. All @value{GDBN} ++output is supressed (stderr is unaffected). This is much quieter than ++@option{--silent} and would be useless for an interactive session. ++ ++This is particularly useful when using targets that give @samp{Loading section} ++messages, for example. ++ ++Note that targets that give their output via @value{GDBN}, as opposed to writing ++directly to @code{stdout}, will also be made silent. ++ ++@item --args @var{prog} [@var{arglist}] ++Change interpretation of command line so that arguments following this ++option are passed as arguments to the inferior. As an example, take ++the following command: ++ ++@smallexample ++gdb ./a.out -q ++@end smallexample ++ ++@noindent ++It would start @value{GDBN} with @option{-q}, not printing the introductory message. On ++the other hand, using: ++ ++@smallexample ++gdb --args ./a.out -q ++@end smallexample ++ ++@noindent ++starts @value{GDBN} with the introductory message, and passes the option to the inferior. ++ ++@item --pid=@var{pid} ++Attach @value{GDBN} to an already running program, with the PID @var{pid}. ++ ++@item --tui ++Open the terminal user interface. ++ ++@item --readnow ++Read all symbols from the given symfile on the first access. ++ ++@item --readnever ++Do not read symbol files. ++ ++@item --dbx ++Run in DBX compatibility mode. ++ ++@item --return-child-result ++@value{GDBN}'s exit code will be the same as the child's exit code. ++ ++@item --configuration ++Print details about GDB configuration and then exit. ++ ++@item --version ++Print version information and then exit. ++ ++@item --cd=@var{directory} + Run @value{GDBN} using @var{directory} as its working directory, + instead of the current directory. + +-@item -fullname ++@item --data-directory=@var{directory} ++@item -D ++Run @value{GDBN} using @var{directory} as its data directory. The data ++directory is where @value{GDBN} searches for its auxiliary files. ++ ++@item --fullname + @itemx -f + Emacs sets this option when it runs @value{GDBN} as a subprocess. It tells + @value{GDBN} to output the full file name and line number in a standard, +@@ -47248,11 +47320,14 @@ and character position separated by colons, and a newline. The + Emacs-to-@value{GDBN} interface program uses the two @samp{\032} + characters as a signal to display the source code for the frame. + +-@item -b @var{bps} ++@item -b @var{baudrate} + Set the line speed (baud rate or bits per second) of any serial + interface used by @value{GDBN} for remote debugging. + +-@item -tty=@var{device} ++@item -l @var{timeout} ++Set timeout, in seconds, for remote debugging. ++ ++@item --tty=@var{device} + Run using @var{device} for your program's standard input and output. + @end table + @c man end diff --git a/gdb-rhbz1007614-memleak-infpy_read_memory-test.patch b/gdb-rhbz1007614-memleak-infpy_read_memory-test.patch index 4c33bab960dad7c366dff6f987437762dc30456e..4d05ba56998ff2c1b326b9255294852cbd83f8b5 100644 --- a/gdb-rhbz1007614-memleak-infpy_read_memory-test.patch +++ b/gdb-rhbz1007614-memleak-infpy_read_memory-test.patch @@ -1,3 +1,33 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1007614-memleak-infpy_read_memory-test.patch + +;; Fix 'memory leak in infpy_read_memory()' (RH BZ 1007614) +;;=fedoratest + +Original message by Tom Tromey: + + + Message-ID: <871uoc1va3.fsf@fleche.redhat.com> + +Comment from Sergio Durigan Junior: + + In order to correctly test this patch, I wrote a testcase based on Jan + Kratochvil's . The + testcase, which can be seen below, tests GDB in order to see if the + amount of memory being leaked is minimal, as requested in the bugzilla. + It is hard to define what "minimum" is, so I ran the testcase on all + supported RHEL architectures and came up with an average. + +commit cc0265cdda9dc7e8665e8bfcf5b4477489daf27c +Author: Tom Tromey +Date: Wed Mar 28 17:38:08 2012 +0000 + + * python/py-inferior.c (infpy_read_memory): Remove cleanups and + explicitly free 'buffer' on exit paths. Decref 'membuf_object' + before returning. + diff --git a/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.c b/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.c new file mode 100644 --- /dev/null diff --git a/gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch b/gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch index 8e21c80c451b04b46d5cef6ddfc7bbeb24bba449..d92bfc3bfe8a09be812f1f4df8c3a7f98e4b9708 100644 --- a/gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch +++ b/gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch @@ -1,3 +1,16 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch + +;; Fix '[ppc64] and [s390x] wrong prologue skip on -O2 -g code' (Jan +;; Kratochvil, RH BZ 1084404). +;;=fedoratest + +These testcases have been created by compiling glibc-2.17-78 on +RHEL-7.1 s390x/ppc64 boxes, and then taking the "select.o" file +present at $builddir/misc/select.o. + diff --git a/gdb/testsuite/gdb.arch/ppc64-prologue-skip.exp b/gdb/testsuite/gdb.arch/ppc64-prologue-skip.exp new file mode 100644 --- /dev/null diff --git a/gdb-rhbz1149205-catch-syscall-after-fork-test.patch b/gdb-rhbz1149205-catch-syscall-after-fork-test.patch index 3f64ab3eb08fe81d5e4e03a40e02a111f0df1622..63c40515430ebb8d99cfac30ef7de7d6e2905c27 100644 --- a/gdb-rhbz1149205-catch-syscall-after-fork-test.patch +++ b/gdb-rhbz1149205-catch-syscall-after-fork-test.patch @@ -1,3 +1,47 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1149205-catch-syscall-after-fork-test.patch + +;; Fix '`catch syscall' doesn't work for parent after `fork' is called' +;; (Philippe Waroquiers, RH BZ 1149205). +;;=fedoratest + +URL: +Message-ID: <1368136582.30058.7.camel@soleil> + + From: Philippe Waroquiers + To: gdb-patches at sourceware dot org + Subject: RFA: fix gdb_assert caused by 'catch signal ...' and fork + Date: Thu, 09 May 2013 23:56:22 +0200 + + The attached patch fixes a gdb_assert caused by the combination of catch + signal and fork: + break-catch-sig.c:152: internal-error: signal_catchpoint_remove_location: Assertion `signal_catch_counts[iter] > 0' failed. + + The problem is that the signal_catch_counts is decremented by detach_breakpoints. + The fix consists in not detaching breakpoint locations of type bp_loc_other. + The patch introduces a new test. + +Comments by Sergio Durigan Junior: + + I addded a specific testcase for this patch, which tests exactly the + issue that the customer is facing. This patch does not solve the + whole problem of catching a syscall and forking (for more details, + see , + specifically comment #3), but it solves the issue reported by the + customer. + + I also removed the original testcase of this patch, because it + relied on "catch signal", which is a command that is not implemented + in this version of GDB. + +commit bd9673a4ded96ea5c108601501c8e59003ea1be6 +Author: Philippe Waroquiers +Date: Tue May 21 18:47:05 2013 +0000 + + Fix internal error caused by interaction between catch signal and fork + diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.c b/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.c new file mode 100644 --- /dev/null diff --git a/gdb-rhbz1156192-recursive-dlopen-test.patch b/gdb-rhbz1156192-recursive-dlopen-test.patch index 1bf48e0eb87e3062c4591376df4a721ba5159b16..96b93ae585f704aa796ab01a91a838d341519a9b 100644 --- a/gdb-rhbz1156192-recursive-dlopen-test.patch +++ b/gdb-rhbz1156192-recursive-dlopen-test.patch @@ -1,3 +1,12 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1156192-recursive-dlopen-test.patch + +;; Testcase for '[SAP] Recursive dlopen causes SAP HANA installer to +;; crash.' (RH BZ 1156192). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libbar.c b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libbar.c new file mode 100644 --- /dev/null @@ -72,7 +81,7 @@ diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.c b/gdb/tes new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.c -@@ -0,0 +1,124 @@ +@@ -0,0 +1,125 @@ +/* Testcase for recursive dlopen calls. + + Copyright (C) 2014 Free Software Foundation, Inc. @@ -169,6 +178,7 @@ new file mode 100644 + /* Called recursively. */ + result = malloc (size); + /* Restore new hooks. */ ++ old_malloc_hook = __malloc_hook; + __malloc_hook = custom_malloc_hook; + return result; +} @@ -201,7 +211,7 @@ diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.exp b/gdb/t new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.exp -@@ -0,0 +1,137 @@ +@@ -0,0 +1,157 @@ +# Copyright 2014 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify @@ -217,8 +227,12 @@ new file mode 100644 +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+if { [skip_shlib_tests] } { -+ return 0 ++if {[skip_shlib_tests]} { ++ untested "skipping shlib tests" ++ return 0 ++} elseif {[use_gdb_stub]} { ++ untested "skipping tests because of stub" ++ return 0 +} + +# Library foo @@ -253,6 +267,21 @@ new file mode 100644 + return -1 +} + ++set supported 0 ++gdb_test_multiple "run" "initial trial run" { ++ -re -wrap "exited normally.*" { ++ set supported 1 ++ pass $gdb_test_name ++ } ++ -re -wrap "exited with code.*" { ++ untested "failed at $gdb_test_name" ++ } ++} ++ ++if { $supported == 0 } { ++ return -1 ++} ++ +proc do_test { has_libfoo has_libbar } { + global hex binfile_lib2 binfile_lib1 gdb_prompt + set libbar_match "[string_to_regexp $binfile_lib2]" @@ -305,6 +334,7 @@ new file mode 100644 + gdb_test_no_output "set stop-on-solib-events 1" "setting stop-on-solib-events" + + gdb_run_cmd ++ gdb_test "" "Wait for first prompt" + foreach l $solib_event_order { + incr pass + with_test_prefix "pass #$pass" { diff --git a/gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch b/gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch index 7cc191d19224a097e52b7c90017160a27b4eeac3..21a1a082d58f6cba0f96c6dc18e020fcd7ff5eb9 100644 --- a/gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch +++ b/gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch @@ -1,3 +1,24 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch + +;; Fix 'backport GDB 7.4 fix to RHEL 6.6 GDB' [Original Sourceware bug +;; description: 'C++ (and objc): Internal error on unqualified name +;; re-set', PR 11657] (RH BZ 1186476). +;;=fedoratest + +Comments from Sergio Durigan Junior: + + The "proper" fix for this whole problem would be to backport the + "ambiguous linespec" patch series. However, it is really not + recommended to do that for RHEL GDB, because the patch series is too + big and could introduce unwanted regressions. Instead, what we + chose to do was to replace the gdb_assert call by a warning (which + allows the user to continue the debugging session), and tell the + user that, although more than one location was found for his/her + breakpoint, only one will be used. + diff --git a/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc new file mode 100644 --- /dev/null diff --git a/gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch b/gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch index 2b981d42d3dee0cfecbf5b612cdd577d6574da0f..a0eb4403cf1085b4b3db1eeba65b6cfbf030bdce 100644 --- a/gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch +++ b/gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch + +;; [aarch64] Fix hardware watchpoints (RH BZ 1261564). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.c b/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.c new file mode 100644 --- /dev/null @@ -65,7 +73,7 @@ new file mode 100644 +set test "rwatch aligned.var4" +if [istarget "s390*-*-*"] { + gdb_test $test {Target does not support this type of hardware watchpoint\.} -+ untested "s390* does not support hw read watchpoint" ++ untested "s390* does not support hw read watchpoint" + return +} +gdb_test $test "Hardware read watchpoint \[0-9\]+: aligned.var4" diff --git a/gdb-rhbz1325795-framefilters-test.patch b/gdb-rhbz1325795-framefilters-test.patch index 72fedd4008be674e41d1d54d98ab3b3803517c78..cfe309d970889951a284734387c7a165a518ad1e 100644 --- a/gdb-rhbz1325795-framefilters-test.patch +++ b/gdb-rhbz1325795-framefilters-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1325795-framefilters-test.patch + +;; New test for Python "Cannot locate object file for block" (for RH BZ 1325795). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.python/py-framefilter-thread.c b/gdb/testsuite/gdb.python/py-framefilter-thread.c new file mode 100644 --- /dev/null diff --git a/gdb-rhbz1350436-type-printers-error.patch b/gdb-rhbz1350436-type-printers-error.patch index 0f5aa353f5c25bc0e1253ac6373c0b6b17e94d0e..33223276cebd9b84af21e5488c451c58d00d49e0 100644 --- a/gdb-rhbz1350436-type-printers-error.patch +++ b/gdb-rhbz1350436-type-printers-error.patch @@ -1,3 +1,17 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1350436-type-printers-error.patch + +;; Test 'info type-printers' Python error (RH BZ 1350436). +;;=fedoratest + +Typo in Python support breaks info type-printers command +https://bugzilla.redhat.com/show_bug.cgi?id=1350436 + +[testsuite patch] PR python/17136: 'info type-printers' causes an exception when there are per-objfile printers +https://sourceware.org/ml/gdb-patches/2016-06/msg00455.html + diff --git a/gdb/testsuite/gdb.python/py-typeprint.cc b/gdb/testsuite/gdb.python/py-typeprint.cc --- a/gdb/testsuite/gdb.python/py-typeprint.cc +++ b/gdb/testsuite/gdb.python/py-typeprint.cc @@ -28,22 +42,24 @@ diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.pytho diff --git a/gdb/testsuite/gdb.python/py-typeprint.py b/gdb/testsuite/gdb.python/py-typeprint.py --- a/gdb/testsuite/gdb.python/py-typeprint.py +++ b/gdb/testsuite/gdb.python/py-typeprint.py -@@ -15,7 +15,7 @@ +@@ -15,8 +15,7 @@ import gdb +- -class Recognizer(object): +class StringRecognizer(object): def __init__(self): self.enabled = True -@@ -30,6 +30,26 @@ class StringTypePrinter(object): +@@ -32,7 +31,27 @@ class StringTypePrinter(object): self.enabled = True def instantiate(self): - return Recognizer() + return StringRecognizer() + gdb.type_printers.append(StringTypePrinter()) + +class OtherRecognizer(object): diff --git a/gdb-rhbz1398387-tab-crash-test.patch b/gdb-rhbz1398387-tab-crash-test.patch index 835b2312a1cfc19cecc77b6adadb37671d044bf3..d0555c06111f28eda829324390223e871e874ec7 100644 --- a/gdb-rhbz1398387-tab-crash-test.patch +++ b/gdb-rhbz1398387-tab-crash-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1398387-tab-crash-test.patch + +;; New testcase for: Fix -completion crash (Gary Benson, RH BZ 1398387). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.base/tab-crash.bz2.uu b/gdb/testsuite/gdb.base/tab-crash.bz2.uu new file mode 100644 --- /dev/null @@ -420,7 +428,7 @@ new file mode 100644 + +if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { + return -+} ++} + +standard_testfile + diff --git a/gdb-rhbz1553104-s390x-arch12-test.patch b/gdb-rhbz1553104-s390x-arch12-test.patch index bcfd342d7c4e0dd3734506d5653f2c365d898a76..2cb15e5b25fddfc2bec064b5009d8d273e87286c 100644 --- a/gdb-rhbz1553104-s390x-arch12-test.patch +++ b/gdb-rhbz1553104-s390x-arch12-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 23 Mar 2018 20:42:44 +0100 +Subject: gdb-rhbz1553104-s390x-arch12-test.patch + +;; [s390x] Backport arch12 instructions decoding (RH BZ 1553104). +;; =fedoratest + diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.S b/gdb/testsuite/gdb.arch/s390x-arch12.S new file mode 100644 --- /dev/null diff --git a/gdb-rhbz1818011-bfd-gcc10-error.patch b/gdb-rhbz1818011-bfd-gcc10-error.patch deleted file mode 100644 index 01740ab9fd8bc270cf2ce03e4b9ee8100a8057f7..0000000000000000000000000000000000000000 --- a/gdb-rhbz1818011-bfd-gcc10-error.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h ---- a/bfd/elf-bfd.h -+++ b/bfd/elf-bfd.h -@@ -1937,7 +1937,7 @@ struct elf_obj_tdata - struct sdt_note *sdt_note_head; - - Elf_Internal_Shdr **group_sect_ptr; -- int num_group; -+ unsigned int num_group; - - /* Index into group_sect_ptr, updated by setup_group when finding a - section's group. Used to optimize subsequent group searches. */ diff --git a/gdb-rhbz1822715-fix-python-deprecation.patch b/gdb-rhbz1822715-fix-python-deprecation.patch deleted file mode 100644 index e0527262219ff81f1a18e5a7e105bb1a068ecedd..0000000000000000000000000000000000000000 --- a/gdb-rhbz1822715-fix-python-deprecation.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/gdb/python/python.c b/gdb/python/python.c ---- a/gdb/python/python.c -+++ b/gdb/python/python.c -@@ -1618,7 +1618,12 @@ do_start_initialization () - #endif - - Py_Initialize (); -+#if PY_VERSION_HEX < 0x03090000 -+ /* PyEval_InitThreads became deprecated in Python 3.9 and will -+ be removed in Python 3.11. Prior to Python 3.7, this call was -+ required to initialize the GIL. */ - PyEval_InitThreads (); -+#endif - - #ifdef IS_PY3K - gdb_module = PyImport_ImportModule ("_gdb"); diff --git a/gdb-rhbz1829702-fix-python39.patch b/gdb-rhbz1829702-fix-python39.patch deleted file mode 100644 index ca072052922c46e20332ca88b1fefda15214659a..0000000000000000000000000000000000000000 --- a/gdb-rhbz1829702-fix-python39.patch +++ /dev/null @@ -1,94 +0,0 @@ -diff --git a/gdb/python/python.c b/gdb/python/python.c ---- a/gdb/python/python.c -+++ b/gdb/python/python.c -@@ -234,6 +234,30 @@ gdbpy_enter::~gdbpy_enter () - PyGILState_Release (m_state); - } - -+/* A helper class to save and restore the GIL, but without touching -+ the other globals that are handled by gdbpy_enter. */ -+ -+class gdbpy_gil -+{ -+public: -+ -+ gdbpy_gil () -+ : m_state (PyGILState_Ensure ()) -+ { -+ } -+ -+ ~gdbpy_gil () -+ { -+ PyGILState_Release (m_state); -+ } -+ -+ DISABLE_COPY_AND_ASSIGN (gdbpy_gil); -+ -+private: -+ -+ PyGILState_STATE m_state; -+}; -+ - /* Set the quit flag. */ - - static void -@@ -247,6 +271,10 @@ gdbpy_set_quit_flag (const struct extension_language_defn *extlang) - static int - gdbpy_check_quit_flag (const struct extension_language_defn *extlang) - { -+ if (!gdb_python_initialized) -+ return 0; -+ -+ gdbpy_gil gil; - return PyOS_InterruptOccurred (); - } - -@@ -924,30 +952,6 @@ gdbpy_source_script (const struct extension_language_defn *extlang, - - /* Posting and handling events. */ - --/* A helper class to save and restore the GIL, but without touching -- the other globals that are handled by gdbpy_enter. */ -- --class gdbpy_gil --{ --public: -- -- gdbpy_gil () -- : m_state (PyGILState_Ensure ()) -- { -- } -- -- ~gdbpy_gil () -- { -- PyGILState_Release (m_state); -- } -- -- DISABLE_COPY_AND_ASSIGN (gdbpy_gil); -- --private: -- -- PyGILState_STATE m_state; --}; -- - /* A single event. */ - struct gdbpy_event - { -@@ -1548,6 +1552,7 @@ finalize_python (void *ignore) - - Py_Finalize (); - -+ gdb_python_initialized = false; - restore_active_ext_lang (previous_active); - } - -@@ -1720,8 +1725,7 @@ do_start_initialization () - return false; - - /* Release the GIL while gdb runs. */ -- PyThreadState_Swap (NULL); -- PyEval_ReleaseLock (); -+ PyEval_SaveThread (); - - make_final_cleanup (finalize_python, NULL); - diff --git a/gdb-rhbz1838777-debuginfod.patch b/gdb-rhbz1838777-debuginfod.patch deleted file mode 100644 index 299227848f74cd22da0bfd36a60edee24735addc..0000000000000000000000000000000000000000 --- a/gdb-rhbz1838777-debuginfod.patch +++ /dev/null @@ -1,1128 +0,0 @@ -diff --git a/config/debuginfod.m4 b/config/debuginfod.m4 -new file mode 100644 ---- /dev/null -+++ b/config/debuginfod.m4 -@@ -0,0 +1,38 @@ -+dnl Copyright (C) 1997-2019 Free Software Foundation, Inc. -+dnl This file is free software, distributed under the terms of the GNU -+dnl General Public License. As a special exception to the GNU General -+dnl Public License, this file may be distributed as part of a program -+dnl that contains a configuration script generated by Autoconf, under -+dnl the same distribution terms as the rest of that program. -+ -+AC_DEFUN([AC_DEBUGINFOD], -+[ -+# Enable debuginfod -+AC_ARG_WITH([debuginfod], -+ AC_HELP_STRING([--with-debuginfod], -+ [Enable debuginfo lookups with debuginfod (auto/yes/no)]), -+ [], [with_debuginfod=auto]) -+AC_MSG_CHECKING([whether to use debuginfod]) -+AC_MSG_RESULT([$with_debuginfod]) -+ -+if test "${with_debuginfod}" = no; then -+ AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.]) -+else -+ AC_CHECK_LIB([debuginfod], [debuginfod_begin], [have_debuginfod_lib=yes]) -+ AC_CHECK_DECL([debuginfod_begin], [have_debuginfod_h=yes], [], -+ [#include ]) -+ if test "x$have_debuginfod_lib" = "xyes" -a \ -+ "x$have_debuginfod_h" = "xyes"; then -+ AC_DEFINE([HAVE_LIBDEBUGINFOD], [1], -+ [Define to 1 if debuginfod is enabled.]) -+ AC_SUBST([LIBDEBUGINFOD], ["-ldebuginfod"]) -+ else -+ AC_SUBST([LIBDEBUGINFOD], []) -+ if test "$with_debuginfod" = yes; then -+ AC_MSG_ERROR([debuginfod is missing or unusable]) -+ else -+ AC_MSG_WARN([debuginfod is missing or unusable; some features may be unavailable.]) -+ fi -+ fi -+fi -+]) -diff --git a/gdb/Makefile.in b/gdb/Makefile.in ---- a/gdb/Makefile.in -+++ b/gdb/Makefile.in -@@ -612,7 +612,8 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(LIBCTF) $(ZLIB) \ - @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \ - $(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \ - $(LIBIBERTY) $(WIN32LIBS) $(LIBGNU) $(LIBICONV) $(LIBMPFR) \ -- $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) -+ $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \ -+ @LIBDEBUGINFOD@ - CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(LIBCTF) \ - $(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) - -@@ -1016,6 +1017,7 @@ COMMON_SFILES = \ - dbxread.c \ - dcache.c \ - debug.c \ -+ debuginfod-support.c \ - dictionary.c \ - disasm.c \ - disasm-selftests.c \ -diff --git a/gdb/NEWS b/gdb/NEWS ---- a/gdb/NEWS -+++ b/gdb/NEWS -@@ -932,6 +932,20 @@ SH-5/SH64 running OpenBSD SH-5/SH64 support in sh*-*-openbsd* - manual for a further description of this feature. - - -+* GDB now supports debuginfod, an HTTP server for distributing ELF/DWARF -+ debugging information as well as source code. -+ -+ When built with debuginfod, GDB can automatically query debuginfod -+ servers for the separate debug files and source code of the executable -+ being debugged. -+ -+ To build GDB with debuginfod, pass --with-debuginfod to configure (this -+ requires libdebuginfod, the debuginfod client library). -+ -+ debuginfod is distributed with elfutils, starting with version 0.178. -+ -+ You can get the latest version from https://sourceware.org/elfutils. -+ - * New features in the GDB remote stub, GDBserver - - ** GDBserver is now able to start inferior processes with a -diff --git a/gdb/README b/gdb/README ---- a/gdb/README -+++ b/gdb/README -@@ -432,6 +432,15 @@ more obscure GDB `configure' options are not listed here. - Use the curses library instead of the termcap library, for - text-mode terminal operations. - -+`--with-debuginfod' -+ Build GDB with libdebuginfod, the debuginfod client library. Used -+ to automatically fetch source files and separate debug files from -+ debuginfod servers using the associated executable's build ID. -+ Enabled by default if libdebuginfod is installed and found at -+ configure time. debuginfod is packaged with elfutils, starting -+ with version 0.178. You can get the latest version from -+ 'https://sourceware.org/elfutils/'. -+ - `--with-libunwind-ia64' - Use the libunwind library for unwinding function call stack on ia64 - target platforms. -diff --git a/gdb/config.in b/gdb/config.in ---- a/gdb/config.in -+++ b/gdb/config.in -@@ -230,6 +230,9 @@ - /* Define if you have the babeltrace library. */ - #undef HAVE_LIBBABELTRACE - -+/* Define to 1 if debuginfod is enabled. */ -+#undef HAVE_LIBDEBUGINFOD -+ - /* Define if you have the expat library. */ - #undef HAVE_LIBEXPAT - -diff --git a/gdb/configure b/gdb/configure ---- a/gdb/configure -+++ b/gdb/configure -@@ -758,6 +758,7 @@ REPORT_BUGS_TEXI - REPORT_BUGS_TO - PKGVERSION - CODESIGN_CERT -+LIBDEBUGINFOD - HAVE_NATIVE_GCORE_TARGET - TARGET_OBS - subdirs -@@ -875,6 +876,7 @@ enable_64_bit_bfd - enable_gdbmi - enable_tui - enable_gdbtk -+with_debuginfod - with_libunwind_ia64 - with_curses - enable_profiling -@@ -1611,6 +1613,8 @@ Optional Packages: - do not restrict auto-loaded files locations - --with-rpm query rpm database for missing debuginfos (yes/no, - def. auto=librpm.so) -+ --with-debuginfod Enable debuginfo lookups with debuginfod -+ (auto/yes/no) - --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets - --with-curses use the curses library instead of the termcap - library -@@ -2271,6 +2275,52 @@ rm -f conftest.val - - } # ac_fn_c_compute_int - -+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES -+# --------------------------------------------- -+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR -+# accordingly. -+ac_fn_c_check_decl () -+{ -+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -+ as_decl_name=`echo $2|sed 's/ *(.*//'` -+ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -+$as_echo_n "checking whether $as_decl_name is declared... " >&6; } -+if eval \${$3+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+$4 -+int -+main () -+{ -+#ifndef $as_decl_name -+#ifdef __cplusplus -+ (void) $as_decl_use; -+#else -+ (void) $as_decl_name; -+#endif -+#endif -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ eval "$3=yes" -+else -+ eval "$3=no" -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+eval ac_res=\$$3 -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -+$as_echo "$ac_res" >&6; } -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -+ -+} # ac_fn_c_check_decl -+ - # ac_fn_c_check_func LINENO FUNC VAR - # ---------------------------------- - # Tests whether FUNC exists, setting the cache variable VAR accordingly -@@ -2449,52 +2499,6 @@ $as_echo "$ac_res" >&6; } - - } # ac_fn_c_check_type - --# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES --# --------------------------------------------- --# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR --# accordingly. --ac_fn_c_check_decl () --{ -- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -- as_decl_name=`echo $2|sed 's/ *(.*//'` -- as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 --$as_echo_n "checking whether $as_decl_name is declared... " >&6; } --if eval \${$3+:} false; then : -- $as_echo_n "(cached) " >&6 --else -- cat confdefs.h - <<_ACEOF >conftest.$ac_ext --/* end confdefs.h. */ --$4 --int --main () --{ --#ifndef $as_decl_name --#ifdef __cplusplus -- (void) $as_decl_use; --#else -- (void) $as_decl_name; --#endif --#endif -- -- ; -- return 0; --} --_ACEOF --if ac_fn_c_try_compile "$LINENO"; then : -- eval "$3=yes" --else -- eval "$3=no" --fi --rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext --fi --eval ac_res=\$$3 -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 --$as_echo "$ac_res" >&6; } -- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -- --} # ac_fn_c_check_decl -- - # ac_fn_cxx_try_link LINENO - # ------------------------- - # Try to link conftest.$ac_ext, and return whether this succeeded. -@@ -6658,8 +6662,8 @@ $as_echo_n "checking specific librpm version... " >&6; } - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --as_fn_error "cannot run test program while cross compiling --See \`config.log' for more details." "$LINENO" 5; } -+as_fn_error $? "cannot run test program while cross compiling -+See \`config.log' for more details" "$LINENO" 5; } - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext - /* end confdefs.h. */ -@@ -6830,7 +6834,7 @@ $as_echo "#define HAVE_LIBRPM 1" >>confdefs.h - $as_echo "no" >&6; } - LIBS="$save_LIBS" - if $DLOPEN_REQUIRE; then -- as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5 -+ as_fn_error $? "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5 - fi - - -@@ -6845,7 +6849,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 - $as_echo_n "checking for $ac_word... " >&6; } --if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : -+if ${ac_cv_path_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 - else - case $PKG_CONFIG in -@@ -6859,7 +6863,7 @@ do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do -- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 -@@ -6888,7 +6892,7 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then - set dummy pkg-config; ac_word=$2 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 - $as_echo_n "checking for $ac_word... " >&6; } --if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : -+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 - else - case $ac_pt_PKG_CONFIG in -@@ -6902,7 +6906,7 @@ do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do -- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 -@@ -7086,7 +7090,7 @@ $as_echo "#define HAVE_LIBRPM 1" >>confdefs.h - LIBS="$LIBS $RPM_LIBS" - else - if $RPM_REQUIRE; then -- as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5 -+ as_fn_error $? "$RPM_PKG_ERRORS" "$LINENO" 5 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5 - $as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;} -@@ -7332,8 +7336,92 @@ $as_echo "$as_me: WARNING: gdbtk isn't supported on $host; disabling" >&2;} - enable_gdbtk=no ;; - esac - --# Libunwind support for ia64. -+# Handle optional debuginfod support -+ -+# Enable debuginfod -+ -+# Check whether --with-debuginfod was given. -+if test "${with_debuginfod+set}" = set; then : -+ withval=$with_debuginfod; -+else -+ with_debuginfod=auto -+fi -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use debuginfod" >&5 -+$as_echo_n "checking whether to use debuginfod... " >&6; } -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_debuginfod" >&5 -+$as_echo "$with_debuginfod" >&6; } -+ -+if test "${with_debuginfod}" = no; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod support disabled; some features may be unavailable." >&5 -+$as_echo "$as_me: WARNING: debuginfod support disabled; some features may be unavailable." >&2;} -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for debuginfod_begin in -ldebuginfod" >&5 -+$as_echo_n "checking for debuginfod_begin in -ldebuginfod... " >&6; } -+if ${ac_cv_lib_debuginfod_debuginfod_begin+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldebuginfod $LIBS" -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char debuginfod_begin (); -+int -+main () -+{ -+return debuginfod_begin (); -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_debuginfod_debuginfod_begin=yes -+else -+ ac_cv_lib_debuginfod_debuginfod_begin=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_debuginfod_debuginfod_begin" >&5 -+$as_echo "$ac_cv_lib_debuginfod_debuginfod_begin" >&6; } -+if test "x$ac_cv_lib_debuginfod_debuginfod_begin" = xyes; then : -+ have_debuginfod_lib=yes -+fi -+ -+ ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include -+" -+if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then : -+ have_debuginfod_h=yes -+fi -+ -+ if test "x$have_debuginfod_lib" = "xyes" -a \ -+ "x$have_debuginfod_h" = "xyes"; then -+ -+$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h -+ -+ LIBDEBUGINFOD="-ldebuginfod" - -+ else -+ -+ if test "$with_debuginfod" = yes; then -+ as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5 -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5 -+$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;} -+ fi -+ fi -+fi -+ -+ -+# Libunwind support for ia64. - - # Check whether --with-libunwind-ia64 was given. - if test "${with_libunwind_ia64+set}" = set; then : -@@ -16441,7 +16529,7 @@ _ACEOF - for ac_header in selinux/selinux.h - do : - ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default" --if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then : -+if test "x$ac_cv_header_selinux_selinux_h" = xyes; then : - cat >>confdefs.h <<_ACEOF - #define HAVE_SELINUX_SELINUX_H 1 - _ACEOF -@@ -16452,7 +16540,7 @@ done - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_get_boolean_active in -lselinux" >&5 - $as_echo_n "checking for security_get_boolean_active in -lselinux... " >&6; } --if test "${ac_cv_lib_selinux_security_get_boolean_active+set}" = set; then : -+if ${ac_cv_lib_selinux_security_get_boolean_active+:} false; then : - $as_echo_n "(cached) " >&6 - else - ac_check_lib_save_LIBS=$LIBS -@@ -16486,7 +16574,7 @@ LIBS=$ac_check_lib_save_LIBS - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_security_get_boolean_active" >&5 - $as_echo "$ac_cv_lib_selinux_security_get_boolean_active" >&6; } --if test "x$ac_cv_lib_selinux_security_get_boolean_active" = x""yes; then : -+if test "x$ac_cv_lib_selinux_security_get_boolean_active" = xyes; then : - cat >>confdefs.h <<_ACEOF - #define HAVE_LIBSELINUX 1 - _ACEOF -diff --git a/gdb/configure.ac b/gdb/configure.ac ---- a/gdb/configure.ac -+++ b/gdb/configure.ac -@@ -18,6 +18,8 @@ dnl along with this program. If not, see . - - dnl Process this file with autoconf to produce a configure script. - -+m4_include(../config/debuginfod.m4) -+ - AC_INIT(main.c) - AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h]) - AM_MAINTAINER_MODE -@@ -516,8 +518,10 @@ case $host_os in - enable_gdbtk=no ;; - esac - --# Libunwind support for ia64. -+# Handle optional debuginfod support -+AC_DEBUGINFOD - -+# Libunwind support for ia64. - AC_ARG_WITH(libunwind-ia64, - AS_HELP_STRING([--with-libunwind-ia64], - [use libunwind frame unwinding for ia64 targets]),, -diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c -new file mode 100644 ---- /dev/null -+++ b/gdb/debuginfod-support.c -@@ -0,0 +1,155 @@ -+/* debuginfod utilities for GDB. -+ Copyright (C) 2020 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 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 . */ -+ -+#include "defs.h" -+#include -+#include "cli/cli-style.h" -+#include "gdbsupport/scoped_fd.h" -+#include "debuginfod-support.h" -+ -+#ifndef HAVE_LIBDEBUGINFOD -+scoped_fd -+debuginfod_source_query (const unsigned char *build_id, -+ int build_id_len, -+ const char *srcpath, -+ gdb::unique_xmalloc_ptr *destname) -+{ -+ return scoped_fd (-ENOSYS); -+} -+ -+scoped_fd -+debuginfod_debuginfo_query (const unsigned char *build_id, -+ int build_id_len, -+ const char *filename, -+ gdb::unique_xmalloc_ptr *destname) -+{ -+ return scoped_fd (-ENOSYS); -+} -+#else -+#include -+ -+/* TODO: Use debuginfod API extensions instead of these globals. */ -+static std::string desc; -+static std::string fname; -+static bool has_printed; -+ -+static int -+progressfn (debuginfod_client *c, long cur, long total) -+{ -+ if (check_quit_flag ()) -+ { -+ printf_filtered ("Cancelling download of %s %ps...\n", -+ desc.c_str (), -+ styled_string (file_name_style.style (), fname.c_str ())); -+ return 1; -+ } -+ -+ if (!has_printed && total != 0) -+ { -+ /* Print this message only once. */ -+ has_printed = true; -+ printf_filtered ("Downloading %s %ps...\n", -+ desc.c_str (), -+ styled_string (file_name_style.style (), fname.c_str ())); -+ } -+ -+ return 0; -+} -+ -+static debuginfod_client * -+debuginfod_init () -+{ -+ debuginfod_client *c = debuginfod_begin (); -+ -+ if (c != nullptr) -+ debuginfod_set_progressfn (c, progressfn); -+ -+ return c; -+} -+ -+/* See debuginfod-support.h */ -+ -+scoped_fd -+debuginfod_source_query (const unsigned char *build_id, -+ int build_id_len, -+ const char *srcpath, -+ gdb::unique_xmalloc_ptr *destname) -+{ -+ if (getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL) -+ return scoped_fd (-ENOSYS); -+ -+ debuginfod_client *c = debuginfod_init (); -+ -+ if (c == nullptr) -+ return scoped_fd (-ENOMEM); -+ -+ desc = std::string ("source file"); -+ fname = std::string (srcpath); -+ has_printed = false; -+ -+ scoped_fd fd (debuginfod_find_source (c, -+ build_id, -+ build_id_len, -+ srcpath, -+ nullptr)); -+ -+ /* TODO: Add 'set debug debuginfod' command to control when error messages are shown. */ -+ if (fd.get () < 0 && fd.get () != -ENOENT) -+ printf_filtered (_("Download failed: %s. Continuing without source file %ps.\n"), -+ safe_strerror (-fd.get ()), -+ styled_string (file_name_style.style (), srcpath)); -+ else -+ destname->reset (xstrdup (srcpath)); -+ -+ debuginfod_end (c); -+ return fd; -+} -+ -+/* See debuginfod-support.h */ -+ -+scoped_fd -+debuginfod_debuginfo_query (const unsigned char *build_id, -+ int build_id_len, -+ const char *filename, -+ gdb::unique_xmalloc_ptr *destname) -+{ -+ if (getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL) -+ return scoped_fd (-ENOSYS); -+ -+ debuginfod_client *c = debuginfod_init (); -+ -+ if (c == nullptr) -+ return scoped_fd (-ENOMEM); -+ -+ desc = std::string ("separate debug info for"); -+ fname = std::string (filename); -+ has_printed = false; -+ char *dname = nullptr; -+ -+ scoped_fd fd (debuginfod_find_debuginfo (c, build_id, build_id_len, &dname)); -+ -+ if (fd.get () < 0 && fd.get () != -ENOENT) -+ printf_filtered (_("Download failed: %s. Continuing without debug info for %ps.\n"), -+ safe_strerror (-fd.get ()), -+ styled_string (file_name_style.style (), filename)); -+ -+ destname->reset (dname); -+ debuginfod_end (c); -+ return fd; -+} -+#endif -diff --git a/gdb/debuginfod-support.h b/gdb/debuginfod-support.h -new file mode 100644 ---- /dev/null -+++ b/gdb/debuginfod-support.h -@@ -0,0 +1,62 @@ -+/* debuginfod utilities for GDB. -+ Copyright (C) 2020 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 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 . */ -+ -+#ifndef DEBUGINFOD_SUPPORT_H -+#define DEBUGINFOD_SUPPORT_H -+ -+/* Query debuginfod servers for a source file associated with an -+ executable with BUILD_ID. BUILD_ID can be given as a binary blob or -+ a null-terminated string. If given as a binary blob, BUILD_ID_LEN -+ should be the number of bytes. If given as a null-terminated string, -+ BUILD_ID_LEN should be 0. -+ -+ SRC_PATH should be the source file's absolute path that includes the -+ compilation directory of the CU associated with the source file. -+ For example if a CU's compilation directory is `/my/build` and the -+ source file path is `/my/source/foo.c`, then SRC_PATH should be -+ `/my/build/../source/foo.c`. -+ -+ If the file is successfully retrieved, its path on the local machine -+ is stored in DESTNAME. If GDB is not built with debuginfod, this -+ function returns -ENOSYS. */ -+ -+extern scoped_fd -+debuginfod_source_query (const unsigned char *build_id, -+ int build_id_len, -+ const char *src_path, -+ gdb::unique_xmalloc_ptr *destname); -+ -+/* Query debuginfod servers for a debug info file with BUILD_ID. -+ BUILD_ID can be given as a binary blob or a null-terminated string. -+ If given as a binary blob, BUILD_ID_LEN should be the number of bytes. -+ If given as a null-terminated string, BUILD_ID_LEN should be 0. -+ -+ FILENAME should be the name or path of the main binary associated with -+ the separate debug info. It is used for printing messages to the user. -+ -+ If the file is successfully retrieved, its path on the local machine -+ is stored in DESTNAME. If GDB is not built with debuginfod, this -+ function returns -ENOSYS. */ -+ -+extern scoped_fd -+debuginfod_debuginfo_query (const unsigned char *build_id, -+ int build_id_len, -+ const char *filename, -+ gdb::unique_xmalloc_ptr *destname); -+ -+#endif /* DEBUGINFOD_SUPPORT_H */ -diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo ---- a/gdb/doc/gdb.texinfo -+++ b/gdb/doc/gdb.texinfo -@@ -37726,6 +37726,14 @@ supported). - Use the curses library instead of the termcap library, for text-mode - terminal operations. - -+@item --with-debuginfod -+Build @value{GDBN} with libdebuginfod, the debuginfod client library. -+Used to automatically fetch source files and separate debug files from -+debuginfod servers using the associated executable's build ID. Enabled -+by default if libdebuginfod is installed and found at configure time. -+debuginfod is packaged with elfutils, starting with version 0.178. You -+can get the latest version from `https://sourceware.org/elfutils/'. -+ - @item --with-libunwind-ia64 - Use the libunwind library for unwinding function call stack on ia64 - target platforms. See http://www.nongnu.org/libunwind/index.html for -diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -77,6 +77,7 @@ - #include "gdbsupport/selftest.h" - #include "rust-lang.h" - #include "gdbsupport/pathstuff.h" -+#include "debuginfod-support.h" - - /* When == 1, print basic high level tracing messages. - When > 1, be more verbose. -@@ -2717,6 +2718,29 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile) - dwz_bfd.reset (nullptr); - } - -+ if (dwz_bfd == nullptr) -+ { -+ gdb::unique_xmalloc_ptr alt_filename; -+ const char *origname = dwarf2_per_objfile->objfile->original_name; -+ -+ scoped_fd fd (debuginfod_debuginfo_query (buildid, -+ buildid_len, -+ origname, -+ &alt_filename)); -+ -+ if (fd.get () >= 0) -+ { -+ /* File successfully retrieved from server. */ -+ dwz_bfd = gdb_bfd_open (alt_filename.get (), gnutarget, -1); -+ -+ if (dwz_bfd == nullptr) -+ warning (_("File \"%s\" from debuginfod cannot be opened as bfd"), -+ alt_filename.get ()); -+ else if (!build_id_verify (dwz_bfd.get (), buildid_len, buildid)) -+ dwz_bfd.reset (nullptr); -+ } -+ } -+ - if (dwz_bfd == NULL) - dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid, NULL); - -diff --git a/gdb/elfread.c b/gdb/elfread.c ---- a/gdb/elfread.c -+++ b/gdb/elfread.c -@@ -49,6 +49,8 @@ - #include "mdebugread.h" - #include "ctfread.h" - #include "gdbsupport/gdb_string_view.h" -+#include "gdbsupport/scoped_fd.h" -+#include "debuginfod-support.h" - - /* Forward declarations. */ - extern const struct sym_fns elf_sym_fns_gdb_index; -@@ -1313,12 +1315,42 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) - symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (), - symfile_flags, objfile); - } -- /* Check if any separate debug info has been extracted out. */ -- else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink") -- != NULL) -- debug_print_missing (objfile_name (objfile), build_id_filename.get ()); - else -- has_dwarf2 = false; -+ { -+ has_dwarf2 = false; -+ const struct bfd_build_id *build_id = build_id_bfd_shdr_get (objfile->obfd); -+ -+ if (build_id != nullptr) -+ { -+ gdb::unique_xmalloc_ptr symfile_path; -+ scoped_fd fd (debuginfod_debuginfo_query (build_id->data, -+ build_id->size, -+ objfile->original_name, -+ &symfile_path)); -+ -+ if (fd.get () >= 0) -+ { -+ /* File successfully retrieved from server. */ -+ gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (symfile_path.get ())); -+ -+ if (debug_bfd == nullptr) -+ warning (_("File \"%s\" from debuginfod cannot be opened as bfd"), -+ objfile->original_name); -+ else if (build_id_verify (debug_bfd.get (), build_id->size, build_id->data)) -+ { -+ symbol_file_add_separate (debug_bfd.get (), symfile_path.get (), -+ symfile_flags, objfile); -+ has_dwarf2 = true; -+ } -+ } -+ } -+ /* Check if any separate debug info has been extracted out. */ -+ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink") -+ != NULL) -+ debug_print_missing (objfile_name (objfile), build_id_filename.get ()); -+ else -+ has_dwarf2 = false; -+ } - } - - /* Read the CTF section only if there is no DWARF info. */ -diff --git a/gdb/source.c b/gdb/source.c ---- a/gdb/source.c -+++ b/gdb/source.c -@@ -47,6 +47,8 @@ - #include "gdbsupport/pathstuff.h" - #include "source-cache.h" - #include "cli/cli-style.h" -+#include "build-id.h" -+#include "debuginfod-support.h" - - #define OPEN_MODE (O_RDONLY | O_BINARY) - #define FDOPEN_MODE FOPEN_RB -@@ -1122,6 +1124,34 @@ open_source_file (struct symtab *s) - s->fullname = NULL; - scoped_fd fd = find_and_open_source (s->filename, SYMTAB_DIRNAME (s), - &fullname); -+ -+ if (fd.get () < 0) -+ { -+ if (SYMTAB_COMPUNIT (s) != nullptr) -+ { -+ const objfile *ofp = COMPUNIT_OBJFILE (SYMTAB_COMPUNIT (s)); -+ -+ std::string srcpath; -+ if (IS_ABSOLUTE_PATH (s->filename)) -+ srcpath = s->filename; -+ else if (SYMTAB_DIRNAME (s) != nullptr) -+ { -+ srcpath = SYMTAB_DIRNAME (s); -+ srcpath += SLASH_STRING; -+ srcpath += s->filename; -+ } -+ -+ const struct bfd_build_id *build_id = build_id_bfd_shdr_get (ofp->obfd); -+ -+ /* Query debuginfod for the source file. */ -+ if (build_id != nullptr) -+ fd = debuginfod_source_query (build_id->data, -+ build_id->size, -+ srcpath.c_str (), -+ &fullname); -+ } -+ } -+ - s->fullname = fullname.release (); - return fd; - } -diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp -@@ -0,0 +1,215 @@ -+# Copyright 2020 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 . -+ -+# Test debuginfod functionality -+ -+standard_testfile main.c -+ -+load_lib dwarf.exp -+ -+if { [which debuginfod] == 0 } { -+ untested "cannot find debuginfod" -+ return -1 -+} -+ -+if { [which curl] == 0 } { -+ untested "cannot find curl" -+ return -1 -+} -+ -+# Skip testing if gdb was not configured with debuginfod -+if { [string first "with-debuginfod" \ -+ [eval exec $GDB $INTERNAL_GDBFLAGS --configuration]] == -1 } { -+ untested "gdb not configured with debuginfod" -+ return -1 -+} -+ -+set cache [standard_output_file ".client_cache"] -+set db [standard_output_file ".debuginfod.db"] -+ -+# Delete any preexisting test files -+file delete -force $cache -+file delete -force $db -+ -+set sourcetmp [standard_output_file tmp-${srcfile}] -+set outputdir [standard_output_file {}] -+ -+# Make a copy source file that we can move around -+if { [catch {file copy -force ${srcdir}/${subdir}/${srcfile} \ -+ [standard_output_file ${sourcetmp}]}] != 0 } { -+ error "create temporary file" -+ return -1 -+} -+ -+if { [gdb_compile "$sourcetmp" "$binfile" executable {debug}] != "" } { -+ fail "compile" -+ return -1 -+} -+ -+setenv DEBUGINFOD_URLS "" -+setenv DEBUGINFOD_TIMEOUT 30 -+setenv DEBUGINFOD_CACHE_PATH $cache -+ -+# Test that gdb cannot find source without debuginfod -+clean_restart $binfile -+gdb_test_no_output "set substitute-path $outputdir /dev/null" -+gdb_test "list" ".*No such file or directory.*" -+ -+# Strip symbols into separate file and move it so gdb cannot find it without debuginfod -+if { [gdb_gnu_strip_debug $binfile ""] != 0 } { -+ fail "strip debuginfo" -+ return -1 -+} -+ -+set debugdir [standard_output_file "debug"] -+set debuginfo [standard_output_file "fetch_src_and_symbols.debug"] -+ -+file mkdir $debugdir -+file rename -force $debuginfo $debugdir -+ -+# Test that gdb cannot find symbols without debuginfod -+clean_restart $binfile -+gdb_test "file" ".*No symbol file.*" -+ -+# Write some assembly that just has a .gnu_debugaltlink section. -+# Copied from testsuite/gdb.dwarf2/dwzbuildid.exp. -+proc write_just_debugaltlink {filename dwzname buildid} { -+ set asm_file [standard_output_file $filename] -+ -+ Dwarf::assemble $asm_file { -+ upvar dwzname dwzname -+ upvar buildid buildid -+ -+ gnu_debugaltlink $dwzname $buildid -+ -+ # Only the DWARF reader checks .gnu_debugaltlink, so make sure -+ # there is a bit of DWARF in here. -+ cu {} { -+ compile_unit {{language @DW_LANG_C}} { -+ } -+ } -+ } -+} -+ -+# Write some DWARF that also sets the buildid. -+# Copied from testsuite/gdb.dwarf2/dwzbuildid.exp. -+proc write_dwarf_file {filename buildid {value 99}} { -+ set asm_file [standard_output_file $filename] -+ -+ Dwarf::assemble $asm_file { -+ declare_labels int_label int_label2 -+ -+ upvar buildid buildid -+ upvar value value -+ -+ build_id $buildid -+ -+ cu {} { -+ compile_unit {{language @DW_LANG_C}} { -+ int_label2: base_type { -+ {name int} -+ {byte_size 4 sdata} -+ {encoding @DW_ATE_signed} -+ } -+ -+ constant { -+ {name the_int} -+ {type :$int_label2} -+ {const_value $value data1} -+ } -+ } -+ } -+ } -+} -+ -+set buildid "01234567890abcdef0123456" -+ -+write_just_debugaltlink ${binfile}_has_altlink.S ${binfile}_dwz.o $buildid -+write_dwarf_file ${binfile}_dwz.S $buildid -+ -+if {[gdb_compile ${binfile}_has_altlink.S ${binfile}_alt.o object nodebug] != ""} { -+ fail "compile main with altlink" -+ return -1 -+} -+ -+if {[gdb_compile ${binfile}_dwz.S ${binfile}_dwz.o object nodebug] != ""} { -+ fail "compile altlink" -+ return -1 -+} -+ -+file rename -force ${binfile}_dwz.o $debugdir -+ -+# Test that gdb cannot find dwz without debuginfod. -+clean_restart -+gdb_test "file ${binfile}_alt.o" ".*could not find '.gnu_debugaltlink'.*" -+ -+# Find an unused port -+set port 7999 -+set found 0 -+while { ! $found } { -+ incr port -+ if { $port == 65536 } { -+ fail "no available ports" -+ return -1 -+ } -+ -+ spawn debuginfod -vvvv -d $db -p $port -F $debugdir -+ expect { -+ "started http server on IPv4 IPv6 port=$port" { set found 1 } -+ "failed to bind to port" { kill_wait_spawned_process $spawn_id } -+ timeout { -+ fail "find port timeout" -+ return -1 -+ } -+ } -+} -+ -+set metrics [list "ready 1" \ -+ "thread_work_total{role=\"traverse\"} 1" \ -+ "thread_work_pending{role=\"scan\"} 0" \ -+ "thread_busy{role=\"scan\"} 0"] -+ -+# Check server metrics to confirm init has completed. -+foreach m $metrics { -+ set timelim 20 -+ while { $timelim != 0 } { -+ sleep 0.5 -+ catch {exec curl -s http://127.0.0.1:$port/metrics} got -+ -+ if { [regexp $m $got] } { -+ break -+ } -+ -+ incr timelim -1 -+ } -+ -+ if { $timelim == 0 } { -+ fail "server init timeout" -+ return -1 -+ } -+} -+ -+# Point the client to the server -+setenv DEBUGINFOD_URLS http://127.0.0.1:$port -+ -+# gdb should now find the symbol and source files -+clean_restart $binfile -+gdb_test_no_output "set substitute-path $outputdir /dev/null" -+gdb_test "br main" "Breakpoint 1 at.*file.*" -+gdb_test "l" ".*This program is distributed in the hope.*" -+ -+# gdb should now find the debugaltlink file -+clean_restart -+gdb_test "file ${binfile}_alt.o" ".*Reading symbols from ${binfile}_alt.o\.\.\.*" -diff --git a/gdb/testsuite/gdb.debuginfod/main.c b/gdb/testsuite/gdb.debuginfod/main.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.debuginfod/main.c -@@ -0,0 +1,25 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2020 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 . */ -+ -+/* Dummy main function. */ -+ -+int -+main() -+{ -+ asm ("main_label: .globl main_label"); -+ return 0; -+} -diff --git a/gdb/top.c b/gdb/top.c ---- a/gdb/top.c -+++ b/gdb/top.c -@@ -1513,6 +1513,17 @@ This GDB was configured as follows:\n\ - --without-python\n\ - ")); - #endif -+ -+#if HAVE_LIBDEBUGINFOD -+ fprintf_filtered (stream, _("\ -+ --with-debuginfod\n\ -+")); -+#else -+ fprintf_filtered (stream, _("\ -+ --without-debuginfod\n\ -+")); -+#endif -+ - #if HAVE_GUILE - fprintf_filtered (stream, _("\ - --with-guile\n\ diff --git a/gdb-rhbz1844458-use-fputX_unfiltered.patch b/gdb-rhbz1844458-use-fputX_unfiltered.patch deleted file mode 100644 index c27d3b988689a27ab4bff25831f8a7c26e88e912..0000000000000000000000000000000000000000 --- a/gdb-rhbz1844458-use-fputX_unfiltered.patch +++ /dev/null @@ -1,57 +0,0 @@ -diff --git a/gdb/utils.c b/gdb/utils.c ---- a/gdb/utils.c -+++ b/gdb/utils.c -@@ -1783,7 +1783,12 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream, - newline -- if chars_per_line is right, we - probably just overflowed anyway; if it's wrong, - let us keep going. */ -- fputc_unfiltered ('\n', stream); -+ /* XXX: The ideal thing would be to call -+ 'stream->putc' here, but we can't because it -+ currently calls 'fputc_unfiltered', which ends up -+ calling us, which generates an infinite -+ recursion. */ -+ stream->puts ("\n"); - } - else - { -@@ -1828,7 +1833,12 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream, - wrap_here ((char *) 0); /* Spit out chars, cancel - further wraps. */ - lines_printed++; -- fputc_unfiltered ('\n', stream); -+ /* XXX: The ideal thing would be to call -+ 'stream->putc' here, but we can't because it -+ currently calls 'fputc_unfiltered', which ends up -+ calling us, which generates an infinite -+ recursion. */ -+ stream->puts ("\n"); - lineptr++; - } - } -@@ -1923,10 +1933,7 @@ fputs_highlighted (const char *str, const compiled_regex &highlight, - int - putchar_unfiltered (int c) - { -- char buf = c; -- -- ui_file_write (gdb_stdout, &buf, 1); -- return c; -+ return fputc_unfiltered (c, gdb_stdout); - } - - /* Write character C to gdb_stdout using GDB's paging mechanism and return C. -@@ -1941,9 +1948,11 @@ putchar_filtered (int c) - int - fputc_unfiltered (int c, struct ui_file *stream) - { -- char buf = c; -+ char buf[2]; - -- ui_file_write (stream, &buf, 1); -+ buf[0] = c; -+ buf[1] = 0; -+ fputs_unfiltered (buf, stream); - return c; - } - diff --git a/gdb-rhbz1976887-field-location-kind.patch b/gdb-rhbz1976887-field-location-kind.patch new file mode 100644 index 0000000000000000000000000000000000000000..00f9accde39c963ea3cb50e253b0964dea54c25f --- /dev/null +++ b/gdb-rhbz1976887-field-location-kind.patch @@ -0,0 +1,30 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= +Date: Wed, 29 Sep 2021 10:58:50 +0200 +Subject: gdb-rhbz1976887-field-location-kind.patch + +;;Backport upstream patch which fixes internal-error: Unexpected +;;type field location kind (RHBZ 1976887). + +gdbtypes.c: Add the case for FIELD_LOC_KIND_DWARF_BLOCK + +The case for FIELD_LOC_KIND_DWARF_BLOCK was missing for +switch TYPE_FIELD_LOC_KIND. Thas caused an internal-error +under some circumstances. + +Fixes bug 28030. + +diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c +--- a/gdb/gdbtypes.c ++++ b/gdb/gdbtypes.c +@@ -5571,6 +5571,10 @@ copy_type_recursive (struct objfile *objfile, + xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type, + i))); + break; ++ case FIELD_LOC_KIND_DWARF_BLOCK: ++ SET_FIELD_DWARF_BLOCK (new_type->field (i), ++ TYPE_FIELD_DWARF_BLOCK (type, i)); ++ break; + default: + internal_error (__FILE__, __LINE__, + _("Unexpected type field location kind: %d"), diff --git a/gdb-rhbz2012976-paper-over-fortran-lex-problems.patch b/gdb-rhbz2012976-paper-over-fortran-lex-problems.patch new file mode 100644 index 0000000000000000000000000000000000000000..433f51d5efdba661b4d3a251819f936d94b90417 --- /dev/null +++ b/gdb-rhbz2012976-paper-over-fortran-lex-problems.patch @@ -0,0 +1,185 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Kevin Buettner +Date: Mon, 11 Oct 2021 11:22:04 -0700 +Subject: gdb-rhbz2012976-paper-over-fortran-lex-problems.patch + +;; Backport gdb.fortran testsuite changes in order to avoid Fortran +;; lexical analyzer bug. + +[gdb/testsuite] Fix FAIL in gdb.mi/mi-var-child-f.exp + +When running test-case gdb.mi/mi-var-child-f.exp on openSUSE Tumbleweed +(with glibc 2.34) I run into: +... +(gdb) ^M +PASS: gdb.mi/mi-var-child-f.exp: mi runto prog_array +Expecting: ^(-var-create array \* array[^M +]+)?(\^done,name="array",numchild="[0-9]+",value=".*",type=.*,has_more="0"[^M +]+[(]gdb[)] ^M +[ ]*) +-var-create array * array^M +&"Attempt to use a type name as an expression.\n"^M +^error,msg="-var-create: unable to create variable object"^M +(gdb) ^M +FAIL: gdb.mi/mi-var-child-f.exp: create local variable array (unexpected output) +... + +The problem is that the name array is used both: +- as the name for a local variable +- as the name of a type in glibc, in file malloc/dynarray-skeleton.c, as included + by nss/nss_files/files-hosts.c. + +Fix this by ignoring the shared lib symbols. + +Likewise in a couple of other fortran tests. + +Tested on x86_64-linux. + +diff --git a/gdb/testsuite/gdb.fortran/allocated.exp b/gdb/testsuite/gdb.fortran/allocated.exp +--- a/gdb/testsuite/gdb.fortran/allocated.exp ++++ b/gdb/testsuite/gdb.fortran/allocated.exp +@@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ + return -1 + } + ++# Avoid shared lib symbols. ++gdb_test_no_output "set auto-solib-add off" ++ + if ![fortran_runto_main] { + untested "could not run to main" + return -1 + } + ++# Avoid libc symbols, in particular the 'array' type. ++gdb_test_no_output "nosharedlibrary" ++ + # Set all the breakpoints. + for { set i 1 } { $i < 6 } { incr i } { + gdb_breakpoint [gdb_get_line_number "Breakpoint $i"] +diff --git a/gdb/testsuite/gdb.fortran/array-slices-bad.exp b/gdb/testsuite/gdb.fortran/array-slices-bad.exp +--- a/gdb/testsuite/gdb.fortran/array-slices-bad.exp ++++ b/gdb/testsuite/gdb.fortran/array-slices-bad.exp +@@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ + return -1 + } + ++# Avoid shared lib symbols. ++gdb_test_no_output "set auto-solib-add off" ++ + if ![fortran_runto_main] { + untested "could not run to main" + return -1 + } + ++# Avoid libc symbols, in particular the 'array' type. ++gdb_test_no_output "nosharedlibrary" ++ + # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"] + gdb_breakpoint [gdb_get_line_number "First Breakpoint"] + gdb_breakpoint [gdb_get_line_number "Second Breakpoint"] +diff --git a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp +--- a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp ++++ b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp +@@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ + return -1 + } + ++# Avoid shared lib symbols. ++gdb_test_no_output "set auto-solib-add off" ++ + if ![fortran_runto_main] { + untested "could not run to main" + return -1 + } + ++# Avoid libc symbols, in particular the 'array' type. ++gdb_test_no_output "nosharedlibrary" ++ + # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"] + gdb_breakpoint [gdb_get_line_number "Stop Here"] + gdb_breakpoint [gdb_get_line_number "Final Breakpoint"] +diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp +--- a/gdb/testsuite/gdb.fortran/array-slices.exp ++++ b/gdb/testsuite/gdb.fortran/array-slices.exp +@@ -55,11 +55,17 @@ proc run_test { repack } { + + clean_restart ${binfile} + ++ # Avoid shared lib symbols. ++ gdb_test_no_output "set auto-solib-add off" ++ + if ![fortran_runto_main] { + untested "could not run to main" + return -1 + } + ++ # Avoid libc symbols, in particular the 'array' type. ++ gdb_test_no_output "nosharedlibrary" ++ + gdb_test_no_output "set fortran repack-array-slices $repack" + + # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"] +diff --git a/gdb/testsuite/gdb.fortran/lbound-ubound.exp b/gdb/testsuite/gdb.fortran/lbound-ubound.exp +--- a/gdb/testsuite/gdb.fortran/lbound-ubound.exp ++++ b/gdb/testsuite/gdb.fortran/lbound-ubound.exp +@@ -25,12 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ + return -1 + } + ++# Avoid shared lib symbols. ++gdb_test_no_output "set auto-solib-add off" + + if ![fortran_runto_main] { + untested "could not run to main" + return -1 + } + ++# Avoid libc symbols, in particular the 'array' type. ++gdb_test_no_output "nosharedlibrary" ++ + gdb_breakpoint [gdb_get_line_number "Test Breakpoint"] + gdb_breakpoint [gdb_get_line_number "Final Breakpoint"] + +diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp +--- a/gdb/testsuite/gdb.fortran/subarray.exp ++++ b/gdb/testsuite/gdb.fortran/subarray.exp +@@ -27,16 +27,17 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} { + return -1 + } + +-gdb_exit +-gdb_start +-gdb_reinitialize_dir $srcdir/$subdir +-gdb_load ${binfile} ++# Avoid shared lib symbols. ++gdb_test_no_output "set auto-solib-add off" + + if ![fortran_runto_main] then { + perror "couldn't run to main" + continue + } + ++# Avoid libc symbols, in particular the 'array' type. ++gdb_test_no_output "nosharedlibrary" ++ + # Try to set breakpoint at the last write statement. + + set bp_location [gdb_get_line_number "str(:)"] +diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp +--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp ++++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp +@@ -36,8 +36,14 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load ${binfile} + ++# Avoid shared lib symbols. ++mi_gdb_test "-gdb-set auto-solib-add off" "\\^done" ++ + mi_runto prog_array + ++# Avoid libc symbols, in particular the 'array' type. ++mi_gdb_test "nosharedlibrary" ".*\\^done" ++ + mi_create_varobj "array" "array" "create local variable array" + + diff --git a/gdb-rhbz2022177-dprintf-1.patch b/gdb-rhbz2022177-dprintf-1.patch new file mode 100644 index 0000000000000000000000000000000000000000..d9122895959d6ed45db114446e85f8f7ea0d9c52 --- /dev/null +++ b/gdb-rhbz2022177-dprintf-1.patch @@ -0,0 +1,315 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Kevin Buettner +Date: Wed, 10 Nov 2021 18:52:22 -0700 +Subject: gdb-rhbz2022177-dprintf-1.patch + +;; Backport fix for dprintf bug (RH BZ 2022177). + +Fix PR 28308 - dprintf breakpoints not working when run from script + +This commit fixes Bug 28308, titled "Strange interactions with +dprintf and break/commands": + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28308 + +Since creating that bug report, I've found a somewhat simpler way of +reproducing the problem. I've encapsulated it into the GDB test case +which I've created along with this bug fix. The name of the new test +is gdb.base/dprintf-execution-x-script.exp, I'll demonstrate the +problem using this test case, though for brevity, I've placed all +relevant files in the same directory and have renamed the files to all +start with 'dp-bug' instead of 'dprintf-execution-x-script'. + +The script file, named dp-bug.gdb, consists of the following commands: + +dprintf increment, "dprintf in increment(), vi=%d\n", vi +break inc_vi +commands + continue +end +run + +Note that the final command in this script is 'run'. When 'run' is +instead issued interactively, the bug does not occur. So, let's look +at the interactive case first in order to see the correct/expected +output: + +$ gdb -q -x dp-bug.gdb dp-bug +... eliding buggy output which I'll discuss later ... +(gdb) run +Starting program: /mesquite2/sourceware-git/f34-master/bld/gdb/tmp/dp-bug +vi=0 +dprintf in increment(), vi=0 + +Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26 +26 in dprintf-execution-x-script.c +vi=1 +dprintf in increment(), vi=1 + +Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26 +26 in dprintf-execution-x-script.c +vi=2 +dprintf in increment(), vi=2 + +Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26 +26 in dprintf-execution-x-script.c +vi=3 +[Inferior 1 (process 1539210) exited normally] + +In this run, in which 'run' was issued from the gdb prompt (instead +of at the end of the script), there are three dprintf messages along +with three 'Breakpoint 2' messages. This is the correct output. + +Now let's look at the output that I snipped above; this is the output +when 'run' is issued from the script loaded via GDB's -x switch: + +$ gdb -q -x dp-bug.gdb dp-bug +Reading symbols from dp-bug... +Dprintf 1 at 0x40116e: file dprintf-execution-x-script.c, line 38. +Breakpoint 2 at 0x40113a: file dprintf-execution-x-script.c, line 26. +vi=0 +dprintf in increment(), vi=0 + +Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26 +26 dprintf-execution-x-script.c: No such file or directory. +vi=1 + +Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26 +26 in dprintf-execution-x-script.c +vi=2 + +Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26 +26 in dprintf-execution-x-script.c +vi=3 +[Inferior 1 (process 1539175) exited normally] + +In the output shown above, only the first dprintf message is printed. +The 2nd and 3rd dprintf messages are missing! However, all three +'Breakpoint 2...' messages are still printed. + +Why does this happen? + +bpstat_do_actions_1() in gdb/breakpoint.c contains the following +comment and code near the start of the function: + + /* Avoid endless recursion if a `source' command is contained + in bs->commands. */ + if (executing_breakpoint_commands) + return 0; + + scoped_restore save_executing + = make_scoped_restore (&executing_breakpoint_commands, 1); + +Also, as described by this comment prior to the 'async' field +in 'struct ui' in top.h, the main UI starts off in sync mode +when processing command line arguments: + + /* True if the UI is in async mode, false if in sync mode. If in + sync mode, a synchronous execution command (e.g, "next") does not + return until the command is finished. If in async mode, then + running a synchronous command returns right after resuming the + target. Waiting for the command's completion is later done on + the top event loop. For the main UI, this starts out disabled, + until all the explicit command line arguments (e.g., `gdb -ex + "start" -ex "next"') are processed. */ + +This combination of things, the state of the static global +'executing_breakpoint_commands' plus the state of the async +field in the main UI causes this behavior. + +This is a backtrace after hitting the dprintf breakpoint for +the second time when doing 'run' from the script file, i.e. +non-interactively: + +Thread 1 "gdb" hit Breakpoint 3, bpstat_do_actions_1 (bsp=0x7fffffffc2b8) + at /ironwood1/sourceware-git/f34-master/bld/../../worktree-master/gdb/breakpoint.c:4431 +4431 if (executing_breakpoint_commands) + + #0 bpstat_do_actions_1 (bsp=0x7fffffffc2b8) + at gdb/breakpoint.c:4431 + #1 0x00000000004d8bc6 in dprintf_after_condition_true (bs=0x1538090) + at gdb/breakpoint.c:13048 + #2 0x00000000004c5caa in bpstat_stop_status (aspace=0x116dbc0, bp_addr=0x40116e, thread=0x137f450, ws=0x7fffffffc718, + stop_chain=0x1538090) at gdb/breakpoint.c:5498 + #3 0x0000000000768d98 in handle_signal_stop (ecs=0x7fffffffc6f0) + at gdb/infrun.c:6172 + #4 0x00000000007678d3 in handle_inferior_event (ecs=0x7fffffffc6f0) + at gdb/infrun.c:5662 + #5 0x0000000000763cd5 in fetch_inferior_event () + at gdb/infrun.c:4060 + #6 0x0000000000746d7d in inferior_event_handler (event_type=INF_REG_EVENT) + at gdb/inf-loop.c:41 + #7 0x00000000007a702f in handle_target_event (error=0, client_data=0x0) + at gdb/linux-nat.c:4207 + #8 0x0000000000b8cd6e in gdb_wait_for_event (block=block@entry=0) + at gdbsupport/event-loop.cc:701 + #9 0x0000000000b8d032 in gdb_wait_for_event (block=0) + at gdbsupport/event-loop.cc:597 + #10 gdb_do_one_event () at gdbsupport/event-loop.cc:212 + #11 0x00000000009d19b6 in wait_sync_command_done () + at gdb/top.c:528 + #12 0x00000000009d1a3f in maybe_wait_sync_command_done (was_sync=0) + at gdb/top.c:545 + #13 0x00000000009d2033 in execute_command (p=0x7fffffffcb18 "", from_tty=0) + at gdb/top.c:676 + #14 0x0000000000560d5b in execute_control_command_1 (cmd=0x13b9bb0, from_tty=0) + at gdb/cli/cli-script.c:547 + #15 0x000000000056134a in execute_control_command (cmd=0x13b9bb0, from_tty=0) + at gdb/cli/cli-script.c:717 + #16 0x00000000004c3bbe in bpstat_do_actions_1 (bsp=0x137f530) + at gdb/breakpoint.c:4469 + #17 0x00000000004c3d40 in bpstat_do_actions () + at gdb/breakpoint.c:4533 + #18 0x00000000006a473a in command_handler (command=0x1399ad0 "run") + at gdb/event-top.c:624 + #19 0x00000000009d182e in read_command_file (stream=0x113e540) + at gdb/top.c:443 + #20 0x0000000000563697 in script_from_file (stream=0x113e540, file=0x13bb0b0 "dp-bug.gdb") + at gdb/cli/cli-script.c:1642 + #21 0x00000000006abd63 in source_gdb_script (extlang=0xc44e80 , stream=0x113e540, + file=0x13bb0b0 "dp-bug.gdb") at gdb/extension.c:188 + #22 0x0000000000544400 in source_script_from_stream (stream=0x113e540, file=0x7fffffffd91a "dp-bug.gdb", + file_to_open=0x13bb0b0 "dp-bug.gdb") + at gdb/cli/cli-cmds.c:692 + #23 0x0000000000544557 in source_script_with_search (file=0x7fffffffd91a "dp-bug.gdb", from_tty=1, search_path=0) + at gdb/cli/cli-cmds.c:750 + #24 0x00000000005445cf in source_script (file=0x7fffffffd91a "dp-bug.gdb", from_tty=1) + at gdb/cli/cli-cmds.c:759 + #25 0x00000000007cf6d9 in catch_command_errors (command=0x5445aa , + arg=0x7fffffffd91a "dp-bug.gdb", from_tty=1, do_bp_actions=false) + at gdb/main.c:523 + #26 0x00000000007cf85d in execute_cmdargs (cmdarg_vec=0x7fffffffd1b0, file_type=CMDARG_FILE, cmd_type=CMDARG_COMMAND, + ret=0x7fffffffd18c) at gdb/main.c:615 + #27 0x00000000007d0c8e in captured_main_1 (context=0x7fffffffd3f0) + at gdb/main.c:1322 + #28 0x00000000007d0eba in captured_main (data=0x7fffffffd3f0) + at gdb/main.c:1343 + #29 0x00000000007d0f25 in gdb_main (args=0x7fffffffd3f0) + at gdb/main.c:1368 + #30 0x00000000004186dd in main (argc=5, argv=0x7fffffffd508) + at gdb/gdb.c:32 + +There are two frames for bpstat_do_actions_1(), one at frame #16 and +the other at frame #0. The one at frame #16 is processing the actions +for Breakpoint 2, which is a 'continue'. The one at frame #0 is attempting +to process the dprintf breakpoint action. However, at this point, +the value of 'executing_breakpoint_commands' is 1, forcing an early +return, i.e. prior to executing the command(s) associated with the dprintf +breakpoint. + +For the sake of comparison, this is what the stack looks like when hitting +the dprintf breakpoint for the second time when issuing the 'run' +command from the GDB prompt. + +Thread 1 "gdb" hit Breakpoint 3, bpstat_do_actions_1 (bsp=0x7fffffffccd8) + at /ironwood1/sourceware-git/f34-master/bld/../../worktree-master/gdb/breakpoint.c:4431 +4431 if (executing_breakpoint_commands) + + #0 bpstat_do_actions_1 (bsp=0x7fffffffccd8) + at gdb/breakpoint.c:4431 + #1 0x00000000004d8bc6 in dprintf_after_condition_true (bs=0x16b0290) + at gdb/breakpoint.c:13048 + #2 0x00000000004c5caa in bpstat_stop_status (aspace=0x116dbc0, bp_addr=0x40116e, thread=0x13f0e60, ws=0x7fffffffd138, + stop_chain=0x16b0290) at gdb/breakpoint.c:5498 + #3 0x0000000000768d98 in handle_signal_stop (ecs=0x7fffffffd110) + at gdb/infrun.c:6172 + #4 0x00000000007678d3 in handle_inferior_event (ecs=0x7fffffffd110) + at gdb/infrun.c:5662 + #5 0x0000000000763cd5 in fetch_inferior_event () + at gdb/infrun.c:4060 + #6 0x0000000000746d7d in inferior_event_handler (event_type=INF_REG_EVENT) + at gdb/inf-loop.c:41 + #7 0x00000000007a702f in handle_target_event (error=0, client_data=0x0) + at gdb/linux-nat.c:4207 + #8 0x0000000000b8cd6e in gdb_wait_for_event (block=block@entry=0) + at gdbsupport/event-loop.cc:701 + #9 0x0000000000b8d032 in gdb_wait_for_event (block=0) + at gdbsupport/event-loop.cc:597 + #10 gdb_do_one_event () at gdbsupport/event-loop.cc:212 + #11 0x00000000007cf512 in start_event_loop () + at gdb/main.c:421 + #12 0x00000000007cf631 in captured_command_loop () + at gdb/main.c:481 + #13 0x00000000007d0ebf in captured_main (data=0x7fffffffd3f0) + at gdb/main.c:1353 + #14 0x00000000007d0f25 in gdb_main (args=0x7fffffffd3f0) + at gdb/main.c:1368 + #15 0x00000000004186dd in main (argc=5, argv=0x7fffffffd508) + at gdb/gdb.c:32 + +This relatively short backtrace is due to the current UI's async field +being set to 1. + +Yet another thing to be aware of regarding this problem is the +difference in the way that commands associated to dprintf breakpoints +versus regular breakpoints are handled. While they both use a command +list associated with the breakpoint, regular breakpoints will place +the commands to be run on the bpstat chain constructed in +bp_stop_status(). These commands are run later on. For dprintf +breakpoints, commands are run via the 'after_condition_true' function +pointer directly from bpstat_stop_status(). (The 'commands' field in +the bpstat is cleared in dprintf_after_condition_true(). This +prevents the dprintf commands from being run again later on when other +commands on the bpstat chain are processed.) + +Another thing that I noticed is that dprintf breakpoints are the only +type of breakpoint which use 'after_condition_true'. This suggests +that one possible way of fixing this problem, that of making dprintf +breakpoints work more like regular breakpoints, probably won't work. +(I must admit, however, that my understanding of this code isn't +complete enough to say why. I'll trust that whoever implemented it +had a good reason for doing it this way.) + +The comment referenced earlier regarding 'executing_breakpoint_commands' +states that the reason for checking this variable is to avoid +potential endless recursion when a 'source' command appears in +bs->commands. We know that a dprintf command is constrained to either +1) execution of a GDB printf command, 2) an inferior function call of +a printf-like function, or 3) execution of an agent-printf command. +Therefore, infinite recursion due to a 'source' command cannot happen +when executing commands upon hitting a dprintf breakpoint. + +I chose to fix this problem by having dprintf_after_condition_true() +directly call execute_control_commands(). This means that it no +longer attempts to go through bpstat_do_actions_1() avoiding the +infinite recursion check for potential 'source' commands on the +command chain. I think it simplifies this code a little bit too, a +definite bonus. + +Summary: + + * breakpoint.c (dprintf_after_condition_true): Don't call + bpstat_do_actions_1(). Call execute_control_commands() + instead. + +diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c +--- a/gdb/breakpoint.c ++++ b/gdb/breakpoint.c +@@ -13043,9 +13043,6 @@ dprintf_print_recreate (struct breakpoint *tp, struct ui_file *fp) + static void + dprintf_after_condition_true (struct bpstats *bs) + { +- struct bpstats tmp_bs; +- struct bpstats *tmp_bs_p = &tmp_bs; +- + /* dprintf's never cause a stop. This wasn't set in the + check_status hook instead because that would make the dprintf's + condition not be evaluated. */ +@@ -13056,14 +13053,9 @@ dprintf_after_condition_true (struct bpstats *bs) + bpstat_do_actions, if a breakpoint that causes a stop happens to + be set at same address as this dprintf, or even if running the + commands here throws. */ +- tmp_bs.commands = bs->commands; +- bs->commands = NULL; +- +- bpstat_do_actions_1 (&tmp_bs_p); +- +- /* 'tmp_bs.commands' will usually be NULL by now, but +- bpstat_do_actions_1 may return early without processing the whole +- list. */ ++ counted_command_line cmds = std::move (bs->commands); ++ gdb_assert (cmds != nullptr); ++ execute_control_commands (cmds.get (), 0); + } + + /* The breakpoint_ops structure to be used on static tracepoints with diff --git a/gdb-rhbz2022177-dprintf-2.patch b/gdb-rhbz2022177-dprintf-2.patch new file mode 100644 index 0000000000000000000000000000000000000000..44bcd87c517b96adb0e49302d8212cba9f728e14 --- /dev/null +++ b/gdb-rhbz2022177-dprintf-2.patch @@ -0,0 +1,194 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Kevin Buettner +Date: Wed, 10 Nov 2021 18:55:43 -0700 +Subject: gdb-rhbz2022177-dprintf-2.patch + +;; Backport test case for dprintf bug (RH BZ 2022177). + +Test case for Bug 28308 + +The purpose of this test is described in the comments in +dprintf-execution-x-script.exp. + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28308 + +The name of this new test was based on that of an existing test, +bp-cmds-execution-x-script.exp. I started off by copying that test, +adding to it, and then rewriting almost all of it. It's different +enough that I decided that listing the copyright year as 2021 +was sufficient. + +diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.c b/gdb/testsuite/gdb.base/dprintf-execution-x-script.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.c +@@ -0,0 +1,53 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2021 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 . */ ++ ++#include ++#include ++ ++volatile int vi = 0; ++ ++void ++inc_vi () ++{ ++ vi++; ++} ++ ++void ++print_vi () ++{ ++ printf ("vi=%d\n", vi); ++} ++ ++void ++increment () ++{ ++ inc_vi (); ++} ++ ++int ++main (int argc, char **argv) ++{ ++ print_vi (); ++ increment (); ++ print_vi (); ++ increment (); ++ print_vi (); ++ increment (); ++ print_vi (); ++ ++ exit (0); ++} +diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp +@@ -0,0 +1,85 @@ ++# Copyright 2021 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 . */ ++ ++# Test that commands in a GDB script file run via GDB's -x flag work ++# as expected. Specifically, the script creates a dprintf breakpoint ++# as well as a normal breakpoint that has "continue" in its command ++# list, and then does "run". Correct output from GDB is checked as ++# part of this test. ++ ++# Bail out if the target can't use the 'run' command. ++if ![target_can_use_run_cmd] { ++ return 0 ++} ++ ++standard_testfile ++ ++if {[build_executable "failed to prepare" $testfile $srcfile debug]} { ++ return -1 ++} ++ ++# This is the name of the GDB script to load. ++set x_file ${srcdir}/${subdir}/$testfile.gdb ++ ++# Create context in which the global, GDBFLAGS, will be restored at ++# the end of the block. All commands run within the block are ++# actually run in the outer context. (This is why 'res' is available ++# outside of the save_vars block.) ++save_vars { GDBFLAGS } { ++ # Set flags with which to start GDB. ++ append GDBFLAGS " -ex \"set height unlimited\"" ++ append GDBFLAGS " -x \"$x_file\"" ++ append GDBFLAGS " --args \"$binfile\"" ++ ++ # Start GDB with above flags. ++ set res [gdb_spawn] ++} ++ ++set test "load and run script with -x" ++if { $res != 0} { ++ fail $test ++ return -1 ++} ++ ++# The script loaded via -x contains a run command; while running, GDB ++# is expected to print three messages from dprintf breakpoints along ++# with three interspersed messages from an ordinary breakpoint (which ++# was set up with a continue command). Set up pattern D to match ++# output from hitting the dprintf breakpoint and B for the ordinary ++# breakpoint. Then set PAT to contain the entire pattern of expected ++# output from the interspersed dprintf and ordinary breakpoints along ++# with some (additional) expected output from the dprintf breakpoints, ++# i.e. 0, 1, and 2. ++set d "dprintf in increment.., vi=" ++set b "Breakpoint ., inc_vi" ++set pat "${d}0.*?$b.*?${d}1.*?$b.*?${d}2.*?$b.*?" ++ ++proc do_test {cmd test} { ++ gdb_test $cmd "$::pat$::inferior_exited_re normally.*" $test ++} ++ ++# Check output from running script with -x ++do_test "" $test ++ ++# Restart GDB and 'source' the script; this will (still) run the program ++# due to the 'run' command in the script. ++clean_restart $binfile ++do_test "source $x_file" "load and run script using source command" ++ ++# This should leave us at the gdb prompt; Run program again using ++# already established breakpoints, i.e. those loaded from the ++# script. Prior to fixing PR 28308, this was the only test that ++# would pass. ++do_test "run" "run again" +diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb b/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb +@@ -0,0 +1,21 @@ ++# Copyright 2021 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 . */ ++ ++dprintf increment, "dprintf in increment(), vi=%d\n", vi ++break inc_vi ++commands ++ continue ++end ++run diff --git a/gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch b/gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch index 198c125fb67ebcee37d1ece17e5245281c603f61..0df5ee52f35d956f6d5a1e0ecad82651499889af 100644 --- a/gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch +++ b/gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch @@ -1,3 +1,12 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch + +;; Import regression test for `gdb/findvar.c:417: internal-error: +;; read_var_value: Assertion `frame' failed.' (RH BZ 947564) from RHEL 6.5. +;;=fedoratest + diff --git a/gdb/testsuite/gdb.threads/tls-rhbz947564.cc b/gdb/testsuite/gdb.threads/tls-rhbz947564.cc new file mode 100644 --- /dev/null diff --git a/gdb-rhel5.9-testcase-xlf-var-inside-mod.patch b/gdb-rhel5.9-testcase-xlf-var-inside-mod.patch index 413181855ca8ae4d93fccb736256d9205fe46f5a..b130d1f677eb03883ee33ba9af62842abfd486e2 100644 --- a/gdb-rhel5.9-testcase-xlf-var-inside-mod.patch +++ b/gdb-rhel5.9-testcase-xlf-var-inside-mod.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch + +;; Include testcase for `Unable to see a variable inside a module (XLF)' (BZ 823789). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.fortran/xlf-variable.S b/gdb/testsuite/gdb.fortran/xlf-variable.S new file mode 100644 --- /dev/null diff --git a/gdb-runtest-pie-override.patch b/gdb-runtest-pie-override.patch index a496cc807de12ea88c82808a403482cffa28f858..25c2bb864871408c9223224b8590384f9c4360d8 100644 --- a/gdb-runtest-pie-override.patch +++ b/gdb-runtest-pie-override.patch @@ -1,7 +1,31 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-runtest-pie-override.patch + +;; Hack for proper PIE run of the testsuite. +;;=fedoratest + +make check//unix/-fPIE/-pie RUNTESTFLAGS=solib-display.exp + +gcc -fpic -c -fPIE -pie -o x.o x.c +/usr/lib/gcc/x86_64-redhat-linux/4.6.1/../../../../lib64/Scrt1.o: In function `_start': +(.text+0x20): undefined reference to `main' + +=> Change the order for overrides. + +One has to also use -fPIC rather than -fPIE, -fPIC is stronger. + +The correct way would be: +make check//unix RUNTESTFLAGS='CC_FOR_TARGET=gcc\ -fPIC\ -pie CXX_FOR_TARGET=g++\ -fPIC\ -pie solib-display.exp' + +But there is a problem with testsuite.unix non-unique subdir name and also +a problem with make -j parallelization of the testsuite. + diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp --- a/gdb/testsuite/lib/future.exp +++ b/gdb/testsuite/lib/future.exp -@@ -195,6 +195,10 @@ proc gdb_default_target_compile {source destfile type options} { +@@ -197,6 +197,10 @@ proc gdb_default_target_compile_1 {source destfile type options} { set ldflags "" set dest [target_info name] @@ -12,7 +36,7 @@ diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp if {[info exists CFLAGS_FOR_TARGET]} { append add_flags " $CFLAGS_FOR_TARGET" } -@@ -529,10 +533,6 @@ proc gdb_default_target_compile {source destfile type options} { +@@ -531,10 +535,6 @@ proc gdb_default_target_compile_1 {source destfile type options} { } } diff --git a/gdb-simultaneous-step-resume-breakpoint-test.patch b/gdb-simultaneous-step-resume-breakpoint-test.patch index b3c0ae6a99d6f51d41102ce8013efa01f0c46b7d..5e1315b77e9809e81742d6596d419fc963577a06 100644 --- a/gdb-simultaneous-step-resume-breakpoint-test.patch +++ b/gdb-simultaneous-step-resume-breakpoint-test.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-simultaneous-step-resume-breakpoint-test.patch + +;; New test for step-resume breakpoint placed in multiple threads at once. +;;=fedoratest + diff --git a/gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.c b/gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.c new file mode 100644 --- /dev/null diff --git a/gdb-test-bt-cfi-without-die.patch b/gdb-test-bt-cfi-without-die.patch index ad1a4fd23b3712959c0047300aea5a813da8845b..6167c145816b5da3217f2b4c1aae46d9fe11ecf8 100644 --- a/gdb-test-bt-cfi-without-die.patch +++ b/gdb-test-bt-cfi-without-die.patch @@ -1,3 +1,71 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-test-bt-cfi-without-die.patch + +;; [delayed-symfile] Test a backtrace regression on CFIs without DIE (BZ 614604). +;;=fedoratest + +http://sourceware.org/ml/archer/2010-q3/msg00028.html + +On Wed, 25 Feb 2009 00:14:29 +0100, Jan Kratochvil wrote: +> commit 6a37c2b9962258ecf9299cc34a650e64a06acaa5 +> +> There was a regression on gdb.base/savedregs.exp. +> +> quick_addrmap/require_partial_symbols should be used even for the unwind debug +> info checking as its load has been also delayed by this branch. +[...] +> --- a/gdb/dwarf2-frame.c +> +++ b/gdb/dwarf2-frame.c +[...] +> @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc) +> struct dwarf2_fde *fde; +> CORE_ADDR offset; +> +> + if (objfile->quick_addrmap) +> + { +> + if (!addrmap_find (objfile->quick_addrmap, *pc)) +> + continue; +> + } +> + /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */ +> + require_partial_symbols (objfile); +> + + +but this has caused a different regression (as discussed in the confcall). + +QUICK_ADDRMAP is built only from .debug_aranges. But we can have existing +built .debug_aranges for CUs in OBJFILE but still some CUs do not need to have +DWARF at all while they can feature CFIs (.eh_frame or .debug_frame). +It has been described by Daniel Jacobowitz at: + Re: [2/4] RFC: check psymtabs_addrmap before reading FDEs + http://sourceware.org/ml/gdb-patches/2010-07/msg00012.html + +Sorry for this regression by me (in that fix of a different regression). + +Fixed it the "slow way" as this branch is now obsoleted by .gdb-index. + +No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. + +Checked-in. + +Thanks, +Jan + +eb8df8566acc1ed963e3e9b77c13b9c2c3db03fb + +Test CFI is parsed even for range (function) not described by any DIE. + +https://bugzilla.redhat.com/show_bug.cgi?id=614028 + +gdb/ + * dwarf2-frame.c (dwarf2_frame_find_fde): Remove the + OBJFILE->QUICK_ADDRMAP check. New comment why. + +gdb/testsuite/ + * gdb.base/cfi-without-die.exp, gdb.base/cfi-without-die-main.c, + gdb.base/cfi-without-die-caller.c: New files. + diff --git a/gdb/testsuite/gdb.base/cfi-without-die-caller.c b/gdb/testsuite/gdb.base/cfi-without-die-caller.c new file mode 100644 --- /dev/null diff --git a/gdb-test-dw2-aranges.patch b/gdb-test-dw2-aranges.patch index 8a48e3c5331736646c77c2334fe4312244c6f99f..458e8ba86eacb7cd7b8dd1c0ca0aa049b9e692a3 100644 --- a/gdb-test-dw2-aranges.patch +++ b/gdb-test-dw2-aranges.patch @@ -1,3 +1,33 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-test-dw2-aranges.patch + +;; [archer-tromey-delayed-symfile] New test gdb.dwarf2/dw2-aranges.exp. +;;=fedoratest + +[archer-tromey-delayed-symfile] + +commit 77fa7778a37b0d28a7e4e5235f074a10ecf1815d +Author: Jan Kratochvil +Date: Sat Aug 15 15:05:54 2009 +0200 + + Test for "handle incorrect aranges". + + readelf: + Contents of the .debug_aranges section: + + Length: 8 + Version: 2 + Offset into .debug_info: 0x0 + Pointer Size: 0 + Segment Size: 0 + + Address Length + Floating point exception + + * gdb.dwarf2/dw2-aranges.exp, gdb.dwarf2/dw2-aranges.S: New files. + diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.S b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S new file mode 100644 --- /dev/null @@ -173,7 +203,7 @@ new file mode 100644 + && ![istarget *-*-openbsd*] + && ![istarget arm-*-eabi*] + && ![istarget powerpc-*-eabi*]} { -+ return 0 ++ return 0 +} + +set testfile "dw2-aranges" diff --git a/gdb-test-expr-cumulative-archer.patch b/gdb-test-expr-cumulative-archer.patch index 4055546fdf7a44b8632738c871f745d1b5d44cb1..28a903dd9b4c7b65f8967b43b6154f863c0b234b 100644 --- a/gdb-test-expr-cumulative-archer.patch +++ b/gdb-test-expr-cumulative-archer.patch @@ -1,3 +1,14 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-test-expr-cumulative-archer.patch + +;; [archer-keiths-expr-cumulative+upstream] Import C++ testcases. +;;=fedoratest + +archer archer-keiths-expr-cumulative +b5a7497340b24199f0c7ba7fdf0d54d4df44d6bc + diff --git a/gdb/testsuite/gdb.cp/namespace-nested-imports.cc b/gdb/testsuite/gdb.cp/namespace-nested-imports.cc new file mode 100644 --- /dev/null diff --git a/gdb-test-for-rhbz1976887.patch b/gdb-test-for-rhbz1976887.patch new file mode 100644 index 0000000000000000000000000000000000000000..3cb70493514ceeba480bfa2d04b18a80d7f81144 --- /dev/null +++ b/gdb-test-for-rhbz1976887.patch @@ -0,0 +1,592 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= +Date: Wed, 29 Sep 2021 11:14:51 +0200 +Subject: gdb-test-for-rhbz1976887.patch + +;; Backport test for RHBZ 1976887 (Kevin Buettner). + +Test case reproducing PR28030 bug + +The original reproducer for PR28030 required use of a specific +compiler version - gcc-c++-11.1.1-3.fc34 is mentioned in the PR, +though it seems probable that other gcc versions might also be able to +reproduce the bug as well. This commit introduces a test case which, +using the DWARF assembler, provides a reproducer which is independent +of the compiler version. (Well, it'll work with whatever compilers +the DWARF assembler works with.) + +To the best of my knowledge, it's also the first test case which uses +the DWARF assembler to provide debug info for a shared object. That +being the case, I provided more than the usual commentary which should +allow this case to be used as a template when a combo shared +library / DWARF assembler test case is required in the future. + +I provide some details regarding the bug in a comment near the +beginning of locexpr-dml.exp. + +This problem was difficult to reproduce; I found myself constantly +referring to the backtrace while trying to figure out what (else) I +might be missing while trying to create a reproducer. Below is a +partial backtrace which I include for posterity. + + #0 internal_error ( + file=0xc50110 "/ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c", line=5575, + fmt=0xc520c0 "Unexpected type field location kind: %d") + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdbsupport/errors.cc:51 + #1 0x00000000006ef0c5 in copy_type_recursive (objfile=0x1635930, + type=0x274c260, copied_types=0x30bb290) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c:5575 + #2 0x00000000006ef382 in copy_type_recursive (objfile=0x1635930, + type=0x274ca10, copied_types=0x30bb290) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c:5602 + #3 0x0000000000a7409a in preserve_one_value (value=0x24269f0, + objfile=0x1635930, copied_types=0x30bb290) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/value.c:2529 + #4 0x000000000072012a in gdbscm_preserve_values ( + extlang=0xc55720 , objfile=0x1635930, + copied_types=0x30bb290) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/guile/scm-value.c:94 + #5 0x00000000006a3f82 in preserve_ext_lang_values (objfile=0x1635930, + copied_types=0x30bb290) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/extension.c:568 + #6 0x0000000000a7428d in preserve_values (objfile=0x1635930) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/value.c:2579 + #7 0x000000000082d514 in objfile::~objfile (this=0x1635930, + __in_chrg=) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:549 + #8 0x0000000000831cc8 in std::_Sp_counted_ptr::_M_dispose (this=0x1654580) + at /usr/include/c++/11/bits/shared_ptr_base.h:348 + #9 0x00000000004e6617 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x1654580) at /usr/include/c++/11/bits/shared_ptr_base.h:168 + #10 0x00000000004e1d2f in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x190bb88, __in_chrg=) + at /usr/include/c++/11/bits/shared_ptr_base.h:705 + #11 0x000000000082feee in std::__shared_ptr::~__shared_ptr (this=0x190bb80, __in_chrg=) + at /usr/include/c++/11/bits/shared_ptr_base.h:1154 + #12 0x000000000082ff0a in std::shared_ptr::~shared_ptr ( + this=0x190bb80, __in_chrg=) + at /usr/include/c++/11/bits/shared_ptr.h:122 + #13 0x000000000085ed7e in __gnu_cxx::new_allocator > >::destroy > (this=0x114bc00, + __p=0x190bb80) at /usr/include/c++/11/ext/new_allocator.h:168 + #14 0x000000000085e88d in std::allocator_traits > > >::destroy > (__a=..., + __p=0x190bb80) at /usr/include/c++/11/bits/alloc_traits.h:531 + #15 0x000000000085e50c in std::__cxx11::list, std::allocator > >::_M_erase (this=0x114bc00, __position= + std::shared_ptr (expired, weak count 1) = {get() = 0x1635930}) + at /usr/include/c++/11/bits/stl_list.h:1925 + #16 0x000000000085df0e in std::__cxx11::list, std::allocator > >::erase (this=0x114bc00, __position= + std::shared_ptr (expired, weak count 1) = {get() = 0x1635930}) + at /usr/include/c++/11/bits/list.tcc:158 + #17 0x000000000085c748 in program_space::remove_objfile (this=0x114bbc0, + objfile=0x1635930) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/progspace.c:210 + #18 0x000000000082d3ae in objfile::unlink (this=0x1635930) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:487 + #19 0x000000000082e68c in objfile_purge_solibs () + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:875 + #20 0x000000000092dd37 in no_shared_libraries (ignored=0x0, from_tty=1) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/solib.c:1236 + #21 0x00000000009a37fe in target_pre_inferior (from_tty=1) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/target.c:2496 + #22 0x00000000007454d6 in run_command_1 (args=0x0, from_tty=1, + run_how=RUN_NORMAL) + at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/infcmd.c:437 + +I'll note a few points regarding this backtrace: + +Frame #1 is where the internal error occurs. It's caused by an +unhandled case for FIELD_LOC_KIND_DWARF_BLOCK. The fix for this bug +adds support for this case. + +Frame #22 - it's a partial backtrace - shows that GDB is attempting to +(re)run the program. You can see the exact command sequence that was +used for reproducing this problem in the PR (at +https://sourceware.org/bugzilla/show_bug.cgi?id=28030), but in a +nutshell, after starting the program and advancing to the appropriate +source line, GDB was asked to step into libstdc++; a "finish" command +was issued, returning a value. The fact that a value was returned is +very important. GDB was then used to step back into libstdc++. A +breakpoint was set on a source line in the library after which a "run" +command was issued. + +Frame #19 shows a call to objfile_purge_solibs. It's aptly named. + +Frame #7 is a call to the destructor for one of the objfile solibs; it +turned out to be the one for libstdc++. + +Frames #6 thru #3 show various value preservation frames. If you look +at preserve_values() in gdb/value.c, the value history is preserved +first, followed by internal variables, followed by values for the +extension languages (python and guile). + +diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c +@@ -0,0 +1,48 @@ ++/* Copyright (C) 2021 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 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 . */ ++ ++#include "locexpr-data-member-location.h" ++ ++struct A g_A = {3, 4}; ++struct B g_B = { {8, 9}, 10, 11 }; ++ ++B * ++foo () ++{ /* foo prologue */ ++ asm ("foo_label: .globl foo_label"); ++ return &g_B; /* foo return */ ++} /* foo end */ ++ ++B * ++bar (B *v) ++{ /* bar prologue */ ++ asm ("bar_label: .globl bar_label"); ++ return v; /* bar return */ ++} /* bar end */ ++ ++/* Some of the DWARF assembler procs (e.g. function_range) compile ++ this file, expecting it to be a complete program with a main() ++ function. When IS_SHAREDLIB is NOT defined, we have main() as ++ defined below. */ ++ ++#ifndef IS_SHAREDLIB ++int ++main () ++{ ++ B *b = foo (); ++} ++#endif +diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-main.c b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-main.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-main.c +@@ -0,0 +1,27 @@ ++/* Copyright (C) 2021 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 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 . */ ++ ++#include "locexpr-data-member-location.h" ++ ++int ++main (void) ++{ ++ B *v1; ++ v1 = bar (foo ()); ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp +@@ -0,0 +1,349 @@ ++# Copyright 2021 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 . ++ ++# This test case uses the DWARF assembler to reproduce the problem ++# described by PR28030. The bug turned out to be that ++# FIELD_LOC_KIND_DWARF_BLOCK was not handled when recursively copying ++# a value's type when preserving the value history during the freeing ++# up of objfiles associated with a shared object. (Yes, figuring out ++# how to make this happen in a concise test case turned out to be ++# challenging.) ++# ++# The following elements proved to be necessary for reproducing the ++# problem: ++# ++# 1) A location expression needed to be used with ++# DW_AT_data_member_location rather than a simple offset. ++# Moreover, this location expression needed to use opcodes ++# which GDB's DWARF reader could not convert to a simple ++# offset. (Note, however, that GDB could probably be improved ++# to handle the opcodes chosen for this test; if decode_locdesc() ++# in dwarf2/read.c is ever updated to handle both DW_OP_pick and ++# DW_OP_drop, then this test could end up passing even if ++# the bug it's intended to test has not been fixed.) ++# ++# 2) The debug info containing the above DWARF info needed ++# to be associated with a shared object since the problem ++# occurred while GDB was preserving values during the ++# purging of shared objects. ++# ++# 3) After performing some simple gdb commands, the program is ++# run again. In the course of running the objfile destructor ++# associated with the shared object, values are preserved ++# along with their types. As noted earlier, it was during ++# the recursive type copy that the bug was observed. ++# ++# Therefore, due to #2 above, this test case creates debug info ++# which is then used by a shared object. ++ ++# This test can't be run on targets lacking shared library support. ++if [skip_shlib_tests] { ++ return 0 ++} ++ ++load_lib dwarf.exp ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++if ![dwarf2_support] { ++ return 0 ++} ++ ++# gdb_test_file_name is the name of this file without the .exp ++# extension. Use it to form basenames for the main program ++# and shared object. ++set main_basename ${::gdb_test_file_name}-main ++set lib_basename ${::gdb_test_file_name}-lib ++ ++# We're generating DWARF assembly for the shared object; therefore, ++# the source file for the library / shared object must be listed first ++# (in the standard_testfile invocation) since ${srcfile} is used by ++# get_func_info (for determining the start, end, and length of a ++# function). ++# ++# The output of Dwarf::assemble will be placed in $lib_basename.S ++# which will be ${srcfile3} after the execution of standard_testfile. ++ ++standard_testfile $lib_basename.c $main_basename.c $lib_basename.S ++ ++set libsrc "${::srcdir}/${::subdir}/${::srcfile}" ++set lib_so [standard_output_file ${lib_basename}.so] ++set asm_file [standard_output_file ${::srcfile3}] ++ ++# We need to know the size of some types in order to write some of the ++# debugging info that we're about to generate. For that, we ask GDB ++# by debugging the shared object associated with this test case. ++ ++# Compile the shared library: -DIS_SHAREDLIB prevents main() from ++# being defined. Note that debugging symbols will be present for ++# this compilation. ++if {[gdb_compile_shlib $libsrc $lib_so \ ++ {additional_flags=-DIS_SHAREDLIB debug}] != ""} { ++ untested "failed to compile shared library" ++ return ++} ++ ++# Start a fresh GDB and load the shared library. ++clean_restart $lib_so ++ ++# Using our running GDB session, determine sizes of several types. ++set long_size [get_sizeof "long" -1] ++set addr_size [get_sizeof "void *" -1] ++set struct_A_size [get_sizeof "g_A" -1] ++set struct_B_size [get_sizeof "g_B" -1] ++ ++if { $long_size == -1 || $addr_size == -1 \ ++ || $struct_A_size == -1 || $struct_B_size == -1} { ++ perror "Can't determine type sizes" ++ return ++} ++ ++# Retrieve struct offset of MBR in struct TP ++proc get_offsetof { tp mbr } { ++ return [get_integer_valueof "&((${tp} *) 0)->${mbr}" -1] ++} ++ ++# Use running GDB session to get struct offsets ++set A_a [get_offsetof A a] ++set A_x [get_offsetof A x] ++set B_a [get_offsetof B a] ++set B_b [get_offsetof B b] ++set B_x2 [get_offsetof B x2] ++ ++# Create the DWARF. ++Dwarf::assemble ${asm_file} { ++ declare_labels L ++ ++ # Find start, end, and length of functions foo and bar. ++ # These calls to get_func_info will create and set variables ++ # foo_start, bar_start, foo_end, bar_end, foo_len, and ++ # bar_len. ++ # ++ # In order to get the right answers, get_func_info (and, ++ # underneath, function_range) should use the same compiler flags ++ # as those used to make a shared object. For any targets that get ++ # this far, -fpic is probably correct. ++ # ++ # Also, it should be noted that IS_SHAREDLIB is NOT defined as one ++ # of the additional flags. Not defining IS_SHAREDLIB will cause a ++ # main() to be defined for the compilation of the shared library ++ # source file which happens as a result of using get_func_info; ++ # this is currently required in order to this facility. ++ set flags {additional_flags=-fpic debug} ++ get_func_info foo $flags ++ get_func_info bar $flags ++ ++ cu {} { ++ DW_TAG_compile_unit { ++ {DW_AT_language @DW_LANG_C_plus_plus} ++ {name ${::srcfile}} ++ {stmt_list $L DW_FORM_sec_offset} ++ } { ++ declare_labels int_label class_A_label class_B_label \ ++ B_ptr_label ++ ++ int_label: DW_TAG_base_type { ++ {DW_AT_byte_size ${::long_size} DW_FORM_udata} ++ {DW_AT_encoding @DW_ATE_signed} ++ {DW_AT_name "int"} ++ } ++ ++ class_A_label: DW_TAG_class_type { ++ {DW_AT_name "A"} ++ {DW_AT_byte_size ${::struct_A_size} DW_FORM_sdata} ++ } { ++ DW_TAG_member { ++ {DW_AT_name "a"} ++ {DW_AT_type :$int_label} ++ {DW_AT_data_member_location ${::A_a} DW_FORM_udata} ++ } ++ DW_TAG_member { ++ {DW_AT_name "x"} ++ {DW_AT_type :$int_label} ++ {DW_AT_data_member_location ${::A_x} DW_FORM_udata} ++ } ++ } ++ ++ class_B_label: DW_TAG_class_type { ++ {DW_AT_name "B"} ++ {DW_AT_byte_size ${::struct_B_size} DW_FORM_sdata} ++ } { ++ # While there are easier / better ways to specify an ++ # offset used by DW_AT_data_member_location than that ++ # used below, we need a location expression here in ++ # order to reproduce the bug. Moreover, this location ++ # expression needs to use opcodes that aren't handled ++ # by decode_locdesc() in dwarf2/read.c; if we use ++ # opcodes that _are_ handled by that function, the ++ # location expression will be converted into a simple ++ # offset - which will then (again) not reproduce the ++ # bug. At the time that this test was written, ++ # neither DW_OP_pick nor DW_OP_drop were being handled ++ # by decode_locdesc(); this is why those opcodes were ++ # chosen. ++ DW_TAG_inheritance { ++ {DW_AT_type :$class_A_label} ++ {DW_AT_data_member_location { ++ DW_OP_constu ${::B_a} ++ DW_OP_plus ++ DW_OP_pick 0 ++ DW_OP_drop} SPECIAL_expr} ++ {DW_AT_accessibility 1 DW_FORM_data1} ++ } ++ DW_TAG_member { ++ {DW_AT_name "b"} ++ {DW_AT_type :$int_label} ++ {DW_AT_data_member_location ${::B_b} DW_FORM_udata} ++ } ++ DW_TAG_member { ++ {DW_AT_name "x2"} ++ {DW_AT_type :$int_label} ++ {DW_AT_data_member_location ${::B_x2} DW_FORM_udata} ++ } ++ } ++ ++ B_ptr_label: DW_TAG_pointer_type { ++ {DW_AT_type :$class_B_label} ++ {DW_AT_byte_size ${::addr_size} DW_FORM_sdata} ++ } ++ ++ DW_TAG_variable { ++ {DW_AT_name "g_A"} ++ {DW_AT_type :$class_A_label} ++ {DW_AT_external 1 flag} ++ {DW_AT_location {DW_OP_addr [gdb_target_symbol "g_A"]} \ ++ SPECIAL_expr} ++ } ++ ++ DW_TAG_variable { ++ {DW_AT_name "g_B"} ++ {DW_AT_type :$class_B_label} ++ {DW_AT_external 1 flag} ++ {DW_AT_location {DW_OP_addr [gdb_target_symbol "g_B"]} \ ++ SPECIAL_expr} ++ } ++ ++ # We can't use MACRO_AT for the definitions of foo and bar ++ # because it doesn't provide a way to pass the appropriate ++ # flags. Therefore, we list the name, low_pc, and high_pc ++ # explicitly. ++ DW_TAG_subprogram { ++ {DW_AT_name foo} ++ {DW_AT_low_pc $foo_start DW_FORM_addr} ++ {DW_AT_high_pc $foo_end DW_FORM_addr} ++ {DW_AT_type :${B_ptr_label}} ++ {DW_AT_external 1 flag} ++ } ++ ++ DW_TAG_subprogram { ++ {DW_AT_name bar} ++ {DW_AT_low_pc $bar_start DW_FORM_addr} ++ {DW_AT_high_pc $bar_end DW_FORM_addr} ++ {DW_AT_type :${B_ptr_label}} ++ {DW_AT_external 1 flag} ++ } { ++ DW_TAG_formal_parameter { ++ {DW_AT_name v} ++ {DW_AT_type :${B_ptr_label}} ++ } ++ } ++ } ++ } ++ ++ lines {version 2} L { ++ include_dir "${::srcdir}/${::subdir}" ++ file_name "${::srcfile}" 1 ++ ++ # Generate a line table program. ++ program { ++ {DW_LNE_set_address $foo_start} ++ {line [gdb_get_line_number "foo prologue"]} ++ {DW_LNS_copy} ++ {DW_LNE_set_address foo_label} ++ {line [gdb_get_line_number "foo return"]} ++ {DW_LNS_copy} ++ {line [gdb_get_line_number "foo end"]} ++ {DW_LNS_copy} ++ {DW_LNE_set_address $foo_end} ++ {DW_LNS_advance_line 1} ++ {DW_LNS_copy} ++ {DW_LNE_end_sequence} ++ ++ {DW_LNE_set_address $bar_start} ++ {line [gdb_get_line_number "bar prologue"]} ++ {DW_LNS_copy} ++ {DW_LNE_set_address bar_label} ++ {line [gdb_get_line_number "bar return"]} ++ {DW_LNS_copy} ++ {line [gdb_get_line_number "bar end"]} ++ {DW_LNS_copy} ++ {DW_LNE_set_address $bar_end} ++ {DW_LNS_advance_line 1} ++ {DW_LNS_copy} ++ {DW_LNE_end_sequence} ++ } ++ } ++} ++ ++# Compile the shared object again, but this time include / use the ++# DWARF info that we've created above. Note that (again) ++# -DIS_SHAREDLIB is used to prevent inclusion of main() in the shared ++# object. Also note the use of the "nodebug" option. Any debugging ++# information that we need will be provided by the DWARF info created ++# above. ++if {[gdb_compile_shlib [list $libsrc $asm_file] $lib_so \ ++ {additional_flags=-DIS_SHAREDLIB nodebug}] != ""} { ++ untested "failed to compile shared library" ++ return ++} ++ ++# Compile the main program for use with the shared object. ++if [prepare_for_testing "failed to prepare" ${testfile} \ ++ ${::srcfile2} [list debug shlib=$lib_so]] { ++ return -1 ++} ++ ++# Do whatever is necessary to make sure that the shared library is ++# loaded for remote targets. ++gdb_load_shlib ${lib_so} ++ ++if ![runto_main] then { ++ fail "can't run to main" ++ return ++} ++ ++# Step into foo so that we can finish out of it. ++gdb_test "step" "foo .. at .* foo end.*" "step into foo" ++ ++# Finishing out of foo will create a value that will later need to ++# be preserved when restarting the program. ++gdb_test "finish" "= \\(class B \\*\\) ${::hex} .*" "finish out of foo" ++ ++# Dereferencing and printing the return value isn't necessary ++# for reproducing the bug, but we should make sure that the ++# return value is what we expect it to be. ++gdb_test "p *$" { = { = {a = 8, x = 9}, b = 10, x2 = 11}} \ ++ "dereference return value" ++ ++# The original PR28030 reproducer stepped back into the shared object, ++# so we'll do the same here: ++gdb_test "step" "bar \\(.*" "step into bar" ++ ++# We don't want a clean restart here since that will be too clean. ++# The original reproducer for PR28030 set a breakpoint in the shared ++# library and then restarted via "run". The command below does roughly ++# the same thing. It's at this step that an internal error would ++# occur for PR28030. The "message" argument tells runto to turn on ++# the printing of PASSes while runto is doing its job. ++runto "bar" message +diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.h b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.h +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.h +@@ -0,0 +1,30 @@ ++/* Copyright (C) 2021 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 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 . */ ++ ++typedef struct A { ++ long a; ++ long x; ++} A; ++ ++typedef struct B { ++ A a; ++ long b; ++ long x2; ++} B; ++ ++extern B *foo (); ++extern B *bar (B *v); diff --git a/gdb-test-ivy-bridge.patch b/gdb-test-ivy-bridge.patch index e3c9c11d612ea8f81113de37c29198065d540ed6..ed827897bb8d6497d3960ec04a4393e53e98314f 100644 --- a/gdb-test-ivy-bridge.patch +++ b/gdb-test-ivy-bridge.patch @@ -1,3 +1,11 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-test-ivy-bridge.patch + +;; Test GDB opcodes/ disassembly of Intel Ivy Bridge instructions (BZ 696890). +;;=fedoratest + diff --git a/gdb/testsuite/gdb.arch/amd64-ivy-bridge.S b/gdb/testsuite/gdb.arch/amd64-ivy-bridge.S new file mode 100644 --- /dev/null @@ -49,21 +57,21 @@ new file mode 100644 + vcvtps2ph $0x2,%ymm4,%xmm4 + vcvtps2ph $0x2,%ymm8,(%r8) + vcvtps2ph $0x2,%xmm4,%xmm4 -+ vcvtps2ph $0x2,%xmm4,(%rcx) ++ vcvtps2ph $0x2,%xmm4,(%rcx) + + .intel_syntax noprefix + vcvtph2ps ymm4,xmm4 + vcvtph2ps ymm8,XMMWORD PTR [r8] + vcvtph2ps ymm4,[rcx] + vcvtph2ps xmm6,xmm4 -+ vcvtph2ps xmm4,QWORD PTR [rcx] ++ vcvtph2ps xmm4,QWORD PTR [rcx] + vcvtph2ps xmm4,[rcx] + vcvtps2ph xmm4,ymm4,0x2 -+ vcvtps2ph XMMWORD PTR [rcx],ymm4,0x2 -+ vcvtps2ph [rcx],ymm4,0x2 ++ vcvtps2ph XMMWORD PTR [rcx],ymm4,0x2 ++ vcvtps2ph [rcx],ymm4,0x2 + vcvtps2ph xmm4,xmm4,0x2 -+ vcvtps2ph QWORD PTR [r8],xmm8,0x2 -+ vcvtps2ph [rcx],xmm4,0x2 ++ vcvtps2ph QWORD PTR [r8],xmm8,0x2 ++ vcvtps2ph [rcx],xmm4,0x2 + +/* gas/i386/x86-64-fsgs.s */ + .att_syntax prefix @@ -72,34 +80,34 @@ new file mode 100644 + rdfsbase %r8d + rdfsbase %r8 + rdgsbase %ebx -+ rdgsbase %rbx -+ rdgsbase %r8d -+ rdgsbase %r8 -+ wrfsbase %ebx -+ wrfsbase %rbx -+ wrfsbase %r8d -+ wrfsbase %r8 -+ wrgsbase %ebx -+ wrgsbase %rbx -+ wrgsbase %r8d -+ wrgsbase %r8 ++ rdgsbase %rbx ++ rdgsbase %r8d ++ rdgsbase %r8 ++ wrfsbase %ebx ++ wrfsbase %rbx ++ wrfsbase %r8d ++ wrfsbase %r8 ++ wrgsbase %ebx ++ wrgsbase %rbx ++ wrgsbase %r8d ++ wrgsbase %r8 + + .intel_syntax noprefix -+ rdfsbase ebx -+ rdfsbase rbx -+ rdfsbase r8d ++ rdfsbase ebx ++ rdfsbase rbx ++ rdfsbase r8d + rdfsbase r8 -+ rdgsbase ebx -+ rdgsbase rbx -+ rdgsbase r8d ++ rdgsbase ebx ++ rdgsbase rbx ++ rdgsbase r8d + rdgsbase r8 -+ wrfsbase ebx -+ wrfsbase rbx -+ wrfsbase r8d ++ wrfsbase ebx ++ wrfsbase rbx ++ wrfsbase r8d + wrfsbase r8 -+ wrgsbase ebx -+ wrgsbase rbx -+ wrgsbase r8d ++ wrgsbase ebx ++ wrgsbase rbx ++ wrgsbase r8d + wrgsbase r8 diff --git a/gdb/testsuite/gdb.arch/amd64-ivy-bridge.exp b/gdb/testsuite/gdb.arch/amd64-ivy-bridge.exp new file mode 100644 @@ -128,7 +136,7 @@ new file mode 100644 +set testfile amd64-ivy-bridge +set test compilation +if [prepare_for_testing ${testfile}.exp ${testfile}.x ${testfile}.S [list debug "additional_flags=-m64 -nostdlib"]] { -+ fail $test ++ unsupported $test + return -1 +} +pass $test @@ -280,7 +288,7 @@ diff --git a/gdb/testsuite/gdb.arch/i386-ivy-bridge.S b/gdb/testsuite/gdb.arch/i new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.arch/i386-ivy-bridge.S -@@ -0,0 +1,67 @@ +@@ -0,0 +1,66 @@ +/* Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify @@ -317,23 +325,23 @@ new file mode 100644 + vcvtph2ps %xmm4,%xmm6 + vcvtph2ps (%ecx),%xmm4 + vcvtps2ph $0x2,%ymm4,%xmm4 -+ vcvtps2ph $0x2,%ymm4,(%ecx) ++ vcvtps2ph $0x2,%ymm4,(%ecx) + vcvtps2ph $0x2,%xmm4,%xmm4 -+ vcvtps2ph $0x2,%xmm4,(%ecx) ++ vcvtps2ph $0x2,%xmm4,(%ecx) + + .intel_syntax noprefix + vcvtph2ps ymm4,xmm4 + vcvtph2ps ymm4,XMMWORD PTR [ecx] + vcvtph2ps ymm4,[ecx] + vcvtph2ps xmm6,xmm4 -+ vcvtph2ps xmm4,QWORD PTR [ecx] ++ vcvtph2ps xmm4,QWORD PTR [ecx] + vcvtph2ps xmm4,[ecx] + vcvtps2ph xmm4,ymm4,0x2 -+ vcvtps2ph XMMWORD PTR [ecx],ymm4,0x2 -+ vcvtps2ph [ecx],ymm4,0x2 ++ vcvtps2ph XMMWORD PTR [ecx],ymm4,0x2 ++ vcvtps2ph [ecx],ymm4,0x2 + vcvtps2ph xmm4,xmm4,0x2 -+ vcvtps2ph QWORD PTR [ecx],xmm4,0x2 -+ vcvtps2ph [ecx],xmm4,0x2 ++ vcvtps2ph QWORD PTR [ecx],xmm4,0x2 ++ vcvtps2ph [ecx],xmm4,0x2 + +/* gas/i386/fsgs.s */ + .att_syntax prefix @@ -343,11 +351,10 @@ new file mode 100644 + wrgsbase %ebx + + .intel_syntax noprefix -+ rdfsbase ebx -+ rdgsbase ebx -+ wrfsbase ebx -+ wrgsbase ebx -+ ++ rdfsbase ebx ++ rdgsbase ebx ++ wrfsbase ebx ++ wrgsbase ebx diff --git a/gdb/testsuite/gdb.arch/i386-ivy-bridge.exp b/gdb/testsuite/gdb.arch/i386-ivy-bridge.exp new file mode 100644 --- /dev/null diff --git a/gdb-test-pid0-core.patch b/gdb-test-pid0-core.patch index cf0a18f0790b3db01a163ae54b2e04048f16d95f..fea4defa99a4226390c2a75a2c17f3297136f18e 100644 --- a/gdb-test-pid0-core.patch +++ b/gdb-test-pid0-core.patch @@ -1,3 +1,19 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-test-pid0-core.patch + +;; New test gdb.arch/x86_64-pid0-core.exp for kernel PID 0 cores (BZ 611435). +;;=fedoratest + +https://bugzilla.redhat.com/show_bug.cgi?id=611435 + +Fix: +Re: [RFA]corelow.c: Add tid to add_to_thread_list +http://sourceware.org/ml/gdb-patches/2010-08/msg00085.html +http://sourceware.org/ml/gdb-cvs/2010-08/msg00026.html +2e5bcfdef1ec3883d48c3f87a4be5c0dff25e17e + diff --git a/gdb/testsuite/gdb.arch/x86_64-pid0-core.core.bz2.uu b/gdb/testsuite/gdb.arch/x86_64-pid0-core.core.bz2.uu new file mode 100644 --- /dev/null @@ -29,22 +45,22 @@ new file mode 100644 +++ b/gdb/testsuite/gdb.arch/x86_64-pid0-core.exp @@ -0,0 +1,46 @@ +# This testcase is part of GDB, the GNU debugger. -+# ++# +# Copyright 2010 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 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. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Some kernel core files have PID 0 - for the idle task. + diff --git a/gdb-vla-intel-fix-print-char-array.patch b/gdb-vla-intel-fix-print-char-array.patch deleted file mode 100644 index 6cfaf541ed528e39c538616df2df582aa43dfaa3..0000000000000000000000000000000000000000 --- a/gdb-vla-intel-fix-print-char-array.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c ---- a/gdb/f-valprint.c -+++ b/gdb/f-valprint.c -@@ -319,8 +319,22 @@ f_val_print (struct type *type, int embedded_offset, - original_value, &opts, 0, stream); - } - else -- val_print_scalar_formatted (type, embedded_offset, -- original_value, options, 0, stream); -+ { -+ val_print_scalar_formatted (type, embedded_offset, -+ original_value, options, 0, stream); -+ /* C and C++ has no single byte int type, char is used instead. -+ Since we don't know whether the value is really intended to -+ be used as an integer or a character, print the character -+ equivalent as well. */ -+ if (TYPE_LENGTH (type) == 1) -+ { -+ LONGEST c; -+ -+ fputs_filtered (" ", stream); -+ c = unpack_long (type, valaddr + embedded_offset); -+ LA_PRINT_CHAR ((unsigned char) c, type, stream); -+ } -+ } - break; - - case TYPE_CODE_STRUCT: -diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp ---- a/gdb/testsuite/gdb.fortran/printing-types.exp -+++ b/gdb/testsuite/gdb.fortran/printing-types.exp -@@ -29,7 +29,7 @@ if {![runto MAIN__]} then { - gdb_breakpoint [gdb_get_line_number "write"] - gdb_continue_to_breakpoint "write" - --gdb_test "print oneByte" " = 1" -+gdb_test "print oneByte" " = 1 \'\\\\001\'" - gdb_test "print twobytes" " = 2" - gdb_test "print chvalue" " = \'a\'" - gdb_test "print logvalue" " = \.TRUE\." diff --git a/gdb-vla-intel-fortran-strides.patch b/gdb-vla-intel-fortran-strides.patch deleted file mode 100644 index 7a87b6e441136f14c54910ab37501c574617d142..0000000000000000000000000000000000000000 --- a/gdb-vla-intel-fortran-strides.patch +++ /dev/null @@ -1,1779 +0,0 @@ -git diff --stat -p gdb/master...gdb/users/bheckel/fortran-strides -dbfd7140bf4c0500d1f5d192be781f83f78f7922 - - gdb/dwarf2loc.c | 46 ++- - gdb/dwarf2loc.h | 6 + - gdb/dwarf2read.c | 13 +- - gdb/eval.c | 391 +++++++++++++++++++++----- - gdb/expprint.c | 20 +- - gdb/expression.h | 18 +- - gdb/f-exp.y | 42 ++- - gdb/f-valprint.c | 8 +- - gdb/gdbtypes.c | 34 ++- - gdb/gdbtypes.h | 18 +- - gdb/parse.c | 24 +- - gdb/rust-exp.y | 12 +- - gdb/rust-lang.c | 17 +- - gdb/testsuite/gdb.fortran/static-arrays.exp | 421 ++++++++++++++++++++++++++++ - gdb/testsuite/gdb.fortran/static-arrays.f90 | 55 ++++ - gdb/testsuite/gdb.fortran/vla-ptype.exp | 4 + - gdb/testsuite/gdb.fortran/vla-sizeof.exp | 4 + - gdb/testsuite/gdb.fortran/vla-stride.exp | 44 +++ - gdb/testsuite/gdb.fortran/vla-stride.f90 | 29 ++ - gdb/testsuite/gdb.fortran/vla.f90 | 10 + - gdb/valarith.c | 10 +- - gdb/valops.c | 197 +++++++++++-- - gdb/value.h | 2 + - 23 files changed, 1242 insertions(+), 183 deletions(-) - -diff --git a/gdb/eval.c b/gdb/eval.c ---- a/gdb/eval.c -+++ b/gdb/eval.c -@@ -372,29 +372,324 @@ init_array_element (struct value *array, struct value *element, - return index; - } - -+/* Evaluates any operation on Fortran arrays or strings with at least -+ one user provided parameter. Expects the input ARRAY to be either -+ an array, or a string. Evaluates EXP by incrementing POS, and -+ writes the content from the elt stack into a local struct. NARGS -+ specifies number of literal or range arguments the user provided. -+ NARGS must be the same number as ARRAY has dimensions. */ -+ - static struct value * --value_f90_subarray (struct value *array, -- struct expression *exp, int *pos, enum noside noside) -+value_f90_subarray (struct value *array, struct expression *exp, -+ int *pos, int nargs, enum noside noside) - { -- int pc = (*pos) + 1; -- LONGEST low_bound, high_bound; -- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array))); -- enum range_type range_type -- = (enum range_type) longest_to_int (exp->elts[pc].longconst); -- -- *pos += 3; -- -- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) -- low_bound = TYPE_LOW_BOUND (range); -- else -- low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); -+ int i, dim_count = 0; -+ struct value *new_array = array; -+ struct type *array_type = check_typedef (value_type (new_array)); -+ struct type *elt_type; -+ -+ typedef struct -+ { -+ enum range_type f90_range_type; -+ LONGEST low, high, stride; -+ } subscript_range; -+ -+ typedef enum subscript_kind -+ { -+ SUBSCRIPT_RANGE, /* e.g. "(lowbound:highbound)" */ -+ SUBSCRIPT_INDEX /* e.g. "(literal)" */ -+ } kind; -+ -+ /* Local struct to hold user data for Fortran subarray dimensions. */ -+ struct subscript_store -+ { -+ /* For every dimension, we are either working on a range or an index -+ expression, so we store this info separately for later. */ -+ enum subscript_kind kind; -+ -+ /* We also store either the lower and upper bound info, or the index -+ number. Before evaluation of the input values, we do not know if we are -+ actually working on a range of ranges, or an index in a range. So as a -+ first step we store all input in a union. The array calculation itself -+ deals with this later on. */ -+ union element_range -+ { -+ subscript_range range; -+ LONGEST number; -+ } U; -+ } *subscript_array; -+ -+ /* Check if the number of arguments provided by the user matches -+ the number of dimension of the array. A string has only one -+ dimension. */ -+ if (nargs != calc_f77_array_dims (value_type (new_array))) -+ error (_("Wrong number of subscripts")); -+ -+ subscript_array = (struct subscript_store*) alloca (sizeof (*subscript_array) * nargs); -+ -+ /* Parse the user input into the SUBSCRIPT_ARRAY to store it. We need -+ to evaluate it first, as the input is from left-to-right. The -+ array is stored from right-to-left. So we have to use the user -+ input in reverse order. Later on, we need the input information to -+ re-calculate the output array. For multi-dimensional arrays, we -+ can be dealing with any possible combination of ranges and indices -+ for every dimension. */ -+ for (i = 0; i < nargs; i++) -+ { -+ struct subscript_store *index = &subscript_array[i]; -+ -+ /* The user input is a range, with or without lower and upper bound. -+ E.g.: "p arry(2:5)", "p arry( :5)", "p arry( : )", etc. */ -+ if (exp->elts[*pos].opcode == OP_RANGE) -+ { -+ int pc = (*pos) + 1; -+ subscript_range *range; -+ -+ index->kind = SUBSCRIPT_RANGE; -+ range = &index->U.range; -+ -+ *pos += 3; -+ range->f90_range_type = (enum range_type) exp->elts[pc].longconst; -+ -+ /* If a lower bound was provided by the user, the bit has been -+ set and we can assign the value from the elt stack. Same for -+ upper bound. */ -+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND) -+ == SUBARRAY_LOW_BOUND) -+ range->low = value_as_long (evaluate_subexp (NULL_TYPE, exp, -+ pos, noside)); -+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND) -+ == SUBARRAY_HIGH_BOUND) -+ range->high = value_as_long (evaluate_subexp (NULL_TYPE, exp, -+ pos, noside)); -+ -+ /* Assign the user's stride value if provided. */ -+ if ((range->f90_range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE) -+ range->stride = value_as_long (evaluate_subexp (NULL_TYPE, exp, -+ pos, noside)); -+ -+ /* Assign the default stride value '1'. */ -+ else -+ range->stride = 1; - -- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) -- high_bound = TYPE_HIGH_BOUND (range); -- else -- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); -+ /* Check the provided stride value is illegal, aka '0'. */ -+ if (range->stride == 0) -+ error (_("Stride must not be 0")); -+ } -+ /* User input is an index. E.g.: "p arry(5)". */ -+ else -+ { -+ struct value *val; -+ -+ index->kind = SUBSCRIPT_INDEX; -+ -+ /* Evaluate each subscript; it must be a legal integer in F77. This -+ ensures the validity of the provided index. */ -+ val = evaluate_subexp_with_coercion (exp, pos, noside); -+ index->U.number = value_as_long (val); -+ } -+ -+ } -+ -+ /* Traverse the array from right to left and set the high and low bounds -+ for later use. */ -+ for (i = nargs - 1; i >= 0; i--) -+ { -+ struct subscript_store *index = &subscript_array[i]; -+ struct type *index_type = TYPE_INDEX_TYPE (array_type); -+ -+ switch (index->kind) -+ { -+ case SUBSCRIPT_RANGE: -+ { -+ -+ /* When we hit the first range specified by the user, we must -+ treat any subsequent user entry as a range. We simply -+ increment DIM_COUNT which tells us how many times we are -+ calling VALUE_SLICE_1. */ -+ subscript_range *range = &index->U.range; -+ -+ /* If no lower bound was provided by the user, we take the -+ default boundary. Same for the high bound. */ -+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND) == 0) -+ range->low = TYPE_LOW_BOUND (index_type); -+ -+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND) == 0) -+ range->high = TYPE_HIGH_BOUND (index_type); -+ -+ /* Both user provided low and high bound have to be inside the -+ array bounds. Throw an error if not. */ -+ if (range->low < TYPE_LOW_BOUND (index_type) -+ || range->low > TYPE_HIGH_BOUND (index_type) -+ || range->high < TYPE_LOW_BOUND (index_type) -+ || range->high > TYPE_HIGH_BOUND (index_type)) -+ error (_("provided bound(s) outside array bound(s)")); -+ -+ /* For a negative stride the lower boundary must be larger than the -+ upper boundary. -+ For a positive stride the lower boundary must be smaller than the -+ upper boundary. */ -+ if ((range->stride < 0 && range->low < range->high) -+ || (range->stride > 0 && range->low > range->high)) -+ error (_("Wrong value provided for stride and boundaries")); -+ -+ } -+ break; -+ -+ case SUBSCRIPT_INDEX: -+ break; -+ -+ } -+ -+ array_type = TYPE_TARGET_TYPE (array_type); -+ } -+ -+ /* Reset ARRAY_TYPE before slicing.*/ -+ array_type = check_typedef (value_type (new_array)); -+ -+ /* Traverse the array from right to left and evaluate each corresponding -+ user input. VALUE_SUBSCRIPT is called for every index, until a range -+ expression is evaluated. After a range expression has been evaluated, -+ every subsequent expression is also treated as a range. */ -+ for (i = nargs - 1; i >= 0; i--) -+ { -+ struct subscript_store *index = &subscript_array[i]; -+ struct type *index_type = TYPE_INDEX_TYPE (array_type); -+ -+ switch (index->kind) -+ { -+ case SUBSCRIPT_RANGE: -+ { -+ -+ /* When we hit the first range specified by the user, we must -+ treat any subsequent user entry as a range. We simply -+ increment DIM_COUNT which tells us how many times we are -+ calling VALUE_SLICE_1. */ -+ subscript_range *range = &index->U.range; -+ -+ /* DIM_COUNT counts every user argument that is treated as a range. -+ This is necessary for expressions like 'print array(7, 8:9). -+ Here the first argument is a literal, but must be treated as a -+ range argument to allow the correct output representation. */ -+ dim_count++; -+ -+ new_array -+ = value_slice_1 (new_array, range->low, -+ range->high - range->low + 1, -+ range->stride, dim_count); -+ } -+ break; -+ -+ case SUBSCRIPT_INDEX: -+ { -+ /* DIM_COUNT only stays '0' when no range argument was processed -+ before, starting from the last dimension. This way we can -+ reduce the number of dimensions from the result array. -+ However, if a range has been processed before an index, we -+ treat the index like a range with equal low- and high bounds -+ to get the value offset right. */ -+ if (dim_count == 0) -+ new_array -+ = value_subscripted_rvalue (new_array, index->U.number, -+ f77_get_lowerbound (value_type -+ (new_array))); -+ else -+ { -+ dim_count++; -+ -+ /* We might end up here, because we have to treat the provided -+ index like a range. But now VALUE_SUBSCRIPTED_RVALUE -+ cannot do the range checks for us. So we have to make sure -+ ourselves that the user provided index is inside the -+ array bounds. Throw an error if not. */ -+ if (index->U.number < TYPE_LOW_BOUND (index_type) -+ && index->U.number > TYPE_HIGH_BOUND (index_type)) -+ error (_("provided bound(s) outside array bound(s)")); -+ -+ if (index->U.number > TYPE_LOW_BOUND (index_type) -+ && index->U.number > TYPE_HIGH_BOUND (index_type)) -+ error (_("provided bound(s) outside array bound(s)")); -+ -+ new_array = value_slice_1 (new_array, -+ index->U.number, -+ 1, /* COUNT is '1' element */ -+ 1, /* STRIDE set to '1' */ -+ dim_count); -+ } -+ -+ } -+ break; -+ } -+ array_type = TYPE_TARGET_TYPE (array_type); -+ } -+ -+ /* With DIM_COUNT > 1 we currently have a one dimensional array, but expect -+ an array of arrays, depending on how many ranges have been provided by -+ the user. So we need to rebuild the array dimensions for printing it -+ correctly. -+ Starting from right to left in the user input, after we hit the first -+ range argument every subsequent argument is also treated as a range. -+ E.g.: -+ "p ary(3, 7, 2:15)" in Fortran has only 1 dimension, but we calculated 3 -+ ranges. -+ "p ary(3, 7:12, 4)" in Fortran has only 1 dimension, but we calculated 2 -+ ranges. -+ "p ary(2:4, 5, 7)" in Fortran has only 1 dimension, and we calculated 1 -+ range. */ -+ if (dim_count > 1) -+ { -+ struct value *v = NULL; -+ -+ elt_type = TYPE_TARGET_TYPE (value_type (new_array)); - -- return value_slice (array, low_bound, high_bound - low_bound + 1); -+ /* Every SUBSCRIPT_RANGE in the user input signifies an actual range in -+ the output array. So we traverse the SUBSCRIPT_ARRAY again, looking -+ for a range entry. When we find one, we use the range info to create -+ an additional range_type to set the correct bounds and dimensions for -+ the output array. In addition, we may have a stride value that is not -+ '1', forcing us to adjust the number of elements in a range, according -+ to the stride value. */ -+ for (i = 0; i < nargs; i++) -+ { -+ struct subscript_store *index = &subscript_array[i]; -+ -+ if (index->kind == SUBSCRIPT_RANGE) -+ { -+ struct type *range_type, *interim_array_type; -+ -+ int new_length; -+ -+ /* The length of a sub-dimension with all elements between the -+ bounds plus the start element itself. It may be modified by -+ a user provided stride value. */ -+ new_length = index->U.range.high - index->U.range.low; -+ -+ new_length /= index->U.range.stride; -+ -+ range_type -+ = create_static_range_type (NULL, -+ elt_type, -+ index->U.range.low, -+ index->U.range.low + new_length); -+ -+ interim_array_type = create_array_type (NULL, -+ elt_type, -+ range_type); -+ -+ TYPE_CODE (interim_array_type) -+ = TYPE_CODE (value_type (new_array)); -+ -+ v = allocate_value (interim_array_type); -+ -+ elt_type = value_type (v); -+ } -+ -+ } -+ value_contents_copy (v, 0, new_array, 0, TYPE_LENGTH (elt_type)); -+ return v; -+ } -+ -+ return new_array; - } - - -@@ -1235,19 +1530,6 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, - return eval_call (exp, noside, nargs, argvec, var_func_name, expect_type); - } - --/* Helper for skipping all the arguments in an undetermined argument list. -- This function was designed for use in the OP_F77_UNDETERMINED_ARGLIST -- case of evaluate_subexp_standard as multiple, but not all, code paths -- require a generic skip. */ -- --static void --skip_undetermined_arglist (int nargs, struct expression *exp, int *pos, -- enum noside noside) --{ -- for (int i = 0; i < nargs; ++i) -- evaluate_subexp (NULL_TYPE, exp, pos, noside); --} -- - struct value * - evaluate_subexp_standard (struct type *expect_type, - struct expression *exp, int *pos, -@@ -1942,33 +2224,8 @@ evaluate_subexp_standard (struct type *expect_type, - switch (code) - { - case TYPE_CODE_ARRAY: -- if (exp->elts[*pos].opcode == OP_RANGE) -- return value_f90_subarray (arg1, exp, pos, noside); -- else -- { -- if (noside == EVAL_SKIP) -- { -- skip_undetermined_arglist (nargs, exp, pos, noside); -- /* Return the dummy value with the correct type. */ -- return arg1; -- } -- goto multi_f77_subscript; -- } -- - case TYPE_CODE_STRING: -- if (exp->elts[*pos].opcode == OP_RANGE) -- return value_f90_subarray (arg1, exp, pos, noside); -- else -- { -- if (noside == EVAL_SKIP) -- { -- skip_undetermined_arglist (nargs, exp, pos, noside); -- /* Return the dummy value with the correct type. */ -- return arg1; -- } -- arg2 = evaluate_subexp_with_coercion (exp, pos, noside); -- return value_subscript (arg1, value_as_long (arg2)); -- } -+ return value_f90_subarray (arg1, exp, pos, nargs, noside); - - case TYPE_CODE_PTR: - case TYPE_CODE_FUNC: -@@ -2388,49 +2645,6 @@ evaluate_subexp_standard (struct type *expect_type, - } - return (arg1); - -- multi_f77_subscript: -- { -- LONGEST subscript_array[MAX_FORTRAN_DIMS]; -- int ndimensions = 1, i; -- struct value *array = arg1; -- -- if (nargs > MAX_FORTRAN_DIMS) -- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS); -- -- ndimensions = calc_f77_array_dims (type); -- -- if (nargs != ndimensions) -- error (_("Wrong number of subscripts")); -- -- gdb_assert (nargs > 0); -- -- /* Now that we know we have a legal array subscript expression -- let us actually find out where this element exists in the array. */ -- -- /* Take array indices left to right. */ -- for (i = 0; i < nargs; i++) -- { -- /* Evaluate each subscript; it must be a legal integer in F77. */ -- arg2 = evaluate_subexp_with_coercion (exp, pos, noside); -- -- /* Fill in the subscript array. */ -- -- subscript_array[i] = value_as_long (arg2); -- } -- -- /* Internal type of array is arranged right to left. */ -- for (i = nargs; i > 0; i--) -- { -- struct type *array_type = check_typedef (value_type (array)); -- LONGEST index = subscript_array[i - 1]; -- -- array = value_subscripted_rvalue (array, index, -- f77_get_lowerbound (array_type)); -- } -- -- return array; -- } -- - case BINOP_LOGICAL_AND: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) -@@ -3350,6 +3564,9 @@ calc_f77_array_dims (struct type *array_type) - int ndimen = 1; - struct type *tmp_type; - -+ if (TYPE_CODE (array_type) == TYPE_CODE_STRING) -+ return 1; -+ - if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY)) - error (_("Can't get dimensions for a non-array type")); - -diff --git a/gdb/expprint.c b/gdb/expprint.c ---- a/gdb/expprint.c -+++ b/gdb/expprint.c -@@ -580,17 +580,14 @@ print_subexp_standard (struct expression *exp, int *pos, - longest_to_int (exp->elts[pc + 1].longconst); - *pos += 2; - -- if (range_type == NONE_BOUND_DEFAULT_EXCLUSIVE -- || range_type == LOW_BOUND_DEFAULT_EXCLUSIVE) -+ if ((range_type & SUBARRAY_HIGH_BOUND_EXCLUSIVE) -+ == SUBARRAY_HIGH_BOUND_EXCLUSIVE) - fputs_filtered ("EXCLUSIVE_", stream); - fputs_filtered ("RANGE(", stream); -- if (range_type == HIGH_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT_EXCLUSIVE) -+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND) - print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); - fputs_filtered ("..", stream); -- if (range_type == LOW_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT) -+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND) - print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); - fputs_filtered (")", stream); - return; -@@ -1107,22 +1104,24 @@ dump_subexp_body_standard (struct expression *exp, - - switch (range_type) - { -- case BOTH_BOUND_DEFAULT: -+ case SUBARRAY_NONE_BOUND: - fputs_filtered ("Range '..'", stream); - break; -- case LOW_BOUND_DEFAULT: -+ case SUBARRAY_HIGH_BOUND: - fputs_filtered ("Range '..EXP'", stream); - break; -- case LOW_BOUND_DEFAULT_EXCLUSIVE: -- fputs_filtered ("ExclusiveRange '..EXP'", stream); -- break; -- case HIGH_BOUND_DEFAULT: -+ case SUBARRAY_LOW_BOUND: - fputs_filtered ("Range 'EXP..'", stream); - break; -- case NONE_BOUND_DEFAULT: -+ case (SUBARRAY_LOW_BOUND -+ | SUBARRAY_HIGH_BOUND -+ | SUBARRAY_HIGH_BOUND_EXCLUSIVE): -+ fputs_filtered ("ExclusiveRange '..EXP'", stream); -+ break; -+ case (SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND): - fputs_filtered ("Range 'EXP..EXP'", stream); - break; -- case NONE_BOUND_DEFAULT_EXCLUSIVE: -+ case (SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE): - fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream); - break; - default: -@@ -1130,11 +1129,9 @@ dump_subexp_body_standard (struct expression *exp, - break; - } - -- if (range_type == HIGH_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT) -+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND) - elt = dump_subexp (exp, stream, elt); -- if (range_type == LOW_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT) -+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND) - elt = dump_subexp (exp, stream, elt); - } - break; -diff --git a/gdb/expression.h b/gdb/expression.h ---- a/gdb/expression.h -+++ b/gdb/expression.h -@@ -167,28 +167,27 @@ extern void dump_raw_expression (struct expression *, - struct ui_file *, const char *); - extern void dump_prefix_expression (struct expression *, struct ui_file *); - --/* In an OP_RANGE expression, either bound could be empty, indicating -- that its value is by default that of the corresponding bound of the -- array or string. Also, the upper end of the range can be exclusive -- or inclusive. So we have six sorts of subrange. This enumeration -- type is to identify this. */ -+/* In an OP_RANGE expression, either bound can be provided by the -+ user, or not. In addition to this, the user can also specify a -+ stride value to indicated only certain elements of the array. -+ Also, the upper end of the range can be exclusive or inclusive. -+ This enumeration type is to identify this. */ - - enum range_type --{ -- /* Neither the low nor the high bound was given -- so this refers to -- the entire available range. */ -- BOTH_BOUND_DEFAULT, -- /* The low bound was not given and the high bound is inclusive. */ -- LOW_BOUND_DEFAULT, -- /* The high bound was not given and the low bound in inclusive. */ -- HIGH_BOUND_DEFAULT, -- /* Both bounds were given and both are inclusive. */ -- NONE_BOUND_DEFAULT, -- /* The low bound was not given and the high bound is exclusive. */ -- NONE_BOUND_DEFAULT_EXCLUSIVE, -- /* Both bounds were given. The low bound is inclusive and the high -- bound is exclusive. */ -- LOW_BOUND_DEFAULT_EXCLUSIVE, --}; -+ { -+ SUBARRAY_NONE_BOUND = 0x0, /* "( : )" */ -+ SUBARRAY_LOW_BOUND = 0x1, /* "(low:)" */ -+ SUBARRAY_HIGH_BOUND = 0x2, /* "(:high)" */ -+ SUBARRAY_STRIDE = 0x4, /* "(::stride)" */ -+ /* The low bound was not given and the high bound is exclusive. -+ In this case we always use (SUBARRAY_HIGH_BOUND | -+ SUBARRAY_HIGH_BOUND_EXCLUSIVE). */ -+ SUBARRAY_HIGH_BOUND_EXCLUSIVE = 0x8, -+ /* Both bounds were given. The low bound is inclusive and the high -+ bound is exclusive. In this case, we use (SUBARRAY_LOW_BOUND | -+ SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE). */ -+ // SUBARRAY_LOW_BOUND_EXCLUSIVE = (SUBARRAY_LOW_BOUND -+ // | SUBARRAY_HIGH_BOUND_EXCLUSIVE), -+ }; - - #endif /* !defined (EXPRESSION_H) */ -diff --git a/gdb/f-exp.y b/gdb/f-exp.y ---- a/gdb/f-exp.y -+++ b/gdb/f-exp.y -@@ -282,31 +282,63 @@ arglist : subrange - - arglist : arglist ',' exp %prec ABOVE_COMMA - { pstate->arglist_len++; } -+ | arglist ',' subrange %prec ABOVE_COMMA -+ { pstate->arglist_len++; } - ; - - /* There are four sorts of subrange types in F90. */ - - subrange: exp ':' exp %prec ABOVE_COMMA -- { write_exp_elt_opcode (pstate, OP_RANGE); -- write_exp_elt_longcst (pstate, NONE_BOUND_DEFAULT); -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, -+ SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND); - write_exp_elt_opcode (pstate, OP_RANGE); } - ; - - subrange: exp ':' %prec ABOVE_COMMA - { write_exp_elt_opcode (pstate, OP_RANGE); -- write_exp_elt_longcst (pstate, HIGH_BOUND_DEFAULT); -+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND); - write_exp_elt_opcode (pstate, OP_RANGE); } - ; - - subrange: ':' exp %prec ABOVE_COMMA - { write_exp_elt_opcode (pstate, OP_RANGE); -- write_exp_elt_longcst (pstate, LOW_BOUND_DEFAULT); -+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND); - write_exp_elt_opcode (pstate, OP_RANGE); } - ; - - subrange: ':' %prec ABOVE_COMMA - { write_exp_elt_opcode (pstate, OP_RANGE); -- write_exp_elt_longcst (pstate, BOTH_BOUND_DEFAULT); -+ write_exp_elt_longcst (pstate, SUBARRAY_NONE_BOUND); -+ write_exp_elt_opcode (pstate, OP_RANGE); } -+ ; -+ -+/* Each subrange type can have a stride argument. */ -+subrange: exp ':' exp ':' exp %prec ABOVE_COMMA -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND -+ | SUBARRAY_HIGH_BOUND -+ | SUBARRAY_STRIDE); -+ write_exp_elt_opcode (pstate, OP_RANGE); } -+ ; -+ -+subrange: exp ':' ':' exp %prec ABOVE_COMMA -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND -+ | SUBARRAY_STRIDE); -+ write_exp_elt_opcode (pstate, OP_RANGE); } -+ ; -+ -+subrange: ':' exp ':' exp %prec ABOVE_COMMA -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND -+ | SUBARRAY_STRIDE); -+ write_exp_elt_opcode (pstate, OP_RANGE); } -+ ; -+ -+subrange: ':' ':' exp %prec ABOVE_COMMA -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, SUBARRAY_STRIDE); - write_exp_elt_opcode (pstate, OP_RANGE); } - ; - -diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c ---- a/gdb/f-valprint.c -+++ b/gdb/f-valprint.c -@@ -129,6 +129,11 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type, - byte_stride = dim_size; - size_t offs = 0; - -+ if (byte_stride) -+ dim_size = byte_stride; -+ else -+ dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type)); -+ - for (i = lowerbound; - (i < upperbound + 1 && (*elts) < options->print_max); - i++) -diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c ---- a/gdb/gdbtypes.c -+++ b/gdb/gdbtypes.c -@@ -936,7 +936,7 @@ create_range_type (struct type *result_type, struct type *index_type, - TYPE_RANGE_DATA (result_type)->high = *high_bound; - TYPE_RANGE_DATA (result_type)->bias = bias; - -- /* Initialize the stride to be a constant, the value will already be zero -+ /* bias the stride to be a constant, the value will already be zero - thanks to the use of TYPE_ZALLOC above. */ - TYPE_RANGE_DATA (result_type)->stride.kind = PROP_CONST; - -@@ -1001,7 +1001,8 @@ create_static_range_type (struct type *result_type, struct type *index_type, - high.kind = PROP_CONST; - high.data.const_val = high_bound; - -- result_type = create_range_type (result_type, index_type, &low, &high, 0); -+ result_type = create_range_type (result_type, index_type, -+ &low, &high, 0); - - return result_type; - } -@@ -1236,6 +1237,7 @@ create_array_type_with_stride (struct type *result_type, - if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) - low_bound = high_bound = 0; - element_type = check_typedef (element_type); -+ - /* Be careful when setting the array length. Ada arrays can be - empty arrays with the high_bound being smaller than the low_bound. - In such cases, the array length should be zero. */ -diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h ---- a/gdb/gdbtypes.h -+++ b/gdb/gdbtypes.h -@@ -803,7 +803,6 @@ struct main_type - /* * Union member used for range types. */ - - struct range_bounds *bounds; -- - } flds_bnds; - - /* * Slot to point to additional language-specific fields of this -@@ -1365,6 +1364,15 @@ extern bool set_type_align (struct type *, ULONGEST); - #define TYPE_BIT_STRIDE(range_type) \ - (TYPE_RANGE_DATA(range_type)->stride.data.const_val \ - * (TYPE_RANGE_DATA(range_type)->flag_is_byte_stride ? 8 : 1)) -+#define TYPE_BYTE_STRIDE(range_type) \ -+ TYPE_RANGE_DATA(range_type)->stride.data.const_val -+#define TYPE_BYTE_STRIDE_BLOCK(range_type) \ -+ TYPE_RANGE_DATA(range_type)->stride.data.locexpr -+#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \ -+ TYPE_RANGE_DATA(range_type)->stride.data.loclist -+#define TYPE_BYTE_STRIDE_KIND(range_type) \ -+ TYPE_RANGE_DATA(range_type)->stride.kind -+ - - /* Property accessors for the type data location. */ - #define TYPE_DATA_LOCATION(thistype) \ -@@ -1400,6 +1408,9 @@ extern bool set_type_align (struct type *, ULONGEST); - TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype)) - #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \ - TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype)) -+#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \ -+ (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0) -+ - - #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \ - (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype)))) -diff --git a/gdb/parse.c b/gdb/parse.c ---- a/gdb/parse.c -+++ b/gdb/parse.c -@@ -919,24 +919,20 @@ operator_length_standard (const struct expression *expr, int endpos, - - case OP_RANGE: - oplen = 3; -+ args = 0; - range_type = (enum range_type) - longest_to_int (expr->elts[endpos - 2].longconst); - -- switch (range_type) -- { -- case LOW_BOUND_DEFAULT: -- case LOW_BOUND_DEFAULT_EXCLUSIVE: -- case HIGH_BOUND_DEFAULT: -- args = 1; -- break; -- case BOTH_BOUND_DEFAULT: -- args = 0; -- break; -- case NONE_BOUND_DEFAULT: -- case NONE_BOUND_DEFAULT_EXCLUSIVE: -- args = 2; -- break; -- } -+ /* Increment the argument counter for each argument -+ provided by the user. */ -+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND) -+ args++; -+ -+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND) -+ args++; -+ -+ if ((range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE) -+ args++; - - break; - -diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y ---- a/gdb/rust-exp.y -+++ b/gdb/rust-exp.y -@@ -2492,24 +2492,28 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation, - - case OP_RANGE: - { -- enum range_type kind = BOTH_BOUND_DEFAULT; -+ enum range_type kind = SUBARRAY_NONE_BOUND; - - if (operation->left.op != NULL) - { - convert_ast_to_expression (operation->left.op, top); -- kind = HIGH_BOUND_DEFAULT; -+ kind = SUBARRAY_LOW_BOUND; - } - if (operation->right.op != NULL) - { - convert_ast_to_expression (operation->right.op, top); -- if (kind == BOTH_BOUND_DEFAULT) -- kind = (operation->inclusive -- ? LOW_BOUND_DEFAULT : LOW_BOUND_DEFAULT_EXCLUSIVE); -+ if (kind == SUBARRAY_NONE_BOUND) -+ { -+ kind = (range_type) SUBARRAY_HIGH_BOUND; -+ if (!operation->inclusive) -+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE); -+ } - else - { -- gdb_assert (kind == HIGH_BOUND_DEFAULT); -- kind = (operation->inclusive -- ? NONE_BOUND_DEFAULT : NONE_BOUND_DEFAULT_EXCLUSIVE); -+ gdb_assert (kind == SUBARRAY_LOW_BOUND); -+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND); -+ if (!operation->inclusive) -+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE); - } - } - else -diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c ---- a/gdb/rust-lang.c -+++ b/gdb/rust-lang.c -@@ -1224,13 +1224,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside) - kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst); - *pos += 3; - -- if (kind == HIGH_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT -- || kind == NONE_BOUND_DEFAULT_EXCLUSIVE) -+ if ((kind & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND) - low = evaluate_subexp (NULL_TYPE, exp, pos, noside); -- if (kind == LOW_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT_EXCLUSIVE -- || kind == NONE_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT_EXCLUSIVE) -+ if ((kind & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND) - high = evaluate_subexp (NULL_TYPE, exp, pos, noside); -- bool inclusive = (kind == NONE_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT); -+ bool inclusive = (!((kind & SUBARRAY_HIGH_BOUND_EXCLUSIVE) == SUBARRAY_HIGH_BOUND_EXCLUSIVE)); - - if (noside == EVAL_SKIP) - return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1); -@@ -1319,7 +1317,7 @@ rust_compute_range (struct type *type, struct value *range, - - *low = 0; - *high = 0; -- *kind = BOTH_BOUND_DEFAULT; -+ *kind = SUBARRAY_NONE_BOUND; - - if (TYPE_NFIELDS (type) == 0) - return; -@@ -1327,15 +1325,14 @@ rust_compute_range (struct type *type, struct value *range, - i = 0; - if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0) - { -- *kind = HIGH_BOUND_DEFAULT; -+ *kind = SUBARRAY_LOW_BOUND; - *low = value_as_long (value_field (range, 0)); - ++i; - } - if (TYPE_NFIELDS (type) > i - && strcmp (TYPE_FIELD_NAME (type, i), "end") == 0) - { -- *kind = (*kind == BOTH_BOUND_DEFAULT -- ? LOW_BOUND_DEFAULT : NONE_BOUND_DEFAULT); -+ *kind = (range_type) (*kind | SUBARRAY_HIGH_BOUND); - *high = value_as_long (value_field (range, i)); - - if (rust_inclusive_range_type_p (type)) -@@ -1353,7 +1350,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside, - struct type *rhstype; - LONGEST low, high_bound; - /* Initialized to appease the compiler. */ -- enum range_type kind = BOTH_BOUND_DEFAULT; -+ enum range_type kind = SUBARRAY_NONE_BOUND; - LONGEST high = 0; - int want_slice = 0; - -@@ -1451,7 +1448,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside, - error (_("Cannot subscript non-array type")); - - if (want_slice -- && (kind == BOTH_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT)) -+ && ((kind & SUBARRAY_LOW_BOUND) != SUBARRAY_LOW_BOUND)) - low = low_bound; - if (low < 0) - error (_("Index less than zero")); -@@ -1469,7 +1466,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside, - CORE_ADDR addr; - struct value *addrval, *tem; - -- if (kind == BOTH_BOUND_DEFAULT || kind == HIGH_BOUND_DEFAULT) -+ if ((kind & SUBARRAY_HIGH_BOUND) != SUBARRAY_HIGH_BOUND) - high = high_bound; - if (high < 0) - error (_("High index less than zero")); -diff --git a/gdb/testsuite/gdb.fortran/static-arrays.exp b/gdb/testsuite/gdb.fortran/static-arrays.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/static-arrays.exp -@@ -0,0 +1,421 @@ -+# Copyright 2015 Free Software Foundation, Inc. -+# -+# Contributed by Intel Corp. -+# -+# 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 . -+ -+standard_testfile static-arrays.f90 -+ -+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}] } { -+ return -1 -+} -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_breakpoint [gdb_get_line_number "BP1"] -+gdb_continue_to_breakpoint "BP1" ".*BP1.*" -+ -+# Tests subarrays of one dimensional arrays with subrange variations -+gdb_test "print ar1" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \ -+ "print ar1." -+gdb_test "print ar1\(4:7\)" "\\$\[0-9\]+ = \\(4, 5, 6, 7\\)" \ -+ "print ar1\(4:7\)" -+gdb_test "print ar1\(8:\)" "\\$\[0-9\]+ = \\(8, 9\\).*" \ -+ "print ar1\(8:\)" -+gdb_test "print ar1\(:3\)" "\\$\[0-9\]+ = \\(1, 2, 3\\).*" \ -+ "print ar1\(:3\)" -+gdb_test "print ar1\(:\)" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \ -+ "print ar1\(:\)" -+ -+# Check assignment -+gdb_test_no_output "set \$my_ary = ar1\(3:8\)" -+gdb_test "print \$my_ary" \ -+ "\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \ -+ "Assignment of subarray to variable" -+gdb_test_no_output "set ar1\(5\) = 42" -+ gdb_test "print ar1\(3:8\)" \ -+ "\\$\[0-9\]+ = \\(3, 4, 42, 6, 7, 8\\)" \ -+ "print ar1\(3:8\) after assignment" -+gdb_test "print \$my_ary" \ -+ "\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \ -+ "Assignment of subarray to variable after original array changed" -+ -+# Test for subarrays of one dimensional arrays with literals -+ gdb_test "print ar1\(3\)" "\\$\[0-9\]+ = 3" \ -+ "print ar1\(3\)" -+ -+# Tests for subranges of 2 dimensional arrays with subrange variations -+gdb_test "print ar2\(2:3, 3:4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 23, 33\\) \\( 24, 34\\) \\)" \ -+ "print ar2\(2:3, 3:4\)." -+gdb_test "print ar2\(8:9,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \ -+ "print ar2\(8:9,8:\)" -+gdb_test "print ar2\(8:9,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \ -+ "print ar2\(8:9,:2\)" -+ -+gdb_test "print ar2\(8:,8:9\)" \ -+ "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \ -+ "print ar2\(8:,8:9\)" -+gdb_test "print ar2\(8:,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \ -+ "print ar2\(8:,8:\)" -+gdb_test "print ar2\(8:,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \ -+ "print ar2\(8:,:2\)" -+ -+gdb_test "print ar2\(:2,2:3\)" \ -+ "\\$\[0-9\]+ = \\(\\( 12, 22\\) \\( 13, 23\\) \\)" \ -+ "print ar2\(:2,2:3\)" -+gdb_test "print ar2\(:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 18, 28\\) \\( 19, 29\\) \\)" \ -+ "print ar2\(:2,8:\)" -+gdb_test "print ar2\(:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 11, 21\\) \\( 12, 22\\) \\)" \ -+ "print ar2\(:2,:2\)" -+ -+# Test subranges of 2 dimensional arrays with literals and subrange variations -+gdb_test "print ar2\(7, 3:6\)" \ -+ "\\$\[0-9\]+ = \\(73, 74, 75, 76\\)" \ -+ "print ar2\(7, 3:6\)" -+gdb_test "print ar2\(7,8:\)" \ -+ "\\$\[0-9\]+ = \\(78, 79\\)" \ -+ "print ar2\(7,8:\)" -+gdb_test "print ar2\(7,:2\)" \ -+ "\\$\[0-9\]+ = \\(71, 72\\)" \ -+ "print ar2\(7,:2\)" -+ -+gdb_test "print ar2\(7:8,4\)" \ -+ "\\$\[0-9\]+ = \\(74, 84\\)" \ -+ "print ar2(7:8,4\)" -+gdb_test "print ar2\(8:,4\)" \ -+ "\\$\[0-9\]+ = \\(84, 94\\)" \ -+ "print ar2\(8:,4\)" -+gdb_test "print ar2\(:2,4\)" \ -+ "\\$\[0-9\]+ = \\(14, 24\\)" \ -+ "print ar2\(:2,4\)" -+gdb_test "print ar2\(3,4\)" \ -+ "\\$\[0-9\]+ = 34" \ -+ "print ar2\(3,4\)" -+ -+# Test subarrays of 3 dimensional arrays with literals and subrange variations -+gdb_test "print ar3\(2:4,3:4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 237, 337, 437\\) \\( 247, 347, 447\\)\ -+ \\) \\( \\( 238, 338, 438\\) \\( 248, 348, 448\\) \\) \\)" \ -+ "print ar3\(2:4,3:4,7:8\)" -+gdb_test "print ar3\(2:3,4:5,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 248, 348\\) \\( 258, 358\\) \\) \\(\ -+ \\( 249, 349\\) \\( 259, 359\\) \\) \\)" \ -+ "print ar3\(2:3,4:5,8:\)" -+gdb_test "print ar3\(2:3,4:5,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 241, 341\\) \\( 251, 351\\) \\) \\(\ -+ \\( 242, 342\\) \\( 252, 352\\) \\) \\)" \ -+ "print ar3\(2:3,4:5,:2\)" -+ -+gdb_test "print ar3\(2:3,8:,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 287, 387\\) \\( 297, 397\\) \\) \\(\ -+ \\( 288, 388\\) \\( 298, 398\\) \\) \\)" \ -+ "print ar3\(2:3,8:,7:8\)" -+gdb_test "print ar3\(2:3,8:,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 288, 388\\) \\( 298, 398\\) \\) \\(\ -+ \\( 289, 389\\) \\( 299, 399\\) \\) \\)" \ -+ "print ar3\(2:3,8:,8:\)" -+gdb_test "print ar3\(2:3,8:,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 281, 381\\) \\( 291, 391\\) \\) \\(\ -+ \\( 282, 382\\) \\( 292, 392\\) \\) \\)" \ -+ "print ar3\(2:3,8:,:2\)" -+ -+gdb_test "print ar3\(2:3,:2,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 217, 317\\) \\( 227, 327\\) \\) \\(\ -+ \\( 218, 318\\) \\( 228, 328\\) \\) \\)" \ -+ "print ar3\(2:3,:2,7:8\)" -+gdb_test "print ar3\(2:3,:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 218, 318\\) \\( 228, 328\\) \\) \\(\ -+ \\( 219, 319\\) \\( 229, 329\\) \\) \\)" \ -+ "print ar3\(2:3,:2,8:\)" -+gdb_test "print ar3\(2:3,:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 211, 311\\) \\( 221, 321\\) \\) \\(\ -+ \\( 212, 312\\) \\( 222, 322\\) \\) \\)" \ -+ "print ar3\(2:3,:2,:2\)" -+ -+gdb_test "print ar3\(8:,3:4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 837, 937\\) \\( 847, 947\\) \\) \\(\ -+ \\( 838, 938\\) \\( 848, 948\\) \\) \\)" \ -+ "print ar3\(8:,3:4,7:8\)" -+gdb_test "print ar3\(8:,4:5,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 848, 948\\) \\( 858, 958\\) \\) \\(\ -+ \\( 849, 949\\) \\( 859, 959\\) \\) \\)" \ -+ "print ar3\(8:,4:5,8:\)" -+gdb_test "print ar3\(8:,4:5,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 841, 941\\) \\( 851, 951\\) \\) \\(\ -+ \\( 842, 942\\) \\( 852, 952\\) \\) \\)" \ -+ "print ar3\(8:,4:5,:2\)" -+ -+gdb_test "print ar3\(8:,8:,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 887, 987\\) \\( 897, 997\\) \\) \\(\ -+ \\( 888, 988\\) \\( 898, 998\\) \\) \\)" \ -+ "print ar3\(8:,8:,7:8\)" -+gdb_test "print ar3\(8:,8:,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 888, 988\\) \\( 898, 998\\) \\) \\(\ -+ \\( 889, 989\\) \\( 899, 999\\) \\) \\)" \ -+ "print ar3\(8:,8:,8:\)" -+gdb_test "print ar3\(8:,8:,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 881, 981\\) \\( 891, 991\\) \\) \\(\ -+ \\( 882, 982\\) \\( 892, 992\\) \\) \\)" \ -+ "print ar3\(8:,8:,:2\)" -+ -+gdb_test "print ar3\(8:,:2,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 817, 917\\) \\( 827, 927\\) \\) \\(\ -+ \\( 818, 918\\) \\( 828, 928\\) \\) \\)" \ -+ "print ar3\(8:,:2,7:8\)" -+gdb_test "print ar3\(8:,:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 818, 918\\) \\( 828, 928\\) \\) \\(\ -+ \\( 819, 919\\) \\( 829, 929\\) \\) \\)" \ -+ "print ar3\(8:,:2,8:\)" -+gdb_test "print ar3\(8:,:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 811, 911\\) \\( 821, 921\\) \\) \\(\ -+ \\( 812, 912\\) \\( 822, 922\\) \\) \\)" \ -+ "print ar3\(8:,:2,:2\)" -+ -+ -+gdb_test "print ar3\(:2,3:4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 137, 237\\) \\( 147, 247\\) \\) \\(\ -+ \\( 138, 238\\) \\( 148, 248\\) \\) \\)" \ -+ "print ar3 \(:2,3:4,7:8\)." -+gdb_test "print ar3\(:2,3:4,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 138, 238\\) \\( 148, 248\\) \\) \\(\ -+ \\( 139, 239\\) \\( 149, 249\\) \\) \\)" \ -+ "print ar3\(:2,3:4,8:\)" -+gdb_test "print ar3\(:2,3:4,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 131, 231\\) \\( 141, 241\\) \\) \\(\ -+ \\( 132, 232\\) \\( 142, 242\\) \\) \\)" \ -+ "print ar3\(:2,3:4,:2\)" -+ -+gdb_test "print ar3\(:2,8:,7:8\)" "\\$\[0-9\]+ = \\(\\( \\( 187, 287\\) \\(\ -+ 197, 297\\) \\) \\( \\( 188, 288\\) \\( 198, 298\\) \\) \\)" \ -+ "print ar3\(:2,8:,7:8\)" -+gdb_test "print ar3\(:2,8:,8:\)" "\\$\[0-9\]+ = \\(\\( \\( 188, 288\\) \\( 198,\ -+ 298\\) \\) \\( \\( 189, 289\\) \\( 199, 299\\) \\) \\)" \ -+ "print ar3\(:2,8:,8:\)" -+gdb_test "print ar3\(:2,8:,:2\)" "\\$\[0-9\]+ = \\(\\( \\( 181, 281\\) \\( 191,\ -+ 291\\) \\) \\( \\( 182, 282\\) \\( 192, 292\\) \\) \\)" \ -+ "print ar3\(:2,8:,:2\)" -+ -+gdb_test "print ar3\(:2,:2,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 117, 217\\) \\( 127, 227\\) \\) \\(\ -+ \\( 118, 218\\) \\( 128, 228\\) \\) \\)" \ -+ "print ar3\(:2,:2,7:8\)" -+gdb_test "print ar3\(:2,:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 118, 218\\) \\( 128, 228\\) \\) \\(\ -+ \\( 119, 219\\) \\( 129, 229\\) \\) \\)" \ -+ "print ar3\(:2,:2,8:\)" -+gdb_test "print ar3\(:2,:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\) \\(\ -+ \\( 112, 212\\) \\( 122, 222\\) \\) \\)" \ -+ "print ar3\(:2,:2,:2\)" -+ -+#Tests for subarrays of 3 dimensional arrays with literals and subranges -+gdb_test "print ar3\(3,3:4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 337, 347\\) \\( 338, 348\\) \\)" \ -+ "print ar3\(3,3:4,7:8\)" -+gdb_test "print ar3\(3,4:5,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 348, 358\\) \\( 349, 359\\) \\)" \ -+ "print ar3\(3,4:5,8:\)" -+gdb_test "print ar3\(3,4:5,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 341, 351\\) \\( 342, 352\\) \\)" \ -+ "print ar3\(3,4:5,:2\)" -+gdb_test "print ar3\(3,4:5,3\)" \ -+ "\\$\[0-9\]+ = \\(343, 353\\)" \ -+ "print ar3\(3,4:5,3\)" -+ -+gdb_test "print ar3\(2,8:,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 287, 297\\) \\( 288, 298\\) \\)" \ -+ "print ar3\(2,8:,7:8\)" -+gdb_test "print ar3\(2,8:,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 288, 298\\) \\( 289, 299\\) \\)" \ -+ "print ar3\(2,8:,8:\)" -+gdb_test "print ar3\(2,8:,:2\)"\ -+ "\\$\[0-9\]+ = \\(\\( 281, 291\\) \\( 282, 292\\) \\)" \ -+ "print ar3\(2,8:,:2\)" -+gdb_test "print ar3\(2,8:,3\)" \ -+ "\\$\[0-9\]+ = \\(283, 293\\)" \ -+ "print ar3\(2,8:,3\)" -+ -+gdb_test "print ar3\(2,:2,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 217, 227\\) \\( 218, 228\\) \\)" \ -+ "print ar3\(2,:2,7:8\)" -+gdb_test "print ar3\(2,:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 218, 228\\) \\( 219, 229\\) \\)" \ -+ "print ar3\(2,:2,8:\)" -+gdb_test "print ar3\(2,:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 211, 221\\) \\( 212, 222\\) \\)" \ -+ "print ar3\(2,:2,:2\)" -+gdb_test "print ar3\(2,:2,3\)" \ -+ "\\$\[0-9\]+ = \\(213, 223\\)" \ -+ "print ar3\(2,:2,3\)" -+ -+gdb_test "print ar3\(3,4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(347, 348\\)" \ -+ "print ar3\(3,4,7:8\)" -+gdb_test "print ar3\(3,4,8:\)" \ -+ "\\$\[0-9\]+ = \\(348, 349\\)" \ -+i "print ar3\(3,4,8:\)" -+gdb_test "print ar3\(3,4,:2\)" \ -+ "\\$\[0-9\]+ = \\(341, 342\\)" \ -+ "print ar3\(3,4,:2\)" -+gdb_test "print ar3\(5,6,7\)" \ -+ "\\$\[0-9\]+ = 567" \ -+ "print ar3\(5,6,7\)" -+ -+gdb_test "print ar3\(3:4,6,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 367, 467\\) \\( 368, 468\\) \\)" \ -+ "print ar3\(3:4,6,7:8\)" -+gdb_test "print ar3\(3:4,6,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 368, 468\\) \\( 369, 469\\) \\)" \ -+ "print ar3\(3:4,6,8:\)" -+gdb_test "print ar3\(3:4,6,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 361, 461\\) \\( 362, 462\\) \\)" \ -+ "print ar3\(3:4,6,:2\)" -+gdb_test "print ar3\(3:4,6,5\)" \ -+ "\\$\[0-9\]+ = \\(365, 465\\)" \ -+ "print ar3\(3:4,6,5\)" -+ -+gdb_test "print ar3\(8:,6,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 867, 967\\) \\( 868, 968\\) \\)" \ -+ "print ar3\(8:,6,7:8\)" -+gdb_test "print ar3\(8:,6,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 868, 968\\) \\( 869, 969\\) \\)" \ -+ "print ar3\(8:,6,8:\)" -+gdb_test "print ar3\(8:,6,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 861, 961\\) \\( 862, 962\\) \\)" \ -+ "print ar3\(8:,6,:2\)" -+gdb_test "print ar3\(8:,6,5\)" \ -+ "\\$\[0-9\]+ = \\(865, 965\\)" \ -+ "print ar3\(8:,6,5\)" -+ -+gdb_test "print ar3\(:2,6,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 167, 267\\) \\( 168, 268\\) \\)" \ -+ "print ar3\(:2,6,7:8\)" -+gdb_test "print ar3\(:2,6,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 168, 268\\) \\( 169, 269\\) \\)" \ -+ "print ar3\(:2,6,8:\)" -+gdb_test "print ar3\(:2,6,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 161, 261\\) \\( 162, 262\\) \\)" \ -+ "print ar3\(:2,6,:2\)" -+gdb_test "print ar3\(:2,6,5\)" \ -+ "\\$\[0-9\]+ = \\(165, 265\\)" \ -+ "print ar3\(:2,6,5\)" -+ -+gdb_test "print ar3\(3:4,5:6,4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 354, 454\\) \\( 364, 464\\) \\)" \ -+ "print ar2\(3:4,5:6,4\)" -+gdb_test "print ar3\(8:,5:6,4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 854, 954\\) \\( 864, 964\\) \\)" \ -+ "print ar2\(8:,5:6,4\)" -+gdb_test "print ar3\(:2,5:6,4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 154, 254\\) \\( 164, 264\\) \\)" \ -+ "print ar2\(:2,5:6,4\)" -+ -+# Stride > 1 -+gdb_test "print ar1\(2:6:2\)" \ -+ "\\$\[0-9\]+ = \\(2, 4, 6\\)" \ -+ "print ar1\(2:6:2\)" -+gdb_test "print ar2\(2:6:2,3:4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 23, 43, 63\\) \\( 24, 44, 64\\) \\)" \ -+ "print ar2\(2:6:2,3:4\)" -+gdb_test "print ar2\(2:6:2,3\)" \ -+ "\\$\[0-9\]+ = \\(23, 43, 63\\)" \ -+ "print ar2\(2:6:2,3\)" -+gdb_test "print ar3\(2:6:2,3:5:2,4:7:3\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 234, 434, 634\\) \\( 254, 454, 654\\)\ -+ \\) \\( \\( 237, 437, 637\\) \\( 257, 457, 657\\) \\) \\)" \ -+ "print ar3\(2:6:2,3:5:2,4:7:3\)" -+gdb_test "print ar3\(2:6:2,5,4:7:3\)" \ -+ "\\$\[0-9\]+ = \\(\\( 254, 454, 654\\) \\( 257, 457, 657\\)\ -+ \\)" \ -+ "print ar3\(2:6:2,5,4:7:3\)" -+ -+# Stride < 0 -+gdb_test "print ar1\(8:2:-2\)" \ -+ "\\$\[0-9\]+ = \\(8, 6, 4, 2\\)" \ -+ "print ar1\(8:2:-2\)" -+gdb_test "print ar2\(8:2:-2,3:4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 83, 63, 43, 23\\) \\( 84, 64, 44, 24\\)\ -+ \\)" \ -+ "print ar2\(8:2:-2,3:4\)" -+gdb_test "print ar2\(2:6:2,3\)" \ -+ "\\$\[0-9\]+ = \\(23, 43, 63\\)" \ -+ "print ar2\(2:6:2,3\)" -+gdb_test "print ar3\(2:3,7:3:-4,4:7:3\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 274, 374\\) \\( 234, 334\\) \\) \\(\ -+ \\( 277, 377\\) \\( 237, 337\\) \\) \\)" \ -+ "print ar3\(2:3,7:3:-4,4:7:3\)" -+gdb_test "print ar3\(2:6:2,5,7:4:-3\)" \ -+ "\\$\[0-9\]+ = \\(\\( 257, 457, 657\\) \\( 254, 454, 654\\)\ -+ \\)" \ -+ "print ar3\(2:6:2,5,7:4:-3\)" -+ -+# Tests with negative and mixed indices -+gdb_test "p ar4\(2:4, -2:1, -15:-14\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 261, 361, 461\\) \\( 271, 371, 471\\)\ -+ \\( 281, 381, 481\\) \\( 291, 391, 491\\) \\) \\( \\( 262,\ -+ 362, 462\\) \\( 272, 372, 472\\) \\( 282, 382, 482\\) \\( 292,\ -+ 392, 492\\) \\) \\)" \ -+ "print ar4(2:4, -2:1, -15:-14)" -+ -+gdb_test "p ar4\(7,-6:2:3,-7\)" \ -+ "\\$\[0-9\]+ = \\(729, 759, 789\\)" \ -+ "print ar4(7,-6:2:3,-7)" -+ -+gdb_test "p ar4\(9:2:-2, -6:2:3, -6:-15:-3\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 930, 730, 530, 330\\) \\( 960, 760,\ -+ 560, 360\\) \\( 990, 790, 590, 390\\) \\) \\( \\( 927, 727,\ -+ 527, 327\\) \\( 957, 757, 557, 357\\) \\( 987, 787, 587,\ -+ 387\\) \\) \\( \\( 924, 724, 524, 324\\) \\( 954, 754, 554,\ -+ 354\\) \\( 984, 784, 584, 384\\) \\) \\( \\( 921, 721, 521,\ -+ 321\\) \\( 951, 751, 551, 351\\) \\( 981, 781, 581, 381\\) \\)\ -+ \\)" \ -+ "print ar4(9:2:-2, -6:2:3, -6:-15:-3)" -+ -+gdb_test "p ar4\(:,:,:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 111, 211, 311, 411, 511, 611, 711,\ -+ 811, .*" \ -+ "print ar4(:,:,:)" -+ -+# Provoke error messages for bad user input -+gdb_test "print ar1\(0:4\)" \ -+ "provided bound\\(s\\) outside array bound\\(s\\)" \ -+ "print ar1\(0:4\)" -+gdb_test "print ar1\(8:12\)" \ -+ "provided bound\\(s\\) outside array bound\\(s\\)" \ -+ "print ar1\(8:12\)" -+gdb_test "print ar1\(8:2:\)" \ -+ "A syntax error in expression, near `\\)'." \ -+ "print ar1\(8:2:\)" -+gdb_test "print ar1\(8:2:2\)" \ -+ "Wrong value provided for stride and boundaries" \ -+ "print ar1\(8:2:2\)" -+gdb_test "print ar1\(2:8:-2\)" \ -+ "Wrong value provided for stride and boundaries" \ -+ "print ar1\(2:8:-2\)" -+gdb_test "print ar1\(2:7:0\)" \ -+ "Stride must not be 0" \ -+ "print ar1\(2:7:0\)" -+gdb_test "print ar1\(3:7\) = 42" \ -+ "Invalid cast." \ -+ "Assignment of value to subarray" -diff --git a/gdb/testsuite/gdb.fortran/static-arrays.f90 b/gdb/testsuite/gdb.fortran/static-arrays.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/static-arrays.f90 -@@ -0,0 +1,55 @@ -+! Copyright 2015 Free Software Foundation, Inc. -+! -+! Contributed by Intel Corp. -+! -+! 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 . -+ -+subroutine sub -+ integer, dimension(9) :: ar1 -+ integer, dimension(9,9) :: ar2 -+ integer, dimension(9,9,9) :: ar3 -+ integer, dimension(10,-7:3, -15:-5) :: ar4 -+ integer :: i,j,k -+ -+ ar1 = 1 -+ ar2 = 1 -+ ar3 = 1 -+ ar4 = 4 -+ -+ ! Resulting array ar3 looks like ((( 111, 112, 113, 114,...))) -+ do i = 1, 9, 1 -+ ar1(i) = i -+ do j = 1, 9, 1 -+ ar2(i,j) = i*10 + j -+ do k = 1, 9, 1 -+ ar3(i,j,k) = i*100 + j*10 + k -+ end do -+ end do -+ end do -+ -+ do i = 1, 10, 1 -+ do j = -7, 3, 1 -+ do k = -15, -5, 1 -+ ar4(i,j,k) = i*100 + (j+8)*10 + (k+16) -+ end do -+ end do -+ end do -+ -+ ar1(1) = 11 !BP1 -+ return -+end -+ -+program testprog -+ call sub -+end -diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp ---- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp -+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp -@@ -32,7 +32,8 @@ gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1" - gdb_test "print sizeof(vla1(3,2,1))" \ - "no such vector element \\(vector not allocated\\)" \ - "print sizeof non-allocated indexed vla1" --gdb_test "print sizeof(vla1(3:4,2,1))" "array not allocated" \ -+gdb_test "print sizeof(vla1(3:4,2,1))" \ -+ "provided bound\\(s\\) outside array bound\\(s\\)" \ - "print sizeof non-allocated sliced vla1" - - # Try to access value in allocated VLA -@@ -41,7 +42,7 @@ gdb_continue_to_breakpoint "vla1-allocated" - gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1" - gdb_test "print sizeof(vla1(3,2,1))" "4" \ - "print sizeof element from allocated vla1" --gdb_test "print sizeof(vla1(3:4,2,1))" "800" \ -+gdb_test "print sizeof(vla1(3:4,2,1))" "8" \ - "print sizeof sliced vla1" - - # Try to access values in undefined pointer to VLA (dangling) -@@ -49,7 +50,8 @@ gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla" - gdb_test "print sizeof(pvla(3,2,1))" \ - "no such vector element \\(vector not associated\\)" \ - "print sizeof non-associated indexed pvla" --gdb_test "print sizeof(pvla(3:4,2,1))" "array not associated" \ -+gdb_test "print sizeof(pvla(3:4,2,1))" \ -+ "provided bound\\(s\\) outside array bound\\(s\\)" \ - "print sizeof non-associated sliced pvla" - - # Try to access values in pointer to VLA and compare them -@@ -58,7 +60,8 @@ gdb_continue_to_breakpoint "pvla-associated" - gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla" - gdb_test "print sizeof(pvla(3,2,1))" "4" \ - "print sizeof element from associated pvla" --gdb_test "print sizeof(pvla(3:4,2,1))" "800" "print sizeof sliced pvla" -+ -+gdb_test "print sizeof(pvla(3:4,2,1))" "8" "print sizeof sliced pvla" - - gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds-v1"] - gdb_continue_to_breakpoint "vla1-neg-bounds-v1" -diff --git a/gdb/testsuite/gdb.fortran/vla-stride.exp b/gdb/testsuite/gdb.fortran/vla-stride.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-stride.exp -@@ -0,0 +1,47 @@ -+# Copyright 2016 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 . -+ -+standard_testfile ".f90" -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ -+ {debug f90 quiet}] } { -+ return -1 -+} -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_test_no_output "set max-value-size unlimited" \ -+ "set max-value-size to unlimited" -+ -+gdb_breakpoint [gdb_get_line_number "re-reverse-elements"] -+gdb_continue_to_breakpoint "re-reverse-elements" -+gdb_test "print pvla" " = \\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\\)" \ -+ "print re-reverse-elements" -+gdb_test "print pvla(1)" " = 1" "print first re-reverse-element" -+gdb_test "print pvla(10)" " = 10" "print last re-reverse-element" -+ -+gdb_breakpoint [gdb_get_line_number "odd-elements"] -+gdb_continue_to_breakpoint "odd-elements" -+gdb_test "print pvla" " = \\\(1, 3, 5, 7, 9\\\)" "print odd-elements" -+gdb_test "print pvla(1)" " = 1" "print first odd-element" -+gdb_test "print pvla(5)" " = 9" "print last odd-element" -+ -+gdb_breakpoint [gdb_get_line_number "single-element"] -+gdb_continue_to_breakpoint "single-element" -+gdb_test "print pvla" " = \\\(5\\\)" "print single-element" -+gdb_test "print pvla(1)" " = 5" "print one single-element" -diff --git a/gdb/testsuite/gdb.fortran/vla-stride.f90 b/gdb/testsuite/gdb.fortran/vla-stride.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-stride.f90 -@@ -0,0 +1,29 @@ -+! Copyright 2016 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 . -+ -+program vla_stride -+ integer, target, allocatable :: vla (:) -+ integer, pointer :: pvla (:) -+ -+ allocate(vla(10)) -+ vla = (/ (I, I = 1,10) /) -+ -+ pvla => vla(10:1:-1) -+ pvla => pvla(10:1:-1) -+ pvla => vla(1:10:2) ! re-reverse-elements -+ pvla => vla(5:4:-2) ! odd-elements -+ -+ pvla => null() ! single-element -+end program vla_stride -diff --git a/gdb/valops.c b/gdb/valops.c ---- a/gdb/valops.c -+++ b/gdb/valops.c -@@ -3797,13 +3797,42 @@ value_of_this_silent (const struct language_defn *lang) - - struct value * - value_slice (struct value *array, int lowbound, int length) -+{ -+ /* Pass unaltered arguments to VALUE_SLICE_1, plus a default stride -+ value of '1', which returns every element between LOWBOUND and -+ (LOWBOUND + LENGTH). We also provide a default CALL_COUNT of '1' -+ as we are only considering the highest dimension, or we are -+ working on a one dimensional array. So we call VALUE_SLICE_1 -+ exactly once. */ -+ return value_slice_1 (array, lowbound, length, 1, 1); -+} -+ -+/* VALUE_SLICE_1 is called for each array dimension to calculate the number -+ of elements as defined by the subscript expression. -+ CALL_COUNT is used to determine if we are calling the function once, e.g. -+ we are working on the current dimension of ARRAY, or if we are calling -+ the function repeatedly. In the later case we need to take elements -+ from the TARGET_TYPE of ARRAY. -+ With a CALL_COUNT greater than 1 we calculate the offsets for every element -+ that should be in the result array. Then we fetch the contents and then -+ copy them into the result array. The result array will have one dimension -+ less than the input array, so later on we need to recreate the indices and -+ ranges in the calling function. */ -+ -+struct value * -+value_slice_1 (struct value *array, int lowbound, int length, -+ int stride_length, int call_count) - { - struct type *slice_range_type, *slice_type, *range_type; -- LONGEST lowerbound, upperbound; -- struct value *slice; -- struct type *array_type; -+ struct type *array_type = check_typedef (value_type (array)); -+ struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); -+ unsigned int elt_size, elt_offs; -+ LONGEST ary_high_bound, ary_low_bound; -+ struct value *v; -+ int slice_range_size, i = 0, row_count = 1, elem_count = 1; - -- array_type = check_typedef (value_type (array)); -+ /* Check for legacy code if we are actually dealing with an array or -+ string. */ - if (TYPE_CODE (array_type) != TYPE_CODE_ARRAY - && TYPE_CODE (array_type) != TYPE_CODE_STRING) - error (_("cannot take slice of non-array")); -@@ -3813,45 +3842,155 @@ value_slice (struct value *array, int lowbound, int length) - if (type_not_associated (array_type)) - error (_("array not associated")); - -- range_type = TYPE_INDEX_TYPE (array_type); -- if (get_discrete_bounds (range_type, &lowerbound, &upperbound) < 0) -- error (_("slice from bad array or bitstring")); -+ ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (array_type)); -+ ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (array_type)); -+ -+ /* When we are working on a multi-dimensional array, we need to get the -+ attributes of the underlying type. */ -+ if (call_count > 1) -+ { -+ ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (elt_type)); -+ ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (elt_type)); -+ elt_type = check_typedef (TYPE_TARGET_TYPE (elt_type)); -+ row_count = TYPE_LENGTH (array_type) -+ / TYPE_LENGTH (TYPE_TARGET_TYPE (array_type)); -+ } -+ -+ /* With a stride of '1', the number of elements per result row is equal to -+ the LENGTH of the subarray. With non-default stride values, we skip -+ elements, but have to add the start element to the total number of -+ elements per row. */ -+ if (stride_length == 1) -+ elem_count = length; -+ else -+ elem_count = ((length - 1) / stride_length) + 1; -+ -+ elt_size = TYPE_LENGTH (elt_type); -+ elt_offs = lowbound - ary_low_bound; - -- if (lowbound < lowerbound || length < 0 -- || lowbound + length - 1 > upperbound) -- error (_("slice out of range")); -+ elt_offs *= elt_size; -+ -+ /* Check for valid user input. In case of Fortran this was already done -+ in the calling function. */ -+ if (call_count == 1 -+ && (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type) -+ && elt_offs >= TYPE_LENGTH (array_type))) -+ error (_("no such vector element")); -+ -+ /* CALL_COUNT is 1 when we are dealing either with the highest dimension -+ of the array, or a one dimensional array. Set RANGE_TYPE accordingly. -+ In both cases we calculate how many rows/elements will be in the output -+ array by setting slice_range_size. */ -+ if (call_count == 1) -+ { -+ range_type = TYPE_INDEX_TYPE (array_type); -+ slice_range_size = ary_low_bound + elem_count - 1; -+ -+ /* Check if the array bounds are valid. */ -+ if (get_discrete_bounds (range_type, &ary_low_bound, &ary_high_bound) < 0) -+ error (_("slice from bad array or bitstring")); -+ } -+ /* When CALL_COUNT is greater than 1, we are dealing with an array of arrays. -+ So we need to get the type below the current one and set the RANGE_TYPE -+ accordingly. */ -+ else -+ { -+ range_type = TYPE_INDEX_TYPE (TYPE_TARGET_TYPE (array_type)); -+ slice_range_size = ary_low_bound + (row_count * elem_count) - 1; -+ ary_low_bound = TYPE_LOW_BOUND (range_type); -+ } - - /* FIXME-type-allocation: need a way to free this type when we are -- done with it. */ -- slice_range_type = create_static_range_type (NULL, -- TYPE_TARGET_TYPE (range_type), -- lowbound, -- lowbound + length - 1); -+ done with it. */ - -+ slice_range_type = create_static_range_type (NULL, TYPE_TARGET_TYPE (range_type), -+ ary_low_bound, slice_range_size); - { -- struct type *element_type = TYPE_TARGET_TYPE (array_type); -- LONGEST offset -- = (lowbound - lowerbound) * TYPE_LENGTH (check_typedef (element_type)); -+ struct type *element_type; -+ -+ /* When both CALL_COUNT and STRIDE_LENGTH equal 1, we can use the legacy -+ code for subarrays. */ -+ if (call_count == 1 && stride_length == 1) -+ { -+ element_type = TYPE_TARGET_TYPE (array_type); -+ -+ slice_type = create_array_type (NULL, element_type, slice_range_type); - -- slice_type = create_array_type (NULL, -- element_type, -- slice_range_type); -- TYPE_CODE (slice_type) = TYPE_CODE (array_type); -+ TYPE_CODE (slice_type) = TYPE_CODE (array_type); - -- if (VALUE_LVAL (array) == lval_memory && value_lazy (array)) -- slice = allocate_value_lazy (slice_type); -+ if (VALUE_LVAL (array) == lval_memory && value_lazy (array)) -+ v = allocate_value_lazy (slice_type); -+ else -+ { -+ v = allocate_value (slice_type); -+ value_contents_copy (v, -+ value_embedded_offset (v), -+ array, -+ value_embedded_offset (array) + elt_offs, -+ elt_size * longest_to_int (length)); -+ } -+ -+ } -+ /* With a CALL_COUNT or STRIDE_LENGTH are greater than 1 we are working -+ on a range of ranges. So we copy the relevant elements into the -+ new array we return. */ - else - { -- slice = allocate_value (slice_type); -- value_contents_copy (slice, 0, array, offset, -- type_length_units (slice_type)); -+ int j, offs_store = elt_offs; -+ LONGEST dst_offset = 0; -+ LONGEST src_row_length = TYPE_LENGTH (TYPE_TARGET_TYPE (array_type)); -+ -+ if (call_count == 1) -+ { -+ /* When CALL_COUNT is equal to 1 we are working on the current range -+ and use these elements directly. */ -+ element_type = TYPE_TARGET_TYPE (array_type); -+ } -+ else -+ { -+ /* Working on an array of arrays, the type of the elements is the type -+ of the subarrays' type. */ -+ element_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (array_type)); -+ } -+ -+ slice_type = create_array_type (NULL, element_type, slice_range_type); -+ -+ /* If we have a one dimensional array, we copy its TYPE_CODE. For a -+ multi dimensional array we copy the embedded type's TYPE_CODE. */ -+ if (call_count == 1) -+ TYPE_CODE (slice_type) = TYPE_CODE (array_type); -+ else -+ TYPE_CODE (slice_type) = TYPE_CODE (TYPE_TARGET_TYPE (array_type)); -+ -+ v = allocate_value (slice_type); -+ -+ /* Iterate through the rows of the outer array and set the new offset -+ for each row. */ -+ for (i = 0; i < row_count; i++) -+ { -+ elt_offs = offs_store + i * src_row_length; -+ -+ /* Iterate through the elements in each row to copy only those. */ -+ for (j = 1; j <= elem_count; j++) -+ { -+ /* Fetches the contents of ARRAY and copies them into V. */ -+ value_contents_copy (v, dst_offset, array, elt_offs, elt_size); -+ elt_offs += elt_size * stride_length; -+ dst_offset += elt_size; -+ } -+ } - } - -- set_value_component_location (slice, array); -- set_value_offset (slice, value_offset (array) + offset); -+ set_value_component_location (v, array); -+ if (VALUE_LVAL (v) == lval_register) -+ { -+ VALUE_REGNUM (v) = VALUE_REGNUM (array); -+ VALUE_NEXT_FRAME_ID (v) = VALUE_NEXT_FRAME_ID (array); -+ } -+ set_value_offset (v, value_offset (array) + elt_offs); - } - -- return slice; -+ return v; - } - - /* Create a value for a FORTRAN complex number. Currently most of the -diff --git a/gdb/value.h b/gdb/value.h ---- a/gdb/value.h -+++ b/gdb/value.h -@@ -1145,6 +1145,8 @@ extern struct value *varying_to_slice (struct value *); - - extern struct value *value_slice (struct value *, int, int); - -+extern struct value *value_slice_1 (struct value *, int, int, int, int); -+ - extern struct value *value_literal_complex (struct value *, struct value *, - struct type *); - diff --git a/gdb-vla-intel-fortran-vla-strings.patch b/gdb-vla-intel-fortran-vla-strings.patch deleted file mode 100644 index c56dbde9ed78eb5006a32f1b92b17ae8e4c2e63b..0000000000000000000000000000000000000000 --- a/gdb-vla-intel-fortran-vla-strings.patch +++ /dev/null @@ -1,1110 +0,0 @@ -git diff --stat -p gdb/master...gdb/users/bheckel/fortran-vla-strings -0ad7d8d1a3a36c6e04e3b6d37d8825f18d595723 - - gdb/NEWS | 2 + - gdb/c-valprint.c | 22 +++++ - gdb/dwarf2read.c | 158 +++++++++++++++++++++++++----- - gdb/f-typeprint.c | 93 +++++++++--------- - gdb/gdbtypes.c | 44 ++++++++- - gdb/testsuite/gdb.cp/vla-cxx.cc | 9 ++ - gdb/testsuite/gdb.cp/vla-cxx.exp | 9 ++ - gdb/testsuite/gdb.fortran/pointers.exp | 143 +++++++++++++++++++++++++++ - gdb/testsuite/gdb.fortran/pointers.f90 | 109 +++++++++++++++++++++ - gdb/testsuite/gdb.fortran/print_type.exp | 100 +++++++++++++++++++ - gdb/testsuite/gdb.fortran/vla-ptype.exp | 12 +-- - gdb/testsuite/gdb.fortran/vla-strings.exp | 103 +++++++++++++++++++ - gdb/testsuite/gdb.fortran/vla-strings.f90 | 39 ++++++++ - gdb/testsuite/gdb.fortran/vla-type.exp | 7 +- - gdb/testsuite/gdb.fortran/vla-value.exp | 12 ++- - gdb/testsuite/gdb.mi/mi-var-child-f.exp | 7 +- - gdb/testsuite/gdb.mi/mi-vla-fortran.exp | 27 ++--- - gdb/typeprint.c | 19 ++++ - gdb/valops.c | 16 ++- - gdb/valprint.c | 6 -- - 20 files changed, 827 insertions(+), 110 deletions(-) - -diff --git a/gdb/NEWS b/gdb/NEWS ---- a/gdb/NEWS -+++ b/gdb/NEWS -@@ -805,6 +805,8 @@ SH-5/SH64 running OpenBSD SH-5/SH64 support in sh*-*-openbsd* - - *** Changes in GDB 8.1 - -+* Fortran: Support pointers to dynamic types. -+ - * GDB now supports dynamically creating arbitrary register groups specified - in XML target descriptions. This allows for finer grain grouping of - registers on systems with a large amount of registers. -diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c ---- a/gdb/c-valprint.c -+++ b/gdb/c-valprint.c -@@ -649,6 +649,28 @@ c_value_print (struct value *val, struct ui_file *stream, - else - { - /* normal case */ -+ if (TYPE_CODE (type) == TYPE_CODE_PTR -+ && 1 == is_dynamic_type (type)) -+ { -+ CORE_ADDR addr; -+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type))) -+ addr = value_address (val); -+ else -+ addr = value_as_address (val); -+ -+ /* We resolve the target-type only when the -+ pointer is associated. */ -+ if ((addr != 0) -+ && (0 == type_not_associated (type))) -+ TYPE_TARGET_TYPE (type) = -+ resolve_dynamic_type (TYPE_TARGET_TYPE (type), -+ NULL, addr); -+ } -+ else -+ { -+ /* Do nothing. References are already resolved from the beginning, -+ only pointers are resolved when we actual need the target. */ -+ } - fprintf_filtered (stream, "("); - type_print (value_type (val), "", stream, -1); - fprintf_filtered (stream, ") "); -diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -1827,7 +1827,10 @@ static void read_signatured_type (struct signatured_type *); - - static int attr_to_dynamic_prop (const struct attribute *attr, - struct die_info *die, struct dwarf2_cu *cu, -- struct dynamic_prop *prop, struct type *type); -+ struct dynamic_prop *prop, -+ struct type *default_type, -+ const gdb_byte *additional_data, -+ int additional_data_size); - - /* memory allocation interface */ - -@@ -13799,7 +13802,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) - newobj->static_link - = XOBNEW (&objfile->objfile_obstack, struct dynamic_prop); - attr_to_dynamic_prop (attr, die, cu, newobj->static_link, -- dwarf2_per_cu_addr_type (cu->per_cu)); -+ dwarf2_per_cu_addr_type (cu->per_cu), NULL, 0); - } - - cu->list_in_scope = cu->get_builder ()->get_local_symbols (); -@@ -16565,7 +16568,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) - byte_stride_prop - = (struct dynamic_prop *) alloca (sizeof (struct dynamic_prop)); - stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop, -- prop_type); -+ prop_type, NULL, 0); - if (!stride_ok) - { - complaint (_("unable to read array DW_AT_byte_stride " -@@ -17325,7 +17328,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - struct attribute *attr; - struct dynamic_prop prop; - bool length_is_constant = true; -- LONGEST length; -+ ULONGEST length = UINT_MAX; - - /* There are a couple of places where bit sizes might be made use of - when parsing a DW_TAG_string_type, however, no producer that we know -@@ -17346,6 +17349,10 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - } - } - -+ index_type = objfile_type (objfile)->builtin_int; -+ range_type = create_static_range_type (NULL, index_type, 1, length); -+ -+ /* If DW_AT_string_length is defined, the length is stored in memory. */ - attr = dwarf2_attr (die, DW_AT_string_length, cu); - if (attr != nullptr && !attr_form_is_constant (attr)) - { -@@ -17372,13 +17379,71 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - } - - /* Convert the attribute into a dynamic property. */ -- if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) -+ if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0)) - length = 1; - else - length_is_constant = false; - } - else if (attr != nullptr) - { -+ if (attr_form_is_block (attr)) -+ { -+ struct attribute *byte_size, *bit_size; -+ struct dynamic_prop high; -+ -+ byte_size = dwarf2_attr (die, DW_AT_byte_size, cu); -+ bit_size = dwarf2_attr (die, DW_AT_bit_size, cu); -+ -+ /* DW_AT_byte_size should never occur in combination with -+ DW_AT_bit_size. */ -+ if (byte_size != NULL && bit_size != NULL) -+ complaint (_("DW_AT_byte_size AND " -+ "DW_AT_bit_size found together at the same time.")); -+ -+ /* If DW_AT_string_length AND DW_AT_byte_size exist together, -+ DW_AT_byte_size describes the number of bytes that should be read -+ from the length memory location. */ -+ if (byte_size != NULL) -+ { -+ /* Build new dwarf2_locexpr_baton structure with additions to the -+ data attribute, to reflect DWARF specialities to get address -+ sizes. */ -+ const gdb_byte append_ops[] = -+ { -+ /* DW_OP_deref_size: size of an address on the target machine -+ (bytes), where the size will be specified by the next -+ operand. */ -+ DW_OP_deref_size, -+ /* Operand for DW_OP_deref_size. */ -+ (gdb_byte) DW_UNSND(byte_size) }; -+ -+ if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type, -+ append_ops, ARRAY_SIZE(append_ops))) -+ complaint (_("Could not parse DW_AT_byte_size")); -+ } -+ else if (bit_size != NULL) -+ complaint (_("DW_AT_string_length AND " -+ "DW_AT_bit_size found but not supported yet.")); -+ /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default -+ is the address size of the target machine. */ -+ else -+ { -+ const gdb_byte append_ops[] = -+ { DW_OP_deref }; -+ -+ if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type, -+ append_ops, ARRAY_SIZE(append_ops))) -+ complaint (_("Could not parse DW_AT_string_length")); -+ } -+ -+ TYPE_RANGE_DATA (range_type)->high = high; -+ } -+ else -+ { -+ TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr); -+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST; -+ } -+ - /* This DW_AT_string_length just contains the length with no - indirection. There's no need to create a dynamic property in this - case. Pass 0 for the default value as we know it will not be -@@ -17392,6 +17457,20 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - } - else - { -+ /* Check for the DW_AT_byte_size attribute, which represents the length -+ in this case. */ -+ attr = dwarf2_attr (die, DW_AT_byte_size, cu); -+ if (attr) -+ { -+ TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr); -+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST; -+ } -+ else -+ { -+ TYPE_HIGH_BOUND (range_type) = 1; -+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST; -+ } -+ - /* Use 1 as a fallback length if we have nothing else. */ - length = 1; - } -@@ -17407,6 +17486,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - low_bound.data.const_val = 1; - range_type = create_range_type (NULL, index_type, &low_bound, &prop, 0); - } -+ - char_type = language_string_char_type (cu->language_defn, gdbarch); - type = create_string_type (NULL, char_type, range_type); - -@@ -17858,7 +17938,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) - static int - attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, - struct dwarf2_cu *cu, struct dynamic_prop *prop, -- struct type *default_type) -+ struct type *default_type, -+ const gdb_byte *additional_data, int additional_data_size) - { - struct dwarf2_property_baton *baton; - struct obstack *obstack -@@ -17885,9 +17966,30 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, - baton->locexpr.is_reference = false; - break; - } -+ -+ if (additional_data != NULL && additional_data_size > 0) -+ { -+ gdb_byte *data; -+ -+ data = (gdb_byte *) obstack_alloc( -+ &cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack, -+ DW_BLOCK (attr)->size + additional_data_size); -+ memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size); -+ memcpy (data + DW_BLOCK (attr)->size, additional_data, -+ additional_data_size); -+ -+ baton->locexpr.data = data; -+ baton->locexpr.size = DW_BLOCK (attr)->size + additional_data_size; -+ } -+ else -+ { -+ baton->locexpr.data = DW_BLOCK (attr)->data; -+ baton->locexpr.size = DW_BLOCK (attr)->size; -+ } -+ - prop->data.baton = baton; - prop->kind = PROP_LOCEXPR; -- gdb_assert (prop->data.baton != NULL); -+ gdb_assert(prop->data.baton != NULL); - } - else if (attr_form_is_ref (attr)) - { -@@ -17920,9 +18022,29 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, - baton = XOBNEW (obstack, struct dwarf2_property_baton); - baton->property_type = die_type (target_die, target_cu); - baton->locexpr.per_cu = cu->per_cu; -- baton->locexpr.size = DW_BLOCK (target_attr)->size; -- baton->locexpr.data = DW_BLOCK (target_attr)->data; - baton->locexpr.is_reference = true; -+ -+ if (additional_data != NULL && additional_data_size > 0) -+ { -+ gdb_byte *data; -+ -+ data = (gdb_byte *) obstack_alloc (&cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack, -+ DW_BLOCK (target_attr)->size + additional_data_size); -+ memcpy (data, DW_BLOCK (target_attr)->data, -+ DW_BLOCK (target_attr)->size); -+ memcpy (data + DW_BLOCK (target_attr)->size, -+ additional_data, additional_data_size); -+ -+ baton->locexpr.data = data; -+ baton->locexpr.size = (DW_BLOCK (target_attr)->size -+ + additional_data_size); -+ } -+ else -+ { -+ baton->locexpr.data = DW_BLOCK (target_attr)->data; -+ baton->locexpr.size = DW_BLOCK (target_attr)->size; -+ } -+ - prop->data.baton = baton; - prop->kind = PROP_LOCEXPR; - gdb_assert (prop->data.baton != NULL); -@@ -18099,8 +18221,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - } - - attr = dwarf2_attr (die, DW_AT_lower_bound, cu); -- if (attr != nullptr) -- attr_to_dynamic_prop (attr, die, cu, &low, base_type); -+ if (attr) -+ attr_to_dynamic_prop (attr, die, cu, &low, base_type, NULL, 0); - else if (!low_default_is_valid) - complaint (_("Missing DW_AT_lower_bound " - "- DIE at %s [in module %s]"), -@@ -18109,10 +18231,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - - struct attribute *attr_ub, *attr_count; - attr = attr_ub = dwarf2_attr (die, DW_AT_upper_bound, cu); -- if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type)) -+ if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0)) - { - attr = attr_count = dwarf2_attr (die, DW_AT_count, cu); -- if (attr_to_dynamic_prop (attr, die, cu, &high, base_type)) -+ if (attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0)) - { - /* If bounds are constant do the final calculation here. */ - if (low.kind == PROP_CONST && high.kind == PROP_CONST) -@@ -18164,7 +18286,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - struct type *prop_type - = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); - attr_to_dynamic_prop (attr_byte_stride, die, cu, &byte_stride_prop, -- prop_type); -+ prop_type, NULL, 0); - } - - struct dynamic_prop bit_stride_prop; -@@ -18185,7 +18307,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - struct type *prop_type - = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); - attr_to_dynamic_prop (attr_bit_stride, die, cu, &bit_stride_prop, -- prop_type); -+ prop_type, NULL, 0); - } - } - -@@ -25879,7 +26001,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - { - struct type *prop_type - = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); -- if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) -+ if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0)) - add_dyn_prop (DYN_PROP_ALLOCATED, prop, type); - } - else if (attr != NULL) -@@ -25895,7 +26017,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - { - struct type *prop_type - = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); -- if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) -+ if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0)) - add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type); - } - else if (attr != NULL) -@@ -25908,7 +26030,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - /* Read DW_AT_data_location and set in type. */ - attr = dwarf2_attr (die, DW_AT_data_location, cu); - if (attr_to_dynamic_prop (attr, die, cu, &prop, -- dwarf2_per_cu_addr_type (cu->per_cu))) -+ dwarf2_per_cu_addr_type (cu->per_cu), NULL, 0)) - add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type); - - if (dwarf2_per_objfile->die_type_hash == NULL) -diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c ---- a/gdb/f-typeprint.c -+++ b/gdb/f-typeprint.c -@@ -197,15 +197,14 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, - print_rank_only = true; - else if ((TYPE_ASSOCIATED_PROP (type) - && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ASSOCIATED_PROP (type))) -- || (TYPE_ALLOCATED_PROP (type) -- && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type))) -- || (TYPE_DATA_LOCATION (type) -- && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type)))) -- { -- /* This case exist when we ptype a typename which has the dynamic -- properties but cannot be resolved as there is no object. */ -- print_rank_only = true; -- } -+ || (TYPE_ALLOCATED_PROP (type) -+ && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type))) -+ || (TYPE_DATA_LOCATION (type) -+ && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type)))) -+ /* This case exist when we ptype a typename which has the -+ dynamic properties but cannot be resolved as there is -+ no object. */ -+ print_rank_only = true; - - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY) - f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, -@@ -217,8 +216,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, - else - { - LONGEST lower_bound = f77_get_lowerbound (type); -+ - if (lower_bound != 1) /* Not the default. */ -- fprintf_filtered (stream, "%s:", plongest (lower_bound)); -+ fprintf_filtered (stream, "%s:", plongest (lower_bound)); - - /* Make sure that, if we have an assumed size array, we - print out a warning and print the upperbound as '*'. */ -@@ -229,7 +229,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, - { - LONGEST upper_bound = f77_get_upperbound (type); - -- fputs_filtered (plongest (upper_bound), stream); -+ fprintf_filtered (stream, "%s", plongest (upper_bound)); - } - } - -@@ -249,7 +249,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, - case TYPE_CODE_REF: - f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0, - arrayprint_recurse_level, false); -- fprintf_filtered (stream, " )"); -+ fprintf_filtered (stream, ")"); - break; - - case TYPE_CODE_FUNC: -diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c ---- a/gdb/gdbtypes.c -+++ b/gdb/gdbtypes.c -@@ -1939,7 +1939,8 @@ is_dynamic_type_internal (struct type *type, int top_level) - type = check_typedef (type); - - /* We only want to recognize references at the outermost level. */ -- if (top_level && TYPE_CODE (type) == TYPE_CODE_REF) -+ if (top_level && -+ (TYPE_CODE (type) == TYPE_CODE_REF || TYPE_CODE (type) == TYPE_CODE_PTR)) - type = check_typedef (TYPE_TARGET_TYPE (type)); - - /* Types that have a dynamic TYPE_DATA_LOCATION are considered -@@ -1972,10 +1973,10 @@ is_dynamic_type_internal (struct type *type, int top_level) - || is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0)); - } - -- case TYPE_CODE_STRING: - /* Strings are very much like an array of characters, and can be - treated as one here. */ - case TYPE_CODE_ARRAY: -+ case TYPE_CODE_STRING: - { - gdb_assert (TYPE_NFIELDS (type) == 1); - -@@ -2139,11 +2140,15 @@ resolve_dynamic_array_or_string (struct type *type, - - ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type)); - -- if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY) -+ if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY -+ || TYPE_CODE (ary_dim) == TYPE_CODE_STRING)) - elt_type = resolve_dynamic_array_or_string (ary_dim, addr_stack); - else - elt_type = TYPE_TARGET_TYPE (type); - -+ if (TYPE_CODE (type) == TYPE_CODE_STRING) -+ return create_string_type (type, elt_type, range_type); -+ - prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type); - if (prop != NULL) - { -@@ -2295,6 +2300,28 @@ resolve_dynamic_struct (struct type *type, - return resolved_type; - } - -+/* Worker for pointer types. */ -+ -+static struct type * -+resolve_dynamic_pointer (struct type *type, -+ struct property_addr_info *addr_stack) -+{ -+ struct dynamic_prop *prop; -+ CORE_ADDR value; -+ -+ type = copy_type (type); -+ -+ /* Resolve associated property. */ -+ prop = TYPE_ASSOCIATED_PROP (type); -+ if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value)) -+ { -+ TYPE_DYN_PROP_ADDR (prop) = value; -+ TYPE_DYN_PROP_KIND (prop) = PROP_CONST; -+ } -+ -+ return type; -+} -+ - /* Worker for resolved_dynamic_type. */ - - static struct type * -@@ -2349,6 +2376,9 @@ resolve_dynamic_type_internal (struct type *type, - case TYPE_CODE_ARRAY: - resolved_type = resolve_dynamic_array_or_string (type, addr_stack); - break; -+ case TYPE_CODE_PTR: -+ resolved_type = resolve_dynamic_pointer (type, addr_stack); -+ break; - - case TYPE_CODE_RANGE: - resolved_type = resolve_dynamic_range (type, addr_stack); -diff --git a/gdb/testsuite/gdb.cp/vla-cxx.cc b/gdb/testsuite/gdb.cp/vla-cxx.cc ---- a/gdb/testsuite/gdb.cp/vla-cxx.cc -+++ b/gdb/testsuite/gdb.cp/vla-cxx.cc -@@ -15,6 +15,10 @@ - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -+extern "C" { -+#include -+} -+ - struct container; - - struct element -@@ -40,11 +44,16 @@ int main(int argc, char **argv) - typedef typeof (vla) &vlareftypedef; - vlareftypedef vlaref2 (vla); - container c; -+ typeof (vla) *ptr = NULL; -+ -+ // Before pointer assignment -+ ptr = &vla; - - for (int i = 0; i < z; ++i) - vla[i] = 5 + 2 * i; - - // vlas_filled - vla[0] = 2 * vla[0]; -+ - return vla[2]; - } -diff --git a/gdb/testsuite/gdb.cp/vla-cxx.exp b/gdb/testsuite/gdb.cp/vla-cxx.exp ---- a/gdb/testsuite/gdb.cp/vla-cxx.exp -+++ b/gdb/testsuite/gdb.cp/vla-cxx.exp -@@ -23,6 +23,12 @@ if ![runto_main] { - return -1 - } - -+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"] -+gdb_continue_to_breakpoint "Before pointer assignment" -+gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment" -+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" "print ptr, Before pointer assignment" -+gdb_test "print *ptr" "Cannot access memory at address 0x0" "print *ptr, Before pointer assignment" -+ - gdb_breakpoint [gdb_get_line_number "vlas_filled"] - gdb_continue_to_breakpoint "vlas_filled" - -@@ -33,3 +39,6 @@ gdb_test "print vlaref" " = \\(int \\(&\\)\\\[3\\\]\\) @$hex: \\{5, 7, 9\\}" - # bug being tested, it's better not to depend on the exact spelling. - gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}" - gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}" -+gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]" -+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex" -+gdb_test "print *ptr" " = \\{5, 7, 9\\}" -diff --git a/gdb/testsuite/gdb.fortran/pointers.exp b/gdb/testsuite/gdb.fortran/pointers.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/pointers.exp -@@ -0,0 +1,143 @@ -+# Copyright 2016 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 . -+ -+standard_testfile "pointers.f90" -+load_lib fortran.exp -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ -+ {debug f90 quiet}] } { -+ return -1 -+} -+ -+if ![runto_main] { -+ untested "could not run to main" -+ return -1 -+} -+ -+# Depending on the compiler being used, the type names can be printed differently. -+set logical [fortran_logical4] -+set real [fortran_real4] -+set int [fortran_int4] -+set complex [fortran_complex4] -+ -+ -+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"] -+gdb_continue_to_breakpoint "Before pointer assignment" -+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) 0x0" "print logp, not associated" -+gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated" -+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) 0x0" "print comp, not associated" -+gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated" -+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) 0x0" "print charp, not associated" -+gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated" -+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) 0x0" "print charap, not associated" -+gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated" -+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0" "print intp, not associated" -+gdb_test "print *intp" "Cannot access memory at address 0x0" "print *intp, not associated" -+set test "print intap, not associated" -+gdb_test_multiple "print intap" $test { -+ -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) \r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re " = \r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) 0x0" "print realp, not associated" -+gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated" -+gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0" -+set test "print cyclicp1, not associated" -+gdb_test_multiple "print cyclicp1" $test { -+ -re "= \\( i = -?\\d+, p = 0x0 \\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "= \\( i = -?\\d+, p = \\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+set test "print cyclicp1%p, not associated" -+gdb_test_multiple "print cyclicp1%p" $test { -+ -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) 0x0\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) \r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+ -+ -+gdb_breakpoint [gdb_get_line_number "Before value assignment"] -+gdb_continue_to_breakpoint "Before value assignment" -+gdb_test "print *(twop)%ivla2" "= " -+ -+ -+gdb_breakpoint [gdb_get_line_number "After value assignment"] -+gdb_continue_to_breakpoint "After value assignment" -+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) $hex\( <.*>\)?" -+gdb_test "print *logp" "= \\.TRUE\\." -+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) $hex\( <.*>\)?" -+gdb_test "print *comp" "= \\(1,2\\)" -+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) $hex\( <.*>\)?" -+gdb_test "print *charp" "= 'a'" -+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\( <.*>\)?" -+gdb_test "print *charap" "= 'abc'" -+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) $hex\( <.*>\)?" -+gdb_test "print *intp" "= 10" -+set test_name "print intap, associated" -+gdb_test_multiple "print intap" $test_name { -+ -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+ -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" { -+ gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)" -+ pass $test_name -+ } -+} -+set test_name "print intvlap, associated" -+gdb_test_multiple "print intvlap" $test_name { -+ -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+ -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" { -+ gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)" -+ pass $test_name -+ } -+} -+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) $hex\( <.*>\)?" -+gdb_test "print *realp" "= 3\\.14000\\d+" -+gdb_test "print arrayOfPtr(2)%p" "= \\(PTR TO -> \\( Type two\\)\\) $hex\( <.*>\)?" -+gdb_test "print *(arrayOfPtr(2)%p)" "= \\( ivla1 = \\(11, 12, 13\\), ivla2 = \\(\\( 211, 221\\) \\( 212, 222\\) \\) \\)" -+set test_name "print arrayOfPtr(3)%p" -+gdb_test_multiple $test_name $test_name { -+ -re "= \\(PTR TO -> \\( Type two\\)\\) \r\n$gdb_prompt $" { -+ pass $test_name -+ } -+ -re "= \\(PTR TO -> \\( Type two\\)\\) 0x0\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+} -+set test_name "print *(arrayOfPtr(3)%p), associated" -+gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name { -+ -re "Cannot access memory at address 0x0\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+ -re "Attempt to take contents of a not associated pointer.\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+} -+gdb_test "print cyclicp1" "= \\( i = 1, p = $hex\( <.*>\)? \\)" -+gdb_test "print cyclicp1%p" "= \\(PTR TO -> \\( Type typewithpointer\\)\\) $hex\( <.*>\)?" -+gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array" -+gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla" -+gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\) \\(\\)\\)\\) $hex " "Print program counter" -diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90 ---- a/gdb/testsuite/gdb.fortran/pointers.f90 -+++ b/gdb/testsuite/gdb.fortran/pointers.f90 -@@ -20,21 +20,34 @@ program pointers - integer, allocatable :: ivla2 (:, :) - end type two - -+ type :: typeWithPointer -+ integer i -+ type(typeWithPointer), pointer:: p -+ end type typeWithPointer -+ -+ type :: twoPtr -+ type (two), pointer :: p -+ end type twoPtr -+ - logical, target :: logv - complex, target :: comv - character, target :: charv - character (len=3), target :: chara - integer, target :: intv - integer, target, dimension (10,2) :: inta -- real, target :: realv -- type(two), target :: twov -+ integer, target, allocatable, dimension (:) :: intvla -+ real, target :: realv -+ type(two), target :: twov -+ type(twoPtr) :: arrayOfPtr (3) -+ type(typeWithPointer), target:: cyclicp1,cyclicp2 - - logical, pointer :: logp - complex, pointer :: comp -- character, pointer :: charp -- character (len=3), pointer :: charap -+ character, pointer:: charp -+ character (len=3), pointer:: charap - integer, pointer :: intp - integer, pointer, dimension (:,:) :: intap -+ integer, pointer, dimension (:) :: intvlap - real, pointer :: realp - type(two), pointer :: twop - -@@ -44,8 +57,14 @@ program pointers - nullify (charap) - nullify (intp) - nullify (intap) -+ nullify (intvlap) - nullify (realp) - nullify (twop) -+ nullify (arrayOfPtr(1)%p) -+ nullify (arrayOfPtr(2)%p) -+ nullify (arrayOfPtr(3)%p) -+ nullify (cyclicp1%p) -+ nullify (cyclicp2%p) - - logp => logv ! Before pointer assignment - comp => comv -@@ -53,8 +72,14 @@ program pointers - charap => chara - intp => intv - intap => inta -+ intvlap => intvla - realp => realv - twop => twov -+ arrayOfPtr(2)%p => twov -+ cyclicp1%i = 1 -+ cyclicp1%p => cyclicp2 -+ cyclicp2%i = 2 -+ cyclicp2%p => cyclicp1 - - logv = associated(logp) ! Before value assignment - comv = cmplx(1,2) -@@ -63,6 +88,10 @@ program pointers - intv = 10 - inta(:,:) = 1 - inta(3,1) = 3 -+ allocate (intvla(10)) -+ intvla(:) = 2 -+ intvla(4) = 4 -+ intvlap => intvla - realv = 3.14 - - allocate (twov%ivla1(3)) -diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp ---- a/gdb/testsuite/gdb.fortran/print_type.exp -+++ b/gdb/testsuite/gdb.fortran/print_type.exp -@@ -1,5 +1,6 @@ - # Copyright 2019-2020 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 -@@ -40,7 +41,7 @@ set complex [fortran_complex4] - # matches the string TYPE. - proc check_pointer_type { var_name type } { - gdb_test "ptype ${var_name}" \ -- "type = PTR TO -> \\( ${type} \\)" -+ "type = PTR TO -> \\( ${type}\\)" - } - - gdb_breakpoint [gdb_get_line_number "Before pointer assignment"] -@@ -85,7 +86,8 @@ gdb_test "ptype twop" \ - [multi_line "type = PTR TO -> \\( Type two" \ - " $int, allocatable :: ivla1\\(:\\)" \ - " $int, allocatable :: ivla2\\(:,:\\)" \ -- "End Type two \\)"] -+ "End Type two\\)"] -+ - - gdb_breakpoint [gdb_get_line_number "After value assignment"] - gdb_continue_to_breakpoint "After value assignment" -@@ -97,11 +99,11 @@ gdb_test "ptype intv" "type = $int" - gdb_test "ptype inta" "type = $int \\(10,2\\)" - gdb_test "ptype realv" "type = $real" - --gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)" --gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)" --gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)" --gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)" --gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)" -+gdb_test "ptype logp" "type = PTR TO -> \\( $logical\\)" -+gdb_test "ptype comp" "type = PTR TO -> \\( $complex\\)" -+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1\\)" -+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3\\)" -+gdb_test "ptype intp" "type = PTR TO -> \\( $int\\)" - set test "ptype intap" - gdb_test_multiple $test $test { - -re "type = $int \\(10,2\\)\r\n$gdb_prompt $" { -@@ -111,4 +113,4 @@ gdb_test_multiple $test $test { - pass $test - } - } --gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)" -+gdb_test "ptype realp" "type = PTR TO -> \\( $real\\)" -diff --git a/gdb/testsuite/gdb.fortran/vla-strings.exp b/gdb/testsuite/gdb.fortran/vla-strings.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-strings.exp -@@ -0,0 +1,103 @@ -+# Copyright 2016 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 . -+ -+standard_testfile ".f90" -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ -+ {debug f90 quiet}] } { -+ return -1 -+} -+ -+# check that all fortran standard datatypes will be -+# handled correctly when using as VLA's -+ -+if ![runto_main] { -+ untested "could not run to main" -+ return -1 -+} -+ -+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"] -+gdb_continue_to_breakpoint "var_char-allocated-1" -+set test "whatis var_char first time" -+gdb_test_multiple "whatis var_char" $test { -+ -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "type = character\\*10\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+set test "ptype var_char first time" -+gdb_test_multiple "ptype var_char" $test { -+ -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "type = character\\*10\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+ -+ -+gdb_test "next" "\\d+.*var_char = 'foo'.*" \ -+ "next to allocation status of var_char" -+gdb_test "print l" " = \\.TRUE\\." "print allocation status first time" -+ -+ -+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"] -+gdb_continue_to_breakpoint "var_char-filled-1" -+set test "print var_char, var_char-filled-1" -+gdb_test_multiple "print var_char" $test { -+ -re "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\r\n$gdb_prompt $" { -+ gdb_test "print *var_char" "= 'foo'" "print *var_char, var_char-filled-1" -+ pass $test -+ } -+ -re "= 'foo'\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+set test "ptype var_char, var_char-filled-1" -+gdb_test_multiple "ptype var_char" $test { -+ -re "type = PTR TO -> \\( character\\*3\\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "type = character\\*3\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)" -+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)" -+ -+ -+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"] -+gdb_continue_to_breakpoint "var_char-filled-2" -+set test "print var_char, var_char-filled-2" -+gdb_test_multiple "print var_char" $test { -+ -re "= \\(PTR TO -> \\( character\\*6\\)\\) $hex\r\n$gdb_prompt $" { -+ gdb_test "print *var_char" "= 'foobar'" "print *var_char, var_char-filled-2" -+ pass $test -+ } -+ -re "= 'foobar'\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+set test "ptype var_char, var_char-filled-2" -+gdb_test_multiple "ptype var_char" $test { -+ -re "type = PTR TO -> \\( character\\*6\\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "type = character\\*6\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -diff --git a/gdb/testsuite/gdb.fortran/vla-strings.f90 b/gdb/testsuite/gdb.fortran/vla-strings.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-strings.f90 -@@ -0,0 +1,39 @@ -+! Copyright 2016 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 . -+ -+program vla_strings -+ character(len=:), target, allocatable :: var_char -+ character(len=:), pointer :: var_char_p -+ logical :: l -+ -+ allocate(character(len=10) :: var_char) -+ l = allocated(var_char) ! var_char-allocated-1 -+ var_char = 'foo' -+ deallocate(var_char) ! var_char-filled-1 -+ l = allocated(var_char) ! var_char-deallocated -+ allocate(character(len=42) :: var_char) -+ l = allocated(var_char) -+ var_char = 'foobar' -+ var_char = '' ! var_char-filled-2 -+ var_char = 'bar' ! var_char-empty -+ deallocate(var_char) -+ allocate(character(len=21) :: var_char) -+ l = allocated(var_char) ! var_char-allocated-3 -+ var_char = 'johndoe' -+ var_char_p => var_char -+ l = associated(var_char_p) ! var_char_p-associated -+ var_char_p => null() -+ l = associated(var_char_p) ! var_char_p-not-associated -+end program vla_strings -diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp ---- a/gdb/testsuite/gdb.fortran/vla-value.exp -+++ b/gdb/testsuite/gdb.fortran/vla-value.exp -@@ -35,7 +35,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"] - gdb_continue_to_breakpoint "vla1-init" - gdb_test "print vla1" " = " "print non-allocated vla1" - gdb_test "print &vla1" \ -- " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\) \\\)\\\) $hex" \ -+ " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\)\\\)\\\) $hex" \ - "print non-allocated &vla1" - gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \ - "print member in non-allocated vla1 (1)" -@@ -56,7 +56,7 @@ with_timeout_factor 15 { - "step over value assignment of vla1" - } - gdb_test "print &vla1" \ -- " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\) \\\)\\\) $hex" \ -+ " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\)\\\)\\\) $hex" \ - "print allocated &vla1" - gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)" - gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)" -@@ -76,7 +76,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \ - # Try to access values in undefined pointer to VLA (dangling) - gdb_test "print pvla" " = " "print undefined pvla" - gdb_test "print &pvla" \ -- " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\) \\\)\\\) $hex" \ -+ " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \ - "print non-associated &pvla" - gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \ - "print undefined pvla(1,3,8)" -@@ -85,7 +85,7 @@ gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated - gdb_breakpoint [gdb_get_line_number "pvla-associated"] - gdb_continue_to_breakpoint "pvla-associated" - gdb_test "print &pvla" \ -- " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\) \\\)\\\) $hex" \ -+ " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \ - "print associated &pvla" - gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)" - gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)" -diff --git a/gdb/typeprint.c b/gdb/typeprint.c ---- a/gdb/typeprint.c -+++ b/gdb/typeprint.c -@@ -574,6 +574,25 @@ whatis_exp (const char *exp, int show) - printf_filtered (" */\n"); - } - -+ /* Resolve any dynamic target type, as we might print -+ additional information about the target. -+ For example, in Fortran and C we are printing the dimension of the -+ dynamic array the pointer is pointing to. */ -+ if (TYPE_CODE (type) == TYPE_CODE_PTR -+ && is_dynamic_type (type) == 1) -+ { -+ CORE_ADDR addr; -+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type))) -+ addr = value_address (val); -+ else -+ addr = value_as_address (val); -+ -+ if (addr != 0 -+ && type_not_associated (type) == 0) -+ TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type), -+ NULL, addr); -+ } -+ - LA_PRINT_TYPE (type, "", gdb_stdout, show, 0, &flags); - printf_filtered ("\n"); - } -diff --git a/gdb/valops.c b/gdb/valops.c ---- a/gdb/valops.c -+++ b/gdb/valops.c -@@ -1553,6 +1553,19 @@ value_ind (struct value *arg1) - if (TYPE_CODE (base_type) == TYPE_CODE_PTR) - { - struct type *enc_type; -+ CORE_ADDR addr; -+ -+ if (type_not_associated (base_type)) -+ error (_("Attempt to take contents of a not associated pointer.")); -+ -+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type))) -+ addr = value_address (arg1); -+ else -+ addr = value_as_address (arg1); -+ -+ if (addr != 0) -+ TYPE_TARGET_TYPE (base_type) = -+ resolve_dynamic_type (TYPE_TARGET_TYPE (base_type), NULL, addr); - - /* We may be pointing to something embedded in a larger object. - Get the real type of the enclosing object. */ -@@ -1568,8 +1581,7 @@ value_ind (struct value *arg1) - else - /* Retrieve the enclosing object pointed to. */ - arg2 = value_at_lazy (enc_type, -- (value_as_address (arg1) -- - value_pointed_to_offset (arg1))); -+ (addr - value_pointed_to_offset (arg1))); - - enc_type = value_type (arg2); - return readjust_indirect_value_type (arg2, enc_type, base_type, arg1); -diff --git a/gdb/valprint.c b/gdb/valprint.c ---- a/gdb/valprint.c -+++ b/gdb/valprint.c -@@ -1149,12 +1149,6 @@ value_check_printable (struct value *val, struct ui_file *stream, - return 0; - } - -- if (type_not_associated (value_type (val))) -- { -- val_print_not_associated (stream); -- return 0; -- } -- - if (type_not_allocated (value_type (val))) - { - val_print_not_allocated (stream); diff --git a/gdb-vla-intel-stringbt-fix.patch b/gdb-vla-intel-stringbt-fix.patch deleted file mode 100644 index 1e2eeba6d071ce7b56f0c27aa60f21b255a1ffd6..0000000000000000000000000000000000000000 --- a/gdb-vla-intel-stringbt-fix.patch +++ /dev/null @@ -1,138 +0,0 @@ -diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c ---- a/gdb/dwarf2loc.c -+++ b/gdb/dwarf2loc.c -@@ -2154,6 +2154,20 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, - ctx.per_cu = per_cu; - ctx.obj_address = 0; - -+frame_id old_frame_id (get_frame_id (deprecated_safe_get_selected_frame ())); -+class RestoreCall { -+private: -+ const std::function func; -+public: -+ RestoreCall(std::function func_):func(func_) {} -+ ~RestoreCall() { func(); } -+} restore_frame([=]() { -+ frame_info *old_frame (frame_find_by_id (old_frame_id)); -+ if (old_frame != NULL) -+ select_frame (old_frame); -+}); -+if (frame != NULL) select_frame (frame); -+ - scoped_value_mark free_values; - - ctx.gdbarch = get_objfile_arch (objfile); -diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 -@@ -0,0 +1,24 @@ -+! Copyright 2010 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 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . -+ -+subroutine bar -+ real :: dummy -+ dummy = 1 -+end subroutine bar -diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp -@@ -0,0 +1,39 @@ -+# Copyright 2010 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 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. -+ -+set testfile "dynamic-other-frame" -+set srcfile1 ${testfile}.f90 -+set srcfile2 ${testfile}-stub.f90 -+set objfile2 [standard_output_file ${testfile}-stub.o] -+set executable ${testfile} -+set binfile [standard_output_file ${executable}] -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f90}] != "" -+ || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f90}] != "" } { -+ untested "Couldn't compile ${srcfile1} or ${srcfile2}" -+ return -1 -+} -+ -+clean_restart ${executable} -+ -+gdb_test_no_output "set print frame-arguments all" -+ -+if ![runto bar_] then { -+ perror "couldn't run to bar_" -+ continue -+} -+ -+gdb_test "bt" {foo \(string='hello'.*} -diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 -@@ -0,0 +1,36 @@ -+! Copyright 2010 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 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . -+ -+subroutine foo (string) -+ interface -+ subroutine bar -+ end subroutine -+ end interface -+ character string*(*) -+ call bar ! stop-here -+end subroutine foo -+program test -+ interface -+ subroutine foo (string) -+ character string*(*) -+ end subroutine -+ end interface -+ call foo ('hello') -+end diff --git a/gdb-vla-intel-tests.patch b/gdb-vla-intel-tests.patch deleted file mode 100644 index b2ab402f5a98842e8a695f204a0d55501a1019f3..0000000000000000000000000000000000000000 --- a/gdb-vla-intel-tests.patch +++ /dev/null @@ -1,340 +0,0 @@ -diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp ---- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp -+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp -@@ -37,5 +37,5 @@ gdb_continue_to_breakpoint "BP1" - gdb_test "ptype tinsta" \ - [multi_line "type = Type tuserdef" \ - " $int :: i" \ -- " PTR TO -> \\( $real :: ptr \\)" \ -+ " PTR TO -> \\( $real :: ptr\\)" \ - "End Type tuserdef"] -diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp ---- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp -+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp -@@ -42,4 +42,4 @@ gdb_test "ptype say_numbers" \ - "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)" - - gdb_test "ptype fun_ptr" \ -- "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)" -+ "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\)\\)\\)\\)" -diff --git a/gdb/testsuite/gdb.fortran/vla-func.exp b/gdb/testsuite/gdb.fortran/vla-func.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-func.exp -@@ -0,0 +1,61 @@ -+# Copyright 2014 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 . -+ -+standard_testfile ".f90" -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ -+ {debug f90 quiet}] } { -+ return -1 -+} -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+# Check VLA passed to first Fortran function. -+gdb_breakpoint [gdb_get_line_number "func1-vla-passed"] -+gdb_continue_to_breakpoint "func1-vla-passed" -+gdb_test "print vla" " = \\( *\\( *22, *22, *22,\[()22, .\]*\\)" \ -+ "print vla (func1)" -+gdb_test "ptype vla" "type = integer\\\(kind=4\\\), allocatable \\\(10,10\\\)" \ -+ "ptype vla (func1)" -+ -+gdb_breakpoint [gdb_get_line_number "func1-vla-modified"] -+gdb_continue_to_breakpoint "func1-vla-modified" -+gdb_test "print vla(5,5)" " = 55" "print vla(5,5) (func1)" -+gdb_test "print vla(7,7)" " = 77" "print vla(5,5) (func1)" -+ -+# Check if the values are correct after returning from func1 -+gdb_breakpoint [gdb_get_line_number "func1-returned"] -+gdb_continue_to_breakpoint "func1-returned" -+gdb_test "print ret" " = .TRUE." "print ret after func1 returned" -+ -+# Check VLA passed to second Fortran function -+gdb_breakpoint [gdb_get_line_number "func2-vla-passed"] -+gdb_continue_to_breakpoint "func2-vla-passed" -+gdb_test "print vla" \ -+ " = \\\(44, 44, 44, 44, 44, 44, 44, 44, 44, 44\\\)" \ -+ "print vla (func2)" -+gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10\\\)" \ -+ "ptype vla (func2)" -+ -+# Check if the returned VLA has the correct values and ptype. -+gdb_breakpoint [gdb_get_line_number "func2-returned"] -+gdb_continue_to_breakpoint "func2-returned" -+gdb_test "print vla3" " = \\\(1, 2, 44, 4, 44, 44, 44, 8, 44, 44\\\)" \ -+ "print vla3 (after func2)" -+gdb_test "ptype vla3" "type = integer\\\(kind=4\\\), allocatable \\\(10\\\)" \ -+ "ptype vla3 (after func2)" -diff --git a/gdb/testsuite/gdb.fortran/vla-func.f90 b/gdb/testsuite/gdb.fortran/vla-func.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-func.f90 -@@ -0,0 +1,71 @@ -+! Copyright 2014 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 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. -+ -+logical function func1 (vla) -+ implicit none -+ integer, allocatable :: vla (:, :) -+ func1 = allocated(vla) -+ vla(5,5) = 55 ! func1-vla-passed -+ vla(7,7) = 77 -+ return ! func1-vla-modified -+end function func1 -+ -+function func2(vla) -+ implicit none -+ integer :: vla (:) -+ integer :: func2(size(vla)) -+ integer :: k -+ -+ vla(1) = 1 ! func2-vla-passed -+ vla(2) = 2 -+ vla(4) = 4 -+ vla(8) = 8 -+ -+ func2 = vla -+end function func2 -+ -+program vla_func -+ implicit none -+ interface -+ logical function func1 (vla) -+ integer, allocatable :: vla (:, :) -+ end function -+ end interface -+ interface -+ function func2 (vla) -+ integer :: vla (:) -+ integer func2(size(vla)) -+ end function -+ end interface -+ -+ logical :: ret -+ integer, allocatable :: vla1 (:, :) -+ integer, allocatable :: vla2 (:) -+ integer, allocatable :: vla3 (:) -+ -+ ret = .FALSE. -+ -+ allocate (vla1 (10,10)) -+ vla1(:,:) = 22 -+ -+ allocate (vla2 (10)) -+ vla2(:) = 44 -+ -+ ret = func1(vla1) -+ vla3 = func2(vla2) ! func1-returned -+ -+ ret = .TRUE. ! func2-returned -+end program vla_func -diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp ---- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp -+++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp -@@ -28,5 +28,5 @@ if ![runto_main] { - # Check the status of a pointer to a dynamic array. - gdb_breakpoint [gdb_get_line_number "pvla-associated"] - gdb_continue_to_breakpoint "pvla-associated" --gdb_test "print &pvla" " = \\(PTR TO -> \\( real\\(kind=4\\) \\(10,10,10\\) \\)\\) ${hex}" \ -+gdb_test "print &pvla" " = \\(PTR TO -> \\( real\\(kind=4\\) \\(10,10,10\\)\\)\\) ${hex}" \ - "print pvla pointer information" -diff --git a/gdb/testsuite/gdb.fortran/vla-stringsold.exp b/gdb/testsuite/gdb.fortran/vla-stringsold.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-stringsold.exp -@@ -0,0 +1,101 @@ -+# Copyright 2014 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 . -+ -+standard_testfile ".f90" -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ -+ {debug f90 quiet}] } { -+ return -1 -+} -+ -+# check that all fortran standard datatypes will be -+# handled correctly when using as VLA's -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"] -+gdb_continue_to_breakpoint "var_char-allocated-1" -+gdb_test "print var_char" \ -+ " = \\(PTR TO -> \\( character\\*10\\)\\) ${hex}" \ -+ "print var_char after allocated first time" -+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*10\\)" \ -+ "whatis var_char first time" -+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*10\\)" \ -+ "ptype var_char first time" -+gdb_test "next" "\\d+.*var_char = 'foo'.*" \ -+ "next to allocation status of var_char" -+gdb_test "print l" " = .TRUE." "print allocation status first time" -+ -+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"] -+gdb_continue_to_breakpoint "var_char-filled-1" -+gdb_test "print var_char" \ -+ " = \\(PTR TO -> \\( character\\*3\\)\\) ${hex}" \ -+ "print var_char after filled first time" -+gdb_test "print *var_char" " = 'foo'" \ -+ "print *var_char after filled first time" -+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*3\\)" \ -+ "whatis var_char after filled first time" -+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*3\\)" \ -+ "ptype var_char after filled first time" -+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)" -+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)" -+ -+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"] -+gdb_continue_to_breakpoint "var_char-filled-2" -+gdb_test "print var_char" \ -+ " = \\(PTR TO -> \\( character\\*6\\)\\) ${hex}" \ -+ "print var_char after allocated second time" -+gdb_test "print *var_char" " = 'foobar'" \ -+ "print *var_char after allocated second time" -+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*6\\)" \ -+ "whatis var_char second time" -+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*6\\)" \ -+ "ptype var_char second time" -+ -+gdb_breakpoint [gdb_get_line_number "var_char-empty"] -+gdb_continue_to_breakpoint "var_char-empty" -+gdb_test "print var_char" \ -+ " = \\(PTR TO -> \\( character\\*0\\)\\) ${hex}" \ -+ "print var_char after set empty" -+gdb_test "print *var_char" " = \"\"" "print *var_char after set empty" -+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*0\\)" \ -+ "whatis var_char after set empty" -+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*0\\)" \ -+ "ptype var_char after set empty" -+ -+gdb_breakpoint [gdb_get_line_number "var_char-allocated-3"] -+gdb_continue_to_breakpoint "var_char-allocated-3" -+gdb_test "print var_char" \ -+ " = \\(PTR TO -> \\( character\\*21\\)\\) ${hex}" \ -+ "print var_char after allocated third time" -+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*21\\)" \ -+ "whatis var_char after allocated third time" -+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*21\\)" \ -+ "ptype var_char after allocated third time" -+ -+gdb_breakpoint [gdb_get_line_number "var_char_p-associated"] -+gdb_continue_to_breakpoint "var_char_p-associated" -+gdb_test "print var_char_p" \ -+ " = \\(PTR TO -> \\( character\\*7\\)\\) ${hex}" \ -+ "print var_char_p after associated" -+gdb_test "print *var_char_p" " = 'johndoe'" \ -+ "print *var_char_ after associated" -+gdb_test "whatis var_char_p" "type = PTR TO -> \\( character\\*7\\)" \ -+ "whatis var_char_p after associated" -+gdb_test "ptype var_char_p" "type = PTR TO -> \\( character\\*7\\)" \ -+ "ptype var_char_p after associated" -diff --git a/gdb/testsuite/gdb.fortran/vla-stringsold.f90 b/gdb/testsuite/gdb.fortran/vla-stringsold.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-stringsold.f90 -@@ -0,0 +1,40 @@ -+! Copyright 2014 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 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. -+ -+program vla_strings -+ character(len=:), target, allocatable :: var_char -+ character(len=:), pointer :: var_char_p -+ logical :: l -+ -+ allocate(character(len=10) :: var_char) -+ l = allocated(var_char) ! var_char-allocated-1 -+ var_char = 'foo' -+ deallocate(var_char) ! var_char-filled-1 -+ l = allocated(var_char) ! var_char-deallocated -+ allocate(character(len=42) :: var_char) -+ l = allocated(var_char) -+ var_char = 'foobar' -+ var_char = '' ! var_char-filled-2 -+ var_char = 'bar' ! var_char-empty -+ deallocate(var_char) -+ allocate(character(len=21) :: var_char) -+ l = allocated(var_char) ! var_char-allocated-3 -+ var_char = 'johndoe' -+ var_char_p => var_char -+ l = associated(var_char_p) ! var_char_p-associated -+ var_char_p => null() -+ l = associated(var_char_p) ! var_char_p-not-associated -+end program vla_strings -diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp ---- a/gdb/testsuite/gdb.fortran/whatis_type.exp -+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp -@@ -44,7 +44,7 @@ gdb_test "whatis t2" "type = Type t2" - gdb_test "whatis t2v" "type = Type t2" - gdb_test "whatis t3" "type = Type t3" - gdb_test "whatis t3v" "type = Type t3" --gdb_test "whatis t3p" "type = PTR TO -> \\( Type t3 \\)" -+gdb_test "whatis t3p" "type = PTR TO -> \\( Type t3\\)" - - gdb_test "ptype t1" \ - [multi_line "type = Type t1" \ -@@ -73,4 +73,4 @@ gdb_test "ptype t3p" \ - [multi_line "type = PTR TO -> \\( Type t3" \ - " $int :: t3_i" \ - " Type t2 :: t2_n" \ -- "End Type t3 \\)"] -+ "End Type t3\\)"] diff --git a/gdb.spec b/gdb.spec index 5e343186e0302d0a5bd703ab34f20afb4f73404f..03e5fc55478d9ae64ecc49f07afc89023193aae1 100644 --- a/gdb.spec +++ b/gdb.spec @@ -1,6 +1,6 @@ Name: gdb -Version: 9.2 -Release: 8 +Version: 11.1 +Release: 1 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL-1.3 Source: ftp://sourceware.org/pub/gdb/releases/gdb-%{version}.tar.xz @@ -10,111 +10,90 @@ Source1: gdb-gstack.man Source2: gdbinit # patch from Fedora -Patch1: gdb-vla-intel-fortran-strides.patch -Patch2: gdb-vla-intel-fortran-vla-strings.patch -Patch3: gdb-vla-intel-stringbt-fix.patch -Patch4: gdb-6.3-gstack-20050411.patch -Patch5: gdb-6.3-test-pie-20050107.patch -Patch6: gdb-6.3-test-self-20050110.patch -Patch7: gdb-6.3-test-dtorfix-20050121.patch -Patch8: gdb-6.3-test-movedir-20050125.patch -Patch9: gdb-6.3-threaded-watchpoints2-20050225.patch -Patch10: gdb-6.3-inferior-notification-20050721.patch -Patch11: gdb-6.3-inheritancetest-20050726.patch -Patch12: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch -Patch13: gdb-6.5-sharedlibrary-path.patch -Patch14: gdb-6.5-BEA-testsuite.patch -Patch15: gdb-6.5-last-address-space-byte-test.patch -Patch16: gdb-6.5-readline-long-line-crash-test.patch -Patch17: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch -Patch18: gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch -Patch19: gdb-6.5-bz109921-DW_AT_decl_file-test.patch -Patch20: gdb-6.3-bz140532-ppc-unwinding-test.patch -Patch21: gdb-6.3-bz202689-exec-from-pthread-test.patch -Patch22: gdb-6.6-bz230000-power6-disassembly-test.patch -Patch23: gdb-6.6-bz229517-gcore-without-terminal.patch -Patch24: gdb-6.6-testsuite-timeouts.patch -Patch25: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch -Patch26: gdb-6.3-attach-see-vdso-test.patch -Patch27: gdb-6.5-bz243845-stale-testing-zombie-test.patch -Patch28: gdb-6.6-buildid-locate.patch -Patch29: gdb-6.6-buildid-locate-solib-missing-ids.patch -Patch30: gdb-6.6-buildid-locate-rpm.patch -Patch31: gdb-6.7-charsign-test.patch -Patch32: gdb-6.7-ppc-clobbered-registers-O2-test.patch -Patch33: gdb-6.7-testsuite-stable-results.patch -Patch34: gdb-6.5-ia64-libunwind-leak-test.patch -Patch35: gdb-6.5-missed-trap-on-step-test.patch -Patch36: gdb-6.5-gcore-buffer-limit-test.patch -Patch37: gdb-6.3-mapping-zero-inode-test.patch -Patch38: gdb-6.3-focus-cmd-prev-test.patch -Patch39: gdb-6.8-bz442765-threaded-exec-test.patch -Patch40: gdb-6.5-section-num-fixup-test.patch -Patch41: gdb-6.8-bz466901-backtrace-full-prelinked.patch -Patch42: gdb-simultaneous-step-resume-breakpoint-test.patch -Patch43: gdb-core-open-vdso-warning.patch -Patch44: gdb-bz533176-fortran-omp-step.patch -Patch45: gdb-ccache-workaround.patch -Patch46: gdb-archer-pie-addons.patch -Patch47: gdb-archer-pie-addons-keep-disabled.patch -Patch48: gdb-lineno-makeup-test.patch -Patch49: gdb-ppc-power7-test.patch -Patch50: gdb-moribund-utrace-workaround.patch -Patch51: gdb-archer-next-over-throw-cxx-exec.patch -Patch52: gdb-bz601887-dwarf4-rh-test.patch -Patch53: gdb-6.6-buildid-locate-core-as-arg.patch -Patch54: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch -Patch55: gdb-test-bt-cfi-without-die.patch -Patch56: gdb-bz634108-solib_address.patch -Patch57: gdb-test-pid0-core.patch -Patch58: gdb-test-dw2-aranges.patch -Patch59: gdb-test-expr-cumulative-archer.patch -Patch60: gdb-physname-pr11734-test.patch -Patch61: gdb-physname-pr12273-test.patch -Patch62: gdb-test-ivy-bridge.patch -Patch63: gdb-runtest-pie-override.patch -Patch64: gdb-attach-fail-reasons-5of5.patch -Patch65: gdb-glibc-strstr-workaround.patch -Patch66: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch -Patch67: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch -Patch68: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch -Patch69: gdb-gnat-dwarf-crash-3of3.patch -Patch70: gdb-rhbz1007614-memleak-infpy_read_memory-test.patch -Patch71: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch -Patch72: gdb-archer-vla-tests.patch -Patch73: gdb-vla-intel-tests.patch -Patch74: gdb-btrobust.patch -Patch75: gdb-fortran-frame-string.patch -Patch76: gdb-rhbz1156192-recursive-dlopen-test.patch -Patch77: gdb-jit-reader-multilib.patch -Patch78: gdb-rhbz1149205-catch-syscall-after-fork-test.patch -Patch79: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch -Patch80: gdb-rhbz1350436-type-printers-error.patch -Patch81: gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch -Patch82: gdb-bz1219747-attach-kills.patch -Patch83: gdb-fedora-libncursesw.patch -Patch84: gdb-opcodes-clflushopt-test.patch -Patch85: gdb-dts-rhel6-python-compat.patch -Patch86: gdb-6.6-buildid-locate-rpm-scl.patch -Patch87: gdb-6.8-quit-never-aborts.patch -Patch88: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch -Patch89: gdb-container-rh-pkg.patch -Patch90: gdb-rhbz1325795-framefilters-test.patch -Patch91: gdb-linux_perf-bundle.patch -Patch92: gdb-libexec-add-index.patch -Patch93: gdb-rhbz1398387-tab-crash-test.patch -Patch94: gdb-archer.patch -Patch95: gdb-vla-intel-fix-print-char-array.patch -Patch96: gdb-rhbz1553104-s390x-arch12-test.patch -Patch97: gdb-rhbz1818011-bfd-gcc10-error.patch -Patch98: gdb-rhbz1822715-fix-python-deprecation.patch -Patch99: gdb-rhbz1829702-fix-python39.patch -Patch100: gdb-rhbz1844458-use-fputX_unfiltered.patch -Patch101: gdb-rhbz1838777-debuginfod.patch -# Fedora patch end - -Patch102: 0001-adjust-include-order-to-avoid-gnulib-error.patch -Patch103: 0001-Make-c-exp.y-work-with-Bison-3.8.patch +Patch1: gdb-6.3-rh-testversion-20041202.patch +Patch2: gdb-6.3-gstack-20050411.patch +Patch3: gdb-6.3-test-dtorfix-20050121.patch +Patch4: gdb-6.3-test-movedir-20050125.patch +Patch5: gdb-6.3-threaded-watchpoints2-20050225.patch +Patch6: gdb-6.3-inferior-notification-20050721.patch +Patch7: gdb-6.3-inheritancetest-20050726.patch +Patch8: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch +Patch9: gdb-6.5-sharedlibrary-path.patch +Patch10: gdb-6.5-BEA-testsuite.patch +Patch11: gdb-6.5-last-address-space-byte-test.patch +Patch12: gdb-6.5-readline-long-line-crash-test.patch +Patch13: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch +Patch14: gdb-6.5-bz109921-DW_AT_decl_file-test.patch +Patch15: gdb-6.3-bz140532-ppc-unwinding-test.patch +Patch16: gdb-6.3-bz202689-exec-from-pthread-test.patch +Patch17: gdb-6.6-bz230000-power6-disassembly-test.patch +Patch18: gdb-6.6-bz229517-gcore-without-terminal.patch +Patch19: gdb-6.6-testsuite-timeouts.patch +Patch20: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch +Patch21: gdb-6.3-attach-see-vdso-test.patch +Patch22: gdb-6.5-bz243845-stale-testing-zombie-test.patch +Patch23: gdb-6.6-buildid-locate.patch +Patch24: gdb-6.6-buildid-locate-solib-missing-ids.patch +Patch25: gdb-6.6-buildid-locate-rpm.patch +Patch26: gdb-6.7-charsign-test.patch +Patch27: gdb-6.7-ppc-clobbered-registers-O2-test.patch +Patch28: gdb-6.7-testsuite-stable-results.patch +Patch29: gdb-6.5-ia64-libunwind-leak-test.patch +Patch30: gdb-6.5-missed-trap-on-step-test.patch +Patch31: gdb-6.5-gcore-buffer-limit-test.patch +Patch32: gdb-6.3-mapping-zero-inode-test.patch +Patch33: gdb-6.3-focus-cmd-prev-test.patch +Patch34: gdb-6.8-bz442765-threaded-exec-test.patch +Patch35: gdb-6.5-section-num-fixup-test.patch +Patch36: gdb-6.8-bz466901-backtrace-full-prelinked.patch +Patch37: gdb-simultaneous-step-resume-breakpoint-test.patch +Patch38: gdb-core-open-vdso-warning.patch +Patch39: gdb-ccache-workaround.patch +Patch40: gdb-lineno-makeup-test.patch +Patch41: gdb-ppc-power7-test.patch +Patch42: gdb-archer-next-over-throw-cxx-exec.patch +Patch43: gdb-bz601887-dwarf4-rh-test.patch +Patch44: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch +Patch45: gdb-test-bt-cfi-without-die.patch +Patch46: gdb-bz634108-solib_address.patch +Patch47: gdb-test-pid0-core.patch +Patch48: gdb-test-dw2-aranges.patch +Patch49: gdb-test-expr-cumulative-archer.patch +Patch50: gdb-physname-pr11734-test.patch +Patch51: gdb-physname-pr12273-test.patch +Patch52: gdb-test-ivy-bridge.patch +Patch53: gdb-runtest-pie-override.patch +Patch54: gdb-glibc-strstr-workaround.patch +Patch55: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch +Patch56: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch +Patch57: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch +Patch58: gdb-rhbz1007614-memleak-infpy_read_memory-test.patch +Patch59: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch +Patch60: gdb-fortran-frame-string.patch +Patch61: gdb-rhbz1156192-recursive-dlopen-test.patch +Patch62: gdb-rhbz1149205-catch-syscall-after-fork-test.patch +Patch63: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch +Patch64: gdb-rhbz1350436-type-printers-error.patch +Patch65: gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch +Patch66: gdb-fedora-libncursesw.patch +Patch67: gdb-opcodes-clflushopt-test.patch +Patch68: gdb-6.6-buildid-locate-rpm-scl.patch +Patch69: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch +Patch70: gdb-container-rh-pkg.patch +Patch71: gdb-rhbz1325795-framefilters-test.patch +Patch72: gdb-linux_perf-bundle.patch +Patch73: gdb-libexec-add-index.patch +Patch74: gdb-rhbz1398387-tab-crash-test.patch +Patch75: gdb-rhbz1553104-s390x-arch12-test.patch +Patch76: gdb-rhbz1976887-field-location-kind.patch +Patch77: gdb-test-for-rhbz1976887.patch +Patch78: gdb-rhbz2012976-paper-over-fortran-lex-problems.patch +Patch79: gdb-rhbz-853071-update-manpages.patch +Patch80: gdb-rhbz2022177-dprintf-1.patch +Patch81: gdb-rhbz2022177-dprintf-2.patch +# Fedra patch end + +Patch82: 0001-Make-c-exp.y-work-with-Bison-3.8.patch %global gdb_src gdb-%{version} %global gdb_build build-%{_target_platform} @@ -196,15 +175,6 @@ This package provides INFO, HTML and PDF user manual for GDB. find -name "*.info*"|xargs rm -f -for i in \ - gdb/python/lib/gdb/FrameWrapper.py \ - gdb/python/lib/gdb/backtrace.py \ - gdb/python/lib/gdb/command/backtrace.py \ - ;do - test -e $i - : >$i -done - find -name "*.orig" | xargs rm -f cat > gdb/version.in << _FOO @@ -277,8 +247,6 @@ perl -i.relocatable -pe 's/^(D\[".*_RELOCATABLE"\]=" )1(")$/${1}0$2/' gdb/config make %{?_smp_mflags} CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" V=1 ! grep '_RELOCATABLE.*1' gdb/config.h -grep '^#define HAVE_LIBSELINUX 1$' gdb/config.h -grep '^#define HAVE_SELINUX_SELINUX_H 1$' gdb/config.h cd .. @@ -397,6 +365,9 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/gdb/python/gdb/command/backtrace.py %{_infodir}/gdb.info* %changelog +* Mon Dec 27 2021 zhouwenpei - 11.1-1 +- upgrade GDB version to 11.1 + * Tue Dec 21 2021 - Chenxi Mao - 9.2-8 - fix gdb build error via cherry-pick upstream patch diff --git a/v1.5-libipt-static.patch b/v1.5-libipt-static.patch new file mode 100644 index 0000000000000000000000000000000000000000..69e1d1a1cd18730dd6075d82fd248becb6414a06 --- /dev/null +++ b/v1.5-libipt-static.patch @@ -0,0 +1,13 @@ +Index: processor-trace-2.0/libipt/src/posix/init.c +=================================================================== +--- processor-trace-2.0.orig/libipt/src/posix/init.c ++++ processor-trace-2.0/libipt/src/posix/init.c +@@ -29,7 +29,7 @@ + #include "pt_ild.h" + + +-static void __attribute__((constructor)) init(void) ++void __libipt_init(void) + { + /* Initialize the Intel(R) Processor Trace instruction decoder. */ + pt_ild_init();