diff --git a/.gitignore b/.gitignore
index e69de29..b83cfdf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/binutils-gdb
+/gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz
+/gdb-9.2.tar.xz
+/v2.0.2.tar.gz
diff --git a/README.local-patches.md b/README.local-patches.md
new file mode 100644
index 0000000..fc2eb90
--- /dev/null
+++ b/README.local-patches.md
@@ -0,0 +1,104 @@
+# Fedora GDB local patches policy
+
+In order to make things easier for the Fedora GDB maintainer, we
+choose to auto-generate the local patches by making use of an upstream
+git repository. Below you can find a few instructions on how to work
+using this method.
+
+You need to run the following commands from the directory that
+contains the "gdb.spec" file.
+
+## Importing the GDB patches into a git repository
+
+1) The local patches (`*.patch`) need to be imported into an upstream
+git repository. For example, let's assume you cloned the repository
+by doing:
+
+`$ git clone git://sourceware.org/git/binutils-gdb.git`
+
+> TIP: if you already have the repository cloned somewhere in your
+> system, you can pass a "--reference
" to the "git clone"
+> command and it will use your local repository as much as possible
+> to make the clone, speeding up things.
+
+2) After cloning the upstream repository, you can import your patches
+by using the script "generate-git-repo-from-patches.sh":
+
+`$ sh generate-git-repo-from-patches.sh `
+
+The script will basically cd into the repository, checkout the
+revision specified in the file `_git_upstream_commit`, iterate through
+the file `_patch_order` and "git-am" every patch *in that order*.
+This operation should complete without errors; if you find a problem
+with `git-am`, it probably means that the revision specified in the
+file `_git_upstream_commit` is wrong.
+
+## Rebasing the patches against a newer version/release
+
+1) First, cd into the upstream repository. All you have to do is
+choose the revision against which you plan to rebase the patches, and
+`git rebase `. git will do the rest, and you will be able
+to perform conflict resolution by git's algorithm, which is smarter.
+
+## Creating new patches
+
+1) Create the new patch on top of the the others, as usual. Note that
+you can use `git rebase` whenever you want to reorder patch order, or
+even to delete a patch.
+
+2) When writing the commit log, you must obey a few rules. The
+subject line *must* be the filename of the patch. This line will be
+used when exporting the patches from the git repository, and
+(obviously) it gives the filename that should be used for this
+specific patch.
+
+3) You can also add comments that will go into the auto-generated
+`Patch:` file (see below). To do that, use the special marker `;;` at
+the beginning of the line. This way, a commit log that says:
+
+~~~~~~~~~~~
+ test-patch.patch
+
+ ;; This is a test patch
+ ;; Second line
+~~~~~~~~~~~
+
+Will generate the following entry in the auto-generated `Patch:` file:
+
+~~~~~~~~~~~
+ # This is a test patch
+ # Second line
+ PatchXYZ: test-patch.patch
+~~~~~~~~~~~
+
+## Exporting the GDB patches from the git repository
+
+1) When you're done working with the patches, go back to the directory
+that contains the `gdb.spec` file, and from there you run:
+
+`$ sh generate-patches-from-git-repo.sh `
+
+This will regenerate all of the `*.patch` files (excluding the ones that
+were also excluded from the git repository), and also regenerate a few
+control files. These control files are:
+
+ - `_gdb.spec.Patch.include`: This file contains the `Patch:` directives.
+
+ - `_gdb.spec.patch.include`: This file contains the `%patch` directives.
+
+ - `_patch_order`: This file contains the patches, in the exact order
+ that they must be applied. It is used when importing the patches
+ into the git repository.
+
+ - `_git_upstream_commit`: This file contains the last upstream commit
+ against which the patches were rebased. It is used when importing
+ the patches into the git repository.
+
+NOTE: If you did a rebase against a newer upstream version, you need
+to specify the commit/tag/branch against which you rebased:
+
+`$ sh generate-patches-from-git-repo.sh `
+
+For example, if you rebased against `gdb-8.1-release`:
+
+`$ sh generate-patches-from-git-repo.sh gdb-8.1-release`
diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include
new file mode 100644
index 0000000..1bf37e7
--- /dev/null
+++ b/_gdb.spec.Patch.include
@@ -0,0 +1,414 @@
+# Match the Fedora's version info.
+#=fedora
+Patch001: gdb-6.3-rh-testversion-20041202.patch
+
+# VLA (Fortran dynamic arrays) from Intel + archer-jankratochvil-vla tests.
+#=push
+Patch002: gdb-vla-intel-fortran-strides.patch
+
+#=push
+Patch003: gdb-vla-intel-fortran-vla-strings.patch
+
+#=push+jan
+Patch004: gdb-vla-intel-stringbt-fix.patch
+
+# Add a wrapper script to GDB that implements pstack using the
+# --readnever option.
+#=push
+Patch005: gdb-6.3-gstack-20050411.patch
+
+# VSYSCALL and PIE
+#=fedoratest
+Patch006: gdb-6.3-test-pie-20050107.patch
+
+# Get selftest working with sep-debug-info
+#=fedoratest
+Patch007: gdb-6.3-test-self-20050110.patch
+
+# Test support of multiple destructors just like multiple constructors
+#=fedoratest
+Patch008: gdb-6.3-test-dtorfix-20050121.patch
+
+# Fix to support executable moving
+#=fedoratest
+Patch009: gdb-6.3-test-movedir-20050125.patch
+
+# Test sibling threads to set threaded watchpoints for x86 and x86-64
+#=fedoratest
+Patch010: gdb-6.3-threaded-watchpoints2-20050225.patch
+
+# Notify observers that the inferior has been created
+#=fedoratest
+Patch011: gdb-6.3-inferior-notification-20050721.patch
+
+# Verify printing of inherited members test
+#=fedoratest
+Patch012: gdb-6.3-inheritancetest-20050726.patch
+
+# Support TLS symbols (+`errno' suggestion if no pthread is found) (BZ 185337).
+#=push+jan: It should be replaced by Infinity project.
+Patch013: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.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.
+Patch014: gdb-6.5-sharedlibrary-path.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.
+Patch015: gdb-6.5-BEA-testsuite.patch
+
+# Testcase for deadlocking on last address space byte; for corrupted backtraces.
+#=fedoratest
+Patch016: gdb-6.5-last-address-space-byte-test.patch
+
+# Fix readline segfault on excessively long hand-typed lines.
+#=fedoratest
+Patch017: gdb-6.5-readline-long-line-crash-test.patch
+
+# Test sideeffects of skipping ppc .so libs trampolines (BZ 218379).
+#=fedoratest
+Patch018: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
+
+# Fix lockup on trampoline vs. its function lookup; unreproducible (BZ 218379).
+#=fedora
+Patch019: gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch
+
+# Find symbols properly at their original (included) file (BZ 109921).
+#=fedoratest
+Patch020: gdb-6.5-bz109921-DW_AT_decl_file-test.patch
+
+# Update PPC unwinding patches to their upstream variants (BZ 140532).
+#=fedoratest
+Patch021: gdb-6.3-bz140532-ppc-unwinding-test.patch
+
+# Testcase for exec() from threaded program (BZ 202689).
+#=fedoratest
+Patch022: gdb-6.3-bz202689-exec-from-pthread-test.patch
+
+# Testcase for PPC Power6/DFP instructions disassembly (BZ 230000).
+#=fedoratest
+Patch023: gdb-6.6-bz230000-power6-disassembly-test.patch
+
+# Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517).
+#=fedoratest
+Patch024: gdb-6.6-bz229517-gcore-without-terminal.patch
+
+# Avoid too long timeouts on failing cases of "annota1.exp annota3.exp".
+#=fedoratest
+Patch025: gdb-6.6-testsuite-timeouts.patch
+
+# Support for stepping over PPC atomic instruction sequences (BZ 237572).
+#=fedoratest
+Patch026: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
+
+# Test kernel VDSO decoding while attaching to an i386 process.
+#=fedoratest
+Patch027: gdb-6.3-attach-see-vdso-test.patch
+
+# Test leftover zombie process (BZ 243845).
+#=fedoratest
+Patch028: gdb-6.5-bz243845-stale-testing-zombie-test.patch
+
+# New locating of the matching binaries from the pure core file (build-id).
+#=push+jan
+Patch029: gdb-6.6-buildid-locate.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
+Patch030: gdb-6.6-buildid-locate-solib-missing-ids.patch
+
+#=push+jan
+Patch031: gdb-6.6-buildid-locate-rpm.patch
+
+# Fix displaying of numeric char arrays as strings (BZ 224128).
+#=fedoratest: But it is failing anyway, one should check the behavior more.
+Patch032: gdb-6.7-charsign-test.patch
+
+# Test PPC hiding of call-volatile parameter register.
+#=fedoratest
+Patch033: gdb-6.7-ppc-clobbered-registers-O2-test.patch
+
+# Testsuite fixes for more stable/comparable results.
+#=fedoratest
+Patch034: gdb-6.7-testsuite-stable-results.patch
+
+# Test ia64 memory leaks of the code using libunwind.
+#=fedoratest
+Patch035: gdb-6.5-ia64-libunwind-leak-test.patch
+
+# Test hiding unexpected breakpoints on intentional step commands.
+#=fedoratest
+Patch036: gdb-6.5-missed-trap-on-step-test.patch
+
+# Test gcore memory and time requirements for large inferiors.
+#=fedoratest
+Patch037: gdb-6.5-gcore-buffer-limit-test.patch
+
+# Test GCORE for shmid 0 shared memory mappings.
+#=fedoratest: But it is broken anyway, sometimes the case being tested is not reproducible.
+Patch038: gdb-6.3-mapping-zero-inode-test.patch
+
+# Test a crash on `focus cmd', `focus prev' commands.
+#=fedoratest
+Patch039: gdb-6.3-focus-cmd-prev-test.patch
+
+# Test various forms of threads tracking across exec() (BZ 442765).
+#=fedoratest
+Patch040: gdb-6.8-bz442765-threaded-exec-test.patch
+
+# Test a crash on libraries missing the .text section.
+#=fedoratest
+Patch041: gdb-6.5-section-num-fixup-test.patch
+
+# Fix resolving of variables at locations lists in prelinked libs (BZ 466901).
+#=fedoratest
+Patch042: gdb-6.8-bz466901-backtrace-full-prelinked.patch
+
+# New test for step-resume breakpoint placed in multiple threads at once.
+#=fedoratest
+Patch043: gdb-simultaneous-step-resume-breakpoint-test.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@.*>
+Patch044: gdb-core-open-vdso-warning.patch
+
+# Fix stepping with OMP parallel Fortran sections (BZ 533176).
+#=push+jan: It requires some better DWARF annotations.
+Patch045: gdb-bz533176-fortran-omp-step.patch
+
+# Workaround ccache making lineno non-zero for command-line definitions.
+#=fedoratest: ccache is rarely used and it is even fixed now.
+Patch046: gdb-ccache-workaround.patch
+
+#=push+jan: May get obsoleted by Tom's unrelocated objfiles patch.
+Patch047: gdb-archer-pie-addons.patch
+
+#=push+jan: Breakpoints disabling matching should not be based on address.
+Patch048: gdb-archer-pie-addons-keep-disabled.patch
+
+# Testcase for "Do not make up line information" fix by Daniel Jacobowitz.
+#=fedoratest
+Patch049: gdb-lineno-makeup-test.patch
+
+# Test power7 ppc disassembly.
+#=fedoratest
+Patch050: gdb-ppc-power7-test.patch
+
+# Workaround non-stop moribund locations exploited by kernel utrace (BZ 590623).
+#=push+jan: Currently it is still not fully safe.
+Patch051: gdb-moribund-utrace-workaround.patch
+
+# Fix follow-exec for C++ programs (bugreported by Martin Stransky).
+#=fedoratest
+Patch052: gdb-archer-next-over-throw-cxx-exec.patch
+
+# Backport DWARF-4 support (BZ 601887, Tom Tromey).
+#=fedoratest
+Patch053: gdb-bz601887-dwarf4-rh-test.patch
+
+#=push+jan
+Patch054: gdb-6.6-buildid-locate-core-as-arg.patch
+
+# Workaround librpm BZ 643031 due to its unexpected exit() calls (BZ 642879).
+#=push+jan
+Patch055: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
+
+# [delayed-symfile] Test a backtrace regression on CFIs without DIE (BZ 614604).
+#=fedoratest
+Patch056: gdb-test-bt-cfi-without-die.patch
+
+# Verify GDB Python built-in function gdb.solib_address exists (BZ # 634108).
+#=fedoratest
+Patch057: gdb-bz634108-solib_address.patch
+
+# New test gdb.arch/x86_64-pid0-core.exp for kernel PID 0 cores (BZ 611435).
+#=fedoratest
+Patch058: gdb-test-pid0-core.patch
+
+# [archer-tromey-delayed-symfile] New test gdb.dwarf2/dw2-aranges.exp.
+#=fedoratest
+Patch059: gdb-test-dw2-aranges.patch
+
+# [archer-keiths-expr-cumulative+upstream] Import C++ testcases.
+#=fedoratest
+Patch060: gdb-test-expr-cumulative-archer.patch
+
+# Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz).
+#=fedoratest
+Patch061: gdb-physname-pr11734-test.patch
+
+# Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz).
+#=fedoratest
+Patch062: gdb-physname-pr12273-test.patch
+
+# Test GDB opcodes/ disassembly of Intel Ivy Bridge instructions (BZ 696890).
+#=fedoratest
+Patch063: gdb-test-ivy-bridge.patch
+
+# Hack for proper PIE run of the testsuite.
+#=fedoratest
+Patch064: gdb-runtest-pie-override.patch
+
+# Print reasons for failed attach/spawn incl. SELinux deny_ptrace (BZ 786878).
+#=push+jan
+Patch065: gdb-attach-fail-reasons-5of5.patch
+
+# Workaround PR libc/14166 for inferior calls of strstr.
+#=fedoratest: Compatibility with RHELs (unchecked which ones).
+Patch066: gdb-glibc-strstr-workaround.patch
+
+# Include testcase for `Unable to see a variable inside a module (XLF)' (BZ 823789).
+#=fedoratest
+Patch067: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch
+
+# Testcase for `Setting solib-absolute-prefix breaks vDSO' (BZ 818343).
+#=fedoratest
+Patch068: gdb-rhbz-818343-set-solib-absolute-prefix-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
+Patch069: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch
+
+# Fix crash of -readnow /usr/lib/debug/usr/bin/gnatbind.debug (BZ 1069211).
+#=push+jan
+Patch070: gdb-gnat-dwarf-crash-3of3.patch
+
+# Fix 'memory leak in infpy_read_memory()' (RH BZ 1007614)
+#=fedoratest
+Patch071: gdb-rhbz1007614-memleak-infpy_read_memory-test.patch
+
+# Fix 'gdb gives highly misleading error when debuginfo pkg is present,
+# but not corresponding binary pkg' (RH BZ 981154).
+#=push+jan
+Patch072: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
+
+#=fedoratest
+Patch073: gdb-archer-vla-tests.patch
+
+#=fedoratest
+Patch074: gdb-vla-intel-tests.patch
+
+# Continue backtrace even if a frame filter throws an exception (Phil Muldoon).
+#=push
+Patch075: gdb-btrobust.patch
+
+# Display Fortran strings in backtraces.
+#=fedoratest
+Patch076: gdb-fortran-frame-string.patch
+
+# Testcase for '[SAP] Recursive dlopen causes SAP HANA installer to
+# crash.' (RH BZ 1156192).
+#=fedoratest
+Patch077: gdb-rhbz1156192-recursive-dlopen-test.patch
+
+# Fix jit-reader.h for multi-lib.
+#=push+jan
+Patch078: gdb-jit-reader-multilib.patch
+
+# Fix '`catch syscall' doesn't work for parent after `fork' is called'
+# (Philippe Waroquiers, RH BZ 1149205).
+#=fedoratest
+Patch079: gdb-rhbz1149205-catch-syscall-after-fork-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
+Patch080: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch
+
+# Test 'info type-printers' Python error (RH BZ 1350436).
+#=fedoratest
+Patch081: gdb-rhbz1350436-type-printers-error.patch
+
+# Fix '[ppc64] and [s390x] wrong prologue skip on -O2 -g code' (Jan
+# Kratochvil, RH BZ 1084404).
+#=fedoratest
+Patch082: gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch
+
+# Never kill PID on: gdb exec PID (Jan Kratochvil, RH BZ 1219747).
+#=push+jan
+Patch083: gdb-bz1219747-attach-kills.patch
+
+# Force libncursesw over libncurses to match the includes (RH BZ 1270534).
+#=push+jan
+Patch084: gdb-fedora-libncursesw.patch
+
+# Test clflushopt instruction decode (for RH BZ 1262471).
+#=fedoratest
+Patch085: gdb-opcodes-clflushopt-test.patch
+
+# [rhel6] DTS backward Python compatibility API (BZ 1020004, Phil Muldoon).
+#=fedora
+Patch086: gdb-dts-rhel6-python-compat.patch
+
+# [SCL] Skip deprecated .gdb_index warning for Red Hat built files (BZ 953585).
+#=push+jan
+Patch087: gdb-6.6-buildid-locate-rpm-scl.patch
+
+# Make the GDB quit processing non-abortable to cleanup everything properly.
+#=fedora: It was useful only after gdb-6.8-attach-signalled-detach-stopped.patch .
+Patch088: gdb-6.8-quit-never-aborts.patch
+
+# [aarch64] Fix hardware watchpoints (RH BZ 1261564).
+#=fedoratest
+Patch089: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
+
+# Add messages suggesting more recent RHEL gdbserver (RH BZ 1321114).
+#=fedora
+Patch090: gdb-container-rh-pkg.patch
+
+# New test for Python "Cannot locate object file for block" (for RH BZ 1325795).
+#=fedoratest
+Patch091: gdb-rhbz1325795-framefilters-test.patch
+
+# [dts+el7] [x86*] Bundle linux_perf.h for libipt (RH BZ 1256513).
+#=fedora
+Patch092: gdb-linux_perf-bundle.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
+Patch093: gdb-libexec-add-index.patch
+
+# New testcase for: Fix -completion crash (Gary Benson, RH BZ 1398387).
+#=fedoratest
+Patch094: gdb-rhbz1398387-tab-crash-test.patch
+
+# Python patches of: http://sourceware.org/gdb/wiki/ProjectArcher
+#=push
+Patch095: gdb-archer.patch
+
+# Revert upstream commit 469412dd9ccc4de5874fd3299b105833f36b34cd
+Patch096: gdb-vla-intel-fix-print-char-array.patch
+
+# [s390x] Backport arch12 instructions decoding (RH BZ 1553104).
+# =fedoratest
+Patch097: gdb-rhbz1553104-s390x-arch12-test.patch
+
+# Fix int conversion error from bfd/elf.c when compiling with gcc 10
+Patch098: gdb-rhbz1818011-bfd-gcc10-error.patch
+
+# Backport fix for deprecation of PyEval_InitThreads in Python 3.9.
+Patch099: gdb-rhbz1822715-fix-python-deprecation.patch
+
+# Backport "Fix Python 3.9 related runtime problems"
+# Kevin Buettner and Keith Seitz
+Patch100: gdb-rhbz1829702-fix-python39.patch
+
+# Fix fput?_unfiltered functions
+# RH BZ 1844458 (Sergio Durigan Junior and Tom Tromey)
+Patch101: gdb-rhbz1844458-use-fputX_unfiltered.patch
+
+# Backport debuginofd support.
+# (Aaron Merey, RH BZ 183877)
+Patch102: gdb-rhbz1838777-debuginfod.patch
+
diff --git a/_gdb.spec.patch.include b/_gdb.spec.patch.include
new file mode 100644
index 0000000..48f09cd
--- /dev/null
+++ b/_gdb.spec.patch.include
@@ -0,0 +1,102 @@
+%patch001 -p1
+%patch002 -p1
+%patch003 -p1
+%patch004 -p1
+%patch005 -p1
+%patch006 -p1
+%patch007 -p1
+%patch008 -p1
+%patch009 -p1
+%patch010 -p1
+%patch011 -p1
+%patch012 -p1
+%patch013 -p1
+%patch014 -p1
+%patch015 -p1
+%patch016 -p1
+%patch017 -p1
+%patch018 -p1
+%patch019 -p1
+%patch020 -p1
+%patch021 -p1
+%patch022 -p1
+%patch023 -p1
+%patch024 -p1
+%patch025 -p1
+%patch026 -p1
+%patch027 -p1
+%patch028 -p1
+%patch029 -p1
+%patch030 -p1
+%patch031 -p1
+%patch032 -p1
+%patch033 -p1
+%patch034 -p1
+%patch035 -p1
+%patch036 -p1
+%patch037 -p1
+%patch038 -p1
+%patch039 -p1
+%patch040 -p1
+%patch041 -p1
+%patch042 -p1
+%patch043 -p1
+%patch044 -p1
+%patch045 -p1
+%patch046 -p1
+%patch047 -p1
+%patch048 -p1
+%patch049 -p1
+%patch050 -p1
+%patch051 -p1
+%patch052 -p1
+%patch053 -p1
+%patch054 -p1
+%patch055 -p1
+%patch056 -p1
+%patch057 -p1
+%patch058 -p1
+%patch059 -p1
+%patch060 -p1
+%patch061 -p1
+%patch062 -p1
+%patch063 -p1
+%patch064 -p1
+%patch065 -p1
+%patch066 -p1
+%patch067 -p1
+%patch068 -p1
+%patch069 -p1
+%patch070 -p1
+%patch071 -p1
+%patch072 -p1
+%patch073 -p1
+%patch074 -p1
+%patch075 -p1
+%patch076 -p1
+%patch077 -p1
+%patch078 -p1
+%patch079 -p1
+%patch080 -p1
+%patch081 -p1
+%patch082 -p1
+%patch083 -p1
+%patch084 -p1
+%patch085 -p1
+%patch086 -p1
+%patch087 -p1
+%patch088 -p1
+%patch089 -p1
+%patch090 -p1
+%patch091 -p1
+%patch092 -p1
+%patch093 -p1
+%patch094 -p1
+%patch095 -p1
+%patch096 -p1
+%patch097 -p1
+%patch098 -p1
+%patch099 -p1
+%patch100 -p1
+%patch101 -p1
+%patch102 -p1
diff --git a/_git_upstream_commit b/_git_upstream_commit
new file mode 100644
index 0000000..751b241
--- /dev/null
+++ b/_git_upstream_commit
@@ -0,0 +1 @@
+e7fe0803b6427d3906e991bbb3b7fd2f0fd05e00
diff --git a/_patch_order b/_patch_order
new file mode 100644
index 0000000..0ff91c4
--- /dev/null
+++ b/_patch_order
@@ -0,0 +1,102 @@
+gdb-6.3-rh-testversion-20041202.patch
+gdb-vla-intel-fortran-strides.patch
+gdb-vla-intel-fortran-vla-strings.patch
+gdb-vla-intel-stringbt-fix.patch
+gdb-6.3-gstack-20050411.patch
+gdb-6.3-test-pie-20050107.patch
+gdb-6.3-test-self-20050110.patch
+gdb-6.3-test-dtorfix-20050121.patch
+gdb-6.3-test-movedir-20050125.patch
+gdb-6.3-threaded-watchpoints2-20050225.patch
+gdb-6.3-inferior-notification-20050721.patch
+gdb-6.3-inheritancetest-20050726.patch
+gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
+gdb-6.5-sharedlibrary-path.patch
+gdb-6.5-BEA-testsuite.patch
+gdb-6.5-last-address-space-byte-test.patch
+gdb-6.5-readline-long-line-crash-test.patch
+gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
+gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch
+gdb-6.5-bz109921-DW_AT_decl_file-test.patch
+gdb-6.3-bz140532-ppc-unwinding-test.patch
+gdb-6.3-bz202689-exec-from-pthread-test.patch
+gdb-6.6-bz230000-power6-disassembly-test.patch
+gdb-6.6-bz229517-gcore-without-terminal.patch
+gdb-6.6-testsuite-timeouts.patch
+gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
+gdb-6.3-attach-see-vdso-test.patch
+gdb-6.5-bz243845-stale-testing-zombie-test.patch
+gdb-6.6-buildid-locate.patch
+gdb-6.6-buildid-locate-solib-missing-ids.patch
+gdb-6.6-buildid-locate-rpm.patch
+gdb-6.7-charsign-test.patch
+gdb-6.7-ppc-clobbered-registers-O2-test.patch
+gdb-6.7-testsuite-stable-results.patch
+gdb-6.5-ia64-libunwind-leak-test.patch
+gdb-6.5-missed-trap-on-step-test.patch
+gdb-6.5-gcore-buffer-limit-test.patch
+gdb-6.3-mapping-zero-inode-test.patch
+gdb-6.3-focus-cmd-prev-test.patch
+gdb-6.8-bz442765-threaded-exec-test.patch
+gdb-6.5-section-num-fixup-test.patch
+gdb-6.8-bz466901-backtrace-full-prelinked.patch
+gdb-simultaneous-step-resume-breakpoint-test.patch
+gdb-core-open-vdso-warning.patch
+gdb-bz533176-fortran-omp-step.patch
+gdb-ccache-workaround.patch
+gdb-archer-pie-addons.patch
+gdb-archer-pie-addons-keep-disabled.patch
+gdb-lineno-makeup-test.patch
+gdb-ppc-power7-test.patch
+gdb-moribund-utrace-workaround.patch
+gdb-archer-next-over-throw-cxx-exec.patch
+gdb-bz601887-dwarf4-rh-test.patch
+gdb-6.6-buildid-locate-core-as-arg.patch
+gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
+gdb-test-bt-cfi-without-die.patch
+gdb-bz634108-solib_address.patch
+gdb-test-pid0-core.patch
+gdb-test-dw2-aranges.patch
+gdb-test-expr-cumulative-archer.patch
+gdb-physname-pr11734-test.patch
+gdb-physname-pr12273-test.patch
+gdb-test-ivy-bridge.patch
+gdb-runtest-pie-override.patch
+gdb-attach-fail-reasons-5of5.patch
+gdb-glibc-strstr-workaround.patch
+gdb-rhel5.9-testcase-xlf-var-inside-mod.patch
+gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch
+gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch
+gdb-gnat-dwarf-crash-3of3.patch
+gdb-rhbz1007614-memleak-infpy_read_memory-test.patch
+gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
+gdb-archer-vla-tests.patch
+gdb-vla-intel-tests.patch
+gdb-btrobust.patch
+gdb-fortran-frame-string.patch
+gdb-rhbz1156192-recursive-dlopen-test.patch
+gdb-jit-reader-multilib.patch
+gdb-rhbz1149205-catch-syscall-after-fork-test.patch
+gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch
+gdb-rhbz1350436-type-printers-error.patch
+gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch
+gdb-bz1219747-attach-kills.patch
+gdb-fedora-libncursesw.patch
+gdb-opcodes-clflushopt-test.patch
+gdb-dts-rhel6-python-compat.patch
+gdb-6.6-buildid-locate-rpm-scl.patch
+gdb-6.8-quit-never-aborts.patch
+gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
+gdb-container-rh-pkg.patch
+gdb-rhbz1325795-framefilters-test.patch
+gdb-linux_perf-bundle.patch
+gdb-libexec-add-index.patch
+gdb-rhbz1398387-tab-crash-test.patch
+gdb-archer.patch
+gdb-vla-intel-fix-print-char-array.patch
+gdb-rhbz1553104-s390x-arch12-test.patch
+gdb-rhbz1818011-bfd-gcc10-error.patch
+gdb-rhbz1822715-fix-python-deprecation.patch
+gdb-rhbz1829702-fix-python39.patch
+gdb-rhbz1844458-use-fputX_unfiltered.patch
+gdb-rhbz1838777-debuginfod.patch
diff --git a/gdb-6.3-attach-see-vdso-test.patch b/gdb-6.3-attach-see-vdso-test.patch
new file mode 100644
index 0000000..14fff21
--- /dev/null
+++ b/gdb-6.3-attach-see-vdso-test.patch
@@ -0,0 +1,115 @@
+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
++++ b/gdb/testsuite/gdb.base/attach-see-vdso.c
+@@ -0,0 +1,25 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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. */
++
++#include
++
++int main ()
++{
++ pause ();
++ return 1;
++}
+diff --git a/gdb/testsuite/gdb.base/attach-see-vdso.exp b/gdb/testsuite/gdb.base/attach-see-vdso.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/attach-see-vdso.exp
+@@ -0,0 +1,72 @@
++# 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.
++
++# This file was created by Jan Kratochvil .
++
++# This test only works on Linux
++if { ![istarget "*-*-linux-gnu*"] } {
++ return 0
++}
++
++set testfile "attach-see-vdso"
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++set escapedbinfile [string_to_regexp [standard_output_file ${testfile}]]
++
++# The kernel VDSO is used for the syscalls returns only on i386 (not x86_64).
++#
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-m32}] != "" } {
++ gdb_suppress_entire_file "Testcase nonthraded compile failed, so all tests in this file will automatically fail."
++}
++
++if [get_compiler_info ${binfile}] {
++ return -1
++}
++
++# Start the program running and then wait for a bit, to be sure
++# that it can be attached to.
++
++set testpid [eval exec $binfile &]
++
++# Avoid some race:
++sleep 2
++
++# Start with clean gdb
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++# Never call: gdb_load ${binfile}
++# as the former problem would not reproduce otherwise.
++
++set test "attach"
++gdb_test_multiple "attach $testpid" "$test" {
++ -re "Attaching to process $testpid\r?\n.*$gdb_prompt $" {
++ pass "$test"
++ }
++}
++
++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
new file mode 100644
index 0000000..4a96e8e
--- /dev/null
+++ b/gdb-6.3-bz140532-ppc-unwinding-test.patch
@@ -0,0 +1,320 @@
+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
++++ b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S
+@@ -0,0 +1,78 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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. */
++
++ .section ".text"
++ .align 2
++ .globl func0
++ .type func0, @function
++func0:
++ stwu 1,-16(1)
++ mflr 0
++ stw 31,12(1)
++ stw 0,20(1)
++ mr 31,1
++ bl abort
++ .size func0, .-func0
++ .align 2
++ .globl func1
++ .type func1, @function
++func1:
++ stwu 1,-16(1)
++ mflr 0
++/* 20 = BO = branch always
++ 31 = BI = CR bit (ignored) */
++ bcl 20,31,.Lpie
++.Lpie: stw 31,12(1)
++ stw 0,20(1)
++ mr 31,1
++ bl func0
++ mr 0,3
++ lis 9,var@ha
++ lwz 9,var@l(9)
++ add 0,0,9
++ mr 3,0
++ lwz 11,0(1)
++ lwz 0,4(11)
++ mtlr 0
++ lwz 31,-4(11)
++ mr 1,11
++ blr
++ .size func1, .-func1
++ .section .note.GNU-stack,"",@progbits
++ .ident "GCC: (GNU) 3.4.6 20060404 (Red Hat 3.4.6-8)"
++
++/* Original source file:
++
++#include
++
++extern volatile int var;
++
++int func0 (void) __attribute__((__noinline__));
++int func0 (void)
++{
++ abort ();
++ return var;
++}
++
++int func1 (void) __attribute__((__noinline__));
++int func1 (void)
++{
++ return func0 () + var;
++}
++
++*/
+diff --git a/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S
+@@ -0,0 +1,98 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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. */
++
++ .section ".toc","aw"
++ .section ".text"
++ .align 2
++ .globl func0
++ .section ".opd","aw"
++ .align 3
++func0:
++ .quad .L.func0,.TOC.@tocbase
++ .previous
++ .type func0, @function
++.L.func0:
++ mflr 0
++ std 31,-8(1)
++ std 0,16(1)
++ stdu 1,-128(1)
++ mr 31,1
++ bl abort
++ nop
++ .long 0
++ .byte 0,0,0,1,128,1,0,1
++ .size func0,.-.L.func0
++ .section ".toc","aw"
++.LC1:
++ .tc var[TC],var
++ .section ".text"
++ .align 2
++ .globl func1
++ .section ".opd","aw"
++ .align 3
++func1:
++ .quad .L.func1,.TOC.@tocbase
++ .previous
++ .type func1, @function
++.L.func1:
++ mflr 0
++/* 20 = BO = branch always
++ 31 = BI = CR bit (ignored) */
++ bcl 20,31,.Lpie
++.Lpie: std 31,-8(1)
++ std 0,16(1)
++ stdu 1,-128(1)
++ mr 31,1
++ bl func0
++ mr 11,3
++ ld 9,.LC1@toc(2)
++ lwz 0,0(9)
++ add 0,11,0
++ extsw 0,0
++ mr 3,0
++ ld 1,0(1)
++ ld 0,16(1)
++ mtlr 0
++ ld 31,-8(1)
++ blr
++ .long 0
++ .byte 0,0,0,1,128,1,0,1
++ .size func1,.-.L.func1
++ .section .note.GNU-stack,"",@progbits
++ .ident "GCC: (GNU) 3.4.6 20060404 (Red Hat 3.4.6-8)"
++
++/* Original source file:
++
++#include
++
++extern volatile int var;
++
++int func0 (void) __attribute__((__noinline__));
++int func0 (void)
++{
++ abort ();
++ return var;
++}
++
++int func1 (void) __attribute__((__noinline__));
++int func1 (void)
++{
++ return func0 () + var;
++}
++
++*/
+diff --git a/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c
+@@ -0,0 +1,29 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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. */
++
++/* Force `-fpie' double jump bl->blrl. */
++/* No longer used. */
++volatile int var;
++
++extern int func1 (void);
++
++int main (void)
++{
++ func1 ();
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp
+@@ -0,0 +1,72 @@
++# Copyright 2006, 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.
++
++# Test unwinding fixes of the PPC platform, specifically on the coping with BCL
++# jump of the PIE code.
++
++if ![istarget "powerpc*-*-linux*"] then {
++ verbose "Skipping powerpc-linux prologue tests."
++ return
++}
++
++set testfile "powerpc-bcl-prologue"
++set srcfile1 ${testfile}.c
++set flags "debug"
++if [istarget "powerpc-*"] then {
++ set srcfile2 ${testfile}-asm32.S
++ set flags "$flags additional_flags=-m32"
++} elseif [istarget "powerpc64-*"] then {
++ set srcfile2 ${testfile}-asm64.S
++ set flags "$flags additional_flags=-m64"
++} else {
++ fail "powerpc arch test"
++ return
++}
++set objfile2 [standard_output_file ${testfile}-asm.o]
++set binfile [standard_output_file ${testfile}]
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2}" ${binfile} executable $flags] != ""} {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++# We should stop in abort(3).
++
++gdb_run_cmd
++
++gdb_test_multiple {} "continue to abort()" {
++ -re ".*Program received signal SIGABRT,.*$gdb_prompt $" {
++ pass "continue to abort()"
++ }
++}
++
++# Check backtrace:
++# #3 0x0804835f in func0 ()
++# #4 0x0804836a in func1 ()
++# #5 0x0804838c in main ()
++# (gdb)
++# `\\.?' prefixes are needed for ppc64 without `debug' (another bug).
++
++set test "matching unwind"
++gdb_test_multiple "backtrace" $test {
++ -re "\r\n#\[0-9\]\[^\r\n\]* in \\.?func0 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?func1 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?main \\(\[^\r\n\]*\r\n$gdb_prompt $" {
++ pass $test
++ }
++}
+diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
+--- a/gdb/testsuite/gdb.arch/powerpc-prologue.exp
++++ b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
+@@ -16,8 +16,9 @@
+ # Test PowerPC prologue analyzer.
+
+ # Do not run on AIX (where we won't be able to build the tests without
+-# some surgery) or on PowerPC64 (ditto, dot symbols).
+-if {[istarget *-*-aix*] || ![istarget "powerpc-*-*"]} then {
++# some surgery). PowerPC64 target would break due to dot symbols but we build
++# there PowerPC32 inferior.
++if {[istarget *-*-aix*] || ![istarget "powerpc*-*-*"]} then {
+ verbose "Skipping PowerPC prologue tests."
+ return
+ }
diff --git a/gdb-6.3-bz202689-exec-from-pthread-test.patch b/gdb-6.3-bz202689-exec-from-pthread-test.patch
new file mode 100644
index 0000000..df59b77
--- /dev/null
+++ b/gdb-6.3-bz202689-exec-from-pthread-test.patch
@@ -0,0 +1,109 @@
+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
++++ b/gdb/testsuite/gdb.threads/threaded-exec.c
+@@ -0,0 +1,46 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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. */
++
++#include
++#include
++#include
++#include
++#include
++
++
++static void *
++threader (void *arg)
++{
++ return NULL;
++}
++
++int
++main (void)
++{
++ pthread_t t1;
++ int i;
++
++ i = pthread_create (&t1, NULL, threader, (void *) NULL);
++ assert (i == 0);
++ i = pthread_join (t1, NULL);
++ assert (i == 0);
++
++ execl ("/bin/true", "/bin/true", NULL);
++ abort ();
++}
+diff --git a/gdb/testsuite/gdb.threads/threaded-exec.exp b/gdb/testsuite/gdb.threads/threaded-exec.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.threads/threaded-exec.exp
+@@ -0,0 +1,41 @@
++# threaded-exec.exp -- Check reset of the tracked threads on exec*(2)
++# Copyright (C) 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. */
++
++# Please email any bugs, comments, and/or additions to this file to:
++# bug-gdb@prep.ai.mit.edu
++
++set testfile threaded-exec
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++
++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++
++gdb_load ${binfile}
++
++gdb_run_cmd
++
++gdb_test_multiple {} "Program exited" {
++ -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {
++ pass "Program exited"
++ }
++}
diff --git a/gdb-6.3-focus-cmd-prev-test.patch b/gdb-6.3-focus-cmd-prev-test.patch
new file mode 100644
index 0000000..27c85f1
--- /dev/null
+++ b/gdb-6.3-focus-cmd-prev-test.patch
@@ -0,0 +1,53 @@
+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
++++ b/gdb/testsuite/gdb.base/focus-cmd-prev.exp
+@@ -0,0 +1,40 @@
++# 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.
++
++if $tracelevel then {
++ strace $tracelevel
++}
++
++gdb_exit
++gdb_start
++
++# Do not use gdb_test or \r\n there since:
++# commit d7e747318f4d04af033f16325f9b6d74f67079ec
++# Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
++
++set test "focus cmd"
++gdb_test_multiple $test $test {
++ -re "$gdb_prompt $" {
++ pass $test
++ }
++}
++
++set test "focus prev"
++gdb_test_multiple $test $test {
++ -re "$gdb_prompt $" {
++ pass $test
++ }
++}
diff --git a/gdb-6.3-gstack-20050411.patch b/gdb-6.3-gstack-20050411.patch
new file mode 100644
index 0000000..982863a
--- /dev/null
+++ b/gdb-6.3-gstack-20050411.patch
@@ -0,0 +1,258 @@
+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
+ install: all
+ @$(MAKE) $(FLAGS_TO_PASS) install-only
+
+-install-only: $(CONFIG_INSTALL)
++install-only: install-gstack $(CONFIG_INSTALL)
+ transformed_name=`t='$(program_transform_name)'; \
+ echo gdb | sed -e "$$t"` ; \
+ if test "x$$transformed_name" = x; then \
+@@ -1817,7 +1817,25 @@ install-guile:
+ install-python:
+ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
+
+-uninstall: force $(CONFIG_UNINSTALL)
++GSTACK=gstack
++.PHONY: install-gstack
++install-gstack:
++ transformed_name=`t='$(program_transform_name)'; \
++ echo $(GSTACK) | sed -e "$$t"` ; \
++ if test "x$$transformed_name" = x; then \
++ transformed_name=$(GSTACK) ; \
++ else \
++ true ; \
++ fi ; \
++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
++ $(INSTALL_PROGRAM) $(srcdir)/$(GSTACK).sh \
++ $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
++ : $(SHELL) $(srcdir)/../mkinstalldirs \
++ $(DESTDIR)$(man1dir) ; \
++ : $(INSTALL_DATA) $(srcdir)/gstack.1 \
++ $(DESTDIR)$(man1dir)/$$transformed_name.1
++
++uninstall: force uninstall-gstack $(CONFIG_UNINSTALL)
+ 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)
+ fi
+ @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
++.PHONY: uninstall-gstack
++uninstall-gstack:
++ transformed_name=`t='$(program_transform_name)'; \
++ echo $(GSTACK) | sed -e $$t` ; \
++ if test "x$$transformed_name" = x; then \
++ transformed_name=$(GSTACK) ; \
++ else \
++ true ; \
++ 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
+diff --git a/gdb/gstack.sh b/gdb/gstack.sh
+new file mode 100644
+--- /dev/null
++++ b/gdb/gstack.sh
+@@ -0,0 +1,43 @@
++#!/bin/sh
++
++if test $# -ne 1; then
++ echo "Usage: `basename $0 .sh` " 1>&2
++ exit 1
++fi
++
++if test ! -r /proc/$1; then
++ echo "Process $1 not found." 1>&2
++ exit 1
++fi
++
++# GDB doesn't allow "thread apply all bt" when the process isn't
++# threaded; need to peek at the process to determine if that or the
++# simpler "bt" should be used.
++
++backtrace="bt"
++if test -d /proc/$1/task ; then
++ # Newer kernel; has a task/ directory.
++ if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then
++ backtrace="thread apply all bt"
++ fi
++elif test -f /proc/$1/maps ; then
++ # Older kernel; go by it loading libpthread.
++ if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then
++ backtrace="thread apply all bt"
++ fi
++fi
++
++GDB=${GDB:-gdb}
++
++# 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 |
++set width 0
++set height 0
++set pagination no
++$backtrace
++EOF
++/bin/sed -n \
++ -e 's/^\((gdb) \)*//' \
++ -e '/^#/p' \
++ -e '/^Thread/p'
+diff --git a/gdb/testsuite/gdb.base/gstack.c b/gdb/testsuite/gdb.base/gstack.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gstack.c
+@@ -0,0 +1,43 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2005, 2007, 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
++#include
++#include
++
++void
++func (void)
++{
++ const char msg[] = "looping\n";
++
++ /* Use the most simple notification not to get caught by attach on exiting
++ the function. */
++ write (1, msg, strlen (msg));
++
++ for (;;);
++}
++
++int
++main (void)
++{
++ alarm (60);
++ nice (100);
++
++ func ();
++
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/gstack.exp b/gdb/testsuite/gdb.base/gstack.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gstack.exp
+@@ -0,0 +1,84 @@
++# Copyright (C) 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 .
++
++set testfile gstack
++set executable ${testfile}
++set binfile [standard_output_file $executable]
++if {[build_executable ${testfile} ${executable} "" {debug}] == -1} {
++ return -1
++}
++
++set test "spawn inferior"
++set command "${binfile}"
++set res [remote_spawn host $command];
++if { $res < 0 || $res == "" } {
++ perror "Spawning $command failed."
++ fail $test
++ return
++}
++
++# The spawn id of the test inferior.
++set test_spawn_id $res
++
++set use_gdb_stub 1
++set pid [exp_pid -i $res]
++gdb_expect {
++ -re "looping\r\n" {
++ pass $test
++ }
++ eof {
++ fail "$test (eof)"
++ return
++ }
++ timeout {
++ fail "$test (timeout)"
++ return
++ }
++}
++
++# Testcase uses the most simple notification not to get caught by attach on
++# exiting the function. Still we could retry the gstack command if we fail.
++
++set test "spawn gstack"
++set command "sh -c GDB=$GDB\\ GDBARGS=-data-directory\\\\\\ $BUILD_DATA_DIRECTORY\\ sh\\ ${srcdir}/../gstack.sh\\ $pid\\;echo\\ GSTACK-END"
++set res [remote_spawn host $command];
++if { $res < 0 || $res == "" } {
++ perror "Spawning $command failed."
++ fail $test
++}
++
++set gdb_spawn_id $res
++
++gdb_test_multiple "" $test {
++ -re "^#0 +(0x\[0-9a-f\]+ in )?\\.?func \\(\\) at \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in \\.?main \\(\\) at \[^\r\n\]*\r\nGSTACK-END\r\n\$" {
++ pass $test
++ }
++}
++
++gdb_test_multiple "" "gstack exits" {
++ eof {
++ set result [wait -i $gdb_spawn_id]
++ verbose $result
++
++ gdb_assert { [lindex $result 2] == 0 } "gstack exits with no error"
++ gdb_assert { [lindex $result 3] == 0 } "gstack's exit status is 0"
++
++ remote_close host
++ clear_gdb_spawn_id
++ }
++}
++
++# Kill the test inferior.
++kill_wait_spawned_process $test_spawn_id
diff --git a/gdb-6.3-inferior-notification-20050721.patch b/gdb-6.3-inferior-notification-20050721.patch
new file mode 100644
index 0000000..d09fe1e
--- /dev/null
+++ b/gdb-6.3-inferior-notification-20050721.patch
@@ -0,0 +1,323 @@
+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
++++ b/gdb/testsuite/gdb.base/attach-32.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.base/attach-32.exp b/gdb/testsuite/gdb.base/attach-32.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/attach-32.exp
+@@ -0,0 +1,245 @@
++# 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.
++#
++# This test was based on attach.exp and modified for 32/64 bit Linux systems. */
++
++# 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 "x86_64*-*linux*"]
++ && ![istarget "powerpc64*-*linux*"]} {
++ return 0
++}
++
++# are we on a target board
++if [is_remote target] then {
++ return 0
++}
++
++set testfile "attach-32"
++set srcfile ${testfile}.c
++set srcfile2 ${testfile}b.c
++set binfile [standard_output_file ${testfile}]
++set binfile2 [standard_output_file ${testfile}b]
++set escapedbinfile [string_to_regexp [standard_output_file ${testfile}]]
++
++#execute_anywhere "rm -f ${binfile} ${binfile2}"
++remote_exec build "rm -f ${binfile} ${binfile2}"
++# For debugging this test
++#
++#log_user 1
++
++# build the first test case
++#
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-m32"]] != "" } {
++ 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 [list debug "additional_flags=-m32"]] != "" } {
++ 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 objdir
++ 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
++ # program.
++
++ gdb_test "set should_exit=1" "" "after attach-32, 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 attach-32, set tbreak postloop"
++ }
++ -re "$gdb_prompt $" {
++ fail "after attach-32, set tbreak postloop"
++ }
++ timeout {
++ fail "(timeout) after attach-32, set tbreak postloop"
++ }
++ }
++ send_gdb "continue\n"
++ gdb_expect {
++ -re "main.*at.*$srcfile:19.*$gdb_prompt $" {
++ pass "after attach-32, reach tbreak postloop"
++ }
++ -re "$gdb_prompt $" {
++ fail "after attach-32, reach tbreak postloop"
++ }
++ timeout {
++ fail "(timeout) after attach-32, reach tbreak postloop"
++ }
++ }
++
++ # Allow the test process to exit, to cleanup after ourselves.
++
++ gdb_test "continue" {\[Inferior .* exited normally\]} "after attach-32, 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
++ if { [istarget "*-*-cygwin*"] } {
++ # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
++ # different due to the way fork/exec works.
++ set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
++ }
++
++ # 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"
++
++ gdb_test "cd /tmp" "Working directory /tmp." \
++ "cd away from process working directory"
++
++ # Explicitly flush out any knowledge of the previous attachment.
++
++ set test "before attach-32-3, flush symbols"
++ gdb_test_multiple "symbol" "$test" {
++ -re "Discard symbol table from.*y or n. $" {
++ gdb_test "y" "No symbol file now." \
++ "$test"
++ }
++ -re "No symbol file now.*$gdb_prompt $" {
++ pass "$test"
++ }
++ }
++
++ gdb_test "exec" "No executable file now." \
++ "before attach-32-3, flush exec"
++
++ gdb_test "attach $testpid" \
++ "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*" \
++ "attach-32 when process' a.out not in cwd"
++
++ set test "after attach-32-3, exit"
++ gdb_test_multiple "kill" "$test" {
++ -re "Kill the program being debugged.*y or n. $" {
++ gdb_test "y" "" "$test"
++ }
++ }
++
++ # Another "don't leave a process around"
++ remote_exec build "kill -9 ${testpid}"
++}
++
++proc do_call_attach_tests {} {
++ 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 $" {
++ fail "$test"
++ }
++ -re "r3.*$gdb_prompt $" {
++ pass "$test"
++ }
++ }
++
++ # 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
++set testpid [eval exec $binfile &]
++exec sleep 3
++if { [istarget "*-*-cygwin*"] } {
++ # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
++ # different due to the way fork/exec works.
++ set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
++}
++
++set GDBFLAGS_orig $GDBFLAGS
++set GDBFLAGS "-iex \"set height 0\" --pid=$testpid"
++gdb_start
++set GDBFLAGS $GDBFLAGS_orig
++
++gdb_reinitialize_dir $srcdir/$subdir
++
++# 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
++set testpid [eval exec $binfile2 &]
++exec sleep 3
++if { [istarget "*-*-cygwin*"] } {
++ # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
++ # different due to the way fork/exec works.
++ set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
++}
++
++set GDBFLAGS_orig $GDBFLAGS
++set GDBFLAGS "-iex \"set height 0\" --pid=$testpid"
++gdb_start
++set GDBFLAGS $GDBFLAGS_orig
++
++gdb_reinitialize_dir $srcdir/$subdir
++do_call_attach_tests
++
++return 0
+diff --git a/gdb/testsuite/gdb.base/attach-32b.c b/gdb/testsuite/gdb.base/attach-32b.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/attach-32b.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-6.3-inheritancetest-20050726.patch b/gdb-6.3-inheritancetest-20050726.patch
new file mode 100644
index 0000000..6b22011
--- /dev/null
+++ b/gdb-6.3-inheritancetest-20050726.patch
@@ -0,0 +1,161 @@
+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 @@
++#include "b146835.h"
++#include
++
++class F : public C {
++
++protected:
++
++ virtual void funcA (unsigned long a, B *b);
++ virtual void funcB (E *e);
++ virtual void funcC (unsigned long x, bool y);
++
++ char *s1, *s2;
++ bool b1;
++ int k;
++
++public:
++ void foo() {
++ std::cout << "foo" << std::endl;
++ }
++};
++
++
++void F::funcA (unsigned long a, B *b) {}
++void F::funcB (E *e) {}
++void F::funcC (unsigned long x, bool y) {}
++
++int main()
++{
++ 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
++++ b/gdb/testsuite/gdb.cp/b146835.exp
+@@ -0,0 +1,47 @@
++# This testcase is part of GDB, the GNU debugger.
++
++# 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.
++
++# Check that GDB can properly print an inherited member variable
++# (Bugzilla 146835)
++
++set testfile "b146835"
++set srcfile ${testfile}.cc
++set srcfile2 ${testfile}b.cc
++set binfile [standard_output_file ${testfile}]
++if {[gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" "${binfile}" executable {debug c++}] != "" } {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++#
++# Run to `main' where we begin our tests.
++#
++
++if ![runto_main] then {
++ gdb_suppress_tests
++}
++
++gdb_test "break 'F::foo()'" ""
++gdb_continue_to_breakpoint "First line foo"
++
++# Verify that we can access the inherited member d
++gdb_test "p d" " = \\(D \\*\\) *0x0" "Verify inherited member d accessible"
+diff --git a/gdb/testsuite/gdb.cp/b146835.h b/gdb/testsuite/gdb.cp/b146835.h
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.cp/b146835.h
+@@ -0,0 +1,36 @@
++
++class A {
++
++protected:
++
++ virtual void funcA (unsigned long a, class B *b) = 0;
++ virtual void funcB (class E *e) = 0;
++ virtual void funcC (unsigned long x, bool y) = 0;
++
++ void funcD (class E *e, class D* d);
++ virtual void funcE (E *e, D *d);
++ virtual void funcF (unsigned long x, D *d);
++};
++
++
++class C : public A {
++
++protected:
++
++ int x;
++ class K *k;
++ class H *h;
++
++ D *d;
++
++ class W *w;
++ class N *n;
++ class L *l;
++ unsigned long *r;
++
++public:
++
++ C();
++ int z (char *s);
++ virtual ~C();
++};
+diff --git a/gdb/testsuite/gdb.cp/b146835b.cc b/gdb/testsuite/gdb.cp/b146835b.cc
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.cp/b146835b.cc
+@@ -0,0 +1,11 @@
++#include "b146835.h"
++
++C::C() { d = 0; x = 3; }
++
++int C::z (char *s) { return 0; }
++
++C::~C() {}
++
++void A::funcD (class E *e, class D *d) {}
++void A::funcE (E *e, D *d) {}
++void A::funcF (unsigned long x, D *d) {}
diff --git a/gdb-6.3-mapping-zero-inode-test.patch b/gdb-6.3-mapping-zero-inode-test.patch
new file mode 100644
index 0000000..1ef25d9
--- /dev/null
+++ b/gdb-6.3-mapping-zero-inode-test.patch
@@ -0,0 +1,247 @@
+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
++++ b/gdb/testsuite/gdb.base/gcore-shmid0.c
+@@ -0,0 +1,128 @@
++/* Copyright 2007, 2009 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or (at
++ your option) any later version.
++
++ This program is distributed in the hope that it will be useful, but
++ WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place - Suite 330,
++ Boston, MA 02111-1307, USA. */
++
++/*
++ * Test GDB's handling of gcore for mapping with a name but zero inode.
++ */
++
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++
++/* The same test running in a parallel testsuite may steal us the zero SID,
++ even if we never get any EEXIST. Just try a while. */
++
++#define TIMEOUT_SEC 10
++
++static volatile int v;
++
++static void
++initialized (void)
++{
++ v++;
++}
++
++static void
++unresolved (void)
++{
++ v++;
++}
++
++int
++main (void)
++{
++ int sid;
++ unsigned int *addr = (void *) -1L;
++ int attempt, round = 0;
++ time_t ts_start, ts;
++
++ if (time (&ts_start) == (time_t) -1)
++ {
++ printf ("time (): %m\n");
++ exit (1);
++ }
++
++ /* The generated SID will cycle with an increment of 32768, attempt until it
++ * wraps to 0. */
++
++ for (attempt = 0; addr == (void *) -1L; attempt++)
++ {
++ /* kernel-2.6.25-8.fc9.x86_64 just never returns the value 0 by
++ shmget(2). shmget returns SID range 0..1<<31 in steps of 32768,
++ 0x1000 should be enough but wrap the range it to be sure. */
++
++ if (attempt > 0x21000)
++ {
++ if (time (&ts) == (time_t) -1)
++ {
++ printf ("time (): %m\n");
++ exit (1);
++ }
++
++ if (ts >= ts_start && ts < ts_start + TIMEOUT_SEC)
++ {
++ attempt = 0;
++ round++;
++ continue;
++ }
++
++ printf ("Problem is not reproducible on this kernel (attempt %d, "
++ "round %d)\n", attempt, round);
++ unresolved ();
++ exit (1);
++ }
++
++ sid = shmget ((key_t) rand (), 0x1000, IPC_CREAT | IPC_EXCL | 0777);
++ if (sid == -1)
++ {
++ if (errno == EEXIST)
++ continue;
++
++ printf ("shmget (%d, 0x1000, IPC_CREAT): errno %d\n", 0, errno);
++ exit (1);
++ }
++
++ /* Use SID only if it is 0, retry it otherwise. */
++
++ if (sid == 0)
++ {
++ addr = shmat (sid, NULL, SHM_RND);
++ if (addr == (void *) -1L)
++ {
++ printf ("shmat (%d, NULL, SHM_RND): errno %d\n", sid,
++ errno);
++ exit (1);
++ }
++ }
++ if (shmctl (sid, IPC_RMID, NULL) != 0)
++ {
++ printf ("shmctl (%d, IPC_RMID, NULL): errno %d\n", sid, errno);
++ exit (1);
++ }
++ }
++
++ initialized ();
++
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/gcore-shmid0.exp b/gdb/testsuite/gdb.base/gcore-shmid0.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-shmid0.exp
+@@ -0,0 +1,101 @@
++# Copyright 2007, 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.
++
++# Test GDB's handling of gcore for mapping with a name but zero inode.
++
++if { [prepare_for_testing gcore-shmid0.exp gcore-shmid0] } {
++ return -1
++}
++
++# Does this gdb support gcore?
++set test "help gcore"
++gdb_test_multiple $test $test {
++ -re "Undefined command: .gcore.*$gdb_prompt $" {
++ # gcore command not supported -- nothing to test here.
++ unsupported "gdb does not support gcore on this target"
++ return -1;
++ }
++ -re "Save a core file .*$gdb_prompt $" {
++ pass $test
++ }
++}
++
++if { ! [ runto_main ] } then {
++ untested gcore-shmid0.exp
++ return -1
++}
++
++gdb_breakpoint "initialized"
++gdb_breakpoint "unresolved"
++
++set oldtimeout $timeout
++set timeout [expr $oldtimeout + 120]
++
++set test "Continue to initialized."
++gdb_test_multiple "continue" $test {
++ -re "Breakpoint .*, initialized .* at .*\r\n$gdb_prompt $" {
++ pass $test
++ }
++ -re "Breakpoint .*, unresolved .* at .*\r\n$gdb_prompt $" {
++ set timeout $oldtimeout
++ unsupported $test
++ return -1
++ }
++}
++set timeout $oldtimeout
++
++set escapedfilename [string_to_regexp [standard_output_file gcore-shmid0.test]]
++
++set test "save a corefile"
++gdb_test_multiple "gcore [standard_output_file gcore-shmid0.test]" $test {
++ -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
++ pass $test
++ }
++ -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
++ unsupported $test
++ }
++}
++
++# Be sure to remove the handle first.
++# But it would get removed even on a kill by GDB as the handle is already
++# deleted, just it is still attached.
++gdb_continue_to_end "finish"
++
++set test "core-file command"
++gdb_test_multiple "core-file [standard_output_file gcore-shmid0.test]" $test {
++ -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 .*\r\n\#0 .*\\\(\\\).*\r\n$gdb_prompt $" {
++ # The filename does not fit there anyway so do not check it.
++ pass $test
++ }
++ -re ".*registers from core file: File in wrong format.* $" {
++ fail "core-file command (could not read registers from core file)"
++ }
++}
++
++set test "backtrace"
++gdb_test_multiple "bt" $test {
++ -re "#0 *initialized \\\(\\\) at .*#1 .* main \\\(.*$gdb_prompt $" {
++ pass $test
++ }
++ -re "#0 *initialized \\\(\\\) at .*Cannot access memory at address .*$gdb_prompt $" {
++ fail $test
++ }
++}
diff --git a/gdb-6.3-rh-testversion-20041202.patch b/gdb-6.3-rh-testversion-20041202.patch
new file mode 100644
index 0000000..48ca4b5
--- /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
+@@ -2096,7 +2096,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
new file mode 100644
index 0000000..6586303
--- /dev/null
+++ b/gdb-6.3-test-dtorfix-20050121.patch
@@ -0,0 +1,247 @@
+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
++++ b/gdb/testsuite/gdb.cp/constructortest.cc
+@@ -0,0 +1,99 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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. */
++
++class A
++{
++ public:
++ A();
++ ~A();
++ int k;
++ private:
++ int x;
++};
++
++class B: public A
++{
++ public:
++ B();
++ private:
++ int y;
++};
++
++/* C and D are for the $delete destructor. */
++
++class C
++{
++ public:
++ C();
++ virtual ~C();
++ private:
++ int x;
++};
++
++class D: public C
++{
++ public:
++ D();
++ private:
++ int y;
++};
++
++int main(int argc, char *argv[])
++{
++ A* a = new A;
++ B* b = new B;
++ D* d = new D;
++ delete a;
++ delete b;
++ delete d;
++ return 0;
++}
++
++A::A() /* Constructor A */
++{
++ x = 1; /* First line A */
++ k = 4; /* Second line A */
++}
++
++A::~A() /* Destructor A */
++{
++ x = 3; /* First line ~A */
++ k = 6; /* Second line ~A */
++}
++
++B::B()
++{
++ y = 2; /* First line B */
++ k = 5;
++}
++
++C::C() /* Constructor C */
++{
++ x = 1; /* First line C */
++}
++
++C::~C() /* Destructor C */
++{
++ x = 3; /* First line ~C */
++}
++
++D::D()
++{
++ y = 2; /* First line D */
++}
+diff --git a/gdb/testsuite/gdb.cp/constructortest.exp b/gdb/testsuite/gdb.cp/constructortest.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.cp/constructortest.exp
+@@ -0,0 +1,130 @@
++# This testcase is part of GDB, the GNU debugger.
++
++# Copyright 2005, 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.
++
++# Check that GDB can break at multiple forms of constructors.
++
++set testfile "constructortest"
++set srcfile ${testfile}.cc
++set binfile [standard_output_file ${testfile}]
++# PIE is required for testing proper BREAKPOINT_RE_SET of the multiple-PC
++# breakpoints.
++if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ "additional_flags=-fpie -pie"}] != "" } {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++#
++# Run to `main' where we begin our tests.
++#
++
++if ![runto_main] then {
++ gdb_suppress_tests
++}
++
++# 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"
++gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A"
++gdb_continue_to_breakpoint "First line A"
++gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A"
++
++# Now do the same for destructors
++gdb_test "break 'A::~A()'" ""
++
++# Verify that we break for the A destructor two times
++# Once for delete a and once for delete b
++gdb_continue_to_breakpoint "First line ~A"
++gdb_test "bt" "#0.*~A.*#1.*main.*" "Verify in in-charge A::~A"
++gdb_continue_to_breakpoint "First line ~A"
++gdb_test "bt" "#0.*~A.*#1.*~B.*#2.*main.*" "Verify in not-in-charge A::~A"
++
++
++# Verify that we can break by line number in a constructor and find
++# both occurrences
++runto_main
++gdb_test "break 'A::A()'" "" "break in constructor A 2"
++gdb_continue_to_breakpoint "First line A"
++set second_line [gdb_get_line_number "Second line A"]
++# " (2 locations)" is displayed depending on G++ version.
++gdb_test "break $second_line" "Breakpoint .*, line $second_line\\..*" "break by line in constructor"
++gdb_continue_to_breakpoint "Second line A"
++gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A second line"
++gdb_continue_to_breakpoint "Second line A"
++gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A second line"
++
++# Verify that we can break by line number in a destructor and find
++# both occurrences
++gdb_test "break 'A::~A()'" "" "break in constructor ~A 2"
++gdb_continue_to_breakpoint "First line ~A"
++set second_line_dtor [gdb_get_line_number "Second line ~A"]
++# " (2 locations)" is displayed depending on G++ version.
++gdb_test "break $second_line_dtor" "Breakpoint .*, line $second_line_dtor\\..*" "break by line in destructor"
++gdb_continue_to_breakpoint "Second line ~A"
++gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::~A second line"
++# FIXME: Analyse this case better.
++gdb_continue_to_breakpoint "Second line ~A"
++gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in A::~A second line #2"
++gdb_continue_to_breakpoint "Second line ~A"
++gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::~A second line"
++
++
++# Test now the $delete destructors.
++
++gdb_load ${binfile}
++runto_main
++
++set first_line_dtor [gdb_get_line_number "First line ~C"]
++set define_line_dtor [gdb_get_line_number "Destructor C"]
++# Break on the various forms of the C::~C destructor
++# " ([23] locations)" is displayed depending on G++ version.
++gdb_test "break C\:\:~C" "Breakpoint .*: C::~C\\. \\(2 locations\\)" "breaking on C::~C"
++gdb_continue_to_breakpoint "First line ~C"
++
++# Verify that we can break by line number in a destructor and find
++# the $delete occurence
++
++gdb_load ${binfile}
++delete_breakpoints
++
++# " (3 locations)" is displayed depending on G++ version.
++gdb_test "break $first_line_dtor" "Breakpoint .*, line $first_line_dtor\\..*" "break by line in destructor"
++
++# Run to `main' where we begin our tests.
++# Set the breakpoints first to test PIE multiple-PC BREAKPOINT_RE_SET.
++# RUNTO_MAIN or RUNTO MAIN are not usable here as it runs DELETE_BREAKPOINTS.
++
++if ![gdb_breakpoint main] {
++ gdb_suppress_tests
++}
++gdb_run_cmd
++set test "running to main"
++gdb_test_multiple "" $test {
++ -re "Breakpoint \[0-9\]*, main .*$gdb_prompt $" {
++ pass $test
++ }
++}
++
++gdb_continue_to_breakpoint "First line ~C"
diff --git a/gdb-6.3-test-movedir-20050125.patch b/gdb-6.3-test-movedir-20050125.patch
new file mode 100644
index 0000000..bcce9fa
--- /dev/null
+++ b/gdb-6.3-test-movedir-20050125.patch
@@ -0,0 +1,103 @@
+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 @@
++#include
++#include
++#include "move-dir.h"
++
++int main() {
++ const char* hw = "hello world.";
++ 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
++++ b/gdb/testsuite/gdb.base/move-dir.exp
+@@ -0,0 +1,57 @@
++# 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.
++
++set testfile "move-dir"
++set srcfile ${testfile}.c
++set incfile ${testfile}.h
++set binfile [standard_output_file ${testfile}]
++
++set testdir [standard_output_file incdir]
++
++remote_exec build "mkdir $testdir"
++remote_exec build "cp ${srcdir}/${subdir}/${srcfile} [standard_output_file ${srcfile}]"
++remote_exec build "cp ${srcdir}/${subdir}/${incfile} [standard_output_file ${incfile}]"
++
++set additional_flags "additional_flags=-I${subdir}/incdir"
++
++if { [gdb_compile [standard_output_file ${srcfile}] "${binfile}" executable [list debug $additional_flags]] != "" } {
++ 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;
++}
++
++
++set oldtimeout $timeout
++set timeout [expr "$timeout + 60"]
++
++# Start with a fresh gdb.
++
++gdb_exit
++gdb_start
++gdb_test "cd ../.." "" ""
++gdb_load ${binfile}
++gdb_test "list main" ".*hw.*other.*" "found main"
++gdb_test "list other" ".*ostring.*" "found include file"
++
++
++set timeout $oldtimeout
++return 0
+diff --git a/gdb/testsuite/gdb.base/move-dir.h b/gdb/testsuite/gdb.base/move-dir.h
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/move-dir.h
+@@ -0,0 +1,7 @@
++#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
new file mode 100644
index 0000000..85f133b
--- /dev/null
+++ b/gdb-6.3-test-pie-20050107.patch
@@ -0,0 +1,2027 @@
+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-pie-20050107.patch
+
+;; VSYSCALL and PIE
+;;=fedoratest
+
+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
new file mode 100644
index 0000000..5662a0e
--- /dev/null
+++ b/gdb-6.3-test-self-20050110.patch
@@ -0,0 +1,42 @@
+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-self-20050110.patch
+
+;; Get selftest working with sep-debug-info
+;;=fedoratest
+
+2004-02-23 Elena Zannoni
+
+ * gdb.gdb/selftest.exp: Make sure that the debug directory is
+ set up properly.
+ * gdb.gdb/complaints.exp: Ditto.
+ * gdb.gdb/xfullpath.exp: Ditto.
+ * gdb.gdb/observer.exp: Ditto.
+
+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
new file mode 100644
index 0000000..42b89bf
--- /dev/null
+++ b/gdb-6.3-threaded-watchpoints2-20050225.patch
@@ -0,0 +1,254 @@
+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 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2002, 2003, 2004, 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.
++
++ This file is copied from schedlock.c. */
++
++#include
++#include
++#include
++#include
++
++void *thread_function(void *arg); /* Pointer to function executed by each thread */
++
++#define NUM 5
++
++unsigned int args[NUM+1];
++
++int main() {
++ int res;
++ pthread_t threads[NUM];
++ void *thread_result;
++ long i;
++
++ for (i = 0; i < NUM; i++)
++ {
++ args[i] = 1; /* Init value. */
++ res = pthread_create(&threads[i],
++ NULL,
++ thread_function,
++ (void *) i);
++ }
++
++ args[i] = 1;
++ thread_function ((void *) i);
++
++ exit(EXIT_SUCCESS);
++}
++
++void *thread_function(void *arg) {
++ int my_number = (long) arg;
++ int *myp = (int *) &args[my_number];
++
++ /* Don't run forever. Run just short of it :) */
++ while (*myp > 0)
++ {
++ (*myp) ++; usleep (1); /* Loop increment. */
++ }
++
++ 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
++++ b/gdb/testsuite/gdb.threads/watchthreads-threaded.exp
+@@ -0,0 +1,126 @@
++# This testcase is part of GDB, the GNU debugger.
++
++# 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.
++
++# Check that GDB can support multiple watchpoints across threads.
++
++# This test verifies that a watchpoint is detected in the proper thread
++# so the test is only meaningful on a system with hardware watchpoints.
++if [target_info exists gdb,no_hardware_watchpoints] {
++ return 0;
++}
++
++set testfile "watchthreads-threaded"
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++gdb_test "set can-use-hw-watchpoints 1" "" ""
++
++#
++# Run to `main' where we begin our tests.
++#
++
++if ![runto_main] then {
++ gdb_suppress_tests
++}
++
++set args_2 0
++set args_3 0
++
++gdb_breakpoint "thread_function"
++gdb_continue_to_breakpoint "thread_function"
++gdb_test "disable 2" ""
++
++gdb_test_multiple "p args\[2\]" "get initial args2" {
++ -re "\\\$\[0-9\]* = (.*)$gdb_prompt $" {
++ set init_args_2 $expect_out(1,string)
++ pass "get initial args2"
++ }
++}
++
++gdb_test_multiple "p args\[3\]" "get initial args3" {
++ -re "\\\$\[0-9\]* = (.*)$gdb_prompt $" {
++ set init_args_3 $expect_out(1,string)
++ pass "get initial args3"
++ }
++}
++
++set args_2 $init_args_2
++set args_3 $init_args_3
++
++# Watch values that will be modified by distinct threads.
++gdb_test "watch args\[2\]" "Hardware watchpoint 3: args\\\[2\\\]"
++gdb_test "watch args\[3\]" "Hardware watchpoint 4: args\\\[3\\\]"
++
++set init_line [expr [gdb_get_line_number "Init value"]+1]
++set inc_line [gdb_get_line_number "Loop increment"]
++
++# Loop and continue to allow both watchpoints to be triggered.
++for {set i 0} {$i < 30} {incr i} {
++ set test_flag 0
++ gdb_test_multiple "continue" "threaded watch loop" {
++ -re "Hardware watchpoint 3: args\\\[2\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*watchthreads-threaded.c:$init_line.*$gdb_prompt $"
++ { 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 $"
++ { 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 $"
++ { set args_3 [expr $args_3+1]; set test_flag 1 }
++ }
++ # If we fail above, don't bother continuing loop
++ if { $test_flag == 0 } {
++ set i 30;
++ }
++}
++
++# Print success message if loop succeeded.
++if { $test_flag == 1 } {
++ pass "threaded watch loop"
++}
++
++# Verify that we hit first watchpoint in child thread.
++set message "watchpoint on args\[2\] hit in thread"
++if { $args_2 > 1 } {
++ pass $message
++} else {
++ fail $message
++}
++
++# Verify that we hit second watchpoint in child thread.
++set message "watchpoint on args\[3\] hit in thread"
++if { $args_3 > 1 } {
++ pass $message
++} else {
++ 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
++} else {
++ fail $message
++}
diff --git a/gdb-6.5-BEA-testsuite.patch b/gdb-6.5-BEA-testsuite.patch
new file mode 100644
index 0000000..84e1c9f
--- /dev/null
+++ b/gdb-6.5-BEA-testsuite.patch
@@ -0,0 +1,938 @@
+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
++++ b/gdb/testsuite/gdb.threads/threadcrash.c
+@@ -0,0 +1,301 @@
++/*
++ * The point of this program is to crash in a multi-threaded app.
++ * There are seven threads, doing the following things:
++ * * Spinning
++ * * Spinning inside a signal handler
++ * * Spinning inside a signal handler executing on the altstack
++ * * In a syscall
++ * * In a syscall inside a signal handler
++ * * In a syscall inside a signal handler executing on the altstack
++ * * Finally, the main thread crashes in main, with no frills.
++ *
++ * These are the things threads in JRockit tend to be doing. If gdb
++ * can handle those things, both in core files and during live
++ * debugging, that will help (at least) JRockit development.
++ *
++ * Let the program create a core file, then load the core file into
++ * 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
++ * #2 0x0804898f in syscallingSighandler (signo=10, info=0xb6be76f0, context=0xb6be7770)
++ * at threadcrash.c:168
++ * #3
++ * #4 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
++ * #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
++ * #2 0x08048936 in syscallingAltSighandler (signo=3, info=0x959cd70, context=0x959cdf0)
++ * at threadcrash.c:144
++ * #3
++ * #4 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
++ * #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
++ * #2 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
++ * #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
++ * #2 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
++ * #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)
++ */
++
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++
++#define SIGSYSCALL_ALT SIGQUIT
++#define SIGSYSCALL SIGUSR1
++#define SIGSPIN_ALT SIGALRM
++#define SIGSPIN SIGUSR2
++
++typedef void (*sigaction_t)(int, siginfo_t *, void *);
++
++static void installHandler(int signo, sigaction_t handler, int onAltstack) {
++ struct sigaction action;
++ sigset_t sigset;
++ 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);
++ altstack.ss_size = SIGSTKSZ;
++ altstack.ss_flags = 0;
++ result = sigaltstack(&altstack, &oldaltstack);
++ assert(result == 0);
++ assert(oldaltstack.ss_flags == SS_DISABLE);
++ }
++
++ sigemptyset(&sigset);
++
++ action.sa_handler = NULL;
++ action.sa_sigaction = handler;
++ action.sa_mask = sigset;
++ action.sa_flags = SA_SIGINFO;
++ if (onAltstack) {
++ action.sa_flags |= SA_ONSTACK;
++ }
++
++ result = sigaction(signo, &action, NULL);
++ assert(result == 0);
++}
++
++static void installNormalHandler(int signo, sigaction_t handler) {
++ installHandler(signo, handler, 0);
++}
++
++static void installAlthandler(int signo, sigaction_t handler) {
++ installHandler(signo, handler, 1);
++}
++
++static void *makeSyscall(void *ignored) {
++ (void)ignored;
++
++ sleep(42);
++
++ fprintf(stderr, "%s: returning\n", __FUNCTION__);
++ return NULL;
++}
++
++/* Return true if we're currently executing on the altstack */
++static int onAltstack(void) {
++ stack_t stack;
++ int result;
++
++ result = sigaltstack(NULL, &stack);
++ assert(result == 0);
++
++ return stack.ss_flags & SS_ONSTACK;
++}
++
++static void syscallingAltSighandler(int signo, siginfo_t *info, void *context) {
++ (void)signo;
++ (void)info;
++ (void)context;
++
++ if (!onAltstack()) {
++ printf("%s() not running on altstack!\n", __FUNCTION__);
++ }
++
++ sleep(42);
++}
++
++static void spinningAltSighandler(int signo, siginfo_t *info, void *context) {
++ (void)signo;
++ (void)info;
++ (void)context;
++
++ if (!onAltstack()) {
++ printf("%s() not running on altstack!\n", __FUNCTION__);
++ }
++
++ while (1);
++}
++
++static void syscallingSighandler(int signo, siginfo_t *info, void *context) {
++ (void)signo;
++ (void)info;
++ (void)context;
++
++ if (onAltstack()) {
++ printf("%s() running on altstack!\n", __FUNCTION__);
++ }
++
++ sleep(42);
++}
++
++static void spinningSighandler(int signo, siginfo_t *info, void *context) {
++ (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__);
++ return NULL;
++}
++
++int main(int argc, char *argv[]) {
++ 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);
++ assert(result == 0);
++ result = pthread_create(&thread, NULL, makeSyscallFromAltSighandler, NULL);
++ assert(result == 0);
++ result = pthread_create(&thread, NULL, spin, NULL);
++ assert(result == 0);
++ result = pthread_create(&thread, NULL, spinFromSighandler, NULL);
++ 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;
++
++ /* Workaround: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29628
++ Simulate use to ensure `DW_AT_location' for them:
++ readelf -a --debug threadcrash|grep -A5 -w argc
++ --> DW_AT_location : 2 byte block: 71 0 (DW_OP_breg1: 0)
++ This case verified on: gcc-4.1.1-30.i386
++ 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
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.threads/threadcrash.exp
+@@ -0,0 +1,37 @@
++# threadcrash.exp - The point of this program is to crash in a multi-threaded app.
++
++
++set testfile threadcrash
++set srcfile ${testfile}.c
++set shellfile ${srcdir}/${subdir}/${testfile}.sh
++set binfile [standard_output_file ${testfile}]
++
++set GDB_abs ${GDB}
++if [regexp "^\[^/\]" ${GDB_abs}] {
++ set GDB_abs $env(PWD)/${GDB_abs}
++}
++
++if [istarget "*-*-linux"] then {
++ set target_cflags "-D_MIT_POSIX_THREADS"
++} else {
++ set target_cflags ""
++}
++
++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
++ return -1
++}
++
++# ${shellfile} argument must not contain any directories.
++set fd [open "|bash ${shellfile} ${binfile} $GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts]" r]
++while { [gets $fd line] >= 0 } {
++ if [regexp " PASS: (.*)$" $line trash message] {
++ pass $message
++ } elseif [regexp " FAIL: (.*)$" $line trash message] {
++ fail $message
++ }
++}
++catch {
++ close $fd
++}
++
++return 0
+diff --git a/gdb/testsuite/gdb.threads/threadcrash.sh b/gdb/testsuite/gdb.threads/threadcrash.sh
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.threads/threadcrash.sh
+@@ -0,0 +1,324 @@
++#! /bin/bash
++
++# NOTE: threadcrash.c *must* be built with debugging symbols
++#
++# The point of this shell script is to crash treadcrash.c, load the
++# resulting core file into gdb and verify that gdb can extract enough
++# information from the core file.
++#
++# The return code from this script is the number of failed tests.
++
++LOG=gdbresult.log
++
++if [ $# = 0 ] ; then
++ echo >&2 Syntax: $0 \ [\ \]
++ exit 1
++fi
++RUNME="$1"
++shift
++GDB="${*:-gdb}"
++
++
++pf_prefix=""
++function pf_prefix() {
++ pf_prefix="$*"
++}
++
++set_test=""
++function set_test() {
++ if [ -n "$set_test" ] ; then
++ echo >&2 "DEJAGNU-BASH ERROR: set_test already set"
++ exit 1
++ fi
++ set_test="$*"
++ if [ -n "$pf_prefix" ] ; then
++ set_test="$pf_prefix: $set_test"
++ fi
++}
++
++# INTERNAL
++function record_test {
++ if [ -z "$set_test" ] ; then
++ echo >&2 "DEJAGNU-BASH ERROR: set_test not set"
++ exit 1
++ fi
++ # Provide the leading whitespace delimiter:
++ echo " $1: $set_test"
++ set_test=""
++}
++
++function pass() {
++ record_test PASS
++}
++function fail() {
++ record_test FAIL
++}
++
++
++# Verify that the gdb output doesn't contain $1.
++function mustNotHave() {
++ local BADWORD=$1
++ set_test gdb output contains "$BADWORD"
++ if grep -q "$BADWORD" $LOG ; then
++ fail
++ return 1
++ fi
++ pass
++ return 0
++}
++
++# Verify that the gdb output contains exactly $1 $2s.
++function mustHaveCorrectAmount() {
++ local WANTEDNUMBER=$1
++ local GOODWORD=$2
++ local ACTUALNUMBER=$(grep "$GOODWORD" $LOG | wc -l)
++ set_test gdb output contained $ACTUALNUMBER \""$GOODWORD"\", not $WANTEDNUMBER as expected
++ if [ $ACTUALNUMBER != $WANTEDNUMBER ] ; then
++ fail
++ return 1
++ fi
++ pass
++ return 0
++}
++
++# Verify that the gdb output contains seven threads
++function mustHaveSevenThreads() {
++ NTHREADS=$(egrep "^Thread [1-7] \(" $LOG | wc -l)
++ set_test gdb output contains $NTHREADS threads, not 7 as expected
++ if [ $NTHREADS != 7 ] ; then
++ fail
++ return 1
++ fi
++ pass
++ return 0
++}
++
++# Verify that the gdb output has all parameters on consecutive lines
++function mustHaveSequence() {
++ SEQUENCE="$*"
++ NPARTS=$#
++ grep "$1" -A$((NPARTS - 1)) $LOG > matches.log
++
++ while [ $# -gt 1 ] ; do
++ shift
++ ((NPARTS--))
++ grep "$1" -A$((NPARTS - 1)) matches.log > temp.log
++ mv temp.log matches.log
++ done
++ LASTPART=$1
++
++ set_test gdb output does not contain the sequence: $SEQUENCE
++ if ! grep -q "$LASTPART" matches.log ; then
++ fail
++ return 1
++ fi
++ pass
++ return 0
++}
++
++# 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
++}
++
++# Put result of debugging a core file in $LOG
++function getLogFromCore() {
++ # Make sure we get a core file
++ set_test Make sure we get a core file
++ if ! ulimit -c unlimited ; then
++ fail
++ exit 1
++ fi
++ pass
++
++ # Run the crasher
++ ./$(basename "$RUNME")
++ EXITCODE=$?
++
++ # Verify that we actually crashed
++ set_test $RUNME should have been killed by a signal, got non-signal exit code $EXITCODE
++ if [ $EXITCODE -lt 128 ] ; then
++ fail
++ exit 1
++ fi
++ pass
++
++ # Verify that we got a core file
++ set_test $RUNME did not create a core file
++ if [ ! -r core* ] ; then
++ fail
++ exit 1
++ fi
++ pass
++
++ # Run gdb
++ cat > gdbscript.gdb < $LOG
++ EXITCODE=$?
++
++ set_test gdb exited with error code
++ if [ $EXITCODE != 0 ] ; then
++ ((FAILURES++))
++ echo >&2 gdb exited with error code $EXITCODE
++ fail
++ fi
++ pass
++}
++
++# Put result of debugging a gcore file in $LOG
++function getLogFromGcore() {
++ # Create the core file
++ rm -f core*
++ cat > gdbscript.gdb < /dev/null
++ EXITCODE=$?
++
++ set_test gdb exited with error code when creating gcore file
++ if [ $EXITCODE != 0 ] ; then
++ ((FAILURES++))
++ echo >&2 gdb exited with error code $EXITCODE when creating gcore file
++ 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
++ fail
++ exit 1
++ fi
++ pass
++
++ # Run gdb on the gcore file
++ cat > gdbscript.gdb < $LOG
++ EXITCODE=$?
++
++ set_test gdb exited with error code when examining gcore file
++ if [ $EXITCODE != 0 ] ; then
++ ((FAILURES++))
++ echo >&2 gdb exited with error code $EXITCODE when examining gcore file
++ fail
++ fi
++ pass
++}
++
++# Put result of debugging a core file in $LOG
++function getLogFromLiveProcess() {
++ # Run gdb
++ cat > gdbscript.gdb < $LOG
++ EXITCODE=$?
++
++ set_test gdb exited with error code
++ if [ $EXITCODE != 0 ] ; then
++ ((FAILURES++))
++ echo >&2 gdb exited with error code $EXITCODE
++ fail
++ fi
++ pass
++}
++
++####### Main program follows #####################
++
++# Make sure we don't clobber anybody else's (core) file(s)
++WORKDIR=/tmp/$PPID
++mkdir -p $WORKDIR
++cp "$RUNME" $WORKDIR
++cd $WORKDIR
++
++# Count problems
++FAILURES=0
++
++echo === Testing gdb vs core file...
++pf_prefix core file
++getLogFromCore
++verifyLog
++((FAILURES+=$?))
++pf_prefix
++echo === Core file tests done.
++
++echo
++
++echo === Testing gdb vs gcore file...
++pf_prefix gcore file
++getLogFromGcore
++verifyLog
++((FAILURES+=$?))
++pf_prefix
++echo === Gcore file tests done.
++
++echo
++
++echo === Testing gdb vs live process...
++pf_prefix live process
++getLogFromLiveProcess
++verifyLog
++((FAILURES+=$?))
++pf_prefix
++echo === Live process tests done.
++
++# Executive summary
++echo
++if [ $FAILURES == 0 ] ; then
++ echo All tests passed!
++else
++ echo $FAILURES tests failed!
++ echo
++ echo Make sure the threadcrash binary contains debugging information \(build with \"gcc -g\"\).
++fi
++
++# Clean up
++cd /
++rm -rf $WORKDIR
++
++exit $FAILURES
+diff --git a/gdb/testsuite/gdb.threads/threadcrash.sh-orig b/gdb/testsuite/gdb.threads/threadcrash.sh-orig
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.threads/threadcrash.sh-orig
+@@ -0,0 +1,248 @@
++#! /bin/bash
++
++# NOTE: threadcrash.c *must* be built with debugging symbols
++#
++# The point of this shell script is to crash treadcrash.c, load the
++# resulting core file into gdb and verify that gdb can extract enough
++# information from the core file.
++#
++# The return code from this script is the number of failed tests.
++
++LOG=gdbresult.log
++
++if [ $# != 1 ] ; then
++ echo > /dev/stderr Syntax: $0 \
++ exit 1
++fi
++RUNME="$1"
++
++# Verify that the gdb output doesn't contain $1.
++function mustNotHave() {
++ local BADWORD=$1
++ if grep -q "$BADWORD" $LOG ; then
++ echo >> /dev/stderr WARNING: gdb output contains "$BADWORD"
++ return 1
++ fi
++ return 0
++}
++
++# Verify that the gdb output contains exactly $1 $2s.
++function mustHaveCorrectAmount() {
++ local WANTEDNUMBER=$1
++ local GOODWORD=$2
++ local ACTUALNUMBER=$(grep "$GOODWORD" $LOG | wc -l)
++ if [ $ACTUALNUMBER != $WANTEDNUMBER ] ; then
++ echo >> /dev/stderr WARNING: gdb output contained $ACTUALNUMBER \""$GOODWORD"\", not $WANTEDNUMBER as expected
++ return 1
++ fi
++ return 0
++}
++
++# Verify that the gdb output contains seven threads
++function mustHaveSevenThreads() {
++ NTHREADS=$(egrep "^Thread [1-7] \(" $LOG | wc -l)
++ if [ $NTHREADS != 7 ] ; then
++ echo >> /dev/stderr WARNING: gdb output contains $NTHREADS threads, not 7 as expected
++ return 1
++ fi
++ return 0
++}
++
++# Verify that the gdb output has all parameters on consecutive lines
++function mustHaveSequence() {
++ SEQUENCE="$*"
++ NPARTS=$#
++ grep "$1" -A$((NPARTS - 1)) $LOG > matches.log
++
++ while [ $# -gt 1 ] ; do
++ shift
++ ((NPARTS--))
++ grep "$1" -A$((NPARTS - 1)) matches.log > temp.log
++ mv temp.log matches.log
++ done
++ LASTPART=$1
++
++ if ! grep -q "$LASTPART" matches.log ; then
++ echo >> /dev/stderr WARNING: gdb output does not contain the sequence: $SEQUENCE
++ return 1
++ fi
++ return 0
++}
++
++# 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
++}
++
++# Put result of debugging a core file in $LOG
++function getLogFromCore() {
++ # Make sure we get a core file
++ ulimit -c unlimited || exit 1
++
++ # Run the crasher
++ ./$(basename "$RUNME")
++ EXITCODE=$?
++
++ # Verify that we actually crashed
++ if [ $EXITCODE -lt 128 ] ; then
++ echo >> /dev/stderr ERROR: $RUNME should have been killed by a signal, got non-signal exit code $EXITCODE
++ exit 1
++ fi
++
++ # Verify that we got a core file
++ if [ ! -r core* ] ; then
++ echo >> /dev/stderr ERROR: $RUNME did not create a core file
++ exit 1
++ fi
++
++ # Run gdb
++ cat > gdbscript.gdb < $LOG
++ EXITCODE=$?
++
++ if [ $EXITCODE != 0 ] ; then
++ ((FAILURES++))
++ echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE
++ fi
++}
++
++# Put result of debugging a gcore file in $LOG
++function getLogFromGcore() {
++ # Create the core file
++ rm -f core*
++ cat > gdbscript.gdb < /dev/null
++ EXITCODE=$?
++
++ if [ $EXITCODE != 0 ] ; then
++ ((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
++ exit 1
++ fi
++
++ # Run gdb on the gcore file
++ cat > gdbscript.gdb < $LOG
++ EXITCODE=$?
++
++ if [ $EXITCODE != 0 ] ; then
++ ((FAILURES++))
++ echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE when examining gcore file
++ fi
++}
++
++# Put result of debugging a core file in $LOG
++function getLogFromLiveProcess() {
++ # Run gdb
++ cat > gdbscript.gdb < $LOG
++ EXITCODE=$?
++
++ if [ $EXITCODE != 0 ] ; then
++ ((FAILURES++))
++ echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE
++ fi
++}
++
++####### Main program follows #####################
++
++# Make sure we don't clobber anybody else's (core) file(s)
++WORKDIR=/tmp/$PPID
++mkdir -p $WORKDIR
++cp "$RUNME" $WORKDIR
++cd $WORKDIR
++
++# Count problems
++FAILURES=0
++
++echo === Testing gdb vs core file...
++getLogFromCore
++verifyLog
++((FAILURES+=$?))
++echo === Core file tests done.
++
++echo
++
++echo === Testing gdb vs gcore file...
++getLogFromGcore
++verifyLog
++((FAILURES+=$?))
++echo === Gcore file tests done.
++
++echo
++
++echo === Testing gdb vs live process...
++getLogFromLiveProcess
++verifyLog
++((FAILURES+=$?))
++echo === Live process tests done.
++
++# Executive summary
++echo
++if [ $FAILURES == 0 ] ; then
++ echo All tests passed!
++else
++ echo $FAILURES tests failed!
++ echo
++ echo Make sure the threadcrash binary contains debugging information \(build with \"gcc -g\"\).
++fi
++
++# Clean up
++cd /
++rm -rf $WORKDIR
++
++exit $FAILURES
diff --git a/gdb-6.5-bz109921-DW_AT_decl_file-test.patch b/gdb-6.5-bz109921-DW_AT_decl_file-test.patch
new file mode 100644
index 0000000..a27c8f3
--- /dev/null
+++ b/gdb-6.5-bz109921-DW_AT_decl_file-test.patch
@@ -0,0 +1,134 @@
+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
++++ b/gdb/testsuite/gdb.dwarf2/dw2-included.c
+@@ -0,0 +1,26 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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. */
++
++#include "dw2-included.h"
++
++int
++main()
++{
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-included.exp b/gdb/testsuite/gdb.dwarf2/dw2-included.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-included.exp
+@@ -0,0 +1,47 @@
++# 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-included"
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++gdb_test "set listsize 1" ""
++gdb_test "list integer" "int integer;\r"
++gdb_test "ptype integer" "type = int\r"
++# Path varies depending on the build location.
++gdb_test "info variables integer" "\r\nFile \[^\r\n\]*/gdb.dwarf2/dw2-included.h:\r\n${decimal}:.*int integer;\r"
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-included.h b/gdb/testsuite/gdb.dwarf2/dw2-included.h
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-included.h
+@@ -0,0 +1,20 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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. */
++
++int integer;
diff --git a/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch b/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
new file mode 100644
index 0000000..a89de0a
--- /dev/null
+++ b/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
@@ -0,0 +1,264 @@
+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)
+
+ if (exp != nullptr && *exp)
+ {
++ /* '*((int *(*) (void)) __errno_location) ()' is incompatible with
++ function descriptors. */
++ if (target_has_execution && strcmp (exp, "errno") == 0)
++ exp = "*(*(int *(*)(void)) __errno_location) ()";
+ expression_up expr = parse_expression (exp);
+ val = evaluate_expression (expr.get ());
+ }
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.c b/gdb/testsuite/gdb.dwarf2/dw2-errno.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-errno.c
+@@ -0,0 +1,28 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2005, 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 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 .
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++#include
++
++int main()
++{
++ errno = 42;
++
++ return 0; /* breakpoint */
++}
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.exp b/gdb/testsuite/gdb.dwarf2/dw2-errno.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-errno.exp
+@@ -0,0 +1,60 @@
++# 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 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 dw2-errno
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++
++proc prep {} {
++ global srcdir subdir binfile
++ gdb_exit
++ gdb_start
++ gdb_reinitialize_dir $srcdir/$subdir
++ gdb_load ${binfile}
++
++ runto_main
++
++ gdb_breakpoint [gdb_get_line_number "breakpoint"]
++ gdb_continue_to_breakpoint "breakpoint"
++}
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++prep
++gdb_test "print errno" ".* = 42" "errno with macros=N threads=N"
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++prep
++gdb_test "print errno" ".* = 42" "errno with macros=Y threads=N"
++
++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
++ return -1
++}
++prep
++gdb_test "print errno" ".* = 42" "errno with macros=N threads=Y"
++
++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
++ return -1
++}
++prep
++gdb_test "print errno" ".* = 42" "errno with macros=Y threads=Y"
++
++# TODO: Test the error on resolving ERRNO with only libc loaded.
++# Just how to find the current libc filename?
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno2.c b/gdb/testsuite/gdb.dwarf2/dw2-errno2.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-errno2.c
+@@ -0,0 +1,28 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2005, 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 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 .
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++#include
++
++int main()
++{
++ errno = 42;
++
++ return 0; /* breakpoint */
++}
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp b/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp
+@@ -0,0 +1,71 @@
++# 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 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 dw2-errno2
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++
++proc prep { message {do_xfail 0} } { with_test_prefix $message {
++ global srcdir subdir binfile variant
++ gdb_exit
++ gdb_start
++ gdb_reinitialize_dir $srcdir/$subdir
++ gdb_load ${binfile}${variant}
++
++ runto_main
++
++ gdb_breakpoint [gdb_get_line_number "breakpoint"]
++ gdb_continue_to_breakpoint "breakpoint"
++
++ gdb_test "gcore ${binfile}${variant}.core" "\r\nSaved corefile .*" "gcore $variant"
++
++ gdb_test "print errno" ".* = 42"
++
++ gdb_test "kill" ".*" "kill" {Kill the program being debugged\? \(y or n\) } "y"
++ gdb_test "core-file ${binfile}${variant}.core" "\r\nCore was generated by .*" "core-file"
++ if $do_xfail {
++ setup_xfail "*-*-*"
++ }
++ gdb_test "print (int) errno" ".* = 42" "print errno for core"
++}}
++
++set variant g2thrN
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g2"] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++prep "macros=N threads=N" 1
++
++set variant g3thrN
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g3"] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++prep "macros=Y threads=N" 1
++
++set variant g2thrY
++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g2"] != "" } {
++ return -1
++}
++prep "macros=N threads=Y"
++
++set variant g3thrY
++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g3"] != "" } {
++ return -1
++}
++prep "macros=Y threads=Y" 1
++
++# TODO: Test the error on resolving ERRNO with only libc loaded.
++# Just how to find the current libc filename?
diff --git a/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch b/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
new file mode 100644
index 0000000..8a648a3
--- /dev/null
+++ b/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
@@ -0,0 +1,102 @@
+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
++++ b/gdb/testsuite/gdb.base/step-over-trampoline.c
+@@ -0,0 +1,28 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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.
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++#include
++
++int main (void)
++{
++ puts ("hello world");
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/step-over-trampoline.exp b/gdb/testsuite/gdb.base/step-over-trampoline.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/step-over-trampoline.exp
+@@ -0,0 +1,54 @@
++# 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.
++
++if $tracelevel then {
++ strace $tracelevel
++}
++
++set testfile step-over-trampoline
++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
++}
++
++# Get things started.
++
++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 .*$srcfile.*" \
++ "start"
++
++# main () at hello2.c:5
++# 5 puts("hello world\n");
++# (gdb) next
++# 0x100007e0 in call___do_global_ctors_aux ()
++
++gdb_test_multiple "next" "invalid `next' output" {
++ -re "\nhello world.*return 0;.*" {
++ pass "stepped over"
++ }
++ -re " in call___do_global_ctors_aux \\(\\).*" {
++ fail "stepped into trampoline"
++ }
++}
diff --git a/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch b/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch
new file mode 100644
index 0000000..0a66b3d
--- /dev/null
+++ b/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch
@@ -0,0 +1,27 @@
+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-solib-trampoline-lookup-lock-fix.patch
+
+;; Fix lockup on trampoline vs. its function lookup; unreproducible (BZ 218379).
+;;=fedora
+
+https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379
+
+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
new file mode 100644
index 0000000..a0520d7
--- /dev/null
+++ b/gdb-6.5-bz243845-stale-testing-zombie-test.patch
@@ -0,0 +1,88 @@
+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 @@
++# 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
++}
++
++# Start the program running and then wait for a bit, to be sure
++# that it can be attached to.
++
++gdb_exit
++gdb_start
++gdb_load sleep
++
++set gdb_pid [exp_pid -i [board_info host fileid]]
++set test "identified the child GDB"
++if {$gdb_pid != "" && $gdb_pid > 0} {
++ pass $test
++ verbose -log "Child GDB PID $gdb_pid"
++} else {
++ fail $test
++}
++
++set testpid [eval exec sleep 10 &]
++exec sleep 2
++
++set test "attach"
++gdb_test_multiple "attach $testpid" "$test" {
++ -re "Attaching to program.*`?.*'?, process $testpid..*$gdb_prompt $" {
++ pass "$test"
++ }
++ -re "Attaching to program.*`?.*\.exe'?, process $testpid.*\[Switching to thread $testpid\..*\].*$gdb_prompt $" {
++ # Response expected on Cygwin
++ pass "$test"
++ }
++}
++
++# Some time to let GDB spawn its testing child.
++exec sleep 2
++
++set found none
++foreach procpid [glob -directory /proc -type d {[0-9]*}] {
++ if {[catch {open $procpid/status} statusfi]} {
++ continue
++ }
++ set status [read $statusfi]
++ close $statusfi
++ if {1
++ && [regexp -line {^Name:\tgdb$} $status]
++ && [regexp -line {^PPid:\t1$} $status]
++ && [regexp -line "^TracerPid:\t$gdb_pid$" $status]} {
++ set found $procpid
++ verbose -log "Found linux_test_for_tracefork zombie PID $procpid"
++ }
++}
++set test "linux_test_for_tracefork leaves no zombie"
++if {$found eq {none}} {
++ pass $test
++} else {
++ fail $test
++}
diff --git a/gdb-6.5-gcore-buffer-limit-test.patch b/gdb-6.5-gcore-buffer-limit-test.patch
new file mode 100644
index 0000000..f4ae65e
--- /dev/null
+++ b/gdb-6.5-gcore-buffer-limit-test.patch
@@ -0,0 +1,149 @@
+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
++++ b/gdb/testsuite/gdb.base/gcore-excessive-memory.c
+@@ -0,0 +1,37 @@
++/* 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 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 */
++
++#include
++#include
++
++#define MEGS 64
++
++int main()
++{
++ void *mem;
++
++ mem = malloc (MEGS * 1024ULL * 1024ULL);
++
++ for (;;)
++ sleep (1);
++
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/gcore-excessive-memory.exp b/gdb/testsuite/gdb.base/gcore-excessive-memory.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-excessive-memory.exp
+@@ -0,0 +1,94 @@
++# 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.
++
++set testfile gcore-excessive-memory
++set srcfile ${testfile}.c
++set shfile [standard_output_file ${testfile}-gdb.sh]
++set corefile [standard_output_file ${testfile}.core]
++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
++
++set pid_of_bin [eval exec $binfile &]
++sleep 2
++
++# Get things started.
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++set pid_of_gdb [exp_pid -i [board_info host fileid]]
++
++gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
++gdb_test "up 99" "in main .*" "verify we can get to 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]
++
++# It must be definitely less than `MEGS' of `gcore-excessive-memory.c'.
++set mb_gcore_reserve 4
++verbose -log "pages_found = $pages_found, mb_gcore_reserve = $mb_gcore_reserve"
++set kb_found [expr $pages_found * $pagesize / 1024]
++set kb_permit [expr $kb_found + 1 * 1024 + $mb_gcore_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]]
++
++gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
++gdb_test "up 99" "in main .*" "verify we can get to main"
++
++verbose -log "kb_found before gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
++
++gdb_test "gcore $corefile" "Saved corefile \[^\n\r\]*" "Save the core file"
++
++verbose -log "kb_found after gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
++
++# Cleanup.
++exec kill -9 $pid_of_bin
diff --git a/gdb-6.5-ia64-libunwind-leak-test.patch b/gdb-6.5-ia64-libunwind-leak-test.patch
new file mode 100644
index 0000000..8a8a43a
--- /dev/null
+++ b/gdb-6.5-ia64-libunwind-leak-test.patch
@@ -0,0 +1,130 @@
+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
++++ b/gdb/testsuite/gdb.base/unwind-leak.c
+@@ -0,0 +1,29 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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.
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++#include
++
++int main()
++{
++ for (;;)
++ alarm (0);
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/unwind-leak.exp b/gdb/testsuite/gdb.base/unwind-leak.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/unwind-leak.exp
+@@ -0,0 +1,83 @@
++# 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.
++
++set testfile unwind-leak
++set srcfile ${testfile}.c
++set shfile [standard_output_file ${testfile}-gdb.sh]
++set binfile [standard_output_file ${testfile}]
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++
++# Get things started.
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++set pid [exp_pid -i [board_info host fileid]]
++
++# For C programs, "start" should stop in main().
++
++gdb_test "start" \
++ "main \\(\\) at .*$srcfile.*" \
++ "start"
++
++set loc [gdb_get_line_number "alarm"]
++gdb_breakpoint $loc
++
++proc memory_get {} {
++ global pid
++ set fd [open "/proc/$pid/statm"]
++ gets $fd line
++ close $fd
++ # number of pages of data/stack
++ scan $line "%*d%*d%*d%*d%*d%d" drs
++ return $drs
++}
++
++set cycles 100
++# For 100 cycles it was 1308: from = 363 KB, to = 1671 KB
++set permit_kb 100
++verbose -log "cycles = $cycles, permit_kb = $permit_kb"
++
++set fail 0
++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} $" {
++ }
++ -re "Segmentation fault" {
++ fail $test
++ set i 0
++ set fail 1
++ }
++ }
++ if ![info exists from] {
++ set from [memory_get]
++ }
++}
++set to [memory_get]
++if {!$fail} {
++ verbose -log "from = $from KB, to = $to KB"
++ if {$from > 0 && $to > 10 && $to < $from + $permit_kb} {
++ pass $test
++ } else {
++ fail $test
++ }
++}
diff --git a/gdb-6.5-last-address-space-byte-test.patch b/gdb-6.5-last-address-space-byte-test.patch
new file mode 100644
index 0000000..9c5779f
--- /dev/null
+++ b/gdb-6.5-last-address-space-byte-test.patch
@@ -0,0 +1,62 @@
+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
++++ b/gdb/testsuite/gdb.base/largecore-last-address-lock.exp
+@@ -0,0 +1,49 @@
++# 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.
++
++if $tracelevel then {
++ strace $tracelevel
++}
++
++# Get things started.
++
++gdb_exit
++gdb_start
++
++# i386 (32-bit) only: gdb with Red Hat largecore patch did lock up:
++# https://enterprise.redhat.com/issue-tracker/?module=issues&action=view&tid=103263
++# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=210614
++
++# i386: Bug exists when the `target_xfer_memory' condition
++# `(memaddr + len < region->hi)' operates on 64-bit operands on
++# largecore-patched with 32-bit addresses and so it can get `false' with
++# arbitrary `len'.
++
++# x86_64: The bug is not present as the operands and calculations have the same
++# bit size. Would would still need to pass there the highest address
++# (`memaddr == 0xffffffffffffffff') but we would need to pass `len == 0'
++# to make the condition `(memaddr + len < region->hi)' false.
++# `len == 0' would get caught eariler.
++
++# Error in the success case is immediate.
++set timeoutold ${timeout}
++set timeout 10
++
++gdb_test "x/xb 0xffffffff" \
++ "Cannot access memory at address 0xffffffff" \
++ "Read the last address space byte"
++
++set timeout ${timeoutold}
diff --git a/gdb-6.5-missed-trap-on-step-test.patch b/gdb-6.5-missed-trap-on-step-test.patch
new file mode 100644
index 0000000..06a9f7e
--- /dev/null
+++ b/gdb-6.5-missed-trap-on-step-test.patch
@@ -0,0 +1,95 @@
+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
++++ b/gdb/testsuite/gdb.base/watchpoint-during-step.c
+@@ -0,0 +1,30 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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.
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++static int var;
++
++int main()
++{
++ var = 1;
++ var = 2;
++ var = 3;
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/watchpoint-during-step.exp b/gdb/testsuite/gdb.base/watchpoint-during-step.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/watchpoint-during-step.exp
+@@ -0,0 +1,44 @@
++# 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.
++
++set testfile watchpoint-during-step
++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
++}
++
++# Get things started.
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++runto_main
++
++gdb_breakpoint [gdb_get_line_number "var = 2"]
++gdb_continue_to_breakpoint "Find the first var set"
++
++gdb_test "step" ".*var = 3;" "Step to the next var set"
++
++gdb_test "watch var" "atchpoint .*: var" "Set the watchpoint"
++
++# Here is the target point. Be careful to not have breakpoint set on the line
++# we step from as in this case it is a valid upstream KFAIL gdb/38
++
++gdb_test "step" ".*Old value = 2.*New value = 3.*" "Catch the watchpoint"
diff --git a/gdb-6.5-readline-long-line-crash-test.patch b/gdb-6.5-readline-long-line-crash-test.patch
new file mode 100644
index 0000000..c4127b7
--- /dev/null
+++ b/gdb-6.5-readline-long-line-crash-test.patch
@@ -0,0 +1,119 @@
+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 @@
++# 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.
++
++# Please email any bugs, comments, and/or additions to this file to:
++# bug-gdb@prep.ai.mit.edu
++
++# This file was written by Jan Kratochvil
++
++# This file is part of the gdb testsuite.
++
++#
++# Tests for readline buffer overflow.
++#
++
++if $tracelevel {
++ strace $tracelevel
++}
++
++global env
++
++save_vars { env(INPUTRC) 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"
++ set env(HISTSIZE) "10"
++
++ gdb_exit
++ gdb_start
++ gdb_reinitialize_dir $srcdir/$subdir
++
++
++ set width 11
++ gdb_test "set width $width" \
++ "" \
++ "Setting width to $width."
++ #gdb_test "set height 1" \
++ # "" \
++ # "Setting height to 1."
++ send_gdb "run X"
++ set i 0
++ # It crashes using `set width 7' on `set total 3560'.
++ # Sometimes it corrupts screen on `set width 7'.
++ # Bugreport used `set total 130001':
++ # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196
++ # Check also `timeout' above.
++ set total 4200
++ gdb_expect {
++ -re X {
++ incr i
++ if {$i <= $total} {
++ send_gdb "X"
++ exp_continue
++ }
++ }
++ -re "\[ \b\r\n\]" {
++ exp_continue
++ }
++ eof {
++ fail "gdb sending total $total characters"
++ note "Failed after sending $i characters, reason: EOF"
++ gdb_clear_suppressed
++ }
++ timeout {
++ fail "gdb sending total $total characters"
++ note "Failed after sending $i characters (timeout $timeout), reason: TIMEOUT"
++ gdb_clear_suppressed
++ }
++ default {
++ fail "gdb sending total $total characters"
++ note "Failed after sending $i characters, reason: 0=\[$expect_out(0,string)\] buffer=\[$expect_out(buffer)\]"
++ gdb_clear_suppressed
++ }
++ }
++ send_gdb "\r"
++ gdb_test "" \
++ "No executable file specified..*" \
++ "All the characters transferred"
++}
diff --git a/gdb-6.5-section-num-fixup-test.patch b/gdb-6.5-section-num-fixup-test.patch
new file mode 100644
index 0000000..012ba92
--- /dev/null
+++ b/gdb-6.5-section-num-fixup-test.patch
@@ -0,0 +1,122 @@
+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
++++ b/gdb/testsuite/gdb.base/datalib-lib.c
+@@ -0,0 +1,22 @@
++/* 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 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 */
++
++int var;
+diff --git a/gdb/testsuite/gdb.base/datalib-main.c b/gdb/testsuite/gdb.base/datalib-main.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/datalib-main.c
+@@ -0,0 +1,26 @@
++/* 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 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 */
++
++int
++main (void)
++{
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/datalib.exp b/gdb/testsuite/gdb.base/datalib.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/datalib.exp
+@@ -0,0 +1,51 @@
++# 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.
++
++set testfile datalib
++set srcfilemain ${testfile}-main.c
++set srcfilelib ${testfile}-lib.c
++set libfile [standard_output_file ${testfile}-lib.so]
++set binfile [standard_output_file ${testfile}-main]
++if { [gdb_compile "${srcdir}/${subdir}/${srcfilelib}" "${libfile}" executable [list debug {additional_flags=-shared -nostdlib}]] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++if { [gdb_compile "${srcdir}/${subdir}/${srcfilemain}" "${binfile} ${libfile}" executable {debug}] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++
++# Get things started.
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++# We must use a separate library as the main executable is compiled to the
++# address 0 by default and it would get fixed up already at the end of
++# INIT_OBJFILE_SECT_INDICES. We also cannot PRELINK it as PRELINK is missing
++# on ia64. The library must be NOSTDLIB as otherwise some stub code would
++# create the `.text' section there. Also DEBUG option is useful as some of
++# the crashes occur in dwarf2read.c.
++
++# FAIL case:
++# ../../gdb/ia64-tdep.c:2838: internal-error: sect_index_text not initialized
++# A problem internal to GDB has been detected,
++
++gdb_test "start" \
++ "main \\(\\) at .*${srcfilemain}.*" \
++ "start"
diff --git a/gdb-6.5-sharedlibrary-path.patch b/gdb-6.5-sharedlibrary-path.patch
new file mode 100644
index 0000000..6f31e88
--- /dev/null
+++ b/gdb-6.5-sharedlibrary-path.patch
@@ -0,0 +1,180 @@
+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 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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.
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++int main()
++{
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
+@@ -0,0 +1,22 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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.
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++__thread int var = 42;
+diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
+@@ -0,0 +1,87 @@
++# 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.
++
++if $tracelevel then {
++ strace $tracelevel
++}
++
++set testfile tls-sepdebug
++set srcmainfile ${testfile}-main.c
++set srcsharedfile ${testfile}-shared.c
++
++set binmainfile [standard_output_file ${testfile}-main]
++set binsharedbase ${testfile}-shared.so
++set binsharedfile [standard_output_file ${binsharedbase}]
++set binshareddebugfile [standard_output_file ${binsharedbase}.debug]
++
++# Use explicit -soname as otherwise the full path to the library would get
++# encoded into ${binmainfile} making LD_LIBRARY_PATH tests useless.
++
++# FIXME: gcc dependency (-Wl,-soname).
++
++if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" [list debug additional_flags=-Wl,-soname=${binsharedbase}]] != "" } {
++ untested "Couldn't compile test library"
++ return -1
++}
++
++# eu-strip(1) works fine but it is a part of `elfutils', not `binutils'.
++if 0 then {
++ remote_exec build "eu-strip -f ${binshareddebugfile} ${binsharedfile}"
++} else {
++ remote_exec build "objcopy --only-keep-debug ${binsharedfile} ${binshareddebugfile}"
++ remote_exec build "objcopy --strip-debug ${binsharedfile}"
++ remote_exec build "objcopy --add-gnu-debuglink=${binshareddebugfile} ${binsharedfile}"
++}
++
++# Do not use `shlib=' as it will automatically add also -rpath for gcc.
++
++if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcmainfile} ${binsharedfile}" "${binmainfile}" executable {debug}] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++
++# Get things started.
++
++# Test also the proper resolving of relative library names to absolute ones.
++# \$PWD is easy - it is the absolute way
++# ${subdir} would fail on "print var"
++
++set absdir [file dirname [standard_output_file ${binsharedbase}]]
++foreach ld_library_path [list $absdir [relative_filename [pwd] $absdir]] name { absolute relative } {
++
++ 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
new file mode 100644
index 0000000..d182ae1
--- /dev/null
+++ b/gdb-6.6-buildid-locate-core-as-arg.patch
@@ -0,0 +1,196 @@
+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-core-as-arg.patch
+
+;;=push+jan
+
+http://sourceware.org/ml/gdb-patches/2010-01/msg00558.html
+
+[ Fixed up since the mail. ]
+
+On Thu, 21 Jan 2010 18:17:15 +0100, Doug Evans wrote:
+> Not an exhaustive list, but if we go down the path of converting "gdb
+> corefile" to "gdb -c corefile", then we also need to think about "file
+> corefile" being converted to "core corefile" [or "target core
+> corefile", "core" is apparently deprecated in favor of "target core"]
+> and "target exec corefile" -> "target core corefile". Presumably
+> "file corefile" (and "target exec corefile") would discard the
+> currently selected executable. But maybe not. Will that be confusing
+> for users? I don't know.
+
+While thinking about it overriding some GDB _commands_ was not my intention.
+
+There is a general assumption if I have a shell COMMAND and some FILE I can do
+$ COMMAND FILE
+and COMMAND will appropriately load the FILE.
+
+FSF GDB currently needs to specify also the executable file for core files
+which already inhibits this intuitive expectation. OTOH with the build-id
+locating patch which could allow such intuitive start notneeding the
+executable file. Still it currently did not work due to the required "-c":
+$ COMMAND -c COREFILE
+
+Entering "file", "core-file" or "attach" commands is already explicit enough
+so that it IMO should do what the command name says without any
+autodetections. The second command line argument
+(captured_main->pid_or_core_arg) is also autodetected (for PID or CORE) but
+neither "attach" accepts a core file nor "core-file" accepts a PID.
+
+The patch makes sense only with the build-id patchset so this is not submit
+for FSF GDB inclusion yet. I am fine with your patch (+/- Hui Zhu's pending
+bfd_check_format_matches) as the patch below is its natural extension.
+
+Sorry for the delay,
+Jan
+
+2010-01-25 Jan Kratochvil
+
+ * exceptions.h (enum errors ): New.
+ * exec.c: Include exceptions.h.
+ (exec_file_attach ): Call throw_error (IS_CORE_ERROR, ...).
+ * main.c (exec_or_core_file_attach): New.
+ (captured_main ): Set also corearg.
+ (captured_main ): New variable func.
+ Call exec_or_core_file_attach if COREARG matches EXECARG. Call
+ symbol_file_add_main only if CORE_BFD remained NULL.
+
+Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html
+2010-01-20 Doug Evans
+
+ * exec.c (exec_file_attach): Print a more useful error message if the
+ user did "gdb core".
+
+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
new file mode 100644
index 0000000..985cb6a
--- /dev/null
+++ b/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
@@ -0,0 +1,129 @@
+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
++++ b/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
+@@ -0,0 +1,97 @@
++# Copyright (C) 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 "normal.c"
++
++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
++ return -1
++}
++
++# Get the build-id of the file
++set build_id_debug_file [build_id_debug_filename_get $binfile]
++regsub -all ".debug$" $build_id_debug_file "" build_id_without_debug
++
++# Run to main
++if { ![runto_main] } {
++ return -1
++}
++
++# We first need to generate a corefile
++set escapedfilename [string_to_regexp [standard_output_file gcore.test]]
++set core_supported 0
++gdb_test_multiple "gcore [standard_output_file gcore.test]" \
++ "save a corefile" \
++{
++ -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
++ pass "save a corefile"
++ global core_supported
++ set core_supported 1
++ }
++ -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
++ unsupported "save a corefile"
++ global core_supported
++ set core_supported 0
++ }
++}
++
++if {!$core_supported} {
++ return -1
++}
++
++# Move the binfile to a temporary name
++remote_exec build "mv $binfile ${binfile}.old"
++
++# Reinitialize GDB and see if we get a yum/dnf warning
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++
++with_test_prefix "first run:" {
++ gdb_test "set build-id-verbose 1" "" \
++ "set build-id-verbose"
++
++ gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \
++ "set debug-file-directory"
++
++ gdb_test "core-file [standard_output_file gcore.test]" \
++ "Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install [standard_output_file $build_id_without_debug]\r\n.*" \
++ "test first yum/dnf warning"
++}
++
++# Now we define and create our .build-id
++file mkdir [file dirname [standard_output_file ${build_id_without_debug}]]
++# Cannot use "file link" (from TCL) because it requires the target file to
++# exist.
++remote_exec build "ln -s $binfile [standard_output_file ${build_id_without_debug}]"
++
++# Reinitialize GDB to get the second yum/dnf warning
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++
++with_test_prefix "second run:" {
++ gdb_test "set build-id-verbose 1" "" \
++ "set build-id-verbose"
++
++ gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \
++ "set debug-file-directory"
++
++ gdb_test "core-file [standard_output_file gcore.test]" \
++ "Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install $binfile\r\n.*" \
++ "test second yum/dnf warning"
++}
++
++# Leaving the link there will cause breakage in the next run.
++remote_exec build "rm -f [standard_output_file ${build_id_without_debug}]"
diff --git a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
new file mode 100644
index 0000000..abea6e6
--- /dev/null
+++ b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
@@ -0,0 +1,42 @@
+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)
+ #include
+ #endif
+
++/* Workarodun https://bugzilla.redhat.com/show_bug.cgi?id=643031
++ librpm must not exit() an application on SIGINT
++
++ Enable or disable a signal handler. SIGNUM: signal to enable (or disable
++ if negative). HANDLER: sa_sigaction handler (or NULL to use
++ rpmsqHandler()). Returns: no. of refs, -1 on error. */
++extern int rpmsqEnable (int signum, /* rpmsqAction_t handler */ void *handler);
++int
++rpmsqEnable (int signum, /* rpmsqAction_t handler */ void *handler)
++{
++ return 0;
++}
++
+ /* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
+ and avoid their duplicities during a single inferior run. */
+
+diff --git a/gdb/proc-service.list b/gdb/proc-service.list
+--- a/gdb/proc-service.list
++++ b/gdb/proc-service.list
+@@ -37,4 +37,7 @@
+ ps_pstop;
+ ps_ptread;
+ ps_ptwrite;
++
++ /* gdb-6.6-buildid-locate-rpm.patch */
++ rpmsqEnable;
+ };
diff --git a/gdb-6.6-buildid-locate-rpm-scl.patch b/gdb-6.6-buildid-locate-rpm-scl.patch
new file mode 100644
index 0000000..ca683ed
--- /dev/null
+++ b/gdb-6.6-buildid-locate-rpm-scl.patch
@@ -0,0 +1,128 @@
+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;
+ /* Returns the count of newly added rpms. */
+
+ static int
++#ifndef GDB_INDEX_VERIFY_VENDOR
+ missing_rpm_enlist (const char *filename)
++#else
++missing_rpm_enlist_1 (const char *filename, int verify_vendor)
++#endif
+ {
+ static int rpm_init_done = 0;
+ rpmts ts;
+@@ -850,7 +854,11 @@ missing_rpm_enlist (const char *filename)
+ mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
+ if (mi != NULL)
+ {
++#ifndef GDB_INDEX_VERIFY_VENDOR
+ for (;;)
++#else
++ if (!verify_vendor) for (;;)
++#endif
+ {
+ Header h;
+ char *debuginfo, **slot, *s, *s2;
+@@ -968,6 +976,37 @@ missing_rpm_enlist (const char *filename)
+ xfree (debuginfo);
+ count++;
+ }
++#ifdef GDB_INDEX_VERIFY_VENDOR
++ else /* verify_vendor */
++ {
++ int vendor_pass = 0, vendor_fail = 0;
++
++ for (;;)
++ {
++ Header h;
++ errmsg_t err;
++ char *vendor;
++
++ h = rpmdbNextIterator_p (mi);
++ if (h == NULL)
++ break;
++
++ vendor = headerFormat_p (h, "%{vendor}", &err);
++ if (!vendor)
++ {
++ warning (_("Error querying the rpm file `%s': %s"), filename,
++ err);
++ continue;
++ }
++ if (strcmp (vendor, "Red Hat, Inc.") == 0)
++ vendor_pass = 1;
++ else
++ vendor_fail = 1;
++ xfree (vendor);
++ }
++ count = vendor_pass != 0 && vendor_fail == 0;
++ }
++#endif
+
+ rpmdbFreeIterator_p (mi);
+ }
+@@ -977,6 +1016,20 @@ missing_rpm_enlist (const char *filename)
+ return count;
+ }
+
++#ifdef GDB_INDEX_VERIFY_VENDOR
++missing_rpm_enlist (const char *filename)
++{
++ return missing_rpm_enlist_1 (filename, 0);
++}
++
++extern int rpm_verify_vendor (const char *filename);
++int
++rpm_verify_vendor (const char *filename)
++{
++ return missing_rpm_enlist_1 (filename, 1);
++}
++#endif
++
+ 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,
+ "set use-deprecated-index-sections on". */
+ if (version < 6 && !deprecated_ok)
+ {
++#ifdef GDB_INDEX_VERIFY_VENDOR
++ extern int rpm_verify_vendor (const char *filename);
++
++ /* Red Hat Developer Toolset exception. */
++ if (rpm_verify_vendor (filename))
++ {}
++ else
++ {
++
++#endif
+ static int warning_printed = 0;
+ if (!warning_printed)
+ {
+@@ -3508,6 +3518,10 @@ to use the section anyway."),
+ warning_printed = 1;
+ }
+ return 0;
++#ifdef GDB_INDEX_VERIFY_VENDOR
++
++ }
++#endif
+ }
+ /* Version 7 indices generated by gold refer to the CU for a symbol instead
+ of the TU (for symbols coming from TUs),
diff --git a/gdb-6.6-buildid-locate-rpm.patch b/gdb-6.6-buildid-locate-rpm.patch
new file mode 100644
index 0000000..6e1cef8
--- /dev/null
+++ b/gdb-6.6-buildid-locate-rpm.patch
@@ -0,0 +1,1508 @@
+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
+@@ -11,7 +11,223 @@
+ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ # PARTICULAR PURPOSE.
+
++# 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
++# 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.
++#
++# As a special exception to the GNU General Public License, if you
++# distribute this file as part of a program that contains a
++# configuration script generated by Autoconf, you may include it under
++# the same distribution terms that you use for the rest of that program.
++
++# PKG_PROG_PKG_CONFIG([MIN-VERSION])
++# ----------------------------------
++AC_DEFUN([PKG_PROG_PKG_CONFIG],
++[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
++m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
++m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
++AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
++AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
++AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
++
++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
++ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
++fi
++if test -n "$PKG_CONFIG"; then
++ _pkg_min_version=m4_default([$1], [0.9.0])
++ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ PKG_CONFIG=""
++ fi
++fi[]dnl
++])# PKG_PROG_PKG_CONFIG
++
++# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
++#
++# Check to see whether a particular set of modules exists. Similar
++# to PKG_CHECK_MODULES(), but does not set variables or print errors.
++#
++# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++# only at the first occurence in configure.ac, so if the first place
++# it's called might be skipped (such as if it is within an "if", you
++# have to call PKG_CHECK_EXISTS manually
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_EXISTS],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++if test -n "$PKG_CONFIG" && \
++ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
++ m4_default([$2], [:])
++m4_ifvaln([$3], [else
++ $3])dnl
++fi])
++
++# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
++# ---------------------------------------------
++m4_define([_PKG_CONFIG],
++[if test -n "$$1"; then
++ pkg_cv_[]$1="$$1"
++ elif test -n "$PKG_CONFIG"; then
++ PKG_CHECK_EXISTS([$3],
++ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
++ test "x$?" != "x0" && pkg_failed=yes ],
++ [pkg_failed=yes])
++ else
++ pkg_failed=untried
++fi[]dnl
++])# _PKG_CONFIG
++
++# _PKG_SHORT_ERRORS_SUPPORTED
++# -----------------------------
++AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++ _pkg_short_errors_supported=yes
++else
++ _pkg_short_errors_supported=no
++fi[]dnl
++])# _PKG_SHORT_ERRORS_SUPPORTED
++
++
++# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
++# [ACTION-IF-NOT-FOUND])
++#
++#
++# Note that if there is a possibility the first call to
++# PKG_CHECK_MODULES might not happen, you should be sure to include an
++# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
++#
++#
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_MODULES],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
++AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
++
++pkg_failed=no
++AC_MSG_CHECKING([for $1])
++
++_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
++_PKG_CONFIG([$1][_LIBS], [libs], [$2])
++
++m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
++and $1[]_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.])
++
++if test $pkg_failed = yes; then
++ 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
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
++ fi
++ # Put the nasty error message in config.log where it belongs
++ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
++
++ m4_default([$4], [AC_MSG_ERROR(
++[Package requirements ($2) were not met:
++
++$$1_PKG_ERRORS
++
++Consider adjusting the PKG_CONFIG_PATH environment variable if you
++installed software in a non-standard prefix.
++
++_PKG_TEXT])[]dnl
++ ])
++elif test $pkg_failed = untried; then
++ 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
++path to pkg-config.
++
++_PKG_TEXT
++
++To get pkg-config, see .])[]dnl
++ ])
++else
++ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
++ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
++ AC_MSG_RESULT([yes])
++ $3
++fi[]dnl
++])# PKG_CHECK_MODULES
++
++
++# PKG_INSTALLDIR(DIRECTORY)
++# -------------------------
++# Substitutes the variable pkgconfigdir as the location where a module
++# should install pkg-config .pc files. By default the directory is
++# $libdir/pkgconfig, but the default can be changed by passing
++# DIRECTORY. The user can override through the --with-pkgconfigdir
++# parameter.
++AC_DEFUN([PKG_INSTALLDIR],
++[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
++m4_pushdef([pkg_description],
++ [pkg-config installation directory @<:@]pkg_default[@:>@])
++AC_ARG_WITH([pkgconfigdir],
++ [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
++ [with_pkgconfigdir=]pkg_default)
++AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
++m4_popdef([pkg_default])
++m4_popdef([pkg_description])
++]) dnl PKG_INSTALLDIR
++
++
++# PKG_NOARCH_INSTALLDIR(DIRECTORY)
++# -------------------------
++# Substitutes the variable noarch_pkgconfigdir as the location where a
++# module should install arch-independent pkg-config .pc files. By
++# default the directory is $datadir/pkgconfig, but the default can be
++# changed by passing DIRECTORY. The user can override through the
++# --with-noarch-pkgconfigdir parameter.
++AC_DEFUN([PKG_NOARCH_INSTALLDIR],
++[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
++m4_pushdef([pkg_description],
++ [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
++AC_ARG_WITH([noarch-pkgconfigdir],
++ [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
++ [with_noarch_pkgconfigdir=]pkg_default)
++AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
++m4_popdef([pkg_default])
++m4_popdef([pkg_description])
++]) dnl PKG_NOARCH_INSTALLDIR
++
++
++# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
++# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
++# -------------------------------------------
++# Retrieves the value of the pkg-config variable for the given module.
++AC_DEFUN([PKG_CHECK_VAR],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
++
++_PKG_CONFIG([$1], [variable="][$3]["], [$2])
++AS_VAR_COPY([$1], [pkg_cv_][$1])
++
++AS_VAR_IF([$1], [""], [$5], [$4])dnl
++])# PKG_CHECK_VAR
++
+ m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
++
+ # AM_AUX_DIR_EXPAND -*- Autoconf -*-
+
+ # Copyright (C) 2001-2017 Free Software Foundation, Inc.
+diff --git a/gdb/build-id.c b/gdb/build-id.c
+--- a/gdb/build-id.c
++++ b/gdb/build-id.c
+@@ -33,6 +33,7 @@
+ #include "gdb_bfd.h"
+ #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)
+ return result;
+ }
+
++#ifdef HAVE_LIBRPM
++
++#include
++#include
++#include
++#include
++#ifdef DLOPEN_LIBRPM
++#include
++#endif
++
++/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
++ and avoid their duplicities during a single inferior run. */
++
++static struct htab *missing_rpm_hash;
++
++/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
++ all the rpms right before the nearest GDB prompt. It gets cleared after
++ each such print (it is questionable if we should clear it after the print).
++ */
++
++struct missing_rpm
++ {
++ struct missing_rpm *next;
++ char rpm[1];
++ };
++static struct missing_rpm *missing_rpm_list;
++static int missing_rpm_list_entries;
++
++/* Returns the count of newly added rpms. */
++
++static int
++missing_rpm_enlist (const char *filename)
++{
++ static int rpm_init_done = 0;
++ rpmts ts;
++ rpmdbMatchIterator mi;
++ int count = 0;
++
++#ifdef DLOPEN_LIBRPM
++ /* Duplicate here the declarations to verify they match. The same sanity
++ check is present also in `configure.ac'. */
++ extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++ static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
++ extern int rpmReadConfigFiles(const char * file, const char * target);
++ static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
++ extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++ static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
++ extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++ static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
++ extern rpmts rpmtsCreate(void);
++ static rpmts (*rpmtsCreate_p) (void);
++ extern rpmts rpmtsFree(rpmts ts);
++ static rpmts (*rpmtsFree_p) (rpmts ts);
++ extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++ const void * keyp, size_t keylen);
++ static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
++ rpmTag rpmtag,
++ const void *keyp,
++ size_t keylen);
++#else /* !DLOPEN_LIBRPM */
++# define headerFormat_p headerFormat
++# define rpmReadConfigFiles_p rpmReadConfigFiles
++# define rpmdbFreeIterator_p rpmdbFreeIterator
++# define rpmdbNextIterator_p rpmdbNextIterator
++# define rpmtsCreate_p rpmtsCreate
++# define rpmtsFree_p rpmtsFree
++# define rpmtsInitIterator_p rpmtsInitIterator
++#endif /* !DLOPEN_LIBRPM */
++
++ gdb_assert (filename != NULL);
++
++ if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
++ return 0;
++
++ if (is_target_filename (filename))
++ return 0;
++
++ if (filename[0] != '/')
++ {
++ warning (_("Ignoring non-absolute filename: <%s>"), filename);
++ return 0;
++ }
++
++ if (!rpm_init_done)
++ {
++ static int init_tried;
++
++ /* Already failed the initialization before? */
++ if (init_tried)
++ return 0;
++ init_tried = 1;
++
++#ifdef DLOPEN_LIBRPM
++ {
++ void *h;
++
++ h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
++ if (!h)
++ {
++ warning (_("Unable to open \"%s\" (%s), "
++ "missing debuginfos notifications will not be displayed"),
++ DLOPEN_LIBRPM, dlerror ());
++ return 0;
++ }
++
++ if (!((headerFormat_p = (char *(*) (Header h, const char * fmt, errmsg_t *errmsg)) dlsym (h, "headerFormat"))
++ && (rpmReadConfigFiles_p = (int (*) (const char * file, const char * target)) dlsym (h, "rpmReadConfigFiles"))
++ && (rpmdbFreeIterator_p = (rpmdbMatchIterator (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbFreeIterator"))
++ && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator"))
++ && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate"))
++ && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree"))
++ && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator"))))
++ {
++ warning (_("Opened library \"%s\" is incompatible (%s), "
++ "missing debuginfos notifications will not be displayed"),
++ DLOPEN_LIBRPM, dlerror ());
++ if (dlclose (h))
++ warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
++ dlerror ());
++ return 0;
++ }
++ }
++#endif /* DLOPEN_LIBRPM */
++
++ if (rpmReadConfigFiles_p (NULL, NULL) != 0)
++ {
++ warning (_("Error reading the rpm configuration files"));
++ return 0;
++ }
++
++ rpm_init_done = 1;
++ }
++
++ ts = rpmtsCreate_p ();
++
++ mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
++ if (mi != NULL)
++ {
++ for (;;)
++ {
++ Header h;
++ char *debuginfo, **slot, *s, *s2;
++ errmsg_t err;
++ size_t srcrpmlen = sizeof (".src.rpm") - 1;
++ size_t debuginfolen = sizeof ("-debuginfo") - 1;
++ rpmdbMatchIterator mi_debuginfo;
++
++ h = rpmdbNextIterator_p (mi);
++ if (h == NULL)
++ break;
++
++ /* Verify the debuginfo file is not already installed. */
++
++ debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
++ &err);
++ if (!debuginfo)
++ {
++ warning (_("Error querying the rpm file `%s': %s"), filename,
++ err);
++ continue;
++ }
++ /* s = `.src.rpm-debuginfo.%{arch}' */
++ s = strrchr (debuginfo, '-') - srcrpmlen;
++ s2 = NULL;
++ if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
++ {
++ /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
++ s2 = (char *) memrchr (debuginfo, '-', s - debuginfo);
++ }
++ if (s2)
++ {
++ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
++ s2 = (char *) memrchr (debuginfo, '-', s2 - debuginfo);
++ }
++ if (!s2)
++ {
++ warning (_("Error querying the rpm file `%s': %s"), filename,
++ debuginfo);
++ xfree (debuginfo);
++ continue;
++ }
++ /* s = `.src.rpm-debuginfo.%{arch}' */
++ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
++ memmove (s2 + debuginfolen, s2, s - s2);
++ memcpy (s2, "-debuginfo", debuginfolen);
++ /* s = `XXXX.%{arch}' */
++ /* strlen ("XXXX") == srcrpmlen + debuginfolen */
++ /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
++ /* strlen ("XX") == srcrpmlen */
++ memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
++ strlen (s + srcrpmlen + debuginfolen) + 1);
++ /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
++
++ /* RPMDBI_PACKAGES requires keylen == sizeof (int). */
++ /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */
++ mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0);
++ xfree (debuginfo);
++ if (mi_debuginfo)
++ {
++ rpmdbFreeIterator_p (mi_debuginfo);
++ count = 0;
++ break;
++ }
++
++ /* The allocated memory gets utilized below for MISSING_RPM_HASH. */
++ debuginfo = headerFormat_p (h,
++ "%{name}-%{version}-%{release}.%{arch}",
++ &err);
++ if (!debuginfo)
++ {
++ warning (_("Error querying the rpm file `%s': %s"), filename,
++ err);
++ continue;
++ }
++
++ /* Base package name for `debuginfo-install'. We do not use the
++ `yum' command directly as the line
++ yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
++ would be more complicated than just:
++ debuginfo-install NAME-VERSION-RELEASE.ARCH
++ Do not supply the rpm base name (derived from .src.rpm name) as
++ debuginfo-install is unable to install the debuginfo package if
++ the base name PKG binary rpm is not installed while for example
++ PKG-libs would be installed (RH Bug 467901).
++ FUTURE: After multiple debuginfo versions simultaneously installed
++ get supported the support for the VERSION-RELEASE tags handling
++ may need an update. */
++
++ if (missing_rpm_hash == NULL)
++ {
++ /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
++ should not deallocate the entries. */
++
++ missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
++ (int (*) (const void *, const void *)) streq,
++ NULL, xcalloc, xfree);
++ }
++ slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
++ /* XCALLOC never returns NULL. */
++ gdb_assert (slot != NULL);
++ if (*slot == NULL)
++ {
++ struct missing_rpm *missing_rpm;
++
++ *slot = debuginfo;
++
++ missing_rpm = (struct missing_rpm *) xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
++ strcpy (missing_rpm->rpm, debuginfo);
++ missing_rpm->next = missing_rpm_list;
++ missing_rpm_list = missing_rpm;
++ missing_rpm_list_entries++;
++ }
++ else
++ xfree (debuginfo);
++ count++;
++ }
++
++ rpmdbFreeIterator_p (mi);
++ }
++
++ rpmtsFree_p (ts);
++
++ return count;
++}
++
++static bool
++missing_rpm_list_compar (const char *ap, const char *bp)
++{
++ return strcoll (ap, bp) < 0;
++}
++
++/* It returns a NULL-terminated array of strings needing to be FREEd. It may
++ also return only NULL. */
++
++static void
++missing_rpm_list_print (void)
++{
++ struct missing_rpm *list_iter;
++
++ if (missing_rpm_list_entries == 0)
++ return;
++
++ std::vector array (missing_rpm_list_entries);
++ size_t idx = 0;
++
++ for (list_iter = missing_rpm_list; list_iter != NULL;
++ list_iter = list_iter->next)
++ {
++ array[idx++] = list_iter->rpm;
++ }
++ gdb_assert (idx == missing_rpm_list_entries);
++
++ std::sort (array.begin (), array.end (), missing_rpm_list_compar);
++
++ /* We zero out the number of missing RPMs here because of a nasty
++ bug (see RHBZ 1801974).
++
++ When we call 'puts_unfiltered' below, if pagination is on and if
++ the number of missing RPMs is big enough to trigger pagination,
++ we will end up in an infinite recursion. The call chain looks
++ like this:
++
++ missing_rpm_list_print -> puts_unfiltered -> fputs_maybe_filtered
++ -> prompt_for_continue -> display_gdb_prompt ->
++ debug_flush_missing -> missing_rpm_list_print ...
++
++ For this reason, we make sure MISSING_RPM_LIST_ENTRIES is zero
++ *before* calling any print function. */
++ missing_rpm_list_entries = 0;
++
++ printf_unfiltered (_("Missing separate debuginfos, use: %s"),
++#ifdef DNF_DEBUGINFO_INSTALL
++ "dnf "
++#endif
++ "debuginfo-install");
++ for (const char *el : array)
++ {
++ puts_unfiltered (" ");
++ puts_unfiltered (el);
++ }
++ puts_unfiltered ("\n");
++
++ while (missing_rpm_list != NULL)
++ {
++ list_iter = missing_rpm_list;
++ missing_rpm_list = list_iter->next;
++ xfree (list_iter);
++ }
++}
++
++static void
++missing_rpm_change (void)
++{
++ debug_flush_missing ();
++
++ gdb_assert (missing_rpm_list == NULL);
++ if (missing_rpm_hash != NULL)
++ {
++ htab_delete (missing_rpm_hash);
++ missing_rpm_hash = NULL;
++ }
++}
++
++enum missing_exec
++ {
++ /* Init state. EXEC_BFD also still could be NULL. */
++ MISSING_EXEC_NOT_TRIED,
++ /* We saw a non-NULL EXEC_BFD but RPM has no info about it. */
++ MISSING_EXEC_NOT_FOUND,
++ /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
++ or separate) or the main executable's RPM is now contained in
++ MISSING_RPM_HASH. */
++ MISSING_EXEC_ENLISTED
++ };
++static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
++
++#endif /* HAVE_LIBRPM */
++
++void
++debug_flush_missing (void)
++{
++#ifdef HAVE_LIBRPM
++ missing_rpm_list_print ();
++#endif
++}
++
+ /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
+- Try to install the hash file ...
++ yum --enablerepo='*debug*' install ...
+ avoidance. */
+
+ struct missing_filepair
+@@ -753,11 +1120,17 @@ missing_filepair_change (void)
+ /* All their memory came just from missing_filepair_OBSTACK. */
+ missing_filepair_hash = NULL;
+ }
++#ifdef HAVE_LIBRPM
++ missing_exec = MISSING_EXEC_NOT_TRIED;
++#endif
+ }
+
+ static void
+ debug_print_executable_changed (void)
+ {
++#ifdef HAVE_LIBRPM
++ missing_rpm_change ();
++#endif
+ missing_filepair_change ();
+ }
+
+@@ -824,14 +1197,38 @@ debug_print_missing (const char *binary, const char *debug)
+
+ *slot = missing_filepair;
+
+- /* We do not collect and flush these messages as each such message
+- already requires its own separate lines. */
++#ifdef HAVE_LIBRPM
++ if (missing_exec == MISSING_EXEC_NOT_TRIED)
++ {
++ const char *execfilename = get_exec_file (0);
+
+- fprintf_unfiltered (gdb_stdlog,
+- _("Missing separate debuginfo for %s\n"), binary);
+- if (debug != NULL)
+- fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
+- debug);
++ if (execfilename != NULL)
++ {
++ if (missing_rpm_enlist (execfilename) == 0)
++ missing_exec = MISSING_EXEC_NOT_FOUND;
++ else
++ missing_exec = MISSING_EXEC_ENLISTED;
++ }
++ }
++ if (missing_exec != MISSING_EXEC_ENLISTED)
++ if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
++ && (debug == NULL || missing_rpm_enlist (debug) == 0))
++#endif /* HAVE_LIBRPM */
++ {
++ /* We do not collect and flush these messages as each such message
++ already requires its own separate lines. */
++
++ fprintf_unfiltered (gdb_stdlog,
++ _("Missing separate debuginfo for %s\n"), binary);
++ if (debug != NULL)
++ fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
++#ifdef DNF_DEBUGINFO_INSTALL
++ "dnf"
++#else
++ "yum"
++#endif
++ " --enablerepo='*debug*' install", debug);
++ }
+ }
+
+ /* See build-id.h. */
+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
+
++/* librpm version specific library name to dlopen. */
++#undef DLOPEN_LIBRPM
++
+ /* Define to 1 if translation of program messages to the user's native
+ language is requested. */
+ #undef ENABLE_NLS
+@@ -245,6 +248,9 @@
+ /* Define if you have the mpfr library. */
+ #undef HAVE_LIBMPFR
+
++/* Define if librpm library is being used. */
++#undef HAVE_LIBRPM
++
+ /* Define to 1 if you have the header file. */
+ #undef HAVE_LIBUNWIND_IA64_H
+
+diff --git a/gdb/configure b/gdb/configure
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -761,6 +761,11 @@ CODESIGN_CERT
+ HAVE_NATIVE_GCORE_TARGET
+ TARGET_OBS
+ subdirs
++RPM_LIBS
++RPM_CFLAGS
++PKG_CONFIG_LIBDIR
++PKG_CONFIG_PATH
++PKG_CONFIG
+ GDB_DATADIR
+ DEBUGDIR
+ MAKEINFO_EXTRA_FLAGS
+@@ -864,6 +869,7 @@ with_gdb_datadir
+ with_relocated_sources
+ with_auto_load_dir
+ with_auto_load_safe_path
++with_rpm
+ enable_targets
+ enable_64_bit_bfd
+ enable_gdbmi
+@@ -926,6 +932,11 @@ CCC
+ CPP
+ MAKEINFO
+ MAKEINFOFLAGS
++PKG_CONFIG
++PKG_CONFIG_PATH
++PKG_CONFIG_LIBDIR
++RPM_CFLAGS
++RPM_LIBS
+ YACC
+ YFLAGS
+ XMKMF'
+@@ -1598,6 +1609,8 @@ Optional Packages:
+ [--with-auto-load-dir]
+ --without-auto-load-safe-path
+ do not restrict auto-loaded files locations
++ --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
++ 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
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
+ $as_echo "$with_auto_load_safe_path" >&6; }
+
++# Integration with rpm library to support missing debuginfo suggestions.
++# --without-rpm: Disable any rpm support.
++# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
++# Even with runtime missing `libname.so' GDB will still other run correctly.
++# Missing `libname.so' during ./configure will abort the configuration.
++# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
++# minor version first such as `librpm-4.6.so' as minor version differences
++# mean API+ABI incompatibility. If the specific match versioned library name
++# could not be found still open dynamically at least `librpm.so'.
++# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
++# to find librpm for compilation-time linking by pkg-config. GDB binary will
++# be probably linked with the version specific library (as `librpm-4.6.so').
++# Failure to find librpm by pkg-config will abort the configuration.
++# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
++# cannot find librpm use to the rpmless compilation (like `--without-rpm').
++
++
++# Check whether --with-rpm was given.
++if test "${with_rpm+set}" = set; then :
++ withval=$with_rpm;
++else
++ with_rpm="auto"
++fi
++
++
++
++
++if test "x$with_rpm" != "xno"; then
++ if test "x$with_rpm" = "xyes"; then
++ LIBRPM="librpm.so"
++ RPM_REQUIRE=true
++ DLOPEN_REQUIRE=false
++ elif test "x$with_rpm" = "xauto"; then
++ LIBRPM="librpm.so"
++ RPM_REQUIRE=false
++ DLOPEN_REQUIRE=false
++ else
++ LIBRPM="$with_rpm"
++ RPM_REQUIRE=true
++ DLOPEN_REQUIRE=true
++ fi
++ LIBRPM_STRING='"'"$LIBRPM"'"'
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
++$as_echo_n "checking specific librpm version... " >&6; }
++ HAVE_DLOPEN_LIBRPM=false
++ save_LIBS="$LIBS"
++ LIBS="$LIBS -ldl"
++ 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; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
++#include
++#include
++#include
++
++int
++main ()
++{
++
++ void *h;
++ const char *const *rpmverp;
++ FILE *f;
++
++ f = fopen ("conftest.out", "w");
++ if (!f)
++ {
++ fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
++ strerror (errno));
++ return 1;
++ }
++ h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
++ if (!h)
++ {
++ fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
++ return 1;
++ }
++ rpmverp = dlsym (h, "RPMVERSION");
++ if (!rpmverp)
++ {
++ fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
++ return 1;
++ }
++ fprintf (stderr, "RPMVERSION is: \"");
++ fprintf (stderr, "%s\"\n", *rpmverp);
++
++ /* Try to find the specific librpm version only for "librpm.so" as we do
++ not know how to assemble the version string otherwise. */
++
++ if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
++ {
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ else
++ {
++ char *h2_name;
++ void *h2;
++ int major, minor;
++
++ if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
++ {
++ fprintf (stderr, "Unable to parse RPMVERSION.\n");
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ /* Avoid the square brackets by malloc. */
++ h2_name = malloc (64);
++ sprintf (h2_name, "librpm-%d.%d.so", major, minor);
++ h2 = dlopen (h2_name, RTLD_LAZY);
++ if (!h2)
++ {
++ fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ if (h2 != h)
++ {
++ fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
++ $LIBRPM_STRING, h2_name);
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ /* Found the valid .so name with a specific version. */
++ fprintf (f, "%s\n", h2_name);
++ return 0;
++ }
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++
++ DLOPEN_LIBRPM="`cat conftest.out`"
++ if test "x$DLOPEN_LIBRPM" != "x"; then
++ HAVE_DLOPEN_LIBRPM=true
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
++$as_echo "$DLOPEN_LIBRPM" >&6; }
++ fi
++
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ rm -f conftest.out
++
++
++
++ if $HAVE_DLOPEN_LIBRPM; then
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
++$as_echo_n "checking rpm library API compatibility... " >&6; }
++ # The compilation requires -Werror to verify anything.
++ save_CFLAGS="$CFLAGS"
++ CFLAGS="$CFLAGS -Werror"
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
++/* Duplicate here the declarations to verify they match "elfread.c". */
++#include
++#include
++#include
++#include
++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++extern int rpmReadConfigFiles(const char * file, const char * target);
++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++extern rpmts rpmtsCreate(void);
++extern rpmts rpmtsFree(rpmts ts);
++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++ const void * keyp, size_t keylen);
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++
++ LIBRPM_COMPAT=true
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++
++else
++
++ LIBRPM_COMPAT=false
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ CFLAGS="$save_CFLAGS"
++
++ if ! $LIBRPM_COMPAT; then
++ HAVE_DLOPEN_LIBRPM=false
++ fi
++ fi
++
++ if $HAVE_DLOPEN_LIBRPM; then
++ DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
++
++cat >>confdefs.h <<_ACEOF
++#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
++_ACEOF
++
++
++$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
++
++ else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$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
++ fi
++
++
++
++
++
++
++
++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
++ if test -n "$ac_tool_prefix"; then
++ # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
++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 :
++ $as_echo_n "(cached) " >&6
++else
++ case $PKG_CONFIG in
++ [\\/]* | ?:[\\/]*)
++ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
++ ;;
++ *)
++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++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
++ 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
++ fi
++done
++ done
++IFS=$as_save_IFS
++
++ ;;
++esac
++fi
++PKG_CONFIG=$ac_cv_path_PKG_CONFIG
++if test -n "$PKG_CONFIG"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
++$as_echo "$PKG_CONFIG" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++
++fi
++if test -z "$ac_cv_path_PKG_CONFIG"; then
++ ac_pt_PKG_CONFIG=$PKG_CONFIG
++ # Extract the first word of "pkg-config", so it can be a program name with args.
++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 :
++ $as_echo_n "(cached) " >&6
++else
++ case $ac_pt_PKG_CONFIG in
++ [\\/]* | ?:[\\/]*)
++ ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
++ ;;
++ *)
++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++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
++ 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
++ fi
++done
++ done
++IFS=$as_save_IFS
++
++ ;;
++esac
++fi
++ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
++if test -n "$ac_pt_PKG_CONFIG"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
++$as_echo "$ac_pt_PKG_CONFIG" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++ if test "x$ac_pt_PKG_CONFIG" = x; then
++ PKG_CONFIG=""
++ else
++ case $cross_compiling:$ac_tool_warned in
++yes:)
++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
++ac_tool_warned=yes ;;
++esac
++ PKG_CONFIG=$ac_pt_PKG_CONFIG
++ fi
++else
++ PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
++fi
++
++fi
++if test -n "$PKG_CONFIG"; then
++ _pkg_min_version=0.9.0
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
++$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++ else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++ PKG_CONFIG=""
++ fi
++fi
++
++pkg_failed=no
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
++$as_echo_n "checking for RPM... " >&6; }
++
++if test -n "$RPM_CFLAGS"; then
++ pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
++ elif test -n "$PKG_CONFIG"; then
++ if test -n "$PKG_CONFIG" && \
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
++ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
++ ac_status=$?
++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++ test $ac_status = 0; }; then
++ pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
++ test "x$?" != "x0" && pkg_failed=yes
++else
++ pkg_failed=yes
++fi
++ else
++ pkg_failed=untried
++fi
++if test -n "$RPM_LIBS"; then
++ pkg_cv_RPM_LIBS="$RPM_LIBS"
++ elif test -n "$PKG_CONFIG"; then
++ if test -n "$PKG_CONFIG" && \
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
++ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
++ ac_status=$?
++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++ test $ac_status = 0; }; then
++ pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
++ test "x$?" != "x0" && pkg_failed=yes
++else
++ pkg_failed=yes
++fi
++ else
++ pkg_failed=untried
++fi
++
++
++
++if test $pkg_failed = yes; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++ _pkg_short_errors_supported=yes
++else
++ _pkg_short_errors_supported=no
++fi
++ if test $_pkg_short_errors_supported = yes; then
++ RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1`
++ else
++ RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1`
++ fi
++ # Put the nasty error message in config.log where it belongs
++ echo "$RPM_PKG_ERRORS" >&5
++
++ HAVE_LIBRPM=false
++elif test $pkg_failed = untried; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++ HAVE_LIBRPM=false
++else
++ RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
++ RPM_LIBS=$pkg_cv_RPM_LIBS
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++ HAVE_LIBRPM=true
++fi
++
++ if $HAVE_LIBRPM; then
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
++$as_echo_n "checking rpm library API compatibility... " >&6; }
++ # The compilation requires -Werror to verify anything.
++ save_CFLAGS="$CFLAGS"
++ CFLAGS="$CFLAGS -Werror"
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
++/* Duplicate here the declarations to verify they match "elfread.c". */
++#include
++#include
++#include
++#include
++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++extern int rpmReadConfigFiles(const char * file, const char * target);
++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++extern rpmts rpmtsCreate(void);
++extern rpmts rpmtsFree(rpmts ts);
++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++ const void * keyp, size_t keylen);
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++
++ LIBRPM_COMPAT=true
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++
++else
++
++ LIBRPM_COMPAT=false
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ CFLAGS="$save_CFLAGS"
++
++ if ! $LIBRPM_COMPAT; then
++ HAVE_LIBRPM=false
++ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
++ fi
++ fi
++
++ if $HAVE_LIBRPM; then
++
++$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
++
++ CFLAGS="$CFLAGS $RPM_CFLAGS"
++ LIBS="$LIBS $RPM_LIBS"
++ else
++ if $RPM_REQUIRE; then
++ 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;}
++ fi
++ fi
++ fi
++fi
++
+
+
+ subdirs="$subdirs testsuite"
+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,
+ [Directories safe to hold auto-loaded files.])
+ AC_MSG_RESULT([$with_auto_load_safe_path])
+
++# Integration with rpm library to support missing debuginfo suggestions.
++# --without-rpm: Disable any rpm support.
++# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
++# Even with runtime missing `libname.so' GDB will still other run correctly.
++# Missing `libname.so' during ./configure will abort the configuration.
++# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
++# minor version first such as `librpm-4.6.so' as minor version differences
++# mean API+ABI incompatibility. If the specific match versioned library name
++# could not be found still open dynamically at least `librpm.so'.
++# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
++# to find librpm for compilation-time linking by pkg-config. GDB binary will
++# be probably linked with the version specific library (as `librpm-4.6.so').
++# Failure to find librpm by pkg-config will abort the configuration.
++# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
++# cannot find librpm use to the rpmless compilation (like `--without-rpm').
++
++AC_ARG_WITH([rpm],
++ [AS_HELP_STRING([--with-rpm],
++ [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
++
++m4_pattern_allow([^AC_MSG_ERROR$])
++m4_pattern_allow([^AC_MSG_WARN$])
++if test "x$with_rpm" != "xno"; then
++ if test "x$with_rpm" = "xyes"; then
++ LIBRPM="librpm.so"
++ RPM_REQUIRE=true
++ DLOPEN_REQUIRE=false
++ elif test "x$with_rpm" = "xauto"; then
++ LIBRPM="librpm.so"
++ RPM_REQUIRE=false
++ DLOPEN_REQUIRE=false
++ else
++ LIBRPM="$with_rpm"
++ RPM_REQUIRE=true
++ DLOPEN_REQUIRE=true
++ fi
++ LIBRPM_STRING='"'"$LIBRPM"'"'
++
++ AC_MSG_CHECKING([specific librpm version])
++ HAVE_DLOPEN_LIBRPM=false
++ save_LIBS="$LIBS"
++ LIBS="$LIBS -ldl"
++ AC_RUN_IFELSE(AC_LANG_PROGRAM([[
++#include
++#include
++#include
++ ]], [[
++ void *h;
++ const char *const *rpmverp;
++ FILE *f;
++
++ f = fopen ("conftest.out", "w");
++ if (!f)
++ {
++ fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
++ strerror (errno));
++ return 1;
++ }
++ h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
++ if (!h)
++ {
++ fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
++ return 1;
++ }
++ rpmverp = dlsym (h, "RPMVERSION");
++ if (!rpmverp)
++ {
++ fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
++ return 1;
++ }
++ fprintf (stderr, "RPMVERSION is: \"");
++ fprintf (stderr, "%s\"\n", *rpmverp);
++
++ /* Try to find the specific librpm version only for "librpm.so" as we do
++ not know how to assemble the version string otherwise. */
++
++ if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
++ {
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ else
++ {
++ char *h2_name;
++ void *h2;
++ int major, minor;
++
++ if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
++ {
++ fprintf (stderr, "Unable to parse RPMVERSION.\n");
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ /* Avoid the square brackets by malloc. */
++ h2_name = malloc (64);
++ sprintf (h2_name, "librpm-%d.%d.so", major, minor);
++ h2 = dlopen (h2_name, RTLD_LAZY);
++ if (!h2)
++ {
++ fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ if (h2 != h)
++ {
++ fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
++ $LIBRPM_STRING, h2_name);
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ /* Found the valid .so name with a specific version. */
++ fprintf (f, "%s\n", h2_name);
++ return 0;
++ }
++ ]]), [
++ DLOPEN_LIBRPM="`cat conftest.out`"
++ if test "x$DLOPEN_LIBRPM" != "x"; then
++ HAVE_DLOPEN_LIBRPM=true
++ AC_MSG_RESULT($DLOPEN_LIBRPM)
++ fi
++ ])
++ rm -f conftest.out
++
++ m4_define([CHECK_LIBRPM_COMPAT], [
++ AC_MSG_CHECKING([rpm library API compatibility])
++ # The compilation requires -Werror to verify anything.
++ save_CFLAGS="$CFLAGS"
++ CFLAGS="$CFLAGS -Werror"
++ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
++/* Duplicate here the declarations to verify they match "elfread.c". */
++#include
++#include
++#include
++#include
++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++extern int rpmReadConfigFiles(const char * file, const char * target);
++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++extern rpmts rpmtsCreate(void);
++extern rpmts rpmtsFree(rpmts ts);
++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++ const void * keyp, size_t keylen);
++ ]]), [
++ LIBRPM_COMPAT=true
++ AC_MSG_RESULT(yes)
++ ], [
++ LIBRPM_COMPAT=false
++ AC_MSG_RESULT(no)
++ ])
++ CFLAGS="$save_CFLAGS"
++ ])
++
++ if $HAVE_DLOPEN_LIBRPM; then
++ CHECK_LIBRPM_COMPAT
++ if ! $LIBRPM_COMPAT; then
++ HAVE_DLOPEN_LIBRPM=false
++ fi
++ fi
++
++ if $HAVE_DLOPEN_LIBRPM; then
++ DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
++ AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
++ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
++ else
++ AC_MSG_RESULT(no)
++ LIBS="$save_LIBS"
++ if $DLOPEN_REQUIRE; then
++ AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
++ fi
++ PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
++
++ if $HAVE_LIBRPM; then
++ CHECK_LIBRPM_COMPAT
++ if ! $LIBRPM_COMPAT; then
++ HAVE_LIBRPM=false
++ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
++ fi
++ fi
++
++ if $HAVE_LIBRPM; then
++ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
++ CFLAGS="$CFLAGS $RPM_CFLAGS"
++ LIBS="$LIBS $RPM_LIBS"
++ else
++ if $RPM_REQUIRE; then
++ AC_MSG_ERROR($RPM_PKG_ERRORS)
++ else
++ AC_MSG_WARN($RPM_PKG_ERRORS)
++ fi
++ fi
++ fi
++fi
++
+ AC_CONFIG_SUBDIRS(testsuite)
+
+ # Check whether to support alternative target configurations
+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-sigmask.h"
++#include "symfile.h"
+
+ /* readline include files. */
+ #include "readline/readline.h"
+@@ -363,6 +364,8 @@ display_gdb_prompt (const char *new_prompt)
+ /* Reset the nesting depth used when trace-commands is set. */
+ reset_command_nest_depth ();
+
++ debug_flush_missing ();
++
+ /* 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)
+ command_handler (cmd);
+
+ if (ui->prompt_state != PROMPTED)
+- display_gdb_prompt (0);
++ {
++ debug_flush_missing ();
++ display_gdb_prompt (0);
++ }
+ }
+ }
+
+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);
+ /* 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 */
+
diff --git a/gdb-6.6-buildid-locate-solib-missing-ids.patch b/gdb-6.6-buildid-locate-solib-missing-ids.patch
new file mode 100644
index 0000000..73b763a
--- /dev/null
+++ b/gdb-6.6-buildid-locate-solib-missing-ids.patch
@@ -0,0 +1,237 @@
+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,
+ }
+
+ {
+- struct bfd_build_id *build_id;
++ struct bfd_build_id *build_id = NULL;
+
+ strncpy (newobj->so_original_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1);
+ newobj->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
+ /* May get overwritten below. */
+ strcpy (newobj->so_name, newobj->so_original_name);
+
+- build_id = build_id_addr_get (((lm_info_svr4 *) newobj->lm_info)->l_ld);
++ /* In the case the main executable was found according to its build-id
++ (from a core file) prevent loading a different build of a library
++ with accidentally the same SO_NAME.
++
++ It suppresses bogus backtraces (and prints "??" there instead) if
++ the on-disk files no longer match the running program version.
++
++ If the main executable was not loaded according to its build-id do
++ 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)
++ 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,
+ xfree (name);
+ }
+ else
+- {
+- debug_print_missing (newobj->so_name, build_id_filename);
+-
+- /* In the case the main executable was found according to
+- its build-id (from a core file) prevent loading
+- a different build of a library with accidentally the
+- same SO_NAME.
+-
+- It suppresses bogus backtraces (and prints "??" there
+- instead) if the on-disk files no longer match the
+- running program version. */
+-
+- if (symfile_objfile != NULL
+- && (symfile_objfile->flags
+- & OBJF_BUILD_ID_CORE_LOADED) != 0)
+- newobj->so_name[0] = 0;
+- }
++ debug_print_missing (newobj->so_name, build_id_filename);
+
+ xfree (build_id_filename);
+ xfree (build_id);
+diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c
+@@ -0,0 +1,21 @@
++/* Copyright 2010 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 . */
++
++void
++lib (void)
++{
++}
+diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c
+@@ -0,0 +1,25 @@
++/* Copyright 2010 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 . */
++
++extern void lib (void);
++
++int
++main (void)
++{
++ lib ();
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
+@@ -0,0 +1,105 @@
++# 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 .
++
++if {[skip_shlib_tests]} {
++ return 0
++}
++
++set testfile "gcore-buildid-exec-but-not-solib"
++set srcmainfile ${testfile}-main.c
++set srclibfile ${testfile}-lib.c
++set libfile [standard_output_file ${testfile}-lib.so]
++set objfile [standard_output_file ${testfile}-main.o]
++set executable ${testfile}-main
++set binfile [standard_output_file ${executable}]
++set gcorefile [standard_output_file ${executable}.gcore]
++set outdir [file dirname $binfile]
++
++if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} "debug additional_flags=-Wl,--build-id"] != ""
++ || [gdb_compile ${srcdir}/${subdir}/${srcmainfile} ${objfile} object {debug}] != "" } {
++ unsupported "-Wl,--build-id compilation failed"
++ return -1
++}
++set opts [list debug shlib=${libfile} "additional_flags=-Wl,--build-id"]
++if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } {
++ unsupported "-Wl,--build-id compilation failed"
++ return -1
++}
++
++clean_restart $executable
++gdb_load_shlib $libfile
++
++# Does this gdb support gcore?
++set test "help gcore"
++gdb_test_multiple $test $test {
++ -re "Undefined command: .gcore.*\r\n$gdb_prompt $" {
++ # gcore command not supported -- nothing to test here.
++ unsupported "gdb does not support gcore on this target"
++ return -1;
++ }
++ -re "Save a core file .*\r\n$gdb_prompt $" {
++ pass $test
++ }
++}
++
++if { ![runto lib] } then {
++ return -1
++}
++
++set escapedfilename [string_to_regexp ${gcorefile}]
++
++set test "save a corefile"
++gdb_test_multiple "gcore ${gcorefile}" $test {
++ -re "Saved corefile ${escapedfilename}\r\n$gdb_prompt $" {
++ pass $test
++ }
++ -re "Can't create a corefile\r\n$gdb_prompt $" {
++ unsupported $test
++ return -1
++ }
++}
++
++# Now restart gdb and load the corefile.
++
++clean_restart $executable
++gdb_load_shlib $libfile
++
++set buildid [build_id_debug_filename_get $libfile]
++
++regsub {\.debug$} $buildid {} buildid
++
++set debugdir [standard_output_file ${testfile}-debugdir]
++file delete -force -- $debugdir
++
++file mkdir $debugdir/[file dirname $libfile]
++file copy $libfile $debugdir/${libfile}
++
++file mkdir $debugdir/[file dirname $buildid]
++file copy $libfile $debugdir/${buildid}
++
++remote_exec build "ln -s /lib ${debugdir}/"
++remote_exec build "ln -s /lib64 ${debugdir}/"
++# /usr is not needed, all the libs are in /lib64: libm.so.6 libc.so.6 ld-linux-x86-64.so.2
++
++gdb_test "set solib-absolute-prefix $debugdir"
++
++gdb_test_no_output "set debug-file-directory $debugdir" "set debug-file-directory"
++
++gdb_test "core ${gcorefile}" "Core was generated by .*" "re-load generated corefile"
++
++gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded"
++
++gdb_test "bt"
++gdb_test "info shared"
diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch
new file mode 100644
index 0000000..504c6a9
--- /dev/null
+++ b/gdb-6.6-buildid-locate.patch
@@ -0,0 +1,1377 @@
+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 *
+ bfd_strdup (const char *str)
+ {
+ size_t len = strlen (str) + 1;
+- char *buf = bfd_malloc (len);
++ char *buf = (char *) bfd_malloc (len);
+ if (buf != NULL)
+ memcpy (buf, str, len);
+ return buf;
+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 *
+ bfd_strdup (const char *str)
+ {
+ size_t len = strlen (str) + 1;
+- char *buf = bfd_malloc (len);
++ char *buf = (char *) bfd_malloc (len);
+ if (buf != NULL)
+ memcpy (buf, str, len);
+ return buf;
+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 @@
+ #include "gdbsupport/gdb_vecs.h"
+ #include "symfile.h"
+ #include "objfiles.h"
++#include
++#include "elf-bfd.h"
++#include "elf/common.h"
++#include "elf/external.h"
++#include "elf/internal.h"
+ #include "filenames.h"
++#include "gdb_bfd.h"
++#include "gdbcmd.h"
+ #include "gdbcore.h"
++#include "libbfd.h"
++#include "objfiles.h"
++#include "observable.h"
++#include "symfile.h"
++
++#define BUILD_ID_VERBOSE_NONE 0
++#define BUILD_ID_VERBOSE_FILENAMES 1
++#define BUILD_ID_VERBOSE_BINARY_PARSE 2
++static int build_id_verbose = BUILD_ID_VERBOSE_FILENAMES;
++static void
++show_build_id_verbose (struct ui_file *file, int from_tty,
++ struct cmd_list_element *c, const char *value)
++{
++ fprintf_filtered (file, _("Verbosity level of the build-id locator is %s.\n"),
++ value);
++}
++/* Locate NT_GNU_BUILD_ID and return its matching debug filename.
++ FIXME: NOTE decoding should be unified with the BFD core notes decoding. */
++
++static struct bfd_build_id *
++build_id_buf_get (bfd *templ, gdb_byte *buf, bfd_size_type size)
++{
++ bfd_byte *p;
++
++ p = buf;
++ while (p < buf + size)
++ {
++ /* FIXME: bad alignment assumption. */
++ Elf_External_Note *xnp = (Elf_External_Note *) p;
++ size_t namesz = H_GET_32 (templ, xnp->namesz);
++ size_t descsz = H_GET_32 (templ, xnp->descsz);
++ bfd_byte *descdata = (gdb_byte *) xnp->name + BFD_ALIGN (namesz, 4);
++
++ if (H_GET_32 (templ, xnp->type) == NT_GNU_BUILD_ID
++ && namesz == sizeof "GNU"
++ && memcmp (xnp->name, "GNU", sizeof "GNU") == 0)
++ {
++ size_t sz = descsz;
++ gdb_byte *data = (gdb_byte *) descdata;
++ struct bfd_build_id *retval;
++
++ retval = (struct bfd_build_id *) xmalloc (sizeof *retval - 1 + sz);
++ retval->size = sz;
++ memcpy (retval->data, data, sz);
++
++ return retval;
++ }
++ p = descdata + BFD_ALIGN (descsz, 4);
++ }
++ return NULL;
++}
+
+ /* See build-id.h. */
+
+ const struct bfd_build_id *
+-build_id_bfd_get (bfd *abfd)
++build_id_bfd_shdr_get (bfd *abfd)
+ {
+ if (!bfd_check_format (abfd, bfd_object)
+ && !bfd_check_format (abfd, bfd_core))
+@@ -43,6 +101,348 @@ build_id_bfd_get (bfd *abfd)
+ return NULL;
+ }
+
++/* Core files may have missing (corrupt) SHDR but PDHR is correct there.
++ bfd_elf_bfd_from_remote_memory () has too much overhead by
++ allocating/reading all the available ELF PT_LOADs. */
++
++static struct bfd_build_id *
++build_id_phdr_get (bfd *templ, bfd_vma loadbase, unsigned e_phnum,
++ Elf_Internal_Phdr *i_phdr)
++{
++ int i;
++ struct bfd_build_id *retval = NULL;
++
++ for (i = 0; i < e_phnum; i++)
++ if (i_phdr[i].p_type == PT_NOTE && i_phdr[i].p_filesz > 0)
++ {
++ Elf_Internal_Phdr *hdr = &i_phdr[i];
++ gdb_byte *buf;
++ int err;
++
++ buf = (gdb_byte *) xmalloc (hdr->p_filesz);
++ err = target_read_memory (loadbase + i_phdr[i].p_vaddr, buf,
++ hdr->p_filesz);
++ if (err == 0)
++ retval = build_id_buf_get (templ, buf, hdr->p_filesz);
++ else
++ retval = NULL;
++ xfree (buf);
++ if (retval != NULL)
++ break;
++ }
++ return retval;
++}
++
++/* First we validate the file by reading in the ELF header and checking
++ the magic number. */
++
++static inline bfd_boolean
++elf_file_p (Elf64_External_Ehdr *x_ehdrp64)
++{
++ gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr));
++ gdb_assert (offsetof (Elf64_External_Ehdr, e_ident)
++ == offsetof (Elf32_External_Ehdr, e_ident));
++ gdb_assert (sizeof (((Elf64_External_Ehdr *) 0)->e_ident)
++ == sizeof (((Elf32_External_Ehdr *) 0)->e_ident));
++
++ return ((x_ehdrp64->e_ident[EI_MAG0] == ELFMAG0)
++ && (x_ehdrp64->e_ident[EI_MAG1] == ELFMAG1)
++ && (x_ehdrp64->e_ident[EI_MAG2] == ELFMAG2)
++ && (x_ehdrp64->e_ident[EI_MAG3] == ELFMAG3));
++}
++
++/* Translate an ELF file header in external format into an ELF file header in
++ internal format. */
++
++#define H_GET_WORD(bfd, ptr) (is64 ? H_GET_64 (bfd, (ptr)) \
++ : H_GET_32 (bfd, (ptr)))
++#define H_GET_SIGNED_WORD(bfd, ptr) (is64 ? H_GET_S64 (bfd, (ptr)) \
++ : H_GET_S32 (bfd, (ptr)))
++
++static void
++elf_swap_ehdr_in (bfd *abfd,
++ const Elf64_External_Ehdr *src64,
++ Elf_Internal_Ehdr *dst)
++{
++ int is64 = bfd_get_arch_size (abfd) == 64;
++#define SRC(field) (is64 ? src64->field \
++ : ((const Elf32_External_Ehdr *) src64)->field)
++
++ int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
++ memcpy (dst->e_ident, SRC (e_ident), EI_NIDENT);
++ dst->e_type = H_GET_16 (abfd, SRC (e_type));
++ dst->e_machine = H_GET_16 (abfd, SRC (e_machine));
++ dst->e_version = H_GET_32 (abfd, SRC (e_version));
++ if (signed_vma)
++ dst->e_entry = H_GET_SIGNED_WORD (abfd, SRC (e_entry));
++ else
++ dst->e_entry = H_GET_WORD (abfd, SRC (e_entry));
++ dst->e_phoff = H_GET_WORD (abfd, SRC (e_phoff));
++ dst->e_shoff = H_GET_WORD (abfd, SRC (e_shoff));
++ dst->e_flags = H_GET_32 (abfd, SRC (e_flags));
++ dst->e_ehsize = H_GET_16 (abfd, SRC (e_ehsize));
++ dst->e_phentsize = H_GET_16 (abfd, SRC (e_phentsize));
++ dst->e_phnum = H_GET_16 (abfd, SRC (e_phnum));
++ dst->e_shentsize = H_GET_16 (abfd, SRC (e_shentsize));
++ dst->e_shnum = H_GET_16 (abfd, SRC (e_shnum));
++ dst->e_shstrndx = H_GET_16 (abfd, SRC (e_shstrndx));
++
++#undef SRC
++}
++
++/* Translate an ELF program header table entry in external format into an
++ ELF program header table entry in internal format. */
++
++static void
++elf_swap_phdr_in (bfd *abfd,
++ const Elf64_External_Phdr *src64,
++ Elf_Internal_Phdr *dst)
++{
++ int is64 = bfd_get_arch_size (abfd) == 64;
++#define SRC(field) (is64 ? src64->field \
++ : ((const Elf32_External_Phdr *) src64)->field)
++
++ int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
++
++ dst->p_type = H_GET_32 (abfd, SRC (p_type));
++ dst->p_flags = H_GET_32 (abfd, SRC (p_flags));
++ dst->p_offset = H_GET_WORD (abfd, SRC (p_offset));
++ if (signed_vma)
++ {
++ dst->p_vaddr = H_GET_SIGNED_WORD (abfd, SRC (p_vaddr));
++ dst->p_paddr = H_GET_SIGNED_WORD (abfd, SRC (p_paddr));
++ }
++ else
++ {
++ dst->p_vaddr = H_GET_WORD (abfd, SRC (p_vaddr));
++ dst->p_paddr = H_GET_WORD (abfd, SRC (p_paddr));
++ }
++ dst->p_filesz = H_GET_WORD (abfd, SRC (p_filesz));
++ dst->p_memsz = H_GET_WORD (abfd, SRC (p_memsz));
++ dst->p_align = H_GET_WORD (abfd, SRC (p_align));
++
++#undef SRC
++}
++
++#undef H_GET_SIGNED_WORD
++#undef H_GET_WORD
++
++static Elf_Internal_Phdr *
++elf_get_phdr (bfd *templ, bfd_vma ehdr_vma, unsigned *e_phnum_pointer,
++ bfd_vma *loadbase_pointer)
++{
++ /* sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr) */
++ Elf64_External_Ehdr x_ehdr64; /* Elf file header, external form */
++ Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */
++ bfd_size_type x_phdrs_size;
++ gdb_byte *x_phdrs_ptr;
++ Elf_Internal_Phdr *i_phdrs;
++ int err;
++ unsigned int i;
++ bfd_vma loadbase;
++ int loadbase_set;
++
++ gdb_assert (templ != NULL);
++ gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr));
++
++ /* Read in the ELF header in external format. */
++ err = target_read_memory (ehdr_vma, (bfd_byte *) &x_ehdr64, sizeof x_ehdr64);
++ if (err)
++ {
++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE)
++ warning (_("build-id: Error reading ELF header at address 0x%lx"),
++ (unsigned long) ehdr_vma);
++ return NULL;
++ }
++
++ /* Now check to see if we have a valid ELF file, and one that BFD can
++ make use of. The magic number must match, the address size ('class')
++ and byte-swapping must match our XVEC entry. */
++
++ if (! elf_file_p (&x_ehdr64)
++ || x_ehdr64.e_ident[EI_VERSION] != EV_CURRENT
++ || !((bfd_get_arch_size (templ) == 64
++ && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS64)
++ || (bfd_get_arch_size (templ) == 32
++ && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS32)))
++ {
++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE)
++ warning (_("build-id: Unrecognized ELF header at address 0x%lx"),
++ (unsigned long) ehdr_vma);
++ return NULL;
++ }
++
++ /* Check that file's byte order matches xvec's */
++ switch (x_ehdr64.e_ident[EI_DATA])
++ {
++ case ELFDATA2MSB: /* Big-endian */
++ if (! bfd_header_big_endian (templ))
++ {
++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE)
++ warning (_("build-id: Unrecognized "
++ "big-endian ELF header at address 0x%lx"),
++ (unsigned long) ehdr_vma);
++ return NULL;
++ }
++ break;
++ case ELFDATA2LSB: /* Little-endian */
++ if (! bfd_header_little_endian (templ))
++ {
++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE)
++ warning (_("build-id: Unrecognized "
++ "little-endian ELF header at address 0x%lx"),
++ (unsigned long) ehdr_vma);
++ return NULL;
++ }
++ break;
++ case ELFDATANONE: /* No data encoding specified */
++ default: /* Unknown data encoding specified */
++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE)
++ warning (_("build-id: Unrecognized "
++ "ELF header endianity at address 0x%lx"),
++ (unsigned long) ehdr_vma);
++ return NULL;
++ }
++
++ elf_swap_ehdr_in (templ, &x_ehdr64, &i_ehdr);
++
++ /* The file header tells where to find the program headers.
++ These are what we use to actually choose what to read. */
++
++ if (i_ehdr.e_phentsize != (bfd_get_arch_size (templ) == 64
++ ? sizeof (Elf64_External_Phdr)
++ : sizeof (Elf32_External_Phdr))
++ || i_ehdr.e_phnum == 0)
++ {
++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE)
++ warning (_("build-id: Invalid ELF program headers from the ELF header "
++ "at address 0x%lx"), (unsigned long) ehdr_vma);
++ return NULL;
++ }
++
++ x_phdrs_size = (bfd_get_arch_size (templ) == 64 ? sizeof (Elf64_External_Phdr)
++ : sizeof (Elf32_External_Phdr));
++
++ i_phdrs = (Elf_Internal_Phdr *) xmalloc (i_ehdr.e_phnum * (sizeof *i_phdrs + x_phdrs_size));
++ x_phdrs_ptr = (gdb_byte *) &i_phdrs[i_ehdr.e_phnum];
++ err = target_read_memory (ehdr_vma + i_ehdr.e_phoff, (bfd_byte *) x_phdrs_ptr,
++ i_ehdr.e_phnum * x_phdrs_size);
++ if (err)
++ {
++ free (i_phdrs);
++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE)
++ warning (_("build-id: Error reading "
++ "ELF program headers at address 0x%lx"),
++ (unsigned long) (ehdr_vma + i_ehdr.e_phoff));
++ return NULL;
++ }
++
++ loadbase = ehdr_vma;
++ loadbase_set = 0;
++ for (i = 0; i < i_ehdr.e_phnum; ++i)
++ {
++ elf_swap_phdr_in (templ, (Elf64_External_Phdr *)
++ (x_phdrs_ptr + i * x_phdrs_size), &i_phdrs[i]);
++ /* IA-64 vDSO may have two mappings for one segment, where one mapping
++ is executable only, and one is read only. We must not use the
++ executable one (PF_R is the first one, PF_X the second one). */
++ if (i_phdrs[i].p_type == PT_LOAD && (i_phdrs[i].p_flags & PF_R))
++ {
++ /* Only the first PT_LOAD segment indicates the file bias.
++ Next segments may have P_VADDR arbitrarily higher.
++ If the first segment has P_VADDR zero any next segment must not
++ confuse us, the first one sets LOADBASE certainly enough. */
++ if (!loadbase_set && i_phdrs[i].p_offset == 0)
++ {
++ loadbase = ehdr_vma - i_phdrs[i].p_vaddr;
++ loadbase_set = 1;
++ }
++ }
++ }
++
++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE)
++ warning (_("build-id: Found ELF header at address 0x%lx, loadbase 0x%lx"),
++ (unsigned long) ehdr_vma, (unsigned long) loadbase);
++
++ *e_phnum_pointer = i_ehdr.e_phnum;
++ *loadbase_pointer = loadbase;
++ return i_phdrs;
++}
++
++/* BUILD_ID_ADDR_GET gets ADDR located somewhere in the object.
++ Find the first section before ADDR containing an ELF header.
++ We rely on the fact the sections from multiple files do not mix.
++ FIXME: We should check ADDR is contained _inside_ the section with possibly
++ missing content (P_FILESZ < P_MEMSZ). These omitted sections are currently
++ hidden by _BFD_ELF_MAKE_SECTION_FROM_PHDR. */
++
++static CORE_ADDR build_id_addr;
++struct build_id_addr_sect
++ {
++ struct build_id_addr_sect *next;
++ asection *sect;
++ };
++static struct build_id_addr_sect *build_id_addr_sect;
++
++static void build_id_addr_candidate (bfd *abfd, asection *sect, void *obj)
++{
++ if (build_id_addr >= bfd_section_vma (sect))
++ {
++ struct build_id_addr_sect *candidate;
++
++ candidate = (struct build_id_addr_sect *) xmalloc (sizeof *candidate);
++ candidate->next = build_id_addr_sect;
++ build_id_addr_sect = candidate;
++ candidate->sect = sect;
++ }
++}
++
++struct bfd_build_id *
++build_id_addr_get (CORE_ADDR addr)
++{
++ struct build_id_addr_sect *candidate;
++ struct bfd_build_id *retval = NULL;
++ Elf_Internal_Phdr *i_phdr = NULL;
++ bfd_vma loadbase = 0;
++ unsigned e_phnum = 0;
++
++ if (core_bfd == NULL)
++ return NULL;
++
++ build_id_addr = addr;
++ gdb_assert (build_id_addr_sect == NULL);
++ bfd_map_over_sections (core_bfd, build_id_addr_candidate, NULL);
++
++ /* Sections are sorted in the high-to-low VMAs order.
++ Stop the search on the first ELF header we find.
++ Do not continue the search even if it does not contain NT_GNU_BUILD_ID. */
++
++ for (candidate = build_id_addr_sect; candidate != NULL;
++ candidate = candidate->next)
++ {
++ i_phdr = elf_get_phdr (core_bfd,
++ bfd_section_vma (candidate->sect),
++ &e_phnum, &loadbase);
++ if (i_phdr != NULL)
++ break;
++ }
++
++ if (i_phdr != NULL)
++ {
++ retval = build_id_phdr_get (core_bfd, loadbase, e_phnum, i_phdr);
++ xfree (i_phdr);
++ }
++
++ while (build_id_addr_sect != NULL)
++ {
++ candidate = build_id_addr_sect;
++ build_id_addr_sect = candidate->next;
++ xfree (candidate);
++ }
++
++ return retval;
++}
++
+ /* See build-id.h. */
+
+ int
+@@ -51,7 +451,7 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
+ const struct bfd_build_id *found;
+ int retval = 0;
+
+- found = build_id_bfd_get (abfd);
++ found = build_id_bfd_shdr_get (abfd);
+
+ 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)
+ return retval;
+ }
+
++static char *
++link_resolve (const char *symlink, int level)
++{
++ char buf[PATH_MAX + 1], *target, *retval;
++ ssize_t got;
++
++ if (level > 10)
++ return xstrdup (symlink);
++
++ got = readlink (symlink, buf, sizeof (buf));
++ if (got < 0 || got >= sizeof (buf))
++ return xstrdup (symlink);
++ buf[got] = '\0';
++
++ if (IS_ABSOLUTE_PATH (buf))
++ target = xstrdup (buf);
++ else
++ {
++ const std::string dir (ldirname (symlink));
++
++ target = xstrprintf ("%s"
++#ifndef HAVE_DOS_BASED_FILE_SYSTEM
++ "/"
++#else /* HAVE_DOS_BASED_FILE_SYSTEM */
++ "\\"
++#endif /* HAVE_DOS_BASED_FILE_SYSTEM */
++ "%s", dir.c_str(), buf);
++ }
++
++ retval = link_resolve (target, level + 1);
++ xfree (target);
++ return retval;
++}
++
+ /* Helper for build_id_to_debug_bfd. LINK is a path to a potential
+ build-id-based separate debug file, potentially a symlink to the real file.
+ If the file exists and matches BUILD_ID, return a BFD reference to it. */
+
+ static gdb_bfd_ref_ptr
+-build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
+- const bfd_byte *build_id)
++build_id_to_debug_bfd_1 (const std::string &orig_link, size_t build_id_len,
++ const bfd_byte *build_id, char **link_return)
+ {
++ gdb_bfd_ref_ptr ret_bfd = {};
++ std::string ret_link;
++
+ if (separate_debug_file_debug)
+ {
+- printf_unfiltered (_(" Trying %s..."), link.c_str ());
++ printf_unfiltered (_(" Trying %s..."), orig_link.c_str ());
+ gdb_flush (gdb_stdout);
+ }
+
+- /* lrealpath() is expensive even for the usually non-existent files. */
+- gdb::unique_xmalloc_ptr filename;
+- if (access (link.c_str (), F_OK) == 0)
+- filename.reset (lrealpath (link.c_str ()));
+-
+- if (filename == NULL)
++ for (unsigned seqno = 0;; seqno++)
+ {
+- if (separate_debug_file_debug)
+- printf_unfiltered (_(" no, unable to compute real path\n"));
++ std::string link = orig_link;
+
+- return {};
+- }
++ if (seqno > 0)
++ {
++ /* 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);
++ }
+
+- 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. */
++ if (lstat (link.c_str (), &statbuf_trash) != 0)
++ {
++ /* Stop increasing SEQNO. */
++ break;
++ }
++
++ /* lrealpath() is expensive even for the usually non-existent files. */
++ gdb::unique_xmalloc_ptr filename;
++
++ if (access (link.c_str (), F_OK) == 0)
++ filename.reset (lrealpath (link.c_str ()));
++
++ if (filename == NULL)
++ {
++ if (separate_debug_file_debug)
++ printf_unfiltered (_(" no, unable to compute real path\n"));
++
++ 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);
++
++ if (debug_bfd == NULL)
++ {
++ if (separate_debug_file_debug)
++ printf_unfiltered (_(" no, unable to open.\n"));
++
++ continue;
++ }
++
++ if (!build_id_verify (debug_bfd.get(), build_id_len, build_id))
++ {
++ if (separate_debug_file_debug)
++ printf_unfiltered (_(" no, build-id does not match.\n"));
++
++ continue;
++ }
++
++ ret_bfd = debug_bfd;
++ break;
+ }
+
+- if (!build_id_verify (debug_bfd.get(), build_id_len, build_id))
++ std::string link_all;
++
++ if (ret_bfd != NULL)
+ {
+ if (separate_debug_file_debug)
+- printf_unfiltered (_(" no, build-id does not match.\n"));
+-
+- return {};
++ printf_unfiltered (_(" yes!\n"));
++ }
++ else
++ {
++ /* If none of the real files is found report as missing file
++ always the non-.%u-suffixed file. */
++ std::string link0 = orig_link;
++
++ /* If the symlink has target request to install the target.
++ BASE-debuginfo.rpm contains the symlink but BASE.rpm may be missing.
++ https://bugzilla.redhat.com/show_bug.cgi?id=981154 */
++ std::string link0_resolved (link_resolve (link0.c_str (), 0));
++
++ if (link_all.empty ())
++ link_all = link0_resolved;
++ else
++ {
++ /* Use whitespace instead of DIRNAME_SEPARATOR to be compatible with
++ its possible use as an argument for installation command. */
++ link_all += " " + link0_resolved;
++ }
+ }
+
+- if (separate_debug_file_debug)
+- printf_unfiltered (_(" yes!\n"));
++ if (link_return != NULL)
++ {
++ if (ret_bfd != NULL)
++ {
++ *link_return = xstrdup (ret_link.c_str ());
++ }
++ else
++ {
++ *link_return = xstrdup (link_all.c_str ());
++ }
++ }
+
+- return debug_bfd;
++ return ret_bfd;
+ }
+
+ /* 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,
+
+ static gdb_bfd_ref_ptr
+ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
+- const char *suffix)
++ const char *suffix, char **link_return)
+ {
+ /* 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,
+ if (size > 0)
+ {
+ size--;
+- string_appendf (link, "%02x/", (unsigned) *data++);
++ string_appendf (link, "%02x", (unsigned) *data++);
+ }
+-
++ if (size > 0)
++ link += "/";
+ while (size-- > 0)
+ string_appendf (link, "%02x", (unsigned) *data++);
+
+ link += suffix;
+
+ gdb_bfd_ref_ptr debug_bfd
+- = build_id_to_debug_bfd_1 (link, build_id_len, build_id);
++ = build_id_to_debug_bfd_1 (link, build_id_len, build_id, link_return);
+ 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,
+ if (strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) != 0)
+ {
+ link = gdb_sysroot + link;
+- debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id);
++ debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id,
++ link_return);
+ 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,
+ return {};
+ }
+
++char *
++build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
++{
++ 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;
++
++ result = xstrdup (bfd_get_filename (abfd.get ()));
++ return result;
++}
++
++/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
++ Try to install the hash file ...
++ avoidance. */
++
++struct missing_filepair
++ {
++ char *binary;
++ char *debug;
++ char data[1];
++ };
++
++static struct htab *missing_filepair_hash;
++static struct obstack missing_filepair_obstack;
++
++static void *
++missing_filepair_xcalloc (size_t nmemb, size_t nmemb_size)
++{
++ void *retval;
++ size_t size = nmemb * nmemb_size;
++
++ retval = obstack_alloc (&missing_filepair_obstack, size);
++ memset (retval, 0, size);
++ return retval;
++}
++
++static hashval_t
++missing_filepair_hash_func (const struct missing_filepair *elem)
++{
++ hashval_t retval = 0;
++
++ retval ^= htab_hash_string (elem->binary);
++ if (elem->debug != NULL)
++ retval ^= htab_hash_string (elem->debug);
++
++ return retval;
++}
++
++static int
++missing_filepair_eq (const struct missing_filepair *elem1,
++ const struct missing_filepair *elem2)
++{
++ return strcmp (elem1->binary, elem2->binary) == 0
++ && ((elem1->debug == NULL) == (elem2->debug == NULL))
++ && (elem1->debug == NULL || strcmp (elem1->debug, elem2->debug) == 0);
++}
++
++static void
++missing_filepair_change (void)
++{
++ if (missing_filepair_hash != NULL)
++ {
++ obstack_free (&missing_filepair_obstack, NULL);
++ /* All their memory came just from missing_filepair_OBSTACK. */
++ missing_filepair_hash = NULL;
++ }
++}
++
++static void
++debug_print_executable_changed (void)
++{
++ missing_filepair_change ();
++}
++
++/* Notify user the file BINARY with (possibly NULL) associated separate debug
++ information file DEBUG is missing. DEBUG may or may not be the build-id
++ file such as would be:
++ /usr/lib/debug/.build-id/dd/b1d2ce632721c47bb9e8679f369e2295ce71be.debug
++ */
++
++void
++debug_print_missing (const char *binary, const char *debug)
++{
++ size_t binary_len0 = strlen (binary) + 1;
++ size_t debug_len0 = debug ? strlen (debug) + 1 : 0;
++ struct missing_filepair missing_filepair_find;
++ struct missing_filepair *missing_filepair;
++ struct missing_filepair **slot;
++
++ if (build_id_verbose < BUILD_ID_VERBOSE_FILENAMES)
++ return;
++
++ if (missing_filepair_hash == NULL)
++ {
++ obstack_init (&missing_filepair_obstack);
++ missing_filepair_hash = htab_create_alloc (64,
++ (hashval_t (*) (const void *)) missing_filepair_hash_func,
++ (int (*) (const void *, const void *)) missing_filepair_eq, NULL,
++ missing_filepair_xcalloc, NULL);
++ }
++
++ /* Use MISSING_FILEPAIR_FIND first instead of calling obstack_alloc with
++ obstack_free in the case of a (rare) match. The problem is ALLOC_F for
++ MISSING_FILEPAIR_HASH allocates from MISSING_FILEPAIR_OBSTACK maintenance
++ structures for MISSING_FILEPAIR_HASH. Calling obstack_free would possibly
++ not to free only MISSING_FILEPAIR but also some such structures (allocated
++ during the htab_find_slot call). */
++
++ missing_filepair_find.binary = (char *) binary;
++ missing_filepair_find.debug = (char *) debug;
++ slot = (struct missing_filepair **) htab_find_slot (missing_filepair_hash,
++ &missing_filepair_find,
++ INSERT);
++
++ /* While it may be still printed duplicitely with the missing debuginfo file
++ * it is due to once printing about the binary file build-id link and once
++ * about the .debug file build-id link as both the build-id symlinks are
++ * located in the debuginfo package. */
++
++ if (*slot != NULL)
++ return;
++
++ missing_filepair = (struct missing_filepair *) obstack_alloc (&missing_filepair_obstack,
++ sizeof (*missing_filepair) - 1
++ + binary_len0 + debug_len0);
++ missing_filepair->binary = missing_filepair->data;
++ memcpy (missing_filepair->binary, binary, binary_len0);
++ if (debug != NULL)
++ {
++ missing_filepair->debug = missing_filepair->binary + binary_len0;
++ memcpy (missing_filepair->debug, debug, debug_len0);
++ }
++ else
++ missing_filepair->debug = NULL;
++
++ *slot = missing_filepair;
++
++ /* We do not collect and flush these messages as each such message
++ already requires its own separate lines. */
++
++ fprintf_unfiltered (gdb_stdlog,
++ _("Missing separate debuginfo for %s\n"), binary);
++ if (debug != NULL)
++ fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
++ debug);
++}
++
+ /* See build-id.h. */
+
+ gdb_bfd_ref_ptr
+-build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
++build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id,
++ char **link_return)
+ {
+- return build_id_to_bfd_suffix (build_id_len, build_id, ".debug");
++ return build_id_to_bfd_suffix (build_id_len, build_id, ".debug",
++ link_return);
+ }
+
+ /* See build-id.h. */
+
+ gdb_bfd_ref_ptr
+-build_id_to_exec_bfd (size_t build_id_len, const bfd_byte *build_id)
++build_id_to_exec_bfd (size_t build_id_len, const bfd_byte *build_id,
++ char **link_return)
+ {
+- return build_id_to_bfd_suffix (build_id_len, build_id, "");
++ return build_id_to_bfd_suffix (build_id_len, build_id, "", link_return);
+ }
+
+ /* See build-id.h. */
+
+ std::string
+-find_separate_debug_file_by_buildid (struct objfile *objfile)
++find_separate_debug_file_by_buildid (struct objfile *objfile,
++ gdb::unique_xmalloc_ptr *build_id_filename_return)
+ {
+ const struct bfd_build_id *build_id;
+
+- build_id = build_id_bfd_get (objfile->obfd);
++ if (build_id_filename_return)
++ *build_id_filename_return = NULL;
++
++ build_id = build_id_bfd_shdr_get (objfile->obfd);
+ if (build_id != NULL)
+ {
+ if (separate_debug_file_debug)
+ printf_unfiltered (_("\nLooking for separate debug info (build-id) for "
+ "%s\n"), objfile_name (objfile));
+
++ 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_filename_return ? NULL : &build_id_filename_cstr)));
++ if (build_id_filename_return)
++ {
++ if (!build_id_filename_cstr)
++ gdb_assert (!*build_id_filename_return);
++ else
++ {
++ *build_id_filename_return = gdb::unique_xmalloc_ptr (build_id_filename_cstr);
++ build_id_filename_cstr = NULL;
++ }
++ }
++
+ /* 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)
+
+ return std::string ();
+ }
++
++extern void _initialize_build_id (void);
++
++void
++_initialize_build_id (void)
++{
++ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose,
++ _("\
++Set debugging level of the build-id locator."), _("\
++Show debugging level of the build-id locator."), _("\
++Level 1 (default) enables printing the missing debug filenames,\n\
++level 2 also prints the parsing of binaries to find the identificators."),
++ NULL,
++ show_build_id_verbose,
++ &setlist, &showlist);
++
++ gdb::observers::executable_changed.attach (debug_print_executable_changed);
++}
+diff --git a/gdb/build-id.h b/gdb/build-id.h
+--- a/gdb/build-id.h
++++ b/gdb/build-id.h
+@@ -23,9 +23,10 @@
+ #include "gdb_bfd.h"
+ #include "gdbsupport/rsp-low.h"
+
+-/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
++/* Separate debuginfo files have corrupted PHDR but SHDR is correct there.
++ Locate NT_GNU_BUILD_ID from ABFD and return its content. */
+
+-extern const struct bfd_build_id *build_id_bfd_get (bfd *abfd);
++extern const struct bfd_build_id *build_id_bfd_shdr_get (bfd *abfd);
+
+ /* Return true if ABFD has NT_GNU_BUILD_ID matching the CHECK value.
+ Otherwise, issue a warning and return false. */
+@@ -38,21 +39,26 @@ extern int build_id_verify (bfd *abfd,
+ can be found, return NULL. */
+
+ 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);
++
++extern char *build_id_to_filename (const struct bfd_build_id *build_id,
++ char **link_return);
+
+ /* Find and open a BFD for an executable file given a build-id. If no BFD
+ can be found, return NULL. The returned reference to the BFD must be
+ released by the caller. */
+
+ extern gdb_bfd_ref_ptr build_id_to_exec_bfd (size_t build_id_len,
+- const bfd_byte *build_id);
++ const bfd_byte *build_id,
++ char **link_return);
+
+ /* Find the separate debug file for OBJFILE, by using the build-id
+ associated with OBJFILE's BFD. If successful, returns the file name for the
+ separate debug file, otherwise, return an empty string. */
+
+-extern std::string find_separate_debug_file_by_buildid
+- (struct objfile *objfile);
++extern std::string find_separate_debug_file_by_buildid (struct objfile *objfile,
++ gdb::unique_xmalloc_ptr *build_id_filename_return);
+
+ /* Return an hex-string representation of BUILD_ID. */
+
+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)
+ /* Try to add separate debug file if no symbols table found. */
+ if (!objfile_has_partial_symbols (objfile))
+ {
+- std::string debugfile = find_separate_debug_file_by_buildid (objfile);
++ std::string debugfile = find_separate_debug_file_by_buildid (objfile,
++ NULL);
+
+ if (debugfile.empty ())
+ debugfile = find_separate_debug_file_by_debuglink (objfile);
+diff --git a/gdb/corelow.c b/gdb/corelow.c
+--- a/gdb/corelow.c
++++ b/gdb/corelow.c
+@@ -22,6 +22,10 @@
+ #include
+ #include
+ #include "frame.h" /* required by inferior.h */
++#include "auxv.h"
++#include "build-id.h"
++#include "elf/common.h"
++#include "gdbcmd.h"
+ #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. */
+ }
+
++static bool build_id_core_loads = true;
++
+ /* 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)
+ static void
+ locate_exec_from_corefile_build_id (bfd *abfd, int from_tty)
+ {
+- const bfd_build_id *build_id = build_id_bfd_get (abfd);
++ const bfd_build_id *build_id = build_id_bfd_shdr_get (abfd);
+ if (build_id == nullptr)
+ return;
+
++ char *build_id_filename;
+ gdb_bfd_ref_ptr execbfd
+- = build_id_to_exec_bfd (build_id->size, build_id->data);
++ = build_id_to_exec_bfd (build_id->size, build_id->data,
++ &build_id_filename);
+
+ if (execbfd != nullptr)
+ {
+ 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;
+ }
++ 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);
++
++ add_setshow_boolean_cmd ("build-id-core-loads", class_files,
++ &build_id_core_loads, _("\
++Set whether CORE-FILE loads the build-id associated files automatically."), _("\
++Show whether CORE-FILE loads the build-id associated files automatically."),
++ NULL, NULL, NULL,
++ &setlist, &showlist);
+ }
+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.
+
+ @end table
+
++You can also adjust the current verbosity of the @dfn{build id} locating.
++
++@table @code
++
++@kindex set build-id-verbose
++@item set build-id-verbose 0
++No additional messages are printed.
++
++@item set build-id-verbose 1
++Missing separate debug filenames are printed.
++
++@item set build-id-verbose 2
++Missing separate debug filenames are printed and also all the parsing of the
++binaries to find their @dfn{build id} content is printed.
++
++@kindex show build-id-verbose
++@item show build-id-verbose
++Show the current verbosity value for the @dfn{build id} content locating.
++
++@end table
++
+ @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)
+ return;
+
+ /* Get build id of objfile. */
+- 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)
+ {
+ if (debug_index_cache)
+@@ -112,7 +112,8 @@ index_cache::store (struct dwarf2_per_objfile *dwarf2_per_objfile)
+
+ if (dwz != nullptr)
+ {
+- const bfd_build_id *dwz_build_id = build_id_bfd_get (dwz->dwz_bfd.get ());
++ const bfd_build_id *dwz_build_id
++ = build_id_bfd_shdr_get (dwz->dwz_bfd.get ());
+
+ 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)
+ static gdb::array_view
+ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_objfile *dwarf2_obj)
+ {
+- 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)
+ static gdb::array_view
+ get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz)
+ {
+- const bfd_build_id *build_id = build_id_bfd_get (dwz->dwz_bfd.get ());
++ const bfd_build_id *build_id = build_id_bfd_shdr_get (dwz->dwz_bfd.get ());
+ if (build_id == nullptr)
+ return {};
+
+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)
+ && objfile->separate_debug_objfile == NULL
+ && objfile->separate_debug_objfile_backlink == NULL)
+ {
+- std::string debugfile = find_separate_debug_file_by_buildid (objfile);
++ gdb::unique_xmalloc_ptr build_id_filename;
++ std::string debugfile
++ = find_separate_debug_file_by_buildid (objfile, &build_id_filename);
+
+ 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);
+ }
+- 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;
+ }
+
+ /* Read the CTF section only if there is no DWARF info. */
+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;
+ };
+
++/* 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 */
+
+ extern struct gdbarch *get_objfile_arch (const struct objfile *);
+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
+@@ -132,7 +132,7 @@ objfpy_get_build_id (PyObject *self, void *closure)
+
+ try
+ {
+- build_id = build_id_bfd_get (objfile->obfd);
++ build_id = build_id_bfd_shdr_get (objfile->obfd);
+ }
+ catch (const gdb_exception &except)
+ {
+@@ -600,7 +600,7 @@ objfpy_lookup_objfile_by_build_id (const char *build_id)
+ /* Don't return separate debug files. */
+ if (objfile->separate_debug_objfile_backlink != NULL)
+ continue;
+- obfd_build_id = build_id_bfd_get (objfile->obfd);
++ obfd_build_id = build_id_bfd_shdr_get (objfile->obfd);
+ if (obfd_build_id == NULL)
+ continue;
+ if (objfpy_build_id_matches (obfd_build_id, build_id))
+diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
+--- a/gdb/solib-svr4.c
++++ b/gdb/solib-svr4.c
+@@ -45,6 +45,7 @@
+ #include "auxv.h"
+ #include "gdb_bfd.h"
+ #include "probe.h"
++#include "build-id.h"
+
+ 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,
+ continue;
+ }
+
+- strncpy (newobj->so_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1);
+- newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
+- strcpy (newobj->so_original_name, newobj->so_name);
++ {
++ struct bfd_build_id *build_id;
++
++ strncpy (newobj->so_original_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1);
++ newobj->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
++ /* May get overwritten below. */
++ strcpy (newobj->so_name, newobj->so_original_name);
++
++ build_id = build_id_addr_get (((lm_info_svr4 *) newobj->lm_info)->l_ld);
++ if (build_id != NULL)
++ {
++ char *name, *build_id_filename;
++
++ /* Missing the build-id matching separate debug info file
++ would be handled while SO_NAME gets loaded. */
++ name = build_id_to_filename (build_id, &build_id_filename);
++ if (name != NULL)
++ {
++ strncpy (newobj->so_name, name, SO_NAME_MAX_PATH_SIZE - 1);
++ newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
++ xfree (name);
++ }
++ else
++ {
++ debug_print_missing (newobj->so_name, build_id_filename);
++
++ /* In the case the main executable was found according to
++ its build-id (from a core file) prevent loading
++ a different build of a library with accidentally the
++ same SO_NAME.
++
++ It suppresses bogus backtraces (and prints "??" there
++ instead) if the on-disk files no longer match the
++ running program version. */
++
++ if (symfile_objfile != NULL
++ && (symfile_objfile->flags
++ & OBJF_BUILD_ID_CORE_LOADED) != 0)
++ newobj->so_name[0] = 0;
++ }
++
++ xfree (build_id_filename);
++ xfree (build_id);
++ }
++ }
+
+ /* 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/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);
+
++
+ /* Target-agnostic function to load the sections of an executable into memory.
+
+ ARGS should be in the form "EXECUTABLE [OFFSET]", where OFFSET is an
+ optional offset to apply to each section. */
+ 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);
++
+ /* From dwarf2read.c */
+
+ /* Names for a dwarf2 debugging section. The field NORMAL is the normal
+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 {
+ pass $test
+ }
+ }
++
++
++# Test auto-loading of binary files through build-id from the core file.
++set buildid [build_id_debug_filename_get $binfile]
++set wholetest "binfile found by build-id"
++if {$buildid == ""} {
++ untested "$wholetest (binary has no build-id)"
++} else {
++ gdb_exit
++ gdb_start
++
++ regsub {\.debug$} $buildid {} buildid
++ set debugdir [standard_output_file ${testfile}-debugdir]
++ file delete -force -- $debugdir
++ file mkdir $debugdir/[file dirname $buildid]
++ file copy $binfile $debugdir/$buildid
++
++ set test "show debug-file-directory"
++ gdb_test_multiple $test $test {
++ -re "The directory where separate debug symbols are searched for is \"(.*)\"\\.\r\n$gdb_prompt $" {
++ set debugdir_orig $expect_out(1,string)
++ pass $test
++ }
++ }
++ gdb_test_no_output "set debug-file-directory $debugdir:$debugdir_orig" "set debug-file-directory"
++ gdb_test "show build-id-core-loads" {Whether CORE-FILE loads the build-id associated files automatically is on\.}
++ gdb_test "core-file $corefile" "\r\nProgram terminated with .*" "core-file without executable"
++ 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/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
+@@ -62,6 +62,7 @@ proc test_command_line_new_ui_pending_input {} {
+ set options ""
+ append options " -iex \"set height 0\""
+ append options " -iex \"set width 0\""
++ append options " -iex \"set build-id-verbose 0\""
+ append options " -iex \"new-ui console $extra_tty_name\""
+ append options " -ex \"b $bpline\""
+ append options " -ex \"run\""
+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 { } {
+ }
+ }
+
++ # Turn off the missing warnings as the testsuite does not expect it.
++ send_gdb "set build-id-verbose 0\n"
++ gdb_expect 10 {
++ -re "$gdb_prompt $" {
++ verbose "Disabled the missing debug infos warnings." 2
++ }
++ timeout {
++ warning "Could not disable the missing debug infos warnings.."
++ }
++ }
++
+ gdb_debug_init
+ return 0
+ }
+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 } {
+ warning "Couldn't set the width to 0."
+ }
+ }
++ # Turn off the missing warnings as the testsuite does not expect it.
++ send_gdb "190-gdb-set build-id-verbose 0\n"
++ gdb_expect 10 {
++ -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
++ verbose "Disabled the missing debug infos warnings." 2
++ }
++ timeout {
++ warning "Could not disable the missing debug infos warnings.."
++ }
++ }
+
+ if { $separate_inferior_pty } {
+ mi_create_inferior_pty
diff --git a/gdb-6.6-bz229517-gcore-without-terminal.patch b/gdb-6.6-bz229517-gcore-without-terminal.patch
new file mode 100644
index 0000000..b4ddc9f
--- /dev/null
+++ b/gdb-6.6-bz229517-gcore-without-terminal.patch
@@ -0,0 +1,188 @@
+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
++++ b/gdb/testsuite/gdb.base/gcorebg.c
+@@ -0,0 +1,49 @@
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++
++int main (int argc, char **argv)
++{
++ pid_t pid = 0;
++ pid_t ppid;
++ char buf[1024*2 + 500];
++ int gotint;
++
++ if (argc != 4)
++ {
++ fprintf (stderr, "Syntax: %s {standard|detached} \n",
++ argv[0]);
++ exit (1);
++ }
++
++ pid = fork ();
++
++ switch (pid)
++ {
++ case 0:
++ if (strcmp (argv[1], "detached") == 0)
++ setpgrp ();
++ ppid = getppid ();
++ gotint = snprintf (buf, sizeof (buf), "sh %s -o %s %d", argv[2], argv[3], (int) ppid);
++ assert (gotint < sizeof (buf));
++ system (buf);
++ fprintf (stderr, "Killing parent PID %d\n", ppid);
++ kill (ppid, SIGTERM);
++ break;
++
++ case -1:
++ perror ("fork err\n");
++ exit (1);
++ break;
++
++ default:
++ fprintf (stderr,"Sleeping as PID %d\n", getpid ());
++ sleep (60);
++ }
++
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcorebg.exp
+@@ -0,0 +1,113 @@
++# 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.
++
++# Please email any bugs, comments, and/or additions to this file to:
++# bug-gdb@prep.ai.mit.edu
++
++# This file was written by Jan Kratochvil .
++# This is a test for `gdb_gcore.sh' functionality.
++# It also tests a regression with `gdb_gcore.sh' being run without its
++# accessible terminal.
++
++if ![info exists GCORE] {
++ set GCORE "[standard_output_file ../../../../gcore]"
++}
++verbose "using GCORE = $GCORE" 2
++
++set testfile "gcorebg"
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++set corefile [standard_output_file ${testfile}.test]
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
++ untested gcorebg.exp
++ return -1
++}
++
++# Cleanup.
++
++proc core_clean {} {
++ global corefile
++
++ foreach file [glob -nocomplain [join [list $corefile *] ""]] {
++ verbose "Delete file $file" 1
++ remote_file target delete $file
++ }
++}
++core_clean
++remote_file target delete "./gdb"
++
++# Generate the core file.
++
++# Provide `./gdb' for `gdb_gcore.sh' running it as a bare `gdb' command.
++# Setup also `$PATH' appropriately.
++# If GDB was not found let `gdb_gcore.sh' to find the system GDB by `$PATH'.
++if {$GDB != "gdb"} {
++ file link ./gdb $GDB
++}
++global env
++set oldpath $env(PATH)
++set env(PATH) [join [list . $env(PATH)] ":"]
++verbose "PATH = $env(PATH)" 2
++
++# Test file body.
++# $detached == "standard" || $detached == "detached"
++
++proc test_body { detached } {
++ global binfile
++ global GCORE
++ global corefile
++
++ set res [remote_spawn target "$binfile $detached $GCORE $corefile"]
++ if { $res < 0 || $res == "" } {
++ fail "Spawning $detached gcore"
++ return 1
++ }
++ pass "Spawning $detached gcore"
++ remote_expect target 20 {
++ timeout {
++ fail "Spawned $detached gcore finished (timeout)"
++ remote_exec target "kill -9 -[exp_pid -i $res]"
++ return 1
++ }
++ "Saved corefile .*\r\nKilling parent PID " {
++ pass "Spawned $detached gcore finished"
++ remote_wait target 20
++ }
++ }
++
++ if {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} {
++ pass "Core file generated by $detached gcore"
++ } else {
++ fail "Core file generated by $detached gcore"
++ }
++ core_clean
++}
++
++# First a general `gdb_gcore.sh' spawn with its controlling terminal available.
++
++test_body standard
++
++# And now `gdb_gcore.sh' spawn without its controlling terminal available.
++# It is spawned through `gcorebg.c' using setpgrp ().
++
++test_body detached
++
++
++# Cleanup.
++
++set env(PATH) $oldpath
++remote_file target delete "./gdb"
diff --git a/gdb-6.6-bz230000-power6-disassembly-test.patch b/gdb-6.6-bz230000-power6-disassembly-test.patch
new file mode 100644
index 0000000..f40b6f6
--- /dev/null
+++ b/gdb-6.6-bz230000-power6-disassembly-test.patch
@@ -0,0 +1,94 @@
+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
++++ b/gdb/testsuite/gdb.arch/powerpc-power6.exp
+@@ -0,0 +1,54 @@
++# 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.
++
++# Test PowerPC Power6 instructions disassembly.
++
++if {![istarget "powerpc*-*-*"]} then {
++ verbose "Skipping PowerPC Power6 instructions disassembly."
++ return
++}
++
++set testfile "powerpc-power6"
++set srcfile ${testfile}.s
++set objfile [standard_output_file ${testfile}.o]
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" } {
++ untested "PowerPC prologue tests"
++ return -1
++}
++
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${objfile}
++
++# Disassemble the function.
++
++gdb_test "disass func" ":\tblr\r\n.*" "Basic disassembly"
++
++gdb_test "disass func" ":\tdcbzl *r8,r9\r\n.*" "Power5 disassembly dcbzl"
++gdb_test "disass func" ":\tfrsqrtes *f10,f11\r\n.*" "Power5 disassembly frsqrtes"
++gdb_test "disass func" ":\tdadd *f1,f2,f1\r\n.*" "Power6 disassembly dadd"
++gdb_test "disass func" ":\tdaddq *f0,f2,f0\r\n.*" "Power6 disassembly daddq"
++gdb_test "disass func" ":\tdsub *f1,f2,f1\r\n.*" "Power6 disassembly dsub"
++gdb_test "disass func" ":\tdsubq *f0,f2,f0\r\n.*" "Power6 disassembly dsubq"
++gdb_test "disass func" ":\tdmul *f1,f2,f1\r\n.*" "Power6 disassembly dmul"
++gdb_test "disass func" ":\tdmulq *f0,f2,f0\r\n.*" "Power6 disassembly dmulq"
++gdb_test "disass func" ":\tddiv *f1,f2,f1\r\n.*" "Power6 disassembly ddiv"
++gdb_test "disass func" ":\tddivq *f0,f2,f0\r\n.*" "Power6 disassembly ddivq"
++gdb_test "disass func" ":\tdcmpu *cr1,f2,f1\r\n.*" "Power6 disassembly dcmpu"
++gdb_test "disass func" ":\tdcmpuq *cr1,f2,f0\r\n.*" "Power6 disassembly dcmpuq"
+diff --git a/gdb/testsuite/gdb.arch/powerpc-power6.s b/gdb/testsuite/gdb.arch/powerpc-power6.s
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.arch/powerpc-power6.s
+@@ -0,0 +1,16 @@
++ .text
++ .globl func
++func:
++ blr
++ .long 0x7c284fec /* dcbzl r8,r9 */
++ .long 0xed405834 /* frsqrtes f10,f11 */
++ .long 0xec220804 /* dadd f1,f2,f1 */
++ .long 0xfc020004 /* daddq f0,f2,f0 */
++ .long 0xec220c04 /* dsub f1,f2,f1 */
++ .long 0xfc020404 /* dsubq f0,f2,f0 */
++ .long 0xec220844 /* dmul f1,f2,f1 */
++ .long 0xfc020044 /* dmulq f0,f2,f0 */
++ .long 0xec220c44 /* ddiv f1,f2,f1 */
++ .long 0xfc020444 /* ddivq f0,f2,f0 */
++ .long 0xec820d04 /* dcmpu cr1,f2,f1 */
++ .long 0xfc820504 /* dcmpuq cr1,f2,f0 */
diff --git a/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch b/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
new file mode 100644
index 0000000..89f2d64
--- /dev/null
+++ b/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
@@ -0,0 +1,278 @@
+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
++++ b/gdb/testsuite/gdb.threads/atomic-seq-threaded.c
+@@ -0,0 +1,171 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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., 51 Franklin Street, Fifth Floor, Boston,
++ MA 02110-1301, USA. */
++
++/* Test stepping over RISC atomic sequences.
++ This variant testcases the code for stepping another thread while skipping
++ over the atomic sequence in the former thread
++ (STEPPING_PAST_SINGLESTEP_BREAKPOINT).
++ Code comes from gcc/testsuite/gcc.dg/sync-2.c */
++
++/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
++/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */
++
++/* Test functionality of the intrinsics for 'short' and 'char'. */
++
++#include
++#include
++#include
++#include
++#include
++
++#define LOOPS 2
++
++static int unused;
++
++static char AI[18];
++static char init_qi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 };
++static char test_qi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 };
++
++static void
++do_qi (void)
++{
++ if (__sync_fetch_and_add(AI+4, 1) != 0)
++ abort ();
++ if (__sync_fetch_and_add(AI+5, 4) != 0)
++ abort ();
++ if (__sync_fetch_and_add(AI+6, 22) != 0)
++ abort ();
++ if (__sync_fetch_and_sub(AI+7, 12) != 0)
++ abort ();
++ if (__sync_fetch_and_and(AI+8, 7) != (char)-1)
++ abort ();
++ if (__sync_fetch_and_or(AI+9, 8) != 0)
++ abort ();
++ if (__sync_fetch_and_xor(AI+10, 9) != 0)
++ abort ();
++ if (__sync_fetch_and_nand(AI+11, 7) != 0)
++ abort ();
++
++ if (__sync_add_and_fetch(AI+12, 1) != 1)
++ abort ();
++ if (__sync_sub_and_fetch(AI+13, 12) != (char)-12)
++ abort ();
++ if (__sync_and_and_fetch(AI+14, 7) != 7)
++ abort ();
++ if (__sync_or_and_fetch(AI+15, 8) != 8)
++ abort ();
++ if (__sync_xor_and_fetch(AI+16, 9) != 9)
++ abort ();
++ if (__sync_nand_and_fetch(AI+17, 7) != 7)
++ abort ();
++}
++
++static short AL[18];
++static short init_hi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 };
++static short test_hi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 };
++
++static void
++do_hi (void)
++{
++ if (__sync_fetch_and_add(AL+4, 1) != 0)
++ abort ();
++ if (__sync_fetch_and_add(AL+5, 4) != 0)
++ abort ();
++ if (__sync_fetch_and_add(AL+6, 22) != 0)
++ abort ();
++ if (__sync_fetch_and_sub(AL+7, 12) != 0)
++ abort ();
++ if (__sync_fetch_and_and(AL+8, 7) != -1)
++ abort ();
++ if (__sync_fetch_and_or(AL+9, 8) != 0)
++ abort ();
++ if (__sync_fetch_and_xor(AL+10, 9) != 0)
++ abort ();
++ if (__sync_fetch_and_nand(AL+11, 7) != 0)
++ abort ();
++
++ if (__sync_add_and_fetch(AL+12, 1) != 1)
++ abort ();
++ if (__sync_sub_and_fetch(AL+13, 12) != -12)
++ abort ();
++ if (__sync_and_and_fetch(AL+14, 7) != 7)
++ abort ();
++ if (__sync_or_and_fetch(AL+15, 8) != 8)
++ abort ();
++ if (__sync_xor_and_fetch(AL+16, 9) != 9)
++ abort ();
++ if (__sync_nand_and_fetch(AL+17, 7) != 7)
++ abort ();
++}
++
++static void *
++start1 (void *arg)
++{
++ unsigned loop;
++ sleep(1);
++
++ for (loop = 0; loop < LOOPS; loop++)
++ {
++ memcpy(AI, init_qi, sizeof(init_qi));
++
++ do_qi ();
++
++ if (memcmp (AI, test_qi, sizeof(test_qi)))
++ abort ();
++ }
++
++ return arg; /* _delete1_ */
++}
++
++static void *
++start2 (void *arg)
++{
++ unsigned loop;
++
++ for (loop = 0; loop < LOOPS; loop++)
++ {
++ memcpy(AL, init_hi, sizeof(init_hi));
++
++ do_hi ();
++
++ if (memcmp (AL, test_hi, sizeof(test_hi)))
++ abort ();
++ }
++
++ return arg; /* _delete2_ */
++}
++
++int
++main (int argc, char **argv)
++{
++ pthread_t thread;
++ int i;
++
++ i = pthread_create (&thread, NULL, start1, NULL); /* _create_ */
++ assert (i == 0); /* _create_after_ */
++
++ sleep (1);
++
++ start2 (NULL);
++
++ i = pthread_join (thread, NULL); /* _delete_ */
++ assert (i == 0);
++
++ return 0; /* _exit_ */
++}
+diff --git a/gdb/testsuite/gdb.threads/atomic-seq-threaded.exp b/gdb/testsuite/gdb.threads/atomic-seq-threaded.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.threads/atomic-seq-threaded.exp
+@@ -0,0 +1,84 @@
++# atomic-seq-threaded.exp -- Test case for stepping over RISC atomic code seqs.
++# This variant testcases the code for stepping another thread while skipping
++# over the atomic sequence in the former thread
++# (STEPPING_PAST_SINGLESTEP_BREAKPOINT).
++# Copyright (C) 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. */
++
++# Please email any bugs, comments, and/or additions to this file to:
++# bug-gdb@prep.ai.mit.edu
++
++set testfile atomic-seq-threaded
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++
++foreach opts {{} {compiler=gcc4} {FAIL}} {
++ if {$opts eq "FAIL"} {
++ return -1
++ }
++ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $opts]] eq "" } {
++ break
++ }
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++
++gdb_load ${binfile}
++if ![runto_main] then {
++ fail "Can't run to main"
++ return 0
++}
++
++# pthread_create () will not pass even on x86_64 with software watchpoint.
++# Pass after pthread_create () without any watchpoint active.
++set line [gdb_get_line_number "_create_after_"]
++gdb_test "tbreak $line" \
++ "reakpoint (\[0-9\]+) at .*$srcfile, line $line\..*" \
++ "set breakpoint after pthread_create ()"
++gdb_test "c" \
++ ".*/\\* _create_after_ \\*/.*" \
++ "run till after pthread_create ()"
++
++# Without a watchpoint being software no single-stepping would be used.
++set test "Start (software) watchpoint"
++gdb_test_multiple "watch unused" $test {
++ -re "Watchpoint \[0-9\]+: unused.*$gdb_prompt $" {
++ pass $test
++ }
++ -re "Hardware watchpoint \[0-9\]+: unused.*$gdb_prompt $" {
++ # We do not test the goal but still the whole testcase should pass.
++ unsupported $test
++ }
++}
++
++# More thorough testing of the scheduling logic.
++gdb_test "set scheduler-locking step" ""
++
++# Critical code path is stepped through at this point.
++set line [gdb_get_line_number "_exit_"]
++gdb_test "tbreak $line" \
++ "reakpoint \[0-9\]+ at .*$srcfile, line $line\..*" \
++ "set breakpoint at _exit_"
++gdb_test "c" \
++ ".*/\\* _exit_ \\*/.*" \
++ "run till _exit_"
++
++# Just a nonproblematic program exit.
++gdb_test "c" \
++ ".*Program exited normally\\..*" \
++ "run till program exit"
diff --git a/gdb-6.6-testsuite-timeouts.patch b/gdb-6.6-testsuite-timeouts.patch
new file mode 100644
index 0000000..a896313
--- /dev/null
+++ b/gdb-6.6-testsuite-timeouts.patch
@@ -0,0 +1,32 @@
+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
+@@ -39,6 +39,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
+
+ clean_restart ${binfile}
+
++gdb_test "set breakpoint pending off" "" "Avoid lockup on nonexisting functions"
++
+ # The commands we test here produce many lines of output; disable "press
+ # to continue" prompts.
+ gdb_test_no_output "set height 0"
+diff --git a/gdb/testsuite/gdb.base/annota3.exp b/gdb/testsuite/gdb.base/annota3.exp
+--- a/gdb/testsuite/gdb.base/annota3.exp
++++ b/gdb/testsuite/gdb.base/annota3.exp
+@@ -38,6 +38,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
+
+ clean_restart ${binfile}
+
++gdb_test "set breakpoint pending off" "" "Avoid lockup on nonexisting functions"
++
+ # The commands we test here produce many lines of output; disable "press
+ # to continue" prompts.
+ gdb_test_no_output "set height 0"
diff --git a/gdb-6.7-charsign-test.patch b/gdb-6.7-charsign-test.patch
new file mode 100644
index 0000000..8c89b13
--- /dev/null
+++ b/gdb-6.7-charsign-test.patch
@@ -0,0 +1,130 @@
+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
++++ b/gdb/testsuite/gdb.base/charsign.c
+@@ -0,0 +1,37 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ 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.
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++int main()
++{
++ return 0;
++}
++
++char n[]="A";
++signed char s[]="A";
++unsigned char u[]="A";
++
++typedef char char_n;
++typedef signed char char_s;
++typedef unsigned char char_u;
++
++char_n n_typed[]="A";
++char_s s_typed[]="A";
++char_u u_typed[]="A";
+diff --git a/gdb/testsuite/gdb.base/charsign.exp b/gdb/testsuite/gdb.base/charsign.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/charsign.exp
+@@ -0,0 +1,63 @@
++# 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.
++
++set testfile charsign
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++
++proc do_test { cflags } {
++ global srcdir
++ global binfile
++ global subdir
++ global srcfile
++ global gdb_prompt
++
++ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug additional_flags=$cflags]] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++ }
++
++ # Get things started.
++
++ gdb_exit
++ gdb_start
++ gdb_reinitialize_dir $srcdir/$subdir
++ gdb_load ${binfile}
++
++ # For C programs, "start" should stop in main().
++
++ gdb_test "p n" \
++ "= \"A\""
++ gdb_test "p s" \
++ "= \\{65 'A', 0 '\\\\0'\\}"
++ gdb_test "p u" \
++ "= \\{65 'A', 0 '\\\\0'\\}"
++ gdb_test "p n_typed" \
++ "= \"A\""
++ gdb_test "p s_typed" \
++ "= \\{65 'A', 0 '\\\\0'\\}"
++ gdb_test "p u_typed" \
++ "= \\{65 'A', 0 '\\\\0'\\}"
++}
++
++# The string identification works despite the compiler flags below due to
++# gdbtypes.c:
++# if (name && strcmp (name, "char") == 0)
++# TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN;
++
++do_test {}
++do_test {-fsigned-char}
++do_test {-funsigned-char}
diff --git a/gdb-6.7-ppc-clobbered-registers-O2-test.patch b/gdb-6.7-ppc-clobbered-registers-O2-test.patch
new file mode 100644
index 0000000..08ee2f9
--- /dev/null
+++ b/gdb-6.7-ppc-clobbered-registers-O2-test.patch
@@ -0,0 +1,108 @@
+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
++++ b/gdb/testsuite/gdb.arch/ppc-clobbered-registers-O2.c
+@@ -0,0 +1,21 @@
++
++unsigned * __attribute__((noinline))
++start_sequence (unsigned * x, unsigned * y)
++{
++ return (unsigned *)0xdeadbeef;
++};
++
++unsigned __attribute__((noinline))
++gen_movsd (unsigned * operand0, unsigned * operand1)
++{
++ return *start_sequence(operand0, operand1);
++}
++
++int main(void)
++{
++ unsigned x, y;
++
++ x = 13;
++ y = 14;
++ return (int)gen_movsd (&x, &y);
++}
+diff --git a/gdb/testsuite/gdb.arch/ppc-clobbered-registers-O2.exp b/gdb/testsuite/gdb.arch/ppc-clobbered-registers-O2.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.arch/ppc-clobbered-registers-O2.exp
+@@ -0,0 +1,54 @@
++# 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.
++#
++# This file is part of the gdb testsuite.
++
++# Test displaying call clobbered registers in optimized binaries for ppc.
++# GDB should not show incorrect values.
++
++if ![istarget "powerpc*-*"] then {
++ verbose "Skipping powerpc* call clobbered registers testing."
++ return
++}
++
++set testfile "ppc-clobbered-registers-O2"
++set srcfile ${testfile}.c
++set binfile [standard_output_file ${testfile}]
++set compile_flags "debug additional_flags=-O2"
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${compile_flags}] != "" } {
++ unsupported "Testcase compile failed."
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++if ![runto_main] then {
++ perror "Couldn't run to breakpoint"
++ continue
++}
++
++gdb_test "b start_sequence" ".*Breakpoint 2 at.*line 6.*" \
++ "Insert breakpoint at problematic function"
++
++gdb_test continue ".*Breakpoint 2.*in start_sequence.*" \
++ "Run until problematic function"
++
++gdb_test backtrace ".*operand0=.*operand1=.*" \
++ "Check value of call clobbered registers"
diff --git a/gdb-6.7-testsuite-stable-results.patch b/gdb-6.7-testsuite-stable-results.patch
new file mode 100644
index 0000000..ec8f9c2
--- /dev/null
+++ b/gdb-6.7-testsuite-stable-results.patch
@@ -0,0 +1,104 @@
+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)
+ int
+ main ()
+ {
++ /* These tests
++ Open for write but no write permission returns EACCES
++ Unlinking a file in a directory w/o write access returns EACCES
++ fail if we are being run as root - drop the privileges here. */
++
++ if (geteuid () == 0)
++ {
++ uid_t uid = 99;
++
++ if (chown (OUTDIR, uid, uid) != 0)
++ {
++ printf ("chown %d.%d %s: %s\n", (int) uid, (int) uid,
++ OUTDIR, strerror (errno));
++ exit (1);
++ }
++ if (setuid (uid) || geteuid () == 0)
++ {
++ printf ("setuid %d: %s\n", (int) uid, strerror (errno));
++ exit (1);
++ }
++ }
++
+ /* Don't change the order of the calls. They partly depend on each other */
+ test_open ();
+ test_write ();
+diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
+--- a/gdb/testsuite/gdb.base/fileio.exp
++++ b/gdb/testsuite/gdb.base/fileio.exp
+@@ -24,9 +24,9 @@ if [target_info exists gdb,nofileio] {
+ standard_testfile
+
+ if {[is_remote host]} {
+- set outdir .
++ set outdir "fileio.dir"
+ } else {
+- set outdir [standard_output_file {}]
++ set outdir [standard_output_file "fileio.dir"]
+ }
+
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+@@ -47,7 +47,8 @@ set dir2 [standard_output_file dir2.fileio.test]
+ if {[file exists $dir2] && ![file writable $dir2]} {
+ system "chmod +w $dir2"
+ }
+-system "rm -rf [standard_output_file *.fileio.test]"
++system "rm -rf [standard_output_file fileio.dir]"
++system "mkdir -m777 [standard_output_file fileio.dir]"
+
+ set oldtimeout $timeout
+ set timeout [expr "$timeout + 60"]
+@@ -89,7 +90,7 @@ gdb_test continue \
+
+ gdb_test "continue" ".*" ""
+
+-catch "system \"chmod -f -w [standard_output_file nowrt.fileio.test]\""
++catch "system \"chmod -f -w [standard_output_file fileio.dir/nowrt.fileio.test]\""
+
+ gdb_test continue \
+ "Continuing\\..*open 5:.*EACCES$stop_msg" \
+@@ -276,9 +277,7 @@ gdb_test continue \
+ gdb_exit
+
+ # Make dir2 writable again so rm -rf of a build tree Just Works.
+-if {[file exists $dir2] && ![file writable $dir2]} {
+- system "chmod +w $dir2"
+-}
++system "chmod -R +w $outdir"
+
+ set timeout $oldtimeout
+ return 0
diff --git a/gdb-6.8-bz442765-threaded-exec-test.patch b/gdb-6.8-bz442765-threaded-exec-test.patch
new file mode 100644
index 0000000..e2ed431
--- /dev/null
+++ b/gdb-6.8-bz442765-threaded-exec-test.patch
@@ -0,0 +1,181 @@
+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
+@@ -18,21 +18,95 @@
+ Boston, MA 02111-1307, USA. */
+
+ #include
+-#include
+ #include
+ #include
+ #include
++#include
+
++#ifdef THREADS
++
++# include
+
+ static void *
+ threader (void *arg)
+ {
+- return NULL;
++ return NULL;
+ }
+
++#endif
++
+ int
+-main (void)
++main (int argc, char **argv)
+ {
++ char *exec_nothreads, *exec_threads, *cmd;
++ int phase;
++ char phase_s[8];
++
++ setbuf (stdout, NULL);
++
++ if (argc != 4)
++ {
++ fprintf (stderr, "%s \n", argv[0]);
++ return 1;
++ }
++
++#ifdef THREADS
++ puts ("THREADS: Y");
++#else
++ puts ("THREADS: N");
++#endif
++ exec_nothreads = argv[1];
++ printf ("exec_nothreads: %s\n", exec_nothreads);
++ exec_threads = argv[2];
++ printf ("exec_threads: %s\n", exec_threads);
++ phase = atoi (argv[3]);
++ printf ("phase: %d\n", phase);
++
++ /* Phases: threading
++ 0: N -> N
++ 1: N -> Y
++ 2: Y -> Y
++ 3: Y -> N
++ 4: N -> exit */
++
++ cmd = NULL;
++
++#ifndef THREADS
++ switch (phase)
++ {
++ case 0:
++ cmd = exec_nothreads;
++ break;
++ case 1:
++ cmd = exec_threads;
++ break;
++ case 2:
++ fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
++ phase);
++ return 1;
++ case 3:
++ fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
++ phase);
++ return 1;
++ case 4:
++ return 0;
++ default:
++ assert (0);
++ }
++#else /* THREADS */
++ switch (phase)
++ {
++ case 0:
++ fprintf (stderr, "%s: We should not have threads for phase %d!\n",
++ argv[0], phase);
++ return 1;
++ case 1:
++ fprintf (stderr, "%s: We should not have threads for phase %d!\n",
++ argv[0], phase);
++ return 1;
++ case 2:
++ cmd = exec_threads;
++ {
+ pthread_t t1;
+ int i;
+
+@@ -40,7 +114,34 @@ main (void)
+ assert (i == 0);
+ i = pthread_join (t1, NULL);
+ assert (i == 0);
++ }
++ break;
++ case 3:
++ cmd = exec_nothreads;
++ {
++ pthread_t t1;
++ int i;
++
++ i = pthread_create (&t1, NULL, threader, (void *) NULL);
++ assert (i == 0);
++ i = pthread_join (t1, NULL);
++ assert (i == 0);
++ }
++ break;
++ case 4:
++ fprintf (stderr, "%s: We should not have threads for phase %d!\n",
++ argv[0], phase);
++ return 1;
++ default:
++ assert (0);
++ }
++#endif /* THREADS */
++
++ assert (cmd != NULL);
++
++ phase++;
++ snprintf (phase_s, sizeof phase_s, "%d", phase);
+
+- execl ("/bin/true", "/bin/true", NULL);
+- abort ();
++ execl (cmd, cmd, exec_nothreads, exec_threads, phase_s, NULL);
++ assert (0);
+ }
+diff --git a/gdb/testsuite/gdb.threads/threaded-exec.exp b/gdb/testsuite/gdb.threads/threaded-exec.exp
+--- a/gdb/testsuite/gdb.threads/threaded-exec.exp
++++ b/gdb/testsuite/gdb.threads/threaded-exec.exp
+@@ -20,9 +20,14 @@
+
+ set testfile threaded-exec
+ set srcfile ${testfile}.c
+-set binfile [standard_output_file ${testfile}]
++set binfile_nothreads [standard_output_file ${testfile}N]
++set binfile_threads [standard_output_file ${testfile}Y]
+
+-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {
++if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_nothreads}" executable {additional_flags=-UTHREADS}] != "" } {
++ return -1
++}
++
++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile_threads}" executable {additional_flags=-DTHREADS}] != "" } {
+ return -1
+ }
+
+@@ -30,9 +35,9 @@ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+-gdb_load ${binfile}
++gdb_load ${binfile_nothreads}
+
+-gdb_run_cmd
++gdb_run_cmd ${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
new file mode 100644
index 0000000..542a956
--- /dev/null
+++ b/gdb-6.8-bz466901-backtrace-full-prelinked.patch
@@ -0,0 +1,481 @@
+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
++++ b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S
+@@ -0,0 +1,328 @@
++/* 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
++func (void)
++{
++ int i;
++
++ abort ();
++}
++*/
++ .file "dw2-loclist-prelinked.c"
++ .section .debug_abbrev,"",@progbits
++.Ldebug_abbrev0:
++ .section .debug_info,"",@progbits
++.Ldebug_info0:
++ .section .debug_line,"",@progbits
++.Ldebug_line0:
++ .text
++.Ltext0:
++.globl func
++ .type func, @function
++func:
++.LFB2:
++ .file 1 "dw2-loclist-prelinked.c"
++ .loc 1 5 0
++ pushl %ebp
++.LCFI0:
++ movl %esp, %ebp
++.LCFI1:
++ subl $24, %esp
++.LCFI2:
++ .loc 1 8 0
++ call abort
++.LFE2:
++ .size func, .-func
++ .section .debug_frame,"",@progbits
++.Lframe0:
++ .long .LECIE0-.LSCIE0
++.LSCIE0:
++ .long 0xffffffff
++ .byte 0x1
++ .string ""
++ .uleb128 0x1
++ .sleb128 -4
++ .byte 0x8
++ .byte 0xc
++ .uleb128 0x4
++ .uleb128 0x4
++ .byte 0x88
++ .uleb128 0x1
++ .align 4
++.LECIE0:
++.LSFDE0:
++ .long .LEFDE0-.LASFDE0
++.LASFDE0:
++ .long .Lframe0
++ .long .LFB2
++ .long .LFE2-.LFB2
++ .byte 0x4
++ .long .LCFI0-.LFB2
++ .byte 0xe
++ .uleb128 0x8
++ .byte 0x85
++ .uleb128 0x2
++ .byte 0x4
++ .long .LCFI1-.LCFI0
++ .byte 0xd
++ .uleb128 0x5
++ .align 4
++.LEFDE0:
++ .text
++.Letext0:
++ .section .debug_loc,"",@progbits
++.Ldebug_loc0:
++.LLST0:
++ .long .LFB2-.Ltext0
++ .long .LCFI0-.Ltext0
++ .value 0x2
++ .byte 0x74
++ .sleb128 4
++ .long .LCFI0-.Ltext0
++ .long .LCFI1-.Ltext0
++ .value 0x2
++ .byte 0x74
++ .sleb128 8
++ .long .LCFI1-.Ltext0
++ .long .LFE2-.Ltext0
++ .value 0x2
++ .byte 0x75
++ .sleb128 8
++ .long 0x0
++ .long 0x0
++ .section .debug_info
++ .long 0x94
++ .value 0x2
++ .long .Ldebug_abbrev0
++ .byte 0x4
++ .uleb128 0x1
++ .long .LASF10
++ .byte 0x1
++ .long .LASF11
++ .long .LASF12
++ .long .Ltext0
++ .long .Letext0
++ .long .Ldebug_line0
++ .uleb128 0x2
++ .byte 0x4
++ .byte 0x7
++ .long .LASF0
++ .uleb128 0x3
++ .byte 0x4
++ .byte 0x5
++ .string "int"
++ .uleb128 0x2
++ .byte 0x4
++ .byte 0x5
++ .long .LASF1
++ .uleb128 0x2
++ .byte 0x1
++ .byte 0x8
++ .long .LASF2
++ .uleb128 0x2
++ .byte 0x2
++ .byte 0x7
++ .long .LASF3
++ .uleb128 0x2
++ .byte 0x4
++ .byte 0x7
++ .long .LASF4
++ .uleb128 0x2
++ .byte 0x1
++ .byte 0x6
++ .long .LASF5
++ .uleb128 0x2
++ .byte 0x2
++ .byte 0x5
++ .long .LASF6
++ .uleb128 0x2
++ .byte 0x8
++ .byte 0x5
++ .long .LASF7
++ .uleb128 0x2
++ .byte 0x8
++ .byte 0x7
++ .long .LASF8
++ .uleb128 0x4
++ .byte 0x4
++ .byte 0x7
++ .uleb128 0x2
++ .byte 0x1
++ .byte 0x6
++ .long .LASF9
++ .uleb128 0x5
++ .byte 0x1
++ .long .LASF13
++ .byte 0x1
++ .byte 0x5
++ .byte 0x1
++ .long .LFB2
++ .long .LFE2
++ .long .LLST0
++ .uleb128 0x6
++ .string "i"
++ .byte 0x1
++ .byte 0x6
++ .long 0x2c
++ .byte 0x2
++ .byte 0x91
++ .sleb128 -12
++ .byte 0x0
++ .byte 0x0
++ .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 0x24
++ .byte 0x0
++ .uleb128 0xb
++ .uleb128 0xb
++ .uleb128 0x3e
++ .uleb128 0xb
++ .uleb128 0x3
++ .uleb128 0xe
++ .byte 0x0
++ .byte 0x0
++ .uleb128 0x3
++ .uleb128 0x24
++ .byte 0x0
++ .uleb128 0xb
++ .uleb128 0xb
++ .uleb128 0x3e
++ .uleb128 0xb
++ .uleb128 0x3
++ .uleb128 0x8
++ .byte 0x0
++ .byte 0x0
++ .uleb128 0x4
++ .uleb128 0x24
++ .byte 0x0
++ .uleb128 0xb
++ .uleb128 0xb
++ .uleb128 0x3e
++ .uleb128 0xb
++ .byte 0x0
++ .byte 0x0
++ .uleb128 0x5
++ .uleb128 0x2e
++ .byte 0x1
++ .uleb128 0x3f
++ .uleb128 0xc
++ .uleb128 0x3
++ .uleb128 0xe
++ .uleb128 0x3a
++ .uleb128 0xb
++ .uleb128 0x3b
++ .uleb128 0xb
++ .uleb128 0x27
++ .uleb128 0xc
++ .uleb128 0x11
++ .uleb128 0x1
++ .uleb128 0x12
++ .uleb128 0x1
++ .uleb128 0x40
++ .uleb128 0x6
++ .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
++ .byte 0x0
++ .section .debug_pubnames,"",@progbits
++ .long 0x17
++ .value 0x2
++ .long .Ldebug_info0
++ .long 0x98
++ .long 0x75
++ .string "func"
++ .long 0x0
++ .section .debug_aranges,"",@progbits
++ .long 0x1c
++ .value 0x2
++ .long .Ldebug_info0
++ .byte 0x4
++ .byte 0x0
++ .value 0x0
++ .value 0x0
++ .long .Ltext0
++ .long .Letext0-.Ltext0
++ .long 0x0
++ .long 0x0
++ .section .debug_str,"MS",@progbits,1
++.LASF7:
++ .string "long long int"
++.LASF0:
++ .string "unsigned int"
++.LASF11:
++ .string "dw2-loclist-prelinked.c"
++.LASF12:
++ .string "gdb-6.8/gdb/testsuite/gdb.dwarf2"
++.LASF4:
++ .string "long unsigned int"
++.LASF8:
++ .string "long long unsigned int"
++.LASF2:
++ .string "unsigned char"
++.LASF9:
++ .string "char"
++.LASF1:
++ .string "long int"
++.LASF3:
++ .string "short unsigned int"
++.LASF5:
++ .string "signed char"
++.LASF10:
++ .string "GNU C 4.3.2 20081007 (Red Hat 4.3.2-6)"
++.LASF13:
++ .string "func"
++.LASF6:
++ .string "short int"
++ .ident "GCC: (GNU) 4.3.2 20081007 (Red Hat 4.3.2-6)"
++ .section .note.GNU-stack,"",@progbits
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c
+@@ -0,0 +1,26 @@
++/* 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 . */
++
++/* dw2-loclist-prelinked-func.S */
++extern void func (void);
++
++int
++main (void)
++{
++ func ();
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp
+@@ -0,0 +1,102 @@
++# 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.
++
++# Minimal DWARF-2 unit test
++
++# This test can only be run on i386/x86_64 targets which support DWARF-2.
++# For now pick a sampling of likely targets.
++if {(![istarget *-*-linux*]
++ && ![istarget *-*-gnu*]
++ && ![istarget *-*-elf*]
++ && ![istarget *-*-openbsd*])
++ || (![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"])} {
++ return 0
++}
++
++set testfile "dw2-loclist-prelinked"
++set srcfuncfile ${testfile}-func.S
++set binsharedfuncfile [standard_output_file ${testfile}.so]
++set srcmainfile ${testfile}-main.c
++set binfile [standard_output_file ${testfile}]
++
++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_shlib "${srcdir}/${subdir}/${srcfuncfile}" "${binsharedfuncfile}" {debug additional_flags=-m32}] != "" } {
++ untested "Couldn't compile test library"
++ return -1
++}
++
++# The new separate debug info file will be stored in the .debug subdirectory.
++
++if [gdb_gnu_strip_debug ${binsharedfuncfile}] {
++ # check that you have a recent version of strip and objcopy installed
++ unsupported "cannot produce separate debug info files"
++ return -1
++}
++
++if {[catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${binsharedfuncfile}\""] != 0} {
++ # Maybe we don't have prelink.
++ return -1
++}
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" \
++ "${binfile}" executable [list debug additional_flags=-m32 shlib=${binsharedfuncfile}]] != "" } {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++gdb_run_cmd
++
++gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
++
++# Incorrect:
++# #0 0x00110430 in __kernel_vsyscall ()
++# No symbol table info available.
++# #1 0x003d44c0 in raise () from /lib/libc.so.6
++# No symbol table info available.
++# #2 0x003d5e88 in abort () from /lib/libc.so.6
++# No symbol table info available.
++# #3 0x44f10437 in func () at dw2-loclist-prelinked.c:8
++# i = Could not find the frame base for "func".
++
++# Correct:
++# #0 0x00110430 in __kernel_vsyscall ()
++# No symbol table info available.
++# #1 0x003d44c0 in raise () from /lib/libc.so.6
++# No symbol table info available.
++# #2 0x003d5e88 in abort () from /lib/libc.so.6
++# No symbol table info available.
++# #3 0x4ae36437 in func () at dw2-loclist-prelinked.c:8
++# i = 3827288
++# #4 0x0804851a in main () at ../../../gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c:24
++# No locals.
++
++# `abort' can get expressed as `*__GI_abort'.
++gdb_test "bt full" "in \[^ \]*abort \\(.*in func \\(.*\r\n\[\t \]+i = -?\[0-9\].*in main \\(.*" "Backtrace after abort()"
diff --git a/gdb-6.8-quit-never-aborts.patch b/gdb-6.8-quit-never-aborts.patch
new file mode 100644
index 0000000..4dd01c5
--- /dev/null
+++ b/gdb-6.8-quit-never-aborts.patch
@@ -0,0 +1,78 @@
+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-quit-never-aborts.patch
+
+;; Make the GDB quit processing non-abortable to cleanup everything properly.
+;;=fedora: It was useful only after gdb-6.8-attach-signalled-detach-stopped.patch .
+
+We may abort the process of detaching threads with multiple SIGINTs - which are
+being sent during a testcase terminating its child GDB.
+
+Some of the threads may not be properly PTRACE_DETACHed which hurts if they
+should have been detached with SIGSTOP (as they are accidentally left running
+on the debugger termination).
+
+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
new file mode 100644
index 0000000..ba71cd3
--- /dev/null
+++ b/gdb-archer-next-over-throw-cxx-exec.patch
@@ -0,0 +1,88 @@
+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
++++ b/gdb/testsuite/gdb.cp/cxxexec.cc
+@@ -0,0 +1,25 @@
++/* This test script 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 . */
++
++#include
++
++int
++main()
++{
++ execlp ("true", "true", NULL);
++ return 1;
++}
+diff --git a/gdb/testsuite/gdb.cp/cxxexec.exp b/gdb/testsuite/gdb.cp/cxxexec.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.cp/cxxexec.exp
+@@ -0,0 +1,42 @@
++# 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 .
++
++if { [skip_cplus_tests] } { continue }
++
++set testfile cxxexec
++if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.cc {c++ debug}] } {
++ return -1
++}
++
++runto_main
++
++# We could stop after `continue' again at `main'.
++delete_breakpoints
++
++set test "p _Unwind_DebugHook"
++gdb_test_multiple $test $test {
++ -re " = .* 0x\[0-9a-f\].*\r\n$gdb_prompt $" {
++ pass $test
++ }
++ -re "\r\nNo symbol .*\r\n$gdb_prompt $" {
++ xfail $test
++ untested ${testfile}.exp
++ return -1
++ }
++}
++
++# Run to end. The buggy GDB failed instead with:
++# Cannot access memory at address ADDR.
++gdb_continue_to_end "" "continue" 1
diff --git a/gdb-archer-pie-addons-keep-disabled.patch b/gdb-archer-pie-addons-keep-disabled.patch
new file mode 100644
index 0000000..40ab16b
--- /dev/null
+++ b/gdb-archer-pie-addons-keep-disabled.patch
@@ -0,0 +1,102 @@
+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-pie-addons-keep-disabled.patch
+
+;;=push+jan: Breakpoints disabling matching should not be based on address.
+
+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
new file mode 100644
index 0000000..e3af3a9
--- /dev/null
+++ b/gdb-archer-pie-addons.patch
@@ -0,0 +1,63 @@
+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-pie-addons.patch
+
+;;=push+jan: May get obsoleted by Tom's unrelocated objfiles patch.
+
+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
new file mode 100644
index 0000000..9921940
--- /dev/null
+++ b/gdb-archer-vla-tests.patch
@@ -0,0 +1,3737 @@
+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-vla-tests.patch
+
+;;=fedoratest
+
+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 /*