commit d25fbabe7fd1a39428c8d65ff4d78416d1a9915d Author: CentOS Sources Date: Thu Apr 23 22:14:15 2020 +0000 import gdb-8.2-11.el8 diff --git a/.gdb.metadata b/.gdb.metadata new file mode 100644 index 0000000..fd804f3 --- /dev/null +++ b/.gdb.metadata @@ -0,0 +1,3 @@ +ee66294d87a109f88a459d0da5d0bb2da5135f45 SOURCES/gdb-8.2.tar.xz +1ad1d2c6f0141b37bbe32b8add91b5691ecc6412 SOURCES/gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz +a08830edc095f4ea8ae516a154942105379c5f67 SOURCES/v2.0.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a8a3997 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +SOURCES/gdb-8.2.tar.xz +SOURCES/gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz +SOURCES/v2.0.tar.gz diff --git a/SOURCES/_gdb.spec.Patch.include b/SOURCES/_gdb.spec.Patch.include new file mode 100644 index 0000000..12d65a5 --- /dev/null +++ b/SOURCES/_gdb.spec.Patch.include @@ -0,0 +1,672 @@ +# 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 + +# Better parse 64-bit PPC system call prologues. +#=push: Write new testcase. +Patch005: gdb-6.3-ppc64syscall-20040622.patch + +# Include the pc's section when doing a symbol lookup so that the +# correct symbol is found. +#=push: Write new testcase. +Patch006: gdb-6.3-ppc64displaysymbol-20041124.patch + +# Add a wrapper script to GDB that implements pstack using the +# --readnever option. +#=push +Patch007: gdb-6.3-gstack-20050411.patch + +# VSYSCALL and PIE +#=fedoratest +Patch008: gdb-6.3-test-pie-20050107.patch + +# Get selftest working with sep-debug-info +#=fedoratest +Patch009: gdb-6.3-test-self-20050110.patch + +# Test support of multiple destructors just like multiple constructors +#=fedoratest +Patch010: gdb-6.3-test-dtorfix-20050121.patch + +# Fix to support executable moving +#=fedoratest +Patch011: gdb-6.3-test-movedir-20050125.patch + +# Test sibling threads to set threaded watchpoints for x86 and x86-64 +#=fedoratest +Patch012: gdb-6.3-threaded-watchpoints2-20050225.patch + +# Notify observers that the inferior has been created +#=fedoratest +Patch013: gdb-6.3-inferior-notification-20050721.patch + +# Verify printing of inherited members test +#=fedoratest +Patch014: gdb-6.3-inheritancetest-20050726.patch + +# Add readnever option +#=push +Patch015: gdb-6.3-readnever-20050907.patch + +# Fix debuginfo addresses resolving for --emit-relocs Linux kernels (BZ 203661). +#=push+jan: There was some mail thread about it, this patch may be a hack. +Patch016: gdb-6.5-bz203661-emit-relocs.patch + +# Support TLS symbols (+`errno' suggestion if no pthread is found) (BZ 185337). +#=push+jan: It should be replaced by Infinity project. +Patch017: 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. +Patch018: 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. +Patch019: gdb-6.5-BEA-testsuite.patch + +# Testcase for deadlocking on last address space byte; for corrupted backtraces. +#=fedoratest +Patch020: gdb-6.5-last-address-space-byte-test.patch + +# Fix readline segfault on excessively long hand-typed lines. +#=fedoratest +Patch021: gdb-6.5-readline-long-line-crash-test.patch + +# Fix bogus 0x0 unwind of the thread's topmost function clone(3) (BZ 216711). +#=fedora +Patch022: gdb-6.5-bz216711-clone-is-outermost.patch + +# Test sideeffects of skipping ppc .so libs trampolines (BZ 218379). +#=fedoratest +Patch023: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch + +# Fix lockup on trampoline vs. its function lookup; unreproducible (BZ 218379). +#=fedora +Patch024: gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch + +# Find symbols properly at their original (included) file (BZ 109921). +#=fedoratest +Patch025: gdb-6.5-bz109921-DW_AT_decl_file-test.patch + +# Update PPC unwinding patches to their upstream variants (BZ 140532). +#=fedoratest +Patch026: gdb-6.3-bz140532-ppc-unwinding-test.patch + +# Testcase for exec() from threaded program (BZ 202689). +#=fedoratest +Patch027: gdb-6.3-bz202689-exec-from-pthread-test.patch + +# Testcase for PPC Power6/DFP instructions disassembly (BZ 230000). +#=fedoratest +Patch028: gdb-6.6-bz230000-power6-disassembly-test.patch + +# Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517). +#=fedoratest +Patch029: gdb-6.6-bz229517-gcore-without-terminal.patch + +# Avoid too long timeouts on failing cases of "annota1.exp annota3.exp". +#=fedoratest +Patch030: gdb-6.6-testsuite-timeouts.patch + +# Support for stepping over PPC atomic instruction sequences (BZ 237572). +#=fedoratest +Patch031: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch + +# Make upstream `set scheduler-locking step' as default. +#=push+jan: How much is scheduler-locking relevant after non-stop? +Patch032: gdb-6.6-scheduler_locking-step-is-default.patch + +# Test kernel VDSO decoding while attaching to an i386 process. +#=fedoratest +Patch033: gdb-6.3-attach-see-vdso-test.patch + +# Test leftover zombie process (BZ 243845). +#=fedoratest +Patch034: gdb-6.5-bz243845-stale-testing-zombie-test.patch + +# New locating of the matching binaries from the pure core file (build-id). +#=push+jan +Patch035: 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 +Patch036: gdb-6.6-buildid-locate-solib-missing-ids.patch + +#=push+jan +Patch037: 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. +Patch038: gdb-6.7-charsign-test.patch + +# Test PPC hiding of call-volatile parameter register. +#=fedoratest +Patch039: gdb-6.7-ppc-clobbered-registers-O2-test.patch + +# Testsuite fixes for more stable/comparable results. +#=fedoratest +Patch040: gdb-6.7-testsuite-stable-results.patch + +# Test ia64 memory leaks of the code using libunwind. +#=fedoratest +Patch041: gdb-6.5-ia64-libunwind-leak-test.patch + +# Test hiding unexpected breakpoints on intentional step commands. +#=fedoratest +Patch042: gdb-6.5-missed-trap-on-step-test.patch + +# Test gcore memory and time requirements for large inferiors. +#=fedoratest +Patch043: 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. +Patch044: gdb-6.3-mapping-zero-inode-test.patch + +# Test a crash on `focus cmd', `focus prev' commands. +#=fedoratest +Patch045: gdb-6.3-focus-cmd-prev-test.patch + +# Test various forms of threads tracking across exec() (BZ 442765). +#=fedoratest +Patch046: gdb-6.8-bz442765-threaded-exec-test.patch + +# Silence memcpy check which returns false positive (sparc64) +#=push: But it is just a GCC workaround, look up the existing GCC PR for it. +Patch047: gdb-6.8-sparc64-silence-memcpy-check.patch + +# Test a crash on libraries missing the .text section. +#=fedoratest +Patch048: gdb-6.5-section-num-fixup-test.patch + +# Fix register assignments with no GDB stack frames (BZ 436037). +#=push+jan: This fix is incorrect. +Patch049: gdb-6.8-bz436037-reg-no-longer-active.patch + +# Test the watchpoints conditionals works. +#=fedoratest +Patch050: gdb-6.8-watchpoint-conditionals-test.patch + +# Fix resolving of variables at locations lists in prelinked libs (BZ 466901). +#=fedoratest +Patch051: gdb-6.8-bz466901-backtrace-full-prelinked.patch + +# New test for step-resume breakpoint placed in multiple threads at once. +#=fedoratest +Patch052: 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@.*> +Patch053: gdb-core-open-vdso-warning.patch + +# Fix syscall restarts for amd64->i386 biarch. +#=push+jan +Patch054: gdb-x86_64-i386-syscall-restart.patch + +# Fix stepping with OMP parallel Fortran sections (BZ 533176). +#=push+jan: It requires some better DWARF annotations. +Patch055: gdb-bz533176-fortran-omp-step.patch + +# Fix regression by python on ia64 due to stale current frame. +#=push+jan +Patch056: gdb-follow-child-stale-parent.patch + +# Workaround ccache making lineno non-zero for command-line definitions. +#=fedoratest: ccache is rarely used and it is even fixed now. +Patch057: gdb-ccache-workaround.patch + +#=push+jan: May get obsoleted by Tom's unrelocated objfiles patch. +Patch058: gdb-archer-pie-addons.patch + +#=push+jan: Breakpoints disabling matching should not be based on address. +Patch059: gdb-archer-pie-addons-keep-disabled.patch + +# Testcase for "Do not make up line information" fix by Daniel Jacobowitz. +#=fedoratest +Patch060: gdb-lineno-makeup-test.patch + +# Test power7 ppc disassembly. +#=fedoratest +Patch061: gdb-ppc-power7-test.patch + +# Fix i386+x86_64 rwatch+awatch before run, regression against 6.8 (BZ 541866). +# Fix i386 rwatch+awatch before run (BZ 688788, on top of BZ 541866). +#=push+jan: It should be fixed properly instead. +Patch062: gdb-bz541866-rwatch-before-run.patch + +# Workaround non-stop moribund locations exploited by kernel utrace (BZ 590623). +#=push+jan: Currently it is still not fully safe. +Patch063: gdb-moribund-utrace-workaround.patch + +# Fix follow-exec for C++ programs (bugreported by Martin Stransky). +#=fedoratest +Patch064: gdb-archer-next-over-throw-cxx-exec.patch + +# Backport DWARF-4 support (BZ 601887, Tom Tromey). +#=fedoratest +Patch065: gdb-bz601887-dwarf4-rh-test.patch + +#=push+jan +Patch066: gdb-6.6-buildid-locate-core-as-arg.patch + +# Workaround librpm BZ 643031 due to its unexpected exit() calls (BZ 642879). +#=push+jan +Patch067: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch + +# [delayed-symfile] Test a backtrace regression on CFIs without DIE (BZ 614604). +#=fedoratest +Patch068: gdb-test-bt-cfi-without-die.patch + +# Out of memory is just an error, not fatal (uninitialized VLS vars, BZ 568248). +#=push+jan: Inferior objects should be read in parts, then this patch gets obsoleted. +Patch069: gdb-bz568248-oom-is-error.patch + +# Verify GDB Python built-in function gdb.solib_address exists (BZ # 634108). +#=fedoratest +Patch070: gdb-bz634108-solib_address.patch + +# New test gdb.arch/x86_64-pid0-core.exp for kernel PID 0 cores (BZ 611435). +#=fedoratest +Patch071: gdb-test-pid0-core.patch + +# [archer-tromey-delayed-symfile] New test gdb.dwarf2/dw2-aranges.exp. +#=fedoratest +Patch072: gdb-test-dw2-aranges.patch + +# [archer-keiths-expr-cumulative+upstream] Import C++ testcases. +#=fedoratest +Patch073: gdb-test-expr-cumulative-archer.patch + +# Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz). +#=fedoratest +Patch074: gdb-physname-pr11734-test.patch + +# Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz). +#=fedoratest +Patch075: gdb-physname-pr12273-test.patch + +# Toolchain on sparc is slightly broken and debuginfo files are generated +# with non 64bit aligned tables/offsets. +# See for example readelf -S ../Xvnc.debug. +# +# As a consenquence calculation of sectp->filepos as used in +# dwarf2_read_section (gdb/dwarf2read.c:1525) will return a non aligned buffer +# that cannot be used directly as done with MMAP. +# Usage will result in a BusError. +# +# While we figure out what's wrong in the toolchain and do a full archive +# rebuild to fix it, we need to be able to use gdb :) +#=push +Patch076: gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch + +# Test GDB opcodes/ disassembly of Intel Ivy Bridge instructions (BZ 696890). +#=fedoratest +Patch077: gdb-test-ivy-bridge.patch + +# Hack for proper PIE run of the testsuite. +#=fedoratest +Patch078: gdb-runtest-pie-override.patch + +# Print reasons for failed attach/spawn incl. SELinux deny_ptrace (BZ 786878). +#=push+jan +Patch079: gdb-attach-fail-reasons-5of5.patch + +# Workaround PR libc/14166 for inferior calls of strstr. +#=fedora: Compatibility with RHELs (unchecked which ones). +Patch080: gdb-glibc-strstr-workaround.patch + +# Include testcase for `Unable to see a variable inside a module (XLF)' (BZ 823789). +#=fedoratest +Patch081: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch + +# Testcase for `Setting solib-absolute-prefix breaks vDSO' (BZ 818343). +#=fedoratest +Patch082: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch + +# Fix `GDB cannot access struct member whose offset is larger than 256MB' +# (RH BZ 795424). +#=push +Patch083: gdb-rhbz795424-bitpos-20of25.patch + +# Fix `GDB cannot access struct member whose offset is larger than 256MB' +# (RH BZ 795424). +#=push +Patch084: gdb-rhbz795424-bitpos-21of25.patch + +# Fix `GDB cannot access struct member whose offset is larger than 256MB' +# (RH BZ 795424). +#=push +Patch085: gdb-rhbz795424-bitpos-22of25.patch + +# Fix `GDB cannot access struct member whose offset is larger than 256MB' +# (RH BZ 795424). +#=push +Patch086: gdb-rhbz795424-bitpos-23of25.patch + +# Fix `GDB cannot access struct member whose offset is larger than 256MB' +# (RH BZ 795424). +#=push +Patch087: gdb-rhbz795424-bitpos-25of25.patch + +# Fix `GDB cannot access struct member whose offset is larger than 256MB' +# (RH BZ 795424). +#=push +Patch088: gdb-rhbz795424-bitpos-25of25-test.patch + +# Fix `GDB cannot access struct member whose offset is larger than 256MB' +# (RH BZ 795424). +#=push +Patch089: gdb-rhbz795424-bitpos-lazyvalue.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 +Patch090: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch + +# Fix crash of -readnow /usr/lib/debug/usr/bin/gnatbind.debug (BZ 1069211). +#=push+jan +Patch091: gdb-gnat-dwarf-crash-3of3.patch + +# Fix 'memory leak in infpy_read_memory()' (RH BZ 1007614) +#=fedoratest +Patch092: 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 +Patch093: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch + +#=fedoratest +Patch094: gdb-archer-vla-tests.patch + +#=fedoratest +Patch095: gdb-vla-intel-tests.patch + +# Continue backtrace even if a frame filter throws an exception (Phil Muldoon). +#=push +Patch096: gdb-btrobust.patch + +# Display Fortran strings in backtraces. +#=fedoratest +Patch097: gdb-fortran-frame-string.patch + +# Fix Python GIL with gdb.execute("continue") (Phil Muldoon, BZ 1116957). +#=push +Patch098: gdb-python-gil.patch + +# Testcase for '[SAP] Recursive dlopen causes SAP HANA installer to +# crash.' (RH BZ 1156192). +#=fedoratest +Patch099: gdb-rhbz1156192-recursive-dlopen-test.patch + +# Fix jit-reader.h for multi-lib. +#=push+jan +Patch100: gdb-jit-reader-multilib.patch + +# Fix '`catch syscall' doesn't work for parent after `fork' is called' +# (Philippe Waroquiers, RH BZ 1149205). +#=fedoratest +Patch101: 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 +Patch102: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch + +# Test 'info type-printers' Python error (RH BZ 1350436). +#=fedoratest +Patch103: gdb-rhbz1350436-type-printers-error.patch + +# Fix '[ppc64] and [s390x] wrong prologue skip on -O2 -g code' (Jan +# Kratochvil, RH BZ 1084404). +#=fedoratest +Patch104: 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 +Patch105: gdb-bz1219747-attach-kills.patch + +# Force libncursesw over libncurses to match the includes (RH BZ 1270534). +#=push+jan +Patch106: gdb-fedora-libncursesw.patch + +# Test clflushopt instruction decode (for RH BZ 1262471). +#=fedoratest +Patch107: gdb-opcodes-clflushopt-test.patch + +# [rhel6] DTS backward Python compatibility API (BZ 1020004, Phil Muldoon). +#=fedora +Patch108: gdb-dts-rhel6-python-compat.patch + +# [SCL] Skip deprecated .gdb_index warning for Red Hat built files (BZ 953585). +#=push+jan +Patch109: gdb-6.6-buildid-locate-rpm-scl.patch + +# Work around readline-6.2 incompatibility not asking for --more-- (BZ 701131). +#=fedora +Patch110: gdb-readline62-ask-more-rh.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 . +Patch111: gdb-6.8-quit-never-aborts.patch + +# [aarch64] Fix hardware watchpoints (RH BZ 1261564). +#=fedoratest +Patch112: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch + +# Add messages suggesting more recent RHEL gdbserver (RH BZ 1321114). +#=fedora +Patch113: gdb-container-rh-pkg.patch + +# New test for Python "Cannot locate object file for block" (for RH BZ 1325795). +#=fedoratest +Patch114: gdb-rhbz1325795-framefilters-test.patch + +# [dts+el7] [x86*] Bundle linux_perf.h for libipt (RH BZ 1256513). +#=fedora +Patch115: gdb-linux_perf-bundle.patch + +# Fix gdb-headless /usr/bin/ executables (BZ 1390251). +#=fedora +Patch116: gdb-libexec-add-index.patch + +# New testcase for: Fix -completion crash (Gary Benson, RH BZ 1398387). +#=fedoratest +Patch117: gdb-rhbz1398387-tab-crash-test.patch + +# [testsuite] Fix false selftest.exp FAIL from system readline-6.3+ (Patrick Palka). +#=fedoratest +Patch118: gdb-testsuite-readline63-sigint.patch + +# Python patches of: http://sourceware.org/gdb/wiki/ProjectArcher +#=push +Patch119: gdb-archer.patch + +# Revert upstream commit 469412dd9ccc4de5874fd3299b105833f36b34cd +Patch120: gdb-vla-intel-fix-print-char-array.patch + +# [s390x] Backport arch12 instructions decoding (RH BZ 1553104). +# =fedoratest +Patch121: gdb-rhbz1553104-s390x-arch12-test.patch + +# Implement IPv6 support for GDB/gdbserver (RH BZ 881849, Sergio Durigan Junior). +Patch122: gdb-rhbz881849-ipv6-1of3.patch + + +Patch123: gdb-rhbz881849-ipv6-2of3.patch + + +Patch124: gdb-rhbz881849-ipv6-3of3.patch + +# Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). +Patch125: gdb-rhbz1187581-power8-regs-1of7.patch + +# Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). +Patch126: gdb-rhbz1187581-power8-regs-2of7.patch + +# Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). +Patch127: gdb-rhbz1187581-power8-regs-3of7.patch + +# Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). +Patch128: gdb-rhbz1187581-power8-regs-4of7.patch + +# Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). +Patch129: gdb-rhbz1187581-power8-regs-5of7.patch + +# Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). +Patch130: gdb-rhbz1187581-power8-regs-6of7.patch + +# Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). +Patch131: gdb-rhbz1187581-power8-regs-7of7.patch + +# Fix for 'gdb in batch mode always exit with status 0' (Gary Benson) +# RHBZ #1491128 +Patch132: gdb-rhbz1491128-batch-mode-exit-status-1of2.patch + +# Fix for 'gdb in batch mode always exit with status 0' (Gary Benson) +# RHBZ #1491128 +Patch133: gdb-rhbz1491128-batch-mode-exit-status-2of2.patch + +# Use pulongest in aarch64-linux-tdep.c. +# This patch was forgotten during the 8.2 release process, and is +# needed to unbreak GDB when compiling on 32-bit arches. +Patch134: gdb-use-pulongest-aarch64-linux-tdep.patch + +# Fix for 'GDB crashes when running from a deleted directory' +# (Tom Tromey, RHBZ#1653410) +Patch135: gdb-rhbz1653410-avoid-crash-when-calling-warning-too-early.patch + +# Fix for 'py-bt is broken, results in exception'. +# RHBZ 1639242 +Patch136: gdb-rhbz1639242-fix-dwarf2_find_containing_comp_unit-binary-search.patch + +# Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +# Keith Seitz, RHBZ#1560010. +Patch137: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-1of5.patch + +# Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +# Keith Seitz, RHBZ#1560010. +Patch138: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-2of5.patch + +# Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +# Keith Seitz, RHBZ#1560010. +Patch139: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-3of5.patch + +# Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +# Keith Seitz, RHBZ#1560010. +Patch140: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-4of5.patch + +# Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +# Keith Seitz, RHBZ#1560010. +Patch141: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch + +# Fix 'gdb suggests using "dnf debuginfo-install' +# Keith Seitz, RHBZ 1666249 +Patch142: gdb-rhbz1666249-suggest-yum-instead-of-dnf.patch + +# Fix 'libiberty: Memory leak in demangle_template function resulting in a denial of service" +# Simon Marchi, RH BZ 1668635 +Patch143: gdb-rhbz1668635-libiberty-demangle_template-memleak.patch + +# Fix 'gdb fails to read zN registers from corefile with aarch64 SVE' +# Alan Hayward, RH BZ 1669953 +Patch144: gdb-rhbz1669953-aarch64-sve-binutils.patch + +# Fix remote.c build failure +# Szabolcs Nagy, RH BZ 1187581 +Patch145: gdb-rhbz1187581-power8-regs-not-in-8.2-01of15.patch + +# Add grok/write functions for new ppc core note sections +# Edjunior Barbosa Machado, RH BZ 1187581 +Patch146: gdb-rhbz1187581-power8-regs-not-in-8.2-02of15.patch + +# Zero-initialize linux note sections +# Pedro Franco de Carvalho, RH BZ 1187581 +Patch147: gdb-rhbz1187581-power8-regs-not-in-8.2-03of15.patch + +# [PowerPC] Don't zero-initialize vector register buffers +# Pedro Franco de Carvalho, RH BZ 1187581 +Patch148: gdb-rhbz1187581-power8-regs-not-in-8.2-04of15.patch + +# Add decfloat registers to float reggroup +# Pedro Franco de Carvalho, RH BZ 1187581 +Patch149: gdb-rhbz1187581-power8-regs-not-in-8.2-05of15.patch + +# [PowerPC] Remove rs6000_pseudo_register_reggroup_p +# Pedro Franco de Carvalho, RH BZ 1187581 +Patch150: gdb-rhbz1187581-power8-regs-not-in-8.2-06of15.patch + +# [PowerPC] Fix two if statements in gdb/ppc-linux-nat.c +# Pedro Franco de Carvalho, RH BZ 1187581 +Patch151: gdb-rhbz1187581-power8-regs-not-in-8.2-07of15.patch + +# [PowerPC] Fix indentation in arch/ppc-linux-common.c +# Pedro Franco de Carvalho, RH BZ 1187581 +Patch152: gdb-rhbz1187581-power8-regs-not-in-8.2-08of15.patch + +# [PowerPC] Refactor have_ initializers in rs6000-tdep.c +# Pedro Franco de Carvalho, RH BZ 1187581 +Patch153: gdb-rhbz1187581-power8-regs-not-in-8.2-09of15.patch + +# [PowerPC] Add support for PPR and DSCR +# Edjunior Barbosa Machado and Pedro Franco de Carvalho, RH BZ 1187581 +Patch154: gdb-rhbz1187581-power8-regs-not-in-8.2-10of15.patch + +# [PowerPC] Add support for TAR +# Edjunior Barbosa Machado and Pedro Franco de Carvalho, RH BZ 1187581 +Patch155: gdb-rhbz1187581-power8-regs-not-in-8.2-11of15.patch + +# [PowerPC] Add support for EBB and PMU registers +# Edjunior Barbosa Machado and Pedro Franco de Carvalho, RH BZ 1187581m +Patch156: gdb-rhbz1187581-power8-regs-not-in-8.2-12of15.patch + +# [PowerPC] Reject tdescs with VSX and no FPU or Altivec +# Pedro Franco de Carvalho, RH BZ 1187581 +Patch157: gdb-rhbz1187581-power8-regs-not-in-8.2-13of15.patch + +# [PowerPC] Add support for HTM registers +# Edjunior Barbosa Machado and Pedro Franco de Carvalho, RH BZ 1187581 +Patch158: gdb-rhbz1187581-power8-regs-not-in-8.2-14of15.patch + +# [PowerPC] Document requirements for VSX feature +# Pedro Franco de Carvalho, RH BZ 1187581 +Patch159: gdb-rhbz1187581-power8-regs-not-in-8.2-15of15.patch + +# "Fix" segfault that happens on parse_macro_definition because +# debugedit corrupts the .debug_macro section. +# Sergio Durigan Junior, RH BZ 1708192. +Patch160: gdb-rhbz1708192-parse_macro_definition-crash.patch + +# Prevent buffer overflow with sections with invalid sizes. +# Keith Seitz, RH BZ 1740299. +Patch161: gdb-rhbz1742099-reject-sections-with-invalid-sizes.patch + +# Fix 'GDB needs s390x arch13 binutils patches' +# RHBZ 1768593, Andreas Krebbel +# This patch contains only the opcodes change. +Patch162: gdb-rhbz1768593-s390x-arch13-01.patch + +# Fix 'GDB needs s390x arch13 binutils patches' +# RHBZ 1768593, Andreas Krebbel +# This patch contains only the opcodes and include changes. +Patch163: gdb-rhbz1768593-s390x-arch13-02.patch + +# Fix 'GDB needs s390x arch13 binutils patches' +# RHBZ 1768593, Andreas Krebbel +Patch164: gdb-rhbz1768593-s390x-arch13-03.patch + diff --git a/SOURCES/_gdb.spec.patch.include b/SOURCES/_gdb.spec.patch.include new file mode 100644 index 0000000..03c1fad --- /dev/null +++ b/SOURCES/_gdb.spec.patch.include @@ -0,0 +1,164 @@ +%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 +%patch103 -p1 +%patch104 -p1 +%patch105 -p1 +%patch106 -p1 +%patch107 -p1 +%patch108 -p1 +%patch109 -p1 +%patch110 -p1 +%patch111 -p1 +%patch112 -p1 +%patch113 -p1 +%patch114 -p1 +%patch115 -p1 +%patch116 -p1 +%patch117 -p1 +%patch118 -p1 +%patch119 -p1 +%patch120 -p1 +%patch121 -p1 +%patch122 -p1 +%patch123 -p1 +%patch124 -p1 +%patch125 -p1 +%patch126 -p1 +%patch127 -p1 +%patch128 -p1 +%patch129 -p1 +%patch130 -p1 +%patch131 -p1 +%patch132 -p1 +%patch133 -p1 +%patch134 -p1 +%patch135 -p1 +%patch136 -p1 +%patch137 -p1 +%patch138 -p1 +%patch139 -p1 +%patch140 -p1 +%patch141 -p1 +%patch142 -p1 +%patch143 -p1 +%patch144 -p1 +%patch145 -p1 +%patch146 -p1 +%patch147 -p1 +%patch148 -p1 +%patch149 -p1 +%patch150 -p1 +%patch151 -p1 +%patch152 -p1 +%patch153 -p1 +%patch154 -p1 +%patch155 -p1 +%patch156 -p1 +%patch157 -p1 +%patch158 -p1 +%patch159 -p1 +%patch160 -p1 +%patch161 -p1 +%patch162 -p1 +%patch163 -p1 +%patch164 -p1 diff --git a/SOURCES/gdb-6.3-attach-see-vdso-test.patch b/SOURCES/gdb-6.3-attach-see-vdso-test.patch new file mode 100644 index 0000000..14fff21 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-bz140532-ppc-unwinding-test.patch b/SOURCES/gdb-6.3-bz140532-ppc-unwinding-test.patch new file mode 100644 index 0000000..4a96e8e --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-bz202689-exec-from-pthread-test.patch b/SOURCES/gdb-6.3-bz202689-exec-from-pthread-test.patch new file mode 100644 index 0000000..df59b77 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-focus-cmd-prev-test.patch b/SOURCES/gdb-6.3-focus-cmd-prev-test.patch new file mode 100644 index 0000000..27c85f1 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-gstack-20050411.patch b/SOURCES/gdb-6.3-gstack-20050411.patch new file mode 100644 index 0000000..37b09de --- /dev/null +++ b/SOURCES/gdb-6.3-gstack-20050411.patch @@ -0,0 +1,240 @@ +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 +@@ -1735,7 +1735,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 \ +@@ -1784,7 +1784,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 \ +@@ -1807,6 +1825,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,66 @@ ++# 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 ++} ++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 ++ } ++} ++gdb_exit ++ ++# 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 pid [exp_pid -i $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_exit ++ ++remote_exec host "kill -9 $pid" diff --git a/SOURCES/gdb-6.3-inferior-notification-20050721.patch b/SOURCES/gdb-6.3-inferior-notification-20050721.patch new file mode 100644 index 0000000..b94b432 --- /dev/null +++ b/SOURCES/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 "--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 "--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/SOURCES/gdb-6.3-inheritancetest-20050726.patch b/SOURCES/gdb-6.3-inheritancetest-20050726.patch new file mode 100644 index 0000000..6b22011 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-mapping-zero-inode-test.patch b/SOURCES/gdb-6.3-mapping-zero-inode-test.patch new file mode 100644 index 0000000..1ef25d9 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-ppc64displaysymbol-20041124.patch b/SOURCES/gdb-6.3-ppc64displaysymbol-20041124.patch new file mode 100644 index 0000000..a09b0fe --- /dev/null +++ b/SOURCES/gdb-6.3-ppc64displaysymbol-20041124.patch @@ -0,0 +1,32 @@ +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-ppc64displaysymbol-20041124.patch + +;; Include the pc's section when doing a symbol lookup so that the +;; correct symbol is found. +;;=push: Write new testcase. + +2004-11-24 Andrew Cagney + + * printcmd.c (build_address_symbolic): Find a section for the + address. + +diff --git a/gdb/printcmd.c b/gdb/printcmd.c +--- a/gdb/printcmd.c ++++ b/gdb/printcmd.c +@@ -587,6 +587,14 @@ build_address_symbolic (struct gdbarch *gdbarch, + addr = overlay_mapped_address (addr, section); + } + } ++ /* To ensure that the symbol returned belongs to the correct setion ++ (and that the last [random] symbol from the previous section ++ isn't returned) try to find the section containing PC. First try ++ the overlay code (which by default returns NULL); and second try ++ the normal section code (which almost always succeeds). */ ++ section = find_pc_overlay (addr); ++ if (section == NULL) ++ section = find_pc_section (addr); + + /* First try to find the address in the symbol table, then + in the minsyms. Take the closest one. */ diff --git a/SOURCES/gdb-6.3-ppc64syscall-20040622.patch b/SOURCES/gdb-6.3-ppc64syscall-20040622.patch new file mode 100644 index 0000000..e6319be --- /dev/null +++ b/SOURCES/gdb-6.3-ppc64syscall-20040622.patch @@ -0,0 +1,118 @@ +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-ppc64syscall-20040622.patch + +;; Better parse 64-bit PPC system call prologues. +;;=push: Write new testcase. + +2004-06-22 Andrew Cagney + + * rs6000-tdep.c (struct rs6000_framedata): Add field "func_start". + (skip_prologue): Delete local variable "orig_pc", use + "func_start". Add local variable "num_skip_linux_syscall_insn", + use to skip over first half of a GNU/Linux syscall and update + "func_start". + +diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c +--- a/gdb/rs6000-tdep.c ++++ b/gdb/rs6000-tdep.c +@@ -134,6 +134,7 @@ static const char *powerpc_vector_abi_string = "auto"; + + struct rs6000_framedata + { ++ CORE_ADDR func_start; /* True function start. */ + int offset; /* total size of frame --- the distance + by which we decrement sp to allocate + the frame */ +@@ -1426,7 +1427,6 @@ static CORE_ADDR + skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc, + struct rs6000_framedata *fdata) + { +- CORE_ADDR orig_pc = pc; + CORE_ADDR last_prologue_pc = pc; + CORE_ADDR li_found_pc = 0; + gdb_byte buf[4]; +@@ -1445,12 +1445,14 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc, + int minimal_toc_loaded = 0; + int prev_insn_was_prologue_insn = 1; + int num_skip_non_prologue_insns = 0; ++ int num_skip_ppc64_gnu_linux_syscall_insn = 0; + int r0_contains_arg = 0; + const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + + memset (fdata, 0, sizeof (struct rs6000_framedata)); ++ fdata->func_start = pc; + fdata->saved_gpr = -1; + fdata->saved_fpr = -1; + fdata->saved_vr = -1; +@@ -1484,6 +1486,55 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc, + break; + op = extract_unsigned_integer (buf, 4, byte_order); + ++ /* A PPC64 GNU/Linux system call function is split into two ++ sub-functions: a non-threaded fast-path (__NAME_nocancel) ++ which does not use a frame; and a threaded slow-path ++ (Lpseudo_cancel) that does create a frame. Ref: ++ nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h ++ ++ *INDENT-OFF* ++ NAME: ++ SINGLE_THREAD_P ++ bne- .Lpseudo_cancel ++ __NAME_nocancel: ++ li r0,162 ++ sc ++ bnslr+ ++ b 0x7fe014ef64 <.__syscall_error> ++ Lpseudo_cancel: ++ stdu r1,-128(r1) ++ ... ++ *INDENT-ON* ++ ++ Unfortunatly, because the latter case uses a local label (not ++ in the symbol table) a PC in "Lpseudo_cancel" appears to be ++ in "__NAME_nocancel". The following code recognizes this, ++ adjusting FUNC_START to point to where "Lpseudo_cancel" ++ should be, and parsing the prologue sequence as if ++ "Lpseudo_cancel" was the entry point. */ ++ ++ if (((op & 0xffff0000) == 0x38000000 /* li r0,N */ ++ && pc == fdata->func_start + 0 ++ && num_skip_ppc64_gnu_linux_syscall_insn == 0) ++ || (op == 0x44000002 /* sc */ ++ && pc == fdata->func_start + 4 ++ && num_skip_ppc64_gnu_linux_syscall_insn == 1) ++ || (op == 0x4ca30020 /* bnslr+ */ ++ && pc == fdata->func_start + 8 ++ && num_skip_ppc64_gnu_linux_syscall_insn == 2)) ++ { ++ num_skip_ppc64_gnu_linux_syscall_insn++; ++ continue; ++ } ++ else if ((op & 0xfc000003) == 0x48000000 /* b __syscall_error */ ++ && pc == fdata->func_start + 12 ++ && num_skip_ppc64_gnu_linux_syscall_insn == 3) ++ { ++ num_skip_ppc64_gnu_linux_syscall_insn = -1; ++ fdata->func_start = pc; ++ continue; ++ } ++ + if ((op & 0xfc1fffff) == 0x7c0802a6) + { /* mflr Rx */ + /* Since shared library / PIC code, which needs to get its +@@ -1673,9 +1724,9 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc, + we have no line table information or the line info tells + us that the subroutine call is not part of the line + associated with the prologue. */ +- if ((pc - orig_pc) > 8) ++ if ((pc - fdata->func_start) > 8) + { +- struct symtab_and_line prologue_sal = find_pc_line (orig_pc, 0); ++ struct symtab_and_line prologue_sal = find_pc_line (fdata->func_start, 0); + struct symtab_and_line this_sal = find_pc_line (pc, 0); + + if ((prologue_sal.line == 0) diff --git a/SOURCES/gdb-6.3-readnever-20050907.patch b/SOURCES/gdb-6.3-readnever-20050907.patch new file mode 100644 index 0000000..b70b58f --- /dev/null +++ b/SOURCES/gdb-6.3-readnever-20050907.patch @@ -0,0 +1,35 @@ +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-readnever-20050907.patch + +;; Add readnever option +;;=push + +2004-11-18 Andrew Cagney + + * dwarf2read.c: Include "top.c". + (dwarf2_has_info): Check for readnever_symbol_files. + * symfile.c (readnever_symbol_files): Define. + * top.h (readnever_symbol_files): Declare. + * main.c (captured_main): Add --readnever option. + (print_gdb_help): Ditto. + +2004-11-18 Andrew Cagney + + * gdb.texinfo (File Options): Document --readnever. + +Pushed upstream: https://sourceware.org/ml/gdb-cvs/2017-12/msg00007.html + +diff --git a/gdb/gcore.in b/gdb/gcore.in +--- a/gdb/gcore.in ++++ b/gdb/gcore.in +@@ -97,7 +97,7 @@ for pid in "$@" + do + # ` +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/SOURCES/gdb-6.3-test-dtorfix-20050121.patch b/SOURCES/gdb-6.3-test-dtorfix-20050121.patch new file mode 100644 index 0000000..6586303 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-test-movedir-20050125.patch b/SOURCES/gdb-6.3-test-movedir-20050125.patch new file mode 100644 index 0000000..bcce9fa --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-test-pie-20050107.patch b/SOURCES/gdb-6.3-test-pie-20050107.patch new file mode 100644 index 0000000..85f133b --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-test-self-20050110.patch b/SOURCES/gdb-6.3-test-self-20050110.patch new file mode 100644 index 0000000..5662a0e --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.3-threaded-watchpoints2-20050225.patch b/SOURCES/gdb-6.3-threaded-watchpoints2-20050225.patch new file mode 100644 index 0000000..42b89bf --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-BEA-testsuite.patch b/SOURCES/gdb-6.5-BEA-testsuite.patch new file mode 100644 index 0000000..84e1c9f --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-bz109921-DW_AT_decl_file-test.patch b/SOURCES/gdb-6.5-bz109921-DW_AT_decl_file-test.patch new file mode 100644 index 0000000..a27c8f3 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch b/SOURCES/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch new file mode 100644 index 0000000..fbeb88c --- /dev/null +++ b/SOURCES/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 +@@ -1190,6 +1190,10 @@ print_command_1 (const char *exp, int voidprint) + + if (exp && *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/SOURCES/gdb-6.5-bz203661-emit-relocs.patch b/SOURCES/gdb-6.5-bz203661-emit-relocs.patch new file mode 100644 index 0000000..75ca84f --- /dev/null +++ b/SOURCES/gdb-6.5-bz203661-emit-relocs.patch @@ -0,0 +1,24 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-bz203661-emit-relocs.patch + +;; Fix debuginfo addresses resolving for --emit-relocs Linux kernels (BZ 203661). +;;=push+jan: There was some mail thread about it, this patch may be a hack. + +diff --git a/gdb/symfile.c b/gdb/symfile.c +--- a/gdb/symfile.c ++++ b/gdb/symfile.c +@@ -3584,6 +3584,12 @@ default_symfile_relocate (struct objfile *objfile, asection *sectp, + DWO file. */ + bfd *abfd = sectp->owner; + ++ /* Executable files have all the relocations already resolved. ++ Handle files linked with --emit-relocs. ++ http://sources.redhat.com/ml/gdb/2006-08/msg00137.html */ ++ if ((abfd->flags & EXEC_P) != 0) ++ return NULL; ++ + /* We're only interested in sections with relocation + information. */ + if ((sectp->flags & SEC_RELOC) == 0) diff --git a/SOURCES/gdb-6.5-bz216711-clone-is-outermost.patch b/SOURCES/gdb-6.5-bz216711-clone-is-outermost.patch new file mode 100644 index 0000000..f11df0a --- /dev/null +++ b/SOURCES/gdb-6.5-bz216711-clone-is-outermost.patch @@ -0,0 +1,304 @@ +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-bz216711-clone-is-outermost.patch + +;; Fix bogus 0x0 unwind of the thread's topmost function clone(3) (BZ 216711). +;;=fedora + +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=216711 + +FIXME: This workaround should be dropped and +glibc/sysdeps/unix/sysv/linux/x86_64/clone.S should get CFI for the child +instead. + +2006-12-17 Jan Kratochvil + + * gdb/amd64-linux-tdep.c (linux_clone_code): New variable. + (LINUX_CLONE_LEN): New definition. + (amd64_linux_clone_running, amd64_linux_outermost_frame): New function. + (amd64_linux_init_abi): Initialize `outermost_frame_p'. + * gdb/i386-tdep.c (i386_gdbarch_init): Likewise. + * gdb/i386-tdep.h (gdbarch_tdep): Add `outermost_frame_p' member. + * gdb/amd64-tdep.c (amd64_frame_this_id): Call `outermost_frame_p'. + +2006-12-17 Jan Kratochvil + + * gdb.threads/bt-clone-stop.exp, gdb.threads/bt-clone-stop.c: + New file. + +2007-10-16 Jan Kratochvil + + Port to GDB-6.7. + +diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c +--- a/gdb/amd64-linux-tdep.c ++++ b/gdb/amd64-linux-tdep.c +@@ -291,6 +291,80 @@ amd64_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum, + + /* Set the program counter for process PTID to PC. */ + ++/* Detect the outermost frame; during unwind of ++ #5 0x000000305cec68c3 in clone () from /lib64/tls/libc.so.6 ++ avoid the additional bogus frame ++ #6 0x0000000000000000 in ?? ++ We compare if the `linux_clone_code' block is _before_ unwound PC. */ ++ ++static const unsigned char linux_clone_code[] = ++{ ++/* libc/sysdeps/unix/sysv/linux/x86_64/clone.S */ ++/* #ifdef RESET_PID */ ++/* ... */ ++/* mov $SYS_ify(getpid), %eax */ ++/* 0xb8, 0x27, 0x00, 0x00, 0x00 */ ++/* OR */ ++/* mov $SYS_ify(getpid), %rax */ ++/* 0x48, 0xc7, 0xc0, 0x27, 0x00, 0x00, 0x00 */ ++/* so just: */ ++ 0x27, 0x00, 0x00, 0x00, ++/* syscall */ ++ 0x0f, 0x05, ++/* movl %eax, %fs:PID */ ++ 0x64, 0x89, 0x04, 0x25, 0x94, 0x00, 0x00, 0x00, ++/* movl %eax, %fs:TID */ ++ 0x64, 0x89, 0x04, 0x25, 0x90, 0x00, 0x00, 0x00, ++/* #endif */ ++/* |* Set up arguments for the function call. *| */ ++/* popq %rax |* Function to call. *| */ ++ 0x58, ++/* popq %rdi |* Argument. *| */ ++ 0x5f, ++/* call *%rax$ */ ++ 0xff, 0xd0 ++}; ++ ++#define LINUX_CLONE_LEN (sizeof linux_clone_code) ++ ++static int ++amd64_linux_clone_running (struct frame_info *this_frame) ++{ ++ CORE_ADDR pc = get_frame_pc (this_frame); ++ unsigned char buf[LINUX_CLONE_LEN]; ++ ++ if (!safe_frame_unwind_memory (this_frame, pc - LINUX_CLONE_LEN, buf, ++ LINUX_CLONE_LEN)) ++ return 0; ++ ++ if (memcmp (buf, linux_clone_code, LINUX_CLONE_LEN) != 0) ++ return 0; ++ ++ return 1; ++} ++ ++static int ++amd64_linux_outermost_frame (struct frame_info *this_frame) ++{ ++ CORE_ADDR pc = get_frame_pc (this_frame); ++ const char *name; ++ ++ find_pc_partial_function (pc, &name, NULL, NULL); ++ ++ /* If we have NAME, we can optimize the search. ++ `clone' NAME still needs to have the code checked as its name may be ++ present in the user code. ++ `__clone' NAME should not be present in the user code but in the initial ++ parts of the `__clone' implementation the unwind still makes sense. ++ More detailed unwinding decision would be too much sensitive to possible ++ subtle changes in specific glibc revisions. */ ++ if (name == NULL || strcmp (name, "clone") == 0 ++ || strcmp ("__clone", name) == 0) ++ return (amd64_linux_clone_running (this_frame) != 0); ++ ++ return 0; ++} ++ + static void + amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) + { +@@ -1808,6 +1882,8 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch) + + tdep->xsave_xcr0_offset = I386_LINUX_XSAVE_XCR0_OFFSET; + ++ tdep->outermost_frame_p = amd64_linux_outermost_frame; ++ + /* Add the %orig_rax register used for syscall restarting. */ + set_gdbarch_write_pc (gdbarch, amd64_linux_write_pc); + +diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c +--- a/gdb/amd64-tdep.c ++++ b/gdb/amd64-tdep.c +@@ -2595,6 +2595,7 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame, + { + struct amd64_frame_cache *cache = + amd64_frame_cache (this_frame, this_cache); ++ struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame)); + + if (!cache->base_p) + return UNWIND_UNAVAILABLE; +@@ -2603,6 +2604,10 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame, + if (cache->base == 0) + return UNWIND_OUTERMOST; + ++ /* Detect OS dependent outermost frames; such as `clone'. */ ++ if (tdep->outermost_frame_p && tdep->outermost_frame_p (this_frame)) ++ return UNWIND_OUTERMOST; ++ + return UNWIND_NO_REASON; + } + +@@ -2737,6 +2742,7 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame, + { + struct amd64_frame_cache *cache = + amd64_sigtramp_frame_cache (this_frame, this_cache); ++ struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame)); + + if (!cache->base_p) + (*this_id) = frame_id_build_unavailable_stack (get_frame_pc (this_frame)); +@@ -2745,6 +2751,11 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame, + /* This marks the outermost frame. */ + return; + } ++ else if (tdep->outermost_frame_p && tdep->outermost_frame_p (this_frame)) ++ { ++ /* Detect OS dependent outermost frames; such as `clone'. */ ++ return; ++ } + else + (*this_id) = frame_id_build (cache->base + 16, get_frame_pc (this_frame)); + } +diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c +--- a/gdb/i386-tdep.c ++++ b/gdb/i386-tdep.c +@@ -8406,6 +8406,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + + tdep->xsave_xcr0_offset = -1; + ++ /* Unwinding stops on i386 automatically. */ ++ tdep->outermost_frame_p = NULL; ++ + tdep->record_regmap = i386_record_regmap; + + set_gdbarch_type_align (gdbarch, i386_type_align); +diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h +--- a/gdb/i386-tdep.h ++++ b/gdb/i386-tdep.h +@@ -251,6 +251,9 @@ struct gdbarch_tdep + + /* Regsets. */ + const struct regset *fpregset; ++ ++ /* Detect OS dependent outermost frames; such as `clone'. */ ++ int (*outermost_frame_p) (struct frame_info *this_frame); + }; + + /* Floating-point registers. */ +diff --git a/gdb/testsuite/gdb.threads/bt-clone-stop.c b/gdb/testsuite/gdb.threads/bt-clone-stop.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.threads/bt-clone-stop.c +@@ -0,0 +1,39 @@ ++/* 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., 51 Franklin Street, Fifth Floor, Boston, ++ MA 02110-1301, USA. */ ++ ++ ++#include ++#include ++#include ++ ++ ++void *threader (void *arg) ++{ ++ assert (0); ++ return NULL; ++} ++ ++int main (void) ++{ ++ pthread_t t1; ++ ++ pthread_create (&t1, NULL, threader, (void *) NULL); ++ for (;;) ++ pause(); ++} +diff --git a/gdb/testsuite/gdb.threads/bt-clone-stop.exp b/gdb/testsuite/gdb.threads/bt-clone-stop.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.threads/bt-clone-stop.exp +@@ -0,0 +1,61 @@ ++# 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. ++ ++# Backtraced `clone' must not have `PC == 0' as its previous frame. ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set testfile bt-clone-stop ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++if { [gdb_compile_pthreads "${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} ++ ++# threader: threader.c:8: threader: Assertion `0' failed. ++# Program received signal SIGABRT, Aborted. ++ ++gdb_test "run" \ ++ {Thread 2 "bt-clone-stop" received signal SIGABRT.*} \ ++ "run" ++ ++# Former gdb unwind (the first function is `clone'): ++# #5 0x0000003421ecd62d in ?? () from /lib64/libc.so.6 ++# #6 0x0000000000000000 in ?? () ++# (gdb) ++# Tested `amd64_linux_outermost_frame' functionality should omit the line `#6'. ++# ++# Two `-re' cases below must be in this order (1st is a subset of the 2nd one). ++# Unhandled case below should not happen and it is fortunately handled by ++# `amd64_linux_outermost_frame' as FAIL (and result `0x0 entry output invalid'). ++gdb_test_multiple "bt" "0x0 entry output invalid" { ++ -re "in threader \\(.*\n#\[0-9\]* *0x0* in .*$gdb_prompt $" { ++ fail "0x0 entry found" ++ } ++ -re "in threader \\(.*$gdb_prompt $" { ++ pass "0x0 entry not found" ++ } ++} diff --git a/SOURCES/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch b/SOURCES/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch new file mode 100644 index 0000000..8a648a3 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch b/SOURCES/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch new file mode 100644 index 0000000..45d8570 --- /dev/null +++ b/SOURCES/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 +@@ -3165,6 +3165,13 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) + SYMBOL_LINKAGE_NAME (msymbol)); */ + ; + /* 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_LINKAGE_NAME (msymbol.minsym), paddress (target_gdbarch (), pc)); ++ /* fall through */ + else + return find_pc_line (BMSYMBOL_VALUE_ADDRESS (mfunsym), 0); + } diff --git a/SOURCES/gdb-6.5-bz243845-stale-testing-zombie-test.patch b/SOURCES/gdb-6.5-bz243845-stale-testing-zombie-test.patch new file mode 100644 index 0000000..a0520d7 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-gcore-buffer-limit-test.patch b/SOURCES/gdb-6.5-gcore-buffer-limit-test.patch new file mode 100644 index 0000000..f4ae65e --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-ia64-libunwind-leak-test.patch b/SOURCES/gdb-6.5-ia64-libunwind-leak-test.patch new file mode 100644 index 0000000..8a8a43a --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-last-address-space-byte-test.patch b/SOURCES/gdb-6.5-last-address-space-byte-test.patch new file mode 100644 index 0000000..9c5779f --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-missed-trap-on-step-test.patch b/SOURCES/gdb-6.5-missed-trap-on-step-test.patch new file mode 100644 index 0000000..06a9f7e --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-readline-long-line-crash-test.patch b/SOURCES/gdb-6.5-readline-long-line-crash-test.patch new file mode 100644 index 0000000..5410899 --- /dev/null +++ b/SOURCES/gdb-6.5-readline-long-line-crash-test.patch @@ -0,0 +1,141 @@ +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,126 @@ ++# 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 ++} ++ ++# 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. ++global env ++if [info exists env(INPUTRC)] { ++ set old_inputrc $env(INPUTRC) ++} ++set env(INPUTRC) "/dev/null" ++ ++set oldtimeout1 $timeout ++set timeout 600 ++ ++if [info exists env(GDBHISTFILE)] { ++ set old_gdbhistfile $env(GDBHISTFILE) ++} ++if [info exists env(HISTSIZE)] { ++ set old_histsize $env(HISTSIZE) ++} ++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" ++ ++ ++# Restore globals modified in this test... ++if [info exists old_inputrc] { ++ set env(INPUTRC) $old_inputrc ++} else { ++ unset env(INPUTRC) ++} ++if [info exists old_gdbhistfile] { ++ set env(GDBHISTFILE) $old_gdbhistfile ++} else { ++ unset env(GDBHISTFILE) ++} ++if [info exists old_histsize] { ++ set env(HISTSIZE) $old_histsize ++} else { ++ unset env(HISTSIZE) ++} ++set timeout $oldtimeout1 ++ diff --git a/SOURCES/gdb-6.5-section-num-fixup-test.patch b/SOURCES/gdb-6.5-section-num-fixup-test.patch new file mode 100644 index 0000000..012ba92 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.5-sharedlibrary-path.patch b/SOURCES/gdb-6.5-sharedlibrary-path.patch new file mode 100644 index 0000000..6f31e88 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.6-buildid-locate-core-as-arg.patch b/SOURCES/gdb-6.6-buildid-locate-core-as-arg.patch new file mode 100644 index 0000000..40938a5 --- /dev/null +++ b/SOURCES/gdb-6.6-buildid-locate-core-as-arg.patch @@ -0,0 +1,197 @@ +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/common/common-exceptions.h b/gdb/common/common-exceptions.h +--- a/gdb/common/common-exceptions.h ++++ b/gdb/common/common-exceptions.h +@@ -104,6 +104,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/exec.c b/gdb/exec.c +--- a/gdb/exec.c ++++ b/gdb/exec.c +@@ -36,6 +36,7 @@ + #include "gdb_bfd.h" + #include "gcore.h" + #include "source.h" ++#include "exceptions.h" + + #include + #include "readline/readline.h" +@@ -357,12 +358,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)); ++ ++ 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 (_("\"%s\": not in executable format: %s"), ++ scratch_pathname, ++ gdb_bfd_errmsg (bfd_get_error (), matching)); + } + + if (build_section_table (exec_bfd, §ions, §ions_end)) +diff --git a/gdb/main.c b/gdb/main.c +--- a/gdb/main.c ++++ b/gdb/main.c +@@ -447,6 +447,37 @@ 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) ++{ ++ volatile struct gdb_exception e; ++ ++ gdb_assert (exec_bfd == NULL); ++ ++ TRY ++ { ++ exec_file_attach (filename, from_tty); ++ } ++ CATCH (e, RETURN_MASK_ALL) ++ { ++ 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 (e); ++ } ++ END_CATCH ++} ++ + static void + captured_main_1 (struct captured_main_args *context) + { +@@ -883,6 +914,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++; + } + +@@ -1033,11 +1066,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! */ +- if (catch_command_errors (exec_file_attach, execarg, +- !batch_flag)) ++ 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. */ ++ if (catch_command_errors (func, execarg, !batch_flag) ++ && core_bfd == NULL) + catch_command_errors (symbol_file_add_main_adapter, symarg, + !batch_flag); + } diff --git a/SOURCES/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch b/SOURCES/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch new file mode 100644 index 0000000..a25057e --- /dev/null +++ b/SOURCES/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch @@ -0,0 +1,144 @@ +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/build-id.c b/gdb/build-id.c +--- a/gdb/build-id.c ++++ b/gdb/build-id.c +@@ -581,7 +581,10 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id, + do_cleanups (inner); + + if (abfd == NULL) +- continue; ++ { ++ filename = NULL; ++ continue; ++ } + + if (build_id_verify (abfd.get(), build_id_len, build_id)) + break; +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/SOURCES/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch b/SOURCES/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch new file mode 100644 index 0000000..375b178 --- /dev/null +++ b/SOURCES/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 +@@ -652,6 +652,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/SOURCES/gdb-6.6-buildid-locate-rpm-scl.patch b/SOURCES/gdb-6.6-buildid-locate-rpm-scl.patch new file mode 100644 index 0000000..7e39488 --- /dev/null +++ b/SOURCES/gdb-6.6-buildid-locate-rpm-scl.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-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 +@@ -689,7 +689,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; +@@ -796,7 +800,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; +@@ -914,6 +922,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); + } +@@ -924,6 +963,21 @@ missing_rpm_enlist (const char *filename) + } + + static int ++#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); ++} ++ ++static int ++#endif + missing_rpm_list_compar (const char *const *ap, const char *const *bp) + { + return strcoll (*ap, *bp); +diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -3469,6 +3469,16 @@ read_gdb_index_from_section (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) + { +@@ -3480,6 +3490,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/SOURCES/gdb-6.6-buildid-locate-rpm.patch b/SOURCES/gdb-6.6-buildid-locate-rpm.patch new file mode 100644 index 0000000..d5ec4b0 --- /dev/null +++ b/SOURCES/gdb-6.6-buildid-locate-rpm.patch @@ -0,0 +1,1514 @@ +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 +@@ -35,6 +35,8 @@ + #include "elf/common.h" + #include "elf-bfd.h" + #include ++#include "elf/external.h" ++#include "inferior.h" + + #define BUILD_ID_VERBOSE_NONE 0 + #define BUILD_ID_VERBOSE_FILENAMES 1 +@@ -640,8 +642,366 @@ 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 int ++missing_rpm_list_compar (const char *const *ap, const char *const *bp) ++{ ++ return strcoll (*ap, *bp); ++} ++ ++/* 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) ++{ ++ char **array, **array_iter; ++ struct missing_rpm *list_iter; ++ struct cleanup *cleanups; ++ ++ if (missing_rpm_list_entries == 0) ++ return; ++ ++ array = (char **) xmalloc (sizeof (*array) * missing_rpm_list_entries); ++ cleanups = make_cleanup (xfree, array); ++ ++ array_iter = array; ++ for (list_iter = missing_rpm_list; list_iter != NULL; ++ list_iter = list_iter->next) ++ { ++ *array_iter++ = list_iter->rpm; ++ } ++ gdb_assert (array_iter == array + missing_rpm_list_entries); ++ ++ qsort (array, missing_rpm_list_entries, sizeof (*array), ++ (int (*) (const void *, const void *)) missing_rpm_list_compar); ++ ++ printf_unfiltered (_("Missing separate debuginfos, use: %s"), ++#ifdef DNF_DEBUGINFO_INSTALL ++ "dnf " ++#endif ++ "debuginfo-install"); ++ for (array_iter = array; array_iter < array + missing_rpm_list_entries; ++ array_iter++) ++ { ++ putchar_unfiltered (' '); ++ puts_unfiltered (*array_iter); ++ } ++ putchar_unfiltered ('\n'); ++ ++ while (missing_rpm_list != NULL) ++ { ++ list_iter = missing_rpm_list; ++ missing_rpm_list = list_iter->next; ++ xfree (list_iter); ++ } ++ missing_rpm_list_entries = 0; ++ ++ do_cleanups (cleanups); ++} ++ ++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 +@@ -695,11 +1055,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 (); + } + +@@ -766,14 +1132,39 @@ 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) ++ { ++ char *execfilename; + +- 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); ++ execfilename = get_exec_file (0); ++ 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 +@@ -33,6 +33,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 +@@ -270,6 +273,9 @@ + /* Define if Python 2.7 is being used. */ + #undef HAVE_LIBPYTHON2_7 + ++/* 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 +@@ -749,6 +749,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 +@@ -853,6 +858,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_gdbcli +@@ -912,6 +918,11 @@ CCC + CPP + MAKEINFO + MAKEINFOFLAGS ++PKG_CONFIG ++PKG_CONFIG_PATH ++PKG_CONFIG_LIBDIR ++RPM_CFLAGS ++RPM_LIBS + YACC + YFLAGS + XMKMF' +@@ -1583,6 +1594,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 +@@ -1640,6 +1653,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'. +@@ -6575,6 +6595,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 +@@ -166,6 +166,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/corelow.c b/gdb/corelow.c +--- a/gdb/corelow.c ++++ b/gdb/corelow.c +@@ -366,7 +366,7 @@ build_id_locate_exec (int from_tty) + symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED; + } + else +- debug_print_missing (_("the main executable file"), build_id_filename); ++ debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename); + + do_cleanups (back_to); + +diff --git a/gdb/event-top.c b/gdb/event-top.c +--- a/gdb/event-top.c ++++ b/gdb/event-top.c +@@ -40,6 +40,7 @@ + #include "buffer.h" + #include "ser-event.h" + #include "gdb_select.h" ++#include "symfile.h" + + /* readline include files. */ + #include "readline/readline.h" +@@ -359,6 +360,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. */ +@@ -774,7 +777,10 @@ command_line_handler (char *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 +@@ -540,6 +540,8 @@ void map_symbol_filenames (symbol_filename_ftype *fun, void *data, + /* 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/SOURCES/gdb-6.6-buildid-locate-solib-missing-ids.patch b/SOURCES/gdb-6.6-buildid-locate-solib-missing-ids.patch new file mode 100644 index 0000000..2b96166 --- /dev/null +++ b/SOURCES/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 +@@ -1358,14 +1358,27 @@ svr4_read_so_list (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; +@@ -1380,23 +1393,7 @@ svr4_read_so_list (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/SOURCES/gdb-6.6-buildid-locate.patch b/SOURCES/gdb-6.6-buildid-locate.patch new file mode 100644 index 0000000..6acb6bc --- /dev/null +++ b/SOURCES/gdb-6.6-buildid-locate.patch @@ -0,0 +1,1249 @@ +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/gdb/build-id.c b/gdb/build-id.c +--- a/gdb/build-id.c ++++ b/gdb/build-id.c +@@ -26,11 +26,67 @@ + #include "objfiles.h" + #include "filenames.h" + #include "gdbcore.h" ++#include "libbfd.h" ++#include "gdbcore.h" ++#include "gdbcmd.h" ++#include "observable.h" ++#include "elf/external.h" ++#include "elf/internal.h" ++#include "elf/common.h" ++#include "elf-bfd.h" ++#include ++ ++#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 size = descsz; ++ gdb_byte *data = (gdb_byte *) descdata; ++ struct bfd_build_id *retval; ++ ++ retval = (struct bfd_build_id *) xmalloc (sizeof *retval - 1 + size); ++ retval->size = size; ++ memcpy (retval->data, data, size); ++ ++ 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)) + return NULL; +@@ -42,6 +98,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 (abfd, 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 (core_bfd, 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 +@@ -50,7 +448,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"), +@@ -65,11 +463,50 @@ 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; ++} ++ + /* 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, int add_debug_suffix) + { ++ char *debugdir; ++ std::string link, link_all; ++ struct cleanup *back_to; ++ int ix; + gdb_bfd_ref_ptr abfd; + + /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will +@@ -82,63 +519,296 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) + { + const gdb_byte *data = build_id; + size_t size = build_id_len; ++ char *filename = NULL; ++ struct cleanup *inner; ++ unsigned seqno; ++ struct stat statbuf_trash; ++ std::string link0; + +- std::string link = debugdir.get (); ++ link = debugdir.get (); + link += "/.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 += ".debug"; +- + if (separate_debug_file_debug) + printf_unfiltered (_(" Trying %s\n"), link.c_str ()); + +- /* 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) +- continue; ++ for (seqno = 0;; seqno++) ++ { ++ if (seqno) ++ { ++ /* 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. */ ++ ++ string_appendf (link, ".%u", seqno); ++ } ++ ++ if (add_debug_suffix) ++ link += ".debug"; ++ ++ if (!seqno) ++ { ++ /* If none of the real files is found report as missing file ++ always the non-.%u-suffixed file. */ ++ link0 = link; ++ } ++ ++ /* `access' automatically dereferences LINK. */ ++ if (lstat (link.c_str (), &statbuf_trash) != 0) ++ { ++ /* Stop increasing SEQNO. */ ++ break; ++ } ++ ++ filename = lrealpath (link.c_str ()); ++ if (filename == NULL) ++ continue; ++ ++ /* We expect to be silent on the non-existing files. */ ++ inner = make_cleanup (xfree, filename); ++ abfd = gdb_bfd_open (filename, gnutarget, -1); ++ do_cleanups (inner); ++ ++ if (abfd == NULL) ++ continue; ++ ++ if (build_id_verify (abfd.get(), build_id_len, build_id)) ++ break; ++ ++ abfd.release (); ++ ++ filename = NULL; ++ } + +- /* We expect to be silent on the non-existing files. */ +- abfd = gdb_bfd_open (filename.get (), gnutarget, -1); ++ if (filename != NULL) ++ { ++ /* LINK_ALL is not used below in this non-NULL FILENAME case. */ ++ break; ++ } + +- if (abfd == NULL) +- continue; ++ /* 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 (build_id_verify (abfd.get(), build_id_len, build_id)) +- break; ++ 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; ++ } ++ } + +- abfd.release (); ++ if (link_return != NULL) ++ { ++ if (abfd != NULL) ++ { ++ *link_return = xstrdup (link.c_str ()); ++ } ++ else ++ { ++ *link_return = xstrdup (link_all.c_str ()); ++ } + } + + return abfd; + } + ++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_debug_bfd (build_id->size, build_id->data, link_return, 0); ++ if (abfd == NULL) ++ return NULL; ++ ++ result = xstrdup (bfd_get_filename (abfd)); ++ abfd.release (); ++ 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. */ + + 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), 1)); ++ 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 ()), +@@ -151,3 +821,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 +@@ -22,9 +22,10 @@ + + #include "gdb_bfd.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,13 +39,18 @@ extern int build_id_verify (bfd *abfd, + the caller. */ + + 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, ++ int add_debug_suffix); ++ ++extern char *build_id_to_filename (const struct bfd_build_id *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); + + #endif /* BUILD_ID_H */ +diff --git a/gdb/coffread.c b/gdb/coffread.c +--- a/gdb/coffread.c ++++ b/gdb/coffread.c +@@ -733,7 +733,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 +@@ -45,6 +45,10 @@ + #include "gdb_bfd.h" + #include "completer.h" + #include "filestuff.h" ++#include "auxv.h" ++#include "elf/common.h" ++#include "gdbcmd.h" ++#include "build-id.h" + + #ifndef O_LARGEFILE + #define O_LARGEFILE 0 +@@ -321,6 +325,54 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg) + inferior_ptid = ptid; /* Yes, make it current. */ + } + ++static int build_id_core_loads = 1; ++ ++static void ++build_id_locate_exec (int from_tty) ++{ ++ CORE_ADDR at_entry; ++ struct bfd_build_id *build_id; ++ char *execfilename, *debug_filename; ++ char *build_id_filename; ++ struct cleanup *back_to; ++ ++ if (exec_bfd != NULL || symfile_objfile != NULL) ++ return; ++ ++ if (target_auxv_search (current_top_target (), AT_ENTRY, &at_entry) <= 0) ++ return; ++ ++ build_id = build_id_addr_get (at_entry); ++ if (build_id == NULL) ++ return; ++ back_to = make_cleanup (xfree, build_id); ++ ++ /* SYMFILE_OBJFILE should refer to the main executable (not only to its ++ separate debug info file). gcc44+ keeps .eh_frame only in the main ++ executable without its duplicate .debug_frame in the separate debug info ++ file - such .eh_frame would not be found if SYMFILE_OBJFILE would refer ++ directly to the separate debug info file. */ ++ ++ execfilename = build_id_to_filename (build_id, &build_id_filename); ++ make_cleanup (xfree, build_id_filename); ++ ++ if (execfilename != NULL) ++ { ++ make_cleanup (xfree, execfilename); ++ exec_file_attach (execfilename, from_tty); ++ symbol_file_add_main (execfilename, ++ symfile_add_flag (!from_tty ? 0 : SYMFILE_VERBOSE)); ++ if (symfile_objfile != NULL) ++ symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED; ++ } ++ else ++ debug_print_missing (_("the main executable file"), build_id_filename); ++ ++ do_cleanups (back_to); ++ ++ /* No automatic SOLIB_ADD as the libraries would get read twice. */ ++} ++ + /* Issue a message saying we have no core to debug, if FROM_TTY. */ + + static void +@@ -464,6 +516,14 @@ core_target_open (const char *arg, int from_tty) + switch_to_thread (thread); + } + ++ /* Find the build_id identifiers. If it gets executed after ++ POST_CREATE_INFERIOR we would clash with asking to discard the already ++ loaded VDSO symbols. If it gets executed before bfd_map_over_sections ++ INFERIOR_PTID is still not set and libthread_db initialization crashes on ++ PID == 0 in ps_pglobal_lookup. */ ++ if (build_id_core_loads != 0) ++ build_id_locate_exec (from_tty); ++ + post_create_inferior (target, from_tty); + + /* Now go through the target stack looking for threads since there +@@ -1072,4 +1132,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 +@@ -19570,6 +19570,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/dwarf2read.c b/gdb/dwarf2read.c +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -2683,7 +2683,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, 1); + + if (dwz_bfd == NULL) + error (_("could not find '.gnu_debugaltlink' file for %s"), +diff --git a/gdb/elfread.c b/gdb/elfread.c +--- a/gdb/elfread.c ++++ b/gdb/elfread.c +@@ -1290,7 +1290,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); +@@ -1302,6 +1304,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) + symbol_file_add_separate (abfd.get (), debugfile.c_str (), + symfile_flags, objfile); + } ++ /* Check if any separate debug info has been extracted out. */ ++ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink") ++ != NULL) ++ debug_print_missing (objfile_name (objfile), build_id_filename.get ()); + } + } + +diff --git a/gdb/objfiles.h b/gdb/objfiles.h +--- a/gdb/objfiles.h ++++ b/gdb/objfiles.h +@@ -470,6 +470,10 @@ struct objfile + htab_t 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 +@@ -137,7 +137,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 (except, RETURN_MASK_ALL) + { +@@ -544,7 +544,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); +@@ -1356,9 +1357,51 @@ svr4_read_so_list (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 +@@ -537,6 +537,10 @@ void expand_symtabs_matching + void map_symbol_filenames (symbol_filename_ftype *fun, void *data, + int need_fullname); + ++/* 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 +@@ -1695,6 +1695,16 @@ proc default_gdb_start { } { + warning "Couldn't set the width to 0." + } + } ++ # 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.." ++ } ++ } + 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/SOURCES/gdb-6.6-bz229517-gcore-without-terminal.patch b/SOURCES/gdb-6.6-bz229517-gcore-without-terminal.patch new file mode 100644 index 0000000..b4ddc9f --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.6-bz230000-power6-disassembly-test.patch b/SOURCES/gdb-6.6-bz230000-power6-disassembly-test.patch new file mode 100644 index 0000000..f40b6f6 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch b/SOURCES/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch new file mode 100644 index 0000000..89f2d64 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.6-scheduler_locking-step-is-default.patch b/SOURCES/gdb-6.6-scheduler_locking-step-is-default.patch new file mode 100644 index 0000000..ebc4aa6 --- /dev/null +++ b/SOURCES/gdb-6.6-scheduler_locking-step-is-default.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.6-scheduler_locking-step-is-default.patch + +;; Make upstream `set scheduler-locking step' as default. +;;=push+jan: How much is scheduler-locking relevant after non-stop? + +diff --git a/gdb/infrun.c b/gdb/infrun.c +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -2193,7 +2193,7 @@ static const char *const scheduler_enums[] = { + schedlock_replay, + NULL + }; +-static const char *scheduler_mode = schedlock_replay; ++static const char *scheduler_mode = schedlock_step; + static void + show_scheduler_mode (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp +--- a/gdb/testsuite/gdb.mi/mi-cli.exp ++++ b/gdb/testsuite/gdb.mi/mi-cli.exp +@@ -199,7 +199,7 @@ mi_expect_stop "breakpoint-hit" "main" "" ".*basics.c" \ + # Test that the token is output even for CLI commands + # Also test that *stopped includes frame information. + mi_gdb_test "34 next" \ +- ".*34\\\^running.*\\*running,thread-id=\"all\"" \ ++ ".*34\\\^running.*\\*running,thread-id=\"1\"" \ + "34 next: run" + + # Test that the new current source line is output to the console +diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp +--- a/gdb/testsuite/gdb.mi/mi-console.exp ++++ b/gdb/testsuite/gdb.mi/mi-console.exp +@@ -60,6 +60,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb + + mi_run_to_main + ++# thread-id=\"all\" vs. thread-id=\"1\" below: ++mi_gdb_test "210-gdb-set scheduler-locking off" "210\\^done" "set scheduler-locking off" ++ + # The output we get from the target depends on how it is hosted. If + # we are semihosted (e.g., the sim or a remote target that supports + # the File I/O remote protocol extension), we see the target I/O +diff --git a/gdb/testsuite/gdb.mi/mi-logging.exp b/gdb/testsuite/gdb.mi/mi-logging.exp +--- a/gdb/testsuite/gdb.mi/mi-logging.exp ++++ b/gdb/testsuite/gdb.mi/mi-logging.exp +@@ -53,7 +53,7 @@ close $chan + + set mi_log_prompt "\[(\]gdb\[)\] \[\r\n\]+" + +-if [regexp "\\^done\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { ++if [regexp "\\^done\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { + pass "log file contents" + } else { + fail "log file contents" +@@ -76,7 +76,7 @@ set chan [open $milogfile] + set logcontent [read $chan] + close $chan + +-if [regexp "1001\\^done\[\r\n\]+$mi_log_prompt.*1002\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt.*1003\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { ++if [regexp "1001\\^done\[\r\n\]+$mi_log_prompt.*1002\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt.*1003\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { + pass "redirect log file contents" + } else { + fail "redirect log file contents" +diff --git a/gdb/testsuite/gdb.opt/inline-cmds.exp b/gdb/testsuite/gdb.opt/inline-cmds.exp +--- a/gdb/testsuite/gdb.opt/inline-cmds.exp ++++ b/gdb/testsuite/gdb.opt/inline-cmds.exp +@@ -331,7 +331,7 @@ proc mi_cli_step {cli_output_re message} { + + send_gdb "interpreter-exec console \"step\"\n" + gdb_expect { +- -re "\\^running\r\n\\*running,thread-id=\"all\"\r\n${mi_gdb_prompt}${cli_output_re}" { ++ -re "\\^running\r\n\\*running,thread-id=\"1\"\r\n${mi_gdb_prompt}${cli_output_re}" { + pass $message + } + timeout { diff --git a/SOURCES/gdb-6.6-testsuite-timeouts.patch b/SOURCES/gdb-6.6-testsuite-timeouts.patch new file mode 100644 index 0000000..a896313 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.7-charsign-test.patch b/SOURCES/gdb-6.7-charsign-test.patch new file mode 100644 index 0000000..8c89b13 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.7-ppc-clobbered-registers-O2-test.patch b/SOURCES/gdb-6.7-ppc-clobbered-registers-O2-test.patch new file mode 100644 index 0000000..08ee2f9 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.7-testsuite-stable-results.patch b/SOURCES/gdb-6.7-testsuite-stable-results.patch new file mode 100644 index 0000000..ec8f9c2 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.8-bz436037-reg-no-longer-active.patch b/SOURCES/gdb-6.8-bz436037-reg-no-longer-active.patch new file mode 100644 index 0000000..ea240af --- /dev/null +++ b/SOURCES/gdb-6.8-bz436037-reg-no-longer-active.patch @@ -0,0 +1,37 @@ +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-bz436037-reg-no-longer-active.patch + +;; Fix register assignments with no GDB stack frames (BZ 436037). +;;=push+jan: This fix is incorrect. + +diff --git a/gdb/valops.c b/gdb/valops.c +--- a/gdb/valops.c ++++ b/gdb/valops.c +@@ -1104,6 +1104,8 @@ value_assign (struct value *toval, struct value *fromval) + struct gdbarch *gdbarch; + int value_reg; + ++ value_reg = VALUE_REGNUM (toval); ++ + /* Figure out which frame this is in currently. + + We use VALUE_FRAME_ID for obtaining the value's frame id instead of +@@ -1113,8 +1115,14 @@ value_assign (struct value *toval, struct value *fromval) + frame. */ + frame = frame_find_by_id (VALUE_FRAME_ID (toval)); + +- value_reg = VALUE_REGNUM (toval); +- ++ /* "set $reg+=1" should work on programs with no debug info, ++ but frame_find_by_id returns NULL here (RH bug 436037). ++ Use current frame, it represents CPU state in this case. ++ If frame_find_by_id is changed to do it internally ++ (it is contemplated there), remove this. */ ++ if (!frame) ++ frame = get_current_frame (); ++ /* Probably never happens. */ + if (!frame) + error (_("Value being assigned to is no longer active.")); + diff --git a/SOURCES/gdb-6.8-bz442765-threaded-exec-test.patch b/SOURCES/gdb-6.8-bz442765-threaded-exec-test.patch new file mode 100644 index 0000000..e2ed431 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.8-bz466901-backtrace-full-prelinked.patch b/SOURCES/gdb-6.8-bz466901-backtrace-full-prelinked.patch new file mode 100644 index 0000000..542a956 --- /dev/null +++ b/SOURCES/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/SOURCES/gdb-6.8-quit-never-aborts.patch b/SOURCES/gdb-6.8-quit-never-aborts.patch new file mode 100644 index 0000000..85db824 --- /dev/null +++ b/SOURCES/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 +@@ -820,6 +820,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 +@@ -1606,7 +1606,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 +@@ -108,6 +108,13 @@ static std::chrono::steady_clock::duration prompt_for_continue_wait_time; + + static int debug_timestamp = 0; + ++#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 ++ + /* Nonzero means that strings with character values >0x7F should be printed + as octal escapes. Zero means just print the value (e.g. it's an + international character, and the terminal or window can cope.) */ diff --git a/SOURCES/gdb-6.8-sparc64-silence-memcpy-check.patch b/SOURCES/gdb-6.8-sparc64-silence-memcpy-check.patch new file mode 100644 index 0000000..6c0848d --- /dev/null +++ b/SOURCES/gdb-6.8-sparc64-silence-memcpy-check.patch @@ -0,0 +1,19 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.8-sparc64-silence-memcpy-check.patch + +;; Silence memcpy check which returns false positive (sparc64) +;;=push: But it is just a GCC workaround, look up the existing GCC PR for it. + +diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c +--- a/gdb/sparc-tdep.c ++++ b/gdb/sparc-tdep.c +@@ -1462,6 +1462,7 @@ sparc32_store_return_value (struct type *type, struct regcache *regcache, + if (sparc_floating_p (type) || sparc_complex_floating_p (type)) + { + /* Floating return values. */ ++ len = (len <= 8) ? len : 8; + memcpy (buf, valbuf, len); + regcache->cooked_write (SPARC_F0_REGNUM, buf); + if (len > 4) diff --git a/SOURCES/gdb-6.8-watchpoint-conditionals-test.patch b/SOURCES/gdb-6.8-watchpoint-conditionals-test.patch new file mode 100644 index 0000000..5096a67 --- /dev/null +++ b/SOURCES/gdb-6.8-watchpoint-conditionals-test.patch @@ -0,0 +1,90 @@ +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-watchpoint-conditionals-test.patch + +;; Test the watchpoints conditionals works. +;;=fedoratest + +For: +http://sourceware.org/ml/gdb-patches/2008-04/msg00379.html +http://sourceware.org/ml/gdb-cvs/2008-04/msg00104.html + +diff --git a/gdb/testsuite/gdb.base/watchpoint-cond.c b/gdb/testsuite/gdb.base/watchpoint-cond.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/watchpoint-cond.c +@@ -0,0 +1,31 @@ ++/* 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 . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@prep.ai.mit.edu */ ++ ++int ++main (int argc, char **argv) ++{ ++ static int i = 0; /* `static' to start initialized. */ ++ int j = 2; ++ ++ for (j = 0; j < 30; j++) ++ i = 30 - j; ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/watchpoint-cond.exp b/gdb/testsuite/gdb.base/watchpoint-cond.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/watchpoint-cond.exp +@@ -0,0 +1,37 @@ ++# Copyright 2008 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 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 watchpoint-cond ++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} ++ ++if { [runto_main] < 0 } { ++ untested watchpoint-cond ++ return -1 ++} ++ ++gdb_test "watch i if i < 20" "atchpoint \[0-9\]+: i" ++gdb_test "cont" "atchpoint \[0-9\]+: i.*Old value = 20.*New value = 19.*" diff --git a/SOURCES/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch b/SOURCES/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch new file mode 100644 index 0000000..fc75329 --- /dev/null +++ b/SOURCES/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch @@ -0,0 +1,68 @@ +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-7.2.50-sparc-add-workaround-to-broken-debug-files.patch + +;; Toolchain on sparc is slightly broken and debuginfo files are generated +;; with non 64bit aligned tables/offsets. +;; See for example readelf -S ../Xvnc.debug. +;; +;; As a consenquence calculation of sectp->filepos as used in +;; dwarf2_read_section (gdb/dwarf2read.c:1525) will return a non aligned buffer +;; that cannot be used directly as done with MMAP. +;; Usage will result in a BusError. +;; +;; While we figure out what's wrong in the toolchain and do a full archive +;; rebuild to fix it, we need to be able to use gdb :) +;;=push + +diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c +--- a/gdb/gdb_bfd.c ++++ b/gdb/gdb_bfd.c +@@ -24,12 +24,14 @@ + #include "hashtab.h" + #include "filestuff.h" + #include "vec.h" ++#ifndef __sparc__ + #ifdef HAVE_MMAP + #include + #ifndef MAP_FAILED + #define MAP_FAILED ((void *) -1) + #endif + #endif ++#endif + #include "target.h" + #include "gdb/fileio.h" + #include "inferior.h" +@@ -484,6 +486,7 @@ free_one_bfd_section (bfd *abfd, asection *sectp, void *ignore) + + if (sect != NULL && sect->data != NULL) + { ++#ifndef __sparc__ + #ifdef HAVE_MMAP + if (sect->map_addr != NULL) + { +@@ -493,6 +496,7 @@ free_one_bfd_section (bfd *abfd, asection *sectp, void *ignore) + gdb_assert (res == 0); + } + else ++#endif + #endif + xfree (sect->data); + } +@@ -659,6 +663,7 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size) + if (descriptor->data != NULL) + goto done; + ++#ifndef __sparc__ + #ifdef HAVE_MMAP + if (!bfd_is_section_compressed (abfd, sectp)) + { +@@ -693,6 +698,7 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size) + } + } + #endif /* HAVE_MMAP */ ++#endif + + /* Handle compressed sections, or ordinary uncompressed sections in + the no-mmap case. */ diff --git a/SOURCES/gdb-archer-next-over-throw-cxx-exec.patch b/SOURCES/gdb-archer-next-over-throw-cxx-exec.patch new file mode 100644 index 0000000..26643f8 --- /dev/null +++ b/SOURCES/gdb-archer-next-over-throw-cxx-exec.patch @@ -0,0 +1,97 @@ +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,51 @@ ++# 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 ++ } ++} ++ ++set test continue ++gdb_test_multiple $test $test { ++ -re "Cannot access memory at address 0x\[0-9a-f\]+\r\n$gdb_prompt $" { ++ fail $test ++ } ++ -re "\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++# `info inferiors' can show on older GDBs. ++gdb_test "info threads" "info threads" "program finished" diff --git a/SOURCES/gdb-archer-pie-addons-keep-disabled.patch b/SOURCES/gdb-archer-pie-addons-keep-disabled.patch new file mode 100644 index 0000000..8824e54 --- /dev/null +++ b/SOURCES/gdb-archer-pie-addons-keep-disabled.patch @@ -0,0 +1,89 @@ +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 +@@ -15522,6 +15522,50 @@ initialize_breakpoint_ops (void) + + static struct cmd_list_element *enablebreaklist = NULL; + ++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) ++ qsort (bp_locations, bp_locations_count, sizeof (*bp_locations), ++ bp_locations_compare); ++} ++ + void + _initialize_breakpoint (void) + { +diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h +--- a/gdb/breakpoint.h ++++ b/gdb/breakpoint.h +@@ -1679,6 +1679,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 +@@ -883,6 +883,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/SOURCES/gdb-archer-pie-addons.patch b/SOURCES/gdb-archer-pie-addons.patch new file mode 100644 index 0000000..9aef617 --- /dev/null +++ b/SOURCES/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 +@@ -505,6 +505,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 */ +@@ -556,6 +557,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; + +@@ -1438,6 +1440,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) \ +@@ -1449,6 +1452,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)) +@@ -1465,6 +1469,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 +@@ -2829,7 +2829,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 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type))))); + break; + case FIELD_LOC_KIND_PHYSNAME: + { diff --git a/SOURCES/gdb-archer-vla-tests.patch b/SOURCES/gdb-archer-vla-tests.patch new file mode 100644 index 0000000..fa4fa0d --- /dev/null +++ b/SOURCES/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 +@@ -56,5 +56,11 @@ gdb_test_multiple "$test" "$test" { + # are. Observed with (FSF GNU Ada 4.5.3 20110124). + xfail $test + } ++ -re "= \\(\\)\[\r\n\]+$gdb_prompt $" { ++ # archer-jankratochvil-vla resolves it as a dynamic type resolved as an ++ # empty array [0..-1]. ++ # DW_AT_upper_bound : (DW_OP_fbreg: -48; DW_OP_deref) ++ xfail $test ++ } + } + +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S +@@ -0,0 +1,358 @@ ++ .file "x86_64-vla-pointer.c" ++ .text ++.Ltext0: ++ .globl foo ++ .type foo, @function ++foo: ++.LFB0: ++ .file 1 "gdb.arch/x86_64-vla-pointer.c" ++ # gdb.arch/x86_64-vla-pointer.c:22 ++ .loc 1 22 0 ++ .cfi_startproc ++# BLOCK 2 seq:0 ++# PRED: ENTRY (FALLTHRU) ++ pushq %rbp ++ .cfi_def_cfa_offset 16 ++ .cfi_offset 6, -16 ++ movq %rsp, %rbp ++ .cfi_def_cfa_register 6 ++ pushq %rbx ++ subq $56, %rsp ++ .cfi_offset 3, -24 ++ movl %edi, -52(%rbp) ++ # gdb.arch/x86_64-vla-pointer.c:22 ++ .loc 1 22 0 ++ movq %rsp, %rax ++ movq %rax, %rsi ++ # gdb.arch/x86_64-vla-pointer.c:23 ++ .loc 1 23 0 ++ movl -52(%rbp), %eax ++ movslq %eax, %rdx ++ subq $1, %rdx ++ movq %rdx, -32(%rbp) ++ movslq %eax, %rdx ++ movq %rdx, %r8 ++ movl $0, %r9d ++ # gdb.arch/x86_64-vla-pointer.c:24 ++ .loc 1 24 0 ++ movslq %eax, %rdx ++ movq %rdx, %rcx ++ movl $0, %ebx ++ cltq ++ movl $16, %edx ++ subq $1, %rdx ++ addq %rdx, %rax ++ movl $16, %ebx ++ movl $0, %edx ++ divq %rbx ++ imulq $16, %rax, %rax ++ subq %rax, %rsp ++ movq %rsp, %rax ++ addq $0, %rax ++ movq %rax, -40(%rbp) ++ # gdb.arch/x86_64-vla-pointer.c:27 ++ .loc 1 27 0 ++ movl $0, -20(%rbp) ++# SUCC: 4 [100.0%] ++ jmp .L2 ++# BLOCK 3 seq:1 ++# PRED: 4 ++.L3: ++ # gdb.arch/x86_64-vla-pointer.c:28 ++ .loc 1 28 0 discriminator 3 ++ movl -20(%rbp), %eax ++ movl %eax, %ecx ++ movq -40(%rbp), %rdx ++ movl -20(%rbp), %eax ++ cltq ++ movb %cl, (%rdx,%rax) ++# SUCC: 4 (FALLTHRU,DFS_BACK) ++ # gdb.arch/x86_64-vla-pointer.c:27 ++ .loc 1 27 0 discriminator 3 ++ addl $1, -20(%rbp) ++# BLOCK 4 seq:2 ++# PRED: 3 (FALLTHRU,DFS_BACK) 2 [100.0%] ++.L2: ++ # gdb.arch/x86_64-vla-pointer.c:27 ++ .loc 1 27 0 is_stmt 0 discriminator 1 ++ movl -20(%rbp), %eax ++ cmpl -52(%rbp), %eax ++# SUCC: 3 5 (FALLTHRU) ++ jl .L3 ++# BLOCK 5 seq:3 ++# PRED: 4 (FALLTHRU) ++ # gdb.arch/x86_64-vla-pointer.c:30 ++ .loc 1 30 0 is_stmt 1 ++ movq -40(%rbp), %rax ++ movb $0, (%rax) ++ movq %rsi, %rsp ++ # gdb.arch/x86_64-vla-pointer.c:31 ++ .loc 1 31 0 ++ nop ++ movq -8(%rbp), %rbx ++ leave ++ .cfi_def_cfa 7, 8 ++# SUCC: EXIT [100.0%] ++ ret ++ .cfi_endproc ++.LFE0: ++ .size foo, .-foo ++.Letext0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .long 0xa5 # Length of Compilation Unit Info ++ .value 0x4 # DWARF version number ++ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section ++ .byte 0x8 # Pointer Size (in bytes) ++ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit) ++ .long .LASF3 # DW_AT_producer: "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g" ++ .byte 0xc # DW_AT_language ++ .long .LASF4 # DW_AT_name: "gdb.arch/x86_64-vla-pointer.c" ++ .long .LASF5 # DW_AT_comp_dir: "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite" ++ .quad .Ltext0 # DW_AT_low_pc ++ .quad .Letext0-.Ltext0 # DW_AT_high_pc ++ .long .Ldebug_line0 # DW_AT_stmt_list ++ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram) ++ # DW_AT_external ++ .ascii "foo\0" # DW_AT_name ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) ++ .byte 0x15 # DW_AT_decl_line ++ # DW_AT_prototyped ++ .quad .LFB0 # DW_AT_low_pc ++ .quad .LFE0-.LFB0 # DW_AT_high_pc ++ .uleb128 0x1 # DW_AT_frame_base ++ .byte 0x9c # DW_OP_call_frame_cfa ++ # DW_AT_GNU_all_call_sites ++ .long 0x80 # DW_AT_sibling ++ .uleb128 0x3 # (DIE (0x4a) DW_TAG_formal_parameter) ++ .long .LASF6 # DW_AT_name: "size" ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) ++ .byte 0x15 # DW_AT_decl_line ++ .long 0x80 # DW_AT_type ++ .uleb128 0x3 # DW_AT_location ++ .byte 0x91 # DW_OP_fbreg ++ .sleb128 -68 ++ .uleb128 0x4 # (DIE (0x59) DW_TAG_typedef) ++ .long .LASF7 # DW_AT_name: "array_t" ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) ++ .byte 0x17 # DW_AT_decl_line ++ .long 0x87 # DW_AT_type ++ .uleb128 0x5 # (DIE (0x64) DW_TAG_variable) ++ .long .LASF0 # DW_AT_name: "array" ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) ++ .byte 0x18 # DW_AT_decl_line ++ .long 0x59 # DW_AT_type ++ .uleb128 0x3 # DW_AT_location ++ .byte 0x91 # DW_OP_fbreg ++ .sleb128 -56 ++ .byte 0x6 # DW_OP_deref ++ .uleb128 0x6 # (DIE (0x73) DW_TAG_variable) ++ .ascii "i\0" # DW_AT_name ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c) ++ .byte 0x19 # DW_AT_decl_line ++ .long 0x80 # DW_AT_type ++ .uleb128 0x2 # DW_AT_location ++ .byte 0x91 # DW_OP_fbreg ++ .sleb128 -36 ++ .byte 0 # end of children of DIE 0x2d ++ .uleb128 0x7 # (DIE (0x80) DW_TAG_base_type) ++ .byte 0x4 # DW_AT_byte_size ++ .byte 0x5 # DW_AT_encoding ++ .ascii "int\0" # DW_AT_name ++ .uleb128 0x8 # (DIE (0x87) DW_TAG_array_type) ++ .long 0xa1 # DW_AT_type ++ .long 0x9a # DW_AT_sibling ++ .uleb128 0x9 # (DIE (0x90) DW_TAG_subrange_type) ++ .long 0x9a # DW_AT_type ++ .uleb128 0x3 # DW_AT_upper_bound ++ .byte 0x91 # DW_OP_fbreg ++ .sleb128 -48 ++ .byte 0x6 # DW_OP_deref ++ .byte 0 # end of children of DIE 0x87 ++ .uleb128 0xa # (DIE (0x9a) DW_TAG_base_type) ++ .byte 0x8 # DW_AT_byte_size ++ .byte 0x7 # DW_AT_encoding ++ .long .LASF1 # DW_AT_name: "sizetype" ++ .uleb128 0xa # (DIE (0xa1) DW_TAG_base_type) ++ .byte 0x1 # DW_AT_byte_size ++ .byte 0x6 # DW_AT_encoding ++ .long .LASF2 # DW_AT_name: "char" ++ .byte 0 # end of children of DIE 0xb ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .uleb128 0x1 # (abbrev code) ++ .uleb128 0x11 # (TAG: DW_TAG_compile_unit) ++ .byte 0x1 # DW_children_yes ++ .uleb128 0x25 # (DW_AT_producer) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x13 # (DW_AT_language) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x1b # (DW_AT_comp_dir) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x7 # (DW_FORM_data8) ++ .uleb128 0x10 # (DW_AT_stmt_list) ++ .uleb128 0x17 # (DW_FORM_sec_offset) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x2 # (abbrev code) ++ .uleb128 0x2e # (TAG: DW_TAG_subprogram) ++ .byte 0x1 # DW_children_yes ++ .uleb128 0x3f # (DW_AT_external) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0x8 # (DW_FORM_string) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x27 # (DW_AT_prototyped) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x7 # (DW_FORM_data8) ++ .uleb128 0x40 # (DW_AT_frame_base) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x1 # (DW_AT_sibling) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x3 # (abbrev code) ++ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter) ++ .byte 0 # DW_children_no ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x2 # (DW_AT_location) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x4 # (abbrev code) ++ .uleb128 0x16 # (TAG: DW_TAG_typedef) ++ .byte 0 # DW_children_no ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x5 # (abbrev code) ++ .uleb128 0x34 # (TAG: DW_TAG_variable) ++ .byte 0 # DW_children_no ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x2 # (DW_AT_location) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x6 # (abbrev code) ++ .uleb128 0x34 # (TAG: DW_TAG_variable) ++ .byte 0 # DW_children_no ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0x8 # (DW_FORM_string) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x2 # (DW_AT_location) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x7 # (abbrev code) ++ .uleb128 0x24 # (TAG: DW_TAG_base_type) ++ .byte 0 # DW_children_no ++ .uleb128 0xb # (DW_AT_byte_size) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3e # (DW_AT_encoding) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0x8 # (DW_FORM_string) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x8 # (abbrev code) ++ .uleb128 0x1 # (TAG: DW_TAG_array_type) ++ .byte 0x1 # DW_children_yes ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x1 # (DW_AT_sibling) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x9 # (abbrev code) ++ .uleb128 0x21 # (TAG: DW_TAG_subrange_type) ++ .byte 0 # DW_children_no ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x2f # (DW_AT_upper_bound) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0 ++ .byte 0 ++ .uleb128 0xa # (abbrev code) ++ .uleb128 0x24 # (TAG: DW_TAG_base_type) ++ .byte 0 # DW_children_no ++ .uleb128 0xb # (DW_AT_byte_size) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3e # (DW_AT_encoding) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .byte 0 ++ .byte 0 ++ .byte 0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c # Length of Address Ranges Info ++ .value 0x2 # DWARF Version ++ .long .Ldebug_info0 # Offset of Compilation Unit Info ++ .byte 0x8 # Size of Address ++ .byte 0 # Size of Segment Descriptor ++ .value 0 # Pad to 16 byte boundary ++ .value 0 ++ .quad .Ltext0 # Address ++ .quad .Letext0-.Ltext0 # Length ++ .quad 0 ++ .quad 0 ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .section .debug_str,"MS",@progbits,1 ++.LASF4: ++ .string "gdb.arch/x86_64-vla-pointer.c" ++.LASF7: ++ .string "array_t" ++.LASF3: ++ .string "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g" ++.LASF2: ++ .string "char" ++.LASF1: ++ .string "sizetype" ++.LASF5: ++ .string "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite" ++.LASF6: ++ .string "size" ++.LASF0: ++ .string "array" ++ .ident "GCC: (GNU) 6.2.1 20160916 (Red Hat 6.2.1-2)" ++ .section .note.GNU-stack,"",@progbits +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c +@@ -0,0 +1,45 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#if 0 ++ ++void ++foo (int size) ++{ ++ typedef char array_t[size]; ++ array_t array; ++ int i; ++ ++ for (i = 0; i < size; i++) ++ array[i] = i; ++ ++ array[0] = 0; /* break-here */ ++} ++ ++#else ++ ++void foo (int size); ++ ++int ++main (void) ++{ ++ foo (26); ++ foo (78); ++ return 0; ++} ++ ++#endif +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp +@@ -0,0 +1,65 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if ![istarget "x86_64-*-*"] then { ++ verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64." ++ return ++} ++ ++set testfile x86_64-vla-pointer ++set srcasmfile ${testfile}-foo.S ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++set binobjfile [standard_output_file ${testfile}-foo.o] ++if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] { ++ untested x86_64-vla-pointer ++ return -1 ++} ++ ++gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"] ++ ++gdb_continue_to_breakpoint "break-here" ++ ++gdb_test "whatis array" "type = array_t" "first: whatis array" ++gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "first: whatis array_t" ++gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" ++ ++gdb_test "whatis *array" "type = char" "first: whatis *array" ++gdb_test "ptype *array" "type = char" "first: ptype *array" ++ ++gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" ++gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" ++gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" ++gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = array_t" "second: whatis array" ++gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "second: whatis array_t" ++gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array" +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S +@@ -0,0 +1,455 @@ ++ .file "x86_64-vla-typedef.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl foo ++ .type foo, @function ++foo: ++.LFB2: ++ .file 1 "x86_64-vla-typedef.c" ++ .loc 1 22 0 ++ pushq %rbp ++.LCFI0: ++ movq %rsp, %rbp ++.LCFI1: ++ subq $64, %rsp ++.LCFI2: ++ movl %edi, -36(%rbp) ++ .loc 1 22 0 ++ movq %rsp, %rax ++ movq %rax, -48(%rbp) ++ .loc 1 23 0 ++ movl -36(%rbp), %edx ++ movslq %edx,%rax ++ subq $1, %rax ++ movq %rax, -24(%rbp) ++ .loc 1 24 0 ++ movslq %edx,%rax ++ addq $15, %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ subq %rax, %rsp ++ movq %rsp, -56(%rbp) ++ movq -56(%rbp), %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ movq %rax, -56(%rbp) ++ movq -56(%rbp), %rax ++ movq %rax, -16(%rbp) ++ .loc 1 27 0 ++ movl $0, -4(%rbp) ++ jmp .L2 ++.L3: ++ .loc 1 28 0 ++ movl -4(%rbp), %esi ++ movl -4(%rbp), %eax ++ movl %eax, %ecx ++ movq -16(%rbp), %rdx ++ movslq %esi,%rax ++ movb %cl, (%rdx,%rax) ++ .loc 1 27 0 ++ addl $1, -4(%rbp) ++.L2: ++ movl -4(%rbp), %eax ++ cmpl -36(%rbp), %eax ++ jl .L3 ++ .loc 1 30 0 ++ .globl break_here ++break_here: ++ movq -16(%rbp), %rax ++ movb $0, (%rax) ++ movq -48(%rbp), %rsp ++ .loc 1 31 0 ++ leave ++ ret ++.LFE2: ++ .size foo, .-foo ++ .section .debug_frame,"",@progbits ++.Lframe0: ++ .long .LECIE0-.LSCIE0 ++.LSCIE0: ++ .long 0xffffffff ++ .byte 0x1 ++ .string "" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE0: ++.LSFDE0: ++ .long .LEFDE0-.LASFDE0 ++.LASFDE0: ++ .long .Lframe0 ++ .quad .LFB2 ++ .quad .LFE2-.LFB2 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE0: ++ .section .eh_frame,"a",@progbits ++.Lframe1: ++ .long .LECIE1-.LSCIE1 ++.LSCIE1: ++ .long 0x0 ++ .byte 0x1 ++ .string "zR" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .uleb128 0x1 ++ .byte 0x3 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE1: ++.LSFDE1: ++ .long .LEFDE1-.LASFDE1 ++.LASFDE1: ++ .long .LASFDE1-.Lframe1 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .uleb128 0x0 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE1: ++ .text ++.Letext0: ++ .section .debug_loc,"",@progbits ++.Ldebug_loc0: ++.LLST0: ++ .quad .LFB2-.Ltext0 ++ .quad .LCFI0-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 8 ++ .quad .LCFI0-.Ltext0 ++ .quad .LCFI1-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 16 ++ .quad .LCFI1-.Ltext0 ++ .quad .LFE2-.Ltext0 ++ .value 0x2 ++ .byte 0x76 ++ .sleb128 16 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_info ++ .long .Ldebug_end - .Ldebug_start ++.Ldebug_start: ++ .value 0x2 ++ .long .Ldebug_abbrev0 ++ .byte 0x8 ++ .uleb128 0x1 ++ .long .LASF2 ++ .byte 0x1 ++ .long .LASF3 ++ .long .LASF4 ++ .quad .Ltext0 ++ .quad .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .byte 0x1 ++ .string "foo" ++ .byte 0x1 ++ .byte 0x16 ++ .byte 0x1 ++ .quad .LFB2 ++ .quad .LFE2 ++ .long .LLST0 ++ .long 0x83 ++ .uleb128 0x3 ++ .long .LASF5 ++ .byte 0x1 ++ .byte 0x15 ++ .long 0x83 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -52 ++.Ltag_typedef: ++ .uleb128 0x4 ++ .long .LASF6 ++ .byte 0x1 ++ .byte 0x17 ++ .long .Ltag_array_type - .debug_info ++ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ ++ .long .LASF0 ++ .byte 0x1 ++ .byte 0x18 ++#if 1 ++ .long .Ltag_typedef - .debug_info ++#else ++ /* Debugging only: Skip the typedef indirection. */ ++ .long .Ltag_array_type - .debug_info ++#endif ++ /* DW_AT_location: DW_FORM_block1: start */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -32 ++#if 0 ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ ++#endif ++ /* DW_AT_location: DW_FORM_block1: end */ ++ .uleb128 0x6 ++ .string "i" ++ .byte 0x1 ++ .byte 0x19 ++ .long 0x83 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -20 ++ .byte 0x0 ++ .uleb128 0x7 ++ .byte 0x4 ++ .byte 0x5 ++ .string "int" ++.Ltag_array_type: ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */ ++ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */ ++1: /* DW_AT_data_location: DW_FORM_block1: start */ ++ .byte 2f - 3f /* length */ ++3: ++ .byte 0x97 /* DW_OP_push_object_address */ ++ .byte 0x6 /* DW_OP_deref */ ++2: /* DW_AT_data_location: DW_FORM_block1: end */ ++ .uleb128 0x9 ++ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -40 ++ .byte 0x6 ++ .byte 0x0 ++ .uleb128 0xa ++ .byte 0x8 ++ .byte 0x7 ++ .uleb128 0xb ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF1 ++ .byte 0x0 ++.Ldebug_end: ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0xe ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x1b ++ .uleb128 0xe ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x27 ++ .uleb128 0xc ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0x6 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 ++ .uleb128 0x16 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .uleb128 0x1 ++ .byte 0x1 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x1 /* DW_AT_sibling */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x50 /* DW_AT_data_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 ++ .uleb128 0x21 ++ .byte 0x0 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2f ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x16 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0xa8 ++ .long 0x2d ++ .string "foo" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x8 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .quad .Ltext0 ++ .quad .Letext0-.Ltext0 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF0: ++ .string "array" ++.LASF5: ++ .string "size" ++.LASF3: ++ .string "x86_64-vla-typedef.c" ++.LASF6: ++ .string "array_t" ++.LASF1: ++ .string "char" ++.LASF4: ++ .string "gdb.arch" ++.LASF2: ++ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .section .note.GNU-stack,"",@progbits +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c +@@ -0,0 +1,45 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2008 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#if 0 ++ ++void ++foo (int size) ++{ ++ typedef char array_t[size]; ++ array_t array; ++ int i; ++ ++ for (i = 0; i < size; i++) ++ array[i] = i; ++ ++ array[0] = 0; /* break-here */ ++} ++ ++#else ++ ++void foo (int size); ++ ++int ++main (void) ++{ ++ foo (26); ++ foo (78); ++ return 0; ++} ++ ++#endif +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp +@@ -0,0 +1,64 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate. ++ ++if ![istarget "x86_64-*-*"] then { ++ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64." ++ return ++} ++ ++set testfile x86_64-vla-typedef ++set srcasmfile ${testfile}-foo.S ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++set binobjfile [standard_output_file ${testfile}-foo.o] ++if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] { ++ untested x86_64-vla-typedef ++ return -1 ++} ++ ++gdb_breakpoint "break_here" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = array_t" "first: whatis array" ++ ++gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" ++ ++gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" ++gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" ++gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" ++gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = array_t" "second: whatis array" ++ ++gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array" +diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c +--- a/gdb/testsuite/gdb.base/arrayidx.c ++++ b/gdb/testsuite/gdb.base/arrayidx.c +@@ -17,6 +17,13 @@ + + int array[] = {1, 2, 3, 4}; + ++#ifdef __GNUC__ ++struct ++ { ++ int a[0]; ++ } unbound; ++#endif ++ + int + main (void) + { +diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp +--- a/gdb/testsuite/gdb.base/arrayidx.exp ++++ b/gdb/testsuite/gdb.base/arrayidx.exp +@@ -49,4 +49,12 @@ gdb_test "print array" \ + "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \ + "print array with array-indexes on" + +- ++set test "p unbound.a == &unbound.a\[0\]" ++gdb_test_multiple $test $test { ++ -re " = 1\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" { ++ unsupported "$test (no GCC)" ++ } ++} +diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/internal-var-field-address.c +@@ -0,0 +1,20 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++struct { ++ int field; ++} staticstruct = { 1 }; +diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp +@@ -0,0 +1,26 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set test internal-var-field-address ++set binfile ${test}.x ++if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "[standard_output_file ${binfile}]" object {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++clean_restart $binfile ++ ++gdb_test {set $varstruct = staticstruct} ++gdb_test {p $varstruct.field} " = 1" +diff --git a/gdb/testsuite/gdb.base/vla-frame.c b/gdb/testsuite/gdb.base/vla-frame.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/vla-frame.c +@@ -0,0 +1,31 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++ ++int ++main (int argc, char **argv) ++{ ++ char s[2 + argc]; ++ void (*f) (char *) = 0; ++ ++ memset (s, 0, sizeof (s)); ++ s[0] = 'X'; ++ ++ f (s); ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/vla-frame.exp b/gdb/testsuite/gdb.base/vla-frame.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/vla-frame.exp +@@ -0,0 +1,38 @@ ++# Copyright 2011 Free Software Foundation, Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile vla-frame ++set executable ${testfile} ++ ++if { [prepare_for_testing ${testfile}.exp ${executable}] } { ++ return -1 ++} ++ ++if ![runto_main] { ++ return -1 ++} ++ ++set test "continue" ++gdb_test_multiple $test $test { ++ -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "\r\n$gdb_prompt $" { ++ untested ${testfile}.exp ++ return ++ } ++} ++ ++gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*" +diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/vla-overflow.c +@@ -0,0 +1,30 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2008 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++ ++int ++main (int argc, char **argv) ++{ ++ int array[argc]; ++ ++ array[0] = array[0]; ++ ++ abort (); ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/vla-overflow.exp +@@ -0,0 +1,109 @@ ++# Copyright 2008 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# We could crash in: ++# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69 ++# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97 ++# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL)); ++# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496 ++# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156 ++# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206 ++# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430 ++# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840 ++# ... ++# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292 ++# ... ++# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273 ++ ++set testfile vla-overflow ++set shfile [standard_output_file ${testfile}-gdb.sh] ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++set f [open "|getconf PAGESIZE" "r"] ++gets $f pagesize ++close $f ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set pid_of_gdb [exp_pid -i [board_info host fileid]] ++ ++if { [runto_main] < 0 } { ++ untested vla-overflow ++ return -1 ++} ++ ++# Get the GDB memory size when we stay at main. ++ ++proc memory_v_pages_get {} { ++ global pid_of_gdb pagesize ++ set fd [open "/proc/$pid_of_gdb/statm"] ++ gets $fd line ++ close $fd ++ # number of pages of virtual memory ++ scan $line "%d" drs ++ return $drs ++} ++ ++set pages_found [memory_v_pages_get] ++ ++# s390x with glibc-debuginfo.s390x installed used approx. 16MB. ++set mb_reserve 40 ++verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve" ++set kb_found [expr $pages_found * $pagesize / 1024] ++set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024] ++verbose -log "kb_found = $kb_found, kb_permit = $kb_permit" ++ ++# Create the ulimit wrapper. ++set f [open $shfile "w"] ++puts $f "#! /bin/sh" ++puts $f "ulimit -v $kb_permit" ++puts $f "exec $GDB \"\$@\"" ++close $f ++remote_exec host "chmod +x $shfile" ++ ++gdb_exit ++set GDBold $GDB ++set GDB "$shfile" ++gdb_start ++set GDB $GDBold ++ ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set pid_of_gdb [exp_pid -i [board_info host fileid]] ++ ++# Check the size again after the second run. ++# We must not stop in main as it would cache `array' and never crash later. ++ ++gdb_run_cmd ++ ++verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" ++ ++gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()" ++ ++verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" ++ ++# `abort' can get expressed as `*__GI_abort'. ++gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()" ++ ++verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" +diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/vla.c +@@ -0,0 +1,55 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2008 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++ ++void ++marker (void) ++{ ++} ++ ++void ++bar (char *a, char *b, char *c, int size) ++{ ++ memset (a, '1', size); ++ memset (b, '2', size); ++ memset (c, '3', 48); ++} ++ ++void ++foo (int size) ++{ ++ char temp1[size]; ++ char temp3[48]; ++ ++ temp1[size - 1] = '\0'; ++ { ++ char temp2[size]; ++ ++ bar (temp1, temp2, temp3, size); ++ ++ marker (); /* break-here */ ++ } ++} ++ ++int ++main (void) ++{ ++ foo (26); ++ foo (78); ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/vla.exp +@@ -0,0 +1,62 @@ ++# Copyright 2008 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile vla ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] { ++ untested vla ++ return -1 ++} ++ ++gdb_breakpoint [gdb_get_line_number "break-here"] ++ ++gdb_continue_to_breakpoint "break-here" ++ ++gdb_test "whatis temp1" "type = char \\\[26\\\]" "first: whatis temp1" ++gdb_test "whatis temp2" "type = char \\\[26\\\]" "first: whatis temp2" ++gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3" ++ ++gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1" ++gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2" ++gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3" ++ ++gdb_test "p temp1" " = '1' " "first: print temp1" ++gdb_test "p temp2" " = '2' " "first: print temp2" ++gdb_test "p temp3" " = '3' " "first: print temp3" ++ ++gdb_continue_to_breakpoint "break-here" ++ ++gdb_test "whatis temp1" "type = char \\\[78\\\]" "second: whatis temp1" ++gdb_test "whatis temp2" "type = char \\\[78\\\]" "second: whatis temp2" ++gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3" ++ ++gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1" ++gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2" ++gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3" ++ ++gdb_test "p temp1" " = '1' " "second: print temp1" ++gdb_test "p temp2" " = '2' " "second: print temp2" ++gdb_test "p temp3" " = '3' " "second: print temp3" +diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/gdb9593.cc +@@ -0,0 +1,180 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2008, 2009 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++ */ ++#include ++ ++using namespace std; ++ ++class NextOverThrowDerivates ++{ ++ ++public: ++ ++ ++ // Single throw an exception in this function. ++ void function1() ++ { ++ throw 20; ++ } ++ ++ // Throw an exception in another function. ++ void function2() ++ { ++ function1(); ++ } ++ ++ // Throw an exception in another function, but handle it ++ // locally. ++ void function3 () ++ { ++ { ++ try ++ { ++ function1 (); ++ } ++ catch (...) ++ { ++ cout << "Caught and handled function1 exception" << endl; ++ } ++ } ++ } ++ ++ void rethrow () ++ { ++ try ++ { ++ function1 (); ++ } ++ catch (...) ++ { ++ throw; ++ } ++ } ++ ++ void finish () ++ { ++ // We use this to test that a "finish" here does not end up in ++ // this frame, but in the one above. ++ try ++ { ++ function1 (); ++ } ++ catch (int x) ++ { ++ } ++ function1 (); // marker for until ++ } ++ ++ void until () ++ { ++ function1 (); ++ function1 (); // until here ++ } ++ ++}; ++NextOverThrowDerivates next_cases; ++ ++ ++int main () ++{ ++ try ++ { ++ next_cases.function1 (); ++ } ++ catch (...) ++ { ++ // Discard ++ } ++ ++ try ++ { ++ next_cases.function2 (); ++ } ++ catch (...) ++ { ++ // Discard ++ } ++ ++ try ++ { ++ // This is duplicated so we can next over one but step into ++ // another. ++ next_cases.function2 (); ++ } ++ catch (...) ++ { ++ // Discard ++ } ++ ++ next_cases.function3 (); ++ ++ try ++ { ++ next_cases.rethrow (); ++ } ++ catch (...) ++ { ++ // Discard ++ } ++ ++ try ++ { ++ // Another duplicate so we can test "finish". ++ next_cases.function2 (); ++ } ++ catch (...) ++ { ++ // Discard ++ } ++ ++ // Another test for "finish". ++ try ++ { ++ next_cases.finish (); ++ } ++ catch (...) ++ { ++ } ++ ++ // Test of "until". ++ try ++ { ++ next_cases.finish (); ++ } ++ catch (...) ++ { ++ } ++ ++ // Test of "until" with an argument. ++ try ++ { ++ next_cases.until (); ++ } ++ catch (...) ++ { ++ } ++ ++ // Test of "advance". ++ try ++ { ++ next_cases.until (); ++ } ++ catch (...) ++ { ++ } ++} ++ +diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/gdb9593.exp +@@ -0,0 +1,182 @@ ++# Copyright 2008, 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++if { [skip_cplus_tests] } { continue } ++ ++set testfile "gdb9593" ++set srcfile ${testfile}.cc ++set binfile [standard_output_file $testfile] ++ ++# Create and source the file that provides information about the compiler ++# used to compile the test case. ++if [get_compiler_info "c++"] { ++ untested gdb9593.exp ++ return -1 ++} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { ++ untested gdb9593.exp ++ return -1 ++} ++ ++# Some targets can't do function calls, so don't even bother with this ++# test. ++if [target_info exists gdb,cannot_call_functions] { ++ setup_xfail "*-*-*" 9593 ++ fail "This target can not call functions" ++ continue ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] then { ++ perror "couldn't run to main" ++ continue ++} ++ ++# See whether we have the needed unwinder hooks. ++set ok 1 ++gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" { ++ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" { ++ pass "check for unwinder hook" ++ } ++ -re "No symbol .* in current context.\r\n$gdb_prompt $" { ++ # Pass the test so we don't get bogus fails in the results. ++ pass "check for unwinder hook" ++ set ok 0 ++ } ++} ++if {!$ok} { ++ untested gdb9593.exp ++ return -1 ++} ++ ++# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593 ++ ++gdb_test "next" \ ++ ".*catch (...).*" \ ++ "next over a throw 1" ++ ++gdb_test "next" \ ++ ".*next_cases.function2.*" \ ++ "next past catch 1" ++ ++gdb_test "next" \ ++ ".*catch (...).*" \ ++ "next over a throw 2" ++ ++gdb_test "next" \ ++ ".*next_cases.function2.*" \ ++ "next past catch 2" ++ ++gdb_test "step" \ ++ ".*function1().*" \ ++ "step into function2 1" ++ ++gdb_test "next" \ ++ ".*catch (...).*" \ ++ "next over a throw 3" ++ ++gdb_test "next" \ ++ ".*next_cases.function3.*" \ ++ "next past catch 3" ++ ++gdb_test "next" \ ++ ".*next_cases.rethrow.*" \ ++ "next over a throw 4" ++ ++gdb_test "next" \ ++ ".*catch (...).*" \ ++ "next over a rethrow" ++ ++gdb_test "next" \ ++ ".*next_cases.function2.*" \ ++ "next after a rethrow" ++ ++gdb_test "step" \ ++ ".*function1().*" \ ++ "step into function2 2" ++ ++gdb_test "finish" \ ++ ".*catch (...).*" \ ++ "finish 1" ++ ++gdb_test "next" \ ++ ".*next_cases.finish ().*" \ ++ "next past catch 4" ++ ++gdb_test "step" \ ++ ".*function1 ().*" \ ++ "step into finish method" ++ ++gdb_test "finish" \ ++ ".*catch (...).*" \ ++ "finish 2" ++ ++gdb_test "next" \ ++ ".*next_cases.finish ().*" \ ++ "next past catch 5" ++ ++gdb_test "step" \ ++ ".*function1 ().*" \ ++ "step into finish, for until" ++ ++gdb_test "until" \ ++ ".*function1 ().*" \ ++ "until with no argument 1" ++ ++set line [gdb_get_line_number "marker for until" $testfile.cc] ++ ++gdb_test "until $line" \ ++ ".*function1 ().*" \ ++ "next past catch 6" ++ ++gdb_test "until" \ ++ ".*catch (...).*" \ ++ "until with no argument 2" ++ ++set line [gdb_get_line_number "until here" $testfile.cc] ++ ++gdb_test "next" \ ++ ".*next_cases.until ().*" \ ++ "next past catch 6" ++ ++gdb_test "step" \ ++ ".*function1 ().*" \ ++ "step into until" ++ ++gdb_test "until $line" \ ++ ".*catch (...).*" \ ++ "until-over-throw" ++ ++gdb_test "next" \ ++ ".*next_cases.until ().*" \ ++ "next past catch 7" ++ ++gdb_test "step" \ ++ ".*function1 ().*" \ ++ "step into until, for advance" ++ ++gdb_test "advance $line" \ ++ ".*catch (...).*" \ ++ "advance-over-throw" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S +@@ -0,0 +1,246 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2010 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++/* Debug information */ ++ ++/* We will `break *main' at the very first instruction. */ ++#define main_length 1 ++ ++ .section .data ++vardata: ++ /* See DW_OP_lit3 + 1 (0-based). */ ++ .string "seennotseen" ++ ++ .section .debug_info ++.Lcu1_begin: ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF version number */ ++ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 4 /* Pointer Size (in bytes) */ ++ ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .4byte .Lproducer /* DW_AT_producer */ ++ /* Use C++ to exploit a bug in parsing DW_AT_name "". */ ++ .byte 4 /* DW_AT_language (C++) - */ ++ .4byte main /* DW_AT_low_pc */ ++ .byte main_length /* DW_AT_high_pc */ ++ ++.Larray_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ ++ ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++.Larrayb_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ ++ ++ /* DW_AT_upper_bound is referencing register. */ ++.Larrayreg_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 8 /* Abbrev: DW_TAG_subrange_type with block */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .byte 2f - 1f /* DW_AT_upper_bound */ ++1: .byte 0x50 /* DW_OP_reg0 */ ++2: ++ .byte 0 /* End of children of die */ ++ ++.Luint_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Luint_str /* DW_AT_name */ ++ .byte 4 /* DW_AT_byte_size */ ++ .byte 7 /* DW_AT_encoding */ ++ ++.Lchar_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Lchar_str /* DW_AT_name */ ++ .byte 1 /* DW_AT_byte_size */ ++ .byte 6 /* DW_AT_encoding */ ++ ++.Llen_var: ++ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */ ++ ++ /* optimized-out variable for b_string. */ ++.Llenb_var: ++ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "a_string" /* DW_AT_name */ ++ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "b_string" /* DW_AT_name */ ++ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ /* DW_AT_upper_bound is referencing register. */ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "reg_string" /* DW_AT_name */ ++ .4byte .Larrayreg_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ .byte 0 /* End of children of CU */ ++.Lcu1_end: ++ ++ .section .debug_loc ++.Lloclist: ++.Llen_loclist: ++ .4byte 0 # Location list begin address ++ .4byte main_length # Location list end address ++ .value 2f-1f # Location expression size ++1: .byte 0x33 # DW_OP_lit3 ++ .byte 0x9f # DW_OP_stack_value ++2: ++ .quad 0x0 # Location list terminator begin (*.LLST2) ++ .quad 0x0 # Location list terminator end (*.LLST2) ++ ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 0x1 /* has_children */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x1 /* TAG: DW_TAG_array_type */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x21 /* DW_TAG_subrange_type */ ++ .byte 0x0 /* no children */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x22 /* DW_AT_lower_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x2f /* DW_AT_upper_bound */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 4 /* Abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3e /* DW_AT_encoding */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 5 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x02 /* DW_AT_location */ ++ .uleb128 0x06 /* DW_FORM_data4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 6 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 7 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 8 /* Abbrev code */ ++ .uleb128 0x21 /* DW_TAG_subrange_type with block */ ++ .byte 0x0 /* no children */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x22 /* DW_AT_lower_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x2f /* DW_AT_upper_bound */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ ++/* String table */ ++ .section .debug_str ++.Lproducer: ++ .string "GNU C 3.3.3" ++.Lchar_str: ++ .string "char" ++.Luint_str: ++ .string "unsigned int" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp +@@ -0,0 +1,66 @@ ++# Copyright 2010 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Test printing variable with dynamic bounds which reference a different ++# (artificial in the GCC case) variable containing loclist as its location. ++# This testcase uses value (not address) of the referenced variable: ++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762 ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile dw2-bound-loclist ++if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } { ++ return -1 ++} ++ ++# Verify it behaves at least as an unbound array without inferior. ++ ++# FIXME: FSF GDB crashes due to !has_stack_frames (). ++# But in practice that should not happen. ++# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762 ++#set test "p a_string" ++#gdb_test_multiple $test $test { ++# -re " = 0x\[0-9a-f\]+ \"seennotseen\"\r\n$gdb_prompt $" { ++# pass $test ++# } ++# -re "No registers\\.\r\n$gdb_prompt $" { ++# kfail "vlaregression" $test ++# } ++#} ++# ++#gdb_test "ptype a_string" {type = char \[variable length\]} ++ ++# Not runto_main as dw2-bound-loclist.S handles only the first byte of main. ++if ![runto "*main"] { ++ return -1 ++} ++ ++gdb_test "p a_string" { = "seen"} ++gdb_test "ptype a_string" {type = char \[4\]} ++ ++gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"} ++gdb_test "ptype b_string" {type = char \[\]} ++ ++# The register contains unpredictable value - the array size. ++gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]} +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c +@@ -0,0 +1,42 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2004 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ++ USA. */ ++ ++ ++/* The function `func1' traced into must have debug info on offset > 0; ++ (DW_UNSND (attr)). This is the reason of `func0' existence. */ ++ ++void ++func0(int a, int b) ++{ ++} ++ ++/* `func1' being traced into must have some arguments to dump. */ ++ ++void ++func1(int a, int b) ++{ ++ func0 (a,b); ++} ++ ++int ++main(void) ++{ ++ func1 (1, 2); ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp +@@ -0,0 +1,79 @@ ++# Copyright 2006 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# Minimal DWARF-2 unit test ++ ++# This test can only be run on targets which support DWARF-2. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "dw2-stripped" ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}.x] ++ ++remote_exec build "rm -f ${binfile}" ++ ++# get the value of gcc_compiled ++if [get_compiler_info ${binfile}] { ++ return -1 ++} ++ ++# This test can only be run on gcc as we use additional_flags=FIXME ++if {$gcc_compiled == 0} { ++ return 0 ++} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } { ++ return -1 ++} ++ ++remote_exec build "objcopy -R .debug_loc ${binfile}" ++set strip_output [remote_exec build "objdump -h ${binfile}"] ++ ++set test "stripping test file preservation" ++if [ regexp ".debug_info " $strip_output] { ++ pass "$test (.debug_info preserved)" ++} else { ++ fail "$test (.debug_info got also stripped)" ++} ++ ++set test "stripping test file functionality" ++if [ regexp ".debug_loc " $strip_output] { ++ fail "$test (.debug_loc still present)" ++} else { ++ pass "$test (.debug_loc stripped)" ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# For C programs, "start" should stop in main(). ++ ++gdb_test "start" \ ++ ".*main \\(\\) at .*" \ ++ "start" ++gdb_test "step" \ ++ "func.* \\(.*\\) at .*" \ ++ "step" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S +@@ -0,0 +1,83 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++/* Debug information */ ++ ++ .section .debug_info ++.Lcu1_begin: ++ /* CU header */ ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF Version */ ++ .4byte .Labbrev1_begin /* Offset into abbrev section */ ++ .byte 4 /* Pointer size */ ++ ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */ ++ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */ ++ .byte 1 /* DW_AT_language (C) */ ++ ++.Ltype_uchar: ++ .uleb128 2 /* Abbrev: DW_TAG_structure_type */ ++ .ascii "some_struct\0" /* DW_AT_name */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_member */ ++ .ascii "field\0" /* DW_AT_name */ ++ .byte 0 /* DW_AT_data_member_location */ ++ ++ .byte 0 /* End of children of some_struct */ ++ ++ .byte 0 /* End of children of CU */ ++ ++.Lcu1_end: ++ ++/* Abbrev table */ ++ .section .debug_abbrev ++.Labbrev1_begin: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x13 /* DW_TAG_structure_type */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x0d /* DW_TAG_member */ ++ .byte 0 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x38 /* DW_AT_data_member_location */ ++ .uleb128 0x0b /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp +@@ -0,0 +1,37 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "dw2-struct-member-data-location" ++set srcfile ${testfile}.S ++set binfile ${testfile}.x ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "[standard_output_file ${binfile}]" object {nodebug}] != "" } { ++ return -1 ++} ++ ++clean_restart $binfile ++ ++gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S +@@ -0,0 +1,121 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2012 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++/* Debug information */ ++ ++ .section .data ++vardata: ++ .rept 129 ++ .ascii "x" ++ .endr ++ .ascii "UNSEEN\0" ++ ++ .section .debug_info ++.Lcu1_begin: ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF version number */ ++ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 4 /* Pointer Size (in bytes) */ ++ ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ ++ .byte 2 /* DW_AT_language (C) - */ ++ ++.Larray_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .byte 128 /* DW_AT_upper_bound */ ++ ++ .byte 0 /* End of children of die */ ++ ++.Lchar_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .ascii "char\0" /* DW_AT_name */ ++ .byte 1 /* DW_AT_byte_size */ ++ .byte 6 /* DW_AT_encoding */ ++ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .ascii "notype_string\0" /* DW_AT_name */ ++ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ .byte 0 /* End of children of CU */ ++.Lcu1_end: ++ ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 0x1 /* has_children */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x1 /* TAG: DW_TAG_array_type */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 4 /* Abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3e /* DW_AT_encoding */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 6 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 8 /* Abbrev code */ ++ .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */ ++ .byte 0x0 /* no children */ ++ .uleb128 0x22 /* DW_AT_lower_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x2f /* DW_AT_upper_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp +@@ -0,0 +1,39 @@ ++# Copyright 2012 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++load_lib dwarf.exp ++ ++# https://bugzilla.redhat.com/show_bug.cgi?id=806920 ++# read_subrange_type reinitialization ++# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without ++# specified DW_AT_type, present only in XLF produced code. ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++if {![dwarf2_support]} { ++ return 0 ++} ++ ++set testfile dw2-subrange-no-type ++set srcfile ${testfile}.S ++set executable ${testfile}.x ++set binfile [standard_output_file ${executable}] ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { ++ return -1 ++} ++ ++clean_restart $executable ++ ++gdb_test "ptype notype_string" {type = char \[129\]} ++gdb_test "p notype_string" " = 'x' " +diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp +@@ -0,0 +1,42 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# This file was written by Jan Kratochvil . ++ ++# This file is part of the gdb testsuite. Array element stride must not be ++# specified in the number of elements but in a number of bytes instead. ++# Original problem: ++# (gdb) p c40pt(1) ++# $1 = '0-hello', ' ' ++# (gdb) p c40pt(2) ++# warning: Fortran array stride not divisible by the element size ++ ++set testfile dwarf-stride ++set srcfile ${testfile}.f90 ++ ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { ++ return -1 ++} ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "break-here"] ++gdb_continue_to_breakpoint "break-here" ".*break-here.*" ++gdb_test "p c40pt(1)" " = '0-hello.*" ++gdb_test "p c40pt(2)" " = '1-hello.*" +diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 +@@ -0,0 +1,40 @@ ++! Copyright 2009 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 2 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program; if not, write to the Free Software ++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++! ++! File written by Alan Matsuoka. ++ ++program repro ++ ++ type small_stride ++ character*40 long_string ++ integer small_pad ++ end type small_stride ++ ++ type(small_stride), dimension (20), target :: unpleasant ++ character*40, pointer, dimension(:):: c40pt ++ ++ integer i ++ ++ do i = 0,19 ++ unpleasant(i+1)%small_pad = i+1 ++ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello' ++ end do ++ ++ c40pt => unpleasant%long_string ++ ++ print *, c40pt ! break-here ++ ++end program repro +diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dynamic.exp +@@ -0,0 +1,154 @@ ++# Copyright 2007 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# This file was written by Jan Kratochvil . ++ ++# This file is part of the gdb testsuite. It contains tests for dynamically ++# allocated Fortran arrays. ++# It depends on the GCC dynamic Fortran arrays DWARF support: ++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244 ++ ++set testfile "dynamic" ++set srcfile ${testfile}.f90 ++set binfile [standard_output_file ${testfile}] ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "varx-init"] ++gdb_continue_to_breakpoint "varx-init" ++ ++# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5 ++# Do not: gdb_test "p varx" "\\$\[0-9\]* = " "p varx unallocated" ++# Do not: gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx unallocated" ++# Do not: gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) unallocated" ++# Do not: gdb_test "p varx(1,5,17)=1" {no such vector element \(vector not allocated\)} "p varx(1,5,17)=1 unallocated" ++# Do not: gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) unallocated" ++ ++gdb_breakpoint [gdb_get_line_number "varx-allocated"] ++gdb_continue_to_breakpoint "varx-allocated" ++# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...) ++gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated" ++# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. ++gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated" ++ ++gdb_breakpoint [gdb_get_line_number "varx-filled"] ++gdb_continue_to_breakpoint "varx-filled" ++gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6" ++gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7" ++gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8" ++gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9" ++# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5 ++# Do not: gdb_test "p varv" "\\$\[0-9\]* = " "p varv unassociated" ++# Do not: gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv unassociated" ++ ++set test "output varx" ++gdb_test_multiple $test $test { ++ -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++gdb_breakpoint [gdb_get_line_number "varv-associated"] ++gdb_continue_to_breakpoint "varv-associated" ++gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated" ++gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated" ++# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. ++gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated" ++gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated" ++# Intel Fortran Compiler 10.1.008 uses the pointer type. ++gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated" ++ ++gdb_breakpoint [gdb_get_line_number "varv-filled"] ++gdb_continue_to_breakpoint "varv-filled" ++gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled" ++gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled" ++ ++gdb_breakpoint [gdb_get_line_number "varv-deassociated"] ++gdb_continue_to_breakpoint "varv-deassociated" ++# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. ++gdb_test "p varv" "\\$\[0-9\]* = (|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated" ++gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv deassociated" ++gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated" ++gdb_test "p varv(1,5,17)" {no such vector element \(vector not associated\)} ++gdb_test "ptype varv(1,5,17)" {no such vector element \(vector not associated\)} ++ ++gdb_breakpoint [gdb_get_line_number "varx-deallocated"] ++gdb_continue_to_breakpoint "varx-deallocated" ++gdb_test "p varx" "\\$\[0-9\]* = " "p varx deallocated" ++gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx deallocated" ++gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated" ++gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) deallocated" ++gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) deallocated" ++ ++gdb_breakpoint [gdb_get_line_number "vary-passed"] ++gdb_continue_to_breakpoint "vary-passed" ++# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...) ++gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)" ++ ++gdb_breakpoint [gdb_get_line_number "vary-filled"] ++gdb_continue_to_breakpoint "vary-filled" ++gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)" ++gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8" ++gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9" ++gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10" ++# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...) ++gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)" ++ ++gdb_breakpoint [gdb_get_line_number "varw-almostfilled"] ++gdb_continue_to_breakpoint "varw-almostfilled" ++gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)" ++gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1" ++# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...) ++gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled" ++# "up" works with GCC but other Fortran compilers may copy the values into the ++# outer function only on the exit of the inner function. ++# We need both variants as depending on the arch we optionally may still be ++# executing the caller line or not after `finish'. ++gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))" ++gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3" ++gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6" ++gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5" ++gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1" ++ ++gdb_breakpoint [gdb_get_line_number "varz-almostfilled"] ++gdb_continue_to_breakpoint "varz-almostfilled" ++# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not. ++gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" ++# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7) ++# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7. ++gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?" ++gdb_test "p varz" "\\$\[0-9\]* = \\(\\)" ++gdb_test "p vart" "\\$\[0-9\]* = \\(\\)" ++gdb_test "p varz(3)" "\\$\[0-9\]* = 4" ++# maps to foo::vary(1,1) ++gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8" ++# maps to foo::vary(2,2) ++gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9" ++# maps to foo::vary(1,3) ++gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10" +diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90 +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dynamic.f90 +@@ -0,0 +1,98 @@ ++! Copyright 2007 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 2 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program; if not, write to the Free Software ++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++subroutine baz ++ real, target, allocatable :: varx (:, :, :) ++ real, pointer :: varv (:, :, :) ++ real, target :: varu (1, 2, 3) ++ logical :: l ++ allocate (varx (1:6, 5:15, 17:28)) ! varx-init ++ l = allocated (varx) ++ varx(:, :, :) = 6 ! varx-allocated ++ varx(1, 5, 17) = 7 ++ varx(2, 6, 18) = 8 ++ varx(6, 15, 28) = 9 ++ varv => varx ! varx-filled ++ l = associated (varv) ++ varv(3, 7, 19) = 10 ! varv-associated ++ varv => null () ! varv-filled ++ l = associated (varv) ++ deallocate (varx) ! varv-deassociated ++ l = allocated (varx) ++ varu(:, :, :) = 10 ! varx-deallocated ++ allocate (varv (1:6, 5:15, 17:28)) ++ l = associated (varv) ++ varv(:, :, :) = 6 ++ varv(1, 5, 17) = 7 ++ varv(2, 6, 18) = 8 ++ varv(6, 15, 28) = 9 ++ deallocate (varv) ++ l = associated (varv) ++ varv => varu ++ varv(1, 1, 1) = 6 ++ varv(1, 2, 3) = 7 ++ l = associated (varv) ++end subroutine baz ++subroutine foo (vary, varw) ++ real :: vary (:, :) ++ real :: varw (:, :, :) ++ vary(:, :) = 4 ! vary-passed ++ vary(1, 1) = 8 ++ vary(2, 2) = 9 ++ vary(1, 3) = 10 ++ varw(:, :, :) = 5 ! vary-filled ++ varw(1, 1, 1) = 6 ++ varw(2, 2, 2) = 7 ! varw-almostfilled ++end subroutine foo ++subroutine bar (varz, vart) ++ real :: varz (*) ++ real :: vart (2:11, 7:*) ++ varz(1:3) = 4 ++ varz(2) = 5 ! varz-almostfilled ++ vart(2,7) = vart(2,7) ++end subroutine bar ++program test ++ interface ++ subroutine foo (vary, varw) ++ real :: vary (:, :) ++ real :: varw (:, :, :) ++ end subroutine ++ end interface ++ interface ++ subroutine bar (varz, vart) ++ real :: varz (*) ++ real :: vart (2:11, 7:*) ++ end subroutine ++ end interface ++ real :: x (10, 10), y (5), z(8, 8, 8) ++ x(:,:) = 1 ++ y(:) = 2 ++ z(:,:,:) = 3 ++ call baz ++ call foo (x, z(2:6, 4:7, 6:8)) ++ call bar (y, x) ++ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort ++ if (x (1, 3) .ne. 10) call abort ++ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort ++ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort ++ call foo (transpose (x), z) ++ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort ++ if (x (3, 1) .ne. 10) call abort ++end +diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/string.exp +@@ -0,0 +1,59 @@ ++# Copyright 2008 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# This file was written by Jan Kratochvil . ++ ++# This file is part of the gdb testsuite. It contains tests for Fortran ++# strings with dynamic length. ++ ++set testfile "string" ++set srcfile ${testfile}.f90 ++set binfile [standard_output_file ${testfile}] ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "var-init"] ++gdb_continue_to_breakpoint "var-init" ++gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)" ++gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)" ++gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)" ++gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)" ++gdb_test "ptype *e" "Attempt to take contents of a non-pointer value." ++gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)" ++gdb_test "p c" "\\$\[0-9\]* = 'c'" ++gdb_test "p d" "\\$\[0-9\]* = 'd '" ++gdb_test "p e" "\\$\[0-9\]* = 'g '" ++gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)" ++gdb_test "p *e" "Attempt to take contents of a non-pointer value." ++gdb_test "p *f" "Attempt to take contents of a non-pointer value." ++ ++gdb_breakpoint [gdb_get_line_number "var-finish"] ++gdb_continue_to_breakpoint "var-finish" ++gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set" ++gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set" +diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90 +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/string.f90 +@@ -0,0 +1,37 @@ ++! Copyright 2008 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 2 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program; if not, write to the Free Software ++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++subroutine foo (e, f) ++ character (len=1) :: c ++ character (len=8) :: d ++ character (len=*) :: e ++ character (len=*) :: f (1:7, 8:10) ++ c = 'c' ++ d = 'd' ++ e = 'e' ! var-init ++ f = 'f' ++ f(1,9) = 'f2' ++ c = 'c' ! var-finish ++end subroutine foo ++ character (len=4) :: g, h (1:7, 8:10) ++ g = 'g' ++ h = 'h' ++ call foo (g, h) ++end +diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/subrange.exp +@@ -0,0 +1,72 @@ ++# Copyright 2011 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if { [skip_fortran_tests] } { return -1 } ++ ++set testfile "subrange" ++set srcfile ${testfile}.f90 ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { ++ return -1 ++} ++ ++if ![runto MAIN__] { ++ perror "Couldn't run to MAIN__" ++ continue ++} ++ ++# Depending on the compiler version being used, the name of the 4-byte integer ++# and real types can be printed differently. For instance, gfortran-4.1 uses ++# "int4" whereas gfortran-4.3 uses "int(kind=4)". ++set int4 "(int4|integer\\(kind=4\\))" ++ ++gdb_breakpoint [gdb_get_line_number "break-static"] ++gdb_continue_to_breakpoint "break-static" ".*break-static.*" ++ ++foreach var {a alloc ptr} { ++ global pf_prefix ++ set old_prefix $pf_prefix ++ lappend pf_prefix "$var:" ++ ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "p $var (2, 2:3)" { = \(22, 32\)} ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "p $var (2:3, 3)" { = \(32, 33\)} ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "p $var (1, 2:)" { = \(21, 31\)} ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "p $var (2, :2)" { = \(12, 22\)} ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "p $var (3, 2:2)" { = \(23\)} ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)" ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "p $var (4, :)" { = \(14, 24, 34\)} ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)} ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)" ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "p $var (:)" "Wrong number of subscripts" ++ setup_kfail "*-*-*" "vlaregression/9999" ++ gdb_test "p $var (:, :, :)" "Wrong number of subscripts" ++ ++ set pf_prefix $old_prefix ++} ++ ++gdb_test_no_output {set $a=a} ++delete_breakpoints ++gdb_unload ++setup_kfail "*-*-*" "vlaregression/9999" ++gdb_test {p $a (3, 2:2)} { = \(23\)} +diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90 +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/subrange.f90 +@@ -0,0 +1,28 @@ ++! Copyright 2011 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 3 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program. If not, see . ++ ++program test ++ integer, target :: a (4, 3) ++ integer, allocatable :: alloc (:, :) ++ integer, pointer :: ptr (:, :) ++ do 1 i = 1, 4 ++ do 1 j = 1, 3 ++ a (i, j) = j * 10 + i ++1 continue ++ allocate (alloc (4, 3)) ++ alloc = a ++ ptr => a ++ write (*,*) a ! break-static ++end +diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c +@@ -0,0 +1,26 @@ ++/* Copyright 2011 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++int ++main (int argc, char **argv) ++{ ++ char vla[argc]; ++ ++ vla[0] = 0; /* break-here */ ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp +@@ -0,0 +1,57 @@ ++# Copyright 2011 Free Software Foundation, Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++load_lib mi-support.exp ++set MIFLAGS "-i=mi2" ++ ++gdb_exit ++if [mi_gdb_start] { ++ continue ++} ++ ++set testfile "mi2-var-stale-type" ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { ++ return -1 ++} ++ ++mi_delete_breakpoints ++mi_gdb_reinitialize_dir $srcdir/$subdir ++mi_gdb_load ${binfile} ++ ++mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \ ++ {\^done} \ ++ "maintenance set internal-error quit yes" ++ ++mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \ ++ {\^done} \ ++ "maintenance set internal-error corefile yes" ++ ++set line [gdb_get_line_number "break-here"] ++set func "main" ++ ++mi_gdb_test "-break-insert -t $srcfile:$line" \ ++ "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",fullname=\".*\",line=\"$line\",\[^\r\n\]*,original-location=\".*\"\}" \ ++ "breakpoint at $func" ++ ++if { [mi_run_cmd] < 0 } { ++ return -1 ++} ++mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla" ++ ++mi_create_varobj "vla" "vla" "create local variable vla" ++ ++mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *" +diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/array-from-register-func.c +@@ -0,0 +1,22 @@ ++/* This file is part of GDB, the GNU debugger. ++ ++ Copyright 2009 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++int ++func (int *arr) ++{ ++ return arr[0]; ++} +diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/array-from-register.c +@@ -0,0 +1,28 @@ ++/* This file is part of GDB, the GNU debugger. ++ ++ Copyright 2009 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++extern int func (int *arr); ++ ++int ++main (void) ++{ ++ int arr[] = { 42 }; ++ ++ func (arr); ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/array-from-register.exp +@@ -0,0 +1,33 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# ++# This file is part of the gdb testsuite. ++ ++if { [prepare_for_testing array-from-register.exp "array-from-register" \ ++ {array-from-register.c array-from-register-func.c} \ ++ {debug optimize=-O2}] } { ++ return -1 ++} ++ ++if ![runto func] then { ++ return -1 ++} ++ ++gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+" ++ ++# Seen regression: ++# Address requested for identifier "arr" which is in register $rdi ++gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42" +diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/fortran-string.exp +@@ -0,0 +1,39 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# This file was written by Jan Kratochvil . ++ ++# Test GDB can cope with Fortran strings having their length present in a CPU ++# register. With -O0 the string length is passed on the stack. To make this ++# test meaningful the follow assertion should pass. It is not being checked ++# here as the "_s" symbol is compiler dependent: ++# (gdb) info address _s ++# Symbol "_s" is a variable in register XX. ++ ++set test fortran-string ++set srcfile ${test}.f90 ++if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f90 additional_flags=-O2}] } { ++ return -1 ++} ++ ++if ![runto $srcfile:[gdb_get_line_number "s = s"]] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_test "frame" ".*s='foo'.*" ++gdb_test "ptype s" "type = character\\*3" ++gdb_test "p s" "\\$\[0-9\]* = 'foo'" +diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90 +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/fortran-string.f90 +@@ -0,0 +1,28 @@ ++! Copyright 2009 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 2 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program; if not, write to the Free Software ++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++ subroutine f(s) ++ character*(*) s ++ s = s ++ end ++ ++ program main ++ call f ('foo') ++ end +diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.pascal/arrays.exp +@@ -0,0 +1,104 @@ ++# Copyright 2008, 2009 Free Software Foundation, Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++load_lib "pascal.exp" ++ ++set testfile "arrays" ++set srcfile ${testfile}.pas ++set binfile [standard_output_file ${testfile}$EXEEXT] ++ ++# These tests only work with fpc, using the -gw3 compile-option ++pascal_init ++if { $pascal_compiler_is_fpc != 1 } { ++ return -1 ++} ++ ++# Detect if the fpc version is below 2.3.0 ++set fpc_generates_dwarf_for_dynamic_arrays 1 ++if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} { ++ set fpc_generates_dwarf_for_dynamic_arrays 0 ++} ++ ++ ++if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] ++set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] ++ ++ ++if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { ++ pass "setting breakpoint 1" ++} ++if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { ++ pass "setting breakpoint 2" ++} ++ ++# Verify that "start" lands inside the right procedure. ++if { [gdb_start_cmd] < 0 } { ++ untested start ++ return -1 ++} ++ ++gdb_test "" ".* at .*${srcfile}.*" "start" ++ ++gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" ++ ++gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type" ++gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer" ++ ++gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint" ++ ++gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char" ++gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type" ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char" ++ +diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.pascal/arrays.pas +@@ -0,0 +1,82 @@ ++{ ++ Copyright 2008, 2009 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++} ++ ++program arrays; ++ ++{$mode objfpc}{$h+} ++ ++uses sysutils; ++ ++type TStatArrInt= array[0..11] of integer; ++ TDynArrInt= array of integer; ++ TStatArrStr= array[0..12] of string; ++ TDynArrStr= array of string; ++ TDynArrChar = array of char; ++ TStatArrChar = array [0..11] of char; ++ ++ TStat2dArrInt = array[0..11,0..4] of integer; ++ ++var StatArrInt: TStatArrInt; ++ StatArrInt_: Array[0..11] of integer; ++ DynArrInt: TDynArrInt; ++ DynArrInt_: Array of integer; ++ StatArrStr: TStatArrStr; ++ DynArrStr: TDynArrStr; ++ StatArrChar: TStatArrChar; ++ DynArrChar: TDynArrChar; ++ ++ Stat2dArrInt: TStat2dArrInt; ++ ++ s: string; ++ ++ i,j : integer; ++ ++begin ++ for i := 0 to 11 do ++ begin ++ StatArrInt[i]:= i+50; ++ StatArrInt_[i]:= i+50; ++ StatArrChar[i]:= chr(ord('a')+i); ++ for j := 0 to 4 do ++ Stat2dArrInt[i,j]:=i+j; ++ end; ++ writeln(StatArrInt_[0]); ++ writeln(StatArrInt[0]); { set breakpoint 1 here } ++ writeln(StatArrChar[0]); ++ writeln(Stat2dArrInt[0,0]); ++ ++ setlength(DynArrInt,13); ++ setlength(DynArrInt_,13); ++ setlength(DynArrStr,13); ++ setlength(DynArrChar,13); ++ for i := 0 to 12 do ++ begin ++ DynArrInt[i]:= i+50; ++ DynArrInt_[i]:= i+50; ++ DynArrChar[i]:= chr(ord('a')+i); ++ StatArrStr[i]:='str'+inttostr(i); ++ DynArrStr[i]:='dstr'+inttostr(i); ++ end; ++ writeln(DynArrInt_[1]); ++ writeln(DynArrInt[1]); ++ writeln(DynArrStr[1]); ++ writeln(StatArrStr[1]); ++ writeln(DynArrChar[1]); ++ ++ s := 'test'#0'string'; ++ writeln(s); { set breakpoint 2 here } ++end. +diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp +--- a/gdb/testsuite/lib/gdb.exp ++++ b/gdb/testsuite/lib/gdb.exp +@@ -170,6 +170,11 @@ proc gdb_unload {} { + send_gdb "y\n" + exp_continue + } ++ -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\ ++ { send_gdb "y\n" ++ verbose "\t\tUnloading symbols for program being debugged" ++ exp_continue ++ } + -re "Discard symbol table from .*y or n.*$" { + send_gdb "y\n" + exp_continue +diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp +--- a/gdb/testsuite/lib/pascal.exp ++++ b/gdb/testsuite/lib/pascal.exp +@@ -37,6 +37,9 @@ proc pascal_init {} { + global pascal_compiler_is_fpc + global gpc_compiler + global fpc_compiler ++ global fpcversion_major ++ global fpcversion_minor ++ global fpcversion_release + global env + + if { $pascal_init_done == 1 } { +@@ -64,6 +67,20 @@ proc pascal_init {} { + set pascal_compiler_is_fpc 1 + verbose -log "Free Pascal compiler found" + } ++ ++ # Detect the fpc-version ++ if { $pascal_compiler_is_fpc == 1 } { ++ set fpcversion_major 1 ++ set fpcversion_minor 0 ++ set fpcversion_release 0 ++ set fpcversion [ remote_exec host $fpc_compiler "-iV" ] ++ if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] { ++ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major ++ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor ++ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release ++ } ++ verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release" ++ } + } + set pascal_init_done 1 + } diff --git a/SOURCES/gdb-archer.patch b/SOURCES/gdb-archer.patch new file mode 100644 index 0000000..dcb989c --- /dev/null +++ b/SOURCES/gdb-archer.patch @@ -0,0 +1,600 @@ +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.patch + +;; Python patches of: http://sourceware.org/gdb/wiki/ProjectArcher +;;=push + +http://sourceware.org/gdb/wiki/ProjectArcher +http://sourceware.org/gdb/wiki/ArcherBranchManagement + +GIT snapshot: +commit 718a1618b2f691a7f407213bb50f100ac59f91c3 + +tromey/python + +diff --git a/gdb/Makefile.in b/gdb/Makefile.in +--- a/gdb/Makefile.in ++++ b/gdb/Makefile.in +@@ -2112,6 +2112,12 @@ stamp-h: $(srcdir)/config.in config.status + CONFIG_LINKS= \ + $(SHELL) config.status + ++.gdbinit: $(srcdir)/gdbinit.in config.status ++ CONFIG_FILES=".gdbinit:gdbinit.in" \ ++ CONFIG_COMMANDS= \ ++ CONFIG_HEADERS= \ ++ $(SHELL) config.status ++ + config.status: $(srcdir)/configure configure.nat configure.tgt configure.host ../bfd/development.sh + $(SHELL) config.status --recheck + +diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in +--- a/gdb/data-directory/Makefile.in ++++ b/gdb/data-directory/Makefile.in +@@ -80,6 +80,7 @@ PYTHON_FILE_LIST = \ + gdb/unwinder.py \ + gdb/xmethod.py \ + gdb/command/__init__.py \ ++ gdb/command/ignore_errors.py \ + gdb/command/explore.py \ + gdb/command/backtrace.py \ + gdb/command/frame_filters.py \ +@@ -92,6 +93,8 @@ PYTHON_FILE_LIST = \ + gdb/function/as_string.py \ + gdb/function/caller_is.py \ + gdb/function/strfns.py \ ++ gdb/function/caller_is.py \ ++ gdb/function/in_scope.py \ + gdb/printer/__init__.py \ + gdb/printer/bound_registers.py + +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -1245,6 +1245,16 @@ for remote debugging. + Run using @var{device} for your program's standard input and output. + @c FIXME: kingdon thinks there is more to -tty. Investigate. + ++@item -P ++@cindex @code{-P} ++@itemx --python ++@cindex @code{--python} ++Change interpretation of command line so that the argument immediately ++following this switch is taken to be the name of a Python script file. ++This option stops option processing; subsequent options are passed to ++Python as @code{sys.argv}. This option is only available if Python ++scripting support was enabled when @value{GDBN} was configured. ++ + @c resolve the situation of these eventually + @item -tui + @cindex @code{--tui} +diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi +--- a/gdb/doc/python.texi ++++ b/gdb/doc/python.texi +@@ -88,8 +88,6 @@ containing @code{end}. For example: + + @smallexample + (@value{GDBP}) python +-Type python script +-End with a line saying just "end". + >print 23 + >end + 23 +diff --git a/gdb/gdb-gdb.gdb.in b/gdb/gdb-gdb.gdb.in +--- a/gdb/gdb-gdb.gdb.in ++++ b/gdb/gdb-gdb.gdb.in +@@ -1,5 +1,15 @@ + echo Setting up the environment for debugging gdb.\n + ++# Set up the Python library and "require" command. ++python ++from os.path import abspath ++gdb.datadir = abspath ('@srcdir@/python/lib') ++gdb.pythonlibdir = gdb.datadir ++gdb.__path__ = [gdb.datadir + '/gdb'] ++sys.path.insert(0, gdb.datadir) ++end ++source @srcdir@/python/lib/gdb/__init__.py ++ + if !$gdb_init_done + set variable $gdb_init_done = 1 + +diff --git a/gdb/main.c b/gdb/main.c +--- a/gdb/main.c ++++ b/gdb/main.c +@@ -33,6 +33,7 @@ + + #include "interps.h" + #include "main.h" ++#include "python/python.h" + #include "source.h" + #include "cli/cli-cmds.h" + #include "objfiles.h" +@@ -479,7 +480,7 @@ exec_or_core_file_attach (const char *filename, int from_tty) + } + + static void +-captured_main_1 (struct captured_main_args *context) ++captured_main_1 (struct captured_main_args *context, int &python_script) + { + int argc = context->argc; + char **argv = context->argv; +@@ -695,10 +696,14 @@ captured_main_1 (struct captured_main_args *context) + {"args", no_argument, &set_args, 1}, + {"l", required_argument, 0, 'l'}, + {"return-child-result", no_argument, &return_child_result, 1}, ++#if HAVE_PYTHON ++ {"python", no_argument, 0, 'P'}, ++ {"P", no_argument, 0, 'P'}, ++#endif + {0, no_argument, 0, 0} + }; + +- while (1) ++ while (!python_script) + { + int option_index; + +@@ -716,6 +721,9 @@ captured_main_1 (struct captured_main_args *context) + case 0: + /* Long option that just sets a flag. */ + break; ++ case 'P': ++ python_script = 1; ++ break; + case OPT_SE: + symarg = optarg; + execarg = optarg; +@@ -890,7 +898,31 @@ captured_main_1 (struct captured_main_args *context) + + /* Now that gdb_init has created the initial inferior, we're in + position to set args for that inferior. */ +- if (set_args) ++ if (python_script) ++ { ++ /* The first argument is a python script to evaluate, and ++ subsequent arguments are passed to the script for ++ processing there. */ ++ if (optind >= argc) ++ { ++ fprintf_unfiltered (gdb_stderr, ++ _("%s: Python script file name required\n"), ++ argv[0]); ++ exit (1); ++ } ++ ++ /* FIXME: should handle inferior I/O intelligently here. ++ E.g., should be possible to run gdb in pipeline and have ++ Python (and gdb) output go to stderr or file; and if a ++ prompt is needed, open the tty. */ ++ quiet = 1; ++ /* FIXME: should read .gdbinit if, and only if, a prompt is ++ requested by the script. Though... maybe this is not ++ ideal? */ ++ /* FIXME: likewise, reading in history. */ ++ inhibit_gdbinit = 1; ++ } ++ else if (set_args) + { + /* The remaining options are the command-line options for the + inferior. The first one is the sym/exec file, and the rest +@@ -1180,7 +1212,8 @@ captured_main_1 (struct captured_main_args *context) + + /* Read in the old history after all the command files have been + read. */ +- init_history (); ++ if (!python_script) ++ init_history (); + + if (batch_flag) + { +@@ -1193,24 +1226,37 @@ static void + captured_main (void *data) + { + struct captured_main_args *context = (struct captured_main_args *) data; ++ int python_script = 0; + +- captured_main_1 (context); ++ captured_main_1 (context, python_script); + +- /* NOTE: cagney/1999-11-07: There is probably no reason for not +- moving this loop and the code found in captured_command_loop() +- into the command_loop() proper. The main thing holding back that +- change - SET_TOP_LEVEL() - has been eliminated. */ +- while (1) ++#if HAVE_PYTHON ++ if (python_script) + { +- TRY +- { +- captured_command_loop (); +- } +- CATCH (ex, RETURN_MASK_ALL) ++ extern int pagination_enabled; ++ pagination_enabled = 0; ++ run_python_script (context->argc - optind, &context->argv[optind]); ++ return; ++ } ++ else ++#endif ++ { ++ /* NOTE: cagney/1999-11-07: There is probably no reason for not ++ moving this loop and the code found in captured_command_loop() ++ into the command_loop() proper. The main thing holding back that ++ change - SET_TOP_LEVEL() - has been eliminated. */ ++ while (1) + { +- exception_print (gdb_stderr, ex); ++ TRY ++ { ++ captured_command_loop (); ++ } ++ CATCH (ex, RETURN_MASK_ALL) ++ { ++ exception_print (gdb_stderr, ex); ++ } ++ END_CATCH + } +- END_CATCH + } + /* No exit -- exit is through quit_command. */ + } +@@ -1253,6 +1299,12 @@ print_gdb_help (struct ui_file *stream) + fputs_unfiltered (_("\ + This is the GNU debugger. Usage:\n\n\ + gdb [options] [executable-file [core-file or process-id]]\n\ ++ gdb [options] --args executable-file [inferior-arguments ...]\n"), stream); ++#if HAVE_PYTHON ++ fputs_unfiltered (_("\ ++ gdb [options] [--python|-P] script-file [script-arguments ...]\n"), stream); ++#endif ++ fputs_unfiltered (_("\n\ + gdb [options] --args executable-file [inferior-arguments ...]\n\n\ + "), stream); + fputs_unfiltered (_("\ +@@ -1298,6 +1350,13 @@ Output and user interface control:\n\n\ + #endif + fputs_unfiltered (_("\ + --dbx DBX compatibility mode.\n\ ++"), stream); ++#if HAVE_PYTHON ++ fputs_unfiltered (_("\ ++ --python, -P Following argument is Python script file; remaining\n\ ++ arguments are passed to script.\n"), stream); ++#endif ++ fputs_unfiltered (_("\ + -q, --quiet, --silent\n\ + Do not print version number on startup.\n\n\ + "), stream); +diff --git a/gdb/python/lib/gdb/command/ignore_errors.py b/gdb/python/lib/gdb/command/ignore_errors.py +new file mode 100644 +--- /dev/null ++++ b/gdb/python/lib/gdb/command/ignore_errors.py +@@ -0,0 +1,37 @@ ++# Ignore errors in user commands. ++ ++# Copyright (C) 2008 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++ ++class IgnoreErrorsCommand (gdb.Command): ++ """Execute a single command, ignoring all errors. ++Only one-line commands are supported. ++This is primarily useful in scripts.""" ++ ++ def __init__ (self): ++ super (IgnoreErrorsCommand, self).__init__ ("ignore-errors", ++ gdb.COMMAND_OBSCURE, ++ # FIXME... ++ gdb.COMPLETE_COMMAND) ++ ++ def invoke (self, arg, from_tty): ++ try: ++ gdb.execute (arg, from_tty) ++ except: ++ pass ++ ++IgnoreErrorsCommand () +diff --git a/gdb/python/lib/gdb/function/in_scope.py b/gdb/python/lib/gdb/function/in_scope.py +new file mode 100644 +--- /dev/null ++++ b/gdb/python/lib/gdb/function/in_scope.py +@@ -0,0 +1,47 @@ ++# In-scope function. ++ ++# Copyright (C) 2008 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++ ++class InScope (gdb.Function): ++ """Return True if all the given variables or macros are in scope. ++Takes one argument for each variable name to be checked.""" ++ ++ def __init__ (self): ++ super (InScope, self).__init__ ("in_scope") ++ ++ def invoke (self, *vars): ++ if len (vars) == 0: ++ raise (TypeError, "in_scope takes at least one argument") ++ ++ # gdb.Value isn't hashable so it can't be put in a map. ++ # Convert to string first. ++ wanted = set (map (lambda x: x.string (), vars)) ++ found = set () ++ block = gdb.selected_frame ().block () ++ while block: ++ for sym in block: ++ if (sym.is_argument or sym.is_constant ++ or sym.is_function or sym.is_variable): ++ if sym.name in wanted: ++ found.add (sym.name) ++ ++ block = block.superblock ++ ++ return wanted == found ++ ++InScope () +diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h +--- a/gdb/python/python-internal.h ++++ b/gdb/python/python-internal.h +@@ -644,6 +644,9 @@ class gdbpy_enter_varobj : public gdbpy_enter + + }; + ++struct cleanup *ensure_python_env (struct gdbarch *gdbarch, ++ const struct language_defn *language); ++ + extern struct gdbarch *python_gdbarch; + extern const struct language_defn *python_language; + +diff --git a/gdb/python/python.c b/gdb/python/python.c +--- a/gdb/python/python.c ++++ b/gdb/python/python.c +@@ -95,6 +95,8 @@ const struct extension_language_defn extension_language_python = + #include "linespec.h" + #include "source.h" + #include "version.h" ++#include "inferior.h" ++#include "gdbthread.h" + #include "target.h" + #include "gdbthread.h" + #include "interps.h" +@@ -237,6 +239,29 @@ gdbpy_enter::~gdbpy_enter () + restore_active_ext_lang (m_previous_active); + } + ++static void ++restore_python_env (void *p) ++{ ++ gdbpy_enter *env = (gdbpy_enter *) p; ++ ++ delete env; ++} ++ ++/* Called before entering the Python interpreter to install the ++ current language and architecture to be used for Python values. ++ Also set the active extension language for GDB so that SIGINT's ++ are directed our way, and if necessary install the right SIGINT ++ handler. */ ++ ++struct cleanup * ++ensure_python_env (struct gdbarch *gdbarch, ++ const struct language_defn *language) ++{ ++ gdbpy_enter *env = new gdbpy_enter (gdbarch, language); ++ ++ return make_cleanup (restore_python_env, env); ++} ++ + /* Set the quit flag. */ + + static void +@@ -1367,6 +1392,92 @@ gdbpy_print_stack (void) + + /* Return the current Progspace. + There always is one. */ ++/* True if 'gdb -P' was used, false otherwise. */ ++static int running_python_script; ++ ++/* True if we are currently in a call to 'gdb.cli', false otherwise. */ ++static int in_cli; ++ ++/* Enter the command loop. */ ++ ++static PyObject * ++gdbpy_cli (PyObject *unused1, PyObject *unused2) ++{ ++ if (! running_python_script || in_cli) ++ return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively"); ++ ++ if (current_uiout->is_mi_like_p ()) ++ return PyErr_Format (PyExc_RuntimeError, _("Cannot invoke CLI from MI.")); ++ ++ in_cli = 1; ++ /* See captured_command_loop. */ ++ ++ /* Give the interpreter a chance to print a prompt. */ ++ interp_pre_command_loop (top_level_interpreter ()); ++ ++ /* Now it's time to start the event loop. */ ++ start_event_loop (); ++ ++ in_cli = 0; ++ ++ Py_RETURN_NONE; ++} ++ ++/* Set up the Python argument vector and evaluate a script. This is ++ used to implement 'gdb -P'. */ ++ ++void ++run_python_script (int argc, char **argv) ++{ ++ FILE *input; ++ ++ /* We never free this, since we plan to exit at the end. */ ++ ensure_python_env (get_current_arch (), current_language); ++ ++ running_python_script = 1; ++ ++#if PYTHON_ABI_VERSION < 3 ++ PySys_SetArgv (argc - 1, argv + 1); ++#else ++ { ++ wchar_t **wargv = (wchar_t **) alloca (sizeof (*wargv) * (argc + 1)); ++ int i; ++ ++ for (i = 1; i < argc; i++) ++ { ++ size_t len = mbstowcs (NULL, argv[i], 0); ++ /* Python-related GDB sources are built with -DNDEBUG ++ https://sourceware.org/bugzilla/show_bug.cgi?id=20445 */ ++ size_t len2 ATTRIBUTE_UNUSED; ++ ++ if (len == (size_t) -1) ++ { ++ fprintf (stderr, "Invalid multibyte argument #%d \"%s\"\n", ++ i, argv[i]); ++ exit (1); ++ } ++ wargv[i] = (wchar_t *) alloca (sizeof (**wargv) * (len + 1)); ++ len2 = mbstowcs (wargv[i], argv[i], len + 1); ++ assert (len2 == len); ++ } ++ wargv[argc] = NULL; ++ PySys_SetArgv (argc - 1, wargv + 1); ++ } ++#endif ++ ++ input = fopen (argv[0], "r"); ++ if (! input) ++ { ++ fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno)); ++ exit (1); ++ } ++ PyRun_SimpleFile (input, argv[0]); ++ fclose (input); ++ exit (0); ++} ++ ++ ++ + + static PyObject * + gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2) +@@ -2057,6 +2168,8 @@ PyMethodDef python_GdbMethods[] = + Evaluate command, a string, as a gdb CLI command. Optionally returns\n\ + a Python String containing the output of the command if to_string is\n\ + set to True." }, ++ { "cli", gdbpy_cli, METH_NOARGS, ++ "Enter the gdb CLI" }, + { "parameter", gdbpy_parameter, METH_VARARGS, + "Return a gdb parameter's value" }, + +diff --git a/gdb/python/python.h b/gdb/python/python.h +--- a/gdb/python/python.h ++++ b/gdb/python/python.h +@@ -25,4 +25,6 @@ + /* This is all that python exports to gdb. */ + extern const struct extension_language_defn extension_language_python; + ++extern void run_python_script (int argc, char **argv); ++ + #endif /* GDB_PYTHON_H */ +diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp +--- a/gdb/testsuite/gdb.python/py-frame.exp ++++ b/gdb/testsuite/gdb.python/py-frame.exp +@@ -95,6 +95,8 @@ gdb_test "python print ('result = %s' % f0.read_var ('a'))" " = 1" "test Frame.r + + gdb_test "python print ('result = %s' % (gdb.selected_frame () == f1))" " = True" "test gdb.selected_frame" + ++gdb_test "python print ('result = %s' % (f0.block ()))" "" "test Frame.block" ++ + # Can read SP register. + gdb_test "python print ('result = %s' % (gdb.selected_frame ().read_register ('sp') == gdb.parse_and_eval ('\$sp')))" \ + " = True" \ +diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp +--- a/gdb/testsuite/gdb.python/py-value.exp ++++ b/gdb/testsuite/gdb.python/py-value.exp +@@ -384,6 +384,15 @@ proc test_value_after_death {} { + "print value's type" + } + ++# Regression test for a cast failure. The bug was that if we cast a ++# value to its own type, gdb could crash. This happened because we ++# could end up double-freeing a struct value. ++proc test_cast_regression {} { ++ gdb_test "python v = gdb.Value(5)" "" "create value for cast test" ++ gdb_test "python v = v.cast(v.type)" "" "cast value for cast test" ++ gdb_test "python print(v)" "5" "print value for cast test" ++} ++ + # Regression test for invalid subscript operations. The bug was that + # the type of the value was not being checked before allowing a + # subscript operation to proceed. +@@ -512,6 +521,7 @@ if ![runto_main] then { + test_value_in_inferior + test_inferior_function_call + test_value_after_death ++test_cast_regression + + # Test either C or C++ values. + +diff --git a/gdb/varobj.c b/gdb/varobj.c +--- a/gdb/varobj.c ++++ b/gdb/varobj.c +@@ -218,6 +218,14 @@ is_root_p (const struct varobj *var) + } + + #ifdef HAVE_PYTHON ++/* Helper function to install a Python environment suitable for ++ use during operations on VAR. */ ++struct cleanup * ++varobj_ensure_python_env (const struct varobj *var) ++{ ++ return ensure_python_env (var->root->exp->gdbarch, ++ var->root->exp->language_defn); ++} + + /* See python-internal.h. */ + gdbpy_enter_varobj::gdbpy_enter_varobj (const struct varobj *var) +diff --git a/gdb/varobj.h b/gdb/varobj.h +--- a/gdb/varobj.h ++++ b/gdb/varobj.h +@@ -328,6 +328,8 @@ extern bool varobj_has_more (const struct varobj *var, int to); + + extern bool varobj_is_dynamic_p (const struct varobj *var); + ++extern struct cleanup *varobj_ensure_python_env (const struct varobj *var); ++ + extern bool varobj_default_value_is_changeable_p (const struct varobj *var); + extern bool varobj_value_is_changeable_p (const struct varobj *var); + diff --git a/SOURCES/gdb-attach-fail-reasons-5of5.patch b/SOURCES/gdb-attach-fail-reasons-5of5.patch new file mode 100644 index 0000000..c8b1267 --- /dev/null +++ b/SOURCES/gdb-attach-fail-reasons-5of5.patch @@ -0,0 +1,357 @@ +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-attach-fail-reasons-5of5.patch + +;; Print reasons for failed attach/spawn incl. SELinux deny_ptrace (BZ 786878). +;;=push+jan + +http://sourceware.org/ml/gdb-patches/2012-03/msg00171.html + +Hi, + +and here is the last bit for new SELinux 'deny_ptrace': + https://bugzilla.redhat.com/show_bug.cgi?id=786878 + +As even PTRACE_TRACEME fails in such case it needs to install hook for even +that event. + +Thanks, +Jan + +gdb/ +2012-03-06 Jan Kratochvil + + * common/linux-ptrace.c [HAVE_SELINUX_SELINUX_H]: include + selinux/selinux.h. + (linux_ptrace_attach_warnings): Call linux_ptrace_create_warnings. + (linux_ptrace_create_warnings): New. + * common/linux-ptrace.h (linux_ptrace_create_warnings): New declaration. + * config.in: Regenerate. + * configure: Regenerate. + * configure.ac: Check selinux/selinux.h and the selinux library. + * inf-ptrace.c (inf_ptrace_me): Check the ptrace result. + * linux-nat.c (linux_nat_create_inferior): New variable ex. Wrap + to_create_inferior into TRY_CATCH, call linux_ptrace_create_warnings. + +gdb/gdbserver/ + * config.in: Regenerate. + * configure: Regenerate. + * configure.ac: Check selinux/selinux.h and the selinux library. + * linux-low.c (linux_traceme): New function. + (linux_create_inferior, linux_tracefork_child): Call it instead of + direct ptrace. + +diff --git a/gdb/config.in b/gdb/config.in +--- a/gdb/config.in ++++ b/gdb/config.in +@@ -276,6 +276,9 @@ + /* Define if librpm library is being used. */ + #undef HAVE_LIBRPM + ++/* Define to 1 if you have the `selinux' library (-lselinux). */ ++#undef HAVE_LIBSELINUX ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_LIBUNWIND_IA64_H + +@@ -399,6 +402,9 @@ + /* Define to 1 if you have the `scm_new_smob' function. */ + #undef HAVE_SCM_NEW_SMOB + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SELINUX_SELINUX_H ++ + /* Define to 1 if you have the `setlocale' function. */ + #undef HAVE_SETLOCALE + +diff --git a/gdb/configure b/gdb/configure +--- a/gdb/configure ++++ b/gdb/configure +@@ -15854,6 +15854,64 @@ cat >>confdefs.h <<_ACEOF + _ACEOF + + ++for ac_header in selinux/selinux.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default" ++if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_SELINUX_SELINUX_H 1 ++_ACEOF ++ ++fi ++ ++done ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_get_boolean_active in -lselinux" >&5 ++$as_echo_n "checking for security_get_boolean_active in -lselinux... " >&6; } ++if test "${ac_cv_lib_selinux_security_get_boolean_active+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lselinux $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char security_get_boolean_active (); ++int ++main () ++{ ++return security_get_boolean_active (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_selinux_security_get_boolean_active=yes ++else ++ ac_cv_lib_selinux_security_get_boolean_active=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_security_get_boolean_active" >&5 ++$as_echo "$ac_cv_lib_selinux_security_get_boolean_active" >&6; } ++if test "x$ac_cv_lib_selinux_security_get_boolean_active" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_LIBSELINUX 1 ++_ACEOF ++ ++ LIBS="-lselinux $LIBS" ++ ++fi ++ ++ + + # Support for --with-sysroot is a copy of GDB_AC_WITH_DIR, + # except that the argument to --with-sysroot is optional. +diff --git a/gdb/configure.ac b/gdb/configure.ac +--- a/gdb/configure.ac ++++ b/gdb/configure.ac +@@ -2054,6 +2054,10 @@ case $host_os in + esac + AC_DEFINE_UNQUOTED(GDBINIT,"$gdbinit",[The .gdbinit filename.]) + ++dnl Check security_get_boolean_active availability. ++AC_CHECK_HEADERS(selinux/selinux.h) ++AC_CHECK_LIB(selinux, security_get_boolean_active) ++ + dnl Handle optional features that can be enabled. + + # Support for --with-sysroot is a copy of GDB_AC_WITH_DIR, +diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in +--- a/gdb/gdbserver/config.in ++++ b/gdb/gdbserver/config.in +@@ -126,6 +126,9 @@ + /* Define to 1 if you have the `mcheck' library (-lmcheck). */ + #undef HAVE_LIBMCHECK + ++/* Define to 1 if you have the `selinux' library (-lselinux). */ ++#undef HAVE_LIBSELINUX ++ + /* Define if the target supports branch tracing. */ + #undef HAVE_LINUX_BTRACE + +@@ -202,6 +205,9 @@ + /* Define to 1 if you have the `pwrite' function. */ + #undef HAVE_PWRITE + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SELINUX_SELINUX_H ++ + /* Define to 1 if you have the `setns' function. */ + #undef HAVE_SETNS + +diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure +--- a/gdb/gdbserver/configure ++++ b/gdb/gdbserver/configure +@@ -8535,6 +8535,64 @@ if $want_ipa ; then + fi + fi + ++for ac_header in selinux/selinux.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default" ++if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_SELINUX_SELINUX_H 1 ++_ACEOF ++ ++fi ++ ++done ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_get_boolean_active in -lselinux" >&5 ++$as_echo_n "checking for security_get_boolean_active in -lselinux... " >&6; } ++if test "${ac_cv_lib_selinux_security_get_boolean_active+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lselinux $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char security_get_boolean_active (); ++int ++main () ++{ ++return security_get_boolean_active (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_selinux_security_get_boolean_active=yes ++else ++ ac_cv_lib_selinux_security_get_boolean_active=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_security_get_boolean_active" >&5 ++$as_echo "$ac_cv_lib_selinux_security_get_boolean_active" >&6; } ++if test "x$ac_cv_lib_selinux_security_get_boolean_active" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_LIBSELINUX 1 ++_ACEOF ++ ++ LIBS="-lselinux $LIBS" ++ ++fi ++ ++ + + + +diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac +--- a/gdb/gdbserver/configure.ac ++++ b/gdb/gdbserver/configure.ac +@@ -486,6 +486,10 @@ if $want_ipa ; then + fi + fi + ++dnl Check security_get_boolean_active availability. ++AC_CHECK_HEADERS(selinux/selinux.h) ++AC_CHECK_LIB(selinux, security_get_boolean_active) ++ + AC_SUBST(GDBSERVER_DEPFILES) + AC_SUBST(GDBSERVER_LIBS) + AC_SUBST(srv_xmlbuiltin) +diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c +--- a/gdb/gdbserver/linux-low.c ++++ b/gdb/gdbserver/linux-low.c +@@ -967,7 +967,16 @@ linux_ptrace_fun () + { + if (ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0, + (PTRACE_TYPE_ARG4) 0) < 0) +- trace_start_error_with_name ("ptrace"); ++ { ++ int save_errno = errno; ++ ++ std::string msg (linux_ptrace_create_warnings ()); ++ ++ msg += _("Cannot trace created process"); ++ ++ errno = save_errno; ++ trace_start_error_with_name (msg.c_str ()); ++ } + + if (setpgid (0, 0) < 0) + trace_start_error_with_name ("setpgid"); +diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c +--- a/gdb/linux-nat.c ++++ b/gdb/linux-nat.c +@@ -1089,7 +1089,17 @@ linux_nat_target::create_inferior (const char *exec_file, + /* Make sure we report all signals during startup. */ + pass_signals (0, NULL); + +- inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty); ++ TRY ++ { ++ inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty); ++ } ++ CATCH (ex, RETURN_MASK_ERROR) ++ { ++ std::string result = linux_ptrace_create_warnings (); ++ ++ throw_error (ex.error, "%s%s", result.c_str (), ex.message); ++ } ++ END_CATCH + } + + /* Callback for linux_proc_attach_tgid_threads. Attach to PTID if not +diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c +--- a/gdb/nat/linux-ptrace.c ++++ b/gdb/nat/linux-ptrace.c +@@ -25,6 +25,10 @@ + #include + #endif + ++#ifdef HAVE_SELINUX_SELINUX_H ++# include ++#endif /* HAVE_SELINUX_SELINUX_H */ ++ + /* Stores the ptrace options supported by the running kernel. + A value of -1 means we did not check for features yet. A value + of 0 means there are no supported features. */ +@@ -50,6 +54,8 @@ linux_ptrace_attach_fail_reason (pid_t pid) + "terminated"), + (int) pid); + ++ result += linux_ptrace_create_warnings (); ++ + return result; + } + +@@ -583,6 +589,25 @@ linux_ptrace_init_warnings (void) + linux_ptrace_test_ret_to_nx (); + } + ++/* Print all possible reasons we could fail to create a traced process. */ ++ ++std::string ++linux_ptrace_create_warnings () ++{ ++ std::string result; ++ ++#ifdef HAVE_LIBSELINUX ++ /* -1 is returned for errors, 0 if it has no effect, 1 if PTRACE_ATTACH is ++ forbidden. */ ++ if (security_get_boolean_active ("deny_ptrace") == 1) ++ string_appendf (result, ++ _("the SELinux boolean 'deny_ptrace' is enabled, " ++ "you can disable this process attach protection by: " ++ "(gdb) shell sudo setsebool deny_ptrace=0\n")); ++#endif /* HAVE_LIBSELINUX */ ++ return result; ++} ++ + /* Extract extended ptrace event from wait status. */ + + int +diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h +--- a/gdb/nat/linux-ptrace.h ++++ b/gdb/nat/linux-ptrace.h +@@ -184,6 +184,7 @@ extern std::string linux_ptrace_attach_fail_reason (pid_t pid); + extern std::string linux_ptrace_attach_fail_reason_string (ptid_t ptid, int err); + + extern void linux_ptrace_init_warnings (void); ++extern std::string linux_ptrace_create_warnings (); + extern void linux_check_ptrace_features (void); + extern void linux_enable_event_reporting (pid_t pid, int attached); + extern void linux_disable_event_reporting (pid_t pid); diff --git a/SOURCES/gdb-btrobust.patch b/SOURCES/gdb-btrobust.patch new file mode 100644 index 0000000..40d406c --- /dev/null +++ b/SOURCES/gdb-btrobust.patch @@ -0,0 +1,45 @@ +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-btrobust.patch + +;; Continue backtrace even if a frame filter throws an exception (Phil Muldoon). +;;=push + +This should fix the error with glib. An error message will still be +printed, but a default backtrace will occur in this case. + +-- + +diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c +--- a/gdb/python/py-framefilter.c ++++ b/gdb/python/py-framefilter.c +@@ -1151,6 +1151,7 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, + htab_eq_pointer, + NULL)); + ++ int count_printed = 0; + while (true) + { + gdbpy_ref<> item (PyIter_Next (iterable.get ())); +@@ -1159,8 +1160,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, + { + if (PyErr_Occurred ()) + { +- throw_quit_or_print_exception (); +- return EXT_LANG_BT_ERROR; ++ gdbpy_print_stack (); ++ return count_printed > 0 ? EXT_LANG_BT_ERROR : EXT_LANG_BT_NO_FILTERS; + } + break; + } +@@ -1193,7 +1194,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, + /* Do not exit on error printing a single frame. Print the + error and continue with other frames. */ + if (success == EXT_LANG_BT_ERROR) +- throw_quit_or_print_exception (); ++ gdbpy_print_stack (); ++ count_printed++; + } + + return success; diff --git a/SOURCES/gdb-bz1219747-attach-kills.patch b/SOURCES/gdb-bz1219747-attach-kills.patch new file mode 100644 index 0000000..6ae10a2 --- /dev/null +++ b/SOURCES/gdb-bz1219747-attach-kills.patch @@ -0,0 +1,178 @@ +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-bz1219747-attach-kills.patch + +;; Never kill PID on: gdb exec PID (Jan Kratochvil, RH BZ 1219747). +;;=push+jan + +http://sourceware.org/ml/gdb-patches/2015-10/msg00301.html + +Hi, + +in some cases with deleted main executable GDB will want to kill the inferior. + +$ cp /bin/sleep /tmp/sleep;/tmp/sleep 1h&p=$! +$ rm /tmp/sleep +$ gdb /tmp/sleep $p +GNU gdb (GDB) 7.10.50.20151016-cvs +/tmp/sleep: No such file or directory. +Attaching to process 9694 +/tmp/sleep (deleted): No such file or directory. +A program is being debugged already. Kill it? (y or n) _ + +The first attachment of "/tmp/sleep" commandline argument errors at: + +267 if (scratch_chan < 0) +268 perror_with_name (filename); +1051 if (catch_command_errors_const (exec_file_attach, execarg, +1052 !batch_flag)) + +Then GDB tries to attach to the process $p: + +1082 if (catch_command_errors (attach_command, pid_or_core_arg, +1083 !batch_flag) == 0) + +This succeeds and since this moment GDB has a valid inferior. But despite that +the lines +1082 if (catch_command_errors (attach_command, pid_or_core_arg, +1083 !batch_flag) == 0) +still fail because consequently attach_command() fails to find the associated +executable file: + +267 if (scratch_chan < 0) +268 perror_with_name (filename); +1082 if (catch_command_errors (attach_command, pid_or_core_arg, +1083 !batch_flag) == 0) + +and therefore GDB executes the following: + +(gdb) bt +2179 if (have_inferiors ()) +2180 { +2181 if (!from_tty +2182 || !have_live_inferiors () +2183 || query (_("A program is being debugged already. Kill it? "))) +2184 iterate_over_inferiors (dispose_inferior, NULL); +2185 else +2186 error (_("Program not killed.")); +2187 } +1084 catch_command_errors (core_file_command, pid_or_core_arg, +1085 !batch_flag); + +No regressions on {x86_64,x86_64-m32,i686}-fedora24pre-linux-gnu. + +Thanks, +Jan + +gdb/ChangeLog +2015-10-16 Jan Kratochvil + + * main.c (captured_main): Run core_file_command for pid_or_core_arg + only if not have_inferiors (). + +gdb/testsuite/ChangeLog +2015-10-16 Jan Kratochvil + + * gdb.base/attach-kills.c: New. + * gdb.base/attach-kills.exp: New. + +diff --git a/gdb/main.c b/gdb/main.c +--- a/gdb/main.c ++++ b/gdb/main.c +@@ -1115,7 +1115,10 @@ captured_main_1 (struct captured_main_args *context) + if (isdigit (pid_or_core_arg[0])) + { + if (catch_command_errors (attach_command, pid_or_core_arg, +- !batch_flag) == 0) ++ !batch_flag) == 0 ++ /* attach_command could succeed partially and core_file_command ++ would try to kill it. */ ++ && !have_inferiors ()) + catch_command_errors (core_file_command, pid_or_core_arg, + !batch_flag); + } +diff --git a/gdb/testsuite/gdb.base/attach-kills.c b/gdb/testsuite/gdb.base/attach-kills.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/attach-kills.c +@@ -0,0 +1,25 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2015 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++ ++int ++main (void) ++{ ++ sleep (600); ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/attach-kills.exp b/gdb/testsuite/gdb.base/attach-kills.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/attach-kills.exp +@@ -0,0 +1,49 @@ ++# Copyright (C) 2015 Free Software Foundation, Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if { ![can_spawn_for_attach] } { ++ return 0 ++} ++ ++standard_testfile ++ ++if { [build_executable ${testfile}.exp $testfile] == -1 } { ++ return -1 ++} ++ ++# Start the program running and then wait for a bit, to be sure ++# that it can be attached to. ++ ++set test_spawn_id [spawn_wait_for_attach $binfile] ++set testpid [spawn_id_get_pid $test_spawn_id] ++ ++remote_exec target "cp -pf -- $binfile $binfile-copy" ++remote_exec target "rm -f -- $binfile" ++ ++set test "start gdb" ++set res [gdb_spawn_with_cmdline_opts \ ++ "-iex \"set height 0\" -iex \"set width 0\" /DoEsNoTeXySt $testpid"] ++if { $res != 0} { ++ fail "$test (spawn)" ++ kill_wait_spawned_process $test_spawn_id ++ return -1 ++} ++gdb_test_multiple "" $test { ++ -re "\r\nAttaching to .*\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++kill_wait_spawned_process $test_spawn_id diff --git a/SOURCES/gdb-bz533176-fortran-omp-step.patch b/SOURCES/gdb-bz533176-fortran-omp-step.patch new file mode 100644 index 0000000..8a23b33 --- /dev/null +++ b/SOURCES/gdb-bz533176-fortran-omp-step.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-bz533176-fortran-omp-step.patch + +;; Fix stepping with OMP parallel Fortran sections (BZ 533176). +;;=push+jan: It requires some better DWARF annotations. + +https://bugzilla.redhat.com/show_bug.cgi?id=533176#c4 + +I find it a bug in DWARF and gdb behaves correctly according to it. From the +current DWARF's point of view the is a function call which you skip by "next". + +If you hide any /usr/lib/debug such as using: +gdb -nx -ex 'set debug-file-directory /qwe' -ex 'file ./tpcommon_gfortran44' +and use "step" command instead of "next" there it will work. +(You need to hide debuginfo from libgomp as you would step into libgomp sources +to maintain the threads for execution.) + +There should be some DWARF extension for it, currently tried to detect +substring ".omp_fn." as this function is called "MAIN__.omp_fn.0" and do not +consider such sub-function as a skippable by "next". + +Another problem is that with "set scheduler-locking" being "off" (default +upstream) or "step" (default in F/RHEL) the simultaneous execution of the +threads is inconvenient. Setting it to "on" will lockup the debugging as the +threads need to get synchronized at some point. This is a more general +debugging problem of GOMP outside of the scope of this Bug. + +diff --git a/gdb/infrun.c b/gdb/infrun.c +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -6695,6 +6695,16 @@ process_event_stop_test (struct execution_control_state *ecs) + + if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL) + { ++ struct symbol *stop_fn = find_pc_function (stop_pc); ++ struct minimal_symbol *stopf = lookup_minimal_symbol_by_pc (stop_pc).minsym; ++ ++ if ((stop_fn == NULL ++ || strstr (SYMBOL_LINKAGE_NAME (stop_fn), ".omp_fn.") == NULL) ++ /* gcc-4.7.2-9.fc19.x86_64 uses a new format. */ ++ && (stopf == NULL ++ || strstr (MSYMBOL_LINKAGE_NAME (stopf), "._omp_fn.") == NULL)) ++{ /* ".omp_fn." */ ++ + /* We're doing a "next". + + Normal (forward) execution: set a breakpoint at the +@@ -6728,6 +6738,7 @@ process_event_stop_test (struct execution_control_state *ecs) + + keep_going (ecs); + return; ++} /* ".omp_fn." */ + } + + /* If we are in a function call trampoline (a stub between the +diff --git a/gdb/testsuite/gdb.fortran/omp-step.exp b/gdb/testsuite/gdb.fortran/omp-step.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/omp-step.exp +@@ -0,0 +1,31 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile "omp-step" ++set srcfile ${testfile}.f90 ++if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90 additional_flags=-fopenmp}] } { ++ return -1 ++} ++ ++if ![runto [gdb_get_line_number "start-here"]] { ++ perror "Couldn't run to start-here" ++ return 0 ++} ++ ++gdb_test "next" {!\$omp parallel} "step closer" ++gdb_test "next" {a\(omp_get_thread_num\(\) \+ 1\) = 1} "step into omp" ++ ++gdb_breakpoint [gdb_get_line_number "success"] ++gdb_continue_to_breakpoint "success" ".*success.*" +diff --git a/gdb/testsuite/gdb.fortran/omp-step.f90 b/gdb/testsuite/gdb.fortran/omp-step.f90 +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/omp-step.f90 +@@ -0,0 +1,32 @@ ++! Copyright 2009 Free Software Foundation, Inc. ++ ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 3 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program. If not, see . ++ ++ use omp_lib ++ integer nthreads, i, a(1000) ++ nthreads = omp_get_num_threads() ++ if (nthreads .gt. 1000) call abort ++ ++ do i = 1, nthreads ++ a(i) = 0 ++ end do ++ print *, "start-here" ++!$omp parallel ++ a(omp_get_thread_num() + 1) = 1 ++!$omp end parallel ++ do i = 1, nthreads ++ if (a(i) .ne. 1) call abort ++ end do ++ print *, "success" ++ end diff --git a/SOURCES/gdb-bz541866-rwatch-before-run.patch b/SOURCES/gdb-bz541866-rwatch-before-run.patch new file mode 100644 index 0000000..0ff3a93 --- /dev/null +++ b/SOURCES/gdb-bz541866-rwatch-before-run.patch @@ -0,0 +1,175 @@ +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-bz541866-rwatch-before-run.patch + +;; Fix i386+x86_64 rwatch+awatch before run, regression against 6.8 (BZ 541866). +;; Fix i386 rwatch+awatch before run (BZ 688788, on top of BZ 541866). +;;=push+jan: It should be fixed properly instead. + +diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c +--- a/gdb/breakpoint.c ++++ b/gdb/breakpoint.c +@@ -8807,7 +8807,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, + int enabled, int internal, unsigned flags, + int display_canonical) + { +- int i; ++ int i ATTRIBUTE_UNUSED; + + if (type == bp_hardware_breakpoint) + { +@@ -14356,7 +14356,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, + + if (bpt->type == bp_hardware_breakpoint) + { +- int i; ++ int i ATTRIBUTE_UNUSED; + i = hw_breakpoint_used_count (); + target_resources_ok = + target_can_use_hardware_watchpoint (bp_hardware_breakpoint, +diff --git a/gdb/config/i386/nm-linux.h b/gdb/config/i386/nm-linux.h +new file mode 100644 +--- /dev/null ++++ b/gdb/config/i386/nm-linux.h +@@ -0,0 +1,28 @@ ++/* Native support for GNU/Linux i386. ++ ++ 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 . */ ++ ++#ifndef NM_LINUX_H ++#define NM_LINUX_H ++ ++#include "config/nm-linux.h" ++ ++/* Red Hat backward compatibility with gdb-6.8. */ ++#define target_can_use_hardware_watchpoint(type, cnt, ot) 1 ++ ++#endif /* NM_LINUX64_H */ +diff --git a/gdb/config/i386/nm-linux64.h b/gdb/config/i386/nm-linux64.h +new file mode 100644 +--- /dev/null ++++ b/gdb/config/i386/nm-linux64.h +@@ -0,0 +1,28 @@ ++/* Native support for GNU/Linux amd64. ++ ++ 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 . */ ++ ++#ifndef NM_LINUX64_H ++#define NM_LINUX64_H ++ ++#include "config/nm-linux.h" ++ ++/* Red Hat backward compatibility with gdb-6.8. */ ++#define target_can_use_hardware_watchpoint(type, cnt, ot) 1 ++ ++#endif /* NM_LINUX64_H */ +diff --git a/gdb/configure.nat b/gdb/configure.nat +--- a/gdb/configure.nat ++++ b/gdb/configure.nat +@@ -238,6 +238,7 @@ case ${gdb_host} in + ;; + i386) + # Host: Intel 386 running GNU/Linux. ++ NAT_FILE="${srcdir}/config/${gdb_host_cpu}/nm-linux.h" + NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \ + i386-linux-nat.o x86-linux-nat.o linux-btrace.o \ + x86-linux.o x86-linux-dregs.o" +@@ -290,6 +291,7 @@ case ${gdb_host} in + case ${gdb_host_cpu} in + i386) + # Host: GNU/Linux x86-64 ++ NAT_FILE="${srcdir}/config/${gdb_host_cpu}/nm-linux64.h" + NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \ + amd64-nat.o amd64-linux-nat.o x86-linux-nat.o linux-btrace.o \ + x86-linux.o x86-linux-dregs.o amd64-linux-siginfo.o" +diff --git a/gdb/target.h b/gdb/target.h +--- a/gdb/target.h ++++ b/gdb/target.h +@@ -1953,9 +1953,11 @@ extern struct thread_info *target_thread_handle_to_thread_info + one. OTHERTYPE is the number of watchpoints of other types than + this one used so far. */ + ++#ifndef target_can_use_hardware_watchpoint + #define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \ + (current_top_target ()->can_use_hw_breakpoint) ( \ + TYPE, CNT, OTHERTYPE) ++#endif + + /* Returns the number of debug registers needed to watch the given + memory region, or zero if not supported. */ +diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp b/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp +@@ -0,0 +1,40 @@ ++# Copyright 2009, 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 . ++ ++# Arch not supporting hw watchpoints does not imply no_hardware_watchpoints set. ++if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] ++ && ![istarget "ia64-*-*"]) ++ || [target_info exists gdb,no_hardware_watchpoints]} then { ++ verbose "Skipping watchpoint-hw-before-run test." ++ return ++} ++ ++set test watchpoint-hw-before-run ++set srcfile watchpoint-hw-hit-once.c ++if { [prepare_for_testing ${test}.exp ${test} ${srcfile}] } { ++ return -1 ++} ++ ++gdb_test "rwatch watchee" "ardware read watchpoint 1: watchee" ++ ++# `runto_main' or `runto main' would delete the watchpoint created above. ++ ++if { [gdb_start_cmd] < 0 } { ++ untested start ++ return -1 ++} ++gdb_test "" "main .* at .*" "start" ++ ++gdb_test "continue" "Continuing.\r\n\r\nHardware read watchpoint \[0-9\]+: watchee\r\n\r\nValue = 0\r\n.*" diff --git a/SOURCES/gdb-bz568248-oom-is-error.patch b/SOURCES/gdb-bz568248-oom-is-error.patch new file mode 100644 index 0000000..f3f61da --- /dev/null +++ b/SOURCES/gdb-bz568248-oom-is-error.patch @@ -0,0 +1,71 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-bz568248-oom-is-error.patch + +;; Out of memory is just an error, not fatal (uninitialized VLS vars, BZ 568248). +;;=push+jan: Inferior objects should be read in parts, then this patch gets obsoleted. + +http://sourceware.org/ml/gdb-patches/2010-06/msg00005.html + +Hi, + +unfortunately I see this problem reproducible only with the +archer-jankratochvil-vla branch (VLA = Variable Length Arrays - char[var]). +OTOH this branch I hopefully submit in some form for FSF GDB later. + +In this case (a general problem but tested for example on Fedora 13 i686): + +int +main (int argc, char **argv) +{ + char a[argc]; + return a[0]; +} + +(gdb) start +(gdb) print a +../../gdb/utils.c:1251: internal-error: virtual memory exhausted: can't allocate 4294951689 bytes. + +It is apparently because boundary for the variable `a' is not initialized +there. Users notice it due to Eclipse-CDT trying to automatically display all +the local variables on each step. + +Apparentl no regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. +But is anone aware of the reasons to use internal_error there? +I find simple error as a perfectly reasonable there. +(history only tracks it since the initial import) + +IIRC this idea has been discussed with Tom Tromey, not sure of its origin. + +I understand it may be offtopic for FSF GDB but from some GDB crashes I am not +sure if it can happen only due to the VLA variables. + +Thanks, +Jan + +gdb/ +2010-06-01 Jan Kratochvil + Tom Tromey + + * utils.c (nomem): Change internal_error to error. + +diff --git a/gdb/utils.c b/gdb/utils.c +--- a/gdb/utils.c ++++ b/gdb/utils.c +@@ -746,13 +746,11 @@ malloc_failure (long size) + { + if (size > 0) + { +- internal_error (__FILE__, __LINE__, +- _("virtual memory exhausted: can't allocate %ld bytes."), +- size); ++ error (_("virtual memory exhausted: can't allocate %ld bytes."), size); + } + else + { +- internal_error (__FILE__, __LINE__, _("virtual memory exhausted.")); ++ error (_("virtual memory exhausted.")); + } + } + diff --git a/SOURCES/gdb-bz601887-dwarf4-rh-test.patch b/SOURCES/gdb-bz601887-dwarf4-rh-test.patch new file mode 100644 index 0000000..87b7817 --- /dev/null +++ b/SOURCES/gdb-bz601887-dwarf4-rh-test.patch @@ -0,0 +1,254 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-bz601887-dwarf4-rh-test.patch + +;; Backport DWARF-4 support (BZ 601887, Tom Tromey). +;;=fedoratest + +diff --git a/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S +@@ -0,0 +1,167 @@ ++/* 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 . */ ++ ++ .file "rh-dwarf4-x86_64.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl main ++ .type main, @function ++main: ++.LFB0: ++ .file 1 "gdb.dwarf2/rh-dwarf4-x86_64.c" ++ # gdb.dwarf2/rh-dwarf4-x86_64.c:20 ++ .loc 1 20 0 ++ .cfi_startproc ++ # basic block 2 ++ pushq %rbp ++ .cfi_def_cfa_offset 16 ++ movq %rsp, %rbp ++ .cfi_offset 6, -16 ++ .cfi_def_cfa_register 6 ++ # gdb.dwarf2/rh-dwarf4-x86_64.c:21 ++ .loc 1 21 0 ++ movl $0, %eax ++ # gdb.dwarf2/rh-dwarf4-x86_64.c:22 ++ .loc 1 22 0 ++ leave ++ .cfi_def_cfa 7, 8 ++ ret ++ .cfi_endproc ++.LFE0: ++ .size main, .-main ++.Letext0: ++ .section .debug_info ++ .long 0x4e # 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 .LASF0 # DW_AT_producer: "GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)" ++ .byte 0x1 # DW_AT_language ++ .long .LASF1 # DW_AT_name: "gdb.dwarf2/rh-dwarf4-x86_64.c" ++ .long .LASF2 # DW_AT_comp_dir ++ .quad .Ltext0 # DW_AT_low_pc ++ .quad .Letext0 # DW_AT_high_pc ++ .long .Ldebug_line0 # DW_AT_stmt_list ++ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram) ++ # DW_AT_external ++ .long .LASF3 # DW_AT_name: "main" ++ .byte 0x1 # DW_AT_decl_file (gdb.dwarf2/rh-dwarf4-x86_64.c) ++ .byte 0x13 # DW_AT_decl_line ++ # DW_AT_prototyped ++ .long 0x4a # DW_AT_type ++ .quad .LFB0 # DW_AT_low_pc ++ .quad .LFE0 # DW_AT_high_pc ++ .uleb128 0x1 # DW_AT_frame_base ++ .byte 0x9c # DW_OP_call_frame_cfa ++ .uleb128 0x3 # (DIE (0x4a) DW_TAG_base_type) ++ .byte 0x4 # DW_AT_byte_size ++ .byte 0x5 # DW_AT_encoding ++ .ascii "int\0" # DW_AT_name ++ .byte 0x0 # end of children of DIE 0xb ++ .section .debug_abbrev ++ .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 0x1 # (DW_FORM_addr) ++ .uleb128 0x10 # (DW_AT_stmt_list) ++ .uleb128 0x17 # (DW_FORM_sec_offset) ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 # (abbrev code) ++ .uleb128 0x2e # (TAG: DW_TAG_subprogram) ++ .byte 0x0 # DW_children_no ++ .uleb128 0x3f # (DW_AT_external) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .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 0x27 # (DW_AT_prototyped) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x40 # (DW_AT_frame_base) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 # (abbrev code) ++ .uleb128 0x24 # (TAG: DW_TAG_base_type) ++ .byte 0x0 # 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 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x17 # Length of Public Names Info ++ .value 0x2 # DWARF Version ++ .long .Ldebug_info0 # Offset of Compilation Unit Info ++ .long 0x52 # Compilation Unit Length ++ .long 0x2d # DIE offset ++ .ascii "main\0" # external name ++ .long 0x0 ++ .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 0x0 # Size of Segment Descriptor ++ .value 0x0 # Pad to 16 byte boundary ++ .value 0x0 ++ .quad .Ltext0 # Address ++ .quad .Letext0-.Ltext0 # Length ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF2: ++ .string "." ++.LASF0: ++ .string "GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)" ++.LASF1: ++ .string "gdb.dwarf2/rh-dwarf4-x86_64.c" ++.LASF3: ++ .string "main" ++ .ident "GCC: (GNU) 4.4.4 20100503 (Red Hat 4.4.4-2)" ++ .section .note.GNU-stack,"",@progbits +diff --git a/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.c b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.c +@@ -0,0 +1,22 @@ ++/* 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 . */ ++ ++int ++main (void) ++{ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.exp b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.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 . ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++if {![istarget x86_64-*]} { ++ return 0 ++} ++ ++set testfile "rh-dwarf4-x86_64" ++set srcfile ${testfile}.S ++set executable ${testfile}.x ++set binfile [standard_output_file ${executable}] ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { ++ return -1 ++} ++ ++clean_restart $executable ++ ++gdb_test "ptype main" {type = int \(void\)} diff --git a/SOURCES/gdb-bz634108-solib_address.patch b/SOURCES/gdb-bz634108-solib_address.patch new file mode 100644 index 0000000..abbc407 --- /dev/null +++ b/SOURCES/gdb-bz634108-solib_address.patch @@ -0,0 +1,41 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-bz634108-solib_address.patch + +;; Verify GDB Python built-in function gdb.solib_address exists (BZ # 634108). +;;=fedoratest + +Fix gdb.solib_address (fix by Phil Muldoon). + +s/solib_address/solib_name/ during upstreaming. + +diff --git a/gdb/testsuite/gdb.python/rh634108-solib_address.exp b/gdb/testsuite/gdb.python/rh634108-solib_address.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/rh634108-solib_address.exp +@@ -0,0 +1,24 @@ ++# Copyright (C) 2008, 2009, 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 . ++ ++# https://bugzilla.redhat.com/show_bug.cgi?id=634108 ++ ++gdb_exit ++gdb_start ++ ++# Skip all tests if Python scripting is not enabled. ++if { [skip_python_tests] } { continue } ++ ++gdb_test "python print gdb.solib_name(-1)" "None" "gdb.solib_name exists" diff --git a/SOURCES/gdb-ccache-workaround.patch b/SOURCES/gdb-ccache-workaround.patch new file mode 100644 index 0000000..60bc5cc --- /dev/null +++ b/SOURCES/gdb-ccache-workaround.patch @@ -0,0 +1,26 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-ccache-workaround.patch + +;; Workaround ccache making lineno non-zero for command-line definitions. +;;=fedoratest: ccache is rarely used and it is even fixed now. + +diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp +--- a/gdb/testsuite/gdb.base/macscp.exp ++++ b/gdb/testsuite/gdb.base/macscp.exp +@@ -25,6 +25,14 @@ if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } { + lappend options additional_flags=-g3 + } + ++# Workaround ccache making lineno non-zero for command-line definitions. ++if {[find_gcc] == "gcc" && [file executable "/usr/bin/gcc"]} { ++ set result [catch "exec which gcc" output] ++ if {$result == 0 && [string first "/ccache/" $output] > -1} { ++ lappend options "compiler=/usr/bin/gcc" ++ } ++} ++ + # Generate the intermediate object file. This is required by Darwin to + # have access to the .debug_macinfo section. + if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \ diff --git a/SOURCES/gdb-container-rh-pkg.patch b/SOURCES/gdb-container-rh-pkg.patch new file mode 100644 index 0000000..2defc8d --- /dev/null +++ b/SOURCES/gdb-container-rh-pkg.patch @@ -0,0 +1,30 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-container-rh-pkg.patch + +;; Add messages suggesting more recent RHEL gdbserver (RH BZ 1321114). +;;=fedora + +diff --git a/gdb/remote.c b/gdb/remote.c +--- a/gdb/remote.c ++++ b/gdb/remote.c +@@ -13909,7 +13909,17 @@ remote_target::pid_to_exec_file (int pid) + char *annex = NULL; + + if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE) +- return NULL; ++ { ++ warning (_("Remote gdbserver does not support determining executable " ++ "automatically.\n" ++"RHEL <=6.8 and <=7.2 versions of gdbserver do not support such automatic executable detection.\n" ++"The following versions of gdbserver support it:\n" ++"- Upstream version of gdbserver (unsupported) 7.10 or later\n" ++"- Red Hat Developer Toolset (DTS) version of gdbserver from DTS 4.0 or later (only on x86_64)\n" ++"- RHEL-7.3 versions of gdbserver (on any architecture)" ++)); ++ return NULL; ++ } + + inf = find_inferior_pid (pid); + if (inf == NULL) diff --git a/SOURCES/gdb-core-open-vdso-warning.patch b/SOURCES/gdb-core-open-vdso-warning.patch new file mode 100644 index 0000000..b0a7311 --- /dev/null +++ b/SOURCES/gdb-core-open-vdso-warning.patch @@ -0,0 +1,58 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-core-open-vdso-warning.patch + +;; Fix GNU/Linux core open: Can't read pathname for load map: Input/output error. +;; Fix regression of undisplayed missing shared libraries caused by a fix for. +;;=fedoratest: It should be in glibc: libc-alpha: <20091004161706.GA27450@.*> + +http://sourceware.org/ml/gdb-patches/2009-10/msg00142.html +Subject: [patch] Fix GNU/Linux core open: Can't read pathname for load map: Input/output error. + +[ New patch variant. ] + +commit 7d760051ffb8a23cdc51342d4e6243fbc462f73f +Author: Ulrich Weigand +Date: Wed Sep 25 11:52:50 2013 +0000 + +diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp +--- a/gdb/testsuite/gdb.base/solib-symbol.exp ++++ b/gdb/testsuite/gdb.base/solib-symbol.exp +@@ -29,6 +29,7 @@ set testfile "solib-symbol-main" + set srcfile ${srcdir}/${subdir}/${testfile}.c + set binfile [standard_output_file ${testfile}] + set bin_flags [list debug shlib=${binfile_lib}] ++set executable ${testfile} + + if [get_compiler_info] { + return -1 +@@ -72,8 +73,26 @@ gdb_test "br foo2" \ + "Breakpoint.*: foo2. .2 locations..*" \ + "foo2 in mdlib" + +-gdb_exit ++# Test GDB warns for shared libraris which have not been found. + +-return 0 ++gdb_test "info sharedlibrary" "/${libname}.*" + ++clean_restart ${executable} ++gdb_breakpoint "main" ++gdb_run_cmd ++set test "no warning for missing libraries" ++gdb_test_multiple "" $test { ++ -re "warning: Could not load shared library symbols for \[0-9\]+ libraries,.*\r\n$gdb_prompt $" { ++ fail $test ++ } ++ -re "Breakpoint \[0-9\]+, main .*\r\n$gdb_prompt $" { ++ pass $test ++ } ++} + ++clean_restart ${executable} ++gdb_test_no_output "set solib-absolute-prefix /doESnotEXIST" ++gdb_breakpoint "main" ++gdb_run_cmd ++gdb_test "" "warning: Could not load shared library symbols for \[0-9\]+ libraries,.*\r\nBreakpoint \[0-9\]+, main .*" \ ++ "warning for missing libraries" diff --git a/SOURCES/gdb-dts-rhel6-python-compat.patch b/SOURCES/gdb-dts-rhel6-python-compat.patch new file mode 100644 index 0000000..697c6f0 --- /dev/null +++ b/SOURCES/gdb-dts-rhel6-python-compat.patch @@ -0,0 +1,315 @@ +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-dts-rhel6-python-compat.patch + +;; [rhel6] DTS backward Python compatibility API (BZ 1020004, Phil Muldoon). +;;=fedora + +https://bugzilla.redhat.com/show_bug.cgi?id=1020004 + +diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in +--- a/gdb/data-directory/Makefile.in ++++ b/gdb/data-directory/Makefile.in +@@ -71,6 +71,8 @@ PYTHON_FILE_LIST = \ + gdb/__init__.py \ + gdb/FrameDecorator.py \ + gdb/FrameIterator.py \ ++ gdb/FrameWrapper.py \ ++ gdb/backtrace.py \ + gdb/frames.py \ + gdb/printing.py \ + gdb/prompt.py \ +@@ -79,6 +81,7 @@ PYTHON_FILE_LIST = \ + gdb/xmethod.py \ + gdb/command/__init__.py \ + gdb/command/explore.py \ ++ gdb/command/backtrace.py \ + gdb/command/frame_filters.py \ + gdb/command/pretty_printers.py \ + gdb/command/prompt.py \ +diff --git a/gdb/python/lib/gdb/FrameWrapper.py b/gdb/python/lib/gdb/FrameWrapper.py +new file mode 100644 +--- /dev/null ++++ b/gdb/python/lib/gdb/FrameWrapper.py +@@ -0,0 +1,122 @@ ++# Wrapper API for frames. ++ ++# Copyright (C) 2008, 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++ ++# FIXME: arguably all this should be on Frame somehow. ++class FrameWrapper: ++ def __init__ (self, frame): ++ self.frame = frame; ++ ++ def write_symbol (self, stream, sym, block): ++ if len (sym.linkage_name): ++ nsym, is_field_of_this = gdb.lookup_symbol (sym.linkage_name, block) ++ if nsym.addr_class != gdb.SYMBOL_LOC_REGISTER: ++ sym = nsym ++ ++ stream.write (sym.print_name + "=") ++ try: ++ val = self.read_var (sym) ++ if val != None: ++ val = str (val) ++ # FIXME: would be nice to have a more precise exception here. ++ except RuntimeError as text: ++ val = text ++ if val == None: ++ stream.write ("???") ++ else: ++ stream.write (str (val)) ++ ++ def print_frame_locals (self, stream, func): ++ ++ try: ++ block = self.frame.block() ++ except RuntimeError: ++ block = None ++ ++ while block != None: ++ if block.is_global or block.is_static: ++ break ++ ++ for sym in block: ++ if sym.is_argument: ++ continue; ++ ++ self.write_symbol (stream, sym, block) ++ stream.write ('\n') ++ ++ def print_frame_args (self, stream, func): ++ ++ try: ++ block = self.frame.block() ++ except RuntimeError: ++ block = None ++ ++ while block != None: ++ if block.function != None: ++ break ++ block = block.superblock ++ ++ first = True ++ for sym in block: ++ if not sym.is_argument: ++ continue; ++ ++ if not first: ++ stream.write (", ") ++ ++ self.write_symbol (stream, sym, block) ++ first = False ++ ++ # FIXME: this should probably just be a method on gdb.Frame. ++ # But then we need stream wrappers. ++ def describe (self, stream, full): ++ if self.type () == gdb.DUMMY_FRAME: ++ stream.write (" \n") ++ elif self.type () == gdb.SIGTRAMP_FRAME: ++ stream.write (" \n") ++ else: ++ sal = self.find_sal () ++ pc = self.pc () ++ name = self.name () ++ if not name: ++ name = "??" ++ if pc != sal.pc or not sal.symtab: ++ stream.write (" 0x%08x in" % pc) ++ stream.write (" " + name + " (") ++ ++ func = self.function () ++ self.print_frame_args (stream, func) ++ ++ stream.write (")") ++ ++ if sal.symtab and sal.symtab.filename: ++ stream.write (" at " + sal.symtab.filename) ++ stream.write (":" + str (sal.line)) ++ ++ if not self.name () or (not sal.symtab or not sal.symtab.filename): ++ lib = gdb.solib_name (pc) ++ if lib: ++ stream.write (" from " + lib) ++ ++ stream.write ("\n") ++ ++ if full: ++ self.print_frame_locals (stream, func) ++ ++ def __getattr__ (self, name): ++ return getattr (self.frame, name) +diff --git a/gdb/python/lib/gdb/backtrace.py b/gdb/python/lib/gdb/backtrace.py +new file mode 100644 +--- /dev/null ++++ b/gdb/python/lib/gdb/backtrace.py +@@ -0,0 +1,42 @@ ++# Filtering backtrace. ++ ++# Copyright (C) 2008, 2011 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++import itertools ++ ++# Our only exports. ++__all__ = ['push_frame_filter', 'create_frame_filter'] ++ ++old_frame_filter = None ++ ++def push_frame_filter (constructor): ++ """Register a new backtrace filter class with the 'backtrace' command. ++The filter will be passed an iterator as an argument. The iterator ++will return gdb.Frame-like objects. The filter should in turn act as ++an iterator returning such objects.""" ++ global old_frame_filter ++ if old_frame_filter == None: ++ old_frame_filter = constructor ++ else: ++ old_frame_filter = lambda iterator, filter = frame_filter: constructor (filter(iterator)) ++ ++def create_frame_filter (iter): ++ global old_frame_filter ++ if old_frame_filter is None: ++ return iter ++ return old_frame_filter (iter) ++ +diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py +new file mode 100644 +--- /dev/null ++++ b/gdb/python/lib/gdb/command/backtrace.py +@@ -0,0 +1,106 @@ ++# New backtrace command. ++ ++# Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++import gdb.backtrace ++import itertools ++from gdb.FrameIterator import FrameIterator ++from gdb.FrameWrapper import FrameWrapper ++import sys ++ ++class ReverseBacktraceParameter (gdb.Parameter): ++ """The new-backtrace command can show backtraces in 'reverse' order. ++This means that the innermost frame will be printed last. ++Note that reverse backtraces are more expensive to compute.""" ++ ++ set_doc = "Enable or disable reverse backtraces." ++ show_doc = "Show whether backtraces will be printed in reverse order." ++ ++ def __init__(self): ++ gdb.Parameter.__init__ (self, "reverse-backtrace", ++ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN) ++ # Default to compatibility with gdb. ++ self.value = False ++ ++class FilteringBacktrace (gdb.Command): ++ """Print backtrace of all stack frames, or innermost COUNT frames. ++With a negative argument, print outermost -COUNT frames. ++Use of the 'full' qualifier also prints the values of the local variables. ++Use of the 'raw' qualifier avoids any filtering by loadable modules. ++""" ++ ++ def __init__ (self): ++ # FIXME: this is not working quite well enough to replace ++ # "backtrace" yet. ++ gdb.Command.__init__ (self, "new-backtrace", gdb.COMMAND_STACK) ++ self.reverse = ReverseBacktraceParameter() ++ ++ def reverse_iter (self, iter): ++ result = [] ++ for item in iter: ++ result.append (item) ++ result.reverse() ++ return result ++ ++ def final_n (self, iter, x): ++ result = [] ++ for item in iter: ++ result.append (item) ++ return result[x:] ++ ++ def invoke (self, arg, from_tty): ++ i = 0 ++ count = 0 ++ filter = True ++ full = False ++ ++ for word in arg.split (" "): ++ if word == '': ++ continue ++ elif word == 'raw': ++ filter = False ++ elif word == 'full': ++ full = True ++ else: ++ count = int (word) ++ ++ # FIXME: provide option to start at selected frame ++ # However, should still number as if starting from newest ++ newest_frame = gdb.newest_frame() ++ iter = itertools.imap (FrameWrapper, ++ FrameIterator (newest_frame)) ++ if filter: ++ iter = gdb.backtrace.create_frame_filter (iter) ++ ++ # Now wrap in an iterator that numbers the frames. ++ iter = itertools.izip (itertools.count (0), iter) ++ ++ # Reverse if the user wanted that. ++ if self.reverse.value: ++ iter = self.reverse_iter (iter) ++ ++ # Extract sub-range user wants. ++ if count < 0: ++ iter = self.final_n (iter, count) ++ elif count > 0: ++ iter = itertools.islice (iter, 0, count) ++ ++ for pair in iter: ++ sys.stdout.write ("#%-2d" % pair[0]) ++ pair[1].describe (sys.stdout, full) ++ ++FilteringBacktrace() diff --git a/SOURCES/gdb-fedora-libncursesw.patch b/SOURCES/gdb-fedora-libncursesw.patch new file mode 100644 index 0000000..5037e29 --- /dev/null +++ b/SOURCES/gdb-fedora-libncursesw.patch @@ -0,0 +1,71 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-fedora-libncursesw.patch + +;; Force libncursesw over libncurses to match the includes (RH BZ 1270534). +;;=push+jan + +Fedora: Force libncursesw over libncurses to match the includes. +https://bugzilla.redhat.com/show_bug.cgi?id=1270534 + +diff --git a/gdb/configure b/gdb/configure +--- a/gdb/configure ++++ b/gdb/configure +@@ -9393,6 +9393,7 @@ if test x"$prefer_curses" = xyes; then + # search /usr/local/include, if ncurses is installed in /usr/local. A + # default installation of ncurses on alpha*-dec-osf* will lead to such + # a situation. ++ # Fedora: Force libncursesw over libncurses to match the includes. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing waddstr" >&5 + $as_echo_n "checking for library containing waddstr... " >&6; } + if ${ac_cv_search_waddstr+:} false; then : +@@ -9417,7 +9418,7 @@ return waddstr (); + return 0; + } + _ACEOF +-for ac_lib in '' ncursesw ncurses cursesX curses; do ++for ac_lib in '' ncursesw; do + if test -z "$ac_lib"; then + ac_res="none required" + else +@@ -9491,6 +9492,7 @@ case $host_os in + esac + + # These are the libraries checked by Readline. ++# Fedora: Force libncursesw over libncurses to match the includes. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5 + $as_echo_n "checking for library containing tgetent... " >&6; } + if ${ac_cv_search_tgetent+:} false; then : +@@ -9515,7 +9517,7 @@ return tgetent (); + return 0; + } + _ACEOF +-for ac_lib in '' termcap tinfo curses ncursesw ncurses; do ++for ac_lib in '' termcap tinfo ncursesw; do + if test -z "$ac_lib"; then + ac_res="none required" + else +diff --git a/gdb/configure.ac b/gdb/configure.ac +--- a/gdb/configure.ac ++++ b/gdb/configure.ac +@@ -766,7 +766,8 @@ if test x"$prefer_curses" = xyes; then + # search /usr/local/include, if ncurses is installed in /usr/local. A + # default installation of ncurses on alpha*-dec-osf* will lead to such + # a situation. +- AC_SEARCH_LIBS(waddstr, [ncursesw ncurses cursesX curses]) ++ # Fedora: Force libncursesw over libncurses to match the includes. ++ AC_SEARCH_LIBS(waddstr, [ncursesw]) + + if test "$ac_cv_search_waddstr" != no; then + curses_found=yes +@@ -808,7 +809,8 @@ case $host_os in + esac + + # These are the libraries checked by Readline. +-AC_SEARCH_LIBS(tgetent, [termcap tinfo curses ncursesw ncurses]) ++# Fedora: Force libncursesw over libncurses to match the includes. ++AC_SEARCH_LIBS(tgetent, [termcap tinfo ncursesw]) + + if test "$ac_cv_search_tgetent" = no; then + CONFIG_OBS="$CONFIG_OBS stub-termcap.o" diff --git a/SOURCES/gdb-follow-child-stale-parent.patch b/SOURCES/gdb-follow-child-stale-parent.patch new file mode 100644 index 0000000..ab3a765 --- /dev/null +++ b/SOURCES/gdb-follow-child-stale-parent.patch @@ -0,0 +1,36 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-follow-child-stale-parent.patch + +;; Fix regression by python on ia64 due to stale current frame. +;;=push+jan + +Problem occurs with python and its get_current_arch () as it selects +selected_frame and current_frame while still inferior_ptid is valid for the +original parent. But since this place it is already attached and later +unwinders try to access it, breaking: + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the first fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the first fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the second fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the second fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: finish + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the first fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the first fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the second fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the second fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: finish + +diff --git a/gdb/infrun.c b/gdb/infrun.c +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -752,6 +752,9 @@ follow_fork (void) + } + else + { ++ /* Possibly referenced PARENT is no longer valid. */ ++ reinit_frame_cache (); ++ + /* This pending follow fork event is now handled, one way + or another. The previous selected thread may be gone + from the lists by now, but if it is still around, need diff --git a/SOURCES/gdb-fortran-frame-string.patch b/SOURCES/gdb-fortran-frame-string.patch new file mode 100644 index 0000000..a7b7b58 --- /dev/null +++ b/SOURCES/gdb-fortran-frame-string.patch @@ -0,0 +1,104 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-fortran-frame-string.patch + +;; Display Fortran strings in backtraces. +;;=fedoratest + +http://sourceware.org/ml/gdb-patches/2014-07/msg00709.html + +Hi, + +for Fortran it fixes displaying normal strings also in frames/backtraces: + +(gdb) frame +-> + +The patch is simple and I do not see why it should not be this way. + +For C/C++ TYPE_CODE_STRING is not used. I am not aware of Pascal but that +language is currently not really much supported in GDB anyway. + +This was a part of my archer/jankratochvil/vla branch but it is not a part of +the Intel VLA patchset as it in fact is completely unrelated to "VLA". + +No regressions on {x86_64,x86_64-m32,i686}-fedora22pre-linux-gnu. + +Thanks, +Jan + +diff --git a/gdb/testsuite/gdb.fortran/fortran-frame-string.exp b/gdb/testsuite/gdb.fortran/fortran-frame-string.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/fortran-frame-string.exp +@@ -0,0 +1,36 @@ ++# Copyright 2014 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++standard_testfile .f90 ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { ++ return -1 ++} ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "s = s"] ++gdb_continue_to_breakpoint "s = s" ++ ++gdb_test "ptype s" {type = character\*3} ++gdb_test "p s" " = 'foo'" ++ ++# Fix rejected upstream: ++# https://sourceware.org/ml/gdb-patches/2014-07/msg00768.html ++setup_kfail "rejected" *-*-* ++gdb_test "frame" { \(s='foo', .*} +diff --git a/gdb/testsuite/gdb.fortran/fortran-frame-string.f90 b/gdb/testsuite/gdb.fortran/fortran-frame-string.f90 +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/fortran-frame-string.f90 +@@ -0,0 +1,28 @@ ++! Copyright 2014 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 2 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program; if not, write to the Free Software ++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++ subroutine f(s) ++ character*3 s ++ s = s ++ end ++ ++ program main ++ call f ('foo') ++ end diff --git a/SOURCES/gdb-glibc-strstr-workaround.patch b/SOURCES/gdb-glibc-strstr-workaround.patch new file mode 100644 index 0000000..85c9621 --- /dev/null +++ b/SOURCES/gdb-glibc-strstr-workaround.patch @@ -0,0 +1,151 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-glibc-strstr-workaround.patch + +;; Workaround PR libc/14166 for inferior calls of strstr. +;;=fedora: Compatibility with RHELs (unchecked which ones). + +diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -21286,6 +21286,26 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, + /* Cache this symbol's name and the name's demangled form (if any). */ + SYMBOL_SET_LANGUAGE (sym, cu->language, &objfile->objfile_obstack); + linkagename = dwarf2_physname (name, die, cu); ++ ++ /* Workaround for: ++ * invalid IFUNC DW_AT_linkage_name: memmove strstr time ++ * http://sourceware.org/bugzilla/show_bug.cgi?id=14166 */ ++ if (strcmp (linkagename, "strstr") == 0 ++ && strstr (objfile_name (objfile), "/libc") != NULL) ++ { ++ struct objfile *objfile_msym; ++ struct bound_minimal_symbol bmsym; ++ ++ if (objfile->separate_debug_objfile_backlink) ++ objfile_msym = objfile->separate_debug_objfile_backlink; ++ else ++ objfile_msym = objfile; ++ bmsym = lookup_minimal_symbol ("strstr", NULL, objfile_msym); ++ if (bmsym.minsym != NULL ++ && MSYMBOL_TYPE (bmsym.minsym) == mst_text_gnu_ifunc) ++ linkagename = "__strstr"; ++ } ++ + SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile); + + /* Fortran does not have mangling standard and the mangling does differ +diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp +@@ -0,0 +1,108 @@ ++# 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 . ++ ++# Workaround for: ++# invalid IFUNC DW_AT_linkage_name: memmove strstr time ++# http://sourceware.org/bugzilla/show_bug.cgi?id=14166 ++ ++if {[skip_shlib_tests]} { ++ return 0 ++} ++ ++set testfile "gnu-ifunc-strstr-workaround" ++set executable ${testfile} ++set srcfile start.c ++set binfile [standard_output_file ${executable}] ++ ++if [prepare_for_testing ${testfile}.exp $executable $srcfile] { ++ return -1 ++} ++ ++if ![runto_main] { ++ return 0 ++} ++ ++set test "ptype atoi" ++gdb_test_multiple $test $test { ++ -re "type = int \\(const char \\*\\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "type = int \\(\\)\r\n$gdb_prompt $" { ++ untested "$test (no DWARF)" ++ return 0 ++ } ++} ++ ++set addr "" ++set test "print strstr" ++gdb_test_multiple $test $test { ++ -re " = {} (0x\[0-9a-f\]+) \r\n$gdb_prompt $" { ++ set addr $expect_out(1,string) ++ pass $test ++ } ++ -re " = {} (0x\[0-9a-f\]+) <__strstr>\r\n$gdb_prompt $" { ++ set addr $expect_out(1,string) ++ pass "$test (GDB workaround)" ++ } ++ -re " = {} (0x\[0-9a-f\]+) <__libc_strstr>\r\n$gdb_prompt $" { ++ set addr $expect_out(1,string) ++ pass "$test (fixed glibc)" ++ } ++ -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ \r\n$gdb_prompt $" { ++ untested "$test (gnu-ifunc not in use by glibc)" ++ return 0 ++ } ++} ++ ++set test "info sym" ++gdb_test_multiple "info sym $addr" $test { ++ -re "strstr in section \\.text of /lib\[^/\]*/libc.so.6\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ \r\n$gdb_prompt $" { ++ # unexpected ++ xfail "$test (not in libc.so.6)" ++ return 0 ++ } ++} ++ ++set test "info addr strstr" ++gdb_test_multiple $test $test { ++ -re "Symbol \"strstr\" is a function at address $addr\\.\r\n$gdb_prompt $" { ++ fail "$test (DWARF for strstr)" ++ } ++ -re "Symbol \"strstr\" is at $addr in a file compiled without debugging\\.\r\n$gdb_prompt $" { ++ pass "$test" ++ } ++} ++ ++set test "print strstr second time" ++gdb_test_multiple "print strstr" $test { ++ -re " = {} $addr \r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re " = {} $addr <__strstr>\r\n$gdb_prompt $" { ++ pass "$test (GDB workaround)" ++ } ++ -re " = {} $addr <__libc_strstr>\r\n$gdb_prompt $" { ++ pass "$test (fixed glibc)" ++ } ++ -re " = {void \\*\\(void\\)} 0x\[0-9a-f\]+ \r\n$gdb_prompt $" { ++ fail $test ++ } ++} ++ ++gdb_test {print strstr("abc","b")} { = 0x[0-9a-f]+ "bc"} ++gdb_test {print strstr("def","e")} { = 0x[0-9a-f]+ "ef"} diff --git a/SOURCES/gdb-gnat-dwarf-crash-3of3.patch b/SOURCES/gdb-gnat-dwarf-crash-3of3.patch new file mode 100644 index 0000000..a20da46 --- /dev/null +++ b/SOURCES/gdb-gnat-dwarf-crash-3of3.patch @@ -0,0 +1,236 @@ +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-gnat-dwarf-crash-3of3.patch + +;; Fix crash of -readnow /usr/lib/debug/usr/bin/gnatbind.debug (BZ 1069211). +;;=push+jan + +http://sourceware.org/ml/gdb-patches/2014-02/msg00731.html + +--6TrnltStXW4iwmi0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline + +Hi, + +PR 16581: + GDB crash on inherit_abstract_dies infinite recursion + https://sourceware.org/bugzilla/show_bug.cgi?id=16581 + +fixed crash from an infinite recursion. But in rare cases the new code can +now gdb_assert() due to weird DWARF file. + +I do not yet fully understand why the DWARF is as it is but just GDB should +never crash due to invalid DWARF anyway. The "invalid" DWARF I see only in +Fedora GCC build, not in FSF GCC build, more info at: + https://bugzilla.redhat.com/show_bug.cgi?id=1069382 + http://people.redhat.com/jkratoch/gcc-debuginfo-4.8.2-7.fc20.x86_64-gnatbind.debug + +Thanks, +Jan + +--6TrnltStXW4iwmi0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline; filename="complaint.patch" + +gdb/ +2014-02-24 Jan Kratochvil + + * dwarf2read.c (process_die): Change gdb_assert to complaint. + +diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -10499,6 +10499,13 @@ private: + static void + process_die (struct die_info *die, struct dwarf2_cu *cu) + { ++ if (die->in_process) ++ { ++ complaint (_("DIE at 0x%s attempted to be processed twice"), ++ sect_offset_str (die->sect_off)); ++ return; ++ } ++ + process_die_scope scope (die, cu); + + switch (die->tag) +diff --git a/gdb/infrun.c b/gdb/infrun.c +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -607,6 +607,13 @@ holding the child stopped. Try \"set detach-on-fork\" or \ + target_pid_to_str (process_ptid)); + } + ++#ifdef NEED_DETACH_SIGSTOP ++ /* We should check PID_WAS_STOPPED and detach it stopped accordingly. ++ In this point of code it cannot be 1 as we would not get FORK ++ executed without CONTINUE first which resets PID_WAS_STOPPED. ++ We would have to first TARGET_STOP and WAITPID it as with running ++ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */ ++#endif + target_detach (parent_inf, 0); + } + +diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c +--- a/gdb/linux-nat.c ++++ b/gdb/linux-nat.c +@@ -191,6 +191,12 @@ struct linux_nat_target *linux_target; + /* Does the current host support PTRACE_GETREGSET? */ + enum tribool have_ptrace_getregset = TRIBOOL_UNKNOWN; + ++#ifdef NEED_DETACH_SIGSTOP ++/* PID of the inferior stopped by SIGSTOP before attaching (or zero). */ ++static pid_t pid_was_stopped; ++ ++#endif ++ + /* The saved to_close method, inherited from inf-ptrace.c. + Called by our to_close. */ + static void (*super_close) (struct target_ops *); +@@ -1027,6 +1033,9 @@ linux_nat_post_attach_wait (ptid_t ptid, int *signalled) + if (debug_linux_nat) + fprintf_unfiltered (gdb_stdlog, + "LNPAW: Attaching to a stopped process\n"); ++#ifdef NEED_DETACH_SIGSTOP ++ pid_was_stopped = ptid.pid (); ++#endif + + /* The process is definitely stopped. It is in a job control + stop, unless the kernel predates the TASK_STOPPED / +@@ -1359,6 +1368,25 @@ get_detach_signal (struct lwp_info *lp) + return gdb_signal_to_host (signo); + } + ++#ifdef NEED_DETACH_SIGSTOP ++ /* Workaround RHEL-5 kernel which has unreliable PTRACE_DETACH, SIGSTOP (that ++ many TIDs are left unstopped). See RH Bug 496732. */ ++ if (lp->ptid.pid () == pid_was_stopped) ++ { ++ int err; ++ ++ errno = 0; ++ err = kill_lwp (lp->ptid.lwp (), SIGSTOP); ++ if (debug_linux_nat) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "SC: lwp kill %d %s\n", ++ err, ++ errno ? safe_strerror (errno) : "ERRNO-OK"); ++ } ++ } ++ ++#endif + return 0; + } + +@@ -1507,6 +1535,10 @@ linux_nat_target::detach (inferior *inf, int from_tty) + detach_one_lwp (main_lwp, &signo); + + detach_success (inf); ++ ++#ifdef NEED_DETACH_SIGSTOP ++ pid_was_stopped = 0; ++#endif + } + } + +@@ -1765,6 +1797,16 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo) + return; + } + ++#ifdef NEED_DETACH_SIGSTOP ++ /* At this point, we are going to resume the inferior and if we ++ have attached to a stopped process, we no longer should leave ++ it as stopped if the user detaches. PTID variable has PID set to LWP ++ while we need to check the real PID here. */ ++ ++ if (!step && lp && pid_was_stopped == lp->ptid.pid ()) ++ pid_was_stopped = 0; ++ ++#endif + if (resume_many) + iterate_over_lwps (ptid, linux_nat_resume_callback, lp); + +@@ -3761,6 +3803,10 @@ linux_nat_target::mourn_inferior () + + /* Let the arch-specific native code know this process is gone. */ + linux_target->low_forget_process (pid); ++#ifdef NEED_DETACH_SIGSTOP ++ ++ pid_was_stopped = 0; ++#endif + } + + /* Convert a native/host siginfo object, into/from the siginfo in the +diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp +--- a/gdb/testsuite/gdb.threads/attach-stopped.exp ++++ b/gdb/testsuite/gdb.threads/attach-stopped.exp +@@ -56,7 +56,65 @@ proc corefunc { threadtype } { + gdb_reinitialize_dir $srcdir/$subdir + gdb_load ${binfile} + +- # Verify that we can attach to the stopped process. ++ # Verify that we can attach to the process by first giving its ++ # executable name via the file command, and using attach with the ++ # process ID. ++ ++ set test "$threadtype: set file, before attach1 to stopped process" ++ gdb_test_multiple "file $binfile" "$test" { ++ -re "Load new symbol table from.*y or n. $" { ++ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \ ++ "$test (re-read)" ++ } ++ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" { ++ pass "$test" ++ } ++ } ++ ++ set test "$threadtype: attach1 to stopped, after setting file" ++ gdb_test_multiple "attach $testpid" "$test" { ++ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" { ++ pass "$test" ++ } ++ } ++ ++ # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there. ++ if {[string equal $threadtype threaded]} { ++ gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: attach1 to stopped bt" ++ } else { ++ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach1 to stopped bt" ++ } ++ ++ # Exit and detach the process. ++ ++ gdb_exit ++ ++ # Avoid some race: ++ sleep 2 ++ ++ if [catch {open /proc/${testpid}/status r} fileid] { ++ set line2 "NOTFOUND" ++ } else { ++ gets $fileid line1; ++ gets $fileid line2; ++ close $fileid; ++ } ++ ++ set test "$threadtype: attach1, exit leaves process stopped" ++ if {[string match "*(stopped)*" $line2]} { ++ pass $test ++ } else { ++ fail $test ++ } ++ ++ # At this point, the process should still be stopped ++ ++ gdb_start ++ gdb_reinitialize_dir $srcdir/$subdir ++ gdb_load ${binfile} ++ ++ # Verify that we can attach to the process just by giving the ++ # process ID. + + set test "$threadtype: attach2 to stopped, after setting file" + gdb_test_multiple "attach $testpid" "$test" { diff --git a/SOURCES/gdb-gstack.man b/SOURCES/gdb-gstack.man new file mode 100644 index 0000000..1f4e406 --- /dev/null +++ b/SOURCES/gdb-gstack.man @@ -0,0 +1,48 @@ +.\" +.\" gstack manual page. +.\" Copyright (c) 1999 Ross Thompson +.\" Copyright (c) 2001, 2002, 2004, 2008 Red Hat, Inc. +.\" +.\" Original author: Ross Thompson +.\" +.\" 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, 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; see the file COPYING. If not, write to +.\" the Free Software Foundation, 59 Temple Place - Suite 330, +.\" Boston, MA 02111-1307, USA. +.\" +.TH GSTACK 1 "Feb 15 2008" "Red Hat Linux" "Linux Programmer's Manual" + +.SH NAME +gstack \- print a stack trace of a running process + +.SH SYNOPSIS +.B gstack +pid + +.SH DESCRIPTION + +\f3gstack\f1 attaches to the active process named by the \f3pid\f1 on +the command line, and prints out an execution stack trace. If ELF +symbols exist in the binary (usually the case unless you have run +strip(1)), then symbolic addresses are printed as well. + +If the process is part of a thread group, then \f3gstack\f1 will print +out a stack trace for each of the threads in the group. + +.SH SEE ALSO +nm(1), ptrace(2), gdb(1) + +.SH AUTHORS +Ross Thompson + +Red Hat, Inc. diff --git a/SOURCES/gdb-jit-reader-multilib.patch b/SOURCES/gdb-jit-reader-multilib.patch new file mode 100644 index 0000000..2aa41c2 --- /dev/null +++ b/SOURCES/gdb-jit-reader-multilib.patch @@ -0,0 +1,46 @@ +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-jit-reader-multilib.patch + +;; Fix jit-reader.h for multi-lib. +;;=push+jan + +diff --git a/gdb/configure b/gdb/configure +--- a/gdb/configure ++++ b/gdb/configure +@@ -9680,10 +9680,12 @@ _ACEOF + + + +-if test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then +- TARGET_PTR="unsigned long" +-elif test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then ++# Try to keep TARGET_PTR the same across archs so that jit-reader.h file ++# content is the same for multilib distributions. ++if test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then + TARGET_PTR="unsigned long long" ++elif test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then ++ TARGET_PTR="unsigned long" + elif test "x${ac_cv_sizeof_unsigned___int128}" = "x16"; then + TARGET_PTR="unsigned __int128" + else +diff --git a/gdb/configure.ac b/gdb/configure.ac +--- a/gdb/configure.ac ++++ b/gdb/configure.ac +@@ -843,10 +843,12 @@ AC_CHECK_SIZEOF(unsigned long long) + AC_CHECK_SIZEOF(unsigned long) + AC_CHECK_SIZEOF(unsigned __int128) + +-if test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then +- TARGET_PTR="unsigned long" +-elif test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then ++# Try to keep TARGET_PTR the same across archs so that jit-reader.h file ++# content is the same for multilib distributions. ++if test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then + TARGET_PTR="unsigned long long" ++elif test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then ++ TARGET_PTR="unsigned long" + elif test "x${ac_cv_sizeof_unsigned___int128}" = "x16"; then + TARGET_PTR="unsigned __int128" + else diff --git a/SOURCES/gdb-libexec-add-index.patch b/SOURCES/gdb-libexec-add-index.patch new file mode 100644 index 0000000..7856866 --- /dev/null +++ b/SOURCES/gdb-libexec-add-index.patch @@ -0,0 +1,23 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-libexec-add-index.patch + +;; Fix gdb-headless /usr/bin/ executables (BZ 1390251). +;;=fedora + +diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh +--- a/gdb/contrib/gdb-add-index.sh ++++ b/gdb/contrib/gdb-add-index.sh +@@ -21,6 +21,11 @@ + GDB=${GDB:=gdb} + OBJCOPY=${OBJCOPY:=objcopy} + ++GDB2=/usr/libexec/gdb ++if test -x $GDB2 && ! which $GDB &>/dev/null; then ++ GDB=$GDB2 ++fi ++ + myname="${0##*/}" + + dwarf5="" diff --git a/SOURCES/gdb-lineno-makeup-test.patch b/SOURCES/gdb-lineno-makeup-test.patch new file mode 100644 index 0000000..313421d --- /dev/null +++ b/SOURCES/gdb-lineno-makeup-test.patch @@ -0,0 +1,165 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-lineno-makeup-test.patch + +;; Testcase for "Do not make up line information" fix by Daniel Jacobowitz. +;;=fedoratest + +New testcase for: +https://bugzilla.redhat.com/show_bug.cgi?id=466222 + (for the first / customer recommended fix) +and the upstream fix: +http://sourceware.org/ml/gdb-patches/2006-11/msg00253.html + [rfc] Do not make up line information +http://sourceware.org/ml/gdb-cvs/2006-11/msg00127.html + +diff --git a/gdb/testsuite/gdb.base/lineno-makeup-func.c b/gdb/testsuite/gdb.base/lineno-makeup-func.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/lineno-makeup-func.c +@@ -0,0 +1,21 @@ ++/* 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 . */ ++ ++void ++func (void) ++{ ++} +diff --git a/gdb/testsuite/gdb.base/lineno-makeup.c b/gdb/testsuite/gdb.base/lineno-makeup.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/lineno-makeup.c +@@ -0,0 +1,35 @@ ++/* 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 . */ ++ ++/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number ++ information (.debug_line) so we cannot use an external object file. ++ ++ It must not be just a label as it would alias on the next function even for ++ correct GDB. Therefore some stub data must be placed there. ++ ++ We need to provide a real stub function body as at least s390 ++ (s390_analyze_prologue) would skip the whole body till reaching `main'. */ ++ ++extern void func (void); ++asm ("func: .incbin \"" BINFILENAME "\""); ++ ++int ++main (void) ++{ ++ func (); ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/lineno-makeup.exp b/gdb/testsuite/gdb.base/lineno-makeup.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/lineno-makeup.exp +@@ -0,0 +1,78 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile "lineno-makeup" ++set srcfuncfile ${testfile}-func.c ++set srcfile ${testfile}.c ++set objfuncfile [standard_output_file ${testfile}-func.o] ++set binfuncfile [standard_output_file ${testfile}-func.bin] ++set binfile [standard_output_file ${testfile}] ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output] ++verbose -log "objcopy=$objcopy: $output" ++if { $objcopy != 0 } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++set binfuncfilesize [file size $binfuncfile] ++verbose -log "file size $binfuncfile = $binfuncfilesize" ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug additional_flags=-DBINFILENAME=\"$binfuncfile\"]] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set b_addr "" ++set test "break func" ++gdb_test_multiple $test $test { ++ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+)\r\n$gdb_prompt $" { ++ set b_addr $expect_out(1,string) ++ pass $test ++ } ++ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" { ++ set b_addr $expect_out(1,string) ++ fail $test ++ } ++} ++verbose -log "b_addr=<$b_addr>" ++ ++set p_addr "" ++set test "print func" ++gdb_test_multiple $test $test { ++ -re "\\$\[0-9\]+ = {} (0x\[0-9a-f\]+) \r\n$gdb_prompt $" { ++ set p_addr $expect_out(1,string) ++ pass $test ++ } ++} ++verbose -log "p_addr=<$p_addr>" ++ ++set test "break address belongs to func" ++if {$b_addr == $p_addr} { ++ pass "$test (exact match)" ++} else { ++ set skip [expr $b_addr - $p_addr] ++ if {$skip > 0 && $skip < $binfuncfilesize} { ++ pass "$test (prologue skip by $skip bytes)" ++ } else { ++ fail $test ++ } ++} diff --git a/SOURCES/gdb-linux_perf-bundle.patch b/SOURCES/gdb-linux_perf-bundle.patch new file mode 100644 index 0000000..c7533f7 --- /dev/null +++ b/SOURCES/gdb-linux_perf-bundle.patch @@ -0,0 +1,236 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-linux_perf-bundle.patch + +;; [dts+el7] [x86*] Bundle linux_perf.h for libipt (RH BZ 1256513). +;;=fedora + +diff --git a/gdb/configure b/gdb/configure +--- a/gdb/configure ++++ b/gdb/configure +@@ -12059,7 +12059,7 @@ else + + #include + #ifndef PERF_ATTR_SIZE_VER5 +-# error ++// error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL + #endif + + _ACEOF +diff --git a/gdb/configure.ac b/gdb/configure.ac +--- a/gdb/configure.ac ++++ b/gdb/configure.ac +@@ -1477,7 +1477,7 @@ else + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ + #include + #ifndef PERF_ATTR_SIZE_VER5 +-# error ++// error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL + #endif + ]])], [perf_event=yes], [perf_event=no]) + if test "$perf_event" != yes; then +diff --git a/gdb/gdb.c b/gdb/gdb.c +--- a/gdb/gdb.c ++++ b/gdb/gdb.c +@@ -20,11 +20,19 @@ + #include "main.h" + #include "interps.h" + ++#ifdef PERF_ATTR_SIZE_VER5_BUNDLE ++extern "C" void __libipt_init(void); ++#endif ++ + int + main (int argc, char **argv) + { + struct captured_main_args args; + ++#ifdef PERF_ATTR_SIZE_VER5_BUNDLE ++ __libipt_init(); ++#endif ++ + memset (&args, 0, sizeof args); + args.argc = argc; + args.argv = argv; +diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h +--- a/gdb/nat/linux-btrace.h ++++ b/gdb/nat/linux-btrace.h +@@ -28,6 +28,177 @@ + # include + #endif + ++#ifdef PERF_ATTR_SIZE_VER5_BUNDLE ++#ifndef HAVE_LINUX_PERF_EVENT_H ++# error "PERF_ATTR_SIZE_VER5_BUNDLE && !HAVE_LINUX_PERF_EVENT_H" ++#endif ++#ifndef PERF_ATTR_SIZE_VER5 ++#define PERF_ATTR_SIZE_VER5 ++#define perf_event_mmap_page perf_event_mmap_page_bundle ++// kernel-headers-3.10.0-493.el7.x86_64/usr/include/linux/perf_event.h ++/* ++ * Structure of the page that can be mapped via mmap ++ */ ++struct perf_event_mmap_page { ++ __u32 version; /* version number of this structure */ ++ __u32 compat_version; /* lowest version this is compat with */ ++ ++ /* ++ * Bits needed to read the hw events in user-space. ++ * ++ * u32 seq, time_mult, time_shift, index, width; ++ * u64 count, enabled, running; ++ * u64 cyc, time_offset; ++ * s64 pmc = 0; ++ * ++ * do { ++ * seq = pc->lock; ++ * barrier() ++ * ++ * enabled = pc->time_enabled; ++ * running = pc->time_running; ++ * ++ * if (pc->cap_usr_time && enabled != running) { ++ * cyc = rdtsc(); ++ * time_offset = pc->time_offset; ++ * time_mult = pc->time_mult; ++ * time_shift = pc->time_shift; ++ * } ++ * ++ * index = pc->index; ++ * count = pc->offset; ++ * if (pc->cap_user_rdpmc && index) { ++ * width = pc->pmc_width; ++ * pmc = rdpmc(index - 1); ++ * } ++ * ++ * barrier(); ++ * } while (pc->lock != seq); ++ * ++ * NOTE: for obvious reason this only works on self-monitoring ++ * processes. ++ */ ++ __u32 lock; /* seqlock for synchronization */ ++ __u32 index; /* hardware event identifier */ ++ __s64 offset; /* add to hardware event value */ ++ __u64 time_enabled; /* time event active */ ++ __u64 time_running; /* time event on cpu */ ++ union { ++ __u64 capabilities; ++ struct { ++ __u64 cap_bit0 : 1, /* Always 0, deprecated, see commit 860f085b74e9 */ ++ cap_bit0_is_deprecated : 1, /* Always 1, signals that bit 0 is zero */ ++ ++ cap_user_rdpmc : 1, /* The RDPMC instruction can be used to read counts */ ++ cap_user_time : 1, /* The time_* fields are used */ ++ cap_user_time_zero : 1, /* The time_zero field is used */ ++ cap_____res : 59; ++ }; ++ }; ++ ++ /* ++ * If cap_user_rdpmc this field provides the bit-width of the value ++ * read using the rdpmc() or equivalent instruction. This can be used ++ * to sign extend the result like: ++ * ++ * pmc <<= 64 - width; ++ * pmc >>= 64 - width; // signed shift right ++ * count += pmc; ++ */ ++ __u16 pmc_width; ++ ++ /* ++ * If cap_usr_time the below fields can be used to compute the time ++ * delta since time_enabled (in ns) using rdtsc or similar. ++ * ++ * u64 quot, rem; ++ * u64 delta; ++ * ++ * quot = (cyc >> time_shift); ++ * rem = cyc & (((u64)1 << time_shift) - 1); ++ * delta = time_offset + quot * time_mult + ++ * ((rem * time_mult) >> time_shift); ++ * ++ * Where time_offset,time_mult,time_shift and cyc are read in the ++ * seqcount loop described above. This delta can then be added to ++ * enabled and possible running (if index), improving the scaling: ++ * ++ * enabled += delta; ++ * if (index) ++ * running += delta; ++ * ++ * quot = count / running; ++ * rem = count % running; ++ * count = quot * enabled + (rem * enabled) / running; ++ */ ++ __u16 time_shift; ++ __u32 time_mult; ++ __u64 time_offset; ++ /* ++ * If cap_usr_time_zero, the hardware clock (e.g. TSC) can be calculated ++ * from sample timestamps. ++ * ++ * time = timestamp - time_zero; ++ * quot = time / time_mult; ++ * rem = time % time_mult; ++ * cyc = (quot << time_shift) + (rem << time_shift) / time_mult; ++ * ++ * And vice versa: ++ * ++ * quot = cyc >> time_shift; ++ * rem = cyc & (((u64)1 << time_shift) - 1); ++ * timestamp = time_zero + quot * time_mult + ++ * ((rem * time_mult) >> time_shift); ++ */ ++ __u64 time_zero; ++ __u32 size; /* Header size up to __reserved[] fields. */ ++ ++ /* ++ * Hole for extension of the self monitor capabilities ++ */ ++ ++ __u8 __reserved[118*8+4]; /* align to 1k. */ ++ ++ /* ++ * Control data for the mmap() data buffer. ++ * ++ * User-space reading the @data_head value should issue an smp_rmb(), ++ * after reading this value. ++ * ++ * When the mapping is PROT_WRITE the @data_tail value should be ++ * written by userspace to reflect the last read data, after issueing ++ * an smp_mb() to separate the data read from the ->data_tail store. ++ * In this case the kernel will not over-write unread data. ++ * ++ * See perf_output_put_handle() for the data ordering. ++ * ++ * data_{offset,size} indicate the location and size of the perf record ++ * buffer within the mmapped area. ++ */ ++ __u64 data_head; /* head in the data section */ ++ __u64 data_tail; /* user-space written tail */ ++ __u64 data_offset; /* where the buffer starts */ ++ __u64 data_size; /* data buffer size */ ++ ++ /* ++ * AUX area is defined by aux_{offset,size} fields that should be set ++ * by the userspace, so that ++ * ++ * aux_offset >= data_offset + data_size ++ * ++ * prior to mmap()ing it. Size of the mmap()ed area should be aux_size. ++ * ++ * Ring buffer pointers aux_{head,tail} have the same semantics as ++ * data_{head,tail} and same ordering rules apply. ++ */ ++ __u64 aux_head; ++ __u64 aux_tail; ++ __u64 aux_offset; ++ __u64 aux_size; ++}; ++#endif // PERF_ATTR_SIZE_VER5 ++#endif // PERF_ATTR_SIZE_VER5_BUNDLE ++ + struct target_ops; + + #if HAVE_LINUX_PERF_EVENT_H diff --git a/SOURCES/gdb-moribund-utrace-workaround.patch b/SOURCES/gdb-moribund-utrace-workaround.patch new file mode 100644 index 0000000..f41e4fb --- /dev/null +++ b/SOURCES/gdb-moribund-utrace-workaround.patch @@ -0,0 +1,25 @@ +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-moribund-utrace-workaround.patch + +;; Workaround non-stop moribund locations exploited by kernel utrace (BZ 590623). +;;=push+jan: Currently it is still not fully safe. + +https://bugzilla.redhat.com/show_bug.cgi?id=590623 +http://sources.redhat.com/bugzilla/show_bug.cgi?id=11593 + +Bug in FSF GDB exploited by the ptrace-on-utrace interaction. + +diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c +--- a/gdb/breakpoint.c ++++ b/gdb/breakpoint.c +@@ -12016,6 +12016,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode) + traps we can no longer explain. */ + + old_loc->events_till_retirement = 3 * (thread_count () + 1); ++ /* Red Hat Bug 590623. */ ++ old_loc->events_till_retirement *= 10; + old_loc->owner = NULL; + + VEC_safe_push (bp_location_p, moribund_locations, old_loc); diff --git a/SOURCES/gdb-opcodes-clflushopt-test.patch b/SOURCES/gdb-opcodes-clflushopt-test.patch new file mode 100644 index 0000000..f95999e --- /dev/null +++ b/SOURCES/gdb-opcodes-clflushopt-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-opcodes-clflushopt-test.patch + +;; Test clflushopt instruction decode (for RH BZ 1262471). +;;=fedoratest + +diff --git a/gdb/testsuite/gdb.arch/amd64-clflushopt.S b/gdb/testsuite/gdb.arch/amd64-clflushopt.S +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/amd64-clflushopt.S +@@ -0,0 +1,19 @@ ++/* 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 . ++ ++ This file is part of the gdb testsuite. */ ++ ++_start: .globl _start ++ clflushopt (%edi) +diff --git a/gdb/testsuite/gdb.arch/amd64-clflushopt.exp b/gdb/testsuite/gdb.arch/amd64-clflushopt.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/amd64-clflushopt.exp +@@ -0,0 +1,25 @@ ++# 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 { ![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"] } then { ++ verbose "Skipping amd64 clflushopt test." ++ return ++} ++ ++if [prepare_for_testing amd64-clflushopt.exp amd64-clflushopt amd64-clflushopt.S [list debug "additional_flags=-nostdlib"]] { ++ return -1 ++} ++ ++gdb_test "disas _start" "Dump of assembler code for function _start:\r\n *0x\[0-9a-f\]+ <\[+\]0>:\tclflushopt \\(%edi\\)\r\nEnd of assembler dump\\." "clflushopt" diff --git a/SOURCES/gdb-orphanripper.c b/SOURCES/gdb-orphanripper.c new file mode 100644 index 0000000..2653dd2 --- /dev/null +++ b/SOURCES/gdb-orphanripper.c @@ -0,0 +1,752 @@ +/* + * 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. + * + * Reap any leftover children possibly holding file descriptors. + * Children are identified by the stale file descriptor or PGID / SID. + * Both can be missed but only the stale file descriptors are important for us. + * PGID / SID may be set by the children on their own. + * If we fine a candidate we kill it will all its process tree (grandchildren). + * The child process is run with `2>&1' redirection (due to forkpty(3)). + * 2007-07-10 Jan Kratochvil + */ + +/* For getpgid(2). */ +#define _GNU_SOURCE 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LENGTH(x) (sizeof (x) / sizeof (*(x))) + +static const char *progname; + +static volatile pid_t child; + +static void signal_chld (int signo) +{ +} + +static volatile int signal_alrm_hit = 0; + +static void signal_alrm (int signo) +{ + signal_alrm_hit = 1; +} + +static char childptyname[LINE_MAX]; + +static void print_child_error (const char *reason, char **argv) +{ + char **sp; + + fprintf (stderr, "%s: %d %s:", progname, (int) child, reason); + for (sp = argv; *sp != NULL; sp++) + { + fputc (' ', stderr); + fputs (*sp, stderr); + } + fputc ('\n', stderr); +} + +static int read_out (int amaster) +{ + char buf[LINE_MAX]; + ssize_t buf_got; + + buf_got = read (amaster, buf, sizeof buf); + if (buf_got == 0) + return 0; + /* Weird but at least after POLLHUP we get EIO instead of just EOF. */ + if (buf_got == -1 && errno == EIO) + return 0; + if (buf_got == -1 && errno == EAGAIN) + return 0; + if (buf_got < 0) + { + perror ("read (amaster)"); + exit (EXIT_FAILURE); + } + if (write (STDOUT_FILENO, buf, buf_got) != buf_got) + { + perror ("write(2)"); + exit (EXIT_FAILURE); + } + return 1; +} + +/* kill (child, 0) == 0 sometimes even when CHILD's state is already "Z". */ + +static int child_exited (void) +{ + char buf[200]; + int fd, i, retval; + ssize_t got; + char state[3]; + + snprintf (buf, sizeof (buf), "/proc/%ld/stat", (long) child); + fd = open (buf, O_RDONLY); + if (fd == -1) + { + perror ("open (/proc/CHILD/stat)"); + exit (EXIT_FAILURE); + } + got = read (fd, buf, sizeof(buf)); + if (got <= 0) + { + perror ("read (/proc/CHILD/stat)"); + exit (EXIT_FAILURE); + } + if (close (fd) != 0) + { + perror ("close (/proc/CHILD/stat)"); + exit (EXIT_FAILURE); + } + /* RHEL-5 does not support %ms. */ + i = sscanf (buf, "%*d%*s%2s", state); + if (i != 1) + { + perror ("sscanf (/proc/CHILD/stat)"); + exit (EXIT_FAILURE); + } + retval = strcmp (state, "Z") == 0; + return retval; +} + +static int spawn (char **argv, int timeout) +{ + pid_t child_got; + int status, amaster, i, rc; + struct sigaction act; + sigset_t set; + struct termios termios; + unsigned alarm_orig; + + /* We do not use signal(2) to be sure we do not have SA_RESTART. */ + memset (&act, 0, sizeof (act)); + act.sa_handler = signal_chld; + i = sigemptyset (&act.sa_mask); + assert (i == 0); + act.sa_flags = 0; /* !SA_RESTART */ + i = sigaction (SIGCHLD, &act, NULL); + assert (i == 0); + + i = sigemptyset (&set); + assert (i == 0); + i = sigaddset (&set, SIGCHLD); + assert (i == 0); + i = sigprocmask (SIG_SETMASK, &set, NULL); + assert (i == 0); + + /* With TERMP passed as NULL we get "\n" -> "\r\n". */ + termios.c_iflag = IGNBRK | IGNPAR; + termios.c_oflag = 0; + termios.c_cflag = CS8 | CREAD | CLOCAL | HUPCL | B9600; + termios.c_lflag = IEXTEN | NOFLSH; + memset (termios.c_cc, _POSIX_VDISABLE, sizeof (termios.c_cc)); + termios.c_cc[VTIME] = 0; + termios.c_cc[VMIN ] = 1; + cfmakeraw (&termios); +#ifdef FLUSHO + /* Workaround a readline deadlock bug in _get_tty_settings(). */ + termios.c_lflag &= ~FLUSHO; +#endif + child = forkpty (&amaster, childptyname, &termios, NULL); + switch (child) + { + case -1: + perror ("forkpty(3)"); + exit (EXIT_FAILURE); + case 0: + /* Do not replace STDIN as inferiors query its termios. */ +#if 0 + i = close (STDIN_FILENO); + assert (i == 0); + i = open ("/dev/null", O_RDONLY); + assert (i == STDIN_FILENO); +#endif + + i = sigemptyset (&set); + assert (i == 0); + i = sigprocmask (SIG_SETMASK, &set, NULL); + assert (i == 0); + + /* Do not setpgrp(2) in the parent process as the process-group + is shared for the whole sh(1) pipeline we could be a part + of. The process-group is set according to PID of the first + command in the pipeline. + We would rip even vi(1) in the case of: + ./orphanripper sh -c 'sleep 1&' | vi - + */ + /* Do not setpgrp(2) as our pty would not be ours and we would + get `SIGSTOP' later, particularly after spawning gdb(1). + setsid(3) was already executed by forkpty(3) and it would fail if + executed again. */ + if (getpid() != getpgrp ()) + { + perror ("getpgrp(2)"); + exit (EXIT_FAILURE); + } + execvp (argv[0], argv); + perror ("execvp(2)"); + exit (EXIT_FAILURE); + default: + break; + } + i = fcntl (amaster, F_SETFL, O_RDWR | O_NONBLOCK); + if (i != 0) + { + perror ("fcntl (amaster, F_SETFL, O_NONBLOCK)"); + exit (EXIT_FAILURE); + } + + /* We do not use signal(2) to be sure we do not have SA_RESTART. */ + act.sa_handler = signal_alrm; + i = sigaction (SIGALRM, &act, NULL); + assert (i == 0); + + alarm_orig = alarm (timeout); + assert (alarm_orig == 0); + + i = sigemptyset (&set); + assert (i == 0); + + while (!signal_alrm_hit) + { + struct pollfd pollfd; + + pollfd.fd = amaster; + pollfd.events = POLLIN; + i = ppoll (&pollfd, 1, NULL, &set); + if (i == -1 && errno == EINTR) + { + if (child_exited ()) + break; + /* Non-CHILD child may have exited. */ + continue; + } + assert (i == 1); + /* Data available? Process it first. */ + if (pollfd.revents & POLLIN) + { + if (!read_out (amaster)) + { + fprintf (stderr, "%s: Unexpected EOF\n", progname); + exit (EXIT_FAILURE); + } + } + if (pollfd.revents & POLLHUP) + break; + if ((pollfd.revents &= ~POLLIN) != 0) + { + fprintf (stderr, "%s: ppoll(2): revents 0x%x\n", progname, + (unsigned) pollfd.revents); + exit (EXIT_FAILURE); + } + /* Child exited? */ + if (child_exited ()) + break; + } + + if (signal_alrm_hit) + { + i = kill (child, SIGKILL); + assert (i == 0); + } + else + alarm (0); + + /* WNOHANG still could fail. */ + child_got = waitpid (child, &status, 0); + if (child != child_got) + { + fprintf (stderr, "waitpid (%d) = %d: %m\n", (int) child, (int) child_got); + exit (EXIT_FAILURE); + } + if (signal_alrm_hit) + { + char *buf; + + if (asprintf (&buf, "Timed out after %d seconds", timeout) != -1) + { + print_child_error (buf, argv); + free (buf); + } + rc = 128 + SIGALRM; + } + else if (WIFEXITED (status)) + rc = WEXITSTATUS (status); + else if (WIFSIGNALED (status)) + { + print_child_error (strsignal (WTERMSIG (status)), argv); + rc = 128 + WTERMSIG (status); + } + else if (WIFSTOPPED (status)) + { + fprintf (stderr, "waitpid (%d): WIFSTOPPED - WSTOPSIG is %d\n", + (int) child, WSTOPSIG (status)); + exit (EXIT_FAILURE); + } + else + { + fprintf (stderr, "waitpid (%d): !WIFEXITED (%d)\n", (int) child, status); + exit (EXIT_FAILURE); + } + + /* Not used in fact. */ + i = sigprocmask (SIG_SETMASK, &set, NULL); + assert (i == 0); + + /* Do not unset O_NONBLOCK as a stale child (the whole purpose of this + program) having open its output pty would block us in read_out. */ +#if 0 + i = fcntl (amaster, F_SETFL, O_RDONLY /* !O_NONBLOCK */); + if (i != 0) + { + perror ("fcntl (amaster, F_SETFL, O_RDONLY /* !O_NONBLOCK */)"); + exit (EXIT_FAILURE); + } +#endif + + while (read_out (amaster)); + + /* Do not close the master FD as the child would have `/dev/pts/23 (deleted)' + entries which are not expected (and expecting ` (deleted)' would be + a race. */ +#if 0 + i = close (amaster); + if (i != 0) + { + perror ("close (forkpty ()'s amaster)"); + exit (EXIT_FAILURE); + } +#endif + + return rc; +} + +/* Detected commandline may look weird due to a race: + Original command: + ./orphanripper sh -c 'sleep 1&' & + Correct output: + [1] 29610 + ./orphanripper: Killed -9 orphan PID 29612 (PGID 29611): sleep 1 + Raced output (sh(1) child still did not update its argv[]): + [1] 29613 + ./orphanripper: Killed -9 orphan PID 29615 (PGID 29614): sh -c sleep 1& + We could delay a bit before ripping the children. */ +static const char *read_cmdline (pid_t pid) +{ + char cmdline_fname[32]; + static char cmdline[LINE_MAX]; + int fd; + ssize_t got; + char *s; + + if (snprintf (cmdline_fname, sizeof cmdline_fname, "/proc/%d/cmdline", + (int) pid) < 0) + return NULL; + fd = open (cmdline_fname, O_RDONLY); + if (fd == -1) + { + /* It may have already exited - ENOENT. */ +#if 0 + fprintf (stderr, "%s: open (\"%s\"): %m\n", progname, cmdline_fname); +#endif + return NULL; + } + got = read (fd, cmdline, sizeof (cmdline) - 1); + if (got == -1) + fprintf (stderr, "%s: read (\"%s\"): %m\n", progname, + cmdline_fname); + if (close (fd) != 0) + fprintf (stderr, "%s: close (\"%s\"): %m\n", progname, + cmdline_fname); + if (got < 0) + return NULL; + /* Convert '\0' argument delimiters to spaces. */ + for (s = cmdline; s < cmdline + got; s++) + if (!*s) + *s = ' '; + /* Trim the trailing spaces (typically single '\0'->' '). */ + while (s > cmdline && isspace (s[-1])) + s--; + *s = 0; + return cmdline; +} + +static int dir_scan (const char *dirname, + int (*callback) (struct dirent *dirent, const char *pathname)) +{ + DIR *dir; + struct dirent *dirent; + int rc = 0; + + dir = opendir (dirname); + if (dir == NULL) + { + if (errno == EACCES || errno == ENOENT) + return rc; + fprintf (stderr, "%s: opendir (\"%s\"): %m\n", progname, dirname); + exit (EXIT_FAILURE); + } + while ((errno = 0, dirent = readdir (dir))) + { + char pathname[LINE_MAX]; + int pathname_len; + + pathname_len = snprintf (pathname, sizeof pathname, "%s/%s", + dirname, dirent->d_name); + if (pathname_len <= 0 || pathname_len >= (int) sizeof pathname) + { + fprintf (stderr, "entry file name too long: `%s' / `%s'\n", + dirname, dirent->d_name); + continue; + } + /* RHEL-4.5 on s390x never fills in D_TYPE. */ + if (dirent->d_type == DT_UNKNOWN) + { + struct stat statbuf; + int i; + + /* We are not interested in the /proc/PID/fd/ links targets. */ + i = lstat (pathname, &statbuf); + if (i == -1) + { + if (errno == EACCES || errno == ENOENT) + continue; + fprintf (stderr, "%s: stat (\"%s\"): %m\n", progname, pathname); + exit (EXIT_FAILURE); + } + if (S_ISDIR (statbuf.st_mode)) + dirent->d_type = DT_DIR; + if (S_ISLNK (statbuf.st_mode)) + dirent->d_type = DT_LNK; + /* No other D_TYPE types used in this code. */ + } + rc = (*callback) (dirent, pathname); + if (rc != 0) + { + errno = 0; + break; + } + } + if (errno != 0) + { + fprintf (stderr, "%s: readdir (\"%s\"): %m\n", progname, dirname); + exit (EXIT_FAILURE); + } + if (closedir (dir) != 0) + { + fprintf (stderr, "%s: closedir (\"%s\"): %m\n", progname, dirname); + exit (EXIT_FAILURE); + } + return rc; +} + +static int fd_fs_scan (pid_t pid, int (*func) (pid_t pid, const char *link)) +{ + char dirname[64]; + + if (snprintf (dirname, sizeof dirname, "/proc/%d/fd", (int) pid) < 0) + { + perror ("snprintf(3)"); + exit (EXIT_FAILURE); + } + + int callback (struct dirent *dirent, const char *pathname) + { + char buf[LINE_MAX]; + ssize_t buf_len; + + if ((dirent->d_type != DT_DIR && dirent->d_type != DT_LNK) + || (dirent->d_type == DT_DIR && strcmp (dirent->d_name, ".") != 0 + && strcmp (dirent->d_name, "..") != 0) + || (dirent->d_type == DT_LNK && strspn (dirent->d_name, "0123456789") + != strlen (dirent->d_name))) + { + fprintf (stderr, "Unexpected entry \"%s\" (d_type %u)" + " on readdir (\"%s\"): %m\n", + dirent->d_name, (unsigned) dirent->d_type, dirname); + return 0; + } + if (dirent->d_type == DT_DIR) + return 0; + buf_len = readlink (pathname, buf, sizeof buf - 1); + if (buf_len <= 0 || buf_len >= (ssize_t) sizeof buf - 1) + { + if (errno != ENOENT && errno != EACCES) + fprintf (stderr, "Error reading link \"%s\": %m\n", pathname); + return 0; + } + buf[buf_len] = 0; + return (*func) (pid, buf); + } + + return dir_scan (dirname, callback); +} + +static void pid_fs_scan (void (*func) (pid_t pid, void *data), void *data) +{ + int callback (struct dirent *dirent, const char *pathname) + { + if (dirent->d_type != DT_DIR + || strspn (dirent->d_name, "0123456789") != strlen (dirent->d_name)) + return 0; + (*func) (atoi (dirent->d_name), data); + return 0; + } + + dir_scan ("/proc", callback); +} + +static int rip_check_ptyname (pid_t pid, const char *link) +{ + assert (pid != getpid ()); + + return strcmp (link, childptyname) == 0; +} + +struct pid + { + struct pid *next; + pid_t pid; + }; +static struct pid *pid_list; + +static int pid_found (pid_t pid) +{ + struct pid *entry; + + for (entry = pid_list; entry != NULL; entry = entry->next) + if (entry->pid == pid) + return 1; + return 0; +} + +/* Single pass is not enough, a (multithreaded) process was seen to survive. + Repeated killing of the same process is not enough, zombies can be killed. + */ +static int cleanup_acted; + +static void pid_record (pid_t pid) +{ + struct pid *entry; + + if (pid_found (pid)) + return; + cleanup_acted = 1; + + entry = malloc (sizeof (*entry)); + if (entry == NULL) + { + fprintf (stderr, "%s: malloc: %m\n", progname); + exit (EXIT_FAILURE); + } + entry->pid = pid; + entry->next = pid_list; + pid_list = entry; +} + +static void pid_forall (void (*func) (pid_t pid)) +{ + struct pid *entry; + + for (entry = pid_list; entry != NULL; entry = entry->next) + (*func) (entry->pid); +} + +/* Returns 0 on failure. */ +static pid_t pid_get_parent (pid_t pid) +{ + char fname[64]; + FILE *f; + char line[LINE_MAX]; + pid_t retval = 0; + + if (snprintf (fname, sizeof fname, "/proc/%d/status", (int) pid) < 0) + { + perror ("snprintf(3)"); + exit (EXIT_FAILURE); + } + f = fopen (fname, "r"); + if (f == NULL) + { + return 0; + } + while (errno = 0, fgets (line, sizeof line, f) == line) + { + if (strncmp (line, "PPid:\t", sizeof "PPid:\t" - 1) != 0) + continue; + retval = atoi (line + sizeof "PPid:\t" - 1); + errno = 0; + break; + } + if (errno != 0) + { + fprintf (stderr, "%s: fgets (\"%s\"): %m\n", progname, fname); + exit (EXIT_FAILURE); + } + if (fclose (f) != 0) + { + fprintf (stderr, "%s: fclose (\"%s\"): %m\n", progname, fname); + exit (EXIT_FAILURE); + } + return retval; +} + +static void killtree (pid_t pid); + +static void killtree_pid_fs_scan (pid_t pid, void *data) +{ + pid_t parent_pid = *(pid_t *) data; + + /* Do not optimize it as we could miss some newly spawned processes. + Always traverse all the leaves. */ +#if 0 + /* Optimization. */ + if (pid_found (pid)) + return; +#endif + + if (pid_get_parent (pid) != parent_pid) + return; + + killtree (pid); +} + +static void killtree (pid_t pid) +{ + pid_record (pid); + pid_fs_scan (killtree_pid_fs_scan, &pid); +} + +static void rip_pid_fs_scan (pid_t pid, void *data) +{ + pid_t pgid; + + /* Shouldn't happen. */ + if (pid == getpid ()) + return; + + /* Check both PGID and the stale file descriptors. */ + pgid = getpgid (pid); + if (pgid == child + || fd_fs_scan (pid, rip_check_ptyname) != 0) + killtree (pid); +} + +static void killproc (pid_t pid) +{ + const char *cmdline; + + cmdline = read_cmdline (pid); + /* Avoid printing the message for already gone processes. */ + if (kill (pid, 0) != 0 && errno == ESRCH) + return; + if (cmdline == NULL) + cmdline = ""; + fprintf (stderr, "%s: Killed -9 orphan PID %d: %s\n", progname, (int) pid, cmdline); + if (kill (pid, SIGKILL) == 0) + cleanup_acted = 1; + else if (errno != ESRCH) + fprintf (stderr, "%s: kill (%d, SIGKILL): %m\n", progname, (int) pid); + /* RHEL-3 kernels cannot SIGKILL a `T (stopped)' process. */ + kill (pid, SIGCONT); + /* Do not waitpid(2) as it cannot be our direct descendant and it gets + cleaned up by init(8). */ +#if 0 + pid_t pid_got; + pid_got = waitpid (pid, NULL, 0); + if (pid != pid_got) + { + fprintf (stderr, "%s: waitpid (%d) != %d: %m\n", progname, + (int) pid, (int) pid_got); + return; + } +#endif +} + +static void rip (void) +{ + cleanup_acted = 0; + do + { + if (cleanup_acted) + usleep (1000000 / 10); + cleanup_acted = 0; + pid_fs_scan (rip_pid_fs_scan, NULL); + pid_forall (killproc); + } + while (cleanup_acted); +} + +int main (int argc, char **argv) +{ + int timeout = 0; + int rc; + + progname = *argv++; + argc--; + + if (argc < 1 || strcmp (*argv, "-h") == 0 + || strcmp (*argv, "--help") == 0) + { + puts ("Syntax: orphanripper [-t ] "); + exit (EXIT_FAILURE); + } + if ((*argv)[0] == '-' && (*argv)[1] == 't') + { + char *timeout_s = NULL; + + if ((*argv)[2] == 0) + timeout_s = *++argv; + else if (isdigit ((*argv)[2])) + timeout_s = (*argv) + 2; + if (timeout_s != NULL) + { + long l; + char *endptr; + + argv++; + l = strtol (timeout_s, &endptr, 0); + timeout = l; + if ((endptr != NULL && *endptr != 0) || timeout < 0 || timeout != l) + { + fprintf (stderr, "%s: Invalid timeout value: %s\n", progname, + timeout_s); + exit (EXIT_FAILURE); + } + } + } + + rc = spawn (argv, timeout); + rip (); + return rc; +} diff --git a/SOURCES/gdb-physname-pr11734-test.patch b/SOURCES/gdb-physname-pr11734-test.patch new file mode 100644 index 0000000..e862eea --- /dev/null +++ b/SOURCES/gdb-physname-pr11734-test.patch @@ -0,0 +1,234 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-physname-pr11734-test.patch + +;; Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz). +;;=fedoratest + +http://sourceware.org/ml/gdb-patches/2010-12/msg00263.html + +diff --git a/gdb/testsuite/gdb.cp/pr11734-1.cc b/gdb/testsuite/gdb.cp/pr11734-1.cc +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr11734-1.cc +@@ -0,0 +1,30 @@ ++/* 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 . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@gnu.org */ ++ ++#include "pr11734.h" ++ ++int ++main () ++{ ++ pr11734 *p = new pr11734; ++ p->foo (); ++ return 0; ++} ++ +diff --git a/gdb/testsuite/gdb.cp/pr11734-2.cc b/gdb/testsuite/gdb.cp/pr11734-2.cc +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr11734-2.cc +@@ -0,0 +1,27 @@ ++/* 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 . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@gnu.org */ ++ ++#include "pr11734.h" ++ ++void ++pr11734::foo(void) ++{ ++} ++ +diff --git a/gdb/testsuite/gdb.cp/pr11734-3.cc b/gdb/testsuite/gdb.cp/pr11734-3.cc +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr11734-3.cc +@@ -0,0 +1,27 @@ ++/* 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 . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@gnu.org */ ++ ++#include "pr11734.h" ++ ++void ++pr11734::foo (int a) ++{ ++} ++ +diff --git a/gdb/testsuite/gdb.cp/pr11734-4.cc b/gdb/testsuite/gdb.cp/pr11734-4.cc +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr11734-4.cc +@@ -0,0 +1,27 @@ ++/* 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 . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@gnu.org */ ++ ++#include "pr11734.h" ++ ++void ++pr11734::foo (char *a) ++{ ++} ++ +diff --git a/gdb/testsuite/gdb.cp/pr11734.exp b/gdb/testsuite/gdb.cp/pr11734.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr11734.exp +@@ -0,0 +1,55 @@ ++# Copyright 2010 Free Software Foundation, Inc. ++# ++# Contributed by Red Hat, originally written by Keith Seitz. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# This file is part of the gdb testsuite. ++ ++if { [skip_cplus_tests] } { continue } ++ ++set testfile "pr11734" ++set class $testfile ++ ++set srcfiles {} ++for {set i 1} {$i < 5} {incr i} { ++ lappend srcfiles $testfile-$i.cc ++} ++ ++prepare_for_testing pr11734 $testfile $srcfiles {c++ debug} ++ ++if {![runto_main]} { ++ perror "couldn't run to breakpoint" ++ continue ++} ++ ++# An array holding the overload types for the method pr11734::foo. The ++# first element is the overloaded method parameter. The second element ++# is the expected source file number, e.g. "pr11734-?.cc". ++array set tests { ++ "char*" 4 ++ "int" 3 ++ "" 2 ++} ++ ++# Test each overload instance twice: once quoted, once unquoted ++foreach ovld [array names tests] { ++ set method "${class}::foo\($ovld\)" ++ set result "Breakpoint (\[0-9\]).*file .*/$class-$tests($ovld).*" ++ gdb_test "break $method" $result ++ gdb_test "break '$method'" $result ++} ++ ++gdb_exit ++return 0 +diff --git a/gdb/testsuite/gdb.cp/pr11734.h b/gdb/testsuite/gdb.cp/pr11734.h +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr11734.h +@@ -0,0 +1,28 @@ ++/* 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 . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@gnu.org */ ++ ++class pr11734 ++{ ++ public: ++ void foo (); ++ void foo (int); ++ void foo (char *); ++}; ++ diff --git a/SOURCES/gdb-physname-pr12273-test.patch b/SOURCES/gdb-physname-pr12273-test.patch new file mode 100644 index 0000000..6c943ad --- /dev/null +++ b/SOURCES/gdb-physname-pr12273-test.patch @@ -0,0 +1,103 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-physname-pr12273-test.patch + +;; Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz). +;;=fedoratest + +http://sourceware.org/ml/gdb-patches/2010-12/msg00264.html + +diff --git a/gdb/testsuite/gdb.cp/pr12273.cc b/gdb/testsuite/gdb.cp/pr12273.cc +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr12273.cc +@@ -0,0 +1,37 @@ ++/* This test case 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 . */ ++ ++template ++class GDB ++{ ++ public: ++ static int simple (void) { return 0; } ++ static int harder (T a) { return 1; } ++ template ++ static X even_harder (T a) { return static_cast (a); } ++ int operator == (GDB const& other) ++ { return 1; } ++}; ++ ++int main(int argc, char **argv) ++{ ++ GDB a, b; ++ if (a == b) ++ return GDB::harder('a') + GDB::harder(3) ++ + GDB::even_harder ('a'); ++ return GDB::simple (); ++} +diff --git a/gdb/testsuite/gdb.cp/pr12273.exp b/gdb/testsuite/gdb.cp/pr12273.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr12273.exp +@@ -0,0 +1,46 @@ ++# Copyright 2010 Free Software Foundation, Inc. ++# ++# Contributed by Red Hat, originally written by Keith Seitz. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# This file is part of the gdb testsuite. ++ ++if {[skip_cplus_tests]} { continue } ++ ++set testfile "pr12273" ++# Do NOT compile with debug flag. ++prepare_for_testing pr12273 $testfile $testfile.cc {c++} ++ ++gdb_test_no_output "set language c++" ++ ++# A list of minimal symbol names to check. ++# Note that GDB::even_harder(char) is quoted and includes ++# the return type. This is necessary because this is the demangled name ++# of the minimal symbol. ++set min_syms [list \ ++ "GDB::operator ==" \ ++ "GDB::operator==(GDB const&)" \ ++ "GDB::harder(char)" \ ++ "GDB::harder(int)" \ ++ {"int GDB::even_harder(char)"} \ ++ "GDB::simple()"] ++ ++foreach sym $min_syms { ++ if {[gdb_breakpoint $sym]} { ++ pass "setting breakpoint at $sym" ++ } ++} ++ ++gdb_exit diff --git a/SOURCES/gdb-ppc-power7-test.patch b/SOURCES/gdb-ppc-power7-test.patch new file mode 100644 index 0000000..3ca7667 --- /dev/null +++ b/SOURCES/gdb-ppc-power7-test.patch @@ -0,0 +1,303 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-ppc-power7-test.patch + +;; Test power7 ppc disassembly. +;;=fedoratest + +diff --git a/gdb/testsuite/gdb.arch/powerpc-power7rh.exp b/gdb/testsuite/gdb.arch/powerpc-power7rh.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-power7rh.exp +@@ -0,0 +1,178 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# Test PowerPC Power7 instructions disassembly. ++ ++if {![istarget "powerpc*-*-*"]} then { ++ verbose "Skipping PowerPC Power7 instructions disassembly." ++ return ++} ++ ++set testfile "powerpc-power7rh" ++set srcfile ${testfile}.s ++set objfile [standard_output_file ${testfile}.o] ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" } { ++ untested "PowerPC Power7 instructions disassembly" ++ return -1 ++} ++ ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${objfile} ++ ++ ++# Disassemble the function. ++ ++set test "disass func" ++gdb_test_multiple $test $test { ++ -re "\r\nDump of assembler code for function func:(\r\n.*\r\n)End of assembler dump.\r\n$gdb_prompt $" { ++ set func $expect_out(1,string) ++ pass $test ++ } ++} ++ ++proc instr_to_patt {offset instr} { ++ # 0x0000000000000018 : stxvd2x vs43,r4,r5 ++ return ".*\r\n\[ \t\]*[string map {0x 0x0*} $offset] <(func)?\\+?\[0-9\]*>:\[ \t\]*[string map [list { } "\[ \t\]+" . {\.}] $instr]\[ \t\]*\r\n.*" ++} ++ ++# KFAIL strings would not exist if -Many would print the same as -Mpower7. ++# That means the power7 form should be the preferred one. ++# http://sourceware.org/ml/gdb-patches/2009-03/threads.html#00020 ++ ++proc func_check {offset instr {kfail ""}} { ++ global func ++ ++ set test "Found $offset: $instr" ++ if [regexp -nocase -line [instr_to_patt $offset $instr] $func] { ++ pass $test ++ } elseif {$kfail != "" && [regexp -nocase -line [instr_to_patt $offset $kfail] $func]} { ++ kfail gdb/NNNN $test ++ } else { ++ fail $test ++ } ++} ++ ++func_check 0x0 "lxvd2x vs3,r4,r5" ++# [PATCH] Remove support for POWER7 VSX load/store with update instructions ++# http://sourceware.org/ml/binutils/2009-09/msg00680.html ++# http://sourceware.org/ml/binutils-cvs/2009-09/msg00331.html ++func_check 0x4 "lxvb16x vs3,r4,r5" ++func_check 0x8 "lxvd2x vs43,r4,r5" ++func_check 0xc "lxvb16x vs43,r4,r5" ++func_check 0x10 "stxvd2x vs3,r4,r5" ++func_check 0x14 "stxvb16x vs3,r4,r5" ++func_check 0x18 "stxvd2x vs43,r4,r5" ++func_check 0x1c "stxvb16x vs43,r4,r5" ++func_check 0x20 "xxmrghd vs3,vs4,vs5" ++func_check 0x24 "xxmrghd vs43,vs44,vs45" ++func_check 0x28 "xxmrgld vs3,vs4,vs5" ++func_check 0x2c "xxmrgld vs43,vs44,vs45" ++func_check 0x30 "xxmrghd vs3,vs4,vs5" ++func_check 0x34 "xxmrghd vs43,vs44,vs45" ++func_check 0x38 "xxmrgld vs3,vs4,vs5" ++func_check 0x3c "xxmrgld vs43,vs44,vs45" ++func_check 0x40 "xxpermdi vs3,vs4,vs5,1" ++func_check 0x44 "xxpermdi vs43,vs44,vs45,1" ++func_check 0x48 "xxpermdi vs3,vs4,vs5,2" ++func_check 0x4c "xxpermdi vs43,vs44,vs45,2" ++func_check 0x50 "xvmovdp vs3,vs4" ++func_check 0x54 "xvmovdp vs43,vs44" ++func_check 0x58 "xvmovdp vs3,vs4" ++func_check 0x5c "xvmovdp vs43,vs44" ++func_check 0x60 "xvcpsgndp vs3,vs4,vs5" ++func_check 0x64 "xvcpsgndp vs43,vs44,vs45" ++func_check 0x68 "wait" ++func_check 0x6c "wait" ++func_check 0x70 "waitrsv" ++func_check 0x74 "waitrsv" ++func_check 0x78 "waitimpl" ++func_check 0x7c "waitimpl" ++func_check 0x80 "doze" ++func_check 0x84 "nap" ++func_check 0x88 "sleep" ++func_check 0x8c "rvwinkle" ++func_check 0x90 "prtyw r3,r4" ++func_check 0x94 "prtyd r13,r14" ++func_check 0x98 "mfcfar r10" "mfspr r10,28" ++func_check 0x9c "mtcfar r11" "mtspr 28,r11" ++func_check 0xa0 "cmpb r3,r4,r5" ++func_check 0xa4 "lwzcix r10,r11,r12" ++func_check 0xa8 "dadd f16,f17,f18" ++func_check 0xac "daddq f20,f22,f24" ++func_check 0xb0 "dss 3" ++func_check 0xb4 "dssall" ++func_check 0xb8 "dst r5,r4,1" ++func_check 0xbc "dstt r8,r7,0" ++func_check 0xc0 "dstst r5,r6,3" ++func_check 0xc4 "dststt r4,r5,2" ++func_check 0xc8 "divwe r10,r11,r12" ++func_check 0xcc "divwe. r11,r12,r13" ++func_check 0xd0 "divweo r12,r13,r14" ++func_check 0xd4 "divweo. r13,r14,r15" ++func_check 0xd8 "divweu r10,r11,r12" ++func_check 0xdc "divweu. r11,r12,r13" ++func_check 0xe0 "divweuo r12,r13,r14" ++func_check 0xe4 "divweuo. r13,r14,r15" ++func_check 0xe8 "bpermd r7,r17,r27" ++func_check 0xec "popcntw r10,r20" ++func_check 0xf0 "popcntd r10,r20" ++func_check 0xf4 "ldbrx r20,r21,r22" ++func_check 0xf8 "stdbrx r20,r21,r22" ++func_check 0xfc "lfiwzx f10,0,r10" ++func_check 0x100 "lfiwzx f10,r9,r10" ++func_check 0x104 "fcfids f4,f5" ++func_check 0x108 "fcfids. f4,f5" ++func_check 0x10c "fcfidus f4,f5" ++func_check 0x110 "fcfidus. f4,f5" ++func_check 0x114 "fctiwu f4,f5" ++func_check 0x118 "fctiwu. f4,f5" ++func_check 0x11c "fctiwuz f4,f5" ++func_check 0x120 "fctiwuz. f4,f5" ++func_check 0x124 "fctidu f4,f5" ++func_check 0x128 "fctidu. f4,f5" ++func_check 0x12c "fctiduz f4,f5" ++func_check 0x130 "fctiduz. f4,f5" ++func_check 0x134 "fcfidu f4,f5" ++func_check 0x138 "fcfidu. f4,f5" ++func_check 0x13c "ftdiv cr0,f10,f11" ++func_check 0x140 "ftdiv cr7,f10,f11" ++func_check 0x144 "ftsqrt cr0,f10" ++func_check 0x148 "ftsqrt cr7,f10" ++func_check 0x14c "dcbtt r8,r9" "dcbt 16,r8,r9" ++func_check 0x150 "dcbtstt r8,r9" "dcbtst 16,r8,r9" ++func_check 0x154 "dcffix f10,f12" ++func_check 0x158 "dcffix. f20,f22" ++func_check 0x15c "lbarx r10,r11,r12" ++func_check 0x160 "lbarx r10,r11,r12" ++func_check 0x164 "lbarx r10,r11,r12,1" ++func_check 0x168 "lharx r20,r21,r22" ++func_check 0x16c "lharx r20,r21,r22" ++func_check 0x170 "lharx r20,r21,r22,1" ++func_check 0x174 "stbcx. r10,r11,r12" ++func_check 0x178 "sthcx. r10,r11,r12" ++func_check 0x17c "fre f14,f15" ++func_check 0x180 "fre. f14,f15" ++func_check 0x184 "fres f14,f15" ++func_check 0x188 "fres. f14,f15" ++func_check 0x18c "frsqrte f14,f15" ++func_check 0x190 "frsqrte. f14,f15" ++func_check 0x194 "frsqrtes f14,f15" ++func_check 0x198 "frsqrtes. f14,f15" ++func_check 0x19c "isel r2,r3,r4,28" +diff --git a/gdb/testsuite/gdb.arch/powerpc-power7rh.s b/gdb/testsuite/gdb.arch/powerpc-power7rh.s +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-power7rh.s +@@ -0,0 +1,107 @@ ++ .text ++ .globl func ++func: ++ .long 0x7c642e98 /* 0: lxvd2x vs3,r4,r5 */ ++ .long 0x7c642ed8 /* 4: lxvd2ux vs3,r4,r5 */ ++ .long 0x7d642e99 /* 8: lxvd2x vs43,r4,r5 */ ++ .long 0x7d642ed9 /* c: lxvd2ux vs43,r4,r5 */ ++ .long 0x7c642f98 /* 10: stxvd2x vs3,r4,r5 */ ++ .long 0x7c642fd8 /* 14: stxvd2ux vs3,r4,r5 */ ++ .long 0x7d642f99 /* 18: stxvd2x vs43,r4,r5 */ ++ .long 0x7d642fd9 /* 1c: stxvd2ux vs43,r4,r5 */ ++ .long 0xf0642850 /* 20: xxmrghd vs3,vs4,vs5 */ ++ .long 0xf16c6857 /* 24: xxmrghd vs43,vs44,vs45 */ ++ .long 0xf0642b50 /* 28: xxmrgld vs3,vs4,vs5 */ ++ .long 0xf16c6b57 /* 2c: xxmrgld vs43,vs44,vs45 */ ++ .long 0xf0642850 /* 30: xxmrghd vs3,vs4,vs5 */ ++ .long 0xf16c6857 /* 34: xxmrghd vs43,vs44,vs45 */ ++ .long 0xf0642b50 /* 38: xxmrgld vs3,vs4,vs5 */ ++ .long 0xf16c6b57 /* 3c: xxmrgld vs43,vs44,vs45 */ ++ .long 0xf0642950 /* 40: xxpermdi vs3,vs4,vs5,1 */ ++ .long 0xf16c6957 /* 44: xxpermdi vs43,vs44,vs45,1 */ ++ .long 0xf0642a50 /* 48: xxpermdi vs3,vs4,vs5,2 */ ++ .long 0xf16c6a57 /* 4c: xxpermdi vs43,vs44,vs45,2 */ ++ .long 0xf0642780 /* 50: xvmovdp vs3,vs4 */ ++ .long 0xf16c6787 /* 54: xvmovdp vs43,vs44 */ ++ .long 0xf0642780 /* 58: xvmovdp vs3,vs4 */ ++ .long 0xf16c6787 /* 5c: xvmovdp vs43,vs44 */ ++ .long 0xf0642f80 /* 60: xvcpsgndp vs3,vs4,vs5 */ ++ .long 0xf16c6f87 /* 64: xvcpsgndp vs43,vs44,vs45 */ ++ .long 0x7c00007c /* 68: wait */ ++ .long 0x7c00007c /* 6c: wait */ ++ .long 0x7c20007c /* 70: waitrsv */ ++ .long 0x7c20007c /* 74: waitrsv */ ++ .long 0x7c40007c /* 78: waitimpl */ ++ .long 0x7c40007c /* 7c: waitimpl */ ++ .long 0x4c000324 /* 80: doze */ ++ .long 0x4c000364 /* 84: nap */ ++ .long 0x4c0003a4 /* 88: sleep */ ++ .long 0x4c0003e4 /* 8c: rvwinkle */ ++ .long 0x7c830134 /* 90: prtyw r3,r4 */ ++ .long 0x7dcd0174 /* 94: prtyd r13,r14 */ ++ .long 0x7d5c02a6 /* 98: mfcfar r10 */ ++ .long 0x7d7c03a6 /* 9c: mtcfar r11 */ ++ .long 0x7c832bf8 /* a0: cmpb r3,r4,r5 */ ++ .long 0x7d4b662a /* a4: lwzcix r10,r11,r12 */ ++ .long 0xee119004 /* a8: dadd f16,f17,f18 */ ++ .long 0xfe96c004 /* ac: daddq f20,f22,f24 */ ++ .long 0x7c60066c /* b0: dss 3 */ ++ .long 0x7e00066c /* b4: dssall */ ++ .long 0x7c2522ac /* b8: dst r5,r4,1 */ ++ .long 0x7e083aac /* bc: dstt r8,r7,0 */ ++ .long 0x7c6532ec /* c0: dstst r5,r6,3 */ ++ .long 0x7e442aec /* c4: dststt r4,r5,2 */ ++ .long 0x7d4b6356 /* c8: divwe r10,r11,r12 */ ++ .long 0x7d6c6b57 /* cc: divwe. r11,r12,r13 */ ++ .long 0x7d8d7756 /* d0: divweo r12,r13,r14 */ ++ .long 0x7dae7f57 /* d4: divweo. r13,r14,r15 */ ++ .long 0x7d4b6316 /* d8: divweu r10,r11,r12 */ ++ .long 0x7d6c6b17 /* dc: divweu. r11,r12,r13 */ ++ .long 0x7d8d7716 /* e0: divweuo r12,r13,r14 */ ++ .long 0x7dae7f17 /* e4: divweuo. r13,r14,r15 */ ++ .long 0x7e27d9f8 /* e8: bpermd r7,r17,r27 */ ++ .long 0x7e8a02f4 /* ec: popcntw r10,r20 */ ++ .long 0x7e8a03f4 /* f0: popcntd r10,r20 */ ++ .long 0x7e95b428 /* f4: ldbrx r20,r21,r22 */ ++ .long 0x7e95b528 /* f8: stdbrx r20,r21,r22 */ ++ .long 0x7d4056ee /* fc: lfiwzx f10,0,r10 */ ++ .long 0x7d4956ee /* 100: lfiwzx f10,r9,r10 */ ++ .long 0xec802e9c /* 104: fcfids f4,f5 */ ++ .long 0xec802e9d /* 108: fcfids. f4,f5 */ ++ .long 0xec802f9c /* 10c: fcfidus f4,f5 */ ++ .long 0xec802f9d /* 110: fcfidus. f4,f5 */ ++ .long 0xfc80291c /* 114: fctiwu f4,f5 */ ++ .long 0xfc80291d /* 118: fctiwu. f4,f5 */ ++ .long 0xfc80291e /* 11c: fctiwuz f4,f5 */ ++ .long 0xfc80291f /* 120: fctiwuz. f4,f5 */ ++ .long 0xfc802f5c /* 124: fctidu f4,f5 */ ++ .long 0xfc802f5d /* 128: fctidu. f4,f5 */ ++ .long 0xfc802f5e /* 12c: fctiduz f4,f5 */ ++ .long 0xfc802f5f /* 130: fctiduz. f4,f5 */ ++ .long 0xfc802f9c /* 134: fcfidu f4,f5 */ ++ .long 0xfc802f9d /* 138: fcfidu. f4,f5 */ ++ .long 0xfc0a5900 /* 13c: ftdiv cr0,f10,f11 */ ++ .long 0xff8a5900 /* 140: ftdiv cr7,f10,f11 */ ++ .long 0xfc005140 /* 144: ftsqrt cr0,f10 */ ++ .long 0xff805140 /* 148: ftsqrt cr7,f10 */ ++ .long 0x7e084a2c /* 14c: dcbtt r8,r9 */ ++ .long 0x7e0849ec /* 150: dcbtstt r8,r9 */ ++ .long 0xed406644 /* 154: dcffix f10,f12 */ ++ .long 0xee80b645 /* 158: dcffix. f20,f22 */ ++ .long 0x7d4b6068 /* 15c: lbarx r10,r11,r12 */ ++ .long 0x7d4b6068 /* 160: lbarx r10,r11,r12 */ ++ .long 0x7d4b6069 /* 164: lbarx r10,r11,r12,1 */ ++ .long 0x7e95b0e8 /* 168: lharx r20,r21,r22 */ ++ .long 0x7e95b0e8 /* 16c: lharx r20,r21,r22 */ ++ .long 0x7e95b0e9 /* 170: lharx r20,r21,r22,1 */ ++ .long 0x7d4b656d /* 174: stbcx. r10,r11,r12 */ ++ .long 0x7d4b65ad /* 178: sthcx. r10,r11,r12 */ ++ .long 0xfdc07830 /* 17c: fre f14,f15 */ ++ .long 0xfdc07831 /* 180: fre. f14,f15 */ ++ .long 0xedc07830 /* 184: fres f14,f15 */ ++ .long 0xedc07831 /* 188: fres. f14,f15 */ ++ .long 0xfdc07834 /* 18c: frsqrte f14,f15 */ ++ .long 0xfdc07835 /* 190: frsqrte. f14,f15 */ ++ .long 0xedc07834 /* 194: frsqrtes f14,f15 */ ++ .long 0xedc07835 /* 198: frsqrtes. f14,f15 */ ++ .long 0x7c43271e /* 19c: isel r2,r3,r4,28 */ diff --git a/SOURCES/gdb-python-gil.patch b/SOURCES/gdb-python-gil.patch new file mode 100644 index 0000000..9ff2e45 --- /dev/null +++ b/SOURCES/gdb-python-gil.patch @@ -0,0 +1,241 @@ +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-python-gil.patch + +;; Fix Python GIL with gdb.execute("continue") (Phil Muldoon, BZ 1116957). +;;=push + +diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi +--- a/gdb/doc/python.texi ++++ b/gdb/doc/python.texi +@@ -232,6 +232,14 @@ returned as a string. The default is @code{False}, in which case the + return value is @code{None}. If @var{to_string} is @code{True}, the + @value{GDBN} virtual terminal will be temporarily set to unlimited width + and height, and its pagination will be disabled; @pxref{Screen Size}. ++ ++The @var{release_gil} flag specifies whether @value{GDBN} ought to ++release the Python GIL before executing the command. This is useful ++in multi-threaded Python programs where by default the Python ++interpreter will acquire the GIL and lock other threads from ++executing. After the command has completed executing in @value{GDBN} ++the Python GIL is reacquired. This flag must be a boolean value. If ++omitted, it defaults to @code{False}. + @end defun + + @findex gdb.breakpoints +diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h +--- a/gdb/python/python-internal.h ++++ b/gdb/python/python-internal.h +@@ -148,6 +148,8 @@ typedef int Py_ssize_t; + #define PyGILState_Release(ARG) ((void)(ARG)) + #define PyEval_InitThreads() + #define PyThreadState_Swap(ARG) ((void)(ARG)) ++#define PyEval_SaveThread() ((void)(ARG)) ++#define PyEval_RestoreThread(ARG) ((void)(ARG)) + #define PyEval_ReleaseLock() + #endif + +diff --git a/gdb/python/python.c b/gdb/python/python.c +--- a/gdb/python/python.c ++++ b/gdb/python/python.c +@@ -556,12 +556,16 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) + { + const char *arg; + PyObject *from_tty_obj = NULL, *to_string_obj = NULL; +- int from_tty, to_string; +- static const char *keywords[] = { "command", "from_tty", "to_string", NULL }; ++ int from_tty, to_string, release_gil; ++ static const char *keywords[] = {"command", "from_tty", "to_string", "release_gil", NULL }; ++ PyObject *release_gil_obj = NULL; ++ /* Initialize it just to avoid a GCC false warning. */ ++ PyThreadState *state = NULL; + +- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg, ++ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!O!", keywords, &arg, + &PyBool_Type, &from_tty_obj, +- &PyBool_Type, &to_string_obj)) ++ &PyBool_Type, &to_string_obj, ++ &PyBool_Type, &release_gil_obj)) + return NULL; + + from_tty = 0; +@@ -582,6 +586,15 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) + to_string = cmp; + } + ++ release_gil = 0; ++ if (release_gil_obj) ++ { ++ int cmp = PyObject_IsTrue (release_gil_obj); ++ if (cmp < 0) ++ return NULL; ++ release_gil = cmp; ++ } ++ + std::string to_string_res; + + TRY +@@ -602,6 +615,13 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) + + counted_command_line lines = read_command_lines_1 (reader, 1, nullptr); + ++ /* In the case of long running GDB commands, allow the user to ++ release the Python GIL acquired by Python. Restore the GIL ++ after the command has completed before handing back to ++ Python. */ ++ if (release_gil) ++ state = PyEval_SaveThread(); ++ + scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0); + + scoped_restore save_uiout = make_scoped_restore (¤t_uiout); +@@ -617,10 +637,22 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) + from_tty); + else + execute_control_commands (lines.get (), from_tty); ++ ++ /* Reacquire the GIL if it was released earlier. */ ++ if (release_gil) ++ PyEval_RestoreThread (state); + } + CATCH (except, RETURN_MASK_ALL) + { +- GDB_PY_HANDLE_EXCEPTION (except); ++ if (except.reason < 0) ++ { ++ /* Reacquire the GIL if it was released earlier. */ ++ if (release_gil) ++ PyEval_RestoreThread (state); ++ ++ gdbpy_convert_exception (except); ++ return NULL; ++ } + } + END_CATCH + +diff --git a/gdb/testsuite/gdb.python/py-gil-mthread.c b/gdb/testsuite/gdb.python/py-gil-mthread.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/py-gil-mthread.c +@@ -0,0 +1,13 @@ ++#include ++#include ++ ++int ++main (void) ++{ ++ int i; ++ for (i = 0; i < 10; i++) ++ { ++ sleep (1); /* break-here */ ++ printf ("Sleeping %d\n", i); ++ } ++} +diff --git a/gdb/testsuite/gdb.python/py-gil-mthread.exp b/gdb/testsuite/gdb.python/py-gil-mthread.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/py-gil-mthread.exp +@@ -0,0 +1,69 @@ ++# 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 .c .py ++set executable $testfile ++ ++if { [prepare_for_testing $testfile.exp $executable $srcfile] } { ++ return -1 ++} ++ ++# Skip all tests if Python scripting is not enabled. ++if { [skip_python_tests] } { continue } ++ ++if ![runto_main] { ++ return -1 ++} ++ ++gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"] temporary ++gdb_continue_to_breakpoint "break-here" ".* break-here .*" ++ ++set test "response" ++set timeout 60 ++set sleeping_last -1 ++set hello_last 0 ++set minimal 5 ++gdb_test_multiple "python exec (open ('$srcdir/$subdir/$srcfile2').read ())" $test { ++ -re "Error: unable to start thread\r\n" { ++ fail $test ++ # Not $gdb_prompt-synced! ++ } ++ -re "Sleeping (\[0-9\]+)\r\n" { ++ set n $expect_out(1,string) ++ if { $sleeping_last + 1 != $n } { ++ fail $test ++ } else { ++ set sleeping_last $n ++ if { $sleeping_last >= $minimal && $hello_last >= $minimal } { ++ pass $test ++ } else { ++ exp_continue ++ } ++ } ++ } ++ -re "Hello \\( (\[0-9\]+) \\)\r\n" { ++ set n $expect_out(1,string) ++ if { $hello_last + 1 != $n } { ++ fail $test ++ } else { ++ set hello_last $n ++ if { $sleeping_last >= $minimal && $hello_last >= $minimal } { ++ pass $test ++ } else { ++ exp_continue ++ } ++ } ++ } ++} +diff --git a/gdb/testsuite/gdb.python/py-gil-mthread.py b/gdb/testsuite/gdb.python/py-gil-mthread.py +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/py-gil-mthread.py +@@ -0,0 +1,28 @@ ++try: ++ import thread ++except: ++ import _thread ++import time ++import gdb ++ ++# Define a function for the thread ++def print_thread_hello(): ++ count = 0 ++ while count < 10: ++ time.sleep(1) ++ count += 1 ++ print ("Hello ( %d )" % count) ++ ++# Create a threads a continue ++try: ++ thread.start_new_thread (print_thread_hello, ()) ++ gdb.execute ("continue", release_gil=True) ++except: ++ try: ++ _thread.start_new_thread (print_thread_hello, ()) ++ gdb.execute ("continue", release_gil=True) ++ except: ++ print ("Error: unable to start thread") ++ ++while 1: ++ pass diff --git a/SOURCES/gdb-readline62-ask-more-rh.patch b/SOURCES/gdb-readline62-ask-more-rh.patch new file mode 100644 index 0000000..a1f1171 --- /dev/null +++ b/SOURCES/gdb-readline62-ask-more-rh.patch @@ -0,0 +1,25 @@ +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-readline62-ask-more-rh.patch + +;; Work around readline-6.2 incompatibility not asking for --more-- (BZ 701131). +;;=fedora + +diff --git a/gdb/event-top.c b/gdb/event-top.c +--- a/gdb/event-top.c ++++ b/gdb/event-top.c +@@ -1183,6 +1183,13 @@ gdb_setup_readline (int editing) + { + struct ui *ui = current_ui; + ++#ifdef NEED_RL_STATE_FEDORA_GDB ++ /* 6.2 regression: no longed asks for --more-- ++ gdb.base/readline-ask.exp ++ https://bugzilla.redhat.com/show_bug.cgi?id=701131 */ ++ RL_SETSTATE (RL_STATE_FEDORA_GDB); ++#endif ++ + /* This function is a noop for the sync case. The assumption is + that the sync setup is ALL done in gdb_init, and we would only + mess it up here. The sync stuff should really go away over diff --git a/SOURCES/gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch b/SOURCES/gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch new file mode 100644 index 0000000..20e5f75 --- /dev/null +++ b/SOURCES/gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch @@ -0,0 +1,83 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch + +;; Testcase for `Setting solib-absolute-prefix breaks vDSO' (BZ 818343). +;;=fedoratest + +diff --git a/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c b/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c +@@ -0,0 +1,26 @@ ++/* Copyright (C) 2012 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++#include ++ ++int ++main (int argc, char *argv[]) ++{ ++ printf ("Hello, World.\n"); ++ abort (); ++} +diff --git a/gdb/testsuite/gdb.base/set-solib-absolute-prefix.exp b/gdb/testsuite/gdb.base/set-solib-absolute-prefix.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/set-solib-absolute-prefix.exp +@@ -0,0 +1,39 @@ ++# Copyright 2012 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile "set-solib-absolute-prefix" ++set srcfile ${testfile}.c ++ ++# It is necessary to verify if the binary is 32-bit, so that the system ++# call `__kernel_vsyscall' originates from vDSO. ++ ++if { ![is_ilp32_target] } { ++ return -1 ++} ++ ++if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { ++ return -1 ++} ++ ++if { ![runto_main] } { ++ return -1 ++} ++ ++gdb_test "continue" "Program received signal SIGABRT, Aborted.*" \ ++ "continue until abort" ++gdb_test "set solib-absolute-prefix /BOGUS_DIRECT" \ ++ ".*warning: Unable to find dynamic linker breakpoint function.*" \ ++ "set solib-absolute-prefix" ++gdb_test "bt" "__kernel_vsyscall.*" "backtrace with __kernel_vsyscall" diff --git a/SOURCES/gdb-rhbz1007614-memleak-infpy_read_memory-test.patch b/SOURCES/gdb-rhbz1007614-memleak-infpy_read_memory-test.patch new file mode 100644 index 0000000..4d05ba5 --- /dev/null +++ b/SOURCES/gdb-rhbz1007614-memleak-infpy_read_memory-test.patch @@ -0,0 +1,170 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1007614-memleak-infpy_read_memory-test.patch + +;; Fix 'memory leak in infpy_read_memory()' (RH BZ 1007614) +;;=fedoratest + +Original message by Tom Tromey: + + + Message-ID: <871uoc1va3.fsf@fleche.redhat.com> + +Comment from Sergio Durigan Junior: + + In order to correctly test this patch, I wrote a testcase based on Jan + Kratochvil's . The + testcase, which can be seen below, tests GDB in order to see if the + amount of memory being leaked is minimal, as requested in the bugzilla. + It is hard to define what "minimum" is, so I ran the testcase on all + supported RHEL architectures and came up with an average. + +commit cc0265cdda9dc7e8665e8bfcf5b4477489daf27c +Author: Tom Tromey +Date: Wed Mar 28 17:38:08 2012 +0000 + + * python/py-inferior.c (infpy_read_memory): Remove cleanups and + explicitly free 'buffer' on exit paths. Decref 'membuf_object' + before returning. + +diff --git a/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.c b/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.c +@@ -0,0 +1,27 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2014 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++static struct x ++ { ++ char unsigned u[4096]; ++ } x, *px = &x; ++ ++int ++main (int argc, char *argv[]) ++{ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.exp b/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.exp +@@ -0,0 +1,68 @@ ++# Copyright 2014 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile py-gdb-rhbz1007614-memleak-infpy_read_memory ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++ ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { ++ return -1 ++} ++ ++if { [skip_python_tests] } { continue } ++ ++set pid_of_gdb [exp_pid -i [board_info host fileid]] ++ ++proc memory_v_pages_get {} { ++ global pid_of_gdb ++ 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 ++} ++ ++if { ![runto_main] } { ++ untested $testfile.exp ++ return -1 ++} ++ ++set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py] ++ ++gdb_test "source ${remote_python_file}" "" ++ ++gdb_test "hello-world" "" ++ ++set kbytes_before [memory_v_pages_get] ++verbose -log "kbytes_before = $kbytes_before" ++ ++gdb_test "hello-world" "" ++ ++set kbytes_after [memory_v_pages_get] ++verbose -log "kbytes_after = $kbytes_after" ++ ++set kbytes_diff [expr $kbytes_after - $kbytes_before] ++verbose -log "kbytes_diff = $kbytes_diff" ++ ++# The value "1000" was calculated by running a few GDB sessions with this ++# testcase, and seeing how much (in average) the memory consumption ++# increased after the "hello-world" command issued above. The average ++# was around 500 bytes, so I chose 1000 as a high estimate. ++if { $kbytes_diff > 1000 } { ++ fail "there is a memory leak on GDB (RHBZ 1007614)" ++} else { ++ pass "there is not a memory leak on GDB (RHBZ 1007614)" ++} +diff --git a/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.py b/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.py +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.py +@@ -0,0 +1,30 @@ ++# 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 . ++ ++class HelloWorld (gdb.Command): ++ """Greet the whole world.""" ++ ++ def __init__ (self): ++ super (HelloWorld, self).__init__ ("hello-world", ++ gdb.COMMAND_OBSCURE) ++ ++ def invoke (self, arg, from_tty): ++ px = gdb.parse_and_eval("px") ++ core = gdb.inferiors()[0] ++ for i in range(256 * 1024): ++ chunk = core.read_memory(px, 4096) ++ print "Hello, World!" ++ ++HelloWorld () diff --git a/SOURCES/gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch b/SOURCES/gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch new file mode 100644 index 0000000..d92bfc3 --- /dev/null +++ b/SOURCES/gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch @@ -0,0 +1,235 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch + +;; Fix '[ppc64] and [s390x] wrong prologue skip on -O2 -g code' (Jan +;; Kratochvil, RH BZ 1084404). +;;=fedoratest + +These testcases have been created by compiling glibc-2.17-78 on +RHEL-7.1 s390x/ppc64 boxes, and then taking the "select.o" file +present at $builddir/misc/select.o. + +diff --git a/gdb/testsuite/gdb.arch/ppc64-prologue-skip.exp b/gdb/testsuite/gdb.arch/ppc64-prologue-skip.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/ppc64-prologue-skip.exp +@@ -0,0 +1,34 @@ ++# Copyright 2015 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if { ![istarget powerpc64-*linux-*] || ![is_lp64_target] } { ++ verbose "Skipping ppc64-prologue-skip.exp" ++ return ++} ++ ++set testfile "ppc64-prologue-skip" ++set uufile "${srcdir}/${subdir}/${testfile}.o.uu" ++set ofile "${srcdir}/${subdir}/${testfile}.o" ++ ++if { [catch "system \"uudecode -o ${ofile} ${uufile}\"" ] != 0 } { ++ untested "failed uudecode" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_load $ofile ++ ++gdb_test "break ___newselect_nocancel" "Breakpoint $decimal at 0xc: file ../sysdeps/unix/syscall-template.S, line 81." "breakpoint on ___newselect_nocancel" +diff --git a/gdb/testsuite/gdb.arch/ppc64-prologue-skip.o.uu b/gdb/testsuite/gdb.arch/ppc64-prologue-skip.o.uu +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/ppc64-prologue-skip.o.uu +@@ -0,0 +1,70 @@ ++begin 644 ppc64-skip-prologue.o.uu ++M?T5,1@("`0`````````````!`!4````!```````````````````````````` ++M``-(``````!```````!``!0`$8%-B-`L"@``0,(`-#@``(Y$```"3.,`('P( ++M`J;X`0`0^"'_D4@```%@````Z`$`@#@A`'!\"`.F3H``(/@A_X%]*`*F^2$` ++MD/CA`-#XP0#(^*$`P/B!`+CX80"P2````6````#X80!PZ.$`T.C!`,CHH0#` ++MZ($`N.AA`+`X``".1````GP``";X80!X^`$`B.AA`'!(```!8````.DA`)#H ++M`0"(Z&$`>'TH`Z9\#_$@."$`@$SC`"!+__]@```````,($``````````O``( ++M7U]S96QE8W0```````````````````````````!6``(````Y!`'[#@T``0$! ++M`0````$```$N+B]S>7-D97!S+W5N:7@``'-Y"]S>7-C86QL+71E;7!L871E ++M+E,`+W)O;W0O9VQI8F,O9VQI8F,M,BXQ-RTW."YE;#$$!&PP!```` ++M`#`````8`````````+P`20YP$4%^1`X`009!0@Z``4(107Y2$49_20X`!D$& ++M1@``````+G-Y;71A8@`N`````````!(````$@````$`````````"``````````8```` ++M)@````$``````````P```````````````````1@````````````````````` ++M``````````$``````````````"P````(``````````,````````````````` ++M``$8```````````````````````````````!```````````````V`````0`` ++M```````#```````````````````!&``````````0```````````````````` ++M"```````````````,0````0`````````````````````````````"L`````` ++M````,````!(````%``````````@`````````&````#L````!```````````` ++M``````````````````$H```````````````````````````````!```````` ++M``````!0`````0`````````````````````````````!*`````````!:```` ++M`````````````````0``````````````2P````0````````````````````` ++M````````"O``````````&````!(````(``````````@`````````&````&$` ++M```!``````````````````````````````&"`````````),````````````` ++M```````!``````````````!<````!``````````````````````````````+ ++M"`````````!@````$@````H`````````"``````````8````;0````$````` ++M`````````````````````````A4`````````%`````````````````````$` ++M`````````````(`````!``````````````````````````````(P```````` ++M`#`````````````````````0``````````````![````!``````````````` ++M```````````````+:``````````P````$@````T`````````"``````````8 ++M````E`````$``````````@```````````````````F``````````2``````` ++M``````````````@``````````````(\````$```````````````````````` ++M``````N8`````````!@````2````#P`````````(`````````!@````1```` ++M`P`````````````````````````````"J`````````">```````````````` ++M`````0```````````````0````(`````````````````````````````"$@` ++M```````!L````!,````+``````````@`````````&`````D````#```````` ++M``````````````````````GX`````````'H````````````````````!```` ++M`````````````````````````````````````````````P```0`````````` ++M`````````````````P```P```````````````````````````P``!``````` ++M`````````````````````P``!0```````````````````````````P``"@`` ++M`````````````````````````P``#````````````````````````````P`` ++M"````````````````````````````P``#0`````````````````````````` ++M`P``#P```````````````````````````P``!P`````````````````````` ++M```!$@``!0```````````````````-@````*$@```0`````````,```````` ++M`#`````@$``````````````````````````````P$``````````````````` ++M``````````!*$`````````````````````````````!E(@``!0`````````` ++M`````````-@```!S(@``!0```````````````````-@`7U]S96QE8W0`7U]? ++M;F5W6YC8V%N8V5L`%]?;&EB8U]D:7-A8FQE7V%S>6YC8V%N8V5L`%]? ++M;&EB8U]S96QE8W0`. ++ ++if { ![istarget s390x-*linux-*] || ![is_lp64_target] } { ++ verbose "Skipping s390x-prologue-skip.exp" ++ return ++} ++ ++set testfile "s390x-prologue-skip" ++set uufile "${srcdir}/${subdir}/${testfile}.o.uu" ++set ofile "${srcdir}/${subdir}/${testfile}.o" ++ ++if { [catch "system \"uudecode -o ${ofile} ${uufile}\"" ] != 0 } { ++ untested "failed uudecode" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_load $ofile ++ ++gdb_test "break select" "Breakpoint $decimal at 0x48: file ../sysdeps/unix/syscall-template.S, line 81." "breakpoint on select" +diff --git a/gdb/testsuite/gdb.arch/s390x-prologue-skip.o.uu b/gdb/testsuite/gdb.arch/s390x-prologue-skip.o.uu +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/s390x-prologue-skip.o.uu +@@ -0,0 +1,64 @@ ++begin 644 s390x-prologue-skip.o.uu ++M?T5,1@("`0`````````````!`!8````!```````````````````````````` ++M``+```````!```````!``!(`#^LE\!``).O?\&@`)+D$`.^G^_]@X^#P```D ++MP.4`````N00``NLE\+``!`J.N00`TKD$`"#`Y0````"Y!``MZ]_Q"``$I_0` ++M"L`0`````+\/$`"G=/_7"HZG2?`!N2$`),"T``````?^````5@`"````.0$! ++M^PX-``$!`0$````!```!+BXO7-C86QL+71E;7!L ++M871E+E,``0`````)`@```````````]```0)F$P("``$!````CP`"``````@! ++M```````````````````````````N+B]S>7-D97!S+W5N:7@OE(``7@. ++M`1L,#Z`!````````&````!P`````````1`!,CP6.!HT'2`[``@```!`````X ++M`````````"```````"YS>6UT86(`+G-T``````````&````!`````&``````````@````````` ++M&````%<````!``````````````````````````````$"`````````),````` ++M```````````````!``````````````!2````!``````````````````````` ++M```````)^`````````!@````$`````@`````````"``````````8````8P`` ++M``$``````````````````````````````94`````````%``````````````` ++M``````$``````````````'8````!``````````````````````````````&P ++M`````````#`````````````````````0``````````````!Q````!``````` ++M```````````````````````*6``````````P````$`````L`````````"``` ++M```````8````B@````$``````````@```````````````````>`````````` ++M2`````````````````````@``````````````(4````$```````````````` ++M``````````````J(`````````#`````0````#0`````````(`````````!@` ++M```1`````P`````````````````````````````"*`````````"4```````` ++M`````````````0```````````````0````(````````````````````````` ++M````!T`````````!L````!$````*``````````@`````````&`````D````# ++M``````````````````````````````CP`````````(X````````````````` ++M```!`````````````````````````````````````````````````P```0`` ++M`````````````````````````P```P```````````````````````````P`` ++M!````````````````````````````P``"``````````````````````````` ++M`P``"@```````````````````````````P``!@`````````````````````` ++M`````P``"P```````````````````````````P``#0`````````````````` ++M`````````P``!0`````````````````````````!$``````````````````` ++M```````````;$``````````````````````````````V$@```0````````!( ++M`````````"`````_$`````````````````````````````!7$@```0`````` ++M``!6`````````!````!I$`````````````````````````````!Y(@```0`` ++M``````!(`````````"````"'(@```0````````!(`````````"``7U]L:6)C ++M7V5N86)L95]A +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1149205-catch-syscall-after-fork-test.patch + +;; Fix '`catch syscall' doesn't work for parent after `fork' is called' +;; (Philippe Waroquiers, RH BZ 1149205). +;;=fedoratest + +URL: +Message-ID: <1368136582.30058.7.camel@soleil> + + From: Philippe Waroquiers + To: gdb-patches at sourceware dot org + Subject: RFA: fix gdb_assert caused by 'catch signal ...' and fork + Date: Thu, 09 May 2013 23:56:22 +0200 + + The attached patch fixes a gdb_assert caused by the combination of catch + signal and fork: + break-catch-sig.c:152: internal-error: signal_catchpoint_remove_location: Assertion `signal_catch_counts[iter] > 0' failed. + + The problem is that the signal_catch_counts is decremented by detach_breakpoints. + The fix consists in not detaching breakpoint locations of type bp_loc_other. + The patch introduces a new test. + +Comments by Sergio Durigan Junior: + + I addded a specific testcase for this patch, which tests exactly the + issue that the customer is facing. This patch does not solve the + whole problem of catching a syscall and forking (for more details, + see , + specifically comment #3), but it solves the issue reported by the + customer. + + I also removed the original testcase of this patch, because it + relied on "catch signal", which is a command that is not implemented + in this version of GDB. + +commit bd9673a4ded96ea5c108601501c8e59003ea1be6 +Author: Philippe Waroquiers +Date: Tue May 21 18:47:05 2013 +0000 + + Fix internal error caused by interaction between catch signal and fork + +diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.c b/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.c +@@ -0,0 +1,11 @@ ++#include ++#include ++ ++int ++main (int argc, char **argv) ++{ ++ if (fork () == 0) ++ sleep (1); ++ chdir ("."); ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.exp b/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.exp +@@ -0,0 +1,58 @@ ++# Copyright 2015 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if { [is_remote target] || ![isnative] } then { ++ continue ++} ++ ++set testfile "gdb-rhbz1149205-catch-syscall-fork" ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++ ++# Until "catch syscall" is implemented on other targets... ++if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then { ++ continue ++} ++ ++# This shall be updated whenever 'catch syscall' is implemented ++# on some architecture. ++#if { ![istarget "i\[34567\]86-*-linux*"] ++if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"] ++ && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"] ++ && ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"] } { ++ continue ++} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested ${testfile}.exp ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load $binfile ++ ++if { ![runto_main] } { ++ return -1 ++} ++ ++gdb_test "catch syscall chdir" \ ++ "Catchpoint $decimal \\\(syscall (.)?chdir(.)? \\\[$decimal\\\]\\\)" \ ++ "catch syscall chdir" ++ ++gdb_test "continue" \ ++ "Continuing\.\r\n.*\r\nCatchpoint $decimal \\\(call to syscall .?chdir.?.*" \ ++ "continue from catch syscall after fork" diff --git a/SOURCES/gdb-rhbz1156192-recursive-dlopen-test.patch b/SOURCES/gdb-rhbz1156192-recursive-dlopen-test.patch new file mode 100644 index 0000000..6ca0c7b --- /dev/null +++ b/SOURCES/gdb-rhbz1156192-recursive-dlopen-test.patch @@ -0,0 +1,350 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1156192-recursive-dlopen-test.patch + +;; Testcase for '[SAP] Recursive dlopen causes SAP HANA installer to +;; crash.' (RH BZ 1156192). +;;=fedoratest + +diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libbar.c b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libbar.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libbar.c +@@ -0,0 +1,30 @@ ++/* Testcase for recursive dlopen calls. ++ ++ Copyright (C) 2014 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 . */ ++ ++/* This test was copied from glibc's testcase called ++ and related files. */ ++ ++#include ++#include ++ ++void ++bar (void) ++{ ++ printf ("Called bar.\n"); ++} +diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libfoo.c b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libfoo.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libfoo.c +@@ -0,0 +1,30 @@ ++/* Testcase for recursive dlopen calls. ++ ++ Copyright (C) 2014 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 . */ ++ ++/* This test was copied from glibc's testcase called ++ and related files. */ ++ ++#include ++#include ++ ++void ++foo (void) ++{ ++ printf ("Called foo.\n"); ++} +diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.c b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.c +@@ -0,0 +1,124 @@ ++/* Testcase for recursive dlopen calls. ++ ++ Copyright (C) 2014 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 . */ ++ ++/* This test was copied from glibc's testcase called ++ and related files. */ ++ ++#include ++#include ++#include ++#include ++ ++#define DSO "gdb-rhbz1156192-recursive-dlopen-libfoo.so" ++#define FUNC "foo" ++ ++#define DSO1 "gdb-rhbz1156192-recursive-dlopen-libbar.so" ++#define FUNC1 "bar" ++ ++/* Prototype for my hook. */ ++void *custom_malloc_hook (size_t, const void *); ++ ++/* Pointer to old malloc hooks. */ ++void *(*old_malloc_hook) (size_t, const void *); ++ ++/* Call function func_name in DSO dso_name via dlopen. */ ++void ++call_func (const char *dso_name, const char *func_name) ++{ ++ int ret; ++ void *dso; ++ void (*func) (void); ++ char *err; ++ ++ /* Open the DSO. */ ++ dso = dlopen (dso_name, RTLD_NOW|RTLD_GLOBAL); ++ if (dso == NULL) ++ { ++ err = dlerror (); ++ fprintf (stderr, "%s\n", err); ++ exit (1); ++ } ++ /* Clear any errors. */ ++ dlerror (); ++ ++ /* Lookup func. */ ++ *(void **) (&func) = dlsym (dso, func_name); ++ if (func == NULL) ++ { ++ err = dlerror (); ++ if (err != NULL) ++ { ++ fprintf (stderr, "%s\n", err); ++ exit (1); ++ } ++ } ++ /* Call func twice. */ ++ (*func) (); ++ ++ /* Close the library and look for errors too. */ ++ ret = dlclose (dso); ++ if (ret != 0) ++ { ++ err = dlerror (); ++ fprintf (stderr, "%s\n", err); ++ exit (1); ++ } ++ ++} ++ ++/* Empty hook that does nothing. */ ++void * ++custom_malloc_hook (size_t size, const void *caller) ++{ ++ void *result; ++ /* Restore old hooks. */ ++ __malloc_hook = old_malloc_hook; ++ /* First call a function in another library via dlopen. */ ++ call_func (DSO1, FUNC1); ++ /* Called recursively. */ ++ result = malloc (size); ++ /* Restore new hooks. */ ++ __malloc_hook = custom_malloc_hook; ++ return result; ++} ++ ++int ++main (void) ++{ ++ ++ /* Save old hook. */ ++ old_malloc_hook = __malloc_hook; ++ /* Install new hook. */ ++ __malloc_hook = custom_malloc_hook; ++ ++ /* Attempt to dlopen a shared library. This dlopen will ++ trigger an access to the ld.so.cache, and that in turn ++ will require a malloc to duplicate data in the cache. ++ The malloc will call our malloc hook which calls dlopen ++ recursively, and upon return of this dlopen the non-ref ++ counted ld.so.cache mapping will be unmapped. We will ++ return to the original dlopen and crash trying to access ++ dlopened data. */ ++ call_func (DSO, FUNC); ++ ++ /* Restore old hook. */ ++ __malloc_hook = old_malloc_hook; ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.exp b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.exp +@@ -0,0 +1,137 @@ ++# Copyright 2014 Free Software Foundation, Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if { [skip_shlib_tests] } { ++ return 0 ++} ++ ++# Library foo ++set libname1 "gdb-rhbz1156192-recursive-dlopen-libfoo" ++set srcfile_lib1 ${srcdir}/${subdir}/${libname1}.c ++set binfile_lib1 [standard_output_file ${libname1}.so] ++# Library bar ++set libname2 "gdb-rhbz1156192-recursive-dlopen-libbar" ++set srcfile_lib2 ${srcdir}/${subdir}/${libname2}.c ++set binfile_lib2 [standard_output_file ${libname2}.so] ++ ++set testfile "gdb-rhbz1156192-recursive-dlopen" ++set srcfile ${testfile}.c ++set executable ${testfile} ++set binfile [standard_output_file ${executable}] ++ ++if { [gdb_compile_shlib ${srcfile_lib1} ${binfile_lib1} \ ++ { debug "additional_flags=-fPIC" }] != "" } { ++ untested "Could not compile ${binfile_lib1}" ++ return -1 ++} ++ ++if { [gdb_compile_shlib ${srcfile_lib2} ${binfile_lib2} \ ++ { debug "additional_flags=-fPIC" }] != "" } { ++ untested "Could not compile ${binfile_lib2}" ++ return -1 ++} ++ ++if { [prepare_for_testing ${testfile}.exp ${executable} ${srcfile} \ ++ [ list debug shlib_load "additional_flags=-Wno-deprecated-declarations" ]] } { ++ untested "Could not compile ${executable}" ++ return -1 ++} ++ ++proc do_test { has_libfoo has_libbar } { ++ global hex binfile_lib2 binfile_lib1 gdb_prompt ++ set libbar_match "[string_to_regexp $binfile_lib2]" ++ set libfoo_match "[string_to_regexp $binfile_lib1]" ++ ++ gdb_test_multiple "info shared" "info shared" { ++ -re ".*$libfoo_match\r\n.*$libbar_match\(\r\n.*Shared library is missing\)?.*\r\n${gdb_prompt} $" { ++ if { $has_libfoo && $has_libbar } { ++ pass "matched libfoo and libbar" ++ } else { ++ fail "matched libfoo and libbar (has_libfoo = $has_libfoo, has_libbar = $has_libbar)" ++ } ++ } ++ -re ".*$libfoo_match\(\r\n.*Shared library is missing\)?.*\r\n${gdb_prompt} $" { ++ if { $has_libfoo && !$has_libbar } { ++ pass "matched libfoo" ++ } else { ++ fail "matched libfoo (has_libfoo = $has_libfoo, has_libbar = $has_libbar)" ++ } ++ } ++ -re ".*$libbar_match\(\r\n.*Shared library is missing\)?.*\r\n${gdb_prompt} $" { ++ if { $has_libbar && !$has_libfoo } { ++ pass "matched libbar" ++ } else { ++ fail "matched libbar (has_libfoo = $has_libfoo, has_libbar = $has_libbar)" ++ } ++ } ++ "\r\n${gdb_prompt} $" { ++ if { !$has_libfoo && !$has_libbar } { ++ pass "did not match libfoo nor libbar" ++ } else { ++ fail "did not match libfoo nor libbar (has_libfoo = $has_libfoo, has_libbar = $has_libbar)" ++ } ++ } ++ } ++} ++ ++proc test_stop_on_solib_events { } { ++ set pass 0 ++ # This variable holds the information about whether libfoo and ++ # libbar (respectively) are expected in the "info shared" output. ++ set solib_event_order { { 0 0 } { 0 0 } { 0 0 } { 0 1 } \ ++ { 0 1 } { 0 0 } { 0 0 } { 0 1 } \ ++ { 0 1 } { 0 0 } { 0 0 } { 0 1 } \ ++ { 0 1 } { 0 0 } { 0 0 1 } { 1 1 } \ ++ { 1 1 } { 1 0 } { 1 0 } { 1 1 } \ ++ { 1 1 } { 1 0 1 } { 1 0 } { 1 0 } } ++ ++ with_test_prefix "stop-on-solib-events" { ++ gdb_test_no_output "set stop-on-solib-events 1" "setting stop-on-solib-events" ++ ++ gdb_run_cmd ++ foreach l $solib_event_order { ++ incr pass ++ with_test_prefix "pass #$pass" { ++ set should_be_corrupted [expr 0+0[lindex $l 2]] ++ do_test [lindex $l 0] [lindex $l 1] ++ set test "continue" ++ global gdb_prompt ++ gdb_test_multiple $test $test { ++ -re "\r\nwarning: Corrupted shared library list:.*\r\nStopped due to shared library event.*\r\n$gdb_prompt $" { ++ set corrupted 1 ++ pass $test ++ } ++ -re "\r\nStopped due to shared library event.*\r\n$gdb_prompt $" { ++ set corrupted 0 ++ pass $test ++ } ++ } ++ set test "corrupted=$corrupted but should_be_corrupted=$should_be_corrupted" ++ if {$corrupted == $should_be_corrupted} { ++ pass $test ++ } else { ++ fail $test ++ } ++ } ++ } ++ # In the last pass we do not expect to see libfoo or libbar. ++ incr pass ++ with_test_prefix "pass #$pass" { ++ do_test 0 0 ++ } ++ } ++} ++ ++test_stop_on_solib_events diff --git a/SOURCES/gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch b/SOURCES/gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch new file mode 100644 index 0000000..21a1a08 --- /dev/null +++ b/SOURCES/gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch @@ -0,0 +1,135 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch + +;; Fix 'backport GDB 7.4 fix to RHEL 6.6 GDB' [Original Sourceware bug +;; description: 'C++ (and objc): Internal error on unqualified name +;; re-set', PR 11657] (RH BZ 1186476). +;;=fedoratest + +Comments from Sergio Durigan Junior: + + The "proper" fix for this whole problem would be to backport the + "ambiguous linespec" patch series. However, it is really not + recommended to do that for RHEL GDB, because the patch series is too + big and could introduce unwanted regressions. Instead, what we + chose to do was to replace the gdb_assert call by a warning (which + allows the user to continue the debugging session), and tell the + user that, although more than one location was found for his/her + breakpoint, only one will be used. + +diff --git a/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc +@@ -0,0 +1,22 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2015 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++int ++main (int argc, char *argv[]) ++{ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.cc b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.cc +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.cc +@@ -0,0 +1,26 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2015 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++class C ++ { ++ public: ++ C () {} ++ C (int x) {} ++ }; ++ ++C a; ++C b (1); +diff --git a/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.exp b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.exp +@@ -0,0 +1,51 @@ ++# Copyright 2015 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if { [skip_cplus_tests] } { continue } ++if { [skip_shlib_tests] } { continue } ++if { [is_remote target] } { continue } ++if { [target_info exists use_gdb_stub] } { continue } ++ ++set testfile gdb-rhbz1186476-internal-error-unqualified-name-re-set-main ++set srcfile $testfile.cc ++set executable $testfile ++set binfile [standard_output_file $executable] ++ ++set libtestfile gdb-rhbz1186476-internal-error-unqualified-name-re-set ++set libsrcfile $libtestfile.cc ++set sofile [standard_output_file lib$libtestfile.so] ++ ++# Create and source the file that provides information about the compiler ++# used to compile the test case. ++if [get_compiler_info "c++"] { ++ return -1 ++} ++ ++if { [gdb_compile_shlib $srcdir/$subdir/$libsrcfile $sofile {debug c++ "additional_flags=-fPIC"}] != "" ++ || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list additional_flags=-Wl,-rpath,[file dirname ${sofile}] "c++" shlib=${sofile} ]] != ""} { ++ untested $libtestfile.exp ++ return -1 ++} ++ ++clean_restart $executable ++ ++gdb_test_no_output "set breakpoint pending on" ++# gdb_breakpoint would print a failure because of some warning messages ++gdb_test "break C::C" "Breakpoint $decimal \\(C::C\\) pending." ++ ++#gdb_test "run" "warning: Found more than one location for breakpoint #$decimal; only the first location will be used.(\r\n)+Breakpoint $decimal, C::C.*" ++gdb_test "run" ++ ++gdb_test "info break" " in C::C\\(\\) at .* in C::C\\(int\\) at .*" diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-1of7.patch b/SOURCES/gdb-rhbz1187581-power8-regs-1of7.patch new file mode 100644 index 0000000..29bd798 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-1of7.patch @@ -0,0 +1,65 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Thu, 9 Aug 2018 17:09:48 +0200 +Subject: gdb-rhbz1187581-power8-regs-1of7.patch + +;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). + +commit 05abfc39c719e740530000059bb963ad33462479 +Author: Pedro Franco de Carvalho +Date: Mon Aug 6 16:24:55 2018 -0300 + + Fix indentation in remote_target::download_tracepoint + + gdb/ChangeLog: + 2018-08-06 Pedro Franco de Carvalho + + * remote.c (remote_target::download_tracepoint): Fix indentation + in for block. + +diff --git a/gdb/remote.c b/gdb/remote.c +--- a/gdb/remote.c ++++ b/gdb/remote.c +@@ -12912,24 +12912,24 @@ remote_target::download_tracepoint (struct bp_location *loc) + error (_("Error on target while setting tracepoints.")); + } + +- for (auto action_it = stepping_actions.begin (); +- action_it != stepping_actions.end (); action_it++) +- { +- QUIT; /* Allow user to bail out with ^C. */ +- +- bool is_first = action_it == stepping_actions.begin (); +- bool has_more = action_it != stepping_actions.end (); +- +- xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s", +- b->number, addrbuf, /* address */ +- is_first ? "S" : "", +- action_it->c_str (), +- has_more ? "-" : ""); +- putpkt (buf); +- remote_get_noisy_reply (); +- if (strcmp (rs->buf, "OK")) +- error (_("Error on target while setting tracepoints.")); +- } ++ for (auto action_it = stepping_actions.begin (); ++ action_it != stepping_actions.end (); action_it++) ++ { ++ QUIT; /* Allow user to bail out with ^C. */ ++ ++ bool is_first = action_it == stepping_actions.begin (); ++ bool has_more = action_it != stepping_actions.end (); ++ ++ xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s", ++ b->number, addrbuf, /* address */ ++ is_first ? "S" : "", ++ action_it->c_str (), ++ has_more ? "-" : ""); ++ putpkt (buf); ++ remote_get_noisy_reply (); ++ if (strcmp (rs->buf, "OK")) ++ error (_("Error on target while setting tracepoints.")); ++ } + + if (packet_support (PACKET_TracepointSource) == PACKET_ENABLE) + { diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-2of7.patch b/SOURCES/gdb-rhbz1187581-power8-regs-2of7.patch new file mode 100644 index 0000000..b0d42cd --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-2of7.patch @@ -0,0 +1,45 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Thu, 9 Aug 2018 17:10:46 +0200 +Subject: gdb-rhbz1187581-power8-regs-2of7.patch + +;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). + +commit aa6f3694ce867884e43d1c0406c64df08ea24bd3 +Author: Pedro Franco de Carvalho +Date: Mon Aug 6 16:24:55 2018 -0300 + + Remove trailing '-' from the last QTDP action packet + + The has_more predicate in remote_target::download_tracepoint always + evaluates to true, so the last action packet will be sent with a + trailing '-'. This patch changes the predicate to remove the last + trailing '-'. + + gdb/ChangeLog: + 2018-08-06 Pedro Franco de Carvalho + + * remote.c (remote_target::download_tracepoint): Fix the has_more + predicate in the QTDP action list iteration. + +diff --git a/gdb/remote.c b/gdb/remote.c +--- a/gdb/remote.c ++++ b/gdb/remote.c +@@ -12899,7 +12899,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + { + QUIT; /* Allow user to bail out with ^C. */ + +- bool has_more = (action_it != tdp_actions.end () ++ bool has_more = ((action_it + 1) != tdp_actions.end () + || !stepping_actions.empty ()); + + xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%c", +@@ -12918,7 +12918,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + QUIT; /* Allow user to bail out with ^C. */ + + bool is_first = action_it == stepping_actions.begin (); +- bool has_more = action_it != stepping_actions.end (); ++ bool has_more = (action_it + 1) != stepping_actions.end (); + + xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s", + b->number, addrbuf, /* address */ diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-3of7.patch b/SOURCES/gdb-rhbz1187581-power8-regs-3of7.patch new file mode 100644 index 0000000..5546f2b --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-3of7.patch @@ -0,0 +1,258 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Thu, 9 Aug 2018 17:11:09 +0200 +Subject: gdb-rhbz1187581-power8-regs-3of7.patch + +;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). + +commit 3df3a985a475db004706d64f83d9085f99053611 +Author: Pedro Franco de Carvalho +Date: Mon Aug 6 16:24:55 2018 -0300 + + Use get_remote_packet_size in download_tracepoint + + This patch changes the remote target to use the remote packet size to + build QTDP packets, and to check if there is enough room for the + packet. + + I changed the function to raise an error if the packet is too small, + instead of aborting gdb (through xsnprintf). It isn't clear if gdb + will be in a consistent state with respect to the stub after this, + since it's possible that some packets will be sent but not others, and + there could be an incomplete tracepoint on the stub. + + The char array used to build the packets is changed to a + gdb::char_vector and sized with the result from + get_remote_packet_size. + + When checking if the buffer is large enough to hold the tracepoint + condition agent expression, the length of the expression is multiplied + by two, since it is encoded with two hex digits per expression + byte. For simplicity, I assume that the result won't overflow, which + can happen for very long condition expressions. + + gdb/ChangeLog: + 2018-08-06 Pedro Franco de Carvalho + + * remote.c (remote_target::download_tracepoint): Remove BUF_SIZE. + Replace array buf with gdb::char_vector buf, of size + get_remote_packet_size (). Replace references to buf and + BUF_SIZE to buf.data () and buf.size (). Replace strcpy, strcat + and xsnprintf with snprintf. Raise errors if the buffer is too + small. + +diff --git a/gdb/remote.c b/gdb/remote.c +--- a/gdb/remote.c ++++ b/gdb/remote.c +@@ -12799,26 +12799,35 @@ remote_target::remote_download_command_source (int num, ULONGEST addr, + void + remote_target::download_tracepoint (struct bp_location *loc) + { +-#define BUF_SIZE 2048 +- + CORE_ADDR tpaddr; + char addrbuf[40]; +- char buf[BUF_SIZE]; + std::vector tdp_actions; + std::vector stepping_actions; + char *pkt; + struct breakpoint *b = loc->owner; + struct tracepoint *t = (struct tracepoint *) b; + struct remote_state *rs = get_remote_state (); ++ int ret; ++ char *err_msg = _("Tracepoint packet too large for target."); ++ size_t size_left; ++ ++ /* We use a buffer other than rs->buf because we'll build strings ++ across multiple statements, and other statements in between could ++ modify rs->buf. */ ++ gdb::char_vector buf (get_remote_packet_size ()); + + encode_actions_rsp (loc, &tdp_actions, &stepping_actions); + + tpaddr = loc->address; + sprintf_vma (addrbuf, tpaddr); +- xsnprintf (buf, BUF_SIZE, "QTDP:%x:%s:%c:%lx:%x", b->number, +- addrbuf, /* address */ +- (b->enable_state == bp_enabled ? 'E' : 'D'), +- t->step_count, t->pass_count); ++ ret = snprintf (buf.data (), buf.size (), "QTDP:%x:%s:%c:%lx:%x", ++ b->number, addrbuf, /* address */ ++ (b->enable_state == bp_enabled ? 'E' : 'D'), ++ t->step_count, t->pass_count); ++ ++ if (ret < 0 || ret >= buf.size ()) ++ error (err_msg); ++ + /* Fast tracepoints are mostly handled by the target, but we can + tell the target how big of an instruction block should be moved + around. */ +@@ -12830,8 +12839,15 @@ remote_target::download_tracepoint (struct bp_location *loc) + { + if (gdbarch_fast_tracepoint_valid_at (loc->gdbarch, tpaddr, + NULL)) +- xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x", +- gdb_insn_length (loc->gdbarch, tpaddr)); ++ { ++ size_left = buf.size () - strlen (buf.data ()); ++ ret = snprintf (buf.data () + strlen (buf.data ()), ++ size_left, ":F%x", ++ gdb_insn_length (loc->gdbarch, tpaddr)); ++ ++ if (ret < 0 || ret >= size_left) ++ error (err_msg); ++ } + else + /* If it passed validation at definition but fails now, + something is very wrong. */ +@@ -12855,7 +12871,14 @@ remote_target::download_tracepoint (struct bp_location *loc) + struct static_tracepoint_marker marker; + + if (target_static_tracepoint_marker_at (tpaddr, &marker)) +- strcat (buf, ":S"); ++ { ++ size_left = buf.size () - strlen (buf.data ()); ++ ret = snprintf (buf.data () + strlen (buf.data ()), ++ size_left, ":S"); ++ ++ if (ret < 0 || ret >= size_left) ++ error (err_msg); ++ } + else + error (_("Static tracepoint not valid during download")); + } +@@ -12873,10 +12896,26 @@ remote_target::download_tracepoint (struct bp_location *loc) + capabilities at definition time. */ + if (remote_supports_cond_tracepoints ()) + { +- agent_expr_up aexpr = gen_eval_for_expr (tpaddr, loc->cond.get ()); +- xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":X%x,", +- aexpr->len); +- pkt = buf + strlen (buf); ++ agent_expr_up aexpr = gen_eval_for_expr (tpaddr, ++ loc->cond.get ()); ++ ++ size_left = buf.size () - strlen (buf.data ()); ++ ++ ret = snprintf (buf.data () + strlen (buf.data ()), ++ size_left, ":X%x,", aexpr->len); ++ ++ if (ret < 0 || ret >= size_left) ++ error (err_msg); ++ ++ size_left = buf.size () - strlen (buf.data ()); ++ ++ /* Two bytes to encode each aexpr byte, plus the terminating ++ null byte. */ ++ if (aexpr->len * 2 + 1 > size_left) ++ error (err_msg); ++ ++ pkt = buf.data () + strlen (buf.data ()); ++ + for (int ndx = 0; ndx < aexpr->len; ++ndx) + pkt = pack_hex_byte (pkt, aexpr->buf[ndx]); + *pkt = '\0'; +@@ -12887,8 +12926,17 @@ remote_target::download_tracepoint (struct bp_location *loc) + } + + if (b->commands || *default_collect) +- strcat (buf, "-"); +- putpkt (buf); ++ { ++ size_left = buf.size () - strlen (buf.data ()); ++ ++ ret = snprintf (buf.data () + strlen (buf.data ()), ++ size_left, "-"); ++ ++ if (ret < 0 || ret >= size_left) ++ error (err_msg); ++ } ++ ++ putpkt (buf.data ()); + remote_get_noisy_reply (); + if (strcmp (rs->buf, "OK")) + error (_("Target does not support tracepoints.")); +@@ -12902,11 +12950,15 @@ remote_target::download_tracepoint (struct bp_location *loc) + bool has_more = ((action_it + 1) != tdp_actions.end () + || !stepping_actions.empty ()); + +- xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%c", +- b->number, addrbuf, /* address */ +- action_it->c_str (), +- has_more ? '-' : 0); +- putpkt (buf); ++ ret = snprintf (buf.data (), buf.size (), "QTDP:-%x:%s:%s%c", ++ b->number, addrbuf, /* address */ ++ action_it->c_str (), ++ has_more ? '-' : 0); ++ ++ if (ret < 0 || ret >= buf.size ()) ++ error (err_msg); ++ ++ putpkt (buf.data ()); + remote_get_noisy_reply (); + if (strcmp (rs->buf, "OK")) + error (_("Error on target while setting tracepoints.")); +@@ -12920,12 +12972,16 @@ remote_target::download_tracepoint (struct bp_location *loc) + bool is_first = action_it == stepping_actions.begin (); + bool has_more = (action_it + 1) != stepping_actions.end (); + +- xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s", +- b->number, addrbuf, /* address */ +- is_first ? "S" : "", +- action_it->c_str (), +- has_more ? "-" : ""); +- putpkt (buf); ++ ret = snprintf (buf.data (), buf.size (), "QTDP:-%x:%s:%s%s%s", ++ b->number, addrbuf, /* address */ ++ is_first ? "S" : "", ++ action_it->c_str (), ++ has_more ? "-" : ""); ++ ++ if (ret < 0 || ret >= buf.size ()) ++ error (err_msg); ++ ++ putpkt (buf.data ()); + remote_get_noisy_reply (); + if (strcmp (rs->buf, "OK")) + error (_("Error on target while setting tracepoints.")); +@@ -12935,22 +12991,32 @@ remote_target::download_tracepoint (struct bp_location *loc) + { + if (b->location != NULL) + { +- strcpy (buf, "QTDPsrc:"); ++ ret = snprintf (buf.data (), buf.size (), "QTDPsrc:"); ++ ++ if (ret < 0 || ret >= buf.size ()) ++ error (err_msg); ++ + encode_source_string (b->number, loc->address, "at", + event_location_to_string (b->location.get ()), +- buf + strlen (buf), 2048 - strlen (buf)); +- putpkt (buf); ++ buf.data () + strlen (buf.data ()), ++ buf.size () - strlen (buf.data ())); ++ putpkt (buf.data ()); + remote_get_noisy_reply (); + if (strcmp (rs->buf, "OK")) + warning (_("Target does not support source download.")); + } + if (b->cond_string) + { +- strcpy (buf, "QTDPsrc:"); ++ ret = snprintf (buf.data (), buf.size (), "QTDPsrc:"); ++ ++ if (ret < 0 || ret >= buf.size ()) ++ error (err_msg); ++ + encode_source_string (b->number, loc->address, +- "cond", b->cond_string, buf + strlen (buf), +- 2048 - strlen (buf)); +- putpkt (buf); ++ "cond", b->cond_string, ++ buf.data () + strlen (buf.data ()), ++ buf.size () - strlen (buf.data ())); ++ putpkt (buf.data ()); + remote_get_noisy_reply (); + if (strcmp (rs->buf, "OK")) + warning (_("Target does not support source download.")); diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-4of7.patch b/SOURCES/gdb-rhbz1187581-power8-regs-4of7.patch new file mode 100644 index 0000000..8c553a8 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-4of7.patch @@ -0,0 +1,449 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Thu, 9 Aug 2018 17:17:16 +0200 +Subject: gdb-rhbz1187581-power8-regs-4of7.patch + +;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). + +commit 4277c4b87addb5354cc47b98d7a73e44cfaf22c2 +Author: Pedro Franco de Carvalho +Date: Mon Aug 6 16:24:55 2018 -0300 + + Use remote register numbers in tracepoint mask + + Currently, tracepoint register masks in the QTDP packets include both + internal and remote register numbers, as well as pseudo-register + numbers. + + This patch changes this so that the mask only includes remote register + numbers. + + Register numbers from agent expressions are already set in the mask + using remote numbers. Other tracepoint actions used internal numbers, + e.g. "collect $regs" or "collect $". To handle pseudoreg + numbers, an empty agent expression is created and ax_reg_mask is + called for this expression and the pseudoreg. This will cause the ax + to set its mask with the corresponding remote raw register + numbers (using ax_regs_mask, which calls + gdbarch_ax_pseudo_register_collect). + + If ax_regs_mask and gdbarch_ax_pseudo_register_collect also generate + more ax bytecode, the ax is also appended to the collection list. It + isn't clear that this was the original intent for + gdbarch_ax_pseudo_register_collect, and none of the arches seem to do + this, but if this changes in the future, it should work. + + The patch also refactors the code used by validate_action line to + validate axs into a function that is now called from every place that + generates axs. Previously, some parts of tracepoint.c that generated + axs didn't check if the ax length was greater than MAX_AGENT_EXPR_LEN. + + gdb/ChangeLog: + 2018-08-06 Pedro Franco de Carvalho + + * tracepoint.h (class collection_list) : Remove. + : + Declare. + : Add scope parameter. + * tracepoint.c (encode_actions_1): Likewise. + (collection_list::add_register): Rename to ... + (collection_list::add_remote_register): ... this. Update + comment. + (collection_list::add_ax_registers, add_local_register): New + methods. + (collection_list::add_memrange): Add scope parameter. Call + add_local_register instead of add_register. + (finalize_tracepoint_aexpr): New function. + (collection_list::collect_symbol): Update calls to add_memrange. + Call add_local_register instead of add_register. Call + add_ax_registers. Call finalize_tracepoint_aexpr. + (encode_actions_1): Get remote regnos for $reg action. Call + add_remote_register, add_ax_registers, and add_local_register. + Update call to add_memrange. Call finalize_tracepoint_aexpr. + (validate_actionline): Call finalize_tracepoint_aexpr. + ++2018-08-06 Pedro Franco de Carvalho ++ ++ * tracepoint.h (class collection_list) : Remove. ++ : ++ Declare. ++ : Add scope parameter. ++ * tracepoint.c (encode_actions_1): Likewise. ++ (collection_list::add_register): Rename to ... ++ (collection_list::add_remote_register): ... this. Update ++ comment. ++ (collection_list::add_ax_registers, add_local_register): New ++ methods. ++ (collection_list::add_memrange): Add scope parameter. Call ++ add_local_register instead of add_register. ++ (finalize_tracepoint_aexpr): New function. ++ (collection_list::collect_symbol): Update calls to add_memrange. ++ Call add_local_register instead of add_register. Call ++ add_ax_registers. Call finalize_tracepoint_aexpr. ++ (encode_actions_1): Get remote regnos for $reg action. Call ++ add_remote_register, add_ax_registers, and add_local_register. ++ Update call to add_memrange. Call finalize_tracepoint_aexpr. ++ (validate_actionline): Call finalize_tracepoint_aexpr. ++ + 2018-08-06 Pedro Franco de Carvalho + + * remote.c (remote_target::download_tracepoint): Remove BUF_SIZE. + +diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c +--- a/gdb/tracepoint.c ++++ b/gdb/tracepoint.c +@@ -615,6 +615,19 @@ report_agent_reqs_errors (struct agent_expr *aexpr) + error (_("Expression is too complicated.")); + } + ++/* Call ax_reqs on AEXPR and raise an error if something is wrong. */ ++ ++static void ++finalize_tracepoint_aexpr (struct agent_expr *aexpr) ++{ ++ ax_reqs (aexpr); ++ ++ if (aexpr->len > MAX_AGENT_EXPR_LEN) ++ error (_("Expression is too complicated.")); ++ ++ report_agent_reqs_errors (aexpr); ++} ++ + /* worker function */ + void + validate_actionline (const char *line, struct breakpoint *b) +@@ -699,12 +712,7 @@ validate_actionline (const char *line, struct breakpoint *b) + exp.get (), + trace_string); + +- if (aexpr->len > MAX_AGENT_EXPR_LEN) +- error (_("Expression is too complicated.")); +- +- ax_reqs (aexpr.get ()); +- +- report_agent_reqs_errors (aexpr.get ()); ++ finalize_tracepoint_aexpr (aexpr.get ()); + } + } + while (p && *p++ == ','); +@@ -731,11 +739,7 @@ validate_actionline (const char *line, struct breakpoint *b) + long. */ + agent_expr_up aexpr = gen_eval_for_expr (loc->address, exp.get ()); + +- if (aexpr->len > MAX_AGENT_EXPR_LEN) +- error (_("Expression is too complicated.")); +- +- ax_reqs (aexpr.get ()); +- report_agent_reqs_errors (aexpr.get ()); ++ finalize_tracepoint_aexpr (aexpr.get ()); + } + } + while (p && *p++ == ','); +@@ -811,10 +815,10 @@ memrange_sortmerge (std::vector &memranges) + } + } + +-/* Add a register to a collection list. */ ++/* Add remote register number REGNO to the collection list mask. */ + + void +-collection_list::add_register (unsigned int regno) ++collection_list::add_remote_register (unsigned int regno) + { + if (info_verbose) + printf_filtered ("collect register %d\n", regno); +@@ -824,12 +828,74 @@ collection_list::add_register (unsigned int regno) + m_regs_mask[regno / 8] |= 1 << (regno % 8); + } + ++/* Add all the registers from the mask in AEXPR to the mask in the ++ collection list. Registers in the AEXPR mask are already remote ++ register numbers. */ ++ ++void ++collection_list::add_ax_registers (struct agent_expr *aexpr) ++{ ++ if (aexpr->reg_mask_len > 0) ++ { ++ for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++) ++ { ++ QUIT; /* Allow user to bail out with ^C. */ ++ if (aexpr->reg_mask[ndx1] != 0) ++ { ++ /* Assume chars have 8 bits. */ ++ for (int ndx2 = 0; ndx2 < 8; ndx2++) ++ if (aexpr->reg_mask[ndx1] & (1 << ndx2)) ++ /* It's used -- record it. */ ++ add_remote_register (ndx1 * 8 + ndx2); ++ } ++ } ++ } ++} ++ ++/* If REGNO is raw, add its corresponding remote register number to ++ the mask. If REGNO is a pseudo-register, figure out the necessary ++ registers using a temporary agent expression, and add it to the ++ list if it needs more than just a mask. */ ++ ++void ++collection_list::add_local_register (struct gdbarch *gdbarch, ++ unsigned int regno, ++ CORE_ADDR scope) ++{ ++ if (regno < gdbarch_num_regs (gdbarch)) ++ { ++ int remote_regno = gdbarch_remote_register_number (gdbarch, regno); ++ ++ if (remote_regno < 0) ++ error (_("Can't collect register %d"), regno); ++ ++ add_remote_register (remote_regno); ++ } ++ else ++ { ++ agent_expr_up aexpr (new agent_expr (gdbarch, scope)); ++ ++ ax_reg_mask (aexpr.get (), regno); ++ ++ finalize_tracepoint_aexpr (aexpr.get ()); ++ ++ add_ax_registers (aexpr.get ()); ++ ++ /* Usually ax_reg_mask for a pseudo-regiser only sets the ++ corresponding raw registers in the ax mask, but if this isn't ++ the case add the expression that is generated to the ++ collection list. */ ++ if (aexpr->len > 0) ++ add_aexpr (std::move (aexpr)); ++ } ++} ++ + /* Add a memrange to a collection list. */ + + void + collection_list::add_memrange (struct gdbarch *gdbarch, + int type, bfd_signed_vma base, +- ULONGEST len) ++ ULONGEST len, CORE_ADDR scope) + { + if (info_verbose) + printf_filtered ("(%d,%s,%s)\n", type, paddress (gdbarch, base), pulongest (len)); +@@ -840,7 +906,7 @@ collection_list::add_memrange (struct gdbarch *gdbarch, + m_memranges.emplace_back (type, base, base + len); + + if (type != memrange_absolute) /* Better collect the base register! */ +- add_register (type); ++ add_local_register (gdbarch, type, scope); + } + + /* Add a symbol to a collection list. */ +@@ -882,19 +948,19 @@ collection_list::collect_symbol (struct symbol *sym, + if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT) + treat_as_expr = 1; + else +- add_memrange (gdbarch, memrange_absolute, offset, len); ++ add_memrange (gdbarch, memrange_absolute, offset, len, scope); + break; + case LOC_REGISTER: + reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch); + if (info_verbose) + printf_filtered ("LOC_REG[parm] %s: ", + SYMBOL_PRINT_NAME (sym)); +- add_register (reg); ++ add_local_register (gdbarch, reg, scope); + /* Check for doubles stored in two registers. */ + /* FIXME: how about larger types stored in 3 or more regs? */ + if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FLT && + len > register_size (gdbarch, reg)) +- add_register (reg + 1); ++ add_local_register (gdbarch, reg + 1, scope); + break; + case LOC_REF_ARG: + printf_filtered ("Sorry, don't know how to do LOC_REF_ARG yet.\n"); +@@ -911,7 +977,7 @@ collection_list::collect_symbol (struct symbol *sym, + SYMBOL_PRINT_NAME (sym), pulongest (len), + paddress (gdbarch, offset), reg); + } +- add_memrange (gdbarch, reg, offset, len); ++ add_memrange (gdbarch, reg, offset, len, scope); + break; + case LOC_REGPARM_ADDR: + reg = SYMBOL_VALUE (sym); +@@ -923,7 +989,7 @@ collection_list::collect_symbol (struct symbol *sym, + SYMBOL_PRINT_NAME (sym), pulongest (len), + paddress (gdbarch, offset), reg); + } +- add_memrange (gdbarch, reg, offset, len); ++ add_memrange (gdbarch, reg, offset, len, scope); + break; + case LOC_LOCAL: + reg = frame_regno; +@@ -935,7 +1001,7 @@ collection_list::collect_symbol (struct symbol *sym, + SYMBOL_PRINT_NAME (sym), pulongest (len), + paddress (gdbarch, offset), reg); + } +- add_memrange (gdbarch, reg, offset, len); ++ add_memrange (gdbarch, reg, offset, len, scope); + break; + + case LOC_UNRESOLVED: +@@ -968,26 +1034,10 @@ collection_list::collect_symbol (struct symbol *sym, + return; + } + +- ax_reqs (aexpr.get ()); +- +- report_agent_reqs_errors (aexpr.get ()); ++ finalize_tracepoint_aexpr (aexpr.get ()); + + /* Take care of the registers. */ +- if (aexpr->reg_mask_len > 0) +- { +- for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++) +- { +- QUIT; /* Allow user to bail out with ^C. */ +- if (aexpr->reg_mask[ndx1] != 0) +- { +- /* Assume chars have 8 bits. */ +- for (int ndx2 = 0; ndx2 < 8; ndx2++) +- if (aexpr->reg_mask[ndx1] & (1 << ndx2)) +- /* It's used -- record it. */ +- add_register (ndx1 * 8 + ndx2); +- } +- } +- } ++ add_ax_registers (aexpr.get ()); + + add_aexpr (std::move (aexpr)); + } +@@ -1257,8 +1307,18 @@ encode_actions_1 (struct command_line *action, + + if (0 == strncasecmp ("$reg", action_exp, 4)) + { +- for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++) +- collect->add_register (i); ++ for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); ++ i++) ++ { ++ int remote_regno = (gdbarch_remote_register_number ++ (target_gdbarch (), i)); ++ ++ /* Ignore arch regnos without a corresponding ++ remote regno. This can happen for regnos not ++ in the tdesc. */ ++ if (remote_regno >= 0) ++ collect->add_remote_register (remote_regno); ++ } + action_exp = strchr (action_exp, ','); /* more? */ + } + else if (0 == strncasecmp ("$arg", action_exp, 4)) +@@ -1288,27 +1348,10 @@ encode_actions_1 (struct command_line *action, + target_gdbarch (), + trace_string); + +- ax_reqs (aexpr.get ()); +- report_agent_reqs_errors (aexpr.get ()); ++ finalize_tracepoint_aexpr (aexpr.get ()); + + /* take care of the registers */ +- if (aexpr->reg_mask_len > 0) +- { +- for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++) +- { +- QUIT; /* allow user to bail out with ^C */ +- if (aexpr->reg_mask[ndx1] != 0) +- { +- /* assume chars have 8 bits */ +- for (int ndx2 = 0; ndx2 < 8; ndx2++) +- if (aexpr->reg_mask[ndx1] & (1 << ndx2)) +- { +- /* It's used -- record it. */ +- collect->add_register (ndx1 * 8 + ndx2); +- } +- } +- } +- } ++ collect->add_ax_registers (aexpr.get ()); + + collect->add_aexpr (std::move (aexpr)); + action_exp = strchr (action_exp, ','); /* more? */ +@@ -1340,7 +1383,8 @@ encode_actions_1 (struct command_line *action, + name); + if (info_verbose) + printf_filtered ("OP_REGISTER: "); +- collect->add_register (i); ++ collect->add_local_register (target_gdbarch (), ++ i, tloc->address); + break; + } + +@@ -1352,7 +1396,8 @@ encode_actions_1 (struct command_line *action, + check_typedef (exp->elts[1].type); + collect->add_memrange (target_gdbarch (), + memrange_absolute, addr, +- TYPE_LENGTH (exp->elts[1].type)); ++ TYPE_LENGTH (exp->elts[1].type), ++ tloc->address); + collect->append_exp (exp.get ()); + break; + +@@ -1376,28 +1421,10 @@ encode_actions_1 (struct command_line *action, + exp.get (), + trace_string); + +- ax_reqs (aexpr.get ()); +- +- report_agent_reqs_errors (aexpr.get ()); ++ finalize_tracepoint_aexpr (aexpr.get ()); + + /* Take care of the registers. */ +- if (aexpr->reg_mask_len > 0) +- { +- for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++) +- { +- QUIT; /* Allow user to bail out with ^C. */ +- if (aexpr->reg_mask[ndx1] != 0) +- { +- /* Assume chars have 8 bits. */ +- for (int ndx2 = 0; ndx2 < 8; ndx2++) +- if (aexpr->reg_mask[ndx1] & (1 << ndx2)) +- { +- /* It's used -- record it. */ +- collect->add_register (ndx1 * 8 + ndx2); +- } +- } +- } +- } ++ collect->add_ax_registers (aexpr.get ()); + + collect->add_aexpr (std::move (aexpr)); + collect->append_exp (exp.get ()); +@@ -1422,8 +1449,7 @@ encode_actions_1 (struct command_line *action, + agent_expr_up aexpr = gen_eval_for_expr (tloc->address, + exp.get ()); + +- ax_reqs (aexpr.get ()); +- report_agent_reqs_errors (aexpr.get ()); ++ finalize_tracepoint_aexpr (aexpr.get ()); + + /* Even though we're not officially collecting, add + to the collect list anyway. */ +diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h +--- a/gdb/tracepoint.h ++++ b/gdb/tracepoint.h +@@ -263,9 +263,14 @@ public: + void add_aexpr (agent_expr_up aexpr); + + void add_register (unsigned int regno); ++ void add_remote_register (unsigned int regno); ++ void add_ax_registers (struct agent_expr *aexpr); ++ void add_local_register (struct gdbarch *gdbarch, ++ unsigned int regno, ++ CORE_ADDR scope); + void add_memrange (struct gdbarch *gdbarch, + int type, bfd_signed_vma base, +- ULONGEST len); ++ ULONGEST len, CORE_ADDR scope); + void collect_symbol (struct symbol *sym, + struct gdbarch *gdbarch, + long frame_regno, long frame_offset, diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-5of7.patch b/SOURCES/gdb-rhbz1187581-power8-regs-5of7.patch new file mode 100644 index 0000000..eaca52f --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-5of7.patch @@ -0,0 +1,215 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Thu, 9 Aug 2018 17:17:46 +0200 +Subject: gdb-rhbz1187581-power8-regs-5of7.patch + +;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). + +commit a04b9d62a234923826e431a209d396a628661548 +Author: Pedro Franco de Carvalho +Date: Mon Aug 6 16:24:55 2018 -0300 + + Variable size for regs mask in collection list + + This patch changes collection_list to allow larger register masks. + + The mask is changed from an array to a vector and is initialized to + hold the maximum possible remote register number. The stringify + method is updated to resize temp_buf if needed. + + gdb/ChangeLog: + 2018-08-06 Pedro Franco de Carvalho + + * tracepoint.h (collection_list) : Change type to + std::vector. + * tracepoint.c (collection_list::collection_list): Remove + m_regs_mask initializer from initializer list. Resize + m_regs_mask using the largest remote register number. + (collection_list::add_remote_register): Remove size check on + m_regs_mask. Use at to access element. + (collection_list::stringify): Change type of temp_buf to + gdb::char_vector. Update uses of temp_buf. Resize if needed to + stringify the register mask. Use pack_hex_byte for the register + mask. + ++2018-08-06 Pedro Franco de Carvalho ++ ++ * tracepoint.h (collection_list) : Change type to ++ std::vector. ++ * tracepoint.c (collection_list::collection_list): Remove ++ m_regs_mask initializer from initializer list. Resize ++ m_regs_mask using the largest remote register number. ++ (collection_list::add_remote_register): Remove size check on ++ m_regs_mask. Use at to access element. ++ (collection_list::stringify): Change type of temp_buf to ++ gdb::char_vector. Update uses of temp_buf. Resize if needed to ++ stringify the register mask. Use pack_hex_byte for the register ++ mask. ++ + 2018-08-06 Pedro Franco de Carvalho + + * tracepoint.h (class collection_list) : Remove. + +diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c +--- a/gdb/tracepoint.c ++++ b/gdb/tracepoint.c +@@ -822,10 +822,8 @@ collection_list::add_remote_register (unsigned int regno) + { + if (info_verbose) + printf_filtered ("collect register %d\n", regno); +- if (regno >= (8 * sizeof (m_regs_mask))) +- error (_("Internal: register number %d too large for tracepoint"), +- regno); +- m_regs_mask[regno / 8] |= 1 << (regno % 8); ++ ++ m_regs_mask.at (regno / 8) |= 1 << (regno % 8); + } + + /* Add all the registers from the mask in AEXPR to the mask in the +@@ -1136,9 +1134,20 @@ collection_list::add_static_trace_data () + } + + collection_list::collection_list () +- : m_regs_mask (), +- m_strace_data (false) ++ : m_strace_data (false) + { ++ int max_remote_regno = 0; ++ for (int i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++) ++ { ++ int remote_regno = (gdbarch_remote_register_number ++ (target_gdbarch (), i)); ++ ++ if (remote_regno >= 0 && remote_regno > max_remote_regno) ++ max_remote_regno = remote_regno; ++ } ++ ++ m_regs_mask.resize ((max_remote_regno / 8) + 1); ++ + m_memranges.reserve (128); + m_aexprs.reserve (128); + } +@@ -1148,7 +1157,8 @@ collection_list::collection_list () + std::vector + collection_list::stringify () + { +- char temp_buf[2048]; ++ gdb::char_vector temp_buf (2048); ++ + int count; + char *end; + long i; +@@ -1158,35 +1168,45 @@ collection_list::stringify () + { + if (info_verbose) + printf_filtered ("\nCollecting static trace data\n"); +- end = temp_buf; ++ end = temp_buf.data (); + *end++ = 'L'; +- str_list.emplace_back (temp_buf, end - temp_buf); ++ str_list.emplace_back (temp_buf.data (), end - temp_buf.data ()); + } + +- for (i = sizeof (m_regs_mask) - 1; i > 0; i--) ++ for (i = m_regs_mask.size () - 1; i > 0; i--) + if (m_regs_mask[i] != 0) /* Skip leading zeroes in regs_mask. */ + break; + if (m_regs_mask[i] != 0) /* Prepare to send regs_mask to the stub. */ + { + if (info_verbose) + printf_filtered ("\nCollecting registers (mask): 0x"); +- end = temp_buf; ++ ++ /* One char for 'R', one for the null terminator and two per ++ mask byte. */ ++ std::size_t new_size = (i + 1) * 2 + 2; ++ if (new_size > temp_buf.size ()) ++ temp_buf.resize (new_size); ++ ++ end = temp_buf.data (); + *end++ = 'R'; + for (; i >= 0; i--) + { + QUIT; /* Allow user to bail out with ^C. */ + if (info_verbose) + printf_filtered ("%02X", m_regs_mask[i]); +- sprintf (end, "%02X", m_regs_mask[i]); +- end += 2; ++ ++ end = pack_hex_byte (end, m_regs_mask[i]); + } +- str_list.emplace_back (temp_buf); ++ *end = '\0'; ++ ++ str_list.emplace_back (temp_buf.data ()); + } + if (info_verbose) + printf_filtered ("\n"); + if (!m_memranges.empty () && info_verbose) + printf_filtered ("Collecting memranges: \n"); +- for (i = 0, count = 0, end = temp_buf; i < m_memranges.size (); i++) ++ for (i = 0, count = 0, end = temp_buf.data (); ++ i < m_memranges.size (); i++) + { + QUIT; /* Allow user to bail out with ^C. */ + if (info_verbose) +@@ -1200,9 +1220,9 @@ collection_list::stringify () + } + if (count + 27 > MAX_AGENT_EXPR_LEN) + { +- str_list.emplace_back (temp_buf, count); ++ str_list.emplace_back (temp_buf.data (), count); + count = 0; +- end = temp_buf; ++ end = temp_buf.data (); + } + + { +@@ -1222,7 +1242,7 @@ collection_list::stringify () + } + + count += strlen (end); +- end = temp_buf + count; ++ end = temp_buf.data () + count; + } + + for (i = 0; i < m_aexprs.size (); i++) +@@ -1230,9 +1250,9 @@ collection_list::stringify () + QUIT; /* Allow user to bail out with ^C. */ + if ((count + 10 + 2 * m_aexprs[i]->len) > MAX_AGENT_EXPR_LEN) + { +- str_list.emplace_back (temp_buf, count); ++ str_list.emplace_back (temp_buf.data (), count); + count = 0; +- end = temp_buf; ++ end = temp_buf.data (); + } + sprintf (end, "X%08X,", m_aexprs[i]->len); + end += 10; /* 'X' + 8 hex digits + ',' */ +@@ -1244,9 +1264,9 @@ collection_list::stringify () + + if (count != 0) + { +- str_list.emplace_back (temp_buf, count); ++ str_list.emplace_back (temp_buf.data (), count); + count = 0; +- end = temp_buf; ++ end = temp_buf.data (); + } + + return str_list; +diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h +--- a/gdb/tracepoint.h ++++ b/gdb/tracepoint.h +@@ -293,8 +293,9 @@ public: + { return m_computed; } + + private: +- /* room for up to 256 regs */ +- unsigned char m_regs_mask[32]; ++ /* We need the allocator zero-initialize the mask, so we don't use ++ gdb::byte_vector. */ ++ std::vector m_regs_mask; + + std::vector m_memranges; + diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-6of7.patch b/SOURCES/gdb-rhbz1187581-power8-regs-6of7.patch new file mode 100644 index 0000000..b0a5e1f --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-6of7.patch @@ -0,0 +1,187 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Thu, 9 Aug 2018 17:18:15 +0200 +Subject: gdb-rhbz1187581-power8-regs-6of7.patch + +;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). + +commit 296956befef3711ed458c7cba8041fde0dab9c50 +Author: Pedro Franco de Carvalho +Date: Mon Aug 6 16:24:55 2018 -0300 + + Allow larger regblock sizes when saving tracefiles + + The tracefile.c:trace_save function assumes trace_regblock_size won't + be larger than the MAX_TRACE_UPLOAD constant, used to size the buffer + which holds trace data. This can cause buffer overruns when this is + not the case. This patch changes this function so that the larger + size is used to size the buffer. + + gdb/ChangeLog: + 2018-08-06 Pedro Franco de Carvalho + + * tracefile.c: Include common/byte-vector.h. + (trace_save): Change type of buf to gdb::byte_vector. Initialize + with trace_regblock_size if needed. Update uses of buf. + ++2018-08-06 Pedro Franco de Carvalho ++ ++ * tracefile.c: Include common/byte-vector.h. ++ (trace_save): Change type of buf to gdb::byte_vector. Initialize ++ with trace_regblock_size if needed. Update uses of buf. ++ + 2018-08-06 Pedro Franco de Carvalho + + * tracepoint.h (collection_list) : Change type to + +diff --git a/gdb/tracefile.c b/gdb/tracefile.c +--- a/gdb/tracefile.c ++++ b/gdb/tracefile.c +@@ -22,6 +22,7 @@ + #include "ctf.h" + #include "exec.h" + #include "regcache.h" ++#include "common/byte-vector.h" + + /* Helper macros. */ + +@@ -67,7 +68,7 @@ trace_save (const char *filename, struct trace_file_writer *writer, + + ULONGEST offset = 0; + #define MAX_TRACE_UPLOAD 2000 +- gdb_byte buf[MAX_TRACE_UPLOAD]; ++ gdb::byte_vector buf (std::max (MAX_TRACE_UPLOAD, trace_regblock_size)); + enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + + /* If the target is to save the data to a file on its own, then just +@@ -144,7 +145,7 @@ trace_save (const char *filename, struct trace_file_writer *writer, + /* We ask for big blocks, in the hopes of efficiency, but + will take less if the target has packet size limitations + or some such. */ +- gotten = target_get_raw_trace_data (buf, offset, ++ gotten = target_get_raw_trace_data (buf.data (), offset, + MAX_TRACE_UPLOAD); + if (gotten < 0) + error (_("Failure to get requested trace buffer data")); +@@ -152,7 +153,7 @@ trace_save (const char *filename, struct trace_file_writer *writer, + if (gotten == 0) + break; + +- writer->ops->write_trace_buffer (writer, buf, gotten); ++ writer->ops->write_trace_buffer (writer, buf.data (), gotten); + + offset += gotten; + } +@@ -163,7 +164,7 @@ trace_save (const char *filename, struct trace_file_writer *writer, + /* Parse the trace buffers according to how data are stored + in trace buffer in GDBserver. */ + +- gotten = target_get_raw_trace_data (buf, offset, 6); ++ gotten = target_get_raw_trace_data (buf.data (), offset, 6); + + if (gotten == 0) + break; +@@ -171,10 +172,10 @@ trace_save (const char *filename, struct trace_file_writer *writer, + /* Read the first six bytes in, which is the tracepoint + number and trace frame size. */ + tp_num = (uint16_t) +- extract_unsigned_integer (&buf[0], 2, byte_order); ++ extract_unsigned_integer (&((buf.data ())[0]), 2, byte_order); + + tf_size = (uint32_t) +- extract_unsigned_integer (&buf[2], 4, byte_order); ++ extract_unsigned_integer (&((buf.data ())[2]), 4, byte_order); + + writer->ops->frame_ops->start (writer, tp_num); + gotten = 6; +@@ -192,7 +193,8 @@ trace_save (const char *filename, struct trace_file_writer *writer, + /* We'll fetch one block each time, in order to + handle the extremely large 'M' block. We first + fetch one byte to get the type of the block. */ +- gotten = target_get_raw_trace_data (buf, offset, 1); ++ gotten = target_get_raw_trace_data (buf.data (), ++ offset, 1); + if (gotten < 1) + error (_("Failure to get requested trace buffer data")); + +@@ -205,13 +207,13 @@ trace_save (const char *filename, struct trace_file_writer *writer, + { + case 'R': + gotten +- = target_get_raw_trace_data (buf, offset, ++ = target_get_raw_trace_data (buf.data (), offset, + trace_regblock_size); + if (gotten < trace_regblock_size) + error (_("Failure to get requested trace" + " buffer data")); + +- TRACE_WRITE_R_BLOCK (writer, buf, ++ TRACE_WRITE_R_BLOCK (writer, buf.data (), + trace_regblock_size); + break; + case 'M': +@@ -221,7 +223,8 @@ trace_save (const char *filename, struct trace_file_writer *writer, + LONGEST t; + int j; + +- t = target_get_raw_trace_data (buf,offset, 10); ++ t = target_get_raw_trace_data (buf.data (), ++ offset, 10); + if (t < 10) + error (_("Failure to get requested trace" + " buffer data")); +@@ -231,10 +234,10 @@ trace_save (const char *filename, struct trace_file_writer *writer, + + gotten = 0; + addr = (ULONGEST) +- extract_unsigned_integer (buf, 8, ++ extract_unsigned_integer (buf.data (), 8, + byte_order); + mlen = (unsigned short) +- extract_unsigned_integer (&buf[8], 2, ++ extract_unsigned_integer (&((buf.data ())[8]), 2, + byte_order); + + TRACE_WRITE_M_BLOCK_HEADER (writer, addr, +@@ -252,14 +255,15 @@ trace_save (const char *filename, struct trace_file_writer *writer, + else + read_length = mlen - j; + +- t = target_get_raw_trace_data (buf, ++ t = target_get_raw_trace_data (buf.data (), + offset + j, + read_length); + if (t < read_length) + error (_("Failure to get requested" + " trace buffer data")); + +- TRACE_WRITE_M_BLOCK_MEMORY (writer, buf, ++ TRACE_WRITE_M_BLOCK_MEMORY (writer, ++ buf.data (), + read_length); + + j += read_length; +@@ -274,18 +278,18 @@ trace_save (const char *filename, struct trace_file_writer *writer, + LONGEST val; + + gotten +- = target_get_raw_trace_data (buf, offset, +- 12); ++ = target_get_raw_trace_data (buf.data (), ++ offset, 12); + if (gotten < 12) + error (_("Failure to get requested" + " trace buffer data")); + +- vnum = (int) extract_signed_integer (buf, ++ vnum = (int) extract_signed_integer (buf.data (), + 4, + byte_order); + val +- = extract_signed_integer (&buf[4], 8, +- byte_order); ++ = extract_signed_integer (&((buf.data ())[4]), ++ 8, byte_order); + + TRACE_WRITE_V_BLOCK (writer, vnum, val); + } diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-7of7.patch b/SOURCES/gdb-rhbz1187581-power8-regs-7of7.patch new file mode 100644 index 0000000..ee82673 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-7of7.patch @@ -0,0 +1,129 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Thu, 9 Aug 2018 17:18:49 +0200 +Subject: gdb-rhbz1187581-power8-regs-7of7.patch + +;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581). + +commit a7f25a84f4cc1df5248c46346337f19a2a66af5a +Author: Simon Marchi +Date: Mon Aug 6 16:54:47 2018 -0400 + + Fix compilation failure in remote.c + + A recent patch introduced a few of these: + + /home/emaisin/src/binutils-gdb/gdb/remote.c:12862:19: error: format not a string literal and no format arguments [-Werror=format-security] + error (err_msg); + ^ + + Fix them by replacing the call to error with + + error ("%s", err_msg); + + gdb/ChangeLog: + + * remote.c (remote_target::download_tracepoint): Fix format + string errors. + ++2018-08-06 Simon Marchi ++ ++ * remote.c (remote_target::download_tracepoint): Fix format ++ string errors. ++ + 2018-08-06 Pedro Franco de Carvalho + + * tracefile.c: Include common/byte-vector.h. + +diff --git a/gdb/remote.c b/gdb/remote.c +--- a/gdb/remote.c ++++ b/gdb/remote.c +@@ -12826,7 +12826,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + t->step_count, t->pass_count); + + if (ret < 0 || ret >= buf.size ()) +- error (err_msg); ++ error ("%s", err_msg); + + /* Fast tracepoints are mostly handled by the target, but we can + tell the target how big of an instruction block should be moved +@@ -12846,7 +12846,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + gdb_insn_length (loc->gdbarch, tpaddr)); + + if (ret < 0 || ret >= size_left) +- error (err_msg); ++ error ("%s", err_msg); + } + else + /* If it passed validation at definition but fails now, +@@ -12877,7 +12877,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + size_left, ":S"); + + if (ret < 0 || ret >= size_left) +- error (err_msg); ++ error ("%s", err_msg); + } + else + error (_("Static tracepoint not valid during download")); +@@ -12905,14 +12905,14 @@ remote_target::download_tracepoint (struct bp_location *loc) + size_left, ":X%x,", aexpr->len); + + if (ret < 0 || ret >= size_left) +- error (err_msg); ++ error ("%s", err_msg); + + size_left = buf.size () - strlen (buf.data ()); + + /* Two bytes to encode each aexpr byte, plus the terminating + null byte. */ + if (aexpr->len * 2 + 1 > size_left) +- error (err_msg); ++ error ("%s", err_msg); + + pkt = buf.data () + strlen (buf.data ()); + +@@ -12933,7 +12933,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + size_left, "-"); + + if (ret < 0 || ret >= size_left) +- error (err_msg); ++ error ("%s", err_msg); + } + + putpkt (buf.data ()); +@@ -12956,7 +12956,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + has_more ? '-' : 0); + + if (ret < 0 || ret >= buf.size ()) +- error (err_msg); ++ error ("%s", err_msg); + + putpkt (buf.data ()); + remote_get_noisy_reply (); +@@ -12979,7 +12979,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + has_more ? "-" : ""); + + if (ret < 0 || ret >= buf.size ()) +- error (err_msg); ++ error ("%s", err_msg); + + putpkt (buf.data ()); + remote_get_noisy_reply (); +@@ -12994,7 +12994,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + ret = snprintf (buf.data (), buf.size (), "QTDPsrc:"); + + if (ret < 0 || ret >= buf.size ()) +- error (err_msg); ++ error ("%s", err_msg); + + encode_source_string (b->number, loc->address, "at", + event_location_to_string (b->location.get ()), +@@ -13010,7 +13010,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + ret = snprintf (buf.data (), buf.size (), "QTDPsrc:"); + + if (ret < 0 || ret >= buf.size ()) +- error (err_msg); ++ error ("%s", err_msg); + + encode_source_string (b->number, loc->address, + "cond", b->cond_string, diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-01of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-01of15.patch new file mode 100644 index 0000000..4c9dd93 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-01of15.patch @@ -0,0 +1,35 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:12 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-01of15.patch + +;; Fix remote.c build failure +;; Szabolcs Nagy, RH BZ 1187581 + +Fix gdb/remote.c build failure + +Add const qualifier to fix + +/S/gdb/common/gdb_locale.h:35:27: error: deprecated conversion from string c + # define _(String) (String) + ^ +/S/gdb/remote.c:12844:19: note: in expansion of macro '_' + char *err_msg = _("Tracepoint packet too large for target."); + ^ +gdb/ChangeLog: + + * remote.c (remote_target::download_tracepoint): Change char* to + const char*. + +diff --git a/gdb/remote.c b/gdb/remote.c +--- a/gdb/remote.c ++++ b/gdb/remote.c +@@ -12808,7 +12808,7 @@ remote_target::download_tracepoint (struct bp_location *loc) + struct tracepoint *t = (struct tracepoint *) b; + struct remote_state *rs = get_remote_state (); + int ret; +- char *err_msg = _("Tracepoint packet too large for target."); ++ const char *err_msg = _("Tracepoint packet too large for target."); + size_t size_left; + + /* We use a buffer other than rs->buf because we'll build strings diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-02of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-02of15.patch new file mode 100644 index 0000000..93b3900 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-02of15.patch @@ -0,0 +1,479 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:12 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-02of15.patch + +;; Add grok/write functions for new ppc core note sections +;; Edjunior Barbosa Machado, RH BZ 1187581 + +Add grok/write functions for new ppc core note sections + +This patch adds functions for grokking and writing more register core +note sections (NT_PPC_TAR, NT_PPC_PPR, NT_PPC_DSCR, NT_PPC_EBB, +NT_PPC_PMU, NT_PPC_TM_CGPR, NT_PPC_TM_CFPR, NT_PPC_TM_CVMX, +NT_PPC_TM_CVSX, NT_PPC_TM_SPR, NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, +NT_PPC_TM_CDSCR). + +2018-07-16 Edjunior Barbosa Machado + +bfd/ + * elf-bfd.h (elfcore_write_ppc_tar): Add prototype. + (elfcore_write_ppc_ppr): Likewise. + (elfcore_write_ppc_dscr): Likewise. + (elfcore_write_ppc_ebb): Likewise. + (elfcore_write_ppc_pmu): Likewise. + (elfcore_write_ppc_tm_cgpr): Likewise. + (elfcore_write_ppc_tm_cfpr): Likewise. + (elfcore_write_ppc_tm_cvmx): Likewise. + (elfcore_write_ppc_tm_cvsx): Likewise. + (elfcore_write_ppc_tm_spr): Likewise. + (elfcore_write_ppc_tm_ctar): Likewise. + (elfcore_write_ppc_tm_cppr): Likewise. + (elfcore_write_ppc_tm_cdscr): Likewise. + * elf.c (elfcore_write_ppc_tar): New function. + (elfcore_write_ppc_ppr): Likewise. + (elfcore_write_ppc_dscr): Likewise. + (elfcore_write_ppc_ebb): Likewise. + (elfcore_write_ppc_pmu): Likewise. + (elfcore_write_ppc_tm_cgpr): Likewise. + (elfcore_write_ppc_tm_cfpr): Likewise. + (elfcore_write_ppc_tm_cvmx): Likewise. + (elfcore_write_ppc_tm_cvsx): Likewise. + (elfcore_write_ppc_tm_spr): Likewise. + (elfcore_write_ppc_tm_ctar): Likewise. + (elfcore_write_ppc_tm_cppr): Likewise. + (elfcore_write_ppc_tm_cdscr): Likewise. + (elfcore_write_register_note): Call them. + (elfcore_grok_ppc_tar): New function. + (elfcore_grok_ppc_ppr): Likewise. + (elfcore_grok_ppc_dscr): Likewise. + (elfcore_grok_ppc_ebb): Likewise. + (elfcore_grok_ppc_pmu): Likewise. + (elfcore_grok_ppc_tm_cgpr): Likewise. + (elfcore_grok_ppc_tm_cfpr): Likewise. + (elfcore_grok_ppc_tm_cvmx): Likewise. + (elfcore_grok_ppc_tm_cvsx): Likewise. + (elfcore_grok_ppc_tm_spr): Likewise. + (elfcore_grok_ppc_tm_ctar): Likewise. + (elfcore_grok_ppc_tm_cppr): Likewise. + (elfcore_grok_ppc_tm_cdscr): Likewise. + (elfcore_grok_note): Call them. + +diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h +--- a/bfd/elf-bfd.h ++++ b/bfd/elf-bfd.h +@@ -2569,6 +2569,32 @@ extern char *elfcore_write_ppc_vmx + (bfd *, char *, int *, const void *, int); + extern char *elfcore_write_ppc_vsx + (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_tar ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_ppr ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_dscr ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_ebb ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_pmu ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_tm_cgpr ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_tm_cfpr ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_tm_cvmx ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_tm_cvsx ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_tm_spr ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_tm_ctar ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_tm_cppr ++ (bfd *, char *, int *, const void *, int); ++extern char *elfcore_write_ppc_tm_cdscr ++ (bfd *, char *, int *, const void *, int); + extern char *elfcore_write_s390_timer + (bfd *, char *, int *, const void *, int); + extern char *elfcore_write_s390_todcmp +diff --git a/bfd/elf.c b/bfd/elf.c +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -9238,6 +9238,84 @@ elfcore_grok_ppc_vsx (bfd *abfd, Elf_Internal_Note *note) + return elfcore_make_note_pseudosection (abfd, ".reg-ppc-vsx", note); + } + ++static bfd_boolean ++elfcore_grok_ppc_tar (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tar", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_ppr (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-ppr", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_dscr (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-dscr", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_ebb (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-ebb", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_pmu (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-pmu", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_tm_cgpr (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cgpr", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_tm_cfpr (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cfpr", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_tm_cvmx (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cvmx", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_tm_cvsx (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cvsx", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_tm_spr (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-spr", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_tm_ctar (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-ctar", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_tm_cppr (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cppr", note); ++} ++ ++static bfd_boolean ++elfcore_grok_ppc_tm_cdscr (bfd *abfd, Elf_Internal_Note *note) ++{ ++ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cdscr", note); ++} ++ + static bfd_boolean + elfcore_grok_s390_high_gprs (bfd *abfd, Elf_Internal_Note *note) + { +@@ -9723,6 +9801,97 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note) + else + return TRUE; + ++ case NT_PPC_TAR: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_tar (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_PPR: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_ppr (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_DSCR: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_dscr (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_EBB: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_ebb (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_PMU: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_pmu (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_TM_CGPR: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_tm_cgpr (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_TM_CFPR: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_tm_cfpr (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_TM_CVMX: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_tm_cvmx (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_TM_CVSX: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_tm_cvsx (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_TM_SPR: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_tm_spr (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_TM_CTAR: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_tm_ctar (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_TM_CPPR: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_tm_cppr (abfd, note); ++ else ++ return TRUE; ++ ++ case NT_PPC_TM_CDSCR: ++ if (note->namesz == 6 ++ && strcmp (note->namedata, "LINUX") == 0) ++ return elfcore_grok_ppc_tm_cdscr (abfd, note); ++ else ++ return TRUE; ++ + case NT_S390_HIGH_GPRS: + if (note->namesz == 6 + && strcmp (note->namedata, "LINUX") == 0) +@@ -10830,6 +10999,162 @@ elfcore_write_ppc_vsx (bfd *abfd, + note_name, NT_PPC_VSX, ppc_vsx, size); + } + ++char * ++elfcore_write_ppc_tar (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_tar, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_TAR, ppc_tar, size); ++} ++ ++char * ++elfcore_write_ppc_ppr (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_ppr, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_PPR, ppc_ppr, size); ++} ++ ++char * ++elfcore_write_ppc_dscr (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_dscr, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_DSCR, ppc_dscr, size); ++} ++ ++char * ++elfcore_write_ppc_ebb (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_ebb, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_EBB, ppc_ebb, size); ++} ++ ++char * ++elfcore_write_ppc_pmu (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_pmu, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_PMU, ppc_pmu, size); ++} ++ ++char * ++elfcore_write_ppc_tm_cgpr (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_tm_cgpr, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_TM_CGPR, ppc_tm_cgpr, size); ++} ++ ++char * ++elfcore_write_ppc_tm_cfpr (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_tm_cfpr, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_TM_CFPR, ppc_tm_cfpr, size); ++} ++ ++char * ++elfcore_write_ppc_tm_cvmx (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_tm_cvmx, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_TM_CVMX, ppc_tm_cvmx, size); ++} ++ ++char * ++elfcore_write_ppc_tm_cvsx (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_tm_cvsx, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_TM_CVSX, ppc_tm_cvsx, size); ++} ++ ++char * ++elfcore_write_ppc_tm_spr (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_tm_spr, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_TM_SPR, ppc_tm_spr, size); ++} ++ ++char * ++elfcore_write_ppc_tm_ctar (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_tm_ctar, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_TM_CTAR, ppc_tm_ctar, size); ++} ++ ++char * ++elfcore_write_ppc_tm_cppr (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_tm_cppr, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_TM_CPPR, ppc_tm_cppr, size); ++} ++ ++char * ++elfcore_write_ppc_tm_cdscr (bfd *abfd, ++ char *buf, ++ int *bufsiz, ++ const void *ppc_tm_cdscr, ++ int size) ++{ ++ char *note_name = "LINUX"; ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, NT_PPC_TM_CDSCR, ppc_tm_cdscr, size); ++} ++ + static char * + elfcore_write_s390_high_gprs (bfd *abfd, + char *buf, +@@ -11070,6 +11395,32 @@ elfcore_write_register_note (bfd *abfd, + return elfcore_write_ppc_vmx (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-ppc-vsx") == 0) + return elfcore_write_ppc_vsx (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-tar") == 0) ++ return elfcore_write_ppc_tar (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-ppr") == 0) ++ return elfcore_write_ppc_ppr (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-dscr") == 0) ++ return elfcore_write_ppc_dscr (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-ebb") == 0) ++ return elfcore_write_ppc_ebb (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-pmu") == 0) ++ return elfcore_write_ppc_pmu (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-tm-cgpr") == 0) ++ return elfcore_write_ppc_tm_cgpr (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-tm-cfpr") == 0) ++ return elfcore_write_ppc_tm_cfpr (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-tm-cvmx") == 0) ++ return elfcore_write_ppc_tm_cvmx (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-tm-cvsx") == 0) ++ return elfcore_write_ppc_tm_cvsx (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-tm-spr") == 0) ++ return elfcore_write_ppc_tm_spr (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-tm-ctar") == 0) ++ return elfcore_write_ppc_tm_ctar (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-tm-cppr") == 0) ++ return elfcore_write_ppc_tm_cppr (abfd, buf, bufsiz, data, size); ++ if (strcmp (section, ".reg-ppc-tm-cdscr") == 0) ++ return elfcore_write_ppc_tm_cdscr (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-s390-high-gprs") == 0) + return elfcore_write_s390_high_gprs (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-s390-timer") == 0) diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-03of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-03of15.patch new file mode 100644 index 0000000..0e9c2c3 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-03of15.patch @@ -0,0 +1,61 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:13 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-03of15.patch + +;; Zero-initialize linux note sections +;; Pedro Franco de Carvalho, RH BZ 1187581 + +Zero-initialize linux note sections + +This patches changes linux-tdep.c so that the buffer used to write +note sections when generating a core file is zero-initialized. This +way, bytes that are not collected won't contain random +data (e.g. padding bytes). + +gdb/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * linux-tdep.c (linux_collect_regset_section_cb): Use + std::vector instead of char * and malloc for buf. + Remove xfree. + +diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c +--- a/gdb/linux-tdep.c ++++ b/gdb/linux-tdep.c +@@ -1584,7 +1584,6 @@ linux_collect_regset_section_cb (const char *sect_name, int supply_size, + int collect_size, const struct regset *regset, + const char *human_name, void *cb_data) + { +- char *buf; + struct linux_collect_regset_section_cb_data *data + = (struct linux_collect_regset_section_cb_data *) cb_data; + bool variable_size_section = (regset != NULL +@@ -1598,19 +1597,22 @@ linux_collect_regset_section_cb (const char *sect_name, int supply_size, + + gdb_assert (regset && regset->collect_regset); + +- buf = (char *) xmalloc (collect_size); +- regset->collect_regset (regset, data->regcache, -1, buf, collect_size); ++ /* This is intentionally zero-initialized by using std::vector, so ++ that any padding bytes in the core file will show as 0. */ ++ std::vector buf (collect_size); ++ ++ regset->collect_regset (regset, data->regcache, -1, buf.data (), ++ collect_size); + + /* PRSTATUS still needs to be treated specially. */ + if (strcmp (sect_name, ".reg") == 0) + data->note_data = (char *) elfcore_write_prstatus + (data->obfd, data->note_data, data->note_size, data->lwp, +- gdb_signal_to_host (data->stop_signal), buf); ++ gdb_signal_to_host (data->stop_signal), buf.data ()); + else + data->note_data = (char *) elfcore_write_register_note + (data->obfd, data->note_data, data->note_size, +- sect_name, buf, collect_size); +- xfree (buf); ++ sect_name, buf.data (), collect_size); + + if (data->note_data == NULL) + data->abort_iteration = 1; diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-04of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-04of15.patch new file mode 100644 index 0000000..0fdac45 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-04of15.patch @@ -0,0 +1,88 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:13 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-04of15.patch + +;; [PowerPC] Don't zero-initialize vector register buffers +;; Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Don't zero-initialize vector register buffers + +Now that linux-tdep.c already zero-initializes the buffer used for +generating core file notes, there is no need to do this in the linux +collect functions for the vector regset. The memsets in gdbserver were +not useful to begin with. + +gdb/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * ppc-linux-tdep.c (ppc_linux_collect_vrregset): Remove. + (ppc32_le_linux_vrregset, ppc32_be_linux_vrregset): Replace + ppc_linux_collect_vrregset by regcache_collect_regset. + +gdb/gdbserver/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * linux-ppc-low.c (ppc_fill_vrregset): Remove memset calls. + +diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c +--- a/gdb/gdbserver/linux-ppc-low.c ++++ b/gdb/gdbserver/linux-ppc-low.c +@@ -495,13 +495,9 @@ ppc_fill_vrregset (struct regcache *regcache, void *buf) + if (__BYTE_ORDER == __BIG_ENDIAN) + vscr_offset = 12; + +- /* Zero-pad the unused bytes in the fields for vscr and vrsave in +- case they get displayed somewhere. */ +- memset (®set[32 * 16], 0, 16); + collect_register_by_name (regcache, "vscr", + ®set[32 * 16 + vscr_offset]); + +- memset (®set[33 * 16], 0, 16); + collect_register_by_name (regcache, "vrsave", ®set[33 * 16]); + } + +diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c +--- a/gdb/ppc-linux-tdep.c ++++ b/gdb/ppc-linux-tdep.c +@@ -444,24 +444,6 @@ ppc_linux_collect_gregset (const struct regset *regset, + } + } + +-static void +-ppc_linux_collect_vrregset (const struct regset *regset, +- const struct regcache *regcache, +- int regnum, void *buf, size_t len) +-{ +- gdb_byte *vrregs = (gdb_byte *) buf; +- +- /* Zero-pad the unused bytes in the fields for vscr and vrsave +- in case they get displayed somewhere (e.g. in core files). */ +- if (regnum == PPC_VSCR_REGNUM || regnum == -1) +- memset (&vrregs[32 * 16], 0, 16); +- +- if (regnum == PPC_VRSAVE_REGNUM || regnum == -1) +- memset (&vrregs[33 * 16], 0, 16); +- +- regcache_collect_regset (regset, regcache, regnum, buf, len); +-} +- + /* Regset descriptions. */ + static const struct ppc_reg_offsets ppc32_linux_reg_offsets = + { +@@ -544,13 +526,13 @@ static const struct regcache_map_entry ppc32_be_linux_vrregmap[] = + static const struct regset ppc32_le_linux_vrregset = { + ppc32_le_linux_vrregmap, + regcache_supply_regset, +- ppc_linux_collect_vrregset ++ regcache_collect_regset + }; + + static const struct regset ppc32_be_linux_vrregset = { + ppc32_be_linux_vrregmap, + regcache_supply_regset, +- ppc_linux_collect_vrregset ++ regcache_collect_regset + }; + + static const struct regcache_map_entry ppc32_linux_vsxregmap[] = diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-05of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-05of15.patch new file mode 100644 index 0000000..6ee44a0 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-05of15.patch @@ -0,0 +1,34 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:14 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-05of15.patch + +;; Add decfloat registers to float reggroup +;; Pedro Franco de Carvalho, RH BZ 1187581 + +Add decfloat registers to float reggroup + +This patch changes default_register_reggroup_p to return true when the +register type is decimal floating point and the reggroup is +float_reggroup. + +gdb/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * reggroups.c (default_register_reggroup_p): Return true for + decfloat registers and float_reggroup. + +diff --git a/gdb/reggroups.c b/gdb/reggroups.c +--- a/gdb/reggroups.c ++++ b/gdb/reggroups.c +@@ -202,7 +202,9 @@ default_register_reggroup_p (struct gdbarch *gdbarch, int regnum, + if (group == all_reggroup) + return 1; + vector_p = TYPE_VECTOR (register_type (gdbarch, regnum)); +- float_p = TYPE_CODE (register_type (gdbarch, regnum)) == TYPE_CODE_FLT; ++ float_p = (TYPE_CODE (register_type (gdbarch, regnum)) == TYPE_CODE_FLT ++ || (TYPE_CODE (register_type (gdbarch, regnum)) ++ == TYPE_CODE_DECFLOAT)); + raw_p = regnum < gdbarch_num_regs (gdbarch); + if (group == float_reggroup) + return float_p; diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-06of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-06of15.patch new file mode 100644 index 0000000..0b61c35 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-06of15.patch @@ -0,0 +1,72 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:14 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-06of15.patch + +;; [PowerPC] Remove rs6000_pseudo_register_reggroup_p +;; Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Remove rs6000_pseudo_register_reggroup_p + +This patch removes rs6000_pseudo_register_reggroup_p. + +Group membership for the pseudoregisters can be detected through their +types in default_register_reggroup_p through +tdesc_register_reggroup_p. + +gdb/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * rs6000-tdep.c: Remove reggroups.h include. + (rs6000_pseudo_register_reggroup_p): Remove. + (rs6000_gdbarch_init): Remove call to + set_tdesc_pseudo_register_reggroup_p. + +diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c +--- a/gdb/rs6000-tdep.c ++++ b/gdb/rs6000-tdep.c +@@ -36,7 +36,6 @@ + #include "infcall.h" + #include "sim-regno.h" + #include "gdb/sim-ppc.h" +-#include "reggroups.h" + #include "dwarf2-frame.h" + #include "target-descriptions.h" + #include "user-regs.h" +@@ -2461,27 +2460,6 @@ rs6000_pseudo_register_type (struct gdbarch *gdbarch, int regnum) + return builtin_type (gdbarch)->builtin_double; + } + +-/* Is REGNUM a member of REGGROUP? */ +-static int +-rs6000_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum, +- struct reggroup *group) +-{ +- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); +- +- /* These are the only pseudo-registers we support. */ +- gdb_assert (IS_SPE_PSEUDOREG (tdep, regnum) +- || IS_DFP_PSEUDOREG (tdep, regnum) +- || IS_VSX_PSEUDOREG (tdep, regnum) +- || IS_EFP_PSEUDOREG (tdep, regnum)); +- +- /* These are the e500 pseudo-registers or the POWER7 VSX registers. */ +- if (IS_SPE_PSEUDOREG (tdep, regnum) || IS_VSX_PSEUDOREG (tdep, regnum)) +- return group == all_reggroup || group == vector_reggroup; +- else +- /* PPC decimal128 or Extended FP pseudo-registers. */ +- return group == all_reggroup || group == float_reggroup; +-} +- + /* The register format for RS/6000 floating point registers is always + double, we need a conversion if the memory format is float. */ + +@@ -6493,8 +6471,6 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + } + + set_tdesc_pseudo_register_type (gdbarch, rs6000_pseudo_register_type); +- set_tdesc_pseudo_register_reggroup_p (gdbarch, +- rs6000_pseudo_register_reggroup_p); + tdesc_use_registers (gdbarch, tdesc, tdesc_data); + + /* Override the normal target description method to make the SPE upper diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-07of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-07of15.patch new file mode 100644 index 0000000..9b6da0c --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-07of15.patch @@ -0,0 +1,41 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:15 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-07of15.patch + +;; [PowerPC] Fix two if statements in gdb/ppc-linux-nat.c +;; Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Fix two if statements in gdb/ppc-linux-nat.c + +This patch changes two if statements to else if statements in +ppc-linux-nat.c:fetch_register for clarity. + +gdb/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * ppc-linux-nat.c (fetch_register): Change if statement to else + if. + (store_register): Likewise. + +diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c +--- a/gdb/ppc-linux-nat.c ++++ b/gdb/ppc-linux-nat.c +@@ -554,7 +554,7 @@ fetch_register (struct regcache *regcache, int tid, int regno) + AltiVec registers, fall through and return zeroes, because + regaddr will be -1 in this case. */ + } +- if (vsx_register_p (gdbarch, regno)) ++ else if (vsx_register_p (gdbarch, regno)) + { + if (have_ptrace_getsetvsxregs) + { +@@ -933,7 +933,7 @@ store_register (const struct regcache *regcache, int tid, int regno) + store_altivec_registers (regcache, tid, regno); + return; + } +- if (vsx_register_p (gdbarch, regno)) ++ else if (vsx_register_p (gdbarch, regno)) + { + store_vsx_registers (regcache, tid, regno); + return; diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-08of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-08of15.patch new file mode 100644 index 0000000..5e04ffc --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-08of15.patch @@ -0,0 +1,64 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:15 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-08of15.patch + +;; [PowerPC] Fix indentation in arch/ppc-linux-common.c +;; Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Fix indentation in arch/ppc-linux-common.c + +This patch parenthesizes the tdesc selection expressions in +arch/ppc-linux-common.c so that they can be tab-indented. + +gdb/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * arch/ppc-linux-common.c (ppc_linux_match_description): + Parenthesize tdesc assignements and indent them properly. + +diff --git a/gdb/arch/ppc-linux-common.c b/gdb/arch/ppc-linux-common.c +--- a/gdb/arch/ppc-linux-common.c ++++ b/gdb/arch/ppc-linux-common.c +@@ -53,14 +53,14 @@ ppc_linux_match_description (struct ppc_linux_features features) + if (features.cell) + tdesc = tdesc_powerpc_cell64l; + else if (features.vsx) +- tdesc = features.isa205 +- ? tdesc_powerpc_isa205_vsx64l : tdesc_powerpc_vsx64l; ++ tdesc = (features.isa205? tdesc_powerpc_isa205_vsx64l ++ : tdesc_powerpc_vsx64l); + else if (features.altivec) +- tdesc = features.isa205 +- ? tdesc_powerpc_isa205_altivec64l : tdesc_powerpc_altivec64l; ++ tdesc = (features.isa205? tdesc_powerpc_isa205_altivec64l ++ : tdesc_powerpc_altivec64l); + else +- tdesc = features.isa205? +- tdesc_powerpc_isa205_64l : tdesc_powerpc_64l; ++ tdesc = (features.isa205? tdesc_powerpc_isa205_64l ++ : tdesc_powerpc_64l); + } + else + { +@@ -69,14 +69,14 @@ ppc_linux_match_description (struct ppc_linux_features features) + if (features.cell) + tdesc = tdesc_powerpc_cell32l; + else if (features.vsx) +- tdesc = features.isa205 +- ? tdesc_powerpc_isa205_vsx32l : tdesc_powerpc_vsx32l; ++ tdesc = (features.isa205? tdesc_powerpc_isa205_vsx32l ++ : tdesc_powerpc_vsx32l); + else if (features.altivec) +- tdesc = features.isa205 +- ? tdesc_powerpc_isa205_altivec32l : tdesc_powerpc_altivec32l; ++ tdesc = (features.isa205? tdesc_powerpc_isa205_altivec32l ++ : tdesc_powerpc_altivec32l); + else +- tdesc = features.isa205 +- ? tdesc_powerpc_isa205_32l : tdesc_powerpc_32l; ++ tdesc = (features.isa205? tdesc_powerpc_isa205_32l ++ : tdesc_powerpc_32l); + } + + gdb_assert (tdesc != NULL); diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-09of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-09of15.patch new file mode 100644 index 0000000..e95c1ad --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-09of15.patch @@ -0,0 +1,36 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:16 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-09of15.patch + +;; [PowerPC] Refactor have_ initializers in rs6000-tdep.c +;; Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Refactor have_ initializers in rs6000-tdep.c + +This patch refactors a series of initializers in rs6000_gdbarch_init +for clarity. The have_fpu initializer is also changed to set the +variable to 0, like the other similar variables. This doesn't affect +program behavior. + +gdb/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * rs6000-tdep.c (rs6000_gdbarch_init): Replace line wrapping by a + second initializer line for the have_* variables. Initialize + have_fpu to 0 instead of 1. + +diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c +--- a/gdb/rs6000-tdep.c ++++ b/gdb/rs6000-tdep.c +@@ -5845,8 +5845,8 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + enum powerpc_long_double_abi long_double_abi = POWERPC_LONG_DOUBLE_AUTO; + enum powerpc_vector_abi vector_abi = powerpc_vector_abi_global; + enum powerpc_elf_abi elf_abi = POWERPC_ELF_AUTO; +- int have_fpu = 1, have_spe = 0, have_mq = 0, have_altivec = 0, have_dfp = 0, +- have_vsx = 0; ++ int have_fpu = 0, have_spe = 0, have_mq = 0, have_altivec = 0; ++ int have_dfp = 0, have_vsx = 0; + int tdesc_wordsize = -1; + const struct target_desc *tdesc = info.target_desc; + struct tdesc_arch_data *tdesc_data = NULL; diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-10of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-10of15.patch new file mode 100644 index 0000000..0b36464 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-10of15.patch @@ -0,0 +1,1987 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:16 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-10of15.patch + +;; [PowerPC] Add support for PPR and DSCR +;; Edjunior Barbosa Machado and Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Add support for PPR and DSCR + +This patch adds gdb support for the Program Priorty Register and the +Data Stream Control Register, for the powerpc linux native and core +file targets, and for the powerpc linux server stub. + +gdb/ChangeLog: +2018-10-26 Edjunior Barbosa Machado + Pedro Franco de Carvalho + + * arch/ppc-linux-tdesc.h (tdesc_powerpc_isa205_ppr_dscr_vsx32l) + (tdesc_powerpc_isa205_ppr_dscr_vsx64l): Declare. + * arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_PPRREGSET) + (PPC_LINUX_SIZEOF_DSCRREGSET): Define. + (struct ppc_linux_features) : New field. + (ppc_linux_no_features): Add initializer for ppr_dscr field. + * arch/ppc-linux-common.c (ppc_linux_match_description): Return + new tdescs. + * nat/ppc-linux.h (PPC_FEATURE2_DSCR, NT_PPC_PPR, NT_PPC_DSCR): + Define if not already defined. + * features/Makefile (WHICH): Add + rs6000/powerpc-isa205-ppr-dscr-vsx32l and + rs6000/powerpc-isa205-ppr-dscr-vsx64l. + (XMLTOC): Add rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml and + rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml. + * features/rs6000/power-dscr.xml: New file. + * features/rs6000/power-ppr.xml: New file. + * features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml: New file. + * features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml: New file. + * features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c: Generate. + * features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c: Generate. + * regformats/rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat: Generate. + * regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat: Generate. + * ppc-linux-nat.c: Include . + (fetch_regset, store_regset, check_regset): New functions. + (fetch_register, fetch_ppc_registers): Call fetch_regset with + DSCR and PPR regsets. + (store_register, store_ppc_registers): Call store_regset with + DSCR and PPR regsets. + (ppc_linux_get_hwcap2): New function. + (ppc_linux_nat_target::read_description): Call + ppc_linux_get_hwcap2 and check_regset, set ppr_dscr field in the + features struct if needed. + * ppc-linux-tdep.c: Include + features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c and + features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c. + (ppc32_regmap_ppr, ppc32_regmap_dscr, ppc32_linux_pprregset) + (ppc32_linux_dscrregset): New globals. + (ppc_linux_iterate_over_regset_sections): Call back with the ppr + and dscr regsets. + (ppc_linux_core_read_description): Check if the ppr and dscr + sections are present and set ppr_dscr in the features struct. + (_initialize_ppc_linux_tdep): Call + initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l and + initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l. + * ppc-linux-tdep.h (ppc32_linux_pprregset) + (ppc32_linux_dscrregset): Declare. + * ppc-tdep.h (struct gdbarch_tdep) : New field. + : New field. + (enum) : New enum values. + * rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate ppr + and dscr features. + (ppc_process_record_op31): Record changes to PPR and DSCR. + +gdb/gdbserver/ChangeLog: +2018-10-26 Edjunior Barbosa Machado + Pedro Franco de Carvalho + + * configure.srv (ipa_ppc_linux_regobj): Add + powerpc-isa205-ppr-dscr-vsx32l-ipa.o and + powerpc-isa205-ppr-dscr-vsx64l-ipa.o. + (powerpc*-*-linux*): Add powerpc-isa205-ppr-dscr-vsx32l.o and + powerpc-isa205-ppr-dscr-vsx64l.o to srv_regobj, add + rs6000/power-dscr.xml, rs6000/power-ppr.xml, + rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml and + rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml to srv_xmlfiles. + * linux-ppc-tdesc-init.h (enum ppc_linux_tdesc) + : New enum value. + (init_registers_powerpc_isa205_ppr_dscr_vsx32l) + (init_registers_powerpc_isa205_ppr_dscr_vsx64l): Declare. + * linux-ppc-low.c: Include "elf/common.h" and . + (ppc_hwcap): Add comment. + (ppc_hwcap2): New global. + (ppc_check_regset, ppc_fill_pprregset, ppc_store_pprregset) + (ppc_fill_dscrregset, ppc_store_dscrregset): New functions. + (ppc_regsets): Add entries for the DSCR and PPR regsets. + (ppc_arch_setup): Get AT_HWCAP2. Set ppr_dscr in features struct + when needed. Set sizes for the the DSCR and PPR regsets. + (ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA205_PPR_DSCR_VSX. + (initialize_low_arch): Call + init_registers_powerpc_isa205_ppr_dscr_vsx32l and + init_registers_powerpc_isa205_ppr_dscr_vsx64l. + * linux-ppc-ipa.c (get_ipa_tdesc): Handle + PPC_TDESC_ISA205_PPR_DSCR_VSX. + (initialize_low_tracepoint): Call + init_registers_powerpc_isa205_ppr_dscr_vsx32l and + init_registers_powerpc_isa205_ppr_dscr_vsx64l. + +gdb/testsuite/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * gdb.arch/powerpc-ppr-dscr.c: New file. + * gdb.arch/powerpc-ppr-dscr.exp: New file. + +gdb/doc/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * gdb.texinfo (PowerPC Features): Describe new features + "org.gnu.gdb.power.ppr" and "org.gnu.gdb.power.dscr". + +diff --git a/gdb/arch/ppc-linux-common.c b/gdb/arch/ppc-linux-common.c +--- a/gdb/arch/ppc-linux-common.c ++++ b/gdb/arch/ppc-linux-common.c +@@ -53,7 +53,8 @@ ppc_linux_match_description (struct ppc_linux_features features) + if (features.cell) + tdesc = tdesc_powerpc_cell64l; + else if (features.vsx) +- tdesc = (features.isa205? tdesc_powerpc_isa205_vsx64l ++ tdesc = (features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx64l ++ : features.isa205? tdesc_powerpc_isa205_vsx64l + : tdesc_powerpc_vsx64l); + else if (features.altivec) + tdesc = (features.isa205? tdesc_powerpc_isa205_altivec64l +@@ -69,7 +70,8 @@ ppc_linux_match_description (struct ppc_linux_features features) + if (features.cell) + tdesc = tdesc_powerpc_cell32l; + else if (features.vsx) +- tdesc = (features.isa205? tdesc_powerpc_isa205_vsx32l ++ tdesc = (features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx32l ++ : features.isa205? tdesc_powerpc_isa205_vsx32l + : tdesc_powerpc_vsx32l); + else if (features.altivec) + tdesc = (features.isa205? tdesc_powerpc_isa205_altivec32l +diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h +--- a/gdb/arch/ppc-linux-common.h ++++ b/gdb/arch/ppc-linux-common.h +@@ -30,6 +30,8 @@ struct target_desc; + #define PPC_LINUX_SIZEOF_VRREGSET 544 + + #define PPC_LINUX_SIZEOF_VSXREGSET 256 ++#define PPC_LINUX_SIZEOF_PPRREGSET 8 ++#define PPC_LINUX_SIZEOF_DSCRREGSET 8 + + /* Check if the hwcap auxv entry indicates that isa205 is supported. */ + bool ppc_linux_has_isa205 (CORE_ADDR hwcap); +@@ -41,6 +43,7 @@ struct ppc_linux_features + bool altivec; + bool vsx; + bool isa205; ++ bool ppr_dscr; + bool cell; + }; + +@@ -51,6 +54,7 @@ const struct ppc_linux_features ppc_linux_no_features = { + false, + false, + false, ++ false, + }; + + /* Return a target description that matches FEATURES. */ +diff --git a/gdb/arch/ppc-linux-tdesc.h b/gdb/arch/ppc-linux-tdesc.h +--- a/gdb/arch/ppc-linux-tdesc.h ++++ b/gdb/arch/ppc-linux-tdesc.h +@@ -29,6 +29,7 @@ extern struct target_desc *tdesc_powerpc_vsx32l; + extern struct target_desc *tdesc_powerpc_isa205_32l; + extern struct target_desc *tdesc_powerpc_isa205_altivec32l; + extern struct target_desc *tdesc_powerpc_isa205_vsx32l; ++extern struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx32l; + extern struct target_desc *tdesc_powerpc_e500l; + + extern struct target_desc *tdesc_powerpc_64l; +@@ -38,5 +39,6 @@ extern struct target_desc *tdesc_powerpc_vsx64l; + extern struct target_desc *tdesc_powerpc_isa205_64l; + extern struct target_desc *tdesc_powerpc_isa205_altivec64l; + extern struct target_desc *tdesc_powerpc_isa205_vsx64l; ++extern struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l; + + #endif /* ARCH_PPC_LINUX_TDESC_H */ +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -42555,6 +42555,12 @@ contain registers @samp{ev0h} through @samp{ev31h}, @samp{acc}, and + these to present registers @samp{ev0} through @samp{ev31} to the + user. + ++The @samp{org.gnu.gdb.power.ppr} feature is optional. It should ++contain the 64-bit register @samp{ppr}. ++ ++The @samp{org.gnu.gdb.power.dscr} feature is optional. It should ++contain the 64-bit register @samp{dscr}. ++ + @node S/390 and System z Features + @subsection S/390 and System z Features + @cindex target descriptions, S/390 features +diff --git a/gdb/features/Makefile b/gdb/features/Makefile +--- a/gdb/features/Makefile ++++ b/gdb/features/Makefile +@@ -73,6 +73,8 @@ WHICH = aarch64 \ + rs6000/powerpc-isa205-32l rs6000/powerpc-isa205-64l \ + rs6000/powerpc-isa205-altivec32l rs6000/powerpc-isa205-altivec64l \ + rs6000/powerpc-isa205-vsx32l rs6000/powerpc-isa205-vsx64l \ ++ rs6000/powerpc-isa205-ppr-dscr-vsx32l \ ++ rs6000/powerpc-isa205-ppr-dscr-vsx64l \ + s390-linux32 s390-linux64 s390x-linux64 \ + s390-linux32v1 s390-linux64v1 s390x-linux64v1 \ + s390-linux32v2 s390-linux64v2 s390x-linux64v2 \ +@@ -167,6 +169,8 @@ XMLTOC = \ + rs6000/powerpc-isa205-altivec64l.xml \ + rs6000/powerpc-isa205-vsx32l.xml \ + rs6000/powerpc-isa205-vsx64l.xml \ ++ rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml \ ++ rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml \ + rs6000/powerpc-vsx32.xml \ + rs6000/powerpc-vsx32l.xml \ + rs6000/powerpc-vsx64.xml \ +diff --git a/gdb/features/rs6000/power-dscr.xml b/gdb/features/rs6000/power-dscr.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-dscr.xml +@@ -0,0 +1,12 @@ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power-ppr.xml b/gdb/features/rs6000/power-ppr.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-ppr.xml +@@ -0,0 +1,12 @@ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c +@@ -0,0 +1,200 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: powerpc-isa205-ppr-dscr-vsx32l.xml */ ++ ++#include "defs.h" ++#include "osabi.h" ++#include "target-descriptions.h" ++ ++struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx32l; ++static void ++initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l (void) ++{ ++ struct target_desc *result = allocate_target_description (); ++ set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common")); ++ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.core"); ++ tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r16", 16, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r17", 17, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r18", 18, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r19", 19, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r20", 20, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r21", 21, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r22", 22, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r23", 23, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r24", 24, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r25", 25, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r26", 26, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r27", 27, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r28", 28, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r29", 29, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r30", 30, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r31", 31, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "pc", 64, 1, NULL, 32, "code_ptr"); ++ tdesc_create_reg (feature, "msr", 65, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr", 66, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "lr", 67, 1, NULL, 32, "code_ptr"); ++ tdesc_create_reg (feature, "ctr", 68, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "xer", 69, 1, NULL, 32, "uint32"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.fpu"); ++ tdesc_create_reg (feature, "f0", 32, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f1", 33, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f2", 34, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f3", 35, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f4", 36, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f5", 37, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f6", 38, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f7", 39, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f8", 40, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f9", 41, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f10", 42, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f11", 43, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f12", 44, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f13", 45, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f14", 46, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f15", 47, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f16", 48, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f17", 49, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f18", 50, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f19", 51, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f20", 52, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f21", 53, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f22", 54, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f23", 55, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f24", 56, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f25", 57, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f26", 58, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f27", 59, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f28", 60, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f29", 61, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f30", 62, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f31", 63, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "fpscr", 70, 1, "float", 64, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux"); ++ tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 32, "int"); ++ tdesc_create_reg (feature, "trap", 72, 1, NULL, 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.altivec"); ++ tdesc_type *element_type; ++ element_type = tdesc_named_type (feature, "ieee_single"); ++ tdesc_create_vector (feature, "v4f", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int32"); ++ tdesc_create_vector (feature, "v4i32", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int16"); ++ tdesc_create_vector (feature, "v8i16", element_type, 8); ++ ++ element_type = tdesc_named_type (feature, "int8"); ++ tdesc_create_vector (feature, "v16i8", element_type, 16); ++ ++ tdesc_type_with_fields *type_with_fields; ++ type_with_fields = tdesc_create_union (feature, "vec128"); ++ tdesc_type *field_type; ++ field_type = tdesc_named_type (feature, "uint128"); ++ tdesc_add_field (type_with_fields, "uint128", field_type); ++ field_type = tdesc_named_type (feature, "v4f"); ++ tdesc_add_field (type_with_fields, "v4_float", field_type); ++ field_type = tdesc_named_type (feature, "v4i32"); ++ tdesc_add_field (type_with_fields, "v4_int32", field_type); ++ field_type = tdesc_named_type (feature, "v8i16"); ++ tdesc_add_field (type_with_fields, "v8_int16", field_type); ++ field_type = tdesc_named_type (feature, "v16i8"); ++ tdesc_add_field (type_with_fields, "v16_int8", field_type); ++ ++ tdesc_create_reg (feature, "vr0", 73, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr1", 74, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr2", 75, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr3", 76, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr4", 77, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr5", 78, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr6", 79, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr7", 80, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr8", 81, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr9", 82, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr10", 83, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr11", 84, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr12", 85, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr13", 86, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr14", 87, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr15", 88, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr16", 89, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr17", 90, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr18", 91, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr19", 92, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr20", 93, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr21", 94, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr22", 95, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr23", 96, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr24", 97, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr25", 98, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr26", 99, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr27", 100, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr28", 101, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr29", 102, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr30", 103, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr31", 104, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int"); ++ tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.vsx"); ++ tdesc_create_reg (feature, "vs0h", 107, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs1h", 108, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs2h", 109, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs3h", 110, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs4h", 111, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs5h", 112, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs6h", 113, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs7h", 114, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs8h", 115, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs9h", 116, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs10h", 117, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs11h", 118, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs12h", 119, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs13h", 120, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs14h", 121, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs15h", 122, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs16h", 123, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs17h", 124, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs18h", 125, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs19h", 126, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs20h", 127, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs21h", 128, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs22h", 129, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs23h", 130, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs24h", 131, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs25h", 132, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs26h", 133, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs27h", 134, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs28h", 135, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs29h", 136, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ppr"); ++ tdesc_create_reg (feature, "ppr", 139, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.dscr"); ++ tdesc_create_reg (feature, "dscr", 140, 1, NULL, 64, "uint64"); ++ ++ tdesc_powerpc_isa205_ppr_dscr_vsx32l = result; ++} +diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml +@@ -0,0 +1,18 @@ ++ ++ ++ ++ ++ ++ powerpc:common ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c +@@ -0,0 +1,200 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: powerpc-isa205-ppr-dscr-vsx64l.xml */ ++ ++#include "defs.h" ++#include "osabi.h" ++#include "target-descriptions.h" ++ ++struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l; ++static void ++initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l (void) ++{ ++ struct target_desc *result = allocate_target_description (); ++ set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64")); ++ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.core"); ++ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r3", 3, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r4", 4, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r5", 5, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r6", 6, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r7", 7, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r8", 8, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r9", 9, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r10", 10, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r11", 11, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r12", 12, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r13", 13, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r14", 14, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r15", 15, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r16", 16, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r17", 17, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r18", 18, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r19", 19, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r20", 20, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r21", 21, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r22", 22, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r23", 23, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r24", 24, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r25", 25, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r26", 26, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r27", 27, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r28", 28, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r29", 29, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r30", 30, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r31", 31, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "pc", 64, 1, NULL, 64, "code_ptr"); ++ tdesc_create_reg (feature, "msr", 65, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr", 66, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "lr", 67, 1, NULL, 64, "code_ptr"); ++ tdesc_create_reg (feature, "ctr", 68, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "xer", 69, 1, NULL, 32, "uint32"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.fpu"); ++ tdesc_create_reg (feature, "f0", 32, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f1", 33, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f2", 34, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f3", 35, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f4", 36, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f5", 37, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f6", 38, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f7", 39, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f8", 40, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f9", 41, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f10", 42, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f11", 43, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f12", 44, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f13", 45, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f14", 46, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f15", 47, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f16", 48, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f17", 49, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f18", 50, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f19", 51, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f20", 52, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f21", 53, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f22", 54, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f23", 55, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f24", 56, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f25", 57, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f26", 58, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f27", 59, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f28", 60, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f29", 61, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f30", 62, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f31", 63, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "fpscr", 70, 1, "float", 64, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux"); ++ tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "trap", 72, 1, NULL, 64, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.altivec"); ++ tdesc_type *element_type; ++ element_type = tdesc_named_type (feature, "ieee_single"); ++ tdesc_create_vector (feature, "v4f", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int32"); ++ tdesc_create_vector (feature, "v4i32", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int16"); ++ tdesc_create_vector (feature, "v8i16", element_type, 8); ++ ++ element_type = tdesc_named_type (feature, "int8"); ++ tdesc_create_vector (feature, "v16i8", element_type, 16); ++ ++ tdesc_type_with_fields *type_with_fields; ++ type_with_fields = tdesc_create_union (feature, "vec128"); ++ tdesc_type *field_type; ++ field_type = tdesc_named_type (feature, "uint128"); ++ tdesc_add_field (type_with_fields, "uint128", field_type); ++ field_type = tdesc_named_type (feature, "v4f"); ++ tdesc_add_field (type_with_fields, "v4_float", field_type); ++ field_type = tdesc_named_type (feature, "v4i32"); ++ tdesc_add_field (type_with_fields, "v4_int32", field_type); ++ field_type = tdesc_named_type (feature, "v8i16"); ++ tdesc_add_field (type_with_fields, "v8_int16", field_type); ++ field_type = tdesc_named_type (feature, "v16i8"); ++ tdesc_add_field (type_with_fields, "v16_int8", field_type); ++ ++ tdesc_create_reg (feature, "vr0", 73, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr1", 74, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr2", 75, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr3", 76, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr4", 77, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr5", 78, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr6", 79, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr7", 80, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr8", 81, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr9", 82, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr10", 83, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr11", 84, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr12", 85, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr13", 86, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr14", 87, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr15", 88, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr16", 89, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr17", 90, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr18", 91, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr19", 92, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr20", 93, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr21", 94, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr22", 95, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr23", 96, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr24", 97, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr25", 98, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr26", 99, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr27", 100, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr28", 101, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr29", 102, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr30", 103, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr31", 104, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int"); ++ tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.vsx"); ++ tdesc_create_reg (feature, "vs0h", 107, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs1h", 108, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs2h", 109, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs3h", 110, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs4h", 111, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs5h", 112, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs6h", 113, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs7h", 114, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs8h", 115, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs9h", 116, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs10h", 117, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs11h", 118, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs12h", 119, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs13h", 120, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs14h", 121, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs15h", 122, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs16h", 123, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs17h", 124, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs18h", 125, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs19h", 126, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs20h", 127, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs21h", 128, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs22h", 129, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs23h", 130, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs24h", 131, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs25h", 132, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs26h", 133, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs27h", 134, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs28h", 135, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs29h", 136, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ppr"); ++ tdesc_create_reg (feature, "ppr", 139, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.dscr"); ++ tdesc_create_reg (feature, "dscr", 140, 1, NULL, 64, "uint64"); ++ ++ tdesc_powerpc_isa205_ppr_dscr_vsx64l = result; ++} +diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml +@@ -0,0 +1,18 @@ ++ ++ ++ ++ ++ ++ powerpc:common64 ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv +--- a/gdb/gdbserver/configure.srv ++++ b/gdb/gdbserver/configure.srv +@@ -32,7 +32,7 @@ else + srv_amd64_linux_regobj="" + fi + +-ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o" ++ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-isa205-ppr-dscr-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o powerpc-isa205-ppr-dscr-vsx64l-ipa.o" + + # Linux object files. This is so we don't have to repeat + # these files over and over again. +@@ -217,6 +217,7 @@ case "${target}" in + srv_regobj="${srv_regobj} powerpc-isa205-32l.o" + srv_regobj="${srv_regobj} powerpc-isa205-altivec32l.o" + srv_regobj="${srv_regobj} powerpc-isa205-vsx32l.o" ++ srv_regobj="${srv_regobj} powerpc-isa205-ppr-dscr-vsx32l.o" + srv_regobj="${srv_regobj} powerpc-e500l.o" + srv_regobj="${srv_regobj} powerpc-64l.o" + srv_regobj="${srv_regobj} powerpc-altivec64l.o" +@@ -225,6 +226,7 @@ case "${target}" in + srv_regobj="${srv_regobj} powerpc-isa205-64l.o" + srv_regobj="${srv_regobj} powerpc-isa205-altivec64l.o" + srv_regobj="${srv_regobj} powerpc-isa205-vsx64l.o" ++ srv_regobj="${srv_regobj} powerpc-isa205-ppr-dscr-vsx64l.o" + srv_tgtobj="$srv_linux_obj linux-ppc-low.o ppc-linux.o" + srv_tgtobj="${srv_tgtobj} arch/ppc-linux-common.o" + srv_xmlfiles="rs6000/powerpc-32l.xml" +@@ -234,12 +236,15 @@ case "${target}" in + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-altivec32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx32l.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-altivec.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-vsx.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-core.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-linux.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-fpu.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-fpu-isa205.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-dscr.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-ppr.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-e500l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-spe.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-64l.xml" +@@ -249,6 +254,7 @@ case "${target}" in + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-altivec64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx64l.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power64-core.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power64-linux.xml" + srv_linux_usrregs=yes +diff --git a/gdb/gdbserver/linux-ppc-ipa.c b/gdb/gdbserver/linux-ppc-ipa.c +--- a/gdb/gdbserver/linux-ppc-ipa.c ++++ b/gdb/gdbserver/linux-ppc-ipa.c +@@ -191,6 +191,8 @@ get_ipa_tdesc (int idx) + return tdesc_powerpc_isa205_altivec64l; + case PPC_TDESC_ISA205_VSX: + return tdesc_powerpc_isa205_vsx64l; ++ case PPC_TDESC_ISA205_PPR_DSCR_VSX: ++ return tdesc_powerpc_isa205_ppr_dscr_vsx64l; + #else + case PPC_TDESC_BASE: + return tdesc_powerpc_32l; +@@ -206,6 +208,8 @@ get_ipa_tdesc (int idx) + return tdesc_powerpc_isa205_altivec32l; + case PPC_TDESC_ISA205_VSX: + return tdesc_powerpc_isa205_vsx32l; ++ case PPC_TDESC_ISA205_PPR_DSCR_VSX: ++ return tdesc_powerpc_isa205_ppr_dscr_vsx32l; + case PPC_TDESC_E500: + return tdesc_powerpc_e500l; + #endif +@@ -234,6 +238,7 @@ initialize_low_tracepoint (void) + init_registers_powerpc_isa205_64l (); + init_registers_powerpc_isa205_altivec64l (); + init_registers_powerpc_isa205_vsx64l (); ++ init_registers_powerpc_isa205_ppr_dscr_vsx64l (); + #else + init_registers_powerpc_32l (); + init_registers_powerpc_altivec32l (); +@@ -242,6 +247,7 @@ initialize_low_tracepoint (void) + init_registers_powerpc_isa205_32l (); + init_registers_powerpc_isa205_altivec32l (); + init_registers_powerpc_isa205_vsx32l (); ++ init_registers_powerpc_isa205_ppr_dscr_vsx32l (); + init_registers_powerpc_e500l (); + #endif + } +diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c +--- a/gdb/gdbserver/linux-ppc-low.c ++++ b/gdb/gdbserver/linux-ppc-low.c +@@ -20,6 +20,8 @@ + #include "server.h" + #include "linux-low.h" + ++#include "elf/common.h" ++#include + #include + #include + +@@ -41,8 +43,14 @@ + #define PPC_LI(insn) (PPC_SEXT (PPC_FIELD (insn, 6, 24), 24) << 2) + #define PPC_BD(insn) (PPC_SEXT (PPC_FIELD (insn, 16, 14), 14) << 2) + ++/* Holds the AT_HWCAP auxv entry. */ ++ + static unsigned long ppc_hwcap; + ++/* Holds the AT_HWCAP2 auxv entry. */ ++ ++static unsigned long ppc_hwcap2; ++ + + #define ppc_num_regs 73 + +@@ -116,6 +124,24 @@ static int ppc_regmap_e500[] = + }; + #endif + ++/* Check whether the kernel provides a register set with number ++ REGSET_ID of size REGSETSIZE for process/thread TID. */ ++ ++static int ++ppc_check_regset (int tid, int regset_id, int regsetsize) ++{ ++ void *buf = alloca (regsetsize); ++ struct iovec iov; ++ ++ iov.iov_base = buf; ++ iov.iov_len = regsetsize; ++ ++ if (ptrace (PTRACE_GETREGSET, tid, regset_id, &iov) >= 0 ++ || errno == ENODATA) ++ return 1; ++ return 0; ++} ++ + static int + ppc_cannot_store_register (int regno) + { +@@ -459,6 +485,46 @@ static void ppc_fill_gregset (struct regcache *regcache, void *buf) + ppc_collect_ptrace_register (regcache, i, (char *) buf + ppc_regmap[i]); + } + ++/* Program Priority Register regset fill function. */ ++ ++static void ++ppc_fill_pprregset (struct regcache *regcache, void *buf) ++{ ++ char *ppr = (char *) buf; ++ ++ collect_register_by_name (regcache, "ppr", ppr); ++} ++ ++/* Program Priority Register regset store function. */ ++ ++static void ++ppc_store_pprregset (struct regcache *regcache, const void *buf) ++{ ++ const char *ppr = (const char *) buf; ++ ++ supply_register_by_name (regcache, "ppr", ppr); ++} ++ ++/* Data Stream Control Register regset fill function. */ ++ ++static void ++ppc_fill_dscrregset (struct regcache *regcache, void *buf) ++{ ++ char *dscr = (char *) buf; ++ ++ collect_register_by_name (regcache, "dscr", dscr); ++} ++ ++/* Data Stream Control Register regset store function. */ ++ ++static void ++ppc_store_dscrregset (struct regcache *regcache, const void *buf) ++{ ++ const char *dscr = (const char *) buf; ++ ++ supply_register_by_name (regcache, "dscr", dscr); ++} ++ + static void + ppc_fill_vsxregset (struct regcache *regcache, void *buf) + { +@@ -568,6 +634,10 @@ static struct regset_info ppc_regsets[] = { + fetch them every time, but still fall back to PTRACE_PEEKUSER for the + general registers. Some kernels support these, but not the newer + PPC_PTRACE_GETREGS. */ ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_PPR, 0, EXTENDED_REGS, ++ ppc_fill_pprregset, ppc_store_pprregset }, ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_DSCR, 0, EXTENDED_REGS, ++ ppc_fill_dscrregset, ppc_store_dscrregset }, + { PTRACE_GETVSXREGS, PTRACE_SETVSXREGS, 0, 0, EXTENDED_REGS, + ppc_fill_vsxregset, ppc_store_vsxregset }, + { PTRACE_GETVRREGS, PTRACE_SETVRREGS, 0, 0, EXTENDED_REGS, +@@ -625,6 +695,7 @@ ppc_arch_setup (void) + /* The value of current_process ()->tdesc needs to be set for this + call. */ + ppc_get_auxv (AT_HWCAP, &ppc_hwcap); ++ ppc_get_auxv (AT_HWCAP2, &ppc_hwcap2); + + features.isa205 = ppc_linux_has_isa205 (ppc_hwcap); + +@@ -634,6 +705,11 @@ ppc_arch_setup (void) + if (ppc_hwcap & PPC_FEATURE_HAS_ALTIVEC) + features.altivec = true; + ++ if ((ppc_hwcap2 & PPC_FEATURE2_DSCR) ++ && ppc_check_regset (tid, NT_PPC_DSCR, PPC_LINUX_SIZEOF_DSCRREGSET) ++ && ppc_check_regset (tid, NT_PPC_PPR, PPC_LINUX_SIZEOF_PPRREGSET)) ++ features.ppr_dscr = true; ++ + if (ppc_hwcap & PPC_FEATURE_CELL) + features.cell = true; + +@@ -678,6 +754,21 @@ ppc_arch_setup (void) + else + regset->size = 0; + break; ++ case PTRACE_GETREGSET: ++ switch (regset->nt_type) ++ { ++ case NT_PPC_PPR: ++ regset->size = (features.ppr_dscr ? ++ PPC_LINUX_SIZEOF_PPRREGSET : 0); ++ break; ++ case NT_PPC_DSCR: ++ regset->size = (features.ppr_dscr ? ++ PPC_LINUX_SIZEOF_DSCRREGSET : 0); ++ break; ++ default: ++ break; ++ } ++ break; + default: + break; + } +@@ -3053,6 +3144,8 @@ ppc_get_ipa_tdesc_idx (void) + return PPC_TDESC_ISA205_ALTIVEC; + if (tdesc == tdesc_powerpc_isa205_vsx64l) + return PPC_TDESC_ISA205_VSX; ++ if (tdesc == tdesc_powerpc_isa205_ppr_dscr_vsx64l) ++ return PPC_TDESC_ISA205_PPR_DSCR_VSX; + #endif + + if (tdesc == tdesc_powerpc_32l) +@@ -3069,6 +3162,8 @@ ppc_get_ipa_tdesc_idx (void) + return PPC_TDESC_ISA205_ALTIVEC; + if (tdesc == tdesc_powerpc_isa205_vsx32l) + return PPC_TDESC_ISA205_VSX; ++ if (tdesc == tdesc_powerpc_isa205_ppr_dscr_vsx32l) ++ return PPC_TDESC_ISA205_PPR_DSCR_VSX; + if (tdesc == tdesc_powerpc_e500l) + return PPC_TDESC_E500; + +@@ -3127,6 +3222,7 @@ initialize_low_arch (void) + init_registers_powerpc_isa205_32l (); + init_registers_powerpc_isa205_altivec32l (); + init_registers_powerpc_isa205_vsx32l (); ++ init_registers_powerpc_isa205_ppr_dscr_vsx32l (); + init_registers_powerpc_e500l (); + #if __powerpc64__ + init_registers_powerpc_64l (); +@@ -3136,6 +3232,7 @@ initialize_low_arch (void) + init_registers_powerpc_isa205_64l (); + init_registers_powerpc_isa205_altivec64l (); + init_registers_powerpc_isa205_vsx64l (); ++ init_registers_powerpc_isa205_ppr_dscr_vsx64l (); + #endif + + initialize_regsets_info (&ppc_regsets_info); +diff --git a/gdb/gdbserver/linux-ppc-tdesc-init.h b/gdb/gdbserver/linux-ppc-tdesc-init.h +--- a/gdb/gdbserver/linux-ppc-tdesc-init.h ++++ b/gdb/gdbserver/linux-ppc-tdesc-init.h +@@ -29,6 +29,7 @@ enum ppc_linux_tdesc { + PPC_TDESC_ISA205, + PPC_TDESC_ISA205_ALTIVEC, + PPC_TDESC_ISA205_VSX, ++ PPC_TDESC_ISA205_PPR_DSCR_VSX, + PPC_TDESC_E500, + }; + +@@ -55,6 +56,9 @@ void init_registers_powerpc_isa205_altivec32l (void); + /* Defined in auto-generated file powerpc-isa205-vsx32l.c. */ + void init_registers_powerpc_isa205_vsx32l (void); + ++/* Defined in auto-generated file powerpc-isa205-ppr-dscr-vsx32l.c. */ ++void init_registers_powerpc_isa205_ppr_dscr_vsx32l (void); ++ + /* Defined in auto-generated file powerpc-e500l.c. */ + void init_registers_powerpc_e500l (void); + +@@ -83,4 +87,7 @@ void init_registers_powerpc_isa205_altivec64l (void); + /* Defined in auto-generated file powerpc-isa205-vsx64l.c. */ + void init_registers_powerpc_isa205_vsx64l (void); + ++/* Defined in auto-generated file powerpc-isa205-ppr-dscr-vsx64l.c. */ ++void init_registers_powerpc_isa205_ppr_dscr_vsx64l (void); ++ + #endif +diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h +--- a/gdb/nat/ppc-linux.h ++++ b/gdb/nat/ppc-linux.h +@@ -51,6 +51,9 @@ + #ifndef PPC_FEATURE_HAS_SPE + #define PPC_FEATURE_HAS_SPE 0x00800000 + #endif ++#ifndef PPC_FEATURE2_DSCR ++#define PPC_FEATURE2_DSCR 0x20000000 ++#endif + + /* Glibc's headers don't define PTRACE_GETVRREGS so we cannot use a + configure time check. Some older glibc's (for instance 2.2.1) +@@ -82,6 +85,16 @@ + #define PTRACE_SETEVRREGS 21 + #endif + ++/* Program Priority Register. */ ++#ifndef NT_PPC_PPR ++#define NT_PPC_PPR 0x104 ++#endif ++ ++/* Data Stream Control Register. */ ++#ifndef NT_PPC_DSCR ++#define NT_PPC_DSCR 0x105 ++#endif ++ + /* Return the wordsize of the target, either 4 or 8 bytes. */ + int ppc_linux_target_wordsize (int tid); + +diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c +--- a/gdb/ppc-linux-nat.c ++++ b/gdb/ppc-linux-nat.c +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #include "gdb_wait.h" + #include + #include +@@ -528,6 +529,78 @@ fetch_spe_register (struct regcache *regcache, int tid, int regno) + regcache->raw_supply (tdep->ppc_spefscr_regnum, &evrregs.spefscr); + } + ++/* Use ptrace to fetch all registers from the register set with note ++ type REGSET_ID, size REGSIZE, and layout described by REGSET, from ++ process/thread TID and supply their values to REGCACHE. If ptrace ++ returns ENODATA to indicate the regset is unavailable, mark the ++ registers as unavailable in REGCACHE. */ ++ ++static void ++fetch_regset (struct regcache *regcache, int tid, ++ int regset_id, int regsetsize, const struct regset *regset) ++{ ++ void *buf = alloca (regsetsize); ++ struct iovec iov; ++ ++ iov.iov_base = buf; ++ iov.iov_len = regsetsize; ++ ++ if (ptrace (PTRACE_GETREGSET, tid, regset_id, &iov) < 0) ++ { ++ if (errno == ENODATA) ++ regset->supply_regset (regset, regcache, -1, NULL, regsetsize); ++ else ++ perror_with_name (_("Couldn't get register set")); ++ } ++ else ++ regset->supply_regset (regset, regcache, -1, buf, regsetsize); ++} ++ ++/* Use ptrace to store register REGNUM of the regset with note type ++ REGSET_ID, size REGSETSIZE, and layout described by REGSET, from ++ REGCACHE back to process/thread TID. If REGNUM is -1 all registers ++ in the set are collected and stored. */ ++ ++static void ++store_regset (const struct regcache *regcache, int tid, int regnum, ++ int regset_id, int regsetsize, const struct regset *regset) ++{ ++ void *buf = alloca (regsetsize); ++ struct iovec iov; ++ ++ iov.iov_base = buf; ++ iov.iov_len = regsetsize; ++ ++ /* Make sure that the buffer that will be stored has up to date values ++ for the registers that won't be collected. */ ++ if (ptrace (PTRACE_GETREGSET, tid, regset_id, &iov) < 0) ++ perror_with_name (_("Couldn't get register set")); ++ ++ regset->collect_regset (regset, regcache, regnum, buf, regsetsize); ++ ++ if (ptrace (PTRACE_SETREGSET, tid, regset_id, &iov) < 0) ++ perror_with_name (_("Couldn't set register set")); ++} ++ ++/* Check whether the kernel provides a register set with number ++ REGSET_ID of size REGSETSIZE for process/thread TID. */ ++ ++static bool ++check_regset (int tid, int regset_id, int regsetsize) ++{ ++ void *buf = alloca (regsetsize); ++ struct iovec iov; ++ ++ iov.iov_base = buf; ++ iov.iov_len = regsetsize; ++ ++ if (ptrace (PTRACE_GETREGSET, tid, regset_id, &iov) >= 0 ++ || errno == ENODATA) ++ return true; ++ else ++ return false; ++} ++ + static void + fetch_register (struct regcache *regcache, int tid, int regno) + { +@@ -567,6 +640,24 @@ fetch_register (struct regcache *regcache, int tid, int regno) + fetch_spe_register (regcache, tid, regno); + return; + } ++ else if (regno == PPC_DSCR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_dscr_regnum != -1); ++ ++ fetch_regset (regcache, tid, NT_PPC_DSCR, ++ PPC_LINUX_SIZEOF_DSCRREGSET, ++ &ppc32_linux_dscrregset); ++ return; ++ } ++ else if (regno == PPC_PPR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_ppr_regnum != -1); ++ ++ fetch_regset (regcache, tid, NT_PPC_PPR, ++ PPC_LINUX_SIZEOF_PPRREGSET, ++ &ppc32_linux_pprregset); ++ return; ++ } + + if (regaddr == -1) + { +@@ -763,6 +854,14 @@ fetch_ppc_registers (struct regcache *regcache, int tid) + fetch_vsx_registers (regcache, tid, -1); + if (tdep->ppc_ev0_upper_regnum >= 0) + fetch_spe_register (regcache, tid, -1); ++ if (tdep->ppc_ppr_regnum != -1) ++ fetch_regset (regcache, tid, NT_PPC_PPR, ++ PPC_LINUX_SIZEOF_PPRREGSET, ++ &ppc32_linux_pprregset); ++ if (tdep->ppc_dscr_regnum != -1) ++ fetch_regset (regcache, tid, NT_PPC_DSCR, ++ PPC_LINUX_SIZEOF_DSCRREGSET, ++ &ppc32_linux_dscrregset); + } + + /* Fetch registers from the child process. Fetch all registers if +@@ -943,6 +1042,24 @@ store_register (const struct regcache *regcache, int tid, int regno) + store_spe_register (regcache, tid, regno); + return; + } ++ else if (regno == PPC_DSCR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_dscr_regnum != -1); ++ ++ store_regset (regcache, tid, regno, NT_PPC_DSCR, ++ PPC_LINUX_SIZEOF_DSCRREGSET, ++ &ppc32_linux_dscrregset); ++ return; ++ } ++ else if (regno == PPC_PPR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_ppr_regnum != -1); ++ ++ store_regset (regcache, tid, regno, NT_PPC_PPR, ++ PPC_LINUX_SIZEOF_PPRREGSET, ++ &ppc32_linux_pprregset); ++ return; ++ } + + if (regaddr == -1) + return; +@@ -1157,6 +1274,14 @@ store_ppc_registers (const struct regcache *regcache, int tid) + store_vsx_registers (regcache, tid, -1); + if (tdep->ppc_ev0_upper_regnum >= 0) + store_spe_register (regcache, tid, -1); ++ if (tdep->ppc_ppr_regnum != -1) ++ store_regset (regcache, tid, -1, NT_PPC_PPR, ++ PPC_LINUX_SIZEOF_PPRREGSET, ++ &ppc32_linux_pprregset); ++ if (tdep->ppc_dscr_regnum != -1) ++ store_regset (regcache, tid, -1, NT_PPC_DSCR, ++ PPC_LINUX_SIZEOF_DSCRREGSET, ++ &ppc32_linux_dscrregset); + } + + /* Fetch the AT_HWCAP entry from the aux vector. */ +@@ -1171,6 +1296,19 @@ ppc_linux_get_hwcap (void) + return field; + } + ++/* Fetch the AT_HWCAP2 entry from the aux vector. */ ++ ++static CORE_ADDR ++ppc_linux_get_hwcap2 (void) ++{ ++ CORE_ADDR field; ++ ++ if (target_auxv_search (current_top_target (), AT_HWCAP2, &field) != 1) ++ return 0; ++ ++ return field; ++} ++ + /* The cached DABR value, to install in new threads. + This variable is used when the PowerPC HWDEBUG ptrace + interface is not available. */ +@@ -2233,6 +2371,7 @@ ppc_linux_nat_target::read_description () + features.wordsize = ppc_linux_target_wordsize (tid); + + CORE_ADDR hwcap = ppc_linux_get_hwcap (); ++ CORE_ADDR hwcap2 = ppc_linux_get_hwcap2 (); + + if (have_ptrace_getsetvsxregs + && (hwcap & PPC_FEATURE_HAS_VSX)) +@@ -2267,6 +2406,11 @@ ppc_linux_nat_target::read_description () + + features.isa205 = ppc_linux_has_isa205 (hwcap); + ++ if ((hwcap2 & PPC_FEATURE2_DSCR) ++ && check_regset (tid, NT_PPC_PPR, PPC_LINUX_SIZEOF_PPRREGSET) ++ && check_regset (tid, NT_PPC_DSCR, PPC_LINUX_SIZEOF_DSCRREGSET)) ++ features.ppr_dscr = true; ++ + return ppc_linux_match_description (features); + } + +diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c +--- a/gdb/ppc-linux-tdep.c ++++ b/gdb/ppc-linux-tdep.c +@@ -71,6 +71,7 @@ + #include "features/rs6000/powerpc-isa205-32l.c" + #include "features/rs6000/powerpc-isa205-altivec32l.c" + #include "features/rs6000/powerpc-isa205-vsx32l.c" ++#include "features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c" + #include "features/rs6000/powerpc-64l.c" + #include "features/rs6000/powerpc-altivec64l.c" + #include "features/rs6000/powerpc-cell64l.c" +@@ -78,6 +79,7 @@ + #include "features/rs6000/powerpc-isa205-64l.c" + #include "features/rs6000/powerpc-isa205-altivec64l.c" + #include "features/rs6000/powerpc-isa205-vsx64l.c" ++#include "features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c" + #include "features/rs6000/powerpc-e500l.c" + + /* Shared library operations for PowerPC-Linux. */ +@@ -547,6 +549,38 @@ static const struct regset ppc32_linux_vsxregset = { + regcache_collect_regset + }; + ++/* Program Priorty Register regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_ppr[] = ++ { ++ { 1, PPC_PPR_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Program Priorty Register regset. */ ++ ++const struct regset ppc32_linux_pprregset = { ++ ppc32_regmap_ppr, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++/* Data Stream Control Register regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_dscr[] = ++ { ++ { 1, PPC_DSCR_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Data Stream Control Register regset. */ ++ ++const struct regset ppc32_linux_dscrregset = { ++ ppc32_regmap_dscr, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ + const struct regset * + ppc_linux_gregset (int wordsize) + { +@@ -585,6 +619,8 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + int have_altivec = tdep->ppc_vr0_regnum != -1; + int have_vsx = tdep->ppc_vsr0_upper_regnum != -1; ++ int have_ppr = tdep->ppc_ppr_regnum != -1; ++ int have_dscr = tdep->ppc_dscr_regnum != -1; + + if (tdep->wordsize == 4) + cb (".reg", 48 * 4, 48 * 4, &ppc32_linux_gregset, NULL, cb_data); +@@ -603,6 +639,17 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, + if (have_vsx) + cb (".reg-ppc-vsx", PPC_LINUX_SIZEOF_VSXREGSET, PPC_LINUX_SIZEOF_VSXREGSET, + &ppc32_linux_vsxregset, "POWER7 VSX", cb_data); ++ ++ if (have_ppr) ++ cb (".reg-ppc-ppr", PPC_LINUX_SIZEOF_PPRREGSET, ++ PPC_LINUX_SIZEOF_PPRREGSET, ++ &ppc32_linux_pprregset, "Priority Program Register", cb_data); ++ ++ if (have_dscr) ++ cb (".reg-ppc-dscr", PPC_LINUX_SIZEOF_DSCRREGSET, ++ PPC_LINUX_SIZEOF_DSCRREGSET, ++ &ppc32_linux_dscrregset, "Data Stream Control Register", ++ cb_data); + } + + static void +@@ -1015,6 +1062,8 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, + asection *altivec = bfd_get_section_by_name (abfd, ".reg-ppc-vmx"); + asection *vsx = bfd_get_section_by_name (abfd, ".reg-ppc-vsx"); + asection *section = bfd_get_section_by_name (abfd, ".reg"); ++ asection *ppr = bfd_get_section_by_name (abfd, ".reg-ppc-ppr"); ++ asection *dscr = bfd_get_section_by_name (abfd, ".reg-ppc-dscr"); + + if (! section) + return NULL; +@@ -1047,6 +1096,9 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, + + features.isa205 = ppc_linux_has_isa205 (hwcap); + ++ if (ppr && dscr) ++ features.ppr_dscr = true; ++ + return ppc_linux_match_description (features); + } + +@@ -1920,6 +1972,7 @@ _initialize_ppc_linux_tdep (void) + initialize_tdesc_powerpc_isa205_32l (); + initialize_tdesc_powerpc_isa205_altivec32l (); + initialize_tdesc_powerpc_isa205_vsx32l (); ++ initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l (); + initialize_tdesc_powerpc_64l (); + initialize_tdesc_powerpc_altivec64l (); + initialize_tdesc_powerpc_cell64l (); +@@ -1927,5 +1980,6 @@ _initialize_ppc_linux_tdep (void) + initialize_tdesc_powerpc_isa205_64l (); + initialize_tdesc_powerpc_isa205_altivec64l (); + initialize_tdesc_powerpc_isa205_vsx64l (); ++ initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l (); + initialize_tdesc_powerpc_e500l (); + } +diff --git a/gdb/ppc-linux-tdep.h b/gdb/ppc-linux-tdep.h +--- a/gdb/ppc-linux-tdep.h ++++ b/gdb/ppc-linux-tdep.h +@@ -44,4 +44,8 @@ enum { + /* Return 1 if PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM are usable. */ + int ppc_linux_trap_reg_p (struct gdbarch *gdbarch); + ++/* Additional register sets, defined in ppc-linux-tdep.c. */ ++extern const struct regset ppc32_linux_pprregset; ++extern const struct regset ppc32_linux_dscrregset; ++ + #endif /* PPC_LINUX_TDEP_H */ +diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h +--- a/gdb/ppc-tdep.h ++++ b/gdb/ppc-tdep.h +@@ -253,6 +253,12 @@ struct gdbarch_tdep + int ppc_acc_regnum; /* SPE 'acc' register. */ + int ppc_spefscr_regnum; /* SPE 'spefscr' register. */ + ++ /* Program Priority Register. */ ++ int ppc_ppr_regnum; ++ ++ /* Data Stream Control Register. */ ++ int ppc_dscr_regnum; ++ + /* Decimal 128 registers. */ + int ppc_dl0_regnum; /* First Decimal128 argument register pair. */ + +@@ -309,6 +315,8 @@ enum { + PPC_VRSAVE_REGNUM = 139, + PPC_VSR0_UPPER_REGNUM = 140, + PPC_VSR31_UPPER_REGNUM = 171, ++ PPC_PPR_REGNUM = 172, ++ PPC_DSCR_REGNUM = 173, + PPC_NUM_REGS + }; + +diff --git a/gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat b/gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat +new file mode 100644 +--- /dev/null ++++ b/gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat +@@ -0,0 +1,146 @@ ++# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: ++# Generated from: rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml ++name:powerpc_isa205_ppr_dscr_vsx32l ++xmltarget:powerpc-isa205-ppr-dscr-vsx32l.xml ++expedite:r1,pc ++32:r0 ++32:r1 ++32:r2 ++32:r3 ++32:r4 ++32:r5 ++32:r6 ++32:r7 ++32:r8 ++32:r9 ++32:r10 ++32:r11 ++32:r12 ++32:r13 ++32:r14 ++32:r15 ++32:r16 ++32:r17 ++32:r18 ++32:r19 ++32:r20 ++32:r21 ++32:r22 ++32:r23 ++32:r24 ++32:r25 ++32:r26 ++32:r27 ++32:r28 ++32:r29 ++32:r30 ++32:r31 ++64:f0 ++64:f1 ++64:f2 ++64:f3 ++64:f4 ++64:f5 ++64:f6 ++64:f7 ++64:f8 ++64:f9 ++64:f10 ++64:f11 ++64:f12 ++64:f13 ++64:f14 ++64:f15 ++64:f16 ++64:f17 ++64:f18 ++64:f19 ++64:f20 ++64:f21 ++64:f22 ++64:f23 ++64:f24 ++64:f25 ++64:f26 ++64:f27 ++64:f28 ++64:f29 ++64:f30 ++64:f31 ++32:pc ++32:msr ++32:cr ++32:lr ++32:ctr ++32:xer ++64:fpscr ++32:orig_r3 ++32:trap ++128:vr0 ++128:vr1 ++128:vr2 ++128:vr3 ++128:vr4 ++128:vr5 ++128:vr6 ++128:vr7 ++128:vr8 ++128:vr9 ++128:vr10 ++128:vr11 ++128:vr12 ++128:vr13 ++128:vr14 ++128:vr15 ++128:vr16 ++128:vr17 ++128:vr18 ++128:vr19 ++128:vr20 ++128:vr21 ++128:vr22 ++128:vr23 ++128:vr24 ++128:vr25 ++128:vr26 ++128:vr27 ++128:vr28 ++128:vr29 ++128:vr30 ++128:vr31 ++32:vscr ++32:vrsave ++64:vs0h ++64:vs1h ++64:vs2h ++64:vs3h ++64:vs4h ++64:vs5h ++64:vs6h ++64:vs7h ++64:vs8h ++64:vs9h ++64:vs10h ++64:vs11h ++64:vs12h ++64:vs13h ++64:vs14h ++64:vs15h ++64:vs16h ++64:vs17h ++64:vs18h ++64:vs19h ++64:vs20h ++64:vs21h ++64:vs22h ++64:vs23h ++64:vs24h ++64:vs25h ++64:vs26h ++64:vs27h ++64:vs28h ++64:vs29h ++64:vs30h ++64:vs31h ++64:ppr ++64:dscr +diff --git a/gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat b/gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat +new file mode 100644 +--- /dev/null ++++ b/gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat +@@ -0,0 +1,146 @@ ++# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: ++# Generated from: rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml ++name:powerpc_isa205_ppr_dscr_vsx64l ++xmltarget:powerpc-isa205-ppr-dscr-vsx64l.xml ++expedite:r1,pc ++64:r0 ++64:r1 ++64:r2 ++64:r3 ++64:r4 ++64:r5 ++64:r6 ++64:r7 ++64:r8 ++64:r9 ++64:r10 ++64:r11 ++64:r12 ++64:r13 ++64:r14 ++64:r15 ++64:r16 ++64:r17 ++64:r18 ++64:r19 ++64:r20 ++64:r21 ++64:r22 ++64:r23 ++64:r24 ++64:r25 ++64:r26 ++64:r27 ++64:r28 ++64:r29 ++64:r30 ++64:r31 ++64:f0 ++64:f1 ++64:f2 ++64:f3 ++64:f4 ++64:f5 ++64:f6 ++64:f7 ++64:f8 ++64:f9 ++64:f10 ++64:f11 ++64:f12 ++64:f13 ++64:f14 ++64:f15 ++64:f16 ++64:f17 ++64:f18 ++64:f19 ++64:f20 ++64:f21 ++64:f22 ++64:f23 ++64:f24 ++64:f25 ++64:f26 ++64:f27 ++64:f28 ++64:f29 ++64:f30 ++64:f31 ++64:pc ++64:msr ++32:cr ++64:lr ++64:ctr ++32:xer ++64:fpscr ++64:orig_r3 ++64:trap ++128:vr0 ++128:vr1 ++128:vr2 ++128:vr3 ++128:vr4 ++128:vr5 ++128:vr6 ++128:vr7 ++128:vr8 ++128:vr9 ++128:vr10 ++128:vr11 ++128:vr12 ++128:vr13 ++128:vr14 ++128:vr15 ++128:vr16 ++128:vr17 ++128:vr18 ++128:vr19 ++128:vr20 ++128:vr21 ++128:vr22 ++128:vr23 ++128:vr24 ++128:vr25 ++128:vr26 ++128:vr27 ++128:vr28 ++128:vr29 ++128:vr30 ++128:vr31 ++32:vscr ++32:vrsave ++64:vs0h ++64:vs1h ++64:vs2h ++64:vs3h ++64:vs4h ++64:vs5h ++64:vs6h ++64:vs7h ++64:vs8h ++64:vs9h ++64:vs10h ++64:vs11h ++64:vs12h ++64:vs13h ++64:vs14h ++64:vs15h ++64:vs16h ++64:vs17h ++64:vs18h ++64:vs19h ++64:vs20h ++64:vs21h ++64:vs22h ++64:vs23h ++64:vs24h ++64:vs25h ++64:vs26h ++64:vs27h ++64:vs28h ++64:vs29h ++64:vs30h ++64:vs31h ++64:ppr ++64:dscr +diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c +--- a/gdb/rs6000-tdep.c ++++ b/gdb/rs6000-tdep.c +@@ -4466,6 +4466,17 @@ ppc_process_record_op31 (struct gdbarch *gdbarch, struct regcache *regcache, + case 570: /* Count Trailing Zeros Doubleword */ + case 890: /* Extend-Sign Word and Shift Left Immediate (445) */ + case 890 | 1: /* Extend-Sign Word and Shift Left Immediate (445) */ ++ ++ if (ext == 444 && tdep->ppc_ppr_regnum >= 0 ++ && (PPC_RS (insn) == PPC_RA (insn)) ++ && (PPC_RA (insn) == PPC_RB (insn)) ++ && !PPC_RC (insn)) ++ { ++ /* or Rx,Rx,Rx alters PRI in PPR. */ ++ record_full_arch_list_add_reg (regcache, tdep->ppc_ppr_regnum); ++ return 0; ++ } ++ + if (PPC_RC (insn)) + record_full_arch_list_add_reg (regcache, tdep->ppc_cr_regnum); + record_full_arch_list_add_reg (regcache, +@@ -4675,6 +4686,10 @@ ppc_process_record_op31 (struct gdbarch *gdbarch, struct regcache *regcache, + case 1: /* XER */ + record_full_arch_list_add_reg (regcache, tdep->ppc_xer_regnum); + return 0; ++ case 3: /* DSCR */ ++ if (tdep->ppc_dscr_regnum >= 0) ++ record_full_arch_list_add_reg (regcache, tdep->ppc_dscr_regnum); ++ return 0; + case 8: /* LR */ + record_full_arch_list_add_reg (regcache, tdep->ppc_lr_regnum); + return 0; +@@ -4684,6 +4699,11 @@ ppc_process_record_op31 (struct gdbarch *gdbarch, struct regcache *regcache, + case 256: /* VRSAVE */ + record_full_arch_list_add_reg (regcache, tdep->ppc_vrsave_regnum); + return 0; ++ case 896: ++ case 898: /* PPR */ ++ if (tdep->ppc_ppr_regnum >= 0) ++ record_full_arch_list_add_reg (regcache, tdep->ppc_ppr_regnum); ++ return 0; + } + + goto UNKNOWN_OP; +@@ -5846,7 +5866,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + enum powerpc_vector_abi vector_abi = powerpc_vector_abi_global; + enum powerpc_elf_abi elf_abi = POWERPC_ELF_AUTO; + int have_fpu = 0, have_spe = 0, have_mq = 0, have_altivec = 0; +- int have_dfp = 0, have_vsx = 0; ++ int have_dfp = 0, have_vsx = 0, have_ppr = 0, have_dscr = 0; + int tdesc_wordsize = -1; + const struct target_desc *tdesc = info.target_desc; + struct tdesc_arch_data *tdesc_data = NULL; +@@ -6129,6 +6149,44 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + } + else + have_spe = 0; ++ ++ /* Program Priority Register. */ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.ppr"); ++ if (feature != NULL) ++ { ++ valid_p = 1; ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_PPR_REGNUM, "ppr"); ++ ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_ppr = 1; ++ } ++ else ++ have_ppr = 0; ++ ++ /* Data Stream Control Register. */ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.dscr"); ++ if (feature != NULL) ++ { ++ valid_p = 1; ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_DSCR_REGNUM, "dscr"); ++ ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_dscr = 1; ++ } ++ else ++ have_dscr = 0; + } + + /* If we have a 64-bit binary on a 32-bit target, complain. Also +@@ -6323,6 +6381,8 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + tdep->ppc_ev0_upper_regnum = have_spe ? PPC_SPE_UPPER_GP0_REGNUM : -1; + tdep->ppc_acc_regnum = have_spe ? PPC_SPE_ACC_REGNUM : -1; + tdep->ppc_spefscr_regnum = have_spe ? PPC_SPE_FSCR_REGNUM : -1; ++ tdep->ppc_ppr_regnum = have_ppr ? PPC_PPR_REGNUM : -1; ++ tdep->ppc_dscr_regnum = have_dscr ? PPC_DSCR_REGNUM : -1; + + set_gdbarch_pc_regnum (gdbarch, PPC_PC_REGNUM); + set_gdbarch_sp_regnum (gdbarch, PPC_R0_REGNUM + 1); +diff --git a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c +@@ -0,0 +1,34 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright (C) 2018 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++int main (void) ++{ ++ /* Set Load Stream Disable bit in DSCR. */ ++ unsigned long dscr = 0x20; ++ ++ /* This is the non-privileged SPR number to access DSCR, ++ available since isa 207. */ ++ asm volatile ("mtspr 3,%0" : : "r" (dscr)); ++ ++ /* Set PPR to low priority (010 in bits 11:13, or ++ 0x0008000000000000). */ ++ asm volatile ("or 1,1,1"); ++ asm volatile ("nop"); // marker ++ asm volatile ("nop"); ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp +@@ -0,0 +1,120 @@ ++# Copyright (C) 2018 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# This file is part of the gdb testsuite. ++ ++# Test access to special purpose registers PPR and DSCR. The test ++# inferior writes to these registers, we check that GDB reads the same ++# values, then write to the registers trough GDB, step once, and check ++# again if we read back the same values. ++ ++if {![istarget "powerpc*-*-linux*"]} then { ++ verbose "Skipping PowerPC test for PPR and DSCR registers." ++ return ++} ++ ++standard_testfile .c ++ ++if {[build_executable "compile" $binfile $srcfile {debug}] == -1} { ++ return ++} ++ ++proc check_register_access { regname } { ++ global gdb_prompt ++ ++ set test "$regname register access" ++ gdb_test_multiple "info reg $regname" "$test" { ++ -re "Invalid register.*\r\n$gdb_prompt $" { ++ unsupported "$test" ++ return 0 ++ } ++ -re "\r\n$regname.*\r\n$gdb_prompt $" { ++ pass "$test" ++ return 1 ++ } ++ } ++ return 0 ++} ++ ++# Do one pass to check if the instructions in our test programs are ++# available to this processor (e.g. mtspr 3, RS for accessing DSCR). ++proc ppr_dscr_available {} { ++ global gdb_prompt ++ global inferior_exited_re ++ ++ set test "PPR/DSCR available to inferior" ++ gdb_test_multiple "continue" "" { ++ -re "Illegal instruction.*\r\n$gdb_prompt $" { ++ unsupported "$test" ++ return 0 ++ } ++ -re "$inferior_exited_re normally.*$gdb_prompt $" { ++ pass "$test" ++ return 1 ++ } ++ } ++ return 0 ++} ++ ++with_test_prefix "check PPR/DSCR access" { ++ clean_restart $binfile ++ ++ if ![runto_main] { ++ return ++ } ++ ++ if {![check_register_access "ppr"]} { ++ return ++ } ++ ++ if {![check_register_access "dscr"]} { ++ return ++ } ++ ++ if {![ppr_dscr_available]} { ++ return ++ } ++} ++ ++# Now do the actual test ++clean_restart $binfile ++ ++if ![runto_main] { ++ return ++} ++ ++gdb_breakpoint [gdb_get_line_number "marker"] ++ ++gdb_continue_to_breakpoint "continue to marker" ++ ++# At the breakpoint the inferior should have set the ++# registers to these expected values. ++ ++with_test_prefix "before write" { ++ gdb_test "info reg dscr" "dscr.*0x0*20\[ \t\]+.*" ++ gdb_test "info reg ppr" "ppr.*0x0*8000000000000\[ \t\]+.*" ++} ++ ++# Set Store Stream Enable in DSCR and set PPR to the medium-low ++# priority. ++gdb_test_no_output "set \$dscr = 0x8" ++gdb_test_no_output "set \$ppr = 0xC000000000000" ++ ++gdb_test "stepi" "asm.*" ++ ++with_test_prefix "after write" { ++ gdb_test "info reg dscr" "dscr.*0x0*8+\[ \t\]+.*" ++ gdb_test "info reg ppr" "ppr.*0x0*\[cC\]000000000000\[ \t\]+.*" ++} diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-11of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-11of15.patch new file mode 100644 index 0000000..475dea3 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-11of15.patch @@ -0,0 +1,1654 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:17 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-11of15.patch + +;; [PowerPC] Add support for TAR +;; Edjunior Barbosa Machado and Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Add support for TAR + +This patch adds support for the Target Address Register for powerpc +linux native and core file targets, and in the powerpc linux server +stub. + +gdb/ChangeLog: +2018-10-26 Edjunior Barbosa Machado + Pedro Franco de Carvalho + + * arch/ppc-linux-tdesc.h (tdesc_powerpc_isa207_vsx32l) + (tdesc_powerpc_isa207_vsx64l): Declare. + * arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_TARREGSET): Define. + (struct ppc_linux_features) : New field. + (ppc_linux_no_features): Add initializer for isa207 field. + * arch/ppc-linux-common.c (ppc_linux_match_description): Return + new tdescs. + * nat/ppc-linux.h (PPC_FEATURE2_ARCH_2_07, PPC_FEATURE2_TAR) + (NT_PPC_TAR): Define if not already defined. + * features/Makefile (WHICH): Add rs6000/powerpc-isa207-vsx32l and + rs6000/powerpc-isa207-vsx64l. + (XMLTOC): Add rs6000/powerpc-isa207-vsx32l.xml and + rs6000/powerpc-isa207-vsx64l.xml. + * features/rs6000/power-tar.xml: New file. + * features/rs6000/powerpc-isa207-vsx32l.xml: New file. + * features/rs6000/powerpc-isa207-vsx64l.xml: New file. + * features/rs6000/powerpc-isa207-vsx32l.c: Generate. + * features/rs6000/powerpc-isa207-vsx64l.c: Generate. + * regformats/rs6000/powerpc-isa207-vsx32l.dat: Generate. + * regformats/rs6000/powerpc-isa207-vsx64l.dat: Generate. + * ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call + fetch_regset with the TAR regset. + (store_register, store_ppc_registers): Call store_regset with the + TAR regset. + (ppc_linux_nat_target::read_description): Set isa207 field in the + features struct if needed. + * ppc-linux-tdep.c: Include + features/rs6000/powerpc-isa207-vsx32l.c and + features/rs6000/powerpc-isa207-vsx64l.c. + (ppc32_regmap_tar, ppc32_linux_tarregset): New globals. + (ppc_linux_iterate_over_regset_sections): Call back with the tar + regset. + (ppc_linux_core_read_description): Check if the tar section is + present and set isa207 in the features struct. + (_initialize_ppc_linux_tdep): Call + initialize_tdesc_powerpc_isa207_vsx32l and + initialize_tdesc_powerpc_isa207_vsx64l. + * ppc-linux-tdep.h (ppc32_linux_tarregset): Declare. + * ppc-tdep.h (gdbarch_tdep) : New field. + (enum) : New enum value. + * rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate tar + feature. + (ppc_process_record_op31): Record changes to TAR. + +gdb/gdbserver/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * configure.srv (ipa_ppc_linux_regobj): Add + powerpc-isa207-vsx64l-ipa.o and powerpc-isa207-vsx32l-ipa.o. + (powerpc*-*-linux*): Add powerpc-isa207-vsx32l.o and + powerpc-isa207-vsx64l.o to srv_regobj, add rs6000/power-tar.xml, + rs6000/powerpc-isa207-vsx32l.xml, and + rs6000/powerpc-isa207-vsx64l.xml to srv_xmlfiles. + * linux-ppc-tdesc-init.h (enum ppc_linux_tdesc) + : New enum value. + (init_registers_powerpc_isa207_vsx32l): Declare. + (init_registers_powerpc_isa207_vsx64l): Declare. + * linux-ppc-low.c (ppc_fill_tarregset): New function. + (ppc_store_tarregset): New function. + (ppc_regsets): Add entry for the TAR regset. + (ppc_arch_setup): Set isa207 in features struct when needed. Set + size for the TAR regsets. + (ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA207_VSX. + (initialize_low_arch): Call init_registers_powerpc_isa207_vsx32l + and init_registers_powerpc_isa207_vsx64l. + * linux-ppc-ipa.c (get_ipa_tdesc): Handle PPC_TDESC_ISA207_VSX. + (initialize_low_tracepoint): Call + init_registers_powerpc_isa207_vsx32l and + init_registers_powerpc_isa207_vsx64l. + +gdb/testsuite/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * gdb.arch/powerpc-tar.c: New file. + * gdb.arch/powerpc-tar.exp: New file. + +gdb/doc/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * gdb.texinfo (PowerPC Features): Describe new feature + "org.gnu.gdb.power.tar". + +diff --git a/gdb/arch/ppc-linux-common.c b/gdb/arch/ppc-linux-common.c +--- a/gdb/arch/ppc-linux-common.c ++++ b/gdb/arch/ppc-linux-common.c +@@ -53,7 +53,8 @@ ppc_linux_match_description (struct ppc_linux_features features) + if (features.cell) + tdesc = tdesc_powerpc_cell64l; + else if (features.vsx) +- tdesc = (features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx64l ++ tdesc = (features.isa207? tdesc_powerpc_isa207_vsx64l ++ : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx64l + : features.isa205? tdesc_powerpc_isa205_vsx64l + : tdesc_powerpc_vsx64l); + else if (features.altivec) +@@ -70,7 +71,8 @@ ppc_linux_match_description (struct ppc_linux_features features) + if (features.cell) + tdesc = tdesc_powerpc_cell32l; + else if (features.vsx) +- tdesc = (features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx32l ++ tdesc = (features.isa207? tdesc_powerpc_isa207_vsx32l ++ : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx32l + : features.isa205? tdesc_powerpc_isa205_vsx32l + : tdesc_powerpc_vsx32l); + else if (features.altivec) +diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h +--- a/gdb/arch/ppc-linux-common.h ++++ b/gdb/arch/ppc-linux-common.h +@@ -32,6 +32,7 @@ struct target_desc; + #define PPC_LINUX_SIZEOF_VSXREGSET 256 + #define PPC_LINUX_SIZEOF_PPRREGSET 8 + #define PPC_LINUX_SIZEOF_DSCRREGSET 8 ++#define PPC_LINUX_SIZEOF_TARREGSET 8 + + /* Check if the hwcap auxv entry indicates that isa205 is supported. */ + bool ppc_linux_has_isa205 (CORE_ADDR hwcap); +@@ -44,6 +45,7 @@ struct ppc_linux_features + bool vsx; + bool isa205; + bool ppr_dscr; ++ bool isa207; + bool cell; + }; + +@@ -55,6 +57,7 @@ const struct ppc_linux_features ppc_linux_no_features = { + false, + false, + false, ++ false, + }; + + /* Return a target description that matches FEATURES. */ +diff --git a/gdb/arch/ppc-linux-tdesc.h b/gdb/arch/ppc-linux-tdesc.h +--- a/gdb/arch/ppc-linux-tdesc.h ++++ b/gdb/arch/ppc-linux-tdesc.h +@@ -30,6 +30,7 @@ extern struct target_desc *tdesc_powerpc_isa205_32l; + extern struct target_desc *tdesc_powerpc_isa205_altivec32l; + extern struct target_desc *tdesc_powerpc_isa205_vsx32l; + extern struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx32l; ++extern struct target_desc *tdesc_powerpc_isa207_vsx32l; + extern struct target_desc *tdesc_powerpc_e500l; + + extern struct target_desc *tdesc_powerpc_64l; +@@ -40,5 +41,6 @@ extern struct target_desc *tdesc_powerpc_isa205_64l; + extern struct target_desc *tdesc_powerpc_isa205_altivec64l; + extern struct target_desc *tdesc_powerpc_isa205_vsx64l; + extern struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l; ++extern struct target_desc *tdesc_powerpc_isa207_vsx64l; + + #endif /* ARCH_PPC_LINUX_TDESC_H */ +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -42561,6 +42561,9 @@ contain the 64-bit register @samp{ppr}. + The @samp{org.gnu.gdb.power.dscr} feature is optional. It should + contain the 64-bit register @samp{dscr}. + ++The @samp{org.gnu.gdb.power.tar} feature is optional. It should ++contain the 64-bit register @samp{tar}. ++ + @node S/390 and System z Features + @subsection S/390 and System z Features + @cindex target descriptions, S/390 features +diff --git a/gdb/features/Makefile b/gdb/features/Makefile +--- a/gdb/features/Makefile ++++ b/gdb/features/Makefile +@@ -75,6 +75,7 @@ WHICH = aarch64 \ + rs6000/powerpc-isa205-vsx32l rs6000/powerpc-isa205-vsx64l \ + rs6000/powerpc-isa205-ppr-dscr-vsx32l \ + rs6000/powerpc-isa205-ppr-dscr-vsx64l \ ++ rs6000/powerpc-isa207-vsx32l rs6000/powerpc-isa207-vsx64l \ + s390-linux32 s390-linux64 s390x-linux64 \ + s390-linux32v1 s390-linux64v1 s390x-linux64v1 \ + s390-linux32v2 s390-linux64v2 s390x-linux64v2 \ +@@ -171,6 +172,8 @@ XMLTOC = \ + rs6000/powerpc-isa205-vsx64l.xml \ + rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml \ + rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml \ ++ rs6000/powerpc-isa207-vsx32l.xml \ ++ rs6000/powerpc-isa207-vsx64l.xml \ + rs6000/powerpc-vsx32.xml \ + rs6000/powerpc-vsx32l.xml \ + rs6000/powerpc-vsx64.xml \ +diff --git a/gdb/features/rs6000/power-tar.xml b/gdb/features/rs6000/power-tar.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-tar.xml +@@ -0,0 +1,12 @@ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/powerpc-isa207-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-vsx32l.c +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa207-vsx32l.c +@@ -0,0 +1,203 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: powerpc-isa207-vsx32l.xml */ ++ ++#include "defs.h" ++#include "osabi.h" ++#include "target-descriptions.h" ++ ++struct target_desc *tdesc_powerpc_isa207_vsx32l; ++static void ++initialize_tdesc_powerpc_isa207_vsx32l (void) ++{ ++ struct target_desc *result = allocate_target_description (); ++ set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common")); ++ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.core"); ++ tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r16", 16, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r17", 17, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r18", 18, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r19", 19, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r20", 20, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r21", 21, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r22", 22, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r23", 23, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r24", 24, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r25", 25, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r26", 26, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r27", 27, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r28", 28, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r29", 29, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r30", 30, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r31", 31, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "pc", 64, 1, NULL, 32, "code_ptr"); ++ tdesc_create_reg (feature, "msr", 65, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr", 66, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "lr", 67, 1, NULL, 32, "code_ptr"); ++ tdesc_create_reg (feature, "ctr", 68, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "xer", 69, 1, NULL, 32, "uint32"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.fpu"); ++ tdesc_create_reg (feature, "f0", 32, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f1", 33, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f2", 34, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f3", 35, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f4", 36, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f5", 37, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f6", 38, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f7", 39, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f8", 40, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f9", 41, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f10", 42, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f11", 43, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f12", 44, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f13", 45, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f14", 46, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f15", 47, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f16", 48, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f17", 49, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f18", 50, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f19", 51, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f20", 52, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f21", 53, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f22", 54, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f23", 55, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f24", 56, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f25", 57, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f26", 58, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f27", 59, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f28", 60, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f29", 61, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f30", 62, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f31", 63, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "fpscr", 70, 1, "float", 64, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux"); ++ tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 32, "int"); ++ tdesc_create_reg (feature, "trap", 72, 1, NULL, 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.altivec"); ++ tdesc_type *element_type; ++ element_type = tdesc_named_type (feature, "ieee_single"); ++ tdesc_create_vector (feature, "v4f", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int32"); ++ tdesc_create_vector (feature, "v4i32", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int16"); ++ tdesc_create_vector (feature, "v8i16", element_type, 8); ++ ++ element_type = tdesc_named_type (feature, "int8"); ++ tdesc_create_vector (feature, "v16i8", element_type, 16); ++ ++ tdesc_type_with_fields *type_with_fields; ++ type_with_fields = tdesc_create_union (feature, "vec128"); ++ tdesc_type *field_type; ++ field_type = tdesc_named_type (feature, "uint128"); ++ tdesc_add_field (type_with_fields, "uint128", field_type); ++ field_type = tdesc_named_type (feature, "v4f"); ++ tdesc_add_field (type_with_fields, "v4_float", field_type); ++ field_type = tdesc_named_type (feature, "v4i32"); ++ tdesc_add_field (type_with_fields, "v4_int32", field_type); ++ field_type = tdesc_named_type (feature, "v8i16"); ++ tdesc_add_field (type_with_fields, "v8_int16", field_type); ++ field_type = tdesc_named_type (feature, "v16i8"); ++ tdesc_add_field (type_with_fields, "v16_int8", field_type); ++ ++ tdesc_create_reg (feature, "vr0", 73, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr1", 74, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr2", 75, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr3", 76, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr4", 77, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr5", 78, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr6", 79, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr7", 80, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr8", 81, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr9", 82, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr10", 83, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr11", 84, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr12", 85, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr13", 86, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr14", 87, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr15", 88, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr16", 89, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr17", 90, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr18", 91, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr19", 92, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr20", 93, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr21", 94, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr22", 95, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr23", 96, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr24", 97, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr25", 98, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr26", 99, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr27", 100, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr28", 101, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr29", 102, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr30", 103, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr31", 104, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int"); ++ tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.vsx"); ++ tdesc_create_reg (feature, "vs0h", 107, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs1h", 108, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs2h", 109, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs3h", 110, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs4h", 111, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs5h", 112, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs6h", 113, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs7h", 114, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs8h", 115, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs9h", 116, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs10h", 117, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs11h", 118, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs12h", 119, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs13h", 120, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs14h", 121, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs15h", 122, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs16h", 123, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs17h", 124, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs18h", 125, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs19h", 126, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs20h", 127, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs21h", 128, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs22h", 129, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs23h", 130, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs24h", 131, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs25h", 132, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs26h", 133, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs27h", 134, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs28h", 135, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs29h", 136, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ppr"); ++ tdesc_create_reg (feature, "ppr", 139, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.dscr"); ++ tdesc_create_reg (feature, "dscr", 140, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.tar"); ++ tdesc_create_reg (feature, "tar", 141, 1, NULL, 64, "uint64"); ++ ++ tdesc_powerpc_isa207_vsx32l = result; ++} +diff --git a/gdb/features/rs6000/powerpc-isa207-vsx32l.xml b/gdb/features/rs6000/powerpc-isa207-vsx32l.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa207-vsx32l.xml +@@ -0,0 +1,19 @@ ++ ++ ++ ++ ++ ++ powerpc:common ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/powerpc-isa207-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-vsx64l.c +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa207-vsx64l.c +@@ -0,0 +1,203 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: powerpc-isa207-vsx64l.xml */ ++ ++#include "defs.h" ++#include "osabi.h" ++#include "target-descriptions.h" ++ ++struct target_desc *tdesc_powerpc_isa207_vsx64l; ++static void ++initialize_tdesc_powerpc_isa207_vsx64l (void) ++{ ++ struct target_desc *result = allocate_target_description (); ++ set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64")); ++ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.core"); ++ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r3", 3, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r4", 4, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r5", 5, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r6", 6, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r7", 7, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r8", 8, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r9", 9, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r10", 10, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r11", 11, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r12", 12, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r13", 13, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r14", 14, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r15", 15, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r16", 16, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r17", 17, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r18", 18, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r19", 19, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r20", 20, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r21", 21, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r22", 22, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r23", 23, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r24", 24, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r25", 25, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r26", 26, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r27", 27, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r28", 28, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r29", 29, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r30", 30, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r31", 31, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "pc", 64, 1, NULL, 64, "code_ptr"); ++ tdesc_create_reg (feature, "msr", 65, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr", 66, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "lr", 67, 1, NULL, 64, "code_ptr"); ++ tdesc_create_reg (feature, "ctr", 68, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "xer", 69, 1, NULL, 32, "uint32"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.fpu"); ++ tdesc_create_reg (feature, "f0", 32, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f1", 33, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f2", 34, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f3", 35, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f4", 36, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f5", 37, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f6", 38, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f7", 39, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f8", 40, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f9", 41, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f10", 42, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f11", 43, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f12", 44, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f13", 45, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f14", 46, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f15", 47, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f16", 48, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f17", 49, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f18", 50, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f19", 51, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f20", 52, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f21", 53, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f22", 54, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f23", 55, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f24", 56, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f25", 57, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f26", 58, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f27", 59, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f28", 60, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f29", 61, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f30", 62, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f31", 63, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "fpscr", 70, 1, "float", 64, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux"); ++ tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "trap", 72, 1, NULL, 64, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.altivec"); ++ tdesc_type *element_type; ++ element_type = tdesc_named_type (feature, "ieee_single"); ++ tdesc_create_vector (feature, "v4f", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int32"); ++ tdesc_create_vector (feature, "v4i32", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int16"); ++ tdesc_create_vector (feature, "v8i16", element_type, 8); ++ ++ element_type = tdesc_named_type (feature, "int8"); ++ tdesc_create_vector (feature, "v16i8", element_type, 16); ++ ++ tdesc_type_with_fields *type_with_fields; ++ type_with_fields = tdesc_create_union (feature, "vec128"); ++ tdesc_type *field_type; ++ field_type = tdesc_named_type (feature, "uint128"); ++ tdesc_add_field (type_with_fields, "uint128", field_type); ++ field_type = tdesc_named_type (feature, "v4f"); ++ tdesc_add_field (type_with_fields, "v4_float", field_type); ++ field_type = tdesc_named_type (feature, "v4i32"); ++ tdesc_add_field (type_with_fields, "v4_int32", field_type); ++ field_type = tdesc_named_type (feature, "v8i16"); ++ tdesc_add_field (type_with_fields, "v8_int16", field_type); ++ field_type = tdesc_named_type (feature, "v16i8"); ++ tdesc_add_field (type_with_fields, "v16_int8", field_type); ++ ++ tdesc_create_reg (feature, "vr0", 73, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr1", 74, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr2", 75, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr3", 76, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr4", 77, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr5", 78, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr6", 79, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr7", 80, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr8", 81, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr9", 82, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr10", 83, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr11", 84, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr12", 85, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr13", 86, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr14", 87, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr15", 88, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr16", 89, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr17", 90, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr18", 91, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr19", 92, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr20", 93, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr21", 94, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr22", 95, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr23", 96, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr24", 97, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr25", 98, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr26", 99, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr27", 100, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr28", 101, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr29", 102, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr30", 103, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr31", 104, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int"); ++ tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.vsx"); ++ tdesc_create_reg (feature, "vs0h", 107, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs1h", 108, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs2h", 109, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs3h", 110, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs4h", 111, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs5h", 112, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs6h", 113, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs7h", 114, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs8h", 115, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs9h", 116, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs10h", 117, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs11h", 118, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs12h", 119, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs13h", 120, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs14h", 121, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs15h", 122, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs16h", 123, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs17h", 124, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs18h", 125, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs19h", 126, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs20h", 127, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs21h", 128, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs22h", 129, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs23h", 130, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs24h", 131, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs25h", 132, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs26h", 133, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs27h", 134, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs28h", 135, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs29h", 136, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ppr"); ++ tdesc_create_reg (feature, "ppr", 139, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.dscr"); ++ tdesc_create_reg (feature, "dscr", 140, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.tar"); ++ tdesc_create_reg (feature, "tar", 141, 1, NULL, 64, "uint64"); ++ ++ tdesc_powerpc_isa207_vsx64l = result; ++} +diff --git a/gdb/features/rs6000/powerpc-isa207-vsx64l.xml b/gdb/features/rs6000/powerpc-isa207-vsx64l.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa207-vsx64l.xml +@@ -0,0 +1,19 @@ ++ ++ ++ ++ ++ ++ powerpc:common64 ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv +--- a/gdb/gdbserver/configure.srv ++++ b/gdb/gdbserver/configure.srv +@@ -32,7 +32,7 @@ else + srv_amd64_linux_regobj="" + fi + +-ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-isa205-ppr-dscr-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o powerpc-isa205-ppr-dscr-vsx64l-ipa.o" ++ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-isa205-ppr-dscr-vsx32l-ipa.o powerpc-isa207-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o powerpc-isa205-ppr-dscr-vsx64l-ipa.o powerpc-isa207-vsx64l-ipa.o" + + # Linux object files. This is so we don't have to repeat + # these files over and over again. +@@ -218,6 +218,7 @@ case "${target}" in + srv_regobj="${srv_regobj} powerpc-isa205-altivec32l.o" + srv_regobj="${srv_regobj} powerpc-isa205-vsx32l.o" + srv_regobj="${srv_regobj} powerpc-isa205-ppr-dscr-vsx32l.o" ++ srv_regobj="${srv_regobj} powerpc-isa207-vsx32l.o" + srv_regobj="${srv_regobj} powerpc-e500l.o" + srv_regobj="${srv_regobj} powerpc-64l.o" + srv_regobj="${srv_regobj} powerpc-altivec64l.o" +@@ -227,6 +228,7 @@ case "${target}" in + srv_regobj="${srv_regobj} powerpc-isa205-altivec64l.o" + srv_regobj="${srv_regobj} powerpc-isa205-vsx64l.o" + srv_regobj="${srv_regobj} powerpc-isa205-ppr-dscr-vsx64l.o" ++ srv_regobj="${srv_regobj} powerpc-isa207-vsx64l.o" + srv_tgtobj="$srv_linux_obj linux-ppc-low.o ppc-linux.o" + srv_tgtobj="${srv_tgtobj} arch/ppc-linux-common.o" + srv_xmlfiles="rs6000/powerpc-32l.xml" +@@ -237,6 +239,7 @@ case "${target}" in + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-altivec32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa207-vsx32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-altivec.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-vsx.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-core.xml" +@@ -245,6 +248,7 @@ case "${target}" in + srv_xmlfiles="${srv_xmlfiles} rs6000/power-fpu-isa205.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-dscr.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-ppr.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-tar.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-e500l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-spe.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-64l.xml" +@@ -255,6 +259,7 @@ case "${target}" in + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-altivec64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa207-vsx64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power64-core.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power64-linux.xml" + srv_linux_usrregs=yes +diff --git a/gdb/gdbserver/linux-ppc-ipa.c b/gdb/gdbserver/linux-ppc-ipa.c +--- a/gdb/gdbserver/linux-ppc-ipa.c ++++ b/gdb/gdbserver/linux-ppc-ipa.c +@@ -193,6 +193,8 @@ get_ipa_tdesc (int idx) + return tdesc_powerpc_isa205_vsx64l; + case PPC_TDESC_ISA205_PPR_DSCR_VSX: + return tdesc_powerpc_isa205_ppr_dscr_vsx64l; ++ case PPC_TDESC_ISA207_VSX: ++ return tdesc_powerpc_isa207_vsx64l; + #else + case PPC_TDESC_BASE: + return tdesc_powerpc_32l; +@@ -210,6 +212,8 @@ get_ipa_tdesc (int idx) + return tdesc_powerpc_isa205_vsx32l; + case PPC_TDESC_ISA205_PPR_DSCR_VSX: + return tdesc_powerpc_isa205_ppr_dscr_vsx32l; ++ case PPC_TDESC_ISA207_VSX: ++ return tdesc_powerpc_isa207_vsx32l; + case PPC_TDESC_E500: + return tdesc_powerpc_e500l; + #endif +@@ -239,6 +243,7 @@ initialize_low_tracepoint (void) + init_registers_powerpc_isa205_altivec64l (); + init_registers_powerpc_isa205_vsx64l (); + init_registers_powerpc_isa205_ppr_dscr_vsx64l (); ++ init_registers_powerpc_isa207_vsx64l (); + #else + init_registers_powerpc_32l (); + init_registers_powerpc_altivec32l (); +@@ -248,6 +253,7 @@ initialize_low_tracepoint (void) + init_registers_powerpc_isa205_altivec32l (); + init_registers_powerpc_isa205_vsx32l (); + init_registers_powerpc_isa205_ppr_dscr_vsx32l (); ++ init_registers_powerpc_isa207_vsx32l (); + init_registers_powerpc_e500l (); + #endif + } +diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c +--- a/gdb/gdbserver/linux-ppc-low.c ++++ b/gdb/gdbserver/linux-ppc-low.c +@@ -525,6 +525,26 @@ ppc_store_dscrregset (struct regcache *regcache, const void *buf) + supply_register_by_name (regcache, "dscr", dscr); + } + ++/* Target Address Register regset fill function. */ ++ ++static void ++ppc_fill_tarregset (struct regcache *regcache, void *buf) ++{ ++ char *tar = (char *) buf; ++ ++ collect_register_by_name (regcache, "tar", tar); ++} ++ ++/* Target Address Register regset store function. */ ++ ++static void ++ppc_store_tarregset (struct regcache *regcache, const void *buf) ++{ ++ const char *tar = (const char *) buf; ++ ++ supply_register_by_name (regcache, "tar", tar); ++} ++ + static void + ppc_fill_vsxregset (struct regcache *regcache, void *buf) + { +@@ -634,6 +654,8 @@ static struct regset_info ppc_regsets[] = { + fetch them every time, but still fall back to PTRACE_PEEKUSER for the + general registers. Some kernels support these, but not the newer + PPC_PTRACE_GETREGS. */ ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TAR, 0, EXTENDED_REGS, ++ ppc_fill_tarregset, ppc_store_tarregset }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_PPR, 0, EXTENDED_REGS, + ppc_fill_pprregset, ppc_store_pprregset }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_DSCR, 0, EXTENDED_REGS, +@@ -708,7 +730,14 @@ ppc_arch_setup (void) + if ((ppc_hwcap2 & PPC_FEATURE2_DSCR) + && ppc_check_regset (tid, NT_PPC_DSCR, PPC_LINUX_SIZEOF_DSCRREGSET) + && ppc_check_regset (tid, NT_PPC_PPR, PPC_LINUX_SIZEOF_PPRREGSET)) +- features.ppr_dscr = true; ++ { ++ features.ppr_dscr = true; ++ if ((ppc_hwcap2 & PPC_FEATURE2_ARCH_2_07) ++ && (ppc_hwcap2 & PPC_FEATURE2_TAR) ++ && ppc_check_regset (tid, NT_PPC_TAR, ++ PPC_LINUX_SIZEOF_TARREGSET)) ++ features.isa207 = true; ++ } + + if (ppc_hwcap & PPC_FEATURE_CELL) + features.cell = true; +@@ -765,6 +794,10 @@ ppc_arch_setup (void) + regset->size = (features.ppr_dscr ? + PPC_LINUX_SIZEOF_DSCRREGSET : 0); + break; ++ case NT_PPC_TAR: ++ regset->size = (features.isa207 ? ++ PPC_LINUX_SIZEOF_TARREGSET : 0); ++ break; + default: + break; + } +@@ -3146,6 +3179,8 @@ ppc_get_ipa_tdesc_idx (void) + return PPC_TDESC_ISA205_VSX; + if (tdesc == tdesc_powerpc_isa205_ppr_dscr_vsx64l) + return PPC_TDESC_ISA205_PPR_DSCR_VSX; ++ if (tdesc == tdesc_powerpc_isa207_vsx64l) ++ return PPC_TDESC_ISA207_VSX; + #endif + + if (tdesc == tdesc_powerpc_32l) +@@ -3164,6 +3199,8 @@ ppc_get_ipa_tdesc_idx (void) + return PPC_TDESC_ISA205_VSX; + if (tdesc == tdesc_powerpc_isa205_ppr_dscr_vsx32l) + return PPC_TDESC_ISA205_PPR_DSCR_VSX; ++ if (tdesc == tdesc_powerpc_isa207_vsx32l) ++ return PPC_TDESC_ISA207_VSX; + if (tdesc == tdesc_powerpc_e500l) + return PPC_TDESC_E500; + +@@ -3223,6 +3260,7 @@ initialize_low_arch (void) + init_registers_powerpc_isa205_altivec32l (); + init_registers_powerpc_isa205_vsx32l (); + init_registers_powerpc_isa205_ppr_dscr_vsx32l (); ++ init_registers_powerpc_isa207_vsx32l (); + init_registers_powerpc_e500l (); + #if __powerpc64__ + init_registers_powerpc_64l (); +@@ -3233,6 +3271,7 @@ initialize_low_arch (void) + init_registers_powerpc_isa205_altivec64l (); + init_registers_powerpc_isa205_vsx64l (); + init_registers_powerpc_isa205_ppr_dscr_vsx64l (); ++ init_registers_powerpc_isa207_vsx64l (); + #endif + + initialize_regsets_info (&ppc_regsets_info); +diff --git a/gdb/gdbserver/linux-ppc-tdesc-init.h b/gdb/gdbserver/linux-ppc-tdesc-init.h +--- a/gdb/gdbserver/linux-ppc-tdesc-init.h ++++ b/gdb/gdbserver/linux-ppc-tdesc-init.h +@@ -30,6 +30,7 @@ enum ppc_linux_tdesc { + PPC_TDESC_ISA205_ALTIVEC, + PPC_TDESC_ISA205_VSX, + PPC_TDESC_ISA205_PPR_DSCR_VSX, ++ PPC_TDESC_ISA207_VSX, + PPC_TDESC_E500, + }; + +@@ -59,6 +60,9 @@ void init_registers_powerpc_isa205_vsx32l (void); + /* Defined in auto-generated file powerpc-isa205-ppr-dscr-vsx32l.c. */ + void init_registers_powerpc_isa205_ppr_dscr_vsx32l (void); + ++/* Defined in auto-generated file powerpc-isa207-vsx32l.c. */ ++void init_registers_powerpc_isa207_vsx32l (void); ++ + /* Defined in auto-generated file powerpc-e500l.c. */ + void init_registers_powerpc_e500l (void); + +@@ -90,4 +94,7 @@ void init_registers_powerpc_isa205_vsx64l (void); + /* Defined in auto-generated file powerpc-isa205-ppr-dscr-vsx64l.c. */ + void init_registers_powerpc_isa205_ppr_dscr_vsx64l (void); + ++/* Defined in auto-generated file powerpc-isa207-vsx64l.c. */ ++void init_registers_powerpc_isa207_vsx64l (void); ++ + #endif +diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h +--- a/gdb/nat/ppc-linux.h ++++ b/gdb/nat/ppc-linux.h +@@ -54,6 +54,12 @@ + #ifndef PPC_FEATURE2_DSCR + #define PPC_FEATURE2_DSCR 0x20000000 + #endif ++#ifndef PPC_FEATURE2_ARCH_2_07 ++#define PPC_FEATURE2_ARCH_2_07 0x80000000 ++#endif ++#ifndef PPC_FEATURE2_TAR ++#define PPC_FEATURE2_TAR 0x04000000 ++#endif + + /* Glibc's headers don't define PTRACE_GETVRREGS so we cannot use a + configure time check. Some older glibc's (for instance 2.2.1) +@@ -85,6 +91,11 @@ + #define PTRACE_SETEVRREGS 21 + #endif + ++/* Target Address Register. */ ++#ifndef NT_PPC_TAR ++#define NT_PPC_TAR 0x103 ++#endif ++ + /* Program Priority Register. */ + #ifndef NT_PPC_PPR + #define NT_PPC_PPR 0x104 +diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c +--- a/gdb/ppc-linux-nat.c ++++ b/gdb/ppc-linux-nat.c +@@ -658,6 +658,15 @@ fetch_register (struct regcache *regcache, int tid, int regno) + &ppc32_linux_pprregset); + return; + } ++ else if (regno == PPC_TAR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_tar_regnum != -1); ++ ++ fetch_regset (regcache, tid, NT_PPC_TAR, ++ PPC_LINUX_SIZEOF_TARREGSET, ++ &ppc32_linux_tarregset); ++ return; ++ } + + if (regaddr == -1) + { +@@ -862,6 +871,10 @@ fetch_ppc_registers (struct regcache *regcache, int tid) + fetch_regset (regcache, tid, NT_PPC_DSCR, + PPC_LINUX_SIZEOF_DSCRREGSET, + &ppc32_linux_dscrregset); ++ if (tdep->ppc_tar_regnum != -1) ++ fetch_regset (regcache, tid, NT_PPC_TAR, ++ PPC_LINUX_SIZEOF_TARREGSET, ++ &ppc32_linux_tarregset); + } + + /* Fetch registers from the child process. Fetch all registers if +@@ -1060,6 +1073,15 @@ store_register (const struct regcache *regcache, int tid, int regno) + &ppc32_linux_pprregset); + return; + } ++ else if (regno == PPC_TAR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_tar_regnum != -1); ++ ++ store_regset (regcache, tid, regno, NT_PPC_TAR, ++ PPC_LINUX_SIZEOF_TARREGSET, ++ &ppc32_linux_tarregset); ++ return; ++ } + + if (regaddr == -1) + return; +@@ -1282,6 +1304,10 @@ store_ppc_registers (const struct regcache *regcache, int tid) + store_regset (regcache, tid, -1, NT_PPC_DSCR, + PPC_LINUX_SIZEOF_DSCRREGSET, + &ppc32_linux_dscrregset); ++ if (tdep->ppc_tar_regnum != -1) ++ store_regset (regcache, tid, -1, NT_PPC_TAR, ++ PPC_LINUX_SIZEOF_TARREGSET, ++ &ppc32_linux_tarregset); + } + + /* Fetch the AT_HWCAP entry from the aux vector. */ +@@ -2409,7 +2435,13 @@ ppc_linux_nat_target::read_description () + if ((hwcap2 & PPC_FEATURE2_DSCR) + && check_regset (tid, NT_PPC_PPR, PPC_LINUX_SIZEOF_PPRREGSET) + && check_regset (tid, NT_PPC_DSCR, PPC_LINUX_SIZEOF_DSCRREGSET)) +- features.ppr_dscr = true; ++ { ++ features.ppr_dscr = true; ++ if ((hwcap2 & PPC_FEATURE2_ARCH_2_07) ++ && (hwcap2 & PPC_FEATURE2_TAR) ++ && check_regset (tid, NT_PPC_TAR, PPC_LINUX_SIZEOF_TARREGSET)) ++ features.isa207 = true; ++ } + + return ppc_linux_match_description (features); + } +diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c +--- a/gdb/ppc-linux-tdep.c ++++ b/gdb/ppc-linux-tdep.c +@@ -72,6 +72,7 @@ + #include "features/rs6000/powerpc-isa205-altivec32l.c" + #include "features/rs6000/powerpc-isa205-vsx32l.c" + #include "features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c" ++#include "features/rs6000/powerpc-isa207-vsx32l.c" + #include "features/rs6000/powerpc-64l.c" + #include "features/rs6000/powerpc-altivec64l.c" + #include "features/rs6000/powerpc-cell64l.c" +@@ -80,6 +81,7 @@ + #include "features/rs6000/powerpc-isa205-altivec64l.c" + #include "features/rs6000/powerpc-isa205-vsx64l.c" + #include "features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c" ++#include "features/rs6000/powerpc-isa207-vsx64l.c" + #include "features/rs6000/powerpc-e500l.c" + + /* Shared library operations for PowerPC-Linux. */ +@@ -581,6 +583,22 @@ const struct regset ppc32_linux_dscrregset = { + regcache_collect_regset + }; + ++/* Target Address Register regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_tar[] = ++ { ++ { 1, PPC_TAR_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Target Address Register regset. */ ++ ++const struct regset ppc32_linux_tarregset = { ++ ppc32_regmap_tar, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ + const struct regset * + ppc_linux_gregset (int wordsize) + { +@@ -621,6 +639,7 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, + int have_vsx = tdep->ppc_vsr0_upper_regnum != -1; + int have_ppr = tdep->ppc_ppr_regnum != -1; + int have_dscr = tdep->ppc_dscr_regnum != -1; ++ int have_tar = tdep->ppc_tar_regnum != -1; + + if (tdep->wordsize == 4) + cb (".reg", 48 * 4, 48 * 4, &ppc32_linux_gregset, NULL, cb_data); +@@ -650,6 +669,11 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, + PPC_LINUX_SIZEOF_DSCRREGSET, + &ppc32_linux_dscrregset, "Data Stream Control Register", + cb_data); ++ ++ if (have_tar) ++ cb (".reg-ppc-tar", PPC_LINUX_SIZEOF_TARREGSET, ++ PPC_LINUX_SIZEOF_TARREGSET, ++ &ppc32_linux_tarregset, "Target Address Register", cb_data); + } + + static void +@@ -1064,6 +1088,7 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, + asection *section = bfd_get_section_by_name (abfd, ".reg"); + asection *ppr = bfd_get_section_by_name (abfd, ".reg-ppc-ppr"); + asection *dscr = bfd_get_section_by_name (abfd, ".reg-ppc-dscr"); ++ asection *tar = bfd_get_section_by_name (abfd, ".reg-ppc-tar"); + + if (! section) + return NULL; +@@ -1097,7 +1122,11 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, + features.isa205 = ppc_linux_has_isa205 (hwcap); + + if (ppr && dscr) +- features.ppr_dscr = true; ++ { ++ features.ppr_dscr = true; ++ if (tar) ++ features.isa207 = true; ++ } + + return ppc_linux_match_description (features); + } +@@ -1973,6 +2002,7 @@ _initialize_ppc_linux_tdep (void) + initialize_tdesc_powerpc_isa205_altivec32l (); + initialize_tdesc_powerpc_isa205_vsx32l (); + initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l (); ++ initialize_tdesc_powerpc_isa207_vsx32l (); + initialize_tdesc_powerpc_64l (); + initialize_tdesc_powerpc_altivec64l (); + initialize_tdesc_powerpc_cell64l (); +@@ -1981,5 +2011,6 @@ _initialize_ppc_linux_tdep (void) + initialize_tdesc_powerpc_isa205_altivec64l (); + initialize_tdesc_powerpc_isa205_vsx64l (); + initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l (); ++ initialize_tdesc_powerpc_isa207_vsx64l (); + initialize_tdesc_powerpc_e500l (); + } +diff --git a/gdb/ppc-linux-tdep.h b/gdb/ppc-linux-tdep.h +--- a/gdb/ppc-linux-tdep.h ++++ b/gdb/ppc-linux-tdep.h +@@ -47,5 +47,6 @@ int ppc_linux_trap_reg_p (struct gdbarch *gdbarch); + /* Additional register sets, defined in ppc-linux-tdep.c. */ + extern const struct regset ppc32_linux_pprregset; + extern const struct regset ppc32_linux_dscrregset; ++extern const struct regset ppc32_linux_tarregset; + + #endif /* PPC_LINUX_TDEP_H */ +diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h +--- a/gdb/ppc-tdep.h ++++ b/gdb/ppc-tdep.h +@@ -259,6 +259,9 @@ struct gdbarch_tdep + /* Data Stream Control Register. */ + int ppc_dscr_regnum; + ++ /* Target Address Register. */ ++ int ppc_tar_regnum; ++ + /* Decimal 128 registers. */ + int ppc_dl0_regnum; /* First Decimal128 argument register pair. */ + +@@ -317,6 +320,7 @@ enum { + PPC_VSR31_UPPER_REGNUM = 171, + PPC_PPR_REGNUM = 172, + PPC_DSCR_REGNUM = 173, ++ PPC_TAR_REGNUM = 174, + PPC_NUM_REGS + }; + +diff --git a/gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat b/gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat +new file mode 100644 +--- /dev/null ++++ b/gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat +@@ -0,0 +1,147 @@ ++# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: ++# Generated from: rs6000/powerpc-isa207-vsx32l.xml ++name:powerpc_isa207_vsx32l ++xmltarget:powerpc-isa207-vsx32l.xml ++expedite:r1,pc ++32:r0 ++32:r1 ++32:r2 ++32:r3 ++32:r4 ++32:r5 ++32:r6 ++32:r7 ++32:r8 ++32:r9 ++32:r10 ++32:r11 ++32:r12 ++32:r13 ++32:r14 ++32:r15 ++32:r16 ++32:r17 ++32:r18 ++32:r19 ++32:r20 ++32:r21 ++32:r22 ++32:r23 ++32:r24 ++32:r25 ++32:r26 ++32:r27 ++32:r28 ++32:r29 ++32:r30 ++32:r31 ++64:f0 ++64:f1 ++64:f2 ++64:f3 ++64:f4 ++64:f5 ++64:f6 ++64:f7 ++64:f8 ++64:f9 ++64:f10 ++64:f11 ++64:f12 ++64:f13 ++64:f14 ++64:f15 ++64:f16 ++64:f17 ++64:f18 ++64:f19 ++64:f20 ++64:f21 ++64:f22 ++64:f23 ++64:f24 ++64:f25 ++64:f26 ++64:f27 ++64:f28 ++64:f29 ++64:f30 ++64:f31 ++32:pc ++32:msr ++32:cr ++32:lr ++32:ctr ++32:xer ++64:fpscr ++32:orig_r3 ++32:trap ++128:vr0 ++128:vr1 ++128:vr2 ++128:vr3 ++128:vr4 ++128:vr5 ++128:vr6 ++128:vr7 ++128:vr8 ++128:vr9 ++128:vr10 ++128:vr11 ++128:vr12 ++128:vr13 ++128:vr14 ++128:vr15 ++128:vr16 ++128:vr17 ++128:vr18 ++128:vr19 ++128:vr20 ++128:vr21 ++128:vr22 ++128:vr23 ++128:vr24 ++128:vr25 ++128:vr26 ++128:vr27 ++128:vr28 ++128:vr29 ++128:vr30 ++128:vr31 ++32:vscr ++32:vrsave ++64:vs0h ++64:vs1h ++64:vs2h ++64:vs3h ++64:vs4h ++64:vs5h ++64:vs6h ++64:vs7h ++64:vs8h ++64:vs9h ++64:vs10h ++64:vs11h ++64:vs12h ++64:vs13h ++64:vs14h ++64:vs15h ++64:vs16h ++64:vs17h ++64:vs18h ++64:vs19h ++64:vs20h ++64:vs21h ++64:vs22h ++64:vs23h ++64:vs24h ++64:vs25h ++64:vs26h ++64:vs27h ++64:vs28h ++64:vs29h ++64:vs30h ++64:vs31h ++64:ppr ++64:dscr ++64:tar +diff --git a/gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat b/gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat +new file mode 100644 +--- /dev/null ++++ b/gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat +@@ -0,0 +1,147 @@ ++# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: ++# Generated from: rs6000/powerpc-isa207-vsx64l.xml ++name:powerpc_isa207_vsx64l ++xmltarget:powerpc-isa207-vsx64l.xml ++expedite:r1,pc ++64:r0 ++64:r1 ++64:r2 ++64:r3 ++64:r4 ++64:r5 ++64:r6 ++64:r7 ++64:r8 ++64:r9 ++64:r10 ++64:r11 ++64:r12 ++64:r13 ++64:r14 ++64:r15 ++64:r16 ++64:r17 ++64:r18 ++64:r19 ++64:r20 ++64:r21 ++64:r22 ++64:r23 ++64:r24 ++64:r25 ++64:r26 ++64:r27 ++64:r28 ++64:r29 ++64:r30 ++64:r31 ++64:f0 ++64:f1 ++64:f2 ++64:f3 ++64:f4 ++64:f5 ++64:f6 ++64:f7 ++64:f8 ++64:f9 ++64:f10 ++64:f11 ++64:f12 ++64:f13 ++64:f14 ++64:f15 ++64:f16 ++64:f17 ++64:f18 ++64:f19 ++64:f20 ++64:f21 ++64:f22 ++64:f23 ++64:f24 ++64:f25 ++64:f26 ++64:f27 ++64:f28 ++64:f29 ++64:f30 ++64:f31 ++64:pc ++64:msr ++32:cr ++64:lr ++64:ctr ++32:xer ++64:fpscr ++64:orig_r3 ++64:trap ++128:vr0 ++128:vr1 ++128:vr2 ++128:vr3 ++128:vr4 ++128:vr5 ++128:vr6 ++128:vr7 ++128:vr8 ++128:vr9 ++128:vr10 ++128:vr11 ++128:vr12 ++128:vr13 ++128:vr14 ++128:vr15 ++128:vr16 ++128:vr17 ++128:vr18 ++128:vr19 ++128:vr20 ++128:vr21 ++128:vr22 ++128:vr23 ++128:vr24 ++128:vr25 ++128:vr26 ++128:vr27 ++128:vr28 ++128:vr29 ++128:vr30 ++128:vr31 ++32:vscr ++32:vrsave ++64:vs0h ++64:vs1h ++64:vs2h ++64:vs3h ++64:vs4h ++64:vs5h ++64:vs6h ++64:vs7h ++64:vs8h ++64:vs9h ++64:vs10h ++64:vs11h ++64:vs12h ++64:vs13h ++64:vs14h ++64:vs15h ++64:vs16h ++64:vs17h ++64:vs18h ++64:vs19h ++64:vs20h ++64:vs21h ++64:vs22h ++64:vs23h ++64:vs24h ++64:vs25h ++64:vs26h ++64:vs27h ++64:vs28h ++64:vs29h ++64:vs30h ++64:vs31h ++64:ppr ++64:dscr ++64:tar +diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c +--- a/gdb/rs6000-tdep.c ++++ b/gdb/rs6000-tdep.c +@@ -4699,6 +4699,10 @@ ppc_process_record_op31 (struct gdbarch *gdbarch, struct regcache *regcache, + case 256: /* VRSAVE */ + record_full_arch_list_add_reg (regcache, tdep->ppc_vrsave_regnum); + return 0; ++ case 815: /* TAR */ ++ if (tdep->ppc_tar_regnum >= 0) ++ record_full_arch_list_add_reg (regcache, tdep->ppc_tar_regnum); ++ return 0; + case 896: + case 898: /* PPR */ + if (tdep->ppc_ppr_regnum >= 0) +@@ -5867,6 +5871,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + enum powerpc_elf_abi elf_abi = POWERPC_ELF_AUTO; + int have_fpu = 0, have_spe = 0, have_mq = 0, have_altivec = 0; + int have_dfp = 0, have_vsx = 0, have_ppr = 0, have_dscr = 0; ++ int have_tar = 0; + int tdesc_wordsize = -1; + const struct target_desc *tdesc = info.target_desc; + struct tdesc_arch_data *tdesc_data = NULL; +@@ -6187,6 +6192,25 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + } + else + have_dscr = 0; ++ ++ /* Target Address Register. */ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.tar"); ++ if (feature != NULL) ++ { ++ valid_p = 1; ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_TAR_REGNUM, "tar"); ++ ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_tar = 1; ++ } ++ else ++ have_tar = 0; + } + + /* If we have a 64-bit binary on a 32-bit target, complain. Also +@@ -6383,6 +6407,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + tdep->ppc_spefscr_regnum = have_spe ? PPC_SPE_FSCR_REGNUM : -1; + tdep->ppc_ppr_regnum = have_ppr ? PPC_PPR_REGNUM : -1; + tdep->ppc_dscr_regnum = have_dscr ? PPC_DSCR_REGNUM : -1; ++ tdep->ppc_tar_regnum = have_tar ? PPC_TAR_REGNUM : -1; + + set_gdbarch_pc_regnum (gdbarch, PPC_PC_REGNUM); + set_gdbarch_sp_regnum (gdbarch, PPC_R0_REGNUM + 1); +diff --git a/gdb/testsuite/gdb.arch/powerpc-tar.c b/gdb/testsuite/gdb.arch/powerpc-tar.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-tar.c +@@ -0,0 +1,33 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright (C) 2018 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++int main (void) ++{ ++ void * target1 = &&target1_l; ++ void * target2 = &&target2_l; ++ asm volatile ("mtspr 815,%0" : : "r" (target1) : ); ++ ++ /* Branch always to TAR. */ ++ asm volatile ("bctar 20,0,0"); // marker ++ ++ target2_l: ++ asm volatile ("nop"); // marker 2 ++ target1_l: ++ asm volatile ("nop"); ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.arch/powerpc-tar.exp b/gdb/testsuite/gdb.arch/powerpc-tar.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-tar.exp +@@ -0,0 +1,122 @@ ++# Copyright (C) 2018 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# This file is part of the gdb testsuite. ++ ++# Test access to special purpose register TAR (the Target Address ++# Register). The test inferior writes to this register, we check that ++# GDB reads the same value, then write to the register the address of ++# another label. We then let the inferior continue and execute a ++# branch to TAR and check that we stop at the address that we wrote to ++# register. ++ ++if {![istarget "powerpc*-*-linux*"]} then { ++ verbose "Skipping PowerPC test for the TAR register." ++ return ++} ++ ++standard_testfile .c ++ ++if {[build_executable "compile" $binfile $srcfile {debug}] == -1} { ++ return -1 ++} ++ ++proc check_register_access { regname } { ++ global gdb_prompt ++ ++ set test "$regname register access" ++ gdb_test_multiple "info reg $regname" "$test" { ++ -re "Invalid register.*\r\n$gdb_prompt $" { ++ unsupported "$test" ++ return 0 ++ } ++ -re "\r\n$regname.*\r\n$gdb_prompt $" { ++ pass "$test" ++ return 1 ++ } ++ } ++ return 0 ++} ++ ++proc tar_available {} { ++ global gdb_prompt ++ global inferior_exited_re ++ ++ set test "TAR available to inferior" ++ gdb_test_multiple "continue" "" { ++ -re "Illegal instruction.*\r\n$gdb_prompt $" { ++ unsupported "$test" ++ return 0 ++ } ++ -re "$inferior_exited_re normally.*$gdb_prompt $" { ++ pass "$test" ++ return 1 ++ } ++ } ++ return 0 ++} ++ ++# Do one pass to check if TAR is usable, system ++# software can prevent it from being used. ++with_test_prefix "check TAR access" { ++ clean_restart $binfile ++ ++ if ![runto_main] { ++ return ++ } ++ ++ if {![check_register_access "tar"]} { ++ return ++ } ++ ++ if {![tar_available]} { ++ return ++ } ++} ++ ++# Now do the actual test ++clean_restart $binfile ++ ++if ![runto_main] { ++ return ++} ++ ++gdb_breakpoint [gdb_get_line_number "marker"] ++ ++gdb_continue_to_breakpoint "continue to marker" ++ ++set target1 [get_hexadecimal_valueof "target1" -1] ++set tar [get_hexadecimal_valueof "\$tar" -2] ++ ++set test "TAR value from mtspr" ++ ++if {${target1} == ${tar}} { ++ pass $test ++} else { ++ fail $test ++} ++ ++set target2 [get_hexadecimal_valueof "target2" -1] ++ ++if {$target2 == -1} { ++ fail "Could not get value of target2" ++ return ++} ++ ++gdb_test_no_output "set \$tar = $target2" "set tar" ++ ++gdb_breakpoint [gdb_get_line_number "marker 2"] ++ ++gdb_continue_to_breakpoint "continue to new target address" ".*marker 2.*" diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-12of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-12of15.patch new file mode 100644 index 0000000..b93af86 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-12of15.patch @@ -0,0 +1,779 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:17 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-12of15.patch + +;; [PowerPC] Add support for EBB and PMU registers +;; Edjunior Barbosa Machado and Pedro Franco de Carvalho, RH BZ 1187581m + +[PowerPC] Add support for EBB and PMU registers + +This patch adds support for registers of the Event Based Branching and +Performance Monitoring Units for the powerpc linux native and core +file targets, and for the powerpc linux server stub. + +All three EBB registers are accessible. Only a subset of the PMU +registers can be accessed through ptrace. Because of this, the PMU +registers are enumerated individually in gdbarch_tdep, as opposed to +having a single "have_pmu" flag. This is intended to make it easier +to add additional PMU registers in the future, since checking a +"have_pmu" flag elsewhere in the code would no longer be correct. The +tdesc feature is named org.gnu.gdb.power.linux.pmu because of this. + +It's unclear if it makes sense to save and restore these registers +across function calls, since some of them can be modified +asynchronously. They are also not tracked in record-replay mode. + +The kernel can return ENODATA when ptrace is used to get the EBB +registers, unless a linux performance event that uses EBB is open in +the inferior. For this reason, the "fill" functions in the server +stub for the ebb register sets is not implemented. + +Since gdbserver writes all registers in one go before resuming the +inferior, this error would not be detected at the time the user tries +to write to one of the registers on the client side, and gdbserver +would print out warnings every time it resumes the inferior when no +ebb performance event is opened, so there is currently no +straightforward way to handle this case. This means the ebb registers +in the client-side regcache can become dirty when the user tries to +write to them, until the inferior is resumed and stopped again. + +A related issue is that 'G' packets used to write to unrelated +registers will include bad data for the EBB registers if they are +unavailable, since no register status information is included in the +'G' packet. This data won't be written to the inferior by the +gdbserver stub because the "fill" functions are not implemented, and +currently the gdbserver stub doesn't change the status of the +registers in its own regcache in response to 'G' packets. + +Another limitation for the ebb registers is that traceframes don't +record if registers are available or not, so if these registers are +collected when a tracepoint is hit and the inferior has no ebb event +opened, the user will see zero values for all of them, instead of the +usual . + +Because these registers are often unavailable, trying to store them +with target_store_registers with -1 for the regno argument (all +registers) would almost always fail, so they are ignored in this case. + +gdb/ChangeLog: +2018-10-26 Edjunior Barbosa Machado + Pedro Franco de Carvalho + + * arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_EBBREGSET) + (PPC_LINUX_SIZEOF_PMUREGSET): Declare. + * nat/ppc-linux.h (PPC_FEATURE2_EBB, NT_PPC_EBB, NT_PPC_PMU): + Define if not already defined. + * features/rs6000/power-ebb.xml: New file. + * features/rs6000/power-linux-pmu.xml: New file. + * features/rs6000/powerpc-isa207-vsx32l.xml: Include ebb and pmu + features. + * features/rs6000/powerpc-isa207-vsx64l.xml: Likewise. + * features/rs6000/powerpc-isa207-vsx32l.c: Re-generate. + * features/rs6000/powerpc-isa207-vsx64l.c: Re-generate. + * regformats/rs6000/powerpc-isa207-vsx32l.dat: Re-generate. + * regformats/rs6000/powerpc-isa207-vsx64l.dat: Re-generate. + * ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call + fetch_regset with ebb and pmu regsets. + (store_register, store_ppc_registers): Call store_regset with ebb + and pmu regsets. + (ppc_linux_nat_target::read_description): Set isa207 field in the + features struct if ebb and pmu are avaiable. + * ppc-linux-tdep.c (ppc32_regmap_ebb, ppc32_regmap_pmu) + (ppc32_linux_ebbregset, ppc32_linux_pmuregset): New globals. + (ppc_linux_iterate_over_regset_sections): Call back with the ebb + and pmu regsets. + (ppc_linux_core_read_description): Check if the pmu section is + present and set isa207 in the features struct. + * ppc-linux-tdep.h (ppc32_linux_ebbregset) + (ppc32_linux_pmuregset): Declare. + * ppc-tdep.h (struct gdbarch_tdep) : New field. + : New fields. + : New field. + (enum): : + New enum values. + : New enum + values. + : New enum values. + (PPC_IS_EBB_REGNUM, PPC_IS_PMU_REGNUM): Define. + * rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate the + ebb and pmu features. + +gdb/gdbserver/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * configure.srv (powerpc*-*-linux*): Add rs6000/power-ebb.xml and + rs6000/power-linux-pmu.xml to srv_xmlfiles. + * linux-ppc-low.c (ppc_store_ebbregset, ppc_fill_pmuregset) + (ppc_store_pmuregset): New functions. + (ppc_regsets): Add entries for ebb and pmu regsets. + (ppc_arch_setup): Set isa207 in features struct if the ebb and + pmu regsets are available. Set sizes for these regsets. + +gdb/doc/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * gdb.texinfo (PowerPC Features): Describe new features + "org.gnu.gdb.power.ebb" and "org.gnu.gdb.power.linux.pmu". + +diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h +--- a/gdb/arch/ppc-linux-common.h ++++ b/gdb/arch/ppc-linux-common.h +@@ -33,6 +33,8 @@ struct target_desc; + #define PPC_LINUX_SIZEOF_PPRREGSET 8 + #define PPC_LINUX_SIZEOF_DSCRREGSET 8 + #define PPC_LINUX_SIZEOF_TARREGSET 8 ++#define PPC_LINUX_SIZEOF_EBBREGSET (3*8) ++#define PPC_LINUX_SIZEOF_PMUREGSET (5*8) + + /* Check if the hwcap auxv entry indicates that isa205 is supported. */ + bool ppc_linux_has_isa205 (CORE_ADDR hwcap); +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -42564,6 +42564,15 @@ contain the 64-bit register @samp{dscr}. + The @samp{org.gnu.gdb.power.tar} feature is optional. It should + contain the 64-bit register @samp{tar}. + ++The @samp{org.gnu.gdb.power.ebb} feature is optional. It should ++contain registers @samp{bescr}, @samp{ebbhr} and @samp{ebbrr}, all ++64-bit wide. ++ ++The @samp{org.gnu.gdb.power.linux.pmu} feature is optional. It should ++contain registers @samp{mmcr0}, @samp{mmcr2}, @samp{siar}, @samp{sdar} ++and @samp{sier}, all 64-bit wide. This is the subset of the isa 2.07 ++server PMU registers provided by @sc{gnu}/Linux. ++ + @node S/390 and System z Features + @subsection S/390 and System z Features + @cindex target descriptions, S/390 features +diff --git a/gdb/features/rs6000/power-ebb.xml b/gdb/features/rs6000/power-ebb.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-ebb.xml +@@ -0,0 +1,14 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power-linux-pmu.xml b/gdb/features/rs6000/power-linux-pmu.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-linux-pmu.xml +@@ -0,0 +1,17 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/powerpc-isa207-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-vsx32l.c +--- a/gdb/features/rs6000/powerpc-isa207-vsx32l.c ++++ b/gdb/features/rs6000/powerpc-isa207-vsx32l.c +@@ -199,5 +199,17 @@ initialize_tdesc_powerpc_isa207_vsx32l (void) + feature = tdesc_create_feature (result, "org.gnu.gdb.power.tar"); + tdesc_create_reg (feature, "tar", 141, 1, NULL, 64, "uint64"); + ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ebb"); ++ tdesc_create_reg (feature, "bescr", 142, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "ebbhr", 143, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "ebbrr", 144, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux.pmu"); ++ tdesc_create_reg (feature, "mmcr0", 145, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "mmcr2", 146, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "siar", 147, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "sdar", 148, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "sier", 149, 0, NULL, 64, "uint64"); ++ + tdesc_powerpc_isa207_vsx32l = result; + } +diff --git a/gdb/features/rs6000/powerpc-isa207-vsx32l.xml b/gdb/features/rs6000/powerpc-isa207-vsx32l.xml +--- a/gdb/features/rs6000/powerpc-isa207-vsx32l.xml ++++ b/gdb/features/rs6000/powerpc-isa207-vsx32l.xml +@@ -16,4 +16,6 @@ + + + ++ ++ + +diff --git a/gdb/features/rs6000/powerpc-isa207-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-vsx64l.c +--- a/gdb/features/rs6000/powerpc-isa207-vsx64l.c ++++ b/gdb/features/rs6000/powerpc-isa207-vsx64l.c +@@ -199,5 +199,17 @@ initialize_tdesc_powerpc_isa207_vsx64l (void) + feature = tdesc_create_feature (result, "org.gnu.gdb.power.tar"); + tdesc_create_reg (feature, "tar", 141, 1, NULL, 64, "uint64"); + ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ebb"); ++ tdesc_create_reg (feature, "bescr", 142, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "ebbhr", 143, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "ebbrr", 144, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux.pmu"); ++ tdesc_create_reg (feature, "mmcr0", 145, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "mmcr2", 146, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "siar", 147, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "sdar", 148, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "sier", 149, 0, NULL, 64, "uint64"); ++ + tdesc_powerpc_isa207_vsx64l = result; + } +diff --git a/gdb/features/rs6000/powerpc-isa207-vsx64l.xml b/gdb/features/rs6000/powerpc-isa207-vsx64l.xml +--- a/gdb/features/rs6000/powerpc-isa207-vsx64l.xml ++++ b/gdb/features/rs6000/powerpc-isa207-vsx64l.xml +@@ -16,4 +16,6 @@ + + + ++ ++ + +diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv +--- a/gdb/gdbserver/configure.srv ++++ b/gdb/gdbserver/configure.srv +@@ -249,6 +249,8 @@ case "${target}" in + srv_xmlfiles="${srv_xmlfiles} rs6000/power-dscr.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-ppr.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-tar.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-ebb.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-linux-pmu.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-e500l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-spe.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-64l.xml" +diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c +--- a/gdb/gdbserver/linux-ppc-low.c ++++ b/gdb/gdbserver/linux-ppc-low.c +@@ -545,6 +545,61 @@ ppc_store_tarregset (struct regcache *regcache, const void *buf) + supply_register_by_name (regcache, "tar", tar); + } + ++/* Event-Based Branching regset store function. Unless the inferior ++ has a perf event open, ptrace can return in error when reading and ++ writing to the regset, with ENODATA. For reading, the registers ++ will correctly show as unavailable. For writing, gdbserver ++ currently only caches any register writes from P and G packets and ++ the stub always tries to write all the regsets when resuming the ++ inferior, which would result in frequent warnings. For this ++ reason, we don't define a fill function. This also means that the ++ client-side regcache will be dirty if the user tries to write to ++ the EBB registers. G packets that the client sends to write to ++ unrelated registers will also include data for EBB registers, even ++ if they are unavailable. */ ++ ++static void ++ppc_store_ebbregset (struct regcache *regcache, const void *buf) ++{ ++ const char *regset = (const char *) buf; ++ ++ /* The order in the kernel regset is: EBBRR, EBBHR, BESCR. In the ++ .dat file is BESCR, EBBHR, EBBRR. */ ++ supply_register_by_name (regcache, "ebbrr", ®set[0]); ++ supply_register_by_name (regcache, "ebbhr", ®set[8]); ++ supply_register_by_name (regcache, "bescr", ®set[16]); ++} ++ ++/* Performance Monitoring Unit regset fill function. */ ++ ++static void ++ppc_fill_pmuregset (struct regcache *regcache, void *buf) ++{ ++ char *regset = (char *) buf; ++ ++ /* The order in the kernel regset is SIAR, SDAR, SIER, MMCR2, MMCR0. ++ In the .dat file is MMCR0, MMCR2, SIAR, SDAR, SIER. */ ++ collect_register_by_name (regcache, "siar", ®set[0]); ++ collect_register_by_name (regcache, "sdar", ®set[8]); ++ collect_register_by_name (regcache, "sier", ®set[16]); ++ collect_register_by_name (regcache, "mmcr2", ®set[24]); ++ collect_register_by_name (regcache, "mmcr0", ®set[32]); ++} ++ ++/* Performance Monitoring Unit regset store function. */ ++ ++static void ++ppc_store_pmuregset (struct regcache *regcache, const void *buf) ++{ ++ const char *regset = (const char *) buf; ++ ++ supply_register_by_name (regcache, "siar", ®set[0]); ++ supply_register_by_name (regcache, "sdar", ®set[8]); ++ supply_register_by_name (regcache, "sier", ®set[16]); ++ supply_register_by_name (regcache, "mmcr2", ®set[24]); ++ supply_register_by_name (regcache, "mmcr0", ®set[32]); ++} ++ + static void + ppc_fill_vsxregset (struct regcache *regcache, void *buf) + { +@@ -654,6 +709,10 @@ static struct regset_info ppc_regsets[] = { + fetch them every time, but still fall back to PTRACE_PEEKUSER for the + general registers. Some kernels support these, but not the newer + PPC_PTRACE_GETREGS. */ ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_EBB, 0, EXTENDED_REGS, ++ NULL, ppc_store_ebbregset }, ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_PMU, 0, EXTENDED_REGS, ++ ppc_fill_pmuregset, ppc_store_pmuregset }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TAR, 0, EXTENDED_REGS, + ppc_fill_tarregset, ppc_store_tarregset }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_PPR, 0, EXTENDED_REGS, +@@ -734,8 +793,13 @@ ppc_arch_setup (void) + features.ppr_dscr = true; + if ((ppc_hwcap2 & PPC_FEATURE2_ARCH_2_07) + && (ppc_hwcap2 & PPC_FEATURE2_TAR) ++ && (ppc_hwcap2 & PPC_FEATURE2_EBB) + && ppc_check_regset (tid, NT_PPC_TAR, +- PPC_LINUX_SIZEOF_TARREGSET)) ++ PPC_LINUX_SIZEOF_TARREGSET) ++ && ppc_check_regset (tid, NT_PPC_EBB, ++ PPC_LINUX_SIZEOF_EBBREGSET) ++ && ppc_check_regset (tid, NT_PPC_PMU, ++ PPC_LINUX_SIZEOF_PMUREGSET)) + features.isa207 = true; + } + +@@ -798,6 +862,14 @@ ppc_arch_setup (void) + regset->size = (features.isa207 ? + PPC_LINUX_SIZEOF_TARREGSET : 0); + break; ++ case NT_PPC_EBB: ++ regset->size = (features.isa207 ? ++ PPC_LINUX_SIZEOF_EBBREGSET : 0); ++ break; ++ case NT_PPC_PMU: ++ regset->size = (features.isa207 ? ++ PPC_LINUX_SIZEOF_PMUREGSET : 0); ++ break; + default: + break; + } +diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h +--- a/gdb/nat/ppc-linux.h ++++ b/gdb/nat/ppc-linux.h +@@ -60,6 +60,9 @@ + #ifndef PPC_FEATURE2_TAR + #define PPC_FEATURE2_TAR 0x04000000 + #endif ++#ifndef PPC_FEATURE2_EBB ++#define PPC_FEATURE2_EBB 0x10000000 ++#endif + + /* Glibc's headers don't define PTRACE_GETVRREGS so we cannot use a + configure time check. Some older glibc's (for instance 2.2.1) +@@ -106,6 +109,16 @@ + #define NT_PPC_DSCR 0x105 + #endif + ++/* Event Based Branch Registers. */ ++#ifndef NT_PPC_EBB ++#define NT_PPC_EBB 0x106 ++#endif ++ ++/* Performance Monitor Registers. */ ++#ifndef NT_PPC_PMU ++#define NT_PPC_PMU 0x107 ++#endif ++ + /* Return the wordsize of the target, either 4 or 8 bytes. */ + int ppc_linux_target_wordsize (int tid); + +diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c +--- a/gdb/ppc-linux-nat.c ++++ b/gdb/ppc-linux-nat.c +@@ -667,6 +667,24 @@ fetch_register (struct regcache *regcache, int tid, int regno) + &ppc32_linux_tarregset); + return; + } ++ else if (PPC_IS_EBB_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_ebb); ++ ++ fetch_regset (regcache, tid, NT_PPC_EBB, ++ PPC_LINUX_SIZEOF_EBBREGSET, ++ &ppc32_linux_ebbregset); ++ return; ++ } ++ else if (PPC_IS_PMU_REGNUM (regno)) ++ { ++ gdb_assert (tdep->ppc_mmcr0_regnum != -1); ++ ++ fetch_regset (regcache, tid, NT_PPC_PMU, ++ PPC_LINUX_SIZEOF_PMUREGSET, ++ &ppc32_linux_pmuregset); ++ return; ++ } + + if (regaddr == -1) + { +@@ -875,6 +893,14 @@ fetch_ppc_registers (struct regcache *regcache, int tid) + fetch_regset (regcache, tid, NT_PPC_TAR, + PPC_LINUX_SIZEOF_TARREGSET, + &ppc32_linux_tarregset); ++ if (tdep->have_ebb) ++ fetch_regset (regcache, tid, NT_PPC_EBB, ++ PPC_LINUX_SIZEOF_EBBREGSET, ++ &ppc32_linux_ebbregset); ++ if (tdep->ppc_mmcr0_regnum != -1) ++ fetch_regset (regcache, tid, NT_PPC_PMU, ++ PPC_LINUX_SIZEOF_PMUREGSET, ++ &ppc32_linux_pmuregset); + } + + /* Fetch registers from the child process. Fetch all registers if +@@ -1082,6 +1108,24 @@ store_register (const struct regcache *regcache, int tid, int regno) + &ppc32_linux_tarregset); + return; + } ++ else if (PPC_IS_EBB_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_ebb); ++ ++ store_regset (regcache, tid, regno, NT_PPC_EBB, ++ PPC_LINUX_SIZEOF_EBBREGSET, ++ &ppc32_linux_ebbregset); ++ return; ++ } ++ else if (PPC_IS_PMU_REGNUM (regno)) ++ { ++ gdb_assert (tdep->ppc_mmcr0_regnum != -1); ++ ++ store_regset (regcache, tid, regno, NT_PPC_PMU, ++ PPC_LINUX_SIZEOF_PMUREGSET, ++ &ppc32_linux_pmuregset); ++ return; ++ } + + if (regaddr == -1) + return; +@@ -1308,6 +1352,15 @@ store_ppc_registers (const struct regcache *regcache, int tid) + store_regset (regcache, tid, -1, NT_PPC_TAR, + PPC_LINUX_SIZEOF_TARREGSET, + &ppc32_linux_tarregset); ++ ++ if (tdep->ppc_mmcr0_regnum != -1) ++ store_regset (regcache, tid, -1, NT_PPC_PMU, ++ PPC_LINUX_SIZEOF_PMUREGSET, ++ &ppc32_linux_pmuregset); ++ ++ /* Because the EBB registers can be unavailable, attempts to store ++ them here would cause this function to fail most of the time, so ++ we ignore them. */ + } + + /* Fetch the AT_HWCAP entry from the aux vector. */ +@@ -2439,7 +2492,10 @@ ppc_linux_nat_target::read_description () + features.ppr_dscr = true; + if ((hwcap2 & PPC_FEATURE2_ARCH_2_07) + && (hwcap2 & PPC_FEATURE2_TAR) +- && check_regset (tid, NT_PPC_TAR, PPC_LINUX_SIZEOF_TARREGSET)) ++ && (hwcap2 & PPC_FEATURE2_EBB) ++ && check_regset (tid, NT_PPC_TAR, PPC_LINUX_SIZEOF_TARREGSET) ++ && check_regset (tid, NT_PPC_EBB, PPC_LINUX_SIZEOF_EBBREGSET) ++ && check_regset (tid, NT_PPC_PMU, PPC_LINUX_SIZEOF_PMUREGSET)) + features.isa207 = true; + } + +diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c +--- a/gdb/ppc-linux-tdep.c ++++ b/gdb/ppc-linux-tdep.c +@@ -599,6 +599,44 @@ const struct regset ppc32_linux_tarregset = { + regcache_collect_regset + }; + ++/* Event-Based Branching regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_ebb[] = ++ { ++ { 1, PPC_EBBRR_REGNUM, 8 }, ++ { 1, PPC_EBBHR_REGNUM, 8 }, ++ { 1, PPC_BESCR_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Event-Based Branching regset. */ ++ ++const struct regset ppc32_linux_ebbregset = { ++ ppc32_regmap_ebb, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++/* Performance Monitoring Unit regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_pmu[] = ++ { ++ { 1, PPC_SIAR_REGNUM, 8 }, ++ { 1, PPC_SDAR_REGNUM, 8 }, ++ { 1, PPC_SIER_REGNUM, 8 }, ++ { 1, PPC_MMCR2_REGNUM, 8 }, ++ { 1, PPC_MMCR0_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Performance Monitoring Unit regset. */ ++ ++const struct regset ppc32_linux_pmuregset = { ++ ppc32_regmap_pmu, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ + const struct regset * + ppc_linux_gregset (int wordsize) + { +@@ -674,6 +712,22 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, + cb (".reg-ppc-tar", PPC_LINUX_SIZEOF_TARREGSET, + PPC_LINUX_SIZEOF_TARREGSET, + &ppc32_linux_tarregset, "Target Address Register", cb_data); ++ ++ /* EBB registers are unavailable when ptrace returns ENODATA. Check ++ availability when generating a core file (regcache != NULL). */ ++ if (tdep->have_ebb) ++ if (regcache == NULL ++ || REG_VALID == regcache->get_register_status (PPC_BESCR_REGNUM)) ++ cb (".reg-ppc-ebb", PPC_LINUX_SIZEOF_EBBREGSET, ++ PPC_LINUX_SIZEOF_EBBREGSET, ++ &ppc32_linux_ebbregset, "Event-based Branching Registers", ++ cb_data); ++ ++ if (tdep->ppc_mmcr0_regnum != -1) ++ cb (".reg-ppc-pmu", PPC_LINUX_SIZEOF_PMUREGSET, ++ PPC_LINUX_SIZEOF_PMUREGSET, ++ &ppc32_linux_pmuregset, "Performance Monitor Registers", ++ cb_data); + } + + static void +@@ -1089,6 +1143,7 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, + asection *ppr = bfd_get_section_by_name (abfd, ".reg-ppc-ppr"); + asection *dscr = bfd_get_section_by_name (abfd, ".reg-ppc-dscr"); + asection *tar = bfd_get_section_by_name (abfd, ".reg-ppc-tar"); ++ asection *pmu = bfd_get_section_by_name (abfd, ".reg-ppc-pmu"); + + if (! section) + return NULL; +@@ -1124,7 +1179,12 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, + if (ppr && dscr) + { + features.ppr_dscr = true; +- if (tar) ++ ++ /* We don't require the EBB note section to be present in the ++ core file to select isa207 because these registers could have ++ been unavailable when the core file was created. They will ++ be in the tdep but will show as unavailable. */ ++ if (tar && pmu) + features.isa207 = true; + } + +diff --git a/gdb/ppc-linux-tdep.h b/gdb/ppc-linux-tdep.h +--- a/gdb/ppc-linux-tdep.h ++++ b/gdb/ppc-linux-tdep.h +@@ -48,5 +48,7 @@ int ppc_linux_trap_reg_p (struct gdbarch *gdbarch); + extern const struct regset ppc32_linux_pprregset; + extern const struct regset ppc32_linux_dscrregset; + extern const struct regset ppc32_linux_tarregset; ++extern const struct regset ppc32_linux_ebbregset; ++extern const struct regset ppc32_linux_pmuregset; + + #endif /* PPC_LINUX_TDEP_H */ +diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h +--- a/gdb/ppc-tdep.h ++++ b/gdb/ppc-tdep.h +@@ -265,6 +265,15 @@ struct gdbarch_tdep + /* Decimal 128 registers. */ + int ppc_dl0_regnum; /* First Decimal128 argument register pair. */ + ++ int have_ebb; ++ ++ /* PMU registers. */ ++ int ppc_mmcr0_regnum; ++ int ppc_mmcr2_regnum; ++ int ppc_siar_regnum; ++ int ppc_sdar_regnum; ++ int ppc_sier_regnum; ++ + /* Offset to ABI specific location where link register is saved. */ + int lr_frame_offset; + +@@ -321,12 +330,31 @@ enum { + PPC_PPR_REGNUM = 172, + PPC_DSCR_REGNUM = 173, + PPC_TAR_REGNUM = 174, ++ ++ /* EBB registers. */ ++ PPC_BESCR_REGNUM = 175, ++ PPC_EBBHR_REGNUM = 176, ++ PPC_EBBRR_REGNUM = 177, ++ ++ /* PMU registers. */ ++ PPC_MMCR0_REGNUM = 178, ++ PPC_MMCR2_REGNUM = 179, ++ PPC_SIAR_REGNUM = 180, ++ PPC_SDAR_REGNUM = 181, ++ PPC_SIER_REGNUM = 182, ++ + PPC_NUM_REGS + }; + + /* Big enough to hold the size of the largest register in bytes. */ + #define PPC_MAX_REGISTER_SIZE 64 + ++#define PPC_IS_EBB_REGNUM(i) \ ++ ((i) >= PPC_BESCR_REGNUM && (i) <= PPC_EBBRR_REGNUM) ++ ++#define PPC_IS_PMU_REGNUM(i) \ ++ ((i) >= PPC_MMCR0_REGNUM && (i) <= PPC_SIER_REGNUM) ++ + /* An instruction to match. */ + + struct ppc_insn_pattern +diff --git a/gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat b/gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat +--- a/gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat ++++ b/gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat +@@ -145,3 +145,11 @@ expedite:r1,pc + 64:ppr + 64:dscr + 64:tar ++64:bescr ++64:ebbhr ++64:ebbrr ++64:mmcr0 ++64:mmcr2 ++64:siar ++64:sdar ++64:sier +diff --git a/gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat b/gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat +--- a/gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat ++++ b/gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat +@@ -145,3 +145,11 @@ expedite:r1,pc + 64:ppr + 64:dscr + 64:tar ++64:bescr ++64:ebbhr ++64:ebbrr ++64:mmcr0 ++64:mmcr2 ++64:siar ++64:sdar ++64:sier +diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c +--- a/gdb/rs6000-tdep.c ++++ b/gdb/rs6000-tdep.c +@@ -5871,7 +5871,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + enum powerpc_elf_abi elf_abi = POWERPC_ELF_AUTO; + int have_fpu = 0, have_spe = 0, have_mq = 0, have_altivec = 0; + int have_dfp = 0, have_vsx = 0, have_ppr = 0, have_dscr = 0; +- int have_tar = 0; ++ int have_tar = 0, have_ebb = 0, have_pmu = 0; + int tdesc_wordsize = -1; + const struct target_desc *tdesc = info.target_desc; + struct tdesc_arch_data *tdesc_data = NULL; +@@ -6211,6 +6211,64 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + } + else + have_tar = 0; ++ ++ /* Event-based Branching Registers. */ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.ebb"); ++ if (feature != NULL) ++ { ++ static const char *const ebb_regs[] = { ++ "bescr", "ebbhr", "ebbrr" ++ }; ++ ++ valid_p = 1; ++ for (i = 0; i < ARRAY_SIZE (ebb_regs); i++) ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_BESCR_REGNUM + i, ++ ebb_regs[i]); ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_ebb = 1; ++ } ++ else ++ have_ebb = 0; ++ ++ /* Subset of the ISA 2.07 Performance Monitor Registers provided ++ by Linux. */ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.linux.pmu"); ++ if (feature != NULL) ++ { ++ valid_p = 1; ++ ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_MMCR0_REGNUM, ++ "mmcr0"); ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_MMCR2_REGNUM, ++ "mmcr2"); ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_SIAR_REGNUM, ++ "siar"); ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_SDAR_REGNUM, ++ "sdar"); ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_SIER_REGNUM, ++ "sier"); ++ ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_pmu = 1; ++ } ++ else ++ have_pmu = 0; + } + + /* If we have a 64-bit binary on a 32-bit target, complain. Also +@@ -6408,6 +6466,20 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + tdep->ppc_ppr_regnum = have_ppr ? PPC_PPR_REGNUM : -1; + tdep->ppc_dscr_regnum = have_dscr ? PPC_DSCR_REGNUM : -1; + tdep->ppc_tar_regnum = have_tar ? PPC_TAR_REGNUM : -1; ++ tdep->have_ebb = have_ebb; ++ ++ /* If additional pmu registers are added, care must be taken when ++ setting new fields in the tdep below, to maintain compatibility ++ with features that only provide some of the registers. Currently ++ gdb access to the pmu registers is only supported in linux, and ++ linux only provides a subset of the pmu registers defined in the ++ architecture. */ ++ ++ tdep->ppc_mmcr0_regnum = have_pmu ? PPC_MMCR0_REGNUM : -1; ++ tdep->ppc_mmcr2_regnum = have_pmu ? PPC_MMCR2_REGNUM : -1; ++ tdep->ppc_siar_regnum = have_pmu ? PPC_SIAR_REGNUM : -1; ++ tdep->ppc_sdar_regnum = have_pmu ? PPC_SDAR_REGNUM : -1; ++ tdep->ppc_sier_regnum = have_pmu ? PPC_SIER_REGNUM : -1; + + set_gdbarch_pc_regnum (gdbarch, PPC_PC_REGNUM); + set_gdbarch_sp_regnum (gdbarch, PPC_R0_REGNUM + 1); diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-13of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-13of15.patch new file mode 100644 index 0000000..e82c15b --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-13of15.patch @@ -0,0 +1,38 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:18 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-13of15.patch + +;; [PowerPC] Reject tdescs with VSX and no FPU or Altivec +;; Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Reject tdescs with VSX and no FPU or Altivec + +Currently rs6000_gdbarch_init will accept a tdesc with the +"org.gnu.gdb.power.vsx" feature but without the +"org.gnu.gdb.power.altivec" or "org.gnu.gdb.power.fpu". + +It isn't clear from the standard features documentation that these are +requirements. However, these tdescs would cause trouble in the VSX +pseudo-register functions, so this patch will cause them to be +rejected. + +gdb/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * rs6000-tdep.c (rs6000_gdbarch_init): Reject tdescs with vsx but + without altivec or fpu. + +diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c +--- a/gdb/rs6000-tdep.c ++++ b/gdb/rs6000-tdep.c +@@ -6096,7 +6096,8 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + valid_p &= tdesc_numbered_register (feature, tdesc_data, + PPC_VSR0_UPPER_REGNUM + i, + vsx_regs[i]); +- if (!valid_p) ++ ++ if (!valid_p || !have_fpu || !have_altivec) + { + tdesc_data_cleanup (tdesc_data); + return NULL; diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-14of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-14of15.patch new file mode 100644 index 0000000..77c0aba --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-14of15.patch @@ -0,0 +1,4787 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:18 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-14of15.patch + +;; [PowerPC] Add support for HTM registers +;; Edjunior Barbosa Machado and Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Add support for HTM registers + +This patch adds support for Hardware Transactional Memory registers +for the powerpc linux native and core file targets, and for the +pwoerpc linux server stub. + +These registers include both the HTM special-purpose registers (TFHAR, +TEXASR and TFIAR) as well as the set of registers that are +checkpointed (saved) when a transaction is initiated, which the +processor restores in the event of a transaction failure. + +The set of checkpointed general-purpose registers is returned by the +linux kernel in the same format as the regular general-purpose +registers, defined in struct pt_regs. However, the architecture +specifies that only some of the registers present in pt_regs are +checkpointed (GPRs 0-31, CR, XER, LR and CTR). The kernel fills the +slots for MSR and NIP with other info. The other fields usually don't +have meaningful values. GDB doesn't define registers that are not +checkpointed in the architecture, but when generating a core file, GDB +fills the slot for the checkpointed MSR with the regular MSR. These +are usually similar, although some bits might be different, and in +some cases the checkpointed MSR will have a value of 0 in a +kernel-generated core-file. The checkpointed NIP is filled with TFHAR +by GDB in the core-file, which is what the kernel does. The other +fields are set to 0 by GDB. + +Core files generated by the kernel have a note section for +checkpointed GPRs with the same size for both 32-bit and 64-bit +threads, and the values for the registers of a 32-bit thread are +squeezed in the first half, with no useful data in the second half. +GDB generates a smaller note section for 32-bit threads, but can read +both sizes. + +The checkpointed XER is required to be 32-bit in the target +description documentation, even though the more recent ISAs define it +as 64-bit wide, since the high-order 32-bits are reserved, and because +in Linux there is no way to get a 64-bit checkpointed XER for 32-bit +threads. If this changes in the future, the target description +feature requirement can be relaxed to allow for a 64-bit checkpointed +XER. + +Access to the checkpointed CR (condition register) can be confusing. +The architecture only specifies that CR fields 1 to 7 (the 24 least +significant bits) are checkpointed, but the kernel provides all 8 +fields (32 bits). The value of field 0 is not masked by ptrace, so it +will sometimes show the result of some kernel operation, probably +treclaim., which sets this field. + +The checkpointed registers are marked not to be saved and restored. +Inferior function calls during an active transaction don't work well, +and it's unclear what should be done in this case. TEXASR and TFIAR +can be altered asynchronously, during transaction failure recording, +so they are also not saved and restored. For consistency neither is +TFHAR. + +Record and replay also doesn't work well when transactions are +involved. This patch doesn't address this, so the values of the HTM +SPRs will sometimes be innacurate when the record/relay target is +enabled. For instance, executing a "tbegin." alters TFHAR and TEXASR, +but these changes are not currently recorded. + +Because the checkpointed registers are only available when a +transaction is active (or suspended), ptrace can return ENODATA when +gdb tries to read these registers and the inferior is not in a +transactional state. The registers are set to the unavailable state +when this happens. When gbd tries to write to one of these registers, +and it is unavailable, an error is raised. + +The "fill" functions for checkpointed register sets in the server stub +are not implemented for the same reason as for the EBB register set, +since ptrace can also return ENODATA for checkpointed regsets. The +same issues with 'G' packets apply here. + +Just like for the EBB registers, tracepoints will not mark the +checkpointed registers as unavailable if the inferior was not in a +transaction, so their content will also show 0 instead of + when inspecting trace data. + +The new tests record the values of the regular registers before +stepping the inferior through a "tbegin." instruction to start a +transaction, then the checkpointed registers are checked against the +recorded pre-transactional values. New values are written to the +checkpointed registers and recorded, the inferior continues until the +transaction aborts (which is usually immediately when it is resumed), +and the regular registers are checked against the recorded values, +because the abort should have reverted the registers to these values. + +Like for the EBB registers, target_store_registers will ignore the +checkpointed registers when called with -1 as the regno +argument (store all registers in one go). + +gdb/ChangeLog: +2018-10-26 Edjunior Barbosa Machado + Pedro Franco de Carvalho + + * arch/ppc-linux-tdesc.h (tdesc_powerpc_isa207_htm_vsx32l) + (tdesc_powerpc_isa207_htm_vsx64l): Declare. + * arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_TM_SPRREGSET) + (PPC32_LINUX_SIZEOF_CGPRREGSET, PPC64_LINUX_SIZEOF_CGPRREGSET) + (PPC_LINUX_SIZEOF_CFPRREGSET, PPC_LINUX_SIZEOF_CVMXREGSET) + (PPC_LINUX_SIZEOF_CVSXREGSET, PPC_LINUX_SIZEOF_CPPRREGSET) + (PPC_LINUX_SIZEOF_CDSCRREGSET, PPC_LINUX_SIZEOF_CTARREGSET): + Define. + (struct ppc_linux_features) : New field. + (ppc_linux_no_features): Add initializer for htm field. + * arch/ppc-linux-common.c (ppc_linux_match_description): Return + new tdescs. + * nat/ppc-linux.h (PPC_FEATURE2_HTM, NT_PPC_TM_CGPR) + (NT_PPC_TM_CFPR, NT_PPC_TM_CVMX, NT_PPC_TM_CVSX) + (NT_PPC_TM_SPR, NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR): + Define if not already defined. + * features/Makefile (WHICH): Add rs6000/powerpc-isa207-htm-vsx32l + and rs6000/powerpc-isa207-htm-vsx64l. + (XMLTOC): Add rs6000/powerpc-isa207-htm-vsx32l.xml and + rs6000/powerpc-isa207-htm-vsx64l.xml. + * features/rs6000/power-htm-spr.xml: New file. + * features/rs6000/power-htm-core.xml: New file. + * features/rs6000/power64-htm-core.xml: New file. + * features/rs6000/power-htm-fpu.xml: New file. + * features/rs6000/power-htm-altivec.xml: New file. + * features/rs6000/power-htm-vsx.xml: New file. + * features/rs6000/power-htm-ppr.xml: New file. + * features/rs6000/power-htm-dscr.xml: New file. + * features/rs6000/power-htm-tar.xml: New file. + * features/rs6000/powerpc-isa207-htm-vsx32l.xml: New file. + * features/rs6000/powerpc-isa207-htm-vsx64l.xml: New file. + * features/rs6000/powerpc-isa207-htm-vsx32l.c: Generate. + * features/rs6000/powerpc-isa207-htm-vsx64l.c: Generate. + * regformats/rs6000/powerpc-isa207-htm-vsx32l.dat: Generate. + * regformats/rs6000/powerpc-isa207-htm-vsx64l.dat: Generate. + * ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call + fetch_regset with HTM regsets. + (store_register, store_ppc_registers): Call store_regset with HTM + regsets. + (ppc_linux_nat_target::read_description): Set htm field in the + features struct if needed. + * ppc-linux-tdep.c: Include + features/rs6000/powerpc-isa207-htm-vsx32l.c and + features/rs6000/powerpc-isa207-htm-vsx64l.c. + (ppc32_regmap_tm_spr, ppc32_regmap_cgpr, ppc64_le_regmap_cgpr) + (ppc64_be_regmap_cgpr, ppc32_regmap_cfpr, ppc32_le_regmap_cvmx) + (ppc32_be_regmap_cvmx, ppc32_regmap_cvsx, ppc32_regmap_cppr) + (ppc32_regmap_cdscr, ppc32_regmap_ctar): New globals. + (ppc32_linux_tm_sprregset, ppc32_linux_cgprregset) + (ppc64_be_linux_cgprregset, ppc64_le_linux_cgprregset) + (ppc32_linux_cfprregset, ppc32_le_linux_cvmxregset) + (ppc32_be_linux_cvmxregset, ppc32_linux_cvsxregset) + (ppc32_linux_cpprregset, ppc32_linux_cdscrregset) + (ppc32_linux_ctarregset): New globals. + (ppc_linux_cgprregset, ppc_linux_cvmxregset): New functions. + (ppc_linux_collect_core_cpgrregset): New function. + (ppc_linux_iterate_over_regset_sections): Call back with the htm + regsets. + (ppc_linux_core_read_description): Check if the tm spr section is + present and set htm in the features struct. + (_initialize_ppc_linux_tdep): Call + initialize_tdesc_powerpc_isa207_htm_vsx32l and + initialize_tdesc_powerpc_isa207_htm_vsx64l. + * ppc-linux-tdep.h (ppc_linux_cgprregset, ppc_linux_cvmxregset): + Declare. + (ppc32_linux_tm_sprregset, ppc32_linux_cfprregset) + (ppc32_linux_cvsxregset, ppc32_linux_cpprregset) + (ppc32_linux_cdscrregset, ppc32_linux_ctarregset): Declare. + * ppc-tdep.h (struct gdbarch_tdep) : + New fields. + : + Likewise. + : Likewise. + : Likewise. + (enum) : + New enum fields. + : Likewise. + : Likewise. + : Likewise. + : Likewise. + : Likewise. + : Likewise. + (PPC_IS_TMSPR_REGNUM, PPC_IS_CKPTGP_REGNUM, PPC_IS_CKPTFP_REGNUM) + (PPC_IS_CKPTVMX_REGNUM, PPC_IS_CKPTVSX_REGNUM): Define. + * rs6000-tdep.c (IS_CDFP_PSEUDOREG, IS_CVSX_PSEUDOREG) + (IS_CEFP_PSEUDOREG): Define. + (rs6000_register_name): Hide the upper halves of checkpointed VSX + registers. Return names for the checkpointed DFP, VSX, and EFP + pseudo registers. + (rs6000_pseudo_register_type): Remove initial assert and raise an + internal error in the else clause instead. Return types for the + checkpointed DFP, VSX, and EFP pseudo registers. + (dfp_pseudo_register_read, dfp_pseudo_register_write): Handle + checkpointed DFP pseudo registers. + (vsx_pseudo_register_read, vsx_pseudo_register_write): Handle + checkpointed VSX pseudo registers. + (efp_pseudo_register_read, efp_pseudo_register_write): Rename + from efpr_pseudo_register_read and + efpr_pseudo_register_write. Handle checkpointed EFP pseudo + registers. + (rs6000_pseudo_register_read, rs6000_pseudo_register_write): + Handle checkpointed DFP, VSX, and EFP registers. + (dfp_ax_pseudo_register_collect, vsx_ax_pseudo_register_collect) + (efp_ax_pseudo_register_collect): New functions. + (rs6000_ax_pseudo_register_collect): Move DFP, VSX and EFP pseudo + register logic to new functions. Handle checkpointed DFP, VSX, + and EFP pseudo registers. + (rs6000_gdbarch_init): Look for and validate the htm features. + Include checkpointed DFP, VSX and EFP pseudo-registers. + * NEWS: Mention access to PPR, DSCR, TAR, EBB/PMU registers and + HTM registers. + +gdb/gdbserver/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * configure.srv (ipa_ppc_linux_regobj): Add + powerpc-isa207-htm-vsx32l-ipa.o and + powerpc-isa207-htm-vsx64l-ipa.o. + (powerpc*-*-linux*): Add powerpc-isa207-htm-vsx32l.o and + powerpc-isa207-htm-vsx64l.o to srv_regobj. Add + rs6000/power-htm-spr.xml, rs6000/power-htm-core.xml, + rs6000/power64-htm-core.xml, rs6000/power-htm-fpu.xml, + rs6000/power-htm-altivec.xml, rs6000/power-htm-vsx.xml, + rs6000/power-htm-ppr.xml, rs6000/power-htm-dscr.xml, + rs6000/power-htm-tar.xml, rs6000/powerpc-isa207-htm-vsx32l.xml, + and rs6000/powerpc-isa207-htm-vsx64l.xml to srv_xmlfiles. + * linux-ppc-tdesc-init.h (enum ppc_linux_tdesc) + : New enum value. + (init_registers_powerpc_isa207_htm_vsx32l) + (init_registers_powerpc_isa207_htm_vsx64l): Declare. + * linux-ppc-low.c (ppc_fill_tm_sprregset, ppc_store_tm_sprregset) + (ppc_store_tm_cgprregset, ppc_store_tm_cfprregset) + (ppc_store_tm_cvrregset, ppc_store_tm_cvsxregset) + (ppc_store_tm_cpprregset, ppc_store_tm_cdscrregset) + (ppc_store_tm_ctarregset): New functions. + (ppc_regsets): Add entries for HTM regsets. + (ppc_arch_setup): Set htm in features struct when needed. Set + sizes for the HTM regsets. + (ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA207_HTM_VSX. + (initialize_low_arch): Call + init_registers_powerpc_isa207_htm_vsx32l and + init_registers_powerpc_isa207_htm_vsx64l. + * linux-ppc-ipa.c (get_ipa_tdesc): Handle + PPC_TDESC_ISA207_HTM_VSX. + (initialize_low_tracepoint): Call + init_registers_powerpc_isa207_htm_vsx32l and + init_registers_powerpc_isa207_htm_vsx64l. + +gdb/testsuite/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * gdb.arch/powerpc-htm-regs.c: New file. + * gdb.arch/powerpc-htm-regs.exp: New file. + +gdb/doc/ChangeLog: +2018-10-26 Pedro Franco de Carvalho + + * gdb.texinfo (PowerPC Features): Describe new features + "org.gnu.gdb.power.htm.spr", "org.gnu.gdb.power.htm.core", + "org.gnu.gdb.power.htm.fpu", "org.gnu.gdb.power.htm.altivec", + "org.gnu.gdb.power.htm.vsx", "org.gnu.gdb.power.htm.ppr", + "org.gnu.gdb.power.htm.dscr", "org.gnu.gdb.power.htm.tar". + +diff --git a/gdb/NEWS b/gdb/NEWS +--- a/gdb/NEWS ++++ b/gdb/NEWS +@@ -12,6 +12,10 @@ + + *** Changes in GDB 8.2 + ++* GDB and GDBserver now support access to additional registers on ++ PowerPC GNU/Linux targets: PPR, DSCR, TAR, EBB/PMU registers, and ++ HTM registers. ++ + * The 'set disassembler-options' command now supports specifying options + for the MIPS target. + +diff --git a/gdb/arch/ppc-linux-common.c b/gdb/arch/ppc-linux-common.c +--- a/gdb/arch/ppc-linux-common.c ++++ b/gdb/arch/ppc-linux-common.c +@@ -53,7 +53,8 @@ ppc_linux_match_description (struct ppc_linux_features features) + if (features.cell) + tdesc = tdesc_powerpc_cell64l; + else if (features.vsx) +- tdesc = (features.isa207? tdesc_powerpc_isa207_vsx64l ++ tdesc = (features.htm? tdesc_powerpc_isa207_htm_vsx64l ++ : features.isa207? tdesc_powerpc_isa207_vsx64l + : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx64l + : features.isa205? tdesc_powerpc_isa205_vsx64l + : tdesc_powerpc_vsx64l); +@@ -71,7 +72,8 @@ ppc_linux_match_description (struct ppc_linux_features features) + if (features.cell) + tdesc = tdesc_powerpc_cell32l; + else if (features.vsx) +- tdesc = (features.isa207? tdesc_powerpc_isa207_vsx32l ++ tdesc = (features.htm? tdesc_powerpc_isa207_htm_vsx32l ++ : features.isa207? tdesc_powerpc_isa207_vsx32l + : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx32l + : features.isa205? tdesc_powerpc_isa205_vsx32l + : tdesc_powerpc_vsx32l); +diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h +--- a/gdb/arch/ppc-linux-common.h ++++ b/gdb/arch/ppc-linux-common.h +@@ -35,6 +35,15 @@ struct target_desc; + #define PPC_LINUX_SIZEOF_TARREGSET 8 + #define PPC_LINUX_SIZEOF_EBBREGSET (3*8) + #define PPC_LINUX_SIZEOF_PMUREGSET (5*8) ++#define PPC_LINUX_SIZEOF_TM_SPRREGSET (3*8) ++#define PPC32_LINUX_SIZEOF_CGPRREGSET (48*4) ++#define PPC64_LINUX_SIZEOF_CGPRREGSET (48*8) ++#define PPC_LINUX_SIZEOF_CFPRREGSET (32*8+8) ++#define PPC_LINUX_SIZEOF_CVMXREGSET (34*16) ++#define PPC_LINUX_SIZEOF_CVSXREGSET (32*8) ++#define PPC_LINUX_SIZEOF_CPPRREGSET 8 ++#define PPC_LINUX_SIZEOF_CDSCRREGSET 8 ++#define PPC_LINUX_SIZEOF_CTARREGSET 8 + + /* Check if the hwcap auxv entry indicates that isa205 is supported. */ + bool ppc_linux_has_isa205 (CORE_ADDR hwcap); +@@ -48,6 +57,7 @@ struct ppc_linux_features + bool isa205; + bool ppr_dscr; + bool isa207; ++ bool htm; + bool cell; + }; + +@@ -60,6 +70,7 @@ const struct ppc_linux_features ppc_linux_no_features = { + false, + false, + false, ++ false, + }; + + /* Return a target description that matches FEATURES. */ +diff --git a/gdb/arch/ppc-linux-tdesc.h b/gdb/arch/ppc-linux-tdesc.h +--- a/gdb/arch/ppc-linux-tdesc.h ++++ b/gdb/arch/ppc-linux-tdesc.h +@@ -31,6 +31,7 @@ extern struct target_desc *tdesc_powerpc_isa205_altivec32l; + extern struct target_desc *tdesc_powerpc_isa205_vsx32l; + extern struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx32l; + extern struct target_desc *tdesc_powerpc_isa207_vsx32l; ++extern struct target_desc *tdesc_powerpc_isa207_htm_vsx32l; + extern struct target_desc *tdesc_powerpc_e500l; + + extern struct target_desc *tdesc_powerpc_64l; +@@ -42,5 +43,6 @@ extern struct target_desc *tdesc_powerpc_isa205_altivec64l; + extern struct target_desc *tdesc_powerpc_isa205_vsx64l; + extern struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l; + extern struct target_desc *tdesc_powerpc_isa207_vsx64l; ++extern struct target_desc *tdesc_powerpc_isa207_htm_vsx64l; + + #endif /* ARCH_PPC_LINUX_TDESC_H */ +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -42573,6 +42573,48 @@ contain registers @samp{mmcr0}, @samp{mmcr2}, @samp{siar}, @samp{sdar} + and @samp{sier}, all 64-bit wide. This is the subset of the isa 2.07 + server PMU registers provided by @sc{gnu}/Linux. + ++The @samp{org.gnu.gdb.power.htm.spr} feature is optional. It should ++contain registers @samp{tfhar}, @samp{texasr} and @samp{tfiar}, all ++64-bit wide. ++ ++The @samp{org.gnu.gdb.power.htm.core} feature is optional. It should ++contain the checkpointed general-purpose registers @samp{cr0} through ++@samp{cr31}, as well as the checkpointed registers @samp{clr} and ++@samp{cctr}. These registers may all be either 32-bit or 64-bit ++depending on the target. It should also contain the checkpointed ++registers @samp{ccr} and @samp{cxer}, which should both be 32-bit ++wide. ++ ++The @samp{org.gnu.gdb.power.htm.fpu} feature is optional. It should ++contain the checkpointed 64-bit floating-point registers @samp{cf0} ++through @samp{cf31}, as well as the checkpointed 64-bit register ++@samp{cfpscr}. ++ ++The @samp{org.gnu.gdb.power.htm.altivec} feature is optional. It ++should contain the checkpointed altivec registers @samp{cvr0} through ++@samp{cvr31}, all 128-bit wide. It should also contain the ++checkpointed registers @samp{cvscr} and @samp{cvrsave}, both 32-bit ++wide. ++ ++The @samp{org.gnu.gdb.power.htm.vsx} feature is optional. It should ++contain registers @samp{cvs0h} through @samp{cvs31h}. @value{GDBN} ++will combine these registers with the checkpointed floating point ++registers (@samp{cf0} through @samp{cf31}) and the checkpointed ++altivec registers (@samp{cvr0} through @samp{cvr31}) to present the ++128-bit wide checkpointed vector-scalar registers @samp{cvs0} through ++@samp{cvs63}. Therefore, this feature requires both ++@samp{org.gnu.gdb.power.htm.altivec} and ++@samp{org.gnu.gdb.power.htm.fpu}. ++ ++The @samp{org.gnu.gdb.power.htm.ppr} feature is optional. It should ++contain the 64-bit checkpointed register @samp{cppr}. ++ ++The @samp{org.gnu.gdb.power.htm.dscr} feature is optional. It should ++contain the 64-bit checkpointed register @samp{cdscr}. ++ ++The @samp{org.gnu.gdb.power.htm.tar} feature is optional. It should ++contain the 64-bit checkpointed register @samp{ctar}. ++ + @node S/390 and System z Features + @subsection S/390 and System z Features + @cindex target descriptions, S/390 features +diff --git a/gdb/features/Makefile b/gdb/features/Makefile +--- a/gdb/features/Makefile ++++ b/gdb/features/Makefile +@@ -76,6 +76,8 @@ WHICH = aarch64 \ + rs6000/powerpc-isa205-ppr-dscr-vsx32l \ + rs6000/powerpc-isa205-ppr-dscr-vsx64l \ + rs6000/powerpc-isa207-vsx32l rs6000/powerpc-isa207-vsx64l \ ++ rs6000/powerpc-isa207-htm-vsx32l \ ++ rs6000/powerpc-isa207-htm-vsx64l \ + s390-linux32 s390-linux64 s390x-linux64 \ + s390-linux32v1 s390-linux64v1 s390x-linux64v1 \ + s390-linux32v2 s390-linux64v2 s390x-linux64v2 \ +@@ -174,6 +176,8 @@ XMLTOC = \ + rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml \ + rs6000/powerpc-isa207-vsx32l.xml \ + rs6000/powerpc-isa207-vsx64l.xml \ ++ rs6000/powerpc-isa207-htm-vsx32l.xml \ ++ rs6000/powerpc-isa207-htm-vsx64l.xml \ + rs6000/powerpc-vsx32.xml \ + rs6000/powerpc-vsx32l.xml \ + rs6000/powerpc-vsx64.xml \ +diff --git a/gdb/features/rs6000/power-htm-altivec.xml b/gdb/features/rs6000/power-htm-altivec.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-htm-altivec.xml +@@ -0,0 +1,58 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power-htm-core.xml b/gdb/features/rs6000/power-htm-core.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-htm-core.xml +@@ -0,0 +1,48 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power-htm-dscr.xml b/gdb/features/rs6000/power-htm-dscr.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-htm-dscr.xml +@@ -0,0 +1,12 @@ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power-htm-fpu.xml b/gdb/features/rs6000/power-htm-fpu.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-htm-fpu.xml +@@ -0,0 +1,45 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power-htm-ppr.xml b/gdb/features/rs6000/power-htm-ppr.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-htm-ppr.xml +@@ -0,0 +1,12 @@ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power-htm-spr.xml b/gdb/features/rs6000/power-htm-spr.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-htm-spr.xml +@@ -0,0 +1,14 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power-htm-tar.xml b/gdb/features/rs6000/power-htm-tar.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-htm-tar.xml +@@ -0,0 +1,12 @@ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power-htm-vsx.xml b/gdb/features/rs6000/power-htm-vsx.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power-htm-vsx.xml +@@ -0,0 +1,43 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/power64-htm-core.xml b/gdb/features/rs6000/power64-htm-core.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/power64-htm-core.xml +@@ -0,0 +1,48 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c +@@ -0,0 +1,396 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: powerpc-isa207-htm-vsx32l.xml */ ++ ++#include "defs.h" ++#include "osabi.h" ++#include "target-descriptions.h" ++ ++struct target_desc *tdesc_powerpc_isa207_htm_vsx32l; ++static void ++initialize_tdesc_powerpc_isa207_htm_vsx32l (void) ++{ ++ struct target_desc *result = allocate_target_description (); ++ set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common")); ++ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.core"); ++ tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r16", 16, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r17", 17, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r18", 18, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r19", 19, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r20", 20, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r21", 21, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r22", 22, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r23", 23, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r24", 24, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r25", 25, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r26", 26, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r27", 27, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r28", 28, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r29", 29, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r30", 30, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "r31", 31, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "pc", 64, 1, NULL, 32, "code_ptr"); ++ tdesc_create_reg (feature, "msr", 65, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr", 66, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "lr", 67, 1, NULL, 32, "code_ptr"); ++ tdesc_create_reg (feature, "ctr", 68, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "xer", 69, 1, NULL, 32, "uint32"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.fpu"); ++ tdesc_create_reg (feature, "f0", 32, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f1", 33, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f2", 34, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f3", 35, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f4", 36, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f5", 37, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f6", 38, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f7", 39, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f8", 40, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f9", 41, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f10", 42, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f11", 43, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f12", 44, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f13", 45, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f14", 46, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f15", 47, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f16", 48, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f17", 49, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f18", 50, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f19", 51, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f20", 52, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f21", 53, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f22", 54, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f23", 55, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f24", 56, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f25", 57, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f26", 58, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f27", 59, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f28", 60, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f29", 61, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f30", 62, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f31", 63, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "fpscr", 70, 1, "float", 64, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux"); ++ tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 32, "int"); ++ tdesc_create_reg (feature, "trap", 72, 1, NULL, 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.altivec"); ++ tdesc_type *element_type; ++ element_type = tdesc_named_type (feature, "ieee_single"); ++ tdesc_create_vector (feature, "v4f", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int32"); ++ tdesc_create_vector (feature, "v4i32", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int16"); ++ tdesc_create_vector (feature, "v8i16", element_type, 8); ++ ++ element_type = tdesc_named_type (feature, "int8"); ++ tdesc_create_vector (feature, "v16i8", element_type, 16); ++ ++ tdesc_type_with_fields *type_with_fields; ++ type_with_fields = tdesc_create_union (feature, "vec128"); ++ tdesc_type *field_type; ++ field_type = tdesc_named_type (feature, "uint128"); ++ tdesc_add_field (type_with_fields, "uint128", field_type); ++ field_type = tdesc_named_type (feature, "v4f"); ++ tdesc_add_field (type_with_fields, "v4_float", field_type); ++ field_type = tdesc_named_type (feature, "v4i32"); ++ tdesc_add_field (type_with_fields, "v4_int32", field_type); ++ field_type = tdesc_named_type (feature, "v8i16"); ++ tdesc_add_field (type_with_fields, "v8_int16", field_type); ++ field_type = tdesc_named_type (feature, "v16i8"); ++ tdesc_add_field (type_with_fields, "v16_int8", field_type); ++ ++ tdesc_create_reg (feature, "vr0", 73, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr1", 74, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr2", 75, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr3", 76, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr4", 77, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr5", 78, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr6", 79, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr7", 80, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr8", 81, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr9", 82, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr10", 83, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr11", 84, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr12", 85, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr13", 86, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr14", 87, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr15", 88, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr16", 89, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr17", 90, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr18", 91, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr19", 92, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr20", 93, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr21", 94, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr22", 95, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr23", 96, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr24", 97, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr25", 98, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr26", 99, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr27", 100, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr28", 101, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr29", 102, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr30", 103, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr31", 104, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int"); ++ tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.vsx"); ++ tdesc_create_reg (feature, "vs0h", 107, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs1h", 108, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs2h", 109, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs3h", 110, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs4h", 111, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs5h", 112, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs6h", 113, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs7h", 114, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs8h", 115, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs9h", 116, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs10h", 117, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs11h", 118, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs12h", 119, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs13h", 120, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs14h", 121, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs15h", 122, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs16h", 123, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs17h", 124, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs18h", 125, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs19h", 126, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs20h", 127, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs21h", 128, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs22h", 129, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs23h", 130, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs24h", 131, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs25h", 132, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs26h", 133, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs27h", 134, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs28h", 135, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs29h", 136, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ppr"); ++ tdesc_create_reg (feature, "ppr", 139, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.dscr"); ++ tdesc_create_reg (feature, "dscr", 140, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.tar"); ++ tdesc_create_reg (feature, "tar", 141, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ebb"); ++ tdesc_create_reg (feature, "bescr", 142, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "ebbhr", 143, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "ebbrr", 144, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux.pmu"); ++ tdesc_create_reg (feature, "mmcr0", 145, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "mmcr2", 146, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "siar", 147, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "sdar", 148, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "sier", 149, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.spr"); ++ tdesc_create_reg (feature, "tfhar", 150, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "texasr", 151, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "tfiar", 152, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.core"); ++ tdesc_create_reg (feature, "cr0", 153, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr1", 154, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr2", 155, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr3", 156, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr4", 157, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr5", 158, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr6", 159, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr7", 160, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr8", 161, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr9", 162, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr10", 163, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr11", 164, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr12", 165, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr13", 166, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr14", 167, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr15", 168, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr16", 169, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr17", 170, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr18", 171, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr19", 172, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr20", 173, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr21", 174, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr22", 175, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr23", 176, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr24", 177, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr25", 178, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr26", 179, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr27", 180, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr28", 181, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr29", 182, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr30", 183, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cr31", 184, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "ccr", 185, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cxer", 186, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "clr", 187, 0, NULL, 32, "code_ptr"); ++ tdesc_create_reg (feature, "cctr", 188, 0, NULL, 32, "uint32"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.fpu"); ++ tdesc_create_reg (feature, "cf0", 189, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf1", 190, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf2", 191, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf3", 192, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf4", 193, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf5", 194, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf6", 195, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf7", 196, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf8", 197, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf9", 198, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf10", 199, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf11", 200, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf12", 201, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf13", 202, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf14", 203, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf15", 204, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf16", 205, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf17", 206, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf18", 207, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf19", 208, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf20", 209, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf21", 210, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf22", 211, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf23", 212, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf24", 213, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf25", 214, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf26", 215, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf27", 216, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf28", 217, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf29", 218, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf30", 219, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf31", 220, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cfpscr", 221, 0, "float", 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.altivec"); ++ element_type = tdesc_named_type (feature, "ieee_single"); ++ tdesc_create_vector (feature, "v4f", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int32"); ++ tdesc_create_vector (feature, "v4i32", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int16"); ++ tdesc_create_vector (feature, "v8i16", element_type, 8); ++ ++ element_type = tdesc_named_type (feature, "int8"); ++ tdesc_create_vector (feature, "v16i8", element_type, 16); ++ ++ type_with_fields = tdesc_create_union (feature, "vec128"); ++ field_type = tdesc_named_type (feature, "uint128"); ++ tdesc_add_field (type_with_fields, "uint128", field_type); ++ field_type = tdesc_named_type (feature, "v4f"); ++ tdesc_add_field (type_with_fields, "v4_float", field_type); ++ field_type = tdesc_named_type (feature, "v4i32"); ++ tdesc_add_field (type_with_fields, "v4_int32", field_type); ++ field_type = tdesc_named_type (feature, "v8i16"); ++ tdesc_add_field (type_with_fields, "v8_int16", field_type); ++ field_type = tdesc_named_type (feature, "v16i8"); ++ tdesc_add_field (type_with_fields, "v16_int8", field_type); ++ ++ tdesc_create_reg (feature, "cvr0", 222, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr1", 223, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr2", 224, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr3", 225, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr4", 226, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr5", 227, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr6", 228, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr7", 229, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr8", 230, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr9", 231, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr10", 232, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr11", 233, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr12", 234, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr13", 235, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr14", 236, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr15", 237, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr16", 238, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr17", 239, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr18", 240, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr19", 241, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr20", 242, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr21", 243, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr22", 244, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr23", 245, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr24", 246, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr25", 247, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr26", 248, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr27", 249, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr28", 250, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr29", 251, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr30", 252, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr31", 253, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvscr", 254, 0, "vector", 32, "int"); ++ tdesc_create_reg (feature, "cvrsave", 255, 0, "vector", 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.vsx"); ++ tdesc_create_reg (feature, "cvs0h", 256, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs1h", 257, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs2h", 258, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs3h", 259, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs4h", 260, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs5h", 261, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs6h", 262, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs7h", 263, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs8h", 264, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs9h", 265, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs10h", 266, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs11h", 267, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs12h", 268, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs13h", 269, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs14h", 270, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs15h", 271, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs16h", 272, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs17h", 273, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs18h", 274, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs19h", 275, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs20h", 276, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs21h", 277, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs22h", 278, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs23h", 279, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs24h", 280, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs25h", 281, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs26h", 282, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs27h", 283, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs28h", 284, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs29h", 285, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs30h", 286, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs31h", 287, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.ppr"); ++ tdesc_create_reg (feature, "cppr", 288, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.dscr"); ++ tdesc_create_reg (feature, "cdscr", 289, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.tar"); ++ tdesc_create_reg (feature, "ctar", 290, 0, NULL, 64, "uint64"); ++ ++ tdesc_powerpc_isa207_htm_vsx32l = result; ++} +diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.xml b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.xml +@@ -0,0 +1,29 @@ ++ ++ ++ ++ ++ ++ powerpc:common ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c +@@ -0,0 +1,396 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: powerpc-isa207-htm-vsx64l.xml */ ++ ++#include "defs.h" ++#include "osabi.h" ++#include "target-descriptions.h" ++ ++struct target_desc *tdesc_powerpc_isa207_htm_vsx64l; ++static void ++initialize_tdesc_powerpc_isa207_htm_vsx64l (void) ++{ ++ struct target_desc *result = allocate_target_description (); ++ set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64")); ++ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.core"); ++ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r3", 3, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r4", 4, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r5", 5, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r6", 6, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r7", 7, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r8", 8, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r9", 9, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r10", 10, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r11", 11, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r12", 12, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r13", 13, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r14", 14, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r15", 15, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r16", 16, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r17", 17, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r18", 18, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r19", 19, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r20", 20, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r21", 21, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r22", 22, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r23", 23, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r24", 24, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r25", 25, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r26", 26, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r27", 27, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r28", 28, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r29", 29, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r30", 30, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "r31", 31, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "pc", 64, 1, NULL, 64, "code_ptr"); ++ tdesc_create_reg (feature, "msr", 65, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr", 66, 1, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "lr", 67, 1, NULL, 64, "code_ptr"); ++ tdesc_create_reg (feature, "ctr", 68, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "xer", 69, 1, NULL, 32, "uint32"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.fpu"); ++ tdesc_create_reg (feature, "f0", 32, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f1", 33, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f2", 34, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f3", 35, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f4", 36, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f5", 37, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f6", 38, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f7", 39, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f8", 40, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f9", 41, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f10", 42, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f11", 43, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f12", 44, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f13", 45, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f14", 46, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f15", 47, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f16", 48, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f17", 49, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f18", 50, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f19", 51, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f20", 52, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f21", 53, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f22", 54, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f23", 55, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f24", 56, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f25", 57, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f26", 58, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f27", 59, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f28", 60, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f29", 61, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f30", 62, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f31", 63, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "fpscr", 70, 1, "float", 64, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux"); ++ tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "trap", 72, 1, NULL, 64, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.altivec"); ++ tdesc_type *element_type; ++ element_type = tdesc_named_type (feature, "ieee_single"); ++ tdesc_create_vector (feature, "v4f", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int32"); ++ tdesc_create_vector (feature, "v4i32", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int16"); ++ tdesc_create_vector (feature, "v8i16", element_type, 8); ++ ++ element_type = tdesc_named_type (feature, "int8"); ++ tdesc_create_vector (feature, "v16i8", element_type, 16); ++ ++ tdesc_type_with_fields *type_with_fields; ++ type_with_fields = tdesc_create_union (feature, "vec128"); ++ tdesc_type *field_type; ++ field_type = tdesc_named_type (feature, "uint128"); ++ tdesc_add_field (type_with_fields, "uint128", field_type); ++ field_type = tdesc_named_type (feature, "v4f"); ++ tdesc_add_field (type_with_fields, "v4_float", field_type); ++ field_type = tdesc_named_type (feature, "v4i32"); ++ tdesc_add_field (type_with_fields, "v4_int32", field_type); ++ field_type = tdesc_named_type (feature, "v8i16"); ++ tdesc_add_field (type_with_fields, "v8_int16", field_type); ++ field_type = tdesc_named_type (feature, "v16i8"); ++ tdesc_add_field (type_with_fields, "v16_int8", field_type); ++ ++ tdesc_create_reg (feature, "vr0", 73, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr1", 74, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr2", 75, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr3", 76, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr4", 77, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr5", 78, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr6", 79, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr7", 80, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr8", 81, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr9", 82, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr10", 83, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr11", 84, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr12", 85, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr13", 86, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr14", 87, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr15", 88, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr16", 89, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr17", 90, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr18", 91, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr19", 92, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr20", 93, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr21", 94, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr22", 95, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr23", 96, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr24", 97, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr25", 98, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr26", 99, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr27", 100, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr28", 101, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr29", 102, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr30", 103, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vr31", 104, 1, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int"); ++ tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.vsx"); ++ tdesc_create_reg (feature, "vs0h", 107, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs1h", 108, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs2h", 109, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs3h", 110, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs4h", 111, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs5h", 112, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs6h", 113, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs7h", 114, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs8h", 115, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs9h", 116, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs10h", 117, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs11h", 118, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs12h", 119, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs13h", 120, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs14h", 121, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs15h", 122, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs16h", 123, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs17h", 124, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs18h", 125, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs19h", 126, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs20h", 127, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs21h", 128, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs22h", 129, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs23h", 130, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs24h", 131, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs25h", 132, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs26h", 133, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs27h", 134, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs28h", 135, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs29h", 136, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ppr"); ++ tdesc_create_reg (feature, "ppr", 139, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.dscr"); ++ tdesc_create_reg (feature, "dscr", 140, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.tar"); ++ tdesc_create_reg (feature, "tar", 141, 1, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.ebb"); ++ tdesc_create_reg (feature, "bescr", 142, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "ebbhr", 143, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "ebbrr", 144, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.linux.pmu"); ++ tdesc_create_reg (feature, "mmcr0", 145, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "mmcr2", 146, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "siar", 147, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "sdar", 148, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "sier", 149, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.spr"); ++ tdesc_create_reg (feature, "tfhar", 150, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "texasr", 151, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "tfiar", 152, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.core"); ++ tdesc_create_reg (feature, "cr0", 153, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr1", 154, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr2", 155, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr3", 156, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr4", 157, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr5", 158, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr6", 159, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr7", 160, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr8", 161, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr9", 162, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr10", 163, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr11", 164, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr12", 165, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr13", 166, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr14", 167, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr15", 168, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr16", 169, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr17", 170, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr18", 171, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr19", 172, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr20", 173, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr21", 174, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr22", 175, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr23", 176, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr24", 177, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr25", 178, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr26", 179, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr27", 180, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr28", 181, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr29", 182, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr30", 183, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cr31", 184, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "ccr", 185, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "cxer", 186, 0, NULL, 32, "uint32"); ++ tdesc_create_reg (feature, "clr", 187, 0, NULL, 64, "code_ptr"); ++ tdesc_create_reg (feature, "cctr", 188, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.fpu"); ++ tdesc_create_reg (feature, "cf0", 189, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf1", 190, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf2", 191, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf3", 192, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf4", 193, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf5", 194, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf6", 195, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf7", 196, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf8", 197, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf9", 198, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf10", 199, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf11", 200, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf12", 201, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf13", 202, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf14", 203, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf15", 204, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf16", 205, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf17", 206, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf18", 207, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf19", 208, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf20", 209, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf21", 210, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf22", 211, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf23", 212, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf24", 213, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf25", 214, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf26", 215, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf27", 216, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf28", 217, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf29", 218, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf30", 219, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cf31", 220, 0, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "cfpscr", 221, 0, "float", 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.altivec"); ++ element_type = tdesc_named_type (feature, "ieee_single"); ++ tdesc_create_vector (feature, "v4f", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int32"); ++ tdesc_create_vector (feature, "v4i32", element_type, 4); ++ ++ element_type = tdesc_named_type (feature, "int16"); ++ tdesc_create_vector (feature, "v8i16", element_type, 8); ++ ++ element_type = tdesc_named_type (feature, "int8"); ++ tdesc_create_vector (feature, "v16i8", element_type, 16); ++ ++ type_with_fields = tdesc_create_union (feature, "vec128"); ++ field_type = tdesc_named_type (feature, "uint128"); ++ tdesc_add_field (type_with_fields, "uint128", field_type); ++ field_type = tdesc_named_type (feature, "v4f"); ++ tdesc_add_field (type_with_fields, "v4_float", field_type); ++ field_type = tdesc_named_type (feature, "v4i32"); ++ tdesc_add_field (type_with_fields, "v4_int32", field_type); ++ field_type = tdesc_named_type (feature, "v8i16"); ++ tdesc_add_field (type_with_fields, "v8_int16", field_type); ++ field_type = tdesc_named_type (feature, "v16i8"); ++ tdesc_add_field (type_with_fields, "v16_int8", field_type); ++ ++ tdesc_create_reg (feature, "cvr0", 222, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr1", 223, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr2", 224, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr3", 225, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr4", 226, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr5", 227, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr6", 228, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr7", 229, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr8", 230, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr9", 231, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr10", 232, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr11", 233, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr12", 234, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr13", 235, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr14", 236, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr15", 237, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr16", 238, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr17", 239, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr18", 240, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr19", 241, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr20", 242, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr21", 243, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr22", 244, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr23", 245, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr24", 246, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr25", 247, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr26", 248, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr27", 249, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr28", 250, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr29", 251, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr30", 252, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvr31", 253, 0, NULL, 128, "vec128"); ++ tdesc_create_reg (feature, "cvscr", 254, 0, "vector", 32, "int"); ++ tdesc_create_reg (feature, "cvrsave", 255, 0, "vector", 32, "int"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.vsx"); ++ tdesc_create_reg (feature, "cvs0h", 256, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs1h", 257, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs2h", 258, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs3h", 259, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs4h", 260, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs5h", 261, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs6h", 262, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs7h", 263, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs8h", 264, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs9h", 265, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs10h", 266, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs11h", 267, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs12h", 268, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs13h", 269, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs14h", 270, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs15h", 271, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs16h", 272, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs17h", 273, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs18h", 274, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs19h", 275, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs20h", 276, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs21h", 277, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs22h", 278, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs23h", 279, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs24h", 280, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs25h", 281, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs26h", 282, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs27h", 283, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs28h", 284, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs29h", 285, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs30h", 286, 0, NULL, 64, "uint64"); ++ tdesc_create_reg (feature, "cvs31h", 287, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.ppr"); ++ tdesc_create_reg (feature, "cppr", 288, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.dscr"); ++ tdesc_create_reg (feature, "cdscr", 289, 0, NULL, 64, "uint64"); ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.power.htm.tar"); ++ tdesc_create_reg (feature, "ctar", 290, 0, NULL, 64, "uint64"); ++ ++ tdesc_powerpc_isa207_htm_vsx64l = result; ++} +diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.xml b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.xml +new file mode 100644 +--- /dev/null ++++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.xml +@@ -0,0 +1,29 @@ ++ ++ ++ ++ ++ ++ powerpc:common64 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv +--- a/gdb/gdbserver/configure.srv ++++ b/gdb/gdbserver/configure.srv +@@ -32,7 +32,7 @@ else + srv_amd64_linux_regobj="" + fi + +-ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-isa205-ppr-dscr-vsx32l-ipa.o powerpc-isa207-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o powerpc-isa205-ppr-dscr-vsx64l-ipa.o powerpc-isa207-vsx64l-ipa.o" ++ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-isa205-ppr-dscr-vsx32l-ipa.o powerpc-isa207-vsx32l-ipa.o powerpc-isa207-htm-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o powerpc-isa205-ppr-dscr-vsx64l-ipa.o powerpc-isa207-vsx64l-ipa.o powerpc-isa207-htm-vsx64l-ipa.o" + + # Linux object files. This is so we don't have to repeat + # these files over and over again. +@@ -219,6 +219,7 @@ case "${target}" in + srv_regobj="${srv_regobj} powerpc-isa205-vsx32l.o" + srv_regobj="${srv_regobj} powerpc-isa205-ppr-dscr-vsx32l.o" + srv_regobj="${srv_regobj} powerpc-isa207-vsx32l.o" ++ srv_regobj="${srv_regobj} powerpc-isa207-htm-vsx32l.o" + srv_regobj="${srv_regobj} powerpc-e500l.o" + srv_regobj="${srv_regobj} powerpc-64l.o" + srv_regobj="${srv_regobj} powerpc-altivec64l.o" +@@ -229,6 +230,7 @@ case "${target}" in + srv_regobj="${srv_regobj} powerpc-isa205-vsx64l.o" + srv_regobj="${srv_regobj} powerpc-isa205-ppr-dscr-vsx64l.o" + srv_regobj="${srv_regobj} powerpc-isa207-vsx64l.o" ++ srv_regobj="${srv_regobj} powerpc-isa207-htm-vsx64l.o" + srv_tgtobj="$srv_linux_obj linux-ppc-low.o ppc-linux.o" + srv_tgtobj="${srv_tgtobj} arch/ppc-linux-common.o" + srv_xmlfiles="rs6000/powerpc-32l.xml" +@@ -240,6 +242,7 @@ case "${target}" in + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa207-vsx32l.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa207-htm-vsx32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-altivec.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-vsx.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-core.xml" +@@ -251,6 +254,14 @@ case "${target}" in + srv_xmlfiles="${srv_xmlfiles} rs6000/power-tar.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-ebb.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-linux-pmu.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-htm-spr.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-htm-core.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-htm-fpu.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-htm-altivec.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-htm-vsx.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-htm-ppr.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-htm-dscr.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power-htm-tar.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-e500l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-spe.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-64l.xml" +@@ -262,8 +273,10 @@ case "${target}" in + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa207-vsx64l.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa207-htm-vsx64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power64-core.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power64-linux.xml" ++ srv_xmlfiles="${srv_xmlfiles} rs6000/power64-htm-core.xml" + srv_linux_usrregs=yes + srv_linux_regsets=yes + srv_linux_thread_db=yes +diff --git a/gdb/gdbserver/linux-ppc-ipa.c b/gdb/gdbserver/linux-ppc-ipa.c +--- a/gdb/gdbserver/linux-ppc-ipa.c ++++ b/gdb/gdbserver/linux-ppc-ipa.c +@@ -195,6 +195,8 @@ get_ipa_tdesc (int idx) + return tdesc_powerpc_isa205_ppr_dscr_vsx64l; + case PPC_TDESC_ISA207_VSX: + return tdesc_powerpc_isa207_vsx64l; ++ case PPC_TDESC_ISA207_HTM_VSX: ++ return tdesc_powerpc_isa207_htm_vsx64l; + #else + case PPC_TDESC_BASE: + return tdesc_powerpc_32l; +@@ -214,6 +216,8 @@ get_ipa_tdesc (int idx) + return tdesc_powerpc_isa205_ppr_dscr_vsx32l; + case PPC_TDESC_ISA207_VSX: + return tdesc_powerpc_isa207_vsx32l; ++ case PPC_TDESC_ISA207_HTM_VSX: ++ return tdesc_powerpc_isa207_htm_vsx32l; + case PPC_TDESC_E500: + return tdesc_powerpc_e500l; + #endif +@@ -244,6 +248,7 @@ initialize_low_tracepoint (void) + init_registers_powerpc_isa205_vsx64l (); + init_registers_powerpc_isa205_ppr_dscr_vsx64l (); + init_registers_powerpc_isa207_vsx64l (); ++ init_registers_powerpc_isa207_htm_vsx64l (); + #else + init_registers_powerpc_32l (); + init_registers_powerpc_altivec32l (); +@@ -254,6 +259,7 @@ initialize_low_tracepoint (void) + init_registers_powerpc_isa205_vsx32l (); + init_registers_powerpc_isa205_ppr_dscr_vsx32l (); + init_registers_powerpc_isa207_vsx32l (); ++ init_registers_powerpc_isa207_htm_vsx32l (); + init_registers_powerpc_e500l (); + #endif + } +diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c +--- a/gdb/gdbserver/linux-ppc-low.c ++++ b/gdb/gdbserver/linux-ppc-low.c +@@ -600,6 +600,158 @@ ppc_store_pmuregset (struct regcache *regcache, const void *buf) + supply_register_by_name (regcache, "mmcr0", ®set[32]); + } + ++/* Hardware Transactional Memory special-purpose register regset fill ++ function. */ ++ ++static void ++ppc_fill_tm_sprregset (struct regcache *regcache, void *buf) ++{ ++ int i, base; ++ char *regset = (char *) buf; ++ ++ base = find_regno (regcache->tdesc, "tfhar"); ++ for (i = 0; i < 3; i++) ++ collect_register (regcache, base + i, ®set[i * 8]); ++} ++ ++/* Hardware Transactional Memory special-purpose register regset store ++ function. */ ++ ++static void ++ppc_store_tm_sprregset (struct regcache *regcache, const void *buf) ++{ ++ int i, base; ++ const char *regset = (const char *) buf; ++ ++ base = find_regno (regcache->tdesc, "tfhar"); ++ for (i = 0; i < 3; i++) ++ supply_register (regcache, base + i, ®set[i * 8]); ++} ++ ++/* For the same reasons as the EBB regset, none of the HTM ++ checkpointed regsets have a fill function. These registers are ++ only available if the inferior is in a transaction. */ ++ ++/* Hardware Transactional Memory checkpointed general-purpose regset ++ store function. */ ++ ++static void ++ppc_store_tm_cgprregset (struct regcache *regcache, const void *buf) ++{ ++ int i, base, size, endian_offset; ++ const char *regset = (const char *) buf; ++ ++ base = find_regno (regcache->tdesc, "cr0"); ++ size = register_size (regcache->tdesc, base); ++ ++ gdb_assert (size == 4 || size == 8); ++ ++ for (i = 0; i < 32; i++) ++ supply_register (regcache, base + i, ®set[i * size]); ++ ++ endian_offset = 0; ++ ++ if ((size == 8) && (__BYTE_ORDER == __BIG_ENDIAN)) ++ endian_offset = 4; ++ ++ supply_register_by_name (regcache, "ccr", ++ ®set[PT_CCR * size + endian_offset]); ++ ++ supply_register_by_name (regcache, "cxer", ++ ®set[PT_XER * size + endian_offset]); ++ ++ supply_register_by_name (regcache, "clr", ®set[PT_LNK * size]); ++ supply_register_by_name (regcache, "cctr", ®set[PT_CTR * size]); ++} ++ ++/* Hardware Transactional Memory checkpointed floating-point regset ++ store function. */ ++ ++static void ++ppc_store_tm_cfprregset (struct regcache *regcache, const void *buf) ++{ ++ int i, base; ++ const char *regset = (const char *) buf; ++ ++ base = find_regno (regcache->tdesc, "cf0"); ++ ++ for (i = 0; i < 32; i++) ++ supply_register (regcache, base + i, ®set[i * 8]); ++ ++ supply_register_by_name (regcache, "cfpscr", ®set[32 * 8]); ++} ++ ++/* Hardware Transactional Memory checkpointed vector regset store ++ function. */ ++ ++static void ++ppc_store_tm_cvrregset (struct regcache *regcache, const void *buf) ++{ ++ int i, base; ++ const char *regset = (const char *) buf; ++ int vscr_offset = 0; ++ ++ base = find_regno (regcache->tdesc, "cvr0"); ++ ++ for (i = 0; i < 32; i++) ++ supply_register (regcache, base + i, ®set[i * 16]); ++ ++ if (__BYTE_ORDER == __BIG_ENDIAN) ++ vscr_offset = 12; ++ ++ supply_register_by_name (regcache, "cvscr", ++ ®set[32 * 16 + vscr_offset]); ++ ++ supply_register_by_name (regcache, "cvrsave", ®set[33 * 16]); ++} ++ ++/* Hardware Transactional Memory checkpointed vector-scalar regset ++ store function. */ ++ ++static void ++ppc_store_tm_cvsxregset (struct regcache *regcache, const void *buf) ++{ ++ int i, base; ++ const char *regset = (const char *) buf; ++ ++ base = find_regno (regcache->tdesc, "cvs0h"); ++ for (i = 0; i < 32; i++) ++ supply_register (regcache, base + i, ®set[i * 8]); ++} ++ ++/* Hardware Transactional Memory checkpointed Program Priority ++ Register regset store function. */ ++ ++static void ++ppc_store_tm_cpprregset (struct regcache *regcache, const void *buf) ++{ ++ const char *cppr = (const char *) buf; ++ ++ supply_register_by_name (regcache, "cppr", cppr); ++} ++ ++/* Hardware Transactional Memory checkpointed Data Stream Control ++ Register regset store function. */ ++ ++static void ++ppc_store_tm_cdscrregset (struct regcache *regcache, const void *buf) ++{ ++ const char *cdscr = (const char *) buf; ++ ++ supply_register_by_name (regcache, "cdscr", cdscr); ++} ++ ++/* Hardware Transactional Memory checkpointed Target Address Register ++ regset store function. */ ++ ++static void ++ppc_store_tm_ctarregset (struct regcache *regcache, const void *buf) ++{ ++ const char *ctar = (const char *) buf; ++ ++ supply_register_by_name (regcache, "ctar", ctar); ++} ++ + static void + ppc_fill_vsxregset (struct regcache *regcache, void *buf) + { +@@ -709,6 +861,22 @@ static struct regset_info ppc_regsets[] = { + fetch them every time, but still fall back to PTRACE_PEEKUSER for the + general registers. Some kernels support these, but not the newer + PPC_PTRACE_GETREGS. */ ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CTAR, 0, EXTENDED_REGS, ++ NULL, ppc_store_tm_ctarregset }, ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CDSCR, 0, EXTENDED_REGS, ++ NULL, ppc_store_tm_cdscrregset }, ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CPPR, 0, EXTENDED_REGS, ++ NULL, ppc_store_tm_cpprregset }, ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CVSX, 0, EXTENDED_REGS, ++ NULL, ppc_store_tm_cvsxregset }, ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CVMX, 0, EXTENDED_REGS, ++ NULL, ppc_store_tm_cvrregset }, ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CFPR, 0, EXTENDED_REGS, ++ NULL, ppc_store_tm_cfprregset }, ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CGPR, 0, EXTENDED_REGS, ++ NULL, ppc_store_tm_cgprregset }, ++ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_SPR, 0, EXTENDED_REGS, ++ ppc_fill_tm_sprregset, ppc_store_tm_sprregset }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_EBB, 0, EXTENDED_REGS, + NULL, ppc_store_ebbregset }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_PMU, 0, EXTENDED_REGS, +@@ -800,7 +968,13 @@ ppc_arch_setup (void) + PPC_LINUX_SIZEOF_EBBREGSET) + && ppc_check_regset (tid, NT_PPC_PMU, + PPC_LINUX_SIZEOF_PMUREGSET)) +- features.isa207 = true; ++ { ++ features.isa207 = true; ++ if ((ppc_hwcap2 & PPC_FEATURE2_HTM) ++ && ppc_check_regset (tid, NT_PPC_TM_SPR, ++ PPC_LINUX_SIZEOF_TM_SPRREGSET)) ++ features.htm = true; ++ } + } + + if (ppc_hwcap & PPC_FEATURE_CELL) +@@ -870,6 +1044,42 @@ ppc_arch_setup (void) + regset->size = (features.isa207 ? + PPC_LINUX_SIZEOF_PMUREGSET : 0); + break; ++ case NT_PPC_TM_SPR: ++ regset->size = (features.htm ? ++ PPC_LINUX_SIZEOF_TM_SPRREGSET : 0); ++ break; ++ case NT_PPC_TM_CGPR: ++ if (features.wordsize == 4) ++ regset->size = (features.htm ? ++ PPC32_LINUX_SIZEOF_CGPRREGSET : 0); ++ else ++ regset->size = (features.htm ? ++ PPC64_LINUX_SIZEOF_CGPRREGSET : 0); ++ break; ++ case NT_PPC_TM_CFPR: ++ regset->size = (features.htm ? ++ PPC_LINUX_SIZEOF_CFPRREGSET : 0); ++ break; ++ case NT_PPC_TM_CVMX: ++ regset->size = (features.htm ? ++ PPC_LINUX_SIZEOF_CVMXREGSET : 0); ++ break; ++ case NT_PPC_TM_CVSX: ++ regset->size = (features.htm ? ++ PPC_LINUX_SIZEOF_CVSXREGSET : 0); ++ break; ++ case NT_PPC_TM_CPPR: ++ regset->size = (features.htm ? ++ PPC_LINUX_SIZEOF_CPPRREGSET : 0); ++ break; ++ case NT_PPC_TM_CDSCR: ++ regset->size = (features.htm ? ++ PPC_LINUX_SIZEOF_CDSCRREGSET : 0); ++ break; ++ case NT_PPC_TM_CTAR: ++ regset->size = (features.htm ? ++ PPC_LINUX_SIZEOF_CTARREGSET : 0); ++ break; + default: + break; + } +@@ -3253,6 +3463,8 @@ ppc_get_ipa_tdesc_idx (void) + return PPC_TDESC_ISA205_PPR_DSCR_VSX; + if (tdesc == tdesc_powerpc_isa207_vsx64l) + return PPC_TDESC_ISA207_VSX; ++ if (tdesc == tdesc_powerpc_isa207_htm_vsx64l) ++ return PPC_TDESC_ISA207_HTM_VSX; + #endif + + if (tdesc == tdesc_powerpc_32l) +@@ -3273,6 +3485,8 @@ ppc_get_ipa_tdesc_idx (void) + return PPC_TDESC_ISA205_PPR_DSCR_VSX; + if (tdesc == tdesc_powerpc_isa207_vsx32l) + return PPC_TDESC_ISA207_VSX; ++ if (tdesc == tdesc_powerpc_isa207_htm_vsx32l) ++ return PPC_TDESC_ISA207_HTM_VSX; + if (tdesc == tdesc_powerpc_e500l) + return PPC_TDESC_E500; + +@@ -3333,6 +3547,7 @@ initialize_low_arch (void) + init_registers_powerpc_isa205_vsx32l (); + init_registers_powerpc_isa205_ppr_dscr_vsx32l (); + init_registers_powerpc_isa207_vsx32l (); ++ init_registers_powerpc_isa207_htm_vsx32l (); + init_registers_powerpc_e500l (); + #if __powerpc64__ + init_registers_powerpc_64l (); +@@ -3344,6 +3559,7 @@ initialize_low_arch (void) + init_registers_powerpc_isa205_vsx64l (); + init_registers_powerpc_isa205_ppr_dscr_vsx64l (); + init_registers_powerpc_isa207_vsx64l (); ++ init_registers_powerpc_isa207_htm_vsx64l (); + #endif + + initialize_regsets_info (&ppc_regsets_info); +diff --git a/gdb/gdbserver/linux-ppc-tdesc-init.h b/gdb/gdbserver/linux-ppc-tdesc-init.h +--- a/gdb/gdbserver/linux-ppc-tdesc-init.h ++++ b/gdb/gdbserver/linux-ppc-tdesc-init.h +@@ -31,6 +31,7 @@ enum ppc_linux_tdesc { + PPC_TDESC_ISA205_VSX, + PPC_TDESC_ISA205_PPR_DSCR_VSX, + PPC_TDESC_ISA207_VSX, ++ PPC_TDESC_ISA207_HTM_VSX, + PPC_TDESC_E500, + }; + +@@ -63,6 +64,9 @@ void init_registers_powerpc_isa205_ppr_dscr_vsx32l (void); + /* Defined in auto-generated file powerpc-isa207-vsx32l.c. */ + void init_registers_powerpc_isa207_vsx32l (void); + ++/* Defined in auto-generated file powerpc-isa207-htm-vsx32l.c. */ ++void init_registers_powerpc_isa207_htm_vsx32l (void); ++ + /* Defined in auto-generated file powerpc-e500l.c. */ + void init_registers_powerpc_e500l (void); + +@@ -97,4 +101,7 @@ void init_registers_powerpc_isa205_ppr_dscr_vsx64l (void); + /* Defined in auto-generated file powerpc-isa207-vsx64l.c. */ + void init_registers_powerpc_isa207_vsx64l (void); + ++/* Defined in auto-generated file powerpc-isa207-htm-vsx64l.c. */ ++void init_registers_powerpc_isa207_htm_vsx64l (void); ++ + #endif +diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h +--- a/gdb/nat/ppc-linux.h ++++ b/gdb/nat/ppc-linux.h +@@ -63,6 +63,9 @@ + #ifndef PPC_FEATURE2_EBB + #define PPC_FEATURE2_EBB 0x10000000 + #endif ++#ifndef PPC_FEATURE2_HTM ++#define PPC_FEATURE2_HTM 0x40000000 ++#endif + + /* Glibc's headers don't define PTRACE_GETVRREGS so we cannot use a + configure time check. Some older glibc's (for instance 2.2.1) +@@ -119,6 +122,46 @@ + #define NT_PPC_PMU 0x107 + #endif + ++/* TM checkpointed GPR Registers. */ ++#ifndef NT_PPC_TM_CGPR ++#define NT_PPC_TM_CGPR 0x108 ++#endif ++ ++/* TM checkpointed FPR Registers. */ ++#ifndef NT_PPC_TM_CFPR ++#define NT_PPC_TM_CFPR 0x109 ++#endif ++ ++/* TM checkpointed VMX Registers. */ ++#ifndef NT_PPC_TM_CVMX ++#define NT_PPC_TM_CVMX 0x10a ++#endif ++ ++/* TM checkpointed VSX Registers. */ ++#ifndef NT_PPC_TM_CVSX ++#define NT_PPC_TM_CVSX 0x10b ++#endif ++ ++/* TM Special Purpose Registers. */ ++#ifndef NT_PPC_TM_SPR ++#define NT_PPC_TM_SPR 0x10c ++#endif ++ ++/* TM checkpointed Target Address Register. */ ++#ifndef NT_PPC_TM_CTAR ++#define NT_PPC_TM_CTAR 0x10d ++#endif ++ ++/* TM checkpointed Program Priority Register. */ ++#ifndef NT_PPC_TM_CPPR ++#define NT_PPC_TM_CPPR 0x10e ++#endif ++ ++/* TM checkpointed Data Stream Control Register. */ ++#ifndef NT_PPC_TM_CDSCR ++#define NT_PPC_TM_CDSCR 0x10f ++#endif ++ + /* Return the wordsize of the target, either 4 or 8 bytes. */ + int ppc_linux_target_wordsize (int tid); + +diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c +--- a/gdb/ppc-linux-nat.c ++++ b/gdb/ppc-linux-nat.c +@@ -685,6 +685,82 @@ fetch_register (struct regcache *regcache, int tid, int regno) + &ppc32_linux_pmuregset); + return; + } ++ else if (PPC_IS_TMSPR_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_spr); ++ ++ fetch_regset (regcache, tid, NT_PPC_TM_SPR, ++ PPC_LINUX_SIZEOF_TM_SPRREGSET, ++ &ppc32_linux_tm_sprregset); ++ return; ++ } ++ else if (PPC_IS_CKPTGP_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_core); ++ ++ const struct regset *cgprregset = ppc_linux_cgprregset (gdbarch); ++ fetch_regset (regcache, tid, NT_PPC_TM_CGPR, ++ (tdep->wordsize == 4? ++ PPC32_LINUX_SIZEOF_CGPRREGSET ++ : PPC64_LINUX_SIZEOF_CGPRREGSET), ++ cgprregset); ++ return; ++ } ++ else if (PPC_IS_CKPTFP_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_fpu); ++ ++ fetch_regset (regcache, tid, NT_PPC_TM_CFPR, ++ PPC_LINUX_SIZEOF_CFPRREGSET, ++ &ppc32_linux_cfprregset); ++ return; ++ } ++ else if (PPC_IS_CKPTVMX_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_altivec); ++ ++ const struct regset *cvmxregset = ppc_linux_cvmxregset (gdbarch); ++ fetch_regset (regcache, tid, NT_PPC_TM_CVMX, ++ PPC_LINUX_SIZEOF_CVMXREGSET, ++ cvmxregset); ++ return; ++ } ++ else if (PPC_IS_CKPTVSX_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_vsx); ++ ++ fetch_regset (regcache, tid, NT_PPC_TM_CVSX, ++ PPC_LINUX_SIZEOF_CVSXREGSET, ++ &ppc32_linux_cvsxregset); ++ return; ++ } ++ else if (regno == PPC_CPPR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_cppr_regnum != -1); ++ ++ fetch_regset (regcache, tid, NT_PPC_TM_CPPR, ++ PPC_LINUX_SIZEOF_CPPRREGSET, ++ &ppc32_linux_cpprregset); ++ return; ++ } ++ else if (regno == PPC_CDSCR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_cdscr_regnum != -1); ++ ++ fetch_regset (regcache, tid, NT_PPC_TM_CDSCR, ++ PPC_LINUX_SIZEOF_CDSCRREGSET, ++ &ppc32_linux_cdscrregset); ++ return; ++ } ++ else if (regno == PPC_CTAR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_ctar_regnum != -1); ++ ++ fetch_regset (regcache, tid, NT_PPC_TM_CTAR, ++ PPC_LINUX_SIZEOF_CTARREGSET, ++ &ppc32_linux_ctarregset); ++ return; ++ } + + if (regaddr == -1) + { +@@ -901,6 +977,46 @@ fetch_ppc_registers (struct regcache *regcache, int tid) + fetch_regset (regcache, tid, NT_PPC_PMU, + PPC_LINUX_SIZEOF_PMUREGSET, + &ppc32_linux_pmuregset); ++ if (tdep->have_htm_spr) ++ fetch_regset (regcache, tid, NT_PPC_TM_SPR, ++ PPC_LINUX_SIZEOF_TM_SPRREGSET, ++ &ppc32_linux_tm_sprregset); ++ if (tdep->have_htm_core) ++ { ++ const struct regset *cgprregset = ppc_linux_cgprregset (gdbarch); ++ fetch_regset (regcache, tid, NT_PPC_TM_CGPR, ++ (tdep->wordsize == 4? ++ PPC32_LINUX_SIZEOF_CGPRREGSET ++ : PPC64_LINUX_SIZEOF_CGPRREGSET), ++ cgprregset); ++ } ++ if (tdep->have_htm_fpu) ++ fetch_regset (regcache, tid, NT_PPC_TM_CFPR, ++ PPC_LINUX_SIZEOF_CFPRREGSET, ++ &ppc32_linux_cfprregset); ++ if (tdep->have_htm_altivec) ++ { ++ const struct regset *cvmxregset = ppc_linux_cvmxregset (gdbarch); ++ fetch_regset (regcache, tid, NT_PPC_TM_CVMX, ++ PPC_LINUX_SIZEOF_CVMXREGSET, ++ cvmxregset); ++ } ++ if (tdep->have_htm_vsx) ++ fetch_regset (regcache, tid, NT_PPC_TM_CVSX, ++ PPC_LINUX_SIZEOF_CVSXREGSET, ++ &ppc32_linux_cvsxregset); ++ if (tdep->ppc_cppr_regnum != -1) ++ fetch_regset (regcache, tid, NT_PPC_TM_CPPR, ++ PPC_LINUX_SIZEOF_CPPRREGSET, ++ &ppc32_linux_cpprregset); ++ if (tdep->ppc_cdscr_regnum != -1) ++ fetch_regset (regcache, tid, NT_PPC_TM_CDSCR, ++ PPC_LINUX_SIZEOF_CDSCRREGSET, ++ &ppc32_linux_cdscrregset); ++ if (tdep->ppc_ctar_regnum != -1) ++ fetch_regset (regcache, tid, NT_PPC_TM_CTAR, ++ PPC_LINUX_SIZEOF_CTARREGSET, ++ &ppc32_linux_ctarregset); + } + + /* Fetch registers from the child process. Fetch all registers if +@@ -1126,6 +1242,82 @@ store_register (const struct regcache *regcache, int tid, int regno) + &ppc32_linux_pmuregset); + return; + } ++ else if (PPC_IS_TMSPR_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_spr); ++ ++ store_regset (regcache, tid, regno, NT_PPC_TM_SPR, ++ PPC_LINUX_SIZEOF_TM_SPRREGSET, ++ &ppc32_linux_tm_sprregset); ++ return; ++ } ++ else if (PPC_IS_CKPTGP_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_core); ++ ++ const struct regset *cgprregset = ppc_linux_cgprregset (gdbarch); ++ store_regset (regcache, tid, regno, NT_PPC_TM_CGPR, ++ (tdep->wordsize == 4? ++ PPC32_LINUX_SIZEOF_CGPRREGSET ++ : PPC64_LINUX_SIZEOF_CGPRREGSET), ++ cgprregset); ++ return; ++ } ++ else if (PPC_IS_CKPTFP_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_fpu); ++ ++ store_regset (regcache, tid, regno, NT_PPC_TM_CFPR, ++ PPC_LINUX_SIZEOF_CFPRREGSET, ++ &ppc32_linux_cfprregset); ++ return; ++ } ++ else if (PPC_IS_CKPTVMX_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_altivec); ++ ++ const struct regset *cvmxregset = ppc_linux_cvmxregset (gdbarch); ++ store_regset (regcache, tid, regno, NT_PPC_TM_CVMX, ++ PPC_LINUX_SIZEOF_CVMXREGSET, ++ cvmxregset); ++ return; ++ } ++ else if (PPC_IS_CKPTVSX_REGNUM (regno)) ++ { ++ gdb_assert (tdep->have_htm_vsx); ++ ++ store_regset (regcache, tid, regno, NT_PPC_TM_CVSX, ++ PPC_LINUX_SIZEOF_CVSXREGSET, ++ &ppc32_linux_cvsxregset); ++ return; ++ } ++ else if (regno == PPC_CPPR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_cppr_regnum != -1); ++ ++ store_regset (regcache, tid, regno, NT_PPC_TM_CPPR, ++ PPC_LINUX_SIZEOF_CPPRREGSET, ++ &ppc32_linux_cpprregset); ++ return; ++ } ++ else if (regno == PPC_CDSCR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_cdscr_regnum != -1); ++ ++ store_regset (regcache, tid, regno, NT_PPC_TM_CDSCR, ++ PPC_LINUX_SIZEOF_CDSCRREGSET, ++ &ppc32_linux_cdscrregset); ++ return; ++ } ++ else if (regno == PPC_CTAR_REGNUM) ++ { ++ gdb_assert (tdep->ppc_ctar_regnum != -1); ++ ++ store_regset (regcache, tid, regno, NT_PPC_TM_CTAR, ++ PPC_LINUX_SIZEOF_CTARREGSET, ++ &ppc32_linux_ctarregset); ++ return; ++ } + + if (regaddr == -1) + return; +@@ -1358,9 +1550,14 @@ store_ppc_registers (const struct regcache *regcache, int tid) + PPC_LINUX_SIZEOF_PMUREGSET, + &ppc32_linux_pmuregset); + +- /* Because the EBB registers can be unavailable, attempts to store +- them here would cause this function to fail most of the time, so +- we ignore them. */ ++ if (tdep->have_htm_spr) ++ store_regset (regcache, tid, -1, NT_PPC_TM_SPR, ++ PPC_LINUX_SIZEOF_TM_SPRREGSET, ++ &ppc32_linux_tm_sprregset); ++ ++ /* Because the EBB and checkpointed HTM registers can be ++ unavailable, attempts to store them here would cause this ++ function to fail most of the time, so we ignore them. */ + } + + /* Fetch the AT_HWCAP entry from the aux vector. */ +@@ -2496,7 +2693,13 @@ ppc_linux_nat_target::read_description () + && check_regset (tid, NT_PPC_TAR, PPC_LINUX_SIZEOF_TARREGSET) + && check_regset (tid, NT_PPC_EBB, PPC_LINUX_SIZEOF_EBBREGSET) + && check_regset (tid, NT_PPC_PMU, PPC_LINUX_SIZEOF_PMUREGSET)) +- features.isa207 = true; ++ { ++ features.isa207 = true; ++ if ((hwcap2 & PPC_FEATURE2_HTM) ++ && check_regset (tid, NT_PPC_TM_SPR, ++ PPC_LINUX_SIZEOF_TM_SPRREGSET)) ++ features.htm = true; ++ } + } + + return ppc_linux_match_description (features); +diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c +--- a/gdb/ppc-linux-tdep.c ++++ b/gdb/ppc-linux-tdep.c +@@ -73,6 +73,7 @@ + #include "features/rs6000/powerpc-isa205-vsx32l.c" + #include "features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c" + #include "features/rs6000/powerpc-isa207-vsx32l.c" ++#include "features/rs6000/powerpc-isa207-htm-vsx32l.c" + #include "features/rs6000/powerpc-64l.c" + #include "features/rs6000/powerpc-altivec64l.c" + #include "features/rs6000/powerpc-cell64l.c" +@@ -82,6 +83,7 @@ + #include "features/rs6000/powerpc-isa205-vsx64l.c" + #include "features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c" + #include "features/rs6000/powerpc-isa207-vsx64l.c" ++#include "features/rs6000/powerpc-isa207-htm-vsx64l.c" + #include "features/rs6000/powerpc-e500l.c" + + /* Shared library operations for PowerPC-Linux. */ +@@ -637,6 +639,239 @@ const struct regset ppc32_linux_pmuregset = { + regcache_collect_regset + }; + ++/* Hardware Transactional Memory special-purpose register regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_tm_spr[] = ++ { ++ { 1, PPC_TFHAR_REGNUM, 8 }, ++ { 1, PPC_TEXASR_REGNUM, 8 }, ++ { 1, PPC_TFIAR_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Hardware Transactional Memory special-purpose register regset. */ ++ ++const struct regset ppc32_linux_tm_sprregset = { ++ ppc32_regmap_tm_spr, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++/* Regmaps for the Hardware Transactional Memory checkpointed ++ general-purpose regsets for 32-bit, 64-bit big-endian, and 64-bit ++ little endian targets. The ptrace and core file buffers for 64-bit ++ targets use 8-byte fields for the 4-byte registers, and the ++ position of the register in the fields depends on the endianess. ++ The 32-bit regmap is the same for both endian types because the ++ fields are all 4-byte long. ++ ++ The layout of checkpointed GPR regset is the same as a regular ++ struct pt_regs, but we skip all registers that are not actually ++ checkpointed by the processor (e.g. msr, nip), except when ++ generating a core file. The 64-bit regset is 48 * 8 bytes long. ++ In some 64-bit kernels, the regset for a 32-bit inferior has the ++ same length, but all the registers are squeezed in the first half ++ (48 * 4 bytes). The pt_regs struct calls the regular cr ccr, but ++ we use ccr for "checkpointed condition register". Note that CR ++ (condition register) field 0 is not checkpointed, but the kernel ++ returns all 4 bytes. The skipped registers should not be touched ++ when writing the regset to the inferior (with ++ PTRACE_SETREGSET). */ ++ ++static const struct regcache_map_entry ppc32_regmap_cgpr[] = ++ { ++ { 32, PPC_CR0_REGNUM, 4 }, ++ { 3, REGCACHE_MAP_SKIP, 4 }, /* nip, msr, orig_gpr3. */ ++ { 1, PPC_CCTR_REGNUM, 4 }, ++ { 1, PPC_CLR_REGNUM, 4 }, ++ { 1, PPC_CXER_REGNUM, 4 }, ++ { 1, PPC_CCR_REGNUM, 4 }, ++ { 9, REGCACHE_MAP_SKIP, 4 }, /* All the rest. */ ++ { 0 } ++ }; ++ ++static const struct regcache_map_entry ppc64_le_regmap_cgpr[] = ++ { ++ { 32, PPC_CR0_REGNUM, 8 }, ++ { 3, REGCACHE_MAP_SKIP, 8 }, ++ { 1, PPC_CCTR_REGNUM, 8 }, ++ { 1, PPC_CLR_REGNUM, 8 }, ++ { 1, PPC_CXER_REGNUM, 4 }, ++ { 1, REGCACHE_MAP_SKIP, 4 }, /* CXER padding. */ ++ { 1, PPC_CCR_REGNUM, 4 }, ++ { 1, REGCACHE_MAP_SKIP, 4}, /* CCR padding. */ ++ { 9, REGCACHE_MAP_SKIP, 8}, ++ { 0 } ++ }; ++ ++static const struct regcache_map_entry ppc64_be_regmap_cgpr[] = ++ { ++ { 32, PPC_CR0_REGNUM, 8 }, ++ { 3, REGCACHE_MAP_SKIP, 8 }, ++ { 1, PPC_CCTR_REGNUM, 8 }, ++ { 1, PPC_CLR_REGNUM, 8 }, ++ { 1, REGCACHE_MAP_SKIP, 4}, /* CXER padding. */ ++ { 1, PPC_CXER_REGNUM, 4 }, ++ { 1, REGCACHE_MAP_SKIP, 4}, /* CCR padding. */ ++ { 1, PPC_CCR_REGNUM, 4 }, ++ { 9, REGCACHE_MAP_SKIP, 8}, ++ { 0 } ++ }; ++ ++/* Regsets for the Hardware Transactional Memory checkpointed ++ general-purpose registers for 32-bit, 64-bit big-endian, and 64-bit ++ little endian targets. ++ ++ Some 64-bit kernels generate a checkpointed gpr note section with ++ 48*8 bytes for a 32-bit thread, of which only 48*4 are actually ++ used, so we set the variable size flag in the corresponding regset ++ to accept this case. */ ++ ++static const struct regset ppc32_linux_cgprregset = { ++ ppc32_regmap_cgpr, ++ regcache_supply_regset, ++ regcache_collect_regset, ++ REGSET_VARIABLE_SIZE ++}; ++ ++static const struct regset ppc64_be_linux_cgprregset = { ++ ppc64_be_regmap_cgpr, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++static const struct regset ppc64_le_linux_cgprregset = { ++ ppc64_le_regmap_cgpr, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++/* Hardware Transactional Memory checkpointed floating-point regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_cfpr[] = ++ { ++ { 32, PPC_CF0_REGNUM, 8 }, ++ { 1, PPC_CFPSCR_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Hardware Transactional Memory checkpointed floating-point regset. */ ++ ++const struct regset ppc32_linux_cfprregset = { ++ ppc32_regmap_cfpr, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++/* Regmaps for the Hardware Transactional Memory checkpointed vector ++ regsets, for big and little endian targets. The position of the ++ 4-byte VSCR in its 16-byte field depends on the endianess. */ ++ ++static const struct regcache_map_entry ppc32_le_regmap_cvmx[] = ++ { ++ { 32, PPC_CVR0_REGNUM, 16 }, ++ { 1, PPC_CVSCR_REGNUM, 4 }, ++ { 1, REGCACHE_MAP_SKIP, 12 }, ++ { 1, PPC_CVRSAVE_REGNUM, 4 }, ++ { 1, REGCACHE_MAP_SKIP, 12 }, ++ { 0 } ++ }; ++ ++static const struct regcache_map_entry ppc32_be_regmap_cvmx[] = ++ { ++ { 32, PPC_CVR0_REGNUM, 16 }, ++ { 1, REGCACHE_MAP_SKIP, 12 }, ++ { 1, PPC_CVSCR_REGNUM, 4 }, ++ { 1, PPC_CVRSAVE_REGNUM, 4 }, ++ { 1, REGCACHE_MAP_SKIP, 12}, ++ { 0 } ++ }; ++ ++/* Hardware Transactional Memory checkpointed vector regsets, for little ++ and big endian targets. */ ++ ++static const struct regset ppc32_le_linux_cvmxregset = { ++ ppc32_le_regmap_cvmx, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++static const struct regset ppc32_be_linux_cvmxregset = { ++ ppc32_be_regmap_cvmx, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++/* Hardware Transactional Memory checkpointed vector-scalar regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_cvsx[] = ++ { ++ { 32, PPC_CVSR0_UPPER_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Hardware Transactional Memory checkpointed vector-scalar regset. */ ++ ++const struct regset ppc32_linux_cvsxregset = { ++ ppc32_regmap_cvsx, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++/* Hardware Transactional Memory checkpointed Program Priority Register ++ regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_cppr[] = ++ { ++ { 1, PPC_CPPR_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Hardware Transactional Memory checkpointed Program Priority Register ++ regset. */ ++ ++const struct regset ppc32_linux_cpprregset = { ++ ppc32_regmap_cppr, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++/* Hardware Transactional Memory checkpointed Data Stream Control ++ Register regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_cdscr[] = ++ { ++ { 1, PPC_CDSCR_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Hardware Transactional Memory checkpointed Data Stream Control ++ Register regset. */ ++ ++const struct regset ppc32_linux_cdscrregset = { ++ ppc32_regmap_cdscr, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ ++/* Hardware Transactional Memory checkpointed Target Address Register ++ regmap. */ ++ ++static const struct regcache_map_entry ppc32_regmap_ctar[] = ++ { ++ { 1, PPC_CTAR_REGNUM, 8 }, ++ { 0 } ++ }; ++ ++/* Hardware Transactional Memory checkpointed Target Address Register ++ regset. */ ++ ++const struct regset ppc32_linux_ctarregset = { ++ ppc32_regmap_ctar, ++ regcache_supply_regset, ++ regcache_collect_regset ++}; ++ + const struct regset * + ppc_linux_gregset (int wordsize) + { +@@ -664,6 +899,88 @@ ppc_linux_vsxregset (void) + return &ppc32_linux_vsxregset; + } + ++const struct regset * ++ppc_linux_cgprregset (struct gdbarch *gdbarch) ++{ ++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ ++ if (tdep->wordsize == 4) ++ { ++ return &ppc32_linux_cgprregset; ++ } ++ else ++ { ++ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) ++ return &ppc64_be_linux_cgprregset; ++ else ++ return &ppc64_le_linux_cgprregset; ++ } ++} ++ ++const struct regset * ++ppc_linux_cvmxregset (struct gdbarch *gdbarch) ++{ ++ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) ++ return &ppc32_be_linux_cvmxregset; ++ else ++ return &ppc32_le_linux_cvmxregset; ++} ++ ++/* Collect function used to generate the core note for the ++ checkpointed GPR regset. Here, we don't want to skip the ++ "checkpointed" NIP and MSR, so that the note section we generate is ++ similar to the one generated by the kernel. To avoid having to ++ define additional registers in GDB which are not actually ++ checkpointed in the architecture, we copy TFHAR to the checkpointed ++ NIP slot, which is what the kernel does, and copy the regular MSR ++ to the checkpointed MSR slot, which will have a similar value in ++ most cases. */ ++ ++static void ++ppc_linux_collect_core_cpgrregset (const struct regset *regset, ++ const struct regcache *regcache, ++ int regnum, void *buf, size_t len) ++{ ++ struct gdbarch *gdbarch = regcache->arch (); ++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ ++ const struct regset *cgprregset = ppc_linux_cgprregset (gdbarch); ++ ++ /* We collect the checkpointed GPRs already defined in the regular ++ regmap, then overlay TFHAR/MSR on the checkpointed NIP/MSR ++ slots. */ ++ cgprregset->collect_regset (cgprregset, regcache, regnum, buf, len); ++ ++ /* Check that we are collecting all the registers, which should be ++ the case when generating a core file. */ ++ if (regnum != -1) ++ return; ++ ++ /* PT_NIP and PT_MSR are 32 and 33 for powerpc. Don't redefine ++ these symbols since this file can run on clients in other ++ architectures where they can already be defined to other ++ values. */ ++ int pt_offset = 32; ++ ++ /* Check that our buffer is long enough to hold two slots at ++ pt_offset * wordsize, one for NIP and one for MSR. */ ++ gdb_assert ((pt_offset + 2) * tdep->wordsize <= len); ++ ++ /* TFHAR is 8 bytes wide, but the NIP slot for a 32-bit thread is ++ 4-bytes long. We use raw_collect_integer which handles ++ differences in the sizes for the source and destination buffers ++ for both endian modes. */ ++ (regcache->raw_collect_integer ++ (PPC_TFHAR_REGNUM, ((gdb_byte *) buf) + pt_offset * tdep->wordsize, ++ tdep->wordsize, false)); ++ ++ pt_offset = 33; ++ ++ (regcache->raw_collect_integer ++ (PPC_MSR_REGNUM, ((gdb_byte *) buf) + pt_offset * tdep->wordsize, ++ tdep->wordsize, false)); ++} ++ + /* Iterate over supported core file register note sections. */ + + static void +@@ -728,6 +1045,121 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, + PPC_LINUX_SIZEOF_PMUREGSET, + &ppc32_linux_pmuregset, "Performance Monitor Registers", + cb_data); ++ ++ if (tdep->have_htm_spr) ++ cb (".reg-ppc-tm-spr", PPC_LINUX_SIZEOF_TM_SPRREGSET, ++ PPC_LINUX_SIZEOF_TM_SPRREGSET, ++ &ppc32_linux_tm_sprregset, ++ "Hardware Transactional Memory Special Purpose Registers", ++ cb_data); ++ ++ /* Checkpointed registers can be unavailable, don't call back if ++ we are generating a core file. */ ++ ++ if (tdep->have_htm_core) ++ { ++ /* Only generate the checkpointed GPR core note if we also have ++ access to the HTM SPRs, because we need TFHAR to fill the ++ "checkpointed" NIP slot. We can read a core file without it ++ since GDB is not aware of this NIP as a visible register. */ ++ if (regcache == NULL || ++ (REG_VALID == regcache->get_register_status (PPC_CR0_REGNUM) ++ && tdep->have_htm_spr)) ++ { ++ int cgpr_size = (tdep->wordsize == 4? ++ PPC32_LINUX_SIZEOF_CGPRREGSET ++ : PPC64_LINUX_SIZEOF_CGPRREGSET); ++ ++ const struct regset *cgprregset = ++ ppc_linux_cgprregset (gdbarch); ++ ++ if (regcache != NULL) ++ { ++ struct regset core_cgprregset = *cgprregset; ++ ++ core_cgprregset.collect_regset ++ = ppc_linux_collect_core_cpgrregset; ++ ++ cb (".reg-ppc-tm-cgpr", ++ cgpr_size, cgpr_size, ++ &core_cgprregset, ++ "Checkpointed General Purpose Registers", cb_data); ++ } ++ else ++ { ++ cb (".reg-ppc-tm-cgpr", ++ cgpr_size, cgpr_size, ++ cgprregset, ++ "Checkpointed General Purpose Registers", cb_data); ++ } ++ } ++ } ++ ++ if (tdep->have_htm_fpu) ++ { ++ if (regcache == NULL || ++ REG_VALID == regcache->get_register_status (PPC_CF0_REGNUM)) ++ cb (".reg-ppc-tm-cfpr", PPC_LINUX_SIZEOF_CFPRREGSET, ++ PPC_LINUX_SIZEOF_CFPRREGSET, ++ &ppc32_linux_cfprregset, ++ "Checkpointed Floating Point Registers", cb_data); ++ } ++ ++ if (tdep->have_htm_altivec) ++ { ++ if (regcache == NULL || ++ REG_VALID == regcache->get_register_status (PPC_CVR0_REGNUM)) ++ { ++ const struct regset *cvmxregset = ++ ppc_linux_cvmxregset (gdbarch); ++ ++ cb (".reg-ppc-tm-cvmx", PPC_LINUX_SIZEOF_CVMXREGSET, ++ PPC_LINUX_SIZEOF_CVMXREGSET, ++ cvmxregset, ++ "Checkpointed Altivec (VMX) Registers", cb_data); ++ } ++ } ++ ++ if (tdep->have_htm_vsx) ++ { ++ if (regcache == NULL || ++ (REG_VALID ++ == regcache->get_register_status (PPC_CVSR0_UPPER_REGNUM))) ++ cb (".reg-ppc-tm-cvsx", PPC_LINUX_SIZEOF_CVSXREGSET, ++ PPC_LINUX_SIZEOF_CVSXREGSET, ++ &ppc32_linux_cvsxregset, ++ "Checkpointed VSX Registers", cb_data); ++ } ++ ++ if (tdep->ppc_cppr_regnum != -1) ++ { ++ if (regcache == NULL || ++ REG_VALID == regcache->get_register_status (PPC_CPPR_REGNUM)) ++ cb (".reg-ppc-tm-cppr", PPC_LINUX_SIZEOF_CPPRREGSET, ++ PPC_LINUX_SIZEOF_CPPRREGSET, ++ &ppc32_linux_cpprregset, ++ "Checkpointed Priority Program Register", cb_data); ++ } ++ ++ if (tdep->ppc_cdscr_regnum != -1) ++ { ++ if (regcache == NULL || ++ REG_VALID == regcache->get_register_status (PPC_CDSCR_REGNUM)) ++ cb (".reg-ppc-tm-cdscr", PPC_LINUX_SIZEOF_CDSCRREGSET, ++ PPC_LINUX_SIZEOF_CDSCRREGSET, ++ &ppc32_linux_cdscrregset, ++ "Checkpointed Data Stream Control Register", cb_data); ++ } ++ ++ if (tdep->ppc_ctar_regnum) ++ { ++ if ( regcache == NULL || ++ REG_VALID == regcache->get_register_status (PPC_CTAR_REGNUM)) ++ cb (".reg-ppc-tm-ctar", PPC_LINUX_SIZEOF_CTARREGSET, ++ PPC_LINUX_SIZEOF_CTARREGSET, ++ &ppc32_linux_ctarregset, ++ "Checkpointed Target Address Register", cb_data); ++ } + } + + static void +@@ -1144,6 +1576,7 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, + asection *dscr = bfd_get_section_by_name (abfd, ".reg-ppc-dscr"); + asection *tar = bfd_get_section_by_name (abfd, ".reg-ppc-tar"); + asection *pmu = bfd_get_section_by_name (abfd, ".reg-ppc-pmu"); ++ asection *htmspr = bfd_get_section_by_name (abfd, ".reg-ppc-tm-spr"); + + if (! section) + return NULL; +@@ -1185,7 +1618,11 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, + been unavailable when the core file was created. They will + be in the tdep but will show as unavailable. */ + if (tar && pmu) +- features.isa207 = true; ++ { ++ features.isa207 = true; ++ if (htmspr) ++ features.htm = true; ++ } + } + + return ppc_linux_match_description (features); +@@ -2063,6 +2500,7 @@ _initialize_ppc_linux_tdep (void) + initialize_tdesc_powerpc_isa205_vsx32l (); + initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l (); + initialize_tdesc_powerpc_isa207_vsx32l (); ++ initialize_tdesc_powerpc_isa207_htm_vsx32l (); + initialize_tdesc_powerpc_64l (); + initialize_tdesc_powerpc_altivec64l (); + initialize_tdesc_powerpc_cell64l (); +@@ -2072,5 +2510,6 @@ _initialize_ppc_linux_tdep (void) + initialize_tdesc_powerpc_isa205_vsx64l (); + initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l (); + initialize_tdesc_powerpc_isa207_vsx64l (); ++ initialize_tdesc_powerpc_isa207_htm_vsx64l (); + initialize_tdesc_powerpc_e500l (); + } +diff --git a/gdb/ppc-linux-tdep.h b/gdb/ppc-linux-tdep.h +--- a/gdb/ppc-linux-tdep.h ++++ b/gdb/ppc-linux-tdep.h +@@ -32,6 +32,14 @@ const struct regset *ppc_linux_fpregset (void); + const struct regset *ppc_linux_vrregset (struct gdbarch *gdbarch); + const struct regset *ppc_linux_vsxregset (void); + ++/* Get the checkpointed GPR regset that matches the target wordsize ++ and byteorder of GDBARCH. */ ++const struct regset *ppc_linux_cgprregset (struct gdbarch *gdbarch); ++ ++/* Get the checkpointed vector regset that matches the target byte ++ order. */ ++const struct regset* ppc_linux_cvmxregset (struct gdbarch *gdbarch); ++ + /* Extra register number constants. The Linux kernel stores a + "trap" code and the original value of r3 into special "registers"; + these need to be saved and restored when performing an inferior +@@ -50,5 +58,11 @@ extern const struct regset ppc32_linux_dscrregset; + extern const struct regset ppc32_linux_tarregset; + extern const struct regset ppc32_linux_ebbregset; + extern const struct regset ppc32_linux_pmuregset; ++extern const struct regset ppc32_linux_tm_sprregset; ++extern const struct regset ppc32_linux_cfprregset; ++extern const struct regset ppc32_linux_cvsxregset; ++extern const struct regset ppc32_linux_cpprregset; ++extern const struct regset ppc32_linux_cdscrregset; ++extern const struct regset ppc32_linux_ctarregset; + + #endif /* PPC_LINUX_TDEP_H */ +diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h +--- a/gdb/ppc-tdep.h ++++ b/gdb/ppc-tdep.h +@@ -274,6 +274,21 @@ struct gdbarch_tdep + int ppc_sdar_regnum; + int ppc_sier_regnum; + ++ /* Hardware Transactional Memory registers. */ ++ int have_htm_spr; ++ int have_htm_core; ++ int have_htm_fpu; ++ int have_htm_altivec; ++ int have_htm_vsx; ++ int ppc_cppr_regnum; ++ int ppc_cdscr_regnum; ++ int ppc_ctar_regnum; ++ ++ /* HTM pseudo registers. */ ++ int ppc_cdl0_regnum; ++ int ppc_cvsr0_regnum; ++ int ppc_cefpr0_regnum; ++ + /* Offset to ABI specific location where link register is saved. */ + int lr_frame_offset; + +@@ -343,6 +358,29 @@ enum { + PPC_SDAR_REGNUM = 181, + PPC_SIER_REGNUM = 182, + ++ /* Hardware transactional memory registers. */ ++ PPC_TFHAR_REGNUM = 183, ++ PPC_TEXASR_REGNUM = 184, ++ PPC_TFIAR_REGNUM = 185, ++ ++ PPC_CR0_REGNUM = 186, ++ PPC_CCR_REGNUM = 218, ++ PPC_CXER_REGNUM = 219, ++ PPC_CLR_REGNUM = 220, ++ PPC_CCTR_REGNUM = 221, ++ ++ PPC_CF0_REGNUM = 222, ++ PPC_CFPSCR_REGNUM = 254, ++ ++ PPC_CVR0_REGNUM = 255, ++ PPC_CVSCR_REGNUM = 287, ++ PPC_CVRSAVE_REGNUM = 288, ++ ++ PPC_CVSR0_UPPER_REGNUM = 289, ++ ++ PPC_CPPR_REGNUM = 321, ++ PPC_CDSCR_REGNUM = 322, ++ PPC_CTAR_REGNUM = 323, + PPC_NUM_REGS + }; + +@@ -355,6 +393,21 @@ enum { + #define PPC_IS_PMU_REGNUM(i) \ + ((i) >= PPC_MMCR0_REGNUM && (i) <= PPC_SIER_REGNUM) + ++#define PPC_IS_TMSPR_REGNUM(i) \ ++ ((i) >= PPC_TFHAR_REGNUM && (i) <= PPC_TFIAR_REGNUM) ++ ++#define PPC_IS_CKPTGP_REGNUM(i) \ ++ ((i) >= PPC_CR0_REGNUM && (i) <= PPC_CCTR_REGNUM) ++ ++#define PPC_IS_CKPTFP_REGNUM(i) \ ++ ((i) >= PPC_CF0_REGNUM && (i) <= PPC_CFPSCR_REGNUM) ++ ++#define PPC_IS_CKPTVMX_REGNUM(i) \ ++ ((i) >= PPC_CVR0_REGNUM && (i) <= PPC_CVRSAVE_REGNUM) ++ ++#define PPC_IS_CKPTVSX_REGNUM(i) \ ++ ((i) >= PPC_CVSR0_UPPER_REGNUM && (i) < (PPC_CVSR0_UPPER_REGNUM + 32)) ++ + /* An instruction to match. */ + + struct ppc_insn_pattern +diff --git a/gdb/regformats/rs6000/powerpc-isa207-htm-vsx32l.dat b/gdb/regformats/rs6000/powerpc-isa207-htm-vsx32l.dat +new file mode 100644 +--- /dev/null ++++ b/gdb/regformats/rs6000/powerpc-isa207-htm-vsx32l.dat +@@ -0,0 +1,296 @@ ++# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: ++# Generated from: rs6000/powerpc-isa207-htm-vsx32l.xml ++name:powerpc_isa207_htm_vsx32l ++xmltarget:powerpc-isa207-htm-vsx32l.xml ++expedite:r1,pc ++32:r0 ++32:r1 ++32:r2 ++32:r3 ++32:r4 ++32:r5 ++32:r6 ++32:r7 ++32:r8 ++32:r9 ++32:r10 ++32:r11 ++32:r12 ++32:r13 ++32:r14 ++32:r15 ++32:r16 ++32:r17 ++32:r18 ++32:r19 ++32:r20 ++32:r21 ++32:r22 ++32:r23 ++32:r24 ++32:r25 ++32:r26 ++32:r27 ++32:r28 ++32:r29 ++32:r30 ++32:r31 ++64:f0 ++64:f1 ++64:f2 ++64:f3 ++64:f4 ++64:f5 ++64:f6 ++64:f7 ++64:f8 ++64:f9 ++64:f10 ++64:f11 ++64:f12 ++64:f13 ++64:f14 ++64:f15 ++64:f16 ++64:f17 ++64:f18 ++64:f19 ++64:f20 ++64:f21 ++64:f22 ++64:f23 ++64:f24 ++64:f25 ++64:f26 ++64:f27 ++64:f28 ++64:f29 ++64:f30 ++64:f31 ++32:pc ++32:msr ++32:cr ++32:lr ++32:ctr ++32:xer ++64:fpscr ++32:orig_r3 ++32:trap ++128:vr0 ++128:vr1 ++128:vr2 ++128:vr3 ++128:vr4 ++128:vr5 ++128:vr6 ++128:vr7 ++128:vr8 ++128:vr9 ++128:vr10 ++128:vr11 ++128:vr12 ++128:vr13 ++128:vr14 ++128:vr15 ++128:vr16 ++128:vr17 ++128:vr18 ++128:vr19 ++128:vr20 ++128:vr21 ++128:vr22 ++128:vr23 ++128:vr24 ++128:vr25 ++128:vr26 ++128:vr27 ++128:vr28 ++128:vr29 ++128:vr30 ++128:vr31 ++32:vscr ++32:vrsave ++64:vs0h ++64:vs1h ++64:vs2h ++64:vs3h ++64:vs4h ++64:vs5h ++64:vs6h ++64:vs7h ++64:vs8h ++64:vs9h ++64:vs10h ++64:vs11h ++64:vs12h ++64:vs13h ++64:vs14h ++64:vs15h ++64:vs16h ++64:vs17h ++64:vs18h ++64:vs19h ++64:vs20h ++64:vs21h ++64:vs22h ++64:vs23h ++64:vs24h ++64:vs25h ++64:vs26h ++64:vs27h ++64:vs28h ++64:vs29h ++64:vs30h ++64:vs31h ++64:ppr ++64:dscr ++64:tar ++64:bescr ++64:ebbhr ++64:ebbrr ++64:mmcr0 ++64:mmcr2 ++64:siar ++64:sdar ++64:sier ++64:tfhar ++64:texasr ++64:tfiar ++32:cr0 ++32:cr1 ++32:cr2 ++32:cr3 ++32:cr4 ++32:cr5 ++32:cr6 ++32:cr7 ++32:cr8 ++32:cr9 ++32:cr10 ++32:cr11 ++32:cr12 ++32:cr13 ++32:cr14 ++32:cr15 ++32:cr16 ++32:cr17 ++32:cr18 ++32:cr19 ++32:cr20 ++32:cr21 ++32:cr22 ++32:cr23 ++32:cr24 ++32:cr25 ++32:cr26 ++32:cr27 ++32:cr28 ++32:cr29 ++32:cr30 ++32:cr31 ++32:ccr ++32:cxer ++32:clr ++32:cctr ++64:cf0 ++64:cf1 ++64:cf2 ++64:cf3 ++64:cf4 ++64:cf5 ++64:cf6 ++64:cf7 ++64:cf8 ++64:cf9 ++64:cf10 ++64:cf11 ++64:cf12 ++64:cf13 ++64:cf14 ++64:cf15 ++64:cf16 ++64:cf17 ++64:cf18 ++64:cf19 ++64:cf20 ++64:cf21 ++64:cf22 ++64:cf23 ++64:cf24 ++64:cf25 ++64:cf26 ++64:cf27 ++64:cf28 ++64:cf29 ++64:cf30 ++64:cf31 ++64:cfpscr ++128:cvr0 ++128:cvr1 ++128:cvr2 ++128:cvr3 ++128:cvr4 ++128:cvr5 ++128:cvr6 ++128:cvr7 ++128:cvr8 ++128:cvr9 ++128:cvr10 ++128:cvr11 ++128:cvr12 ++128:cvr13 ++128:cvr14 ++128:cvr15 ++128:cvr16 ++128:cvr17 ++128:cvr18 ++128:cvr19 ++128:cvr20 ++128:cvr21 ++128:cvr22 ++128:cvr23 ++128:cvr24 ++128:cvr25 ++128:cvr26 ++128:cvr27 ++128:cvr28 ++128:cvr29 ++128:cvr30 ++128:cvr31 ++32:cvscr ++32:cvrsave ++64:cvs0h ++64:cvs1h ++64:cvs2h ++64:cvs3h ++64:cvs4h ++64:cvs5h ++64:cvs6h ++64:cvs7h ++64:cvs8h ++64:cvs9h ++64:cvs10h ++64:cvs11h ++64:cvs12h ++64:cvs13h ++64:cvs14h ++64:cvs15h ++64:cvs16h ++64:cvs17h ++64:cvs18h ++64:cvs19h ++64:cvs20h ++64:cvs21h ++64:cvs22h ++64:cvs23h ++64:cvs24h ++64:cvs25h ++64:cvs26h ++64:cvs27h ++64:cvs28h ++64:cvs29h ++64:cvs30h ++64:cvs31h ++64:cppr ++64:cdscr ++64:ctar +diff --git a/gdb/regformats/rs6000/powerpc-isa207-htm-vsx64l.dat b/gdb/regformats/rs6000/powerpc-isa207-htm-vsx64l.dat +new file mode 100644 +--- /dev/null ++++ b/gdb/regformats/rs6000/powerpc-isa207-htm-vsx64l.dat +@@ -0,0 +1,296 @@ ++# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: ++# Generated from: rs6000/powerpc-isa207-htm-vsx64l.xml ++name:powerpc_isa207_htm_vsx64l ++xmltarget:powerpc-isa207-htm-vsx64l.xml ++expedite:r1,pc ++64:r0 ++64:r1 ++64:r2 ++64:r3 ++64:r4 ++64:r5 ++64:r6 ++64:r7 ++64:r8 ++64:r9 ++64:r10 ++64:r11 ++64:r12 ++64:r13 ++64:r14 ++64:r15 ++64:r16 ++64:r17 ++64:r18 ++64:r19 ++64:r20 ++64:r21 ++64:r22 ++64:r23 ++64:r24 ++64:r25 ++64:r26 ++64:r27 ++64:r28 ++64:r29 ++64:r30 ++64:r31 ++64:f0 ++64:f1 ++64:f2 ++64:f3 ++64:f4 ++64:f5 ++64:f6 ++64:f7 ++64:f8 ++64:f9 ++64:f10 ++64:f11 ++64:f12 ++64:f13 ++64:f14 ++64:f15 ++64:f16 ++64:f17 ++64:f18 ++64:f19 ++64:f20 ++64:f21 ++64:f22 ++64:f23 ++64:f24 ++64:f25 ++64:f26 ++64:f27 ++64:f28 ++64:f29 ++64:f30 ++64:f31 ++64:pc ++64:msr ++32:cr ++64:lr ++64:ctr ++32:xer ++64:fpscr ++64:orig_r3 ++64:trap ++128:vr0 ++128:vr1 ++128:vr2 ++128:vr3 ++128:vr4 ++128:vr5 ++128:vr6 ++128:vr7 ++128:vr8 ++128:vr9 ++128:vr10 ++128:vr11 ++128:vr12 ++128:vr13 ++128:vr14 ++128:vr15 ++128:vr16 ++128:vr17 ++128:vr18 ++128:vr19 ++128:vr20 ++128:vr21 ++128:vr22 ++128:vr23 ++128:vr24 ++128:vr25 ++128:vr26 ++128:vr27 ++128:vr28 ++128:vr29 ++128:vr30 ++128:vr31 ++32:vscr ++32:vrsave ++64:vs0h ++64:vs1h ++64:vs2h ++64:vs3h ++64:vs4h ++64:vs5h ++64:vs6h ++64:vs7h ++64:vs8h ++64:vs9h ++64:vs10h ++64:vs11h ++64:vs12h ++64:vs13h ++64:vs14h ++64:vs15h ++64:vs16h ++64:vs17h ++64:vs18h ++64:vs19h ++64:vs20h ++64:vs21h ++64:vs22h ++64:vs23h ++64:vs24h ++64:vs25h ++64:vs26h ++64:vs27h ++64:vs28h ++64:vs29h ++64:vs30h ++64:vs31h ++64:ppr ++64:dscr ++64:tar ++64:bescr ++64:ebbhr ++64:ebbrr ++64:mmcr0 ++64:mmcr2 ++64:siar ++64:sdar ++64:sier ++64:tfhar ++64:texasr ++64:tfiar ++64:cr0 ++64:cr1 ++64:cr2 ++64:cr3 ++64:cr4 ++64:cr5 ++64:cr6 ++64:cr7 ++64:cr8 ++64:cr9 ++64:cr10 ++64:cr11 ++64:cr12 ++64:cr13 ++64:cr14 ++64:cr15 ++64:cr16 ++64:cr17 ++64:cr18 ++64:cr19 ++64:cr20 ++64:cr21 ++64:cr22 ++64:cr23 ++64:cr24 ++64:cr25 ++64:cr26 ++64:cr27 ++64:cr28 ++64:cr29 ++64:cr30 ++64:cr31 ++32:ccr ++32:cxer ++64:clr ++64:cctr ++64:cf0 ++64:cf1 ++64:cf2 ++64:cf3 ++64:cf4 ++64:cf5 ++64:cf6 ++64:cf7 ++64:cf8 ++64:cf9 ++64:cf10 ++64:cf11 ++64:cf12 ++64:cf13 ++64:cf14 ++64:cf15 ++64:cf16 ++64:cf17 ++64:cf18 ++64:cf19 ++64:cf20 ++64:cf21 ++64:cf22 ++64:cf23 ++64:cf24 ++64:cf25 ++64:cf26 ++64:cf27 ++64:cf28 ++64:cf29 ++64:cf30 ++64:cf31 ++64:cfpscr ++128:cvr0 ++128:cvr1 ++128:cvr2 ++128:cvr3 ++128:cvr4 ++128:cvr5 ++128:cvr6 ++128:cvr7 ++128:cvr8 ++128:cvr9 ++128:cvr10 ++128:cvr11 ++128:cvr12 ++128:cvr13 ++128:cvr14 ++128:cvr15 ++128:cvr16 ++128:cvr17 ++128:cvr18 ++128:cvr19 ++128:cvr20 ++128:cvr21 ++128:cvr22 ++128:cvr23 ++128:cvr24 ++128:cvr25 ++128:cvr26 ++128:cvr27 ++128:cvr28 ++128:cvr29 ++128:cvr30 ++128:cvr31 ++32:cvscr ++32:cvrsave ++64:cvs0h ++64:cvs1h ++64:cvs2h ++64:cvs3h ++64:cvs4h ++64:cvs5h ++64:cvs6h ++64:cvs7h ++64:cvs8h ++64:cvs9h ++64:cvs10h ++64:cvs11h ++64:cvs12h ++64:cvs13h ++64:cvs14h ++64:cvs15h ++64:cvs16h ++64:cvs17h ++64:cvs18h ++64:cvs19h ++64:cvs20h ++64:cvs21h ++64:cvs22h ++64:cvs23h ++64:cvs24h ++64:cvs25h ++64:cvs26h ++64:cvs27h ++64:cvs28h ++64:cvs29h ++64:cvs30h ++64:cvs31h ++64:cppr ++64:cdscr ++64:ctar +diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c +--- a/gdb/rs6000-tdep.c ++++ b/gdb/rs6000-tdep.c +@@ -105,6 +105,22 @@ + && (regnum) >= (tdep)->ppc_efpr0_regnum \ + && (regnum) < (tdep)->ppc_efpr0_regnum + ppc_num_efprs) + ++/* Determine if regnum is a checkpointed decimal float ++ pseudo-register. */ ++#define IS_CDFP_PSEUDOREG(tdep, regnum) ((tdep)->ppc_cdl0_regnum >= 0 \ ++ && (regnum) >= (tdep)->ppc_cdl0_regnum \ ++ && (regnum) < (tdep)->ppc_cdl0_regnum + 16) ++ ++/* Determine if regnum is a Checkpointed POWER7 VSX register. */ ++#define IS_CVSX_PSEUDOREG(tdep, regnum) ((tdep)->ppc_cvsr0_regnum >= 0 \ ++ && (regnum) >= (tdep)->ppc_cvsr0_regnum \ ++ && (regnum) < (tdep)->ppc_cvsr0_regnum + ppc_num_vsrs) ++ ++/* Determine if regnum is a Checkpointed POWER7 Extended FP register. */ ++#define IS_CEFP_PSEUDOREG(tdep, regnum) ((tdep)->ppc_cefpr0_regnum >= 0 \ ++ && (regnum) >= (tdep)->ppc_cefpr0_regnum \ ++ && (regnum) < (tdep)->ppc_cefpr0_regnum + ppc_num_efprs) ++ + /* Holds the current set of options to be passed to the disassembler. */ + static char *powerpc_disassembler_options; + +@@ -2375,6 +2391,11 @@ rs6000_register_name (struct gdbarch *gdbarch, int regno) + && regno < tdep->ppc_vsr0_upper_regnum + ppc_num_gprs) + return ""; + ++ /* Hide the upper halves of the cvs0~cvs31 registers. */ ++ if (PPC_CVSR0_UPPER_REGNUM <= regno ++ && regno < PPC_CVSR0_UPPER_REGNUM + ppc_num_gprs) ++ return ""; ++ + /* Check if the SPE pseudo registers are available. */ + if (IS_SPE_PSEUDOREG (tdep, regno)) + { +@@ -2429,6 +2450,48 @@ rs6000_register_name (struct gdbarch *gdbarch, int regno) + return efpr_regnames[regno - tdep->ppc_efpr0_regnum]; + } + ++ /* Check if this is a Checkpointed DFP pseudo-register. */ ++ if (IS_CDFP_PSEUDOREG (tdep, regno)) ++ { ++ static const char *const cdfp128_regnames[] = { ++ "cdl0", "cdl1", "cdl2", "cdl3", ++ "cdl4", "cdl5", "cdl6", "cdl7", ++ "cdl8", "cdl9", "cdl10", "cdl11", ++ "cdl12", "cdl13", "cdl14", "cdl15" ++ }; ++ return cdfp128_regnames[regno - tdep->ppc_cdl0_regnum]; ++ } ++ ++ /* Check if this is a Checkpointed VSX pseudo-register. */ ++ if (IS_CVSX_PSEUDOREG (tdep, regno)) ++ { ++ static const char *const cvsx_regnames[] = { ++ "cvs0", "cvs1", "cvs2", "cvs3", "cvs4", "cvs5", "cvs6", "cvs7", ++ "cvs8", "cvs9", "cvs10", "cvs11", "cvs12", "cvs13", "cvs14", ++ "cvs15", "cvs16", "cvs17", "cvs18", "cvs19", "cvs20", "cvs21", ++ "cvs22", "cvs23", "cvs24", "cvs25", "cvs26", "cvs27", "cvs28", ++ "cvs29", "cvs30", "cvs31", "cvs32", "cvs33", "cvs34", "cvs35", ++ "cvs36", "cvs37", "cvs38", "cvs39", "cvs40", "cvs41", "cvs42", ++ "cvs43", "cvs44", "cvs45", "cvs46", "cvs47", "cvs48", "cvs49", ++ "cvs50", "cvs51", "cvs52", "cvs53", "cvs54", "cvs55", "cvs56", ++ "cvs57", "cvs58", "cvs59", "cvs60", "cvs61", "cvs62", "cvs63" ++ }; ++ return cvsx_regnames[regno - tdep->ppc_cvsr0_regnum]; ++ } ++ ++ /* Check if the this is a Checkpointed Extended FP pseudo-register. */ ++ if (IS_CEFP_PSEUDOREG (tdep, regno)) ++ { ++ static const char *const cefpr_regnames[] = { ++ "cf32", "cf33", "cf34", "cf35", "cf36", "cf37", "cf38", ++ "cf39", "cf40", "cf41", "cf42", "cf43", "cf44", "cf45", ++ "cf46", "cf47", "cf48", "cf49", "cf50", "cf51", ++ "cf52", "cf53", "cf54", "cf55", "cf56", "cf57", ++ "cf58", "cf59", "cf60", "cf61", "cf62", "cf63" ++ }; ++ return cefpr_regnames[regno - tdep->ppc_cefpr0_regnum]; ++ } ++ + return tdesc_register_name (gdbarch, regno); + } + +@@ -2440,24 +2503,26 @@ rs6000_pseudo_register_type (struct gdbarch *gdbarch, int regnum) + { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + +- /* These are the only pseudo-registers we support. */ +- gdb_assert (IS_SPE_PSEUDOREG (tdep, regnum) +- || IS_DFP_PSEUDOREG (tdep, regnum) +- || IS_VSX_PSEUDOREG (tdep, regnum) +- || IS_EFP_PSEUDOREG (tdep, regnum)); +- + /* These are the e500 pseudo-registers. */ + if (IS_SPE_PSEUDOREG (tdep, regnum)) + return rs6000_builtin_type_vec64 (gdbarch); +- else if (IS_DFP_PSEUDOREG (tdep, regnum)) ++ else if (IS_DFP_PSEUDOREG (tdep, regnum) ++ || IS_CDFP_PSEUDOREG (tdep, regnum)) + /* PPC decimal128 pseudo-registers. */ + return builtin_type (gdbarch)->builtin_declong; +- else if (IS_VSX_PSEUDOREG (tdep, regnum)) ++ else if (IS_VSX_PSEUDOREG (tdep, regnum) ++ || IS_CVSX_PSEUDOREG (tdep, regnum)) + /* POWER7 VSX pseudo-registers. */ + return rs6000_builtin_type_vec128 (gdbarch); +- else ++ else if (IS_EFP_PSEUDOREG (tdep, regnum) ++ || IS_CEFP_PSEUDOREG (tdep, regnum)) + /* POWER7 Extended FP pseudo-registers. */ + return builtin_type (gdbarch)->builtin_double; ++ else ++ internal_error (__FILE__, __LINE__, ++ _("rs6000_pseudo_register_type: " ++ "called on unexpected register '%s' (%d)"), ++ gdbarch_register_name (gdbarch, regnum), regnum); + } + + /* The register format for RS/6000 floating point registers is always +@@ -2633,25 +2698,35 @@ dfp_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, + int reg_nr, gdb_byte *buffer) + { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); +- int reg_index = reg_nr - tdep->ppc_dl0_regnum; ++ int reg_index, fp0; + enum register_status status; + ++ if (IS_DFP_PSEUDOREG (tdep, reg_nr)) ++ { ++ reg_index = reg_nr - tdep->ppc_dl0_regnum; ++ fp0 = PPC_F0_REGNUM; ++ } ++ else ++ { ++ gdb_assert (IS_CDFP_PSEUDOREG (tdep, reg_nr)); ++ ++ reg_index = reg_nr - tdep->ppc_cdl0_regnum; ++ fp0 = PPC_CF0_REGNUM; ++ } ++ + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) + { + /* Read two FP registers to form a whole dl register. */ +- status = regcache->raw_read (tdep->ppc_fp0_regnum + +- 2 * reg_index, buffer); ++ status = regcache->raw_read (fp0 + 2 * reg_index, buffer); + if (status == REG_VALID) +- status = regcache->raw_read (tdep->ppc_fp0_regnum + +- 2 * reg_index + 1, buffer + 8); ++ status = regcache->raw_read (fp0 + 2 * reg_index + 1, ++ buffer + 8); + } + else + { +- status = regcache->raw_read (tdep->ppc_fp0_regnum + +- 2 * reg_index + 1, buffer); ++ status = regcache->raw_read (fp0 + 2 * reg_index + 1, buffer); + if (status == REG_VALID) +- status = regcache->raw_read (tdep->ppc_fp0_regnum + +- 2 * reg_index, buffer + 8); ++ status = regcache->raw_read (fp0 + 2 * reg_index, buffer + 8); + } + + return status; +@@ -2663,23 +2738,32 @@ dfp_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, + int reg_nr, const gdb_byte *buffer) + { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); +- int reg_index = reg_nr - tdep->ppc_dl0_regnum; ++ int reg_index, fp0; ++ ++ if (IS_DFP_PSEUDOREG (tdep, reg_nr)) ++ { ++ reg_index = reg_nr - tdep->ppc_dl0_regnum; ++ fp0 = PPC_F0_REGNUM; ++ } ++ else ++ { ++ gdb_assert (IS_CDFP_PSEUDOREG (tdep, reg_nr)); ++ ++ reg_index = reg_nr - tdep->ppc_cdl0_regnum; ++ fp0 = PPC_CF0_REGNUM; ++ } + + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) + { + /* Write each half of the dl register into a separate +- FP register. */ +- regcache->raw_write (tdep->ppc_fp0_regnum + +- 2 * reg_index, buffer); +- regcache->raw_write (tdep->ppc_fp0_regnum + +- 2 * reg_index + 1, buffer + 8); ++ FP register. */ ++ regcache->raw_write (fp0 + 2 * reg_index, buffer); ++ regcache->raw_write (fp0 + 2 * reg_index + 1, buffer + 8); + } + else + { +- regcache->raw_write (tdep->ppc_fp0_regnum + +- 2 * reg_index + 1, buffer); +- regcache->raw_write (tdep->ppc_fp0_regnum + +- 2 * reg_index, buffer + 8); ++ regcache->raw_write (fp0 + 2 * reg_index + 1, buffer); ++ regcache->raw_write (fp0 + 2 * reg_index, buffer + 8); + } + } + +@@ -2689,30 +2773,43 @@ vsx_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, + int reg_nr, gdb_byte *buffer) + { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); +- int reg_index = reg_nr - tdep->ppc_vsr0_regnum; ++ int reg_index, vr0, fp0, vsr0_upper; + enum register_status status; + ++ if (IS_VSX_PSEUDOREG (tdep, reg_nr)) ++ { ++ reg_index = reg_nr - tdep->ppc_vsr0_regnum; ++ vr0 = PPC_VR0_REGNUM; ++ fp0 = PPC_F0_REGNUM; ++ vsr0_upper = PPC_VSR0_UPPER_REGNUM; ++ } ++ else ++ { ++ gdb_assert (IS_CVSX_PSEUDOREG (tdep, reg_nr)); ++ ++ reg_index = reg_nr - tdep->ppc_cvsr0_regnum; ++ vr0 = PPC_CVR0_REGNUM; ++ fp0 = PPC_CF0_REGNUM; ++ vsr0_upper = PPC_CVSR0_UPPER_REGNUM; ++ } ++ + /* Read the portion that overlaps the VMX registers. */ + if (reg_index > 31) +- status = regcache->raw_read (tdep->ppc_vr0_regnum + +- reg_index - 32, buffer); ++ status = regcache->raw_read (vr0 + reg_index - 32, buffer); + else + /* Read the portion that overlaps the FPR registers. */ + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) + { +- status = regcache->raw_read (tdep->ppc_fp0_regnum + +- reg_index, buffer); ++ status = regcache->raw_read (fp0 + reg_index, buffer); + if (status == REG_VALID) +- status = regcache->raw_read (tdep->ppc_vsr0_upper_regnum + +- reg_index, buffer + 8); ++ status = regcache->raw_read (vsr0_upper + reg_index, ++ buffer + 8); + } + else + { +- status = regcache->raw_read (tdep->ppc_fp0_regnum + +- reg_index, buffer + 8); ++ status = regcache->raw_read (fp0 + reg_index, buffer + 8); + if (status == REG_VALID) +- status = regcache->raw_read (tdep->ppc_vsr0_upper_regnum + +- reg_index, buffer); ++ status = regcache->raw_read (vsr0_upper + reg_index, buffer); + } + + return status; +@@ -2724,56 +2821,103 @@ vsx_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, + int reg_nr, const gdb_byte *buffer) + { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); +- int reg_index = reg_nr - tdep->ppc_vsr0_regnum; ++ int reg_index, vr0, fp0, vsr0_upper; ++ ++ if (IS_VSX_PSEUDOREG (tdep, reg_nr)) ++ { ++ reg_index = reg_nr - tdep->ppc_vsr0_regnum; ++ vr0 = PPC_VR0_REGNUM; ++ fp0 = PPC_F0_REGNUM; ++ vsr0_upper = PPC_VSR0_UPPER_REGNUM; ++ } ++ else ++ { ++ gdb_assert (IS_CVSX_PSEUDOREG (tdep, reg_nr)); ++ ++ reg_index = reg_nr - tdep->ppc_cvsr0_regnum; ++ vr0 = PPC_CVR0_REGNUM; ++ fp0 = PPC_CF0_REGNUM; ++ vsr0_upper = PPC_CVSR0_UPPER_REGNUM; ++ } + + /* Write the portion that overlaps the VMX registers. */ + if (reg_index > 31) +- regcache->raw_write (tdep->ppc_vr0_regnum + +- reg_index - 32, buffer); ++ regcache->raw_write (vr0 + reg_index - 32, buffer); + else + /* Write the portion that overlaps the FPR registers. */ + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) + { +- regcache->raw_write (tdep->ppc_fp0_regnum + +- reg_index, buffer); +- regcache->raw_write (tdep->ppc_vsr0_upper_regnum + +- reg_index, buffer + 8); ++ regcache->raw_write (fp0 + reg_index, buffer); ++ regcache->raw_write (vsr0_upper + reg_index, buffer + 8); + } + else + { +- regcache->raw_write (tdep->ppc_fp0_regnum + +- reg_index, buffer + 8); +- regcache->raw_write (tdep->ppc_vsr0_upper_regnum + +- reg_index, buffer); ++ regcache->raw_write (fp0 + reg_index, buffer + 8); ++ regcache->raw_write (vsr0_upper + reg_index, buffer); + } + } + + /* Read method for POWER7 Extended FP pseudo-registers. */ + static enum register_status +-efpr_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, ++efp_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, + int reg_nr, gdb_byte *buffer) + { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); +- int reg_index = reg_nr - tdep->ppc_efpr0_regnum; ++ int reg_index, vr0; ++ ++ if (IS_EFP_PSEUDOREG (tdep, reg_nr)) ++ { ++ reg_index = reg_nr - tdep->ppc_efpr0_regnum; ++ vr0 = PPC_VR0_REGNUM; ++ } ++ else ++ { ++ gdb_assert (IS_CEFP_PSEUDOREG (tdep, reg_nr)); ++ ++ reg_index = reg_nr - tdep->ppc_cefpr0_regnum; ++ vr0 = PPC_CVR0_REGNUM; ++ } ++ + int offset = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 0 : 8; + + /* Read the portion that overlaps the VMX register. */ +- return regcache->raw_read_part (tdep->ppc_vr0_regnum + reg_index, +- offset, register_size (gdbarch, reg_nr), ++ return regcache->raw_read_part (vr0 + reg_index, offset, ++ register_size (gdbarch, reg_nr), + buffer); + } + + /* Write method for POWER7 Extended FP pseudo-registers. */ + static void +-efpr_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, ++efp_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, + int reg_nr, const gdb_byte *buffer) + { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); +- int reg_index = reg_nr - tdep->ppc_efpr0_regnum; ++ int reg_index, vr0; + int offset = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 0 : 8; + ++ if (IS_EFP_PSEUDOREG (tdep, reg_nr)) ++ { ++ reg_index = reg_nr - tdep->ppc_efpr0_regnum; ++ vr0 = PPC_VR0_REGNUM; ++ } ++ else ++ { ++ gdb_assert (IS_CEFP_PSEUDOREG (tdep, reg_nr)); ++ ++ reg_index = reg_nr - tdep->ppc_cefpr0_regnum; ++ vr0 = PPC_CVR0_REGNUM; ++ ++ /* The call to raw_write_part fails silently if the initial read ++ of the read-update-write sequence returns an invalid status, ++ so we check this manually and throw an error if needed. */ ++ regcache->raw_update (vr0 + reg_index); ++ if (regcache->get_register_status (vr0 + reg_index) != REG_VALID) ++ error (_("Cannot write to the checkpointed EFP register, " ++ "the corresponding vector register is unavailable.")); ++ } ++ + /* Write the portion that overlaps the VMX register. */ +- regcache->raw_write_part (tdep->ppc_vr0_regnum + reg_index, offset, ++ regcache->raw_write_part (vr0 + reg_index, offset, + register_size (gdbarch, reg_nr), buffer); + } + +@@ -2789,12 +2933,15 @@ rs6000_pseudo_register_read (struct gdbarch *gdbarch, + + if (IS_SPE_PSEUDOREG (tdep, reg_nr)) + return e500_pseudo_register_read (gdbarch, regcache, reg_nr, buffer); +- else if (IS_DFP_PSEUDOREG (tdep, reg_nr)) ++ else if (IS_DFP_PSEUDOREG (tdep, reg_nr) ++ || IS_CDFP_PSEUDOREG (tdep, reg_nr)) + return dfp_pseudo_register_read (gdbarch, regcache, reg_nr, buffer); +- else if (IS_VSX_PSEUDOREG (tdep, reg_nr)) ++ else if (IS_VSX_PSEUDOREG (tdep, reg_nr) ++ || IS_CVSX_PSEUDOREG (tdep, reg_nr)) + return vsx_pseudo_register_read (gdbarch, regcache, reg_nr, buffer); +- else if (IS_EFP_PSEUDOREG (tdep, reg_nr)) +- return efpr_pseudo_register_read (gdbarch, regcache, reg_nr, buffer); ++ else if (IS_EFP_PSEUDOREG (tdep, reg_nr) ++ || IS_CEFP_PSEUDOREG (tdep, reg_nr)) ++ return efp_pseudo_register_read (gdbarch, regcache, reg_nr, buffer); + else + internal_error (__FILE__, __LINE__, + _("rs6000_pseudo_register_read: " +@@ -2814,12 +2961,15 @@ rs6000_pseudo_register_write (struct gdbarch *gdbarch, + + if (IS_SPE_PSEUDOREG (tdep, reg_nr)) + e500_pseudo_register_write (gdbarch, regcache, reg_nr, buffer); +- else if (IS_DFP_PSEUDOREG (tdep, reg_nr)) ++ else if (IS_DFP_PSEUDOREG (tdep, reg_nr) ++ || IS_CDFP_PSEUDOREG (tdep, reg_nr)) + dfp_pseudo_register_write (gdbarch, regcache, reg_nr, buffer); +- else if (IS_VSX_PSEUDOREG (tdep, reg_nr)) ++ else if (IS_VSX_PSEUDOREG (tdep, reg_nr) ++ || IS_CVSX_PSEUDOREG (tdep, reg_nr)) + vsx_pseudo_register_write (gdbarch, regcache, reg_nr, buffer); +- else if (IS_EFP_PSEUDOREG (tdep, reg_nr)) +- efpr_pseudo_register_write (gdbarch, regcache, reg_nr, buffer); ++ else if (IS_EFP_PSEUDOREG (tdep, reg_nr) ++ || IS_CEFP_PSEUDOREG (tdep, reg_nr)) ++ efp_pseudo_register_write (gdbarch, regcache, reg_nr, buffer); + else + internal_error (__FILE__, __LINE__, + _("rs6000_pseudo_register_write: " +@@ -2827,6 +2977,97 @@ rs6000_pseudo_register_write (struct gdbarch *gdbarch, + gdbarch_register_name (gdbarch, reg_nr), reg_nr); + } + ++/* Set the register mask in AX with the registers that form the DFP or ++ checkpointed DFP pseudo-register REG_NR. */ ++ ++static void ++dfp_ax_pseudo_register_collect (struct gdbarch *gdbarch, ++ struct agent_expr *ax, int reg_nr) ++{ ++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ int reg_index, fp0; ++ ++ if (IS_DFP_PSEUDOREG (tdep, reg_nr)) ++ { ++ reg_index = reg_nr - tdep->ppc_dl0_regnum; ++ fp0 = PPC_F0_REGNUM; ++ } ++ else ++ { ++ gdb_assert (IS_CDFP_PSEUDOREG (tdep, reg_nr)); ++ ++ reg_index = reg_nr - tdep->ppc_cdl0_regnum; ++ fp0 = PPC_CF0_REGNUM; ++ } ++ ++ ax_reg_mask (ax, fp0 + 2 * reg_index); ++ ax_reg_mask (ax, fp0 + 2 * reg_index + 1); ++} ++ ++/* Set the register mask in AX with the registers that form the VSX or ++ checkpointed VSX pseudo-register REG_NR. */ ++ ++static void ++vsx_ax_pseudo_register_collect (struct gdbarch *gdbarch, ++ struct agent_expr *ax, int reg_nr) ++{ ++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ int reg_index, vr0, fp0, vsr0_upper; ++ ++ if (IS_VSX_PSEUDOREG (tdep, reg_nr)) ++ { ++ reg_index = reg_nr - tdep->ppc_vsr0_regnum; ++ vr0 = PPC_VR0_REGNUM; ++ fp0 = PPC_F0_REGNUM; ++ vsr0_upper = PPC_VSR0_UPPER_REGNUM; ++ } ++ else ++ { ++ gdb_assert (IS_CVSX_PSEUDOREG (tdep, reg_nr)); ++ ++ reg_index = reg_nr - tdep->ppc_cvsr0_regnum; ++ vr0 = PPC_CVR0_REGNUM; ++ fp0 = PPC_CF0_REGNUM; ++ vsr0_upper = PPC_CVSR0_UPPER_REGNUM; ++ } ++ ++ if (reg_index > 31) ++ { ++ ax_reg_mask (ax, vr0 + reg_index - 32); ++ } ++ else ++ { ++ ax_reg_mask (ax, fp0 + reg_index); ++ ax_reg_mask (ax, vsr0_upper + reg_index); ++ } ++} ++ ++/* Set the register mask in AX with the register that corresponds to ++ the EFP or checkpointed EFP pseudo-register REG_NR. */ ++ ++static void ++efp_ax_pseudo_register_collect (struct gdbarch *gdbarch, ++ struct agent_expr *ax, int reg_nr) ++{ ++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ int reg_index, vr0; ++ ++ if (IS_EFP_PSEUDOREG (tdep, reg_nr)) ++ { ++ reg_index = reg_nr - tdep->ppc_efpr0_regnum; ++ vr0 = PPC_VR0_REGNUM; ++ } ++ else ++ { ++ gdb_assert (IS_CEFP_PSEUDOREG (tdep, reg_nr)); ++ ++ reg_index = reg_nr - tdep->ppc_cefpr0_regnum; ++ vr0 = PPC_CVR0_REGNUM; ++ } ++ ++ ax_reg_mask (ax, vr0 + reg_index); ++} ++ + static int + rs6000_ax_pseudo_register_collect (struct gdbarch *gdbarch, + struct agent_expr *ax, int reg_nr) +@@ -2838,29 +3079,20 @@ rs6000_ax_pseudo_register_collect (struct gdbarch *gdbarch, + ax_reg_mask (ax, tdep->ppc_gp0_regnum + reg_index); + ax_reg_mask (ax, tdep->ppc_ev0_upper_regnum + reg_index); + } +- else if (IS_DFP_PSEUDOREG (tdep, reg_nr)) ++ else if (IS_DFP_PSEUDOREG (tdep, reg_nr) ++ || IS_CDFP_PSEUDOREG (tdep, reg_nr)) + { +- int reg_index = reg_nr - tdep->ppc_dl0_regnum; +- ax_reg_mask (ax, tdep->ppc_fp0_regnum + 2 * reg_index); +- ax_reg_mask (ax, tdep->ppc_fp0_regnum + 2 * reg_index + 1); ++ dfp_ax_pseudo_register_collect (gdbarch, ax, reg_nr); + } +- else if (IS_VSX_PSEUDOREG (tdep, reg_nr)) ++ else if (IS_VSX_PSEUDOREG (tdep, reg_nr) ++ || IS_CVSX_PSEUDOREG (tdep, reg_nr)) + { +- int reg_index = reg_nr - tdep->ppc_vsr0_regnum; +- if (reg_index > 31) +- { +- ax_reg_mask (ax, tdep->ppc_vr0_regnum + reg_index - 32); +- } +- else +- { +- ax_reg_mask (ax, tdep->ppc_fp0_regnum + reg_index); +- ax_reg_mask (ax, tdep->ppc_vsr0_upper_regnum + reg_index); +- } ++ vsx_ax_pseudo_register_collect (gdbarch, ax, reg_nr); + } +- else if (IS_EFP_PSEUDOREG (tdep, reg_nr)) ++ else if (IS_EFP_PSEUDOREG (tdep, reg_nr) ++ || IS_CEFP_PSEUDOREG (tdep, reg_nr)) + { +- int reg_index = reg_nr - tdep->ppc_efpr0_regnum; +- ax_reg_mask (ax, tdep->ppc_vr0_regnum + reg_index); ++ efp_ax_pseudo_register_collect (gdbarch, ax, reg_nr); + } + else + internal_error (__FILE__, __LINE__, +@@ -5871,7 +6103,10 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + enum powerpc_elf_abi elf_abi = POWERPC_ELF_AUTO; + int have_fpu = 0, have_spe = 0, have_mq = 0, have_altivec = 0; + int have_dfp = 0, have_vsx = 0, have_ppr = 0, have_dscr = 0; +- int have_tar = 0, have_ebb = 0, have_pmu = 0; ++ int have_tar = 0, have_ebb = 0, have_pmu = 0, have_htm_spr = 0; ++ int have_htm_core = 0, have_htm_fpu = 0, have_htm_altivec = 0; ++ int have_htm_vsx = 0, have_htm_ppr = 0, have_htm_dscr = 0; ++ int have_htm_tar = 0; + int tdesc_wordsize = -1; + const struct target_desc *tdesc = info.target_desc; + struct tdesc_arch_data *tdesc_data = NULL; +@@ -6270,6 +6505,201 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + } + else + have_pmu = 0; ++ ++ /* Hardware Transactional Memory Registers. */ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.htm.spr"); ++ if (feature != NULL) ++ { ++ static const char *const tm_spr_regs[] = { ++ "tfhar", "texasr", "tfiar" ++ }; ++ ++ valid_p = 1; ++ for (i = 0; i < ARRAY_SIZE (tm_spr_regs); i++) ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_TFHAR_REGNUM + i, ++ tm_spr_regs[i]); ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ ++ have_htm_spr = 1; ++ } ++ else ++ have_htm_spr = 0; ++ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.htm.core"); ++ if (feature != NULL) ++ { ++ static const char *const cgprs[] = { ++ "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", ++ "cr8", "cr9", "cr10", "cr11", "cr12", "cr13", "cr14", ++ "cr15", "cr16", "cr17", "cr18", "cr19", "cr20", "cr21", ++ "cr22", "cr23", "cr24", "cr25", "cr26", "cr27", "cr28", ++ "cr29", "cr30", "cr31", "ccr", "cxer", "clr", "cctr" ++ }; ++ ++ valid_p = 1; ++ ++ for (i = 0; i < ARRAY_SIZE (cgprs); i++) ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_CR0_REGNUM + i, ++ cgprs[i]); ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ ++ have_htm_core = 1; ++ } ++ else ++ have_htm_core = 0; ++ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.htm.fpu"); ++ if (feature != NULL) ++ { ++ valid_p = 1; ++ ++ static const char *const cfprs[] = { ++ "cf0", "cf1", "cf2", "cf3", "cf4", "cf5", "cf6", "cf7", ++ "cf8", "cf9", "cf10", "cf11", "cf12", "cf13", "cf14", "cf15", ++ "cf16", "cf17", "cf18", "cf19", "cf20", "cf21", "cf22", ++ "cf23", "cf24", "cf25", "cf26", "cf27", "cf28", "cf29", ++ "cf30", "cf31", "cfpscr" ++ }; ++ ++ for (i = 0; i < ARRAY_SIZE (cfprs); i++) ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_CF0_REGNUM + i, ++ cfprs[i]); ++ ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_htm_fpu = 1; ++ } ++ else ++ have_htm_fpu = 0; ++ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.htm.altivec"); ++ if (feature != NULL) ++ { ++ valid_p = 1; ++ ++ static const char *const cvmx[] = { ++ "cvr0", "cvr1", "cvr2", "cvr3", "cvr4", "cvr5", "cvr6", ++ "cvr7", "cvr8", "cvr9", "cvr10", "cvr11", "cvr12", "cvr13", ++ "cvr14", "cvr15","cvr16", "cvr17", "cvr18", "cvr19", "cvr20", ++ "cvr21", "cvr22", "cvr23", "cvr24", "cvr25", "cvr26", ++ "cvr27", "cvr28", "cvr29", "cvr30", "cvr31", "cvscr", ++ "cvrsave" ++ }; ++ ++ for (i = 0; i < ARRAY_SIZE (cvmx); i++) ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ PPC_CVR0_REGNUM + i, ++ cvmx[i]); ++ ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_htm_altivec = 1; ++ } ++ else ++ have_htm_altivec = 0; ++ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.htm.vsx"); ++ if (feature != NULL) ++ { ++ valid_p = 1; ++ ++ static const char *const cvsx[] = { ++ "cvs0h", "cvs1h", "cvs2h", "cvs3h", "cvs4h", "cvs5h", ++ "cvs6h", "cvs7h", "cvs8h", "cvs9h", "cvs10h", "cvs11h", ++ "cvs12h", "cvs13h", "cvs14h", "cvs15h", "cvs16h", "cvs17h", ++ "cvs18h", "cvs19h", "cvs20h", "cvs21h", "cvs22h", "cvs23h", ++ "cvs24h", "cvs25h", "cvs26h", "cvs27h", "cvs28h", "cvs29h", ++ "cvs30h", "cvs31h" ++ }; ++ ++ for (i = 0; i < ARRAY_SIZE (cvsx); i++) ++ valid_p &= tdesc_numbered_register (feature, tdesc_data, ++ (PPC_CVSR0_UPPER_REGNUM ++ + i), ++ cvsx[i]); ++ ++ if (!valid_p || !have_htm_fpu || !have_htm_altivec) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_htm_vsx = 1; ++ } ++ else ++ have_htm_vsx = 0; ++ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.htm.ppr"); ++ if (feature != NULL) ++ { ++ valid_p = tdesc_numbered_register (feature, tdesc_data, ++ PPC_CPPR_REGNUM, "cppr"); ++ ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_htm_ppr = 1; ++ } ++ else ++ have_htm_ppr = 0; ++ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.htm.dscr"); ++ if (feature != NULL) ++ { ++ valid_p = tdesc_numbered_register (feature, tdesc_data, ++ PPC_CDSCR_REGNUM, "cdscr"); ++ ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_htm_dscr = 1; ++ } ++ else ++ have_htm_dscr = 0; ++ ++ feature = tdesc_find_feature (tdesc, ++ "org.gnu.gdb.power.htm.tar"); ++ if (feature != NULL) ++ { ++ valid_p = tdesc_numbered_register (feature, tdesc_data, ++ PPC_CTAR_REGNUM, "ctar"); ++ ++ if (!valid_p) ++ { ++ tdesc_data_cleanup (tdesc_data); ++ return NULL; ++ } ++ have_htm_tar = 1; ++ } ++ else ++ have_htm_tar = 0; + } + + /* If we have a 64-bit binary on a 32-bit target, complain. Also +@@ -6482,6 +6912,15 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + tdep->ppc_sdar_regnum = have_pmu ? PPC_SDAR_REGNUM : -1; + tdep->ppc_sier_regnum = have_pmu ? PPC_SIER_REGNUM : -1; + ++ tdep->have_htm_spr = have_htm_spr; ++ tdep->have_htm_core = have_htm_core; ++ tdep->have_htm_fpu = have_htm_fpu; ++ tdep->have_htm_altivec = have_htm_altivec; ++ tdep->have_htm_vsx = have_htm_vsx; ++ tdep->ppc_cppr_regnum = have_htm_ppr ? PPC_CPPR_REGNUM : -1; ++ tdep->ppc_cdscr_regnum = have_htm_dscr ? PPC_CDSCR_REGNUM : -1; ++ tdep->ppc_ctar_regnum = have_htm_tar ? PPC_CTAR_REGNUM : -1; ++ + set_gdbarch_pc_regnum (gdbarch, PPC_PC_REGNUM); + set_gdbarch_sp_regnum (gdbarch, PPC_R0_REGNUM + 1); + set_gdbarch_fp0_regnum (gdbarch, tdep->ppc_fp0_regnum); +@@ -6503,7 +6942,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + else + tdep->lr_frame_offset = 4; + +- if (have_spe || have_dfp || have_vsx) ++ if (have_spe || have_dfp || have_vsx || have_htm_fpu || have_htm_vsx) + { + set_gdbarch_pseudo_register_read (gdbarch, rs6000_pseudo_register_read); + set_gdbarch_pseudo_register_write (gdbarch, +@@ -6525,6 +6964,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + if (have_vsx) + /* Include both VSX and Extended FP registers. */ + num_pseudoregs += 96; ++ if (have_htm_fpu) ++ num_pseudoregs += 16; ++ /* Include both checkpointed VSX and EFP registers. */ ++ if (have_htm_vsx) ++ num_pseudoregs += 64 + 32; + + set_gdbarch_num_pseudo_regs (gdbarch, num_pseudoregs); + +@@ -6640,6 +7084,9 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + tdep->ppc_dl0_regnum = -1; + tdep->ppc_vsr0_regnum = -1; + tdep->ppc_efpr0_regnum = -1; ++ tdep->ppc_cdl0_regnum = -1; ++ tdep->ppc_cvsr0_regnum = -1; ++ tdep->ppc_cefpr0_regnum = -1; + + cur_reg = gdbarch_num_regs (gdbarch); + +@@ -6660,6 +7107,18 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + tdep->ppc_efpr0_regnum = cur_reg; + cur_reg += 32; + } ++ if (have_htm_fpu) ++ { ++ tdep->ppc_cdl0_regnum = cur_reg; ++ cur_reg += 16; ++ } ++ if (have_htm_vsx) ++ { ++ tdep->ppc_cvsr0_regnum = cur_reg; ++ cur_reg += 64; ++ tdep->ppc_cefpr0_regnum = cur_reg; ++ cur_reg += 32; ++ } + + gdb_assert (gdbarch_num_regs (gdbarch) + + gdbarch_num_pseudo_regs (gdbarch) == cur_reg); +diff --git a/gdb/testsuite/gdb.arch/powerpc-htm-regs.c b/gdb/testsuite/gdb.arch/powerpc-htm-regs.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-htm-regs.c +@@ -0,0 +1,39 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright (C) 2018 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++int main (void) ++{ ++ /* Touch DSCR. Some kernels won't schedule the thread with a DSCR ++ altered by ptrace unless the register was used at some point. */ ++ unsigned long dscr = 0x0; ++ ++ /* This is the non-privileged SPR number to access DSCR, ++ available since isa 207. */ ++ asm volatile ("mtspr 3,%0" : : "r" (dscr)); ++ ++ asm volatile ("tbegin."); // first marker ++ asm volatile goto ("bc 12,2,%l[end]" ++ : ++ : ++ : ++ : end); ++ asm volatile ("tabort. 0"); ++end: ++ asm volatile ("nop"); // second marker ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp b/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp +@@ -0,0 +1,328 @@ ++# Copyright (C) 2018 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# This file is part of the gdb testsuite. ++ ++# Test access to HTM (Hardware Transactional Memory) registers. The ++# tests read the values of various registers before stepping the ++# inferior through a "tbegin." instruction to start a transaction, ++# then the checkpointed versions of the registers are checked against ++# the pre-transactional values. Then, new values are written to some ++# of the checkpointed registers, these values are read back and saved, ++# the inferior continues until the transaction aborts, and the regular ++# registers are then checked against the saved values, because the ++# abort should have reverted the registers to these values. ++ ++if {![istarget "powerpc*-*-linux*"]} then { ++ verbose "Skipping PowerPC test for HTM registers." ++ return ++} ++ ++standard_testfile .c .gen.c ++ ++# First check if our processor and kernel support access to ++# the registers we need and to the HTM facility. ++ ++proc check_register_access { regname } { ++ global gdb_prompt ++ ++ set test "$regname register access" ++ gdb_test_multiple "info reg $regname" "$test" { ++ -re "Invalid register.*\r\n$gdb_prompt $" { ++ unsupported "$test" ++ return 0 ++ } ++ -re "\r\n$regname.*\r\n$gdb_prompt $" { ++ pass "$test" ++ return 1 ++ } ++ } ++ return 0 ++} ++ ++proc check_htm_support {} { ++ global gdb_prompt ++ set test "htm support" ++ ++ gdb_test_multiple "stepi" "$test" { ++ -re "Illegal instruction.*\r\n$gdb_prompt $" { ++ unsupported $test ++ return 0 ++ } ++ -re "nop.*\r\n$gdb_prompt $" ++ { ++ pass $test ++ return 1 ++ } ++ } ++ return 0; ++} ++ ++with_test_prefix "check htm support" { ++ set gen_src [standard_output_file $srcfile2] ++ ++ gdb_produce_source $gen_src { ++ int main () { ++ asm volatile ("tbegin."); // marker ++ asm volatile ("nop"); ++ return 0; ++ } ++ } ++ ++ if {[build_executable "compile" $binfile $gen_src {debug}] == -1} { ++ return ++ } ++ ++ clean_restart $binfile ++ ++ # Displaced-stepping a tbegin. causes problems, ++ # so we make the breakpoint temporary. ++ gdb_breakpoint [gdb_get_line_number "marker" "$gen_src"] temporary ++ ++ gdb_run_cmd ++ ++ # Wait for the prompt. ++ if {[gdb_test "" "Temporary breakpoint.*"] != 0 } { ++ return ++ } ++ ++ # Make sure that we stopped at the right place (just before tbegin. is ++ # executed). ++ if { [gdb_test "x/i \$pc" "=> $hex.*:.*tbegin\\..*" "disassemble tbegin"] != 0} { ++ return ++ } ++ ++ if {![check_register_access "vs0"]} { ++ return ++ } ++ ++ if {![check_register_access "texasr"]} { ++ return ++ } ++ ++ if {![check_register_access "dscr"]} { ++ return ++ } ++ ++ if {![check_register_access "ppr"]} { ++ return ++ } ++ ++ if {![check_register_access "tar"]} { ++ return ++ } ++ ++ if {![check_htm_support]} { ++ return ++ } ++} ++ ++# Now do the actual test. ++if {[build_executable "compile" $binfile $srcfile {debug}] == -1} { ++ return ++} ++ ++clean_restart $binfile ++ ++gdb_breakpoint [gdb_get_line_number "first marker"] temporary ++ ++gdb_run_cmd ++ ++# Wait for the prompt. ++gdb_test "" "Temporary breakpoint.*" ++ ++if {[gdb_test "x/i \$pc" "=> $hex.*:.*tbegin\\..*" "disassemble tbegin"] != 0} { ++ return ++} ++ ++# Now we write non-zero values to some registers, then read the values ++# of various registers, then stepi to start the transaction. The ++# checkpointed register state should correspond to the values we read. ++ ++# Write to the GPRs ++for {set i 0} {$i < 32} {incr i 1} { ++ gdb_test_no_output "set \$r$i = $i" ++} ++ ++gdb_test_no_output "set \$xer = 0xc0000000" ++ ++# FPRs ++gdb_test_no_output "set \$f0 = 0.5" ++for {set i 1} {$i < 32} {incr i 1} { ++ gdb_test_no_output "set \$f$i = \$f[expr $i - 1] + 1.0" ++} ++ ++gdb_test_no_output "set \$fpscr = 0x84005000" ++ ++# VRs ++for {set i 0} {$i < 32} {incr i 1} { ++ for {set j 0} {$j < 4} {incr j 1} { ++ gdb_test_no_output "set \$vr$i.v4_int32\[$j\] = $i" ++ } ++} ++ ++gdb_test_no_output "set \$dscr = 0x2" ++gdb_test_no_output "set \$tar = &main" "set tar" ++ ++# Get the pre-transactional value of the registers. ++for {set i 0} {$i < 32} {incr i 1} { ++ set "r$i" [get_hexadecimal_valueof "\$r$i" "default0"] ++} ++ ++set cr [get_hexadecimal_valueof "\$cr" "default0"] ++set xer [get_hexadecimal_valueof "\$xer" "default0"] ++set lr [get_hexadecimal_valueof "\$lr" "default0"] ++set ctr [get_hexadecimal_valueof "\$ctr" "default0"] ++ ++for {set i 0} {$i < 32} {incr i 1} { ++ set "f$i" [get_valueof "" "\$f$i" "default0"] ++} ++ ++set fpscr [get_hexadecimal_valueof "\$fpscr" "default0"] ++ ++for {set i 0} {$i < 32} {incr i 1} { ++ set "vr$i" [get_hexadecimal_valueof "\$vr$i.uint128" "default0"] ++} ++ ++set vscr [get_hexadecimal_valueof "\$vscr" "default0"] ++set vrsave [get_hexadecimal_valueof "\$vrsave" "default0"] ++ ++for {set i 0} {$i < 64} {incr i 1} { ++ set "vs$i" [get_hexadecimal_valueof "\$vs$i.uint128" "default0"] ++} ++ ++set dscr [get_hexadecimal_valueof "\$dscr" "default0"] ++set ppr [get_hexadecimal_valueof "\$ppr" "default0"] ++set tar [get_hexadecimal_valueof "\$tar" "default0"] ++ ++gdb_test "stepi" "asm.*bc.*" ++ ++proc test_register_match {reg_name reg_var_name hex} { ++ set test "$reg_name matches $reg_var_name" ++ ++ # In some infrequent cases CXER doesn't match the ++ # pre-transactional XER, possibly due to a linux kernel bug. ++ set should_xfail 0 ++ if [istarget "powerpc*-*-linux*" && reg_name == "cxer"] { ++ set should_xfail 1 ++ } ++ ++ upvar $reg_var_name expected_val ++ ++ if {$hex} { ++ set actual_val [get_hexadecimal_valueof "\$$reg_name" "default1"] ++ } else { ++ set actual_val [get_valueof "" "\$$reg_name" "default1"] ++ } ++ ++ if { "$expected_val" == "$actual_val" } { ++ pass $test ++ } else { ++ if {$should_xfail} { ++ xfail $test ++ } else { ++ fail $test ++ } ++ } ++} ++ ++for {set i 0} {$i < 32} {incr i 1} { ++ test_register_match "cr$i" "r$i" 1 ++} ++ ++test_register_match "ccr" "cr" 1 ++test_register_match "cxer" "xer" 1 ++test_register_match "clr" "lr" 1 ++test_register_match "cctr" "ctr" 1 ++ ++for {set i 0} {$i < 32} {incr i 1} { ++ test_register_match "cf$i" "f$i" 0 ++} ++ ++test_register_match "cfpscr" "fpscr" 1 ++ ++for {set i 0} {$i < 32} {incr i 1} { ++ test_register_match "cvr$i.uint128" "vr$i" 1 ++} ++ ++test_register_match "cvscr" "vscr" 1 ++test_register_match "cvrsave" "vrsave" 1 ++ ++for {set i 0} {$i < 64} {incr i 1} { ++ test_register_match "cvs$i.uint128" "vs$i" 1 ++} ++ ++test_register_match "cdscr" "dscr" 1 ++test_register_match "cppr" "ppr" 1 ++test_register_match "ctar" "tar" 1 ++ ++# Support for writing to the checkpointed registers is not ++# currently available in the gdbserver stub. ++if [target_is_gdbserver] { ++ unsupported "write to checkpointed registers" ++ return ++} ++ ++# Now write different values to some of the checkpointed registers and ++# check that the transaction abort reverts the register to these ++# values. ++for {set i 0} {$i < 32} {incr i 1} { ++ gdb_test_no_output "set \$cr$i = $i + 0xC00" ++} ++ ++gdb_test_no_output "set \$cf0 = 0.25" ++for {set i 1} {$i < 32} {incr i 1} { ++ gdb_test_no_output "set \$cf$i = \$cf[expr $i - 1] + 1.0" ++} ++ ++for {set i 0} {$i < 32} {incr i 1} { ++ for {set j 0} {$j < 4} {incr j 1} { ++ gdb_test_no_output "set \$cvr$i.v4_int32\[$j\] = $i + 0xF00" ++ } ++} ++ ++# Read back the values. ++with_test_prefix "after write" { ++ for {set i 0} {$i < 32} {incr i 1} { ++ set "cr$i" [get_hexadecimal_valueof "\$cr$i" "default0"] ++ } ++ ++ for {set i 0} {$i < 32} {incr i 1} { ++ set "cf$i" [get_valueof "" "\$cf$i" "default0"] ++ } ++ ++ for {set i 0} {$i < 64} {incr i 1} { ++ set "cvs$i" [get_hexadecimal_valueof "\$cvs$i.uint128" "default0"] ++ } ++} ++ ++gdb_breakpoint [gdb_get_line_number "second marker"] ++ ++gdb_test "continue" ++ ++with_test_prefix "after transaction failure" { ++ for {set i 0} {$i < 32} {incr i 1} { ++ test_register_match "r$i" "cr$i" 1 ++ } ++ ++ for {set i 0} {$i < 32} {incr i 1} { ++ test_register_match "f$i" "cf$i" 0 ++ } ++ ++ for {set i 0} {$i < 64} {incr i 1} { ++ test_register_match "vs$i.uint128" "cvs$i" 1 ++ } ++} ++ diff --git a/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-15of15.patch b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-15of15.patch new file mode 100644 index 0000000..a2339b6 --- /dev/null +++ b/SOURCES/gdb-rhbz1187581-power8-regs-not-in-8.2-15of15.patch @@ -0,0 +1,43 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 11 Jan 2019 17:02:19 -0500 +Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-15of15.patch + +;; [PowerPC] Document requirements for VSX feature +;; Pedro Franco de Carvalho, RH BZ 1187581 + +[PowerPC] Document requirements for VSX feature + +As suggested in +https://sourceware.org/ml/gdb-patches/2018-10/msg00510.html, this +patch changes the documentation for the VSX tdesc feature to make it +clear that the altivec and FPU features are requirements. + +gdb/doc/ChangeLog: +2018-11-09 Pedro Franco de Carvalho + + * gdb.texinfo (PowerPC Features): Document the altivec and fpu + requirements for the org.gnu.gdb.power.vsx feature. + +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -42541,11 +42541,13 @@ contain registers @samp{vr0} through @samp{vr31}, @samp{vscr}, + and @samp{vrsave}. + + The @samp{org.gnu.gdb.power.vsx} feature is optional. It should +-contain registers @samp{vs0h} through @samp{vs31h}. @value{GDBN} +-will combine these registers with the floating point registers +-(@samp{f0} through @samp{f31}) and the altivec registers (@samp{vr0} +-through @samp{vr31}) to present the 128-bit wide registers @samp{vs0} +-through @samp{vs63}, the set of vector registers for POWER7. ++contain registers @samp{vs0h} through @samp{vs31h}. @value{GDBN} will ++combine these registers with the floating point registers (@samp{f0} ++through @samp{f31}) and the altivec registers (@samp{vr0} through ++@samp{vr31}) to present the 128-bit wide registers @samp{vs0} through ++@samp{vs63}, the set of vector-scalar registers for POWER7. ++Therefore, this feature requires both @samp{org.gnu.gdb.power.fpu} and ++@samp{org.gnu.gdb.power.altivec}. + + The @samp{org.gnu.gdb.power.spe} feature is optional. It should + contain registers @samp{ev0h} through @samp{ev31h}, @samp{acc}, and diff --git a/SOURCES/gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch b/SOURCES/gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch new file mode 100644 index 0000000..b4e3109 --- /dev/null +++ b/SOURCES/gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch @@ -0,0 +1,104 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch + +;; [aarch64] Fix hardware watchpoints (RH BZ 1261564). +;;=fedoratest + +diff --git a/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.c b/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.c +@@ -0,0 +1,33 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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 . */ ++ ++__attribute__((aligned(16))) struct ++{ ++ int var0, var4, var8; ++} aligned; ++ ++int ++main (void) ++{ ++ aligned.var0 = 1; ++ aligned.var4 = 2; ++ aligned.var8 = 3; ++ ++ aligned.var4 = aligned.var0; ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.exp b/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.exp +@@ -0,0 +1,53 @@ ++# Copyright (C) 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 { [prepare_for_testing rhbz1261564-aarch64-watchpoint.exp "rhbz1261564-aarch64-watchpoint"] } { ++ return -1 ++} ++ ++if { ! [ runto main ] } then { return 0 } ++ ++set test "rwatch aligned.var4" ++if [istarget "s390*-*-*"] { ++ gdb_test $test {Target does not support this type of hardware watchpoint\.} ++ untested "s390* does not support hw read watchpoint" ++ return ++} ++gdb_test $test "Hardware read watchpoint \[0-9\]+: aligned.var4" ++ ++proc checkvar { address } { ++ global gdb_prompt ++ ++ set test "p &aligned.var$address" ++ gdb_test_multiple $test $test { ++ -re " = \\(int \\*\\) 0x\[0-9a-f\]+$address \r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "\r\n$gdb_prompt $" { ++ untested "$test (unexpected ELF layout)" ++ return 0 ++ } ++ } ++ return 1 ++} ++if ![checkvar "0"] { return } ++if ![checkvar "4"] { return } ++if ![checkvar "8"] { return } ++ ++# Assumes: PPC_PTRACE_GETHWDBGINFO::data_bp_alignment == 8 ++# 'lwz' does read only 4 bytes but the hw watchpoint is 8 bytes wide. ++setup_xfail "powerpc*-*-*" ++ ++gdb_continue_to_end diff --git a/SOURCES/gdb-rhbz1325795-framefilters-test.patch b/SOURCES/gdb-rhbz1325795-framefilters-test.patch new file mode 100644 index 0000000..cfe309d --- /dev/null +++ b/SOURCES/gdb-rhbz1325795-framefilters-test.patch @@ -0,0 +1,176 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1325795-framefilters-test.patch + +;; New test for Python "Cannot locate object file for block" (for RH BZ 1325795). +;;=fedoratest + +diff --git a/gdb/testsuite/gdb.python/py-framefilter-thread.c b/gdb/testsuite/gdb.python/py-framefilter-thread.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/py-framefilter-thread.c +@@ -0,0 +1,39 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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 . */ ++ ++#include ++#include ++ ++static void * ++start (void *arg) ++{ ++ return arg; /* Backtrace end breakpoint */ ++} ++ ++int ++main (void) ++{ ++ pthread_t thread1; ++ int i; ++ ++ i = pthread_create (&thread1, NULL, start, NULL); ++ assert (i == 0); ++ i = pthread_join (thread1, NULL); ++ assert (i == 0); ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.python/py-framefilter-thread.exp b/gdb/testsuite/gdb.python/py-framefilter-thread.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/py-framefilter-thread.exp +@@ -0,0 +1,54 @@ ++# Copyright (C) 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 . ++ ++load_lib gdb-python.exp ++ ++standard_testfile ++ ++if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug pthreads}]} { ++ return -1 ++} ++ ++# Skip all tests if Python scripting is not enabled. ++if { [skip_python_tests] } { continue } ++ ++if ![runto_main] then { ++ return ++} ++gdb_test_no_output "set python print-stack full" \ ++ "Set python print-stack to full" ++ ++# Load global frame-filters ++set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py] ++gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ ++ "Load python file" ++ ++gdb_breakpoint [gdb_get_line_number "Backtrace end breakpoint"] ++gdb_continue_to_breakpoint "Backtrace end breakpoint" ++ ++# #2 0x00007ffff75f228d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113^M ++gdb_test "bt no-filters" " in (\\.?_*clone|thread_start) \[^\r\n\]*" "bt no-filters" ++ ++# #2 0x00007ffff75f228d in 941595343737041 () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113^M ++# vs. ++# #2 0x00007ffff75f228d in 941595343737041Traceback (most recent call last): ++# File "/home/jkratoch/redhat/rhel/gdb/rhel-7.3/gdb-7.6.1/gdb/testsuite/../data-directory/python/gdb/FrameDecorator.py", line 145, in frame_args ++# return self._base.frame_args() ++# File "/home/jkratoch/redhat/rhel/gdb/rhel-7.3/gdb-7.6.1/gdb/testsuite/../data-directory/python/gdb/FrameDecorator.py", line 152, in frame_args ++# return args.fetch_frame_args() ++# File "/home/jkratoch/redhat/rhel/gdb/rhel-7.3/gdb-7.6.1/gdb/testsuite/../data-directory/python/gdb/FrameDecorator.py", line 276, in fetch_frame_args ++# block = self.frame.block() ++# RuntimeError: Cannot locate object file for block. ++gdb_test "bt" " in \[0-9\]+ \[^\r\n\]*" "bt with filters" +diff --git a/gdb/testsuite/gdb.python/py-framefilter-thread.py b/gdb/testsuite/gdb.python/py-framefilter-thread.py +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.python/py-framefilter-thread.py +@@ -0,0 +1,60 @@ ++# Copyright (C) 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 . ++ ++# This file is part of the GDB testsuite. It tests Python-based ++# frame-filters. ++ ++# This test is specifically crafted for RH BZ 1197665. ++ ++import gdb ++import itertools ++from gdb.FrameDecorator import FrameDecorator ++import copy ++ ++class Reverse_Function (FrameDecorator): ++ ++ def __init__(self, fobj): ++ super(Reverse_Function, self).__init__(fobj) ++ self.fobj = fobj ++ ++ def function (self): ++ # This function call should not fail. ++ gdb.target_charset () ++ ++ fname = str (self.fobj.function()) ++ if (fname == None or fname == ""): ++ return None ++ else: ++ fname = fname[::-1] ++ return fname ++ ++class FrameFilter (): ++ ++ def __init__ (self): ++ self.name = "Reverse" ++ self.priority = 100 ++ self.enabled = True ++ gdb.frame_filters [self.name] = self ++ ++ def filter (self, frame_iter): ++ # Python 3.x moved the itertools.imap functionality to map(), ++ # so check if it is available. ++ if hasattr(itertools, "imap"): ++ frame_iter = itertools.imap (Reverse_Function, frame_iter) ++ else: ++ frame_iter = map (Reverse_Function, frame_iter) ++ return frame_iter ++ ++FrameFilter() diff --git a/SOURCES/gdb-rhbz1350436-type-printers-error.patch b/SOURCES/gdb-rhbz1350436-type-printers-error.patch new file mode 100644 index 0000000..d06e121 --- /dev/null +++ b/SOURCES/gdb-rhbz1350436-type-printers-error.patch @@ -0,0 +1,81 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1350436-type-printers-error.patch + +;; Test 'info type-printers' Python error (RH BZ 1350436). +;;=fedoratest + +Typo in Python support breaks info type-printers command +https://bugzilla.redhat.com/show_bug.cgi?id=1350436 + +[testsuite patch] PR python/17136: 'info type-printers' causes an exception when there are per-objfile printers +https://sourceware.org/ml/gdb-patches/2016-06/msg00455.html + +diff --git a/gdb/testsuite/gdb.python/py-typeprint.cc b/gdb/testsuite/gdb.python/py-typeprint.cc +--- a/gdb/testsuite/gdb.python/py-typeprint.cc ++++ b/gdb/testsuite/gdb.python/py-typeprint.cc +@@ -31,6 +31,12 @@ templ s; + + basic_string bs; + ++class Other ++{ ++}; ++ ++Other ovar; ++ + int main() + { + return 0; +diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.python/py-typeprint.exp +--- a/gdb/testsuite/gdb.python/py-typeprint.exp ++++ b/gdb/testsuite/gdb.python/py-typeprint.exp +@@ -50,3 +50,7 @@ gdb_test_no_output "enable type-printer string" + gdb_test "whatis bs" "string" "whatis with enabled printer" + + gdb_test "whatis s" "templ" ++ ++gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \ ++ "info type-printers for other" ++gdb_test "whatis ovar" "type = Another" +diff --git a/gdb/testsuite/gdb.python/py-typeprint.py b/gdb/testsuite/gdb.python/py-typeprint.py +--- a/gdb/testsuite/gdb.python/py-typeprint.py ++++ b/gdb/testsuite/gdb.python/py-typeprint.py +@@ -15,7 +15,7 @@ + + import gdb + +-class Recognizer(object): ++class StringRecognizer(object): + def __init__(self): + self.enabled = True + +@@ -30,6 +30,26 @@ class StringTypePrinter(object): + self.enabled = True + + def instantiate(self): +- return Recognizer() ++ return StringRecognizer() + + gdb.type_printers.append(StringTypePrinter()) ++ ++class OtherRecognizer(object): ++ def __init__(self): ++ self.enabled = True ++ ++ def recognize(self, type_obj): ++ if type_obj.tag == 'Other': ++ return 'Another' ++ return None ++ ++class OtherTypePrinter(object): ++ def __init__(self): ++ self.name = 'other' ++ self.enabled = True ++ ++ def instantiate(self): ++ return OtherRecognizer() ++ ++import gdb.types ++gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter()) diff --git a/SOURCES/gdb-rhbz1398387-tab-crash-test.patch b/SOURCES/gdb-rhbz1398387-tab-crash-test.patch new file mode 100644 index 0000000..c8fe7b4 --- /dev/null +++ b/SOURCES/gdb-rhbz1398387-tab-crash-test.patch @@ -0,0 +1,454 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-rhbz1398387-tab-crash-test.patch + +;; New testcase for: Fix -completion crash (Gary Benson, RH BZ 1398387). +;;=fedoratest + +diff --git a/gdb/testsuite/gdb.base/tab-crash.bz2.uu b/gdb/testsuite/gdb.base/tab-crash.bz2.uu +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/tab-crash.bz2.uu +@@ -0,0 +1,393 @@ ++begin 644 /tmp/libgcc_s-6.3.1-20161221.so.1-objcopyR.debug.bz2 ++M0EIH.3%!6293622@"44`>Q=_____________________________________ ++M________X#\<>SD#OM[7/HAP:R]\H#D"=!/";NP7!]OOJG>U[N;WW'KVV?9I ++M[[,[X.\/;%2U``[[NUM7P^T[U617V#12M]6M7W;M7CZU<=!]/8WL[LI=AZZ> ++MJ5XW;QP]W]DVHY@]/6RS= ++M8[:2][W/F01Z:GIID,IC$GHU-HR$:@T0F ++M@$PC($P"`$PF)D9-&IZFCT-4\$TRI^330-$TR>32>FFF@F!H0GJ>TD_*9!E, ++MR3Q3/11M-,%#T-3:-3T9(P-3T3TT@;1ZD>C1E,AM0:`@@303"`(Q*>FGHU)Z ++MGDFR8FFJ'L5/1C313R3U/*?JF]&35-J!Y3U/TI^1$\IZGFBGJ>HVF4>H])ZA ++MZC)ZFT)H>IH]0>H!H&RC0,F0T9E!HT-`TT`)-1(A$R&J?J3T80]313\F0GHC ++MU3:90\H]$]3:C93U-!LH\IIZ$]0R>:D>329J--`/4_5'I-`TT9#3U!ZC0>H# ++M0])H!H9!Z@#30VH#30-/4T'J`]09%$!4\)A3R,-1'J`S2#0--,$:/$C9-3TG ++MH:FR9-(T>D\4],HT'I`/4`>HVFIIZFR:FR:)Y,3*/3*;"FT:(VIYJC:FF)Z: ++MCTFAIZCTAH:#U!F*")1`0!`"9#4Q-,FT(R33R-4VFE/U&TU-3RGZ1FJ>&H]2 ++M;U38GJ-J3TQ0Q'DU-'J?JF]2&30-'J:>H,FC1HWJ@#RFC0!Z#2-/4T&&4T-/ ++M2:&(>D'J,5#"1JH5B["KJTH:1R2I95!0TXN8+PQ'&*+8%8JVQCC/1G1D0A-S ++M91MLJJLK];M*G>^]MGIW=W7E>KL ++M)MXKMO7VV\M77ANM3H=6LGI)+AR&CF'#<66)4&4S6:;*26:S5DUQGS$+>97< ++M!3.,U$LQELITU,X3Y5[GW>0?IM4(5>Z!^AE04E8=:H(X[7T$U.`@QRT\Z]_" ++M7?`4-8Q_UDP"AQ@$1,B`G(D*S"^7Z%ABZ-%T6MS+#&8M+G ++M)M>_Y9ME3-K"RMO>,UK^9/4HYU5!3:6'45^1-AA23JG7FH&=KT9ZK-!6>?\- ++M;_HD;$V3C,[X\-20B*R?`.(:CK$3A&J2!XYI6TW[U*HI*560[F!42LB.:FO9 ++MT2S-`KC"H/^S^JJFC(54?*/HIBKH,!73^2++62,G98Y/*,\,%R,Y08$R@$&L ++MC#"P#E53*YTZS&>L\]4*"<8&2^]*I?02,46;3.V(P+2P`3$>F+HNTY/(%Z<` ++MM.P&I]6,NED[M1J4`O?!J@8`&>?1 ++M%!8/]>.7UF-'?ZO,O??);\\L:3X7JN-O^ZWAPV:'ONI*N$I2REEE+$\Q47N6 ++M)NB0W\O.LZ)TMD[9VG1NS+?94@_.$$=!P2#U2(8;*%.99OOW:1@#`W]ZV:OR ++M1IWEL,R4\*2Y2^>SP[^QB ++M_,U-)GY3;9KT/P=Q.GX.7G"Q:>QK&9"$ ++M[#-J-&>2W>*T.XDRFC(,4I`"ED(D0(($(R0#&6;D6H(.:&R(R,:JBHZ!54G< ++M11T9V@K&&$`@8+T3IN#,:<5@P(RTBD1%(JP%55$2*#^!4E,%ER22`*-**JU6 ++MJZII6%N>*+(`*J_?LDI@")%A1D1`@0D?O:UXU=+B+/%.C.3P3935G@9N(=B( ++M39SA1$,K(<1`/."P@;M&4XI&*(9N(H[,#92F)PFDD,V:;%@V(`6%EHV(`6$+T`+00*I0;U ++M`+6F`+<5+:@OPH!:+<%V-Y:H6@0ST6@@$DQO&U0"]M7&.2N,;AN4`HP8H!<7 ++MT;QP4`N;A(R`&`P88BZ-&+V-:04?;20GS/LL>$_B,!&RT)$%@$(*)!"$E!7/ ++M#&8("!8N/9=K.,FB'MY.._/VD>C9#^`XS.XJ/S:XR1TI^MMN1AER0/FI,QI< ++MI!S/-3&8!4S2B>DK$=5/`G2Z><=$L7)SB`(%.`?MXB?J?H_!K]]%1:Q0>>D5 ++M@*,0!$21@`8Q[N?N_7_H;4[#S/![4O,^[NUOC?7F"'Z'YMMYO*;_)-K^K9([W=II7_32_/>'@"M-U3'I3>\5F/7!,>LN:H3*N!L;; ++M")']UU7>>-S\,?K65#!/&(542)(!76C2F<92T@@7G-NX#D][M'6*;YS)AF7< ++M!W7=#3Y1,RGT_`:&!`EU8>JEM/&JEI"+[5?4O\_]DT0",,XH95*#$@#=L,AO4L+ ++M1BB(3Q$X?C1IAS!$AY.>_%4]AI=*'&F6&\>U;\YG,QV14-HP9\BY30H/3].G ++MTW36AQ.N"4&8U(-$CSEJ:IAKE6J,KC=.U9$\H:1I/5!WK37"2WTTCL+"6YJD ++MVV8?W_`MAI=@)]J^U-YAOBS;:'(S4SPBJP))LEQ'+GK;<]US[@5VN)U.SEI] ++M@B6(>WE8&UNN(Z_Y^_U`>?=I*[4=\'V/"\YOXXU=RH7$2P ++MZ8AP5/2@#F" ++M^(R"5",K@5=:R=P=>/%\_!=LCS0>*ISX$*;G?\$9(P-<"734Z=7:V/E#,EJ3 ++MR#)DN].):$0+S";E13Q8UADO"%],GD)5UBLWUDCN34&A3.I3U+69_K:PL#9:%6F) ++M[AU5/05TLKLJ2*QB0,US:"U%(#G!9N81MN&'7T1O*J^]%%^#HV->-]LNGN*= ++M"C%H8>WG7$,^&0"244E4:#V6Y!289:<&E<<-ZGKH1[>$BW"MUU,#SL;,,),V ++M565B6/E!Z,H8E#]WD=(P%@X(,/C7GD0D ++MP-:,NZ$0>8GQY;JN=^^\XXXN0&5=W>Z5]AZ1HYC%E&S'8*.!D@5[<8]"EYC) ++M7*.I"&7-3RH1V#K4>$VO7@MZ*G*`]>M6049!\$(C%$3O$(">"B@IT'Y=.=H)`'G ++MP?T,;OF2.6;FQ;,.#Y<(PT)/0+73.OI!]&#-""F[4ST51A!FJDN2B3PA ++MCB(Q@J)!V14/5@R7:FG%FN\:RY!,K%>T32S-L$$!!OM9<,*\;?V9^D]EW* ++MBQ6*UR5PQ\J=9&)2U[%%,*&2VK(M$(BHTDQO)TV^76K`\E7:.HV99X,B$L68 ++MSG"]BK3]QP^-(JA!,M42_#=-`S`(@)8T4R,S_Y[7P__.8YW/0JJJJJJJNK8X ++M-=3PO'T&C*J9)`]F0`%K%$*P$#"""'MX"\OETF6EW>4IT9RN8.;PY_?U:<^? ++M*X$4&<5`%`1414BR`"1@4.DH8`QG9@#`TT7)^C&:7C@IA^%"_<3WTX+Q5*-=*7Y#/IE(_)_ ++MYYO52X/>^`A8NS+]GQ6$%J!9HFB5*_*22UE#*>TYS.T"1U[AFR44'A(ZIZ$N ++M7O')DXRK49/4T!7XG8#F7\)CF+,TPJAPV;\#4,AD7,Z/*?9D2DQDGR.^]LB( ++M%[`,/\]CK_:F,LN`#`T>]RT?A*WQ[K='\FN+&[/YKKD[GOG)".MPK9KOE&2> ++M4312<,\Y^C:>3=S-OHU-R)^F^*9H5Q"=7^-'_#GT?0V-ZX-3_S"6N2Q?O;7: ++M=G#ZR=L/JQG[ ++MO\_!J];07#9:XP=/JNC6V$KW5]`_.82T05/S?='X=WG0YS.[I94'X$?S()[N ++M#_Y@OQH(_`@/2399*2&\0*8=X^IVZ-3#*-44=7^#1YU#@<+A<&%:']\FNF[I ++M29_6J&Z$R.&H/.2,M8LDC$UZC*6*@F7SBW:"GQ3@-&AS/D'%[PAX*Z.!&Q`! ++MK?M_?V/CA,ZX91WMR-A0992O)T0BR^HF9=VIA-3&20"GDL&" ++M2O*AJJ$K`'3#X"@L61'"0N\_-&J])J,%%(*O_R0A*R3X>_<_]4=+TNCF/6?< ++M]IGY%UQ&M/IX7^;)C'TSL++)C1,MUVW257A0K(-$P.$V@S/RDA=MA.W#)`^< ++MI.1!C(@-*E;AB)^IQOD_^YWQ:2]K^31Z+%2J$@W$OT7PD.02BH.>E@'022(E ++M3@Y$+>HD)''I ++MK!<&,1@9T",6@FYM(V?[Q8KX6%]RJ`*8F:0\/6K-)X%%08$0"I?TTOH7J&:2 ++MP"RV[FF`@B!MYU]ZA5,A0DG2_Q)37"OW#@@D%P1P53,Y9BTRN'V=+Z4!-QP> ++M0Y0QJ(A,6"07X?-ZWOBHFM&@L1]UFNEG^IKIM+R/9>.LI"N99-[D[:+A+S@] ++M9SU/\?K]_\Q%2,`!A(D20!4>@D8$G;HBBL(!"(2`J'98-5R/N2MRE[9.N+,! ++MO"/VT9Y%Q@(TM(/8\%_VL"*'2P^*D+N2,C?4!XXM?3VL;&:5WJ^+#L>F7!H_,N ++MIUM`#L5Y[#M_O]A6"9J&&AI_78:(A$4RYACP^Q[,#B9?EORFBL,[/%'C)]'[ ++M.CACW"3O$#=`(=[_-\UU>&,/=25L+C^"'BK/E0!N1^$_"JB+_JPA`*]8CO(: ++M`,.^+BG;`ZF7BV09<[-_][:8^4KLHF.(1`0<SWGYJ3I.3K!0![LX-.34%X ++MKYZ.+[/.9+T`A+UD=Y@88X+WRYRQ#Z.0GAL_X^DU8%6CXLM.6/V<%ZXA\X\>Z?;"LR((5^)BH[ ++M9YVM6QCU[L+>4:^0@[(+A[*2R473>#_#80G05=[MO!0B83]S4Y#69SL\FU;, ++MM[%]++>'XGB[M<9CU9H/*ZY^J8LEQ/Y>=4H#=D ++M076@OV1*HU!09+VY&I##%336?/5%)M>9>5%%"0;X0^D(!5LP%ZR;J#4AL2A( ++MVL=+2L3>4N`V%1T%AG`R@("$$@E`4)0]>@`6#Y_ ++M!?KZ5D(#B^G8"OV,(-.'8LE-"R&W?C;5W&U,*%TS9#DQGG02?LI;-V'6_'VD:/[B\[^!BK._+R4O,AIRU>SJ67X@ ++M9BGP5'Z*.")D_)5(1^2U>5IE7MC^?6;KS0@W,1]%[_1Q>7T[6YJ6XJQ.^W;Y ++M/EBI?KRW$W[U(3Z"^#'K&C9:437[_,^`K\[(S?[&%\T)U''KMU:$5SAVI&?1 ++MO)WDB92)(QL1_:14'+!3-4<$"%!A'EL*M:SVOPL/C22OB0/^XF ++MK<69BJ[(VD8/"J7=>==O$-;WW//)P10\;N+6!'EH$U.A3!PVG>^?[V.QP)[E ++MM#M7!J:JJ5FI.V-&A9([(@[VAQ'!<$'(1S;SN=_.6>^5#L1AQ&_D'TL&-9`/ ++M68$)7J_190&=D@#5'\F^+AINR/5:*)DDUZ[PNR9<+9KN3=Z?U+GOLD3<33S= ++MITE&9$Q@::(*8DUSZ<4:QI+(U)BWK2;WBIFENWDW[`N'(FMFG:Z>V\N0-.!C ++M]U#!U]T8<9HC9P8<^B_][RM5^;"??IE6G\((HDSM:T1.%M7\:[:DU2F*_DM4 ++MYS/(B9,$-F_^*?"5:RW^<#:*&>C'":.!%4R6T1D?:_G=$H[JG;^K-&;DAU5X ++M&\$R"F*J1F;BV>]?N_E7K/--@V7(QI0@&I.NR=19-&!(=T.&_,X7T=/'`?1* ++M%W!R_DXWII`J:7?>BE$CIAWG*'YBZ$Q'_%_<27$JIQGYCU"!+X5C(PDS@W[\ ++M7\*E`_CB_W[+#`2HNE+Z5(.40BX]1`,]W]9L2=-5S\JMIA,-W<&@; ++M^[8^O76V>0CBYD0'SW%)\GD[WPO%X,)C%,*J;0T`C:JCB'+92>O:H';H,-[R ++M=DRZ#I]-'NVA`SO3(FDOZW8P4EL?@9A=5^0Y7FCDLWBFFUTVRG&%.[D2V^=` ++M5#K.+)QE0NXQY^M7*(C1-,N?>U93STMV@CGTY>&R$>RPK3'2R2*?5I5(24S/ ++M3K0$S`PJ(?/0Q9_SG%)RTTU3HP8:\7'A72DJ57`^O/MG`YY><>SSD?WAH=M: ++M"RO5HS+T!`\:(`9QAYB=#3-8"F2'/%UT1%Q3?D&F$[TQ2-M#%>'(OH`!2E./ ++M)389QV:(LHH6GG+(3N1L[?82L*K4K0&9XD2X6@M+0N,)U%K,T-":?/Y]\MK5 ++MK_Z:_I>'2UZ7+0:AKH\.K%VYPA6E!DHVG,PO?KU25M)+DT,P/AGJ<1$85R9% ++MPF!G=#T]U45@%VRRB)A-TW^ZQ(Q_ZZED+F:K/ ++M%[7I:0$4UD$#WL$0]Y40\#A.AW7;\'O>+#S^/JY/1OZ/3K>4XW>>[AD]#5PU ++M:AAQU[/W.(AMMJ>4Q`29&#B9U_*;%>_:VI]+:'MP6ICV=R&`\X8;_^^!.GMS ++M[CNN,)<#02E3:J,LVK(;7-QHKD@J'][T+:HKY^3V'XE@FQ3YWDML=KUMVS9T ++M--UE*6'ES*\2LIZ+T;BH^&&6:[X%`OG)G&&W,6 ++M)H$T1"14@OL:/PY6'YT^RE4`/70$D`%\6*J_[>]LELD`/3H$FC6R':]3T>]R:N[G/F>L^-Z8W(@05",604",9-Y"A3TN;K^7U_D?5 ++M]+)>,!C#_7R<;\D\CX1PL]S$^X[C@`P,/0"-31'T61;6DR@][DZ>GRX>I6>`E\3;J]#&J;J-QZDEZ ++MN`Z"S<>Q9D;G8V4DQ'4T:78NL=:(*1TE&S_R-!0N)EE'3[0&B*! ++MXQ*NL=1!1^MME#CP3"#Z\>EWS"6?=]^))"@K:@'@@WDG:-N)I=7TH:&]V:HU#$8H@2H7&5C!B8/< ++M>+*R`ZN=[,`1\>^V(NU#+I]][;J]J$$)=@@8!C&8F38Z2ZYW@!C;&*7UJH?S ++MQ*8,+&MJ!D'$H2WJ"=:##R1L!V.SV:FBB#KMJZ-A8U=P'F)%DBD+Y(]`W<76 ++M0"B`P'7/I#2C1W`Q//G]JRCF4N!U6V.,:6B(^'F_PM]?37_I^G\>W:F,#`!L ++M#$,?SLN]D@92+./&PT_IX_D\#C]]P.?H=A[GX8-3>EHG#-5Y:9#51"%*"@8, ++MR,#P4(,M6C4*U0!009;_,O-S^;=Q%1U4]/RN)VFLJGPB`SJ%?B]A6)UT%0>\ ++M7?CM)8U>&P!P_@=A7"`%&/ZL=2/B:J/Z>/Q_QN./XO]HL>FR%6\R]CX<7IV1 ++MM0K6BSY&M4Q1/\^R5ZB<#`'BZ1KJHV!@LE\&)<,`$827-VNZ1PXSI0/%T;N2 ++M:'A7:2NQC\#-SZFY*DG.9SA'QL/C0XYFJ`..@)-DDV29VD5#RDE>]G8Q^3VW ++ML)IY;;C3C--_D9B/%?0-[\A)B^]1S.A,'R5))?(UTRN%AZ[R=7^#1>8QD6;? ++M\\>9'WS7+Q2MMQB$4G'&LKKE_5:P6VHX=!IXC/A?V!&;E12BA`S"D%5]>PD& ++MLS[;Q-_NX\>E1,6!J!`.E>BKU-7><]ML_>YUY`*]=J1"%3^'=ZG#M`_=FP\5 ++M_1@U\L5HC!6/M^AK=6RKL$<4WMRZ#=/)WD-JE[^K[$5:2F,WF$W:PM9.*M4Y ++M,1F3/&3Z4AKF[0P[+OYJE&NVX5N("$H-U)M)Q]U1O+/^/[+5!F0AOSIW)JO1 ++M-W"XB@\FPFF^^+'I5<9E=\R":I,J$XM:0Y$V!"D*0/[J>C4]94.6F>7>N3E^ ++MZS4N7`.VR=BDAPI]W\W2SM;LA4L[C%P*HES%0]GNJ_4,L#<[Z^]\A0P/G_9< ++M-GJDQ,;U!M7+G$4.Q774HG@<3ZR^,@.(C5#=9R1V,1BJ>G;B^X1G8:0*J9PI ++M0O;M#TOG'I,BH@=IM=C3M.?3S+JKI7#,9^+T0K`E=MSFF.*<'F(&]5Y[G99G ++M$Q0MHQB/4_,W&S73.T(4?>X?VDZ)REP[?IQJS%,A"CV=$(_EC6+=\=C[AZ^L ++MT6_?WU:<<"*P,*F!BTVR-7-UZ8R*<(0Z,?*JV<():T68@T1[:_##<>AN:?DT ++MFK>X6UN;;41]M,=73:_5`8T)T.!>[ADD@M$)!&9DX4_BU5+'$2![3L[L]J^Z ++MNB>(E(74J3W"%&E0J0Z!0A1"@K/[XD5C,*BGM#&WV3BL+08N0>"'P6\JH&%[ ++M_'ONYQUCK5P8Z@\6BSVU0/@G(./1*RH.1^?4F$S2GX":4R%3D!X_,0:@()!, ++MX.-/LI6"D^5H9QOY(BMN;Y[FTCO5U^=_V]-005[^R6@N"H]!I"@*J2I9445_ ++M?LM+4&A$:4*A`@3/(K`5895(TB768N-]$Y",C9W-PTE8>7<6FSV_800?X^2Q ++ML6'"\!JHI4"AC#]EJ"+343WC0"P%!X6Z=Z+>/#;E\:3H ++M*J9Z)ZHG?FL$!@@([X%`13X]*>3\4W=4+!:?80*1;@X_:7`V2$",%O%+Y;NW ++MSK?IH.1]7FZJ%F6T;`NP\"[HC>M:RB9@9CM ++MN5V'C^C]SZ+:[B[]+=^EM]A+]F_!\*>SA;M^^UT*,[^Z802/D8,&I$20.*F'Q/!Z_P-@_2/8^OT^"0@))K'@?MU`W<04B($7/6DU3`./KY ++M:1.?^/Y_JBD3"%"(29.P4)IHI_DA+0R?6Z%LR#'D>>-RY]_<[&]";4S'N9LZ ++M"Y_Z2\H5#%Z.7J?>2_*H\+?3*3@?E2>)5$*M1;0//-@K!L7>5:>)F4[WO4.>,LM,94O5/E$SMAZ>H ++M\![?H>XT]I?,L*YE4(_XY&?7:=O,PS0::.'M8IM8F#)34%%76)^HW?:5.S=Y6&,4AE,AE@%G2V47(DXEPJT)0 ++M..PL_..*EQ-^+I,4 ++M56.:ST1Q#2EAT>"]%8+(?\>5O`*'!.B37T7>L6.7PW*[?5@`6%UD\A!('2L+ ++M.$R'/6!C>GKC#<5U,GN3M%F9WZDL`#J-4OYO1/K#W'8/.+L-B!CG ++MX>C5+"2X.U^#\@\X%#M@H7^B?UMO@_`IC<6<>OX?O"ZMQ?_D-P]Z(A[$]Z_% ++M+`/EE#J)UQ1L@*%@C[$1"K]>"A+B&;O@8'Q?I;)U?/;1OP=SD7X(0+@/D`C ++M/D>5DIGL#VVM`4V40(D($48(AZH0`3N`(J^_Z7C^-$K2C]+3I-44+?CE2BE: ++M#.]`(@$(E,*(A?*OS&D'J%0$X>>2#.C>W]UAB?==P[^@X@.USAH$4HVQ5N0` ++MZODUS#,W(T.=7,.=4Z"1PJ7D&>!D_"SMO9HN>!IEBHY@LWU&4`A2C*%!*P@F ++M8:NPEZZ1OJ+8!2PM4`I5D,(BM2`%DHF4@!@-D)G$G;9"2$@VMR@%5`*C5O"T ++M4`BYZ*`8%I9>WMXV(`8>GP<;"C@H!&EW$,0`H)-61KVF4`"BE8`&6*P(T5MY ++M[,,;ND@P0:%;$:!6,4@"?R*`@&(I`?/V.OR$P*:HNV,TP%#5A;Z`2JI_A9J' ++M][V!`!.$/:?0EGVF8TSR<_YI`4.0%0RB(=X"A!$/`!0OJ`)50["B$$0M!0I0 ++M2"H11'R04*J-04+S-FYJBAX210"0]YV;I/?,69?B1'DF7D;]MP`1`).+&>KUBK4B?4=S:MC<=XWW$U4KM[G[J2EVCN; ++M/@/-;<73F[?O[4P!0W`4.`%#R=[`2!W.O9K37>X]!V]56Z^)X;I9Q1+C!41$ ++MA)"20]?3*9`AEP?L?*3)N`Q3!3D0`LC0"E*)%1I%>]!0VP4.J"ALW`8GBTD@ ++M#L^)$P#&[CW_!W%E/`IFIAB>S2DGPA)&9)!F9F`A"*L=/@R,)LXZQI19P9&2 ++M15")D#(0,00(D`:\P,X<1RJ9G3.Q+U&^0G`B'FW@#<8A8&_T9K"I@@00;!0V ++MFV+(\9;GZW-.K6N_:8*<.7D+*!;[0KZ.DM+/;Q1#DO]1P=U0K$SDMIB"0,=)TI=B1D1`&1@9+]015`AUX.G%YCZTQSMP&.NF[Q2D ++MLFF^%S/`X*6,"GT/\-3\I.+EJ[:-C*DVU%JVK?RT55HA5M ++M=IL\W`ZX8X'%R6G6UJ($"HG#NPH6)[9)5#I>#661&#'.,(R#0BA?#,(=4P<9 ++MC849O*SG1$]L9,1UH*!1HCV=J7?)NP'\_L2T\!H*$(67:P!AE18K\Z$!Z8K# ++M3**H"OOKTP&`WF3K!\@2',QTC=T"G1R-J+][XLV ++M(+8U@=`1MFP\,V/E5"&F8=JAMA>ST4A8R]DFB-V.8J;>MYL^"G(IU)_!1T1S ++M1ZKUQC]A"6W+L==(4)^N[[/IW.W'V>OI3ZQ3I)5#=,;"[4`WYH:H"EIO#QP] ++MSLR@!H'@:TL;M]IPBL<^H8]HE8\TV##;I=QSPY_]QF;P ++MM/>O"3T)[*80=VMJ@'7HE+(S=H(%<+PY^)\@S]_< ++M;HPZ-X4BF#W(*'(0`K;8HF.\+K,J(@7U(\$0%_L?>;GX@ZBQQ8+SQM-(KZ,T ++M9C:"/-1$LP6-!UB!H'J`"Z[BU1&&*B])JICY7IM$"$[=1A]Z(`N00(;F^!CC ++M5^P%&$;?H8DTT347F=$+184JBY0.(9!0,+$N[M:9UZ'XN^`PG`&KU$+X:VQP^/6EA!K$],NI#&V[..-H-1%"/>\UILE?@CGDZ_->"R,B!V.L@$ ++M\&)YAC4=[_/OLTGHN.\HM45P\AYL%3UTXX8UK89FA0IA!,I6./VBK\XR="PY ++MX$>0E!].'NBXP53HL[#=M+887P^KJ$O*\J%%R3%HS53F3>PW"W)RE^0XP`&B ++MX5S4FXKO7KFF=!'B*40SE(LCGE4:[%<'28D=N(EZTAK?KT,J8/+0;J:&KD4Q ++MB[OTEDH1OBO+GDKUP8>/$/I/K&79VH!DW(/A#%O11Q,@?43>'>UDD\ER#*FT ++M')J(=2J>5.VW66K+2X(DT)IN(PK1W!R2F&OY&3M18,?"*L,:G@I^8P.Q>&WF ++M#.EZ:?20E*9N80_^%7)T'JNIOAM2U8J7U%SQ!5SP<%>O\CD:[T#9,"[%5=`GHARQIT ++M%\QD4*(FQ4)1^"94)MT,<05.QG++X<\&]/K$6S/WCS493!P1"*-:=F<4IPIN ++M/+HA_?]9K12Z4?9#B^ZG``&8)YPC&'J`:.$+6*I=A&GX74>)[[HP]&G1Q'WD ++M&I$34#4[D:E&0X>6!PZ:3'B0^W>(,D=*^/92`7Q>Q9-VAPUEQY3OTL_HZO#; ++M>#LA+:6P2J`"-2V,RA8$1Z7F[]*K)3,'CQHY$78K\B']@`8P%]=;,/U'E7#N ++M*&)X?MY1EQ%FK,8H:9K>;;!S?'N^@'EQ,87%WG+>)!%3C>! ++MPG)6ZNZG!P'@4%04Y;)`BM,$\7AB]3RL4:\XW7W00(".LJFSTKGT*M2TN^L7 ++M%@0`B`(A<`$"(1N!QX5FD\?@KO;H<;O.81WCXCX0Q*/U9@/0C ++M%(`V()O@A7*8\:4@&#F)EC0I05R7\PBCBCE#2XF,#"KCFN@W ++M>X>>N2Q1:\ZY(2F0,Q?:''2/&A[N9<9W,W"C.BFA"X6`#S/>PH?FQ$NZU?L5 ++M:%KJY31\`:46RYB8I12>4+@=KUF'V84*AZ9)<=+3`TMQSW!&4&1 ++MOVK3F)P\F'+M>@6I@UR)FR&V&]@54]WN43U=;>HIBQ14'9V"IBLL3##*Q],) ++M]QWNQWGS@"VU^,'ZK(O"&XX73+[$P:JK;=PJN[)=#R\,!3RVIIE4%#$M#M:[T;+*^L[L\_E->?;7GBTF.WV'SA^,C ++MI_(U5I*^F0K_A\E2M,7C("1S"";,76BQS-J0\@"(!@A7K8LPYTN8I$"81B%1 ++M`2=VC#?M08HPA"!^5`AU)@H2LH%WI7IIQW$(44H5I@A&_(*0&2]9BH$/S424 ++MA[ID(4F0PG+%CL8%'F96&M\T#-$984"5((`GI9O\^J`G)"3 ++MF$F&UPO%T7I"-_4@?=<7448N.,D(T:\SOC/B0Q[.&;'-BYP3#<._R"(7]"@2 ++MB;[:-2ACE"YUZ)"\@RP@*&P7C0%#GO?PG1Z($QPJPJX;0J% ++MM77KK\]``=R#J10T14"4D%<\6L+ME\?UG3^>^5U.OD!0]L0`3B!0@@KR<9-P ++MXQ-;L=B_?>*S;KP@@@<.\Z#.-M"Q%IPM$S$,EA?"(H)'AE%@E>(`38$0KENH ++M]!A=)P]Y_=LLSAE$R%+").Z_8;-;K9`DT\WCWG0Y"P]#];[*TR"=W$V,V91A ++M71,P*$:G9H`TMG,HETJ\/!38KNF;OK\P*&5H!OJJO>I!4(\(*&-IF"F@%#?: ++MYPX,&FHI(<=[S*;`*%BV3+ ++M@P&<#C!ZMB!2%%`=4,*!O.H4S#`@H%NK\B\5#*>?XGQMCF8W'\*G4SGM?J3$ ++M.[`K2U%`44!BQ&16V,KX'0*3KCCC(@8G90&TX@*';F\]9.BEPZ+322R/-M10 ++MR5`$IZ@@N9>,I984,W=;)`QC)JX*%>Y?0&'-AM15=<-%!(&;ZK>!O.*&]IL/,LNP44\D;(=EVWGN. ++M<:*;Y.R9TN"O:[A73N%1/,)PN)6#(&+%6B&Y"2A!;:[G-0( ++M^-\(=F/B/>'L(+-)POFTHV%?R5\SNC[ABBN!J7%-YELS%@L5(H5@58P5D`B` ++MQ/D!-HQ7,::HBH&,@RH3&"0PAK<0`BHRSV)WVT<&3@">YM+7(7/6<0U33JH% ++MFYS:'!VWP`!*]J2!E)"0B0B*((HQ$11B/WIB!1L2$UPD9"-3(1C`4W^Z@.T2 ++M$RV=VM%5165C3(]7JSZ`N=#Z<"=NM9G/\83I['_K/4_HWCFKHWV:J:Y?Y'7A ++M?DI$1`BM`$0%(``A]#ENPDS3Z^)MN7]3\W6%.*Z'<&R.8+:@@0!@(0% ++M"09`0($!0@H)Q;WT=+2$%0GCY,%V.FV#8+C555,5:JE1I*&A64J4TRPD#?A"`A7A?E=V;H^5^.-Z ++M6;9:`B>RV7/ZWMF<\GFAL7@"0.W=<"A9CT-E%!,43[^,@)S]'FB,H9"!IZQH ++MH1S!EM)#>P@B%+J@H=P:#%`(H!&-^E\:4(U/%V"IIP!0VP4,!8N3#&7E(4*% ++M)0E+QR`H8:"X`T;-Y?41POCSN=O=DYGW<]63['4"AD9$])!#N0$%Y%49R1H] ++M6*"?%YJ!HJ9E39'VPG`9;O/EH#D8L95,.A8F&DHX/>60794`1,M0S,&B"%^> ++M[P>L"]1T,P1:P($'TD0"Y41OAU@4,@*&P>W@],!U&R'%CMFQ:HY5&CU!-N[: ++M:`]:H6HH)F;`H[WL[.Z[\^9ZZ[8.CHFX(ZCAF4T3E@H1&D:F)3>UXW%).3O] ++MRT3:,VU>!F(A42\]S]WA?`OT/W'0ZPB&3&:)2,V*VM25/IZA($,I-Z0HI"08 ++M-.R5&JC:35G(%UE`@`EGDP"BC`(HW^#4+@4(!-L%"/8+F@V"(0E!$*(9H2M" ++MHPD"AN&[" ++MHYN6'+C&PP%&S;A:II;HDMNP,&X`2"C@&373*.8%#/6+@=`;!$.`>9,UQMY*T*=9H'VFCSJY7!1 ++MH?-G*%!;>7G+:^;0H7;MI8I6M-//XE"IS@R@H7E ++MY\2C1W-"$VZCS`4,FYEC"$C)Q.UJUX'2_3P_3?C7Y81 ++MP,^I,KDUEX*'2RG3Z1TR=K[S57UI`^G-6<@AIA:KW**=FLHRLF,>RE9I:;CV ++M4C_OU2_?Z=CQ.71PKA'F+1J.K@V'#!L0F\Q=I##\/`0="-8S0ZE_`R/TQF'CHT4`W8<[TPTZU!0+[.[FW,VK1354`PU6:N@I$Y ++M1)%S)K0='IB5-T]&)5RK!@S/9"_3E$4!NNR>F!0@9T1/(CV^`DDA/[34!0RQ ++M%#(P6<\X#56L2%-:EHOT6QP7!X.0;!#X&/ASC>:8LLPWEBS*LKKB9-)5-!59 ++M;6UU`W:U?"X$VMI5J-"JJM33NIPX&OL!*OGM;9XNSKN6C=V;OA4M:TIL8[8* ++M%^J)980DA-L3E:P4-XO,2W1]3!ORDA(8FT"AA0@TH(;+`IJ,.ZW.(-U!^J\((H=5D)E'S]CYGC\FGS[,.=D#, ++M(@6/J18(LK%TQ`B`(48]'1WW<%0RDAXIVF(Y#P3)VT/;XM?VC8[E<)6]2F'B^O^_4N,>`RGOW`@G[W'RU`?#%[PDA$DU(]^8A?^ ++MDQ/MS"1D8>ER,>3H3/'H7"ZZZZZ8`23.A,Z?;PB*/NR+C\>IA[S;IO[X\L(U ++M*8+6$!40?^>X!1K^-^)7O8>D0_%NKYCSHZS]:)( ++M#/7AQ%$8&:1AS>,M=[MMCGM6%&D&#F`2`,8!0\5[J>,"A_;L#]"=R+AE/7]C ++M8_=MCV(DO(2>>\_GL\JRX/G?045JAA`"?.G7@>0?@4#[;Q3V6/>^I+CR_SZ/ ++M,QH'S_0_0J>U@>)/_$/5:-1JY7&7'UTX3B"P`2@J&]3PK1Y37045.-[&RU@C ++MRZE!QRM1S7R%'CX/#[_R-&9Z3/H$A9[*ITAY+H87N/MQ^XRSN=4GN]8J"*9T ++M4R?\IT_Z'OD_W1@',I\5%O.?>V!^_>KA%_VPS55;10&&]E*IK?KLI,/7_/>L ++M^UO:R&]I_AK"3J+\;_ ++M27^:>[[K:'0_IRO#AY]*0D\W_]V,W?7WO7[;][\4N]4J;74]OKR#I("ZF)[\D.+7[JW<1M_S+T\R07]^.GHN2N_V9W^UAH/?M6L(]G=;K8`^ ++MNGF*OQV7S(P>`QF$K9K.8#_/:_`86%)Q#=W]L'PKE*TZ/Q/>W0X:[]Z!=MVAGZ3XE^R4@7Z<;!&Y2#\_ ++MZ)!2!?*E\$B%&8XI)1DC5[YX0Q.D!U5!X>T_#9.<7W8\W8*\2(#[7OKPL/%P ++MMCZ'U_NJ)T\='S>((D_7A^ELI=U(3,[P-9[+TT'PWDE'"$\!X=_\_).ROW^? ++MC=.S-W,8.>T2CBVG&3T>S'H/R==M"JX)?-VOP7GM- ++M?2\':;;5N;OB<3>9^20W4&3S:/LW:AARVH-G6TXL ++MDV\!)L(@OU(`.H@8<80FQRK)$PE(T\YV=T-QZICXH'U:!W.%:XYY4M:_.D`5 ++M6YB":A=D94"H`(#`W"$#%A,')0]-U:>&S":X@W%\BOH3^V+%,$"HQKE""HB- ++M0A!C@V((WR@$O#G3>I#[/G[2P@U&5UR47BO1?WMZ5$;Y`0%V0?IONU7!O;OQ ++M$->N4W#HL,OL_MU_I-KT.>\Z;3O>4:*LX#Q,&CM7">7Z$\6]4ZMY7I=NTYM% ++MZ)IY48P2K*WEJ^2V-(B`/`IKS(?6MQ2E'=>U[*5&>8($I,!YRH*,FI%59T3G ++MCT@9#11"[,IUXXTZJ=+@L^BO,#!,@8`B,,'D:[,(IRKJN!N(PCUN7ETFMNQ> ++MT.M,<5L4#9FB*%?$W!57FM?/^ZBA@2T-7E"Z%F;\[:8XR0<6)_+$E*H!FF8. ++M-XG<(8#8^U:S%08IU0*`6B3A$>0E<[+JG_>:@;>-`Y1E`&`8=(RYUE')]1`TYY(A:#RB0FG3$PE+)8S ++MGU.@!,R[6^+K@E&1>47'U:5Y9^H"9N$SLJ5J?%:_%JV9"PQ"#C%I;C:?MTG) ++M<_+^*U#T[J#O`$?NA$H`J5@CT><;M?J"+89:J5'/N15EU7F7>F1"I0/G+">Y ++M3+-@8%+J^"D)LAGHE1:IW4%D>L70=!S'KQZ=T/&:X3,<[QS#1;Q0:L.Y4(WR ++MIS8('-XK,_=EA`C,5^$HZS9@[X!)(&TP;5L0+F9IIL:86^R:&;<$8IY<9"=$ ++M980D2B%BWIQ8MF1**D]I;;CK69[X^A0WPLO@0K_*(X]F;<'PTXE7 ++M=W36:V(H)-CY_U'(8WEH]4NH>1WYRQ+BR@4% ++M$1U.K,)S+4!]61]+Q!Q];=1<:0H&&9F^&`@320!JS8'6STZ[:=E*IZ;&BDC7 ++M0Z/7-5O>MY:IK*BM/5>;X56^9&U^#42.H)OFI54HV1)`TJC7_B33GAVXJ]7O ++M;?1"OI([IPP,[MV,/M;SJ$X)F]1/8&A&510:&ID)5D![*U)9=_1^5X(."9$3 ++MAKAD3Q"G(58]/R>7K9'EWM'SQL4<(VSXPXG5&YKMU-_C3ND*S57\G4:0+B9, ++MJ5UN=Z]5!0TZS\:=[S.J>H-)[0]6K0B-@S.BC387!M ++M$S)!YJMA-!`JT[;'[Z^+^[0R-)::%H%GHKM=7G#8VW_]:.U^;<&A9&M/6UP?W""!BY%` ++M#![EE,U-#7?W49=0ZXLS<=KZ:P-?Z3.X9G9?7W,9U.N2TLZ.@I-#Z@G7\7TV ++MWHSA0AEJ*,1,`G^Y-'RV*AEKF,/?,:P^UZ&F<"J&#J0NMG0&<\V@F>9R#G`8 ++M8"2$M4:2?X:&&W[K8\*=>CQHL8G]'<]@CN1F#'"X-ZO8\(=;X+BJT=]2+C:H ++M4PL_D99">XRIU6^@S@B;6=;A"S6J!DD&;F8.@CY3\G*1J,;%1,\3U?C65;#&*>6OE! ++MFVJJJM,IDRO),/K661%M4\6#1,IBT04O9HXN64;!]\FH*H#<46AK6%-'LCF9 ++MR+1L24TY4/W_$$4`;*4R6-)=-<[!3VX70!7=GKY%5A/>5U.!KP4`/^X".'H%Q?;P',T8(,[(O1T\\K!%">*#TZ3L)AZ$/:3# ++MN#L_''38,`!CF+]:(8[7>H+[G4L`8'8$'2;(;A-TB>Y-?`Z0SHGO<-&]>=?1 ++M.%\D]#]-"\?6"0!S,$=]"\WZJKFWW+0,KN8@H5#,P4JO+2[I8+)K.GE;OZ'7 ++MW6^-;6=X]"-%4;W@V9C.#*N(]M'VAWIC7&N_#'E;W?3^T'>]-2-X=9B^4;U\ ++MT'*-(H-.>>8:,Q(3.V46OUD]TQT7D-PM+!C5]1&$A5_.0$FU.WL(&AB[^J(W ++MC9_.U;3@%I%C#)%M;R_(%(ZBT`U7Z%$^2K53FF"->R$&0GTQ1HJCRC*ZNL1@ ++M;F!0>FK6OK[E(YYHF^=GYS,F>9DC+2@>J2@N@/>\BL^-6Z=!H*-?OLIAZ_NK ++MLDN"E,GB8]*I2!;=UH7JBS.6AF88^:>-ZOR=_N7A"M\B,YE=CKV?B(2%+;-$FTH0P@=0=)7(@D5HIYCOV$EW.MZP_:HB ++M&,OED]W=BZGUITM#NKAC8,`1SO"V/<*,?4Q+AGF/V=O(_QZ9Q08'TG;(.%W> ++M3QI"^R0+9F25\+`V81V6@)V/X&8HAATY-]YTO.V[=I1-2`X6_"5%@0JCBP0? ++M!4@"!(7#-S*G*12#Q7ISP]OR(^?&&48%!EP>;\@B($4F'_XNY(IPH2!)0!** ++` ++end +diff --git a/gdb/testsuite/gdb.base/tab-crash.exp b/gdb/testsuite/gdb.base/tab-crash.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/tab-crash.exp +@@ -0,0 +1,43 @@ ++# This testcase is part of GDB, the GNU debugger. ++ ++# Copyright 2017 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-*-* ] || ![is_lp64_target] } { ++ return ++} ++ ++standard_testfile ++ ++# gcc-base-debuginfo-6.3.1-1.fc25.x86_64 ++# /usr/lib/debug/lib64/libgcc_s-6.3.1-20161221.so.1.debug ++# objcopy -R .debug_loc -R .debug_ranges -R .debug_info -R .debug_abbrev -R .debug_aranges -R .debug_str -R .comment ... ++ ++set debugfilebz2uu ${srcdir}/${subdir}/${testfile}.bz2.uu ++set debugfile [standard_output_file ${testfile}] ++ ++if {[catch "system \"uudecode -o - ${debugfilebz2uu} | bzip2 -dc >${debugfile}\""] != 0} { ++ untested "failed uudecode or bzip2" ++ return -1 ++} ++file stat ${debugfile} debugfilestat ++if {$debugfilestat(size) != 71936} { ++ untested "uudecode or bzip2 produce invalid result" ++ return -1 ++} ++ ++clean_restart ${debugfile} ++ ++gdb_test "complete p si" "complete p si\r\np size_of_encoded_value" diff --git a/SOURCES/gdb-rhbz1491128-batch-mode-exit-status-1of2.patch b/SOURCES/gdb-rhbz1491128-batch-mode-exit-status-1of2.patch new file mode 100644 index 0000000..3648130 --- /dev/null +++ b/SOURCES/gdb-rhbz1491128-batch-mode-exit-status-1of2.patch @@ -0,0 +1,323 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Gary Benson +Date: Wed, 29 Aug 2018 16:11:50 +0100 +Subject: gdb-rhbz1491128-batch-mode-exit-status-1of2.patch + +;; Fix for 'gdb in batch mode always exit with status 0' (Gary Benson) +;; RHBZ #1491128 + +Indicate batch mode failures by exiting with nonzero status + +This commit causes GDB in batch mode to exit with nonzero status +if the last command to be executed fails. + +gdb/ChangeLog: + + PR gdb/13000: + * gdb/main.c (captured_main_1): Exit with nonzero status + in batch mode if the last command to be executed failed. + * NEWS: Mention the above. + +gdb/testsuite/ChangeLog: + + PR gdb/13000: + * gdb.base/batch-exit-status.exp: New file. + * gdb.base/batch-exit-status.good-commands: Likewise. + * gdb.base/batch-exit-status.bad-commands: Likewise. + +diff --git a/gdb/ChangeLog b/gdb/ChangeLog +--- a/gdb/ChangeLog ++++ b/gdb/ChangeLog +@@ -1,3 +1,10 @@ ++2018-08-16 Gary Benson ++ ++ PR gdb/13000: ++ * gdb/main.c (captured_main_1): Exit with nonzero status ++ in batch mode if the last command to be executed failed. ++ * NEWS: Mention the above. ++ + 2018-08-03 Sergio Durigan Junior + + * ser-tcp.c (net_open): Fix thinko when deciding whether to +diff --git a/gdb/NEWS b/gdb/NEWS +--- a/gdb/NEWS ++++ b/gdb/NEWS +@@ -7,6 +7,9 @@ + can be passed using the '[ADDRESS]:PORT' notation, or the regular + 'ADDRESS:PORT' method. + ++* GDB in batch mode now exits with status 1 if the last command to be ++ executed failed. ++ + *** Changes in GDB 8.2 + + * The 'set disassembler-options' command now supports specifying options +diff --git a/gdb/main.c b/gdb/main.c +--- a/gdb/main.c ++++ b/gdb/main.c +@@ -518,6 +518,7 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + int i; + int save_auto_load; + struct objfile *objfile; ++ int ret = 1; + + #ifdef HAVE_SBRK + /* Set this before constructing scoped_command_stats. */ +@@ -1051,7 +1052,7 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + processed; it sets global parameters, which are independent of + what file you are debugging or what directory you are in. */ + if (system_gdbinit && !inhibit_gdbinit) +- catch_command_errors (source_script, system_gdbinit, 0); ++ ret = catch_command_errors (source_script, system_gdbinit, 0); + + /* Read and execute $HOME/.gdbinit file, if it exists. This is done + *before* all the command line arguments are processed; it sets +@@ -1059,7 +1060,7 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + debugging or what directory you are in. */ + + if (home_gdbinit && !inhibit_gdbinit && !inhibit_home_gdbinit) +- catch_command_errors (source_script, home_gdbinit, 0); ++ ret = catch_command_errors (source_script, home_gdbinit, 0); + + /* Process '-ix' and '-iex' options early. */ + for (i = 0; i < cmdarg_vec.size (); i++) +@@ -1069,12 +1070,12 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + switch (cmdarg_p.type) + { + case CMDARG_INIT_FILE: +- catch_command_errors (source_script, cmdarg_p.string, +- !batch_flag); ++ ret = catch_command_errors (source_script, cmdarg_p.string, ++ !batch_flag); + break; + case CMDARG_INIT_COMMAND: +- catch_command_errors (execute_command, cmdarg_p.string, +- !batch_flag); ++ ret = catch_command_errors (execute_command, cmdarg_p.string, ++ !batch_flag); + break; + } + } +@@ -1082,11 +1083,11 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + /* Now perform all the actions indicated by the arguments. */ + if (cdarg != NULL) + { +- catch_command_errors (cd_command, cdarg, 0); ++ ret = catch_command_errors (cd_command, cdarg, 0); + } + + for (i = 0; i < dirarg.size (); i++) +- catch_command_errors (directory_switch, dirarg[i], 0); ++ ret = catch_command_errors (directory_switch, dirarg[i], 0); + + /* Skip auto-loading section-specified scripts until we've sourced + local_gdbinit (which is often used to augment the source search +@@ -1115,19 +1116,19 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + 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. */ +- if (catch_command_errors (func, execarg, !batch_flag) +- && core_bfd == NULL) +- catch_command_errors (symbol_file_add_main_adapter, symarg, +- !batch_flag); ++ 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); + } + else + { + if (execarg != NULL) +- catch_command_errors (exec_file_attach, execarg, +- !batch_flag); ++ ret = catch_command_errors (exec_file_attach, execarg, ++ !batch_flag); + if (symarg != NULL) +- catch_command_errors (symbol_file_add_main_adapter, symarg, +- !batch_flag); ++ ret = catch_command_errors (symbol_file_add_main_adapter, ++ symarg, !batch_flag); + } + + if (corearg && pidarg) +@@ -1135,9 +1136,14 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + "a core file at the same time.")); + + if (corearg != NULL) +- catch_command_errors (core_file_command, corearg, !batch_flag); ++ { ++ ret = catch_command_errors (core_file_command, corearg, ++ !batch_flag); ++ } + else if (pidarg != NULL) +- catch_command_errors (attach_command, pidarg, !batch_flag); ++ { ++ ret = catch_command_errors (attach_command, pidarg, !batch_flag); ++ } + else if (pid_or_core_arg) + { + /* The user specified 'gdb program pid' or gdb program core'. +@@ -1146,17 +1152,23 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + + if (isdigit (pid_or_core_arg[0])) + { +- if (catch_command_errors (attach_command, pid_or_core_arg, +- !batch_flag) == 0 ++ ret = catch_command_errors (attach_command, pid_or_core_arg, ++ !batch_flag); ++ if (ret == 0 + /* attach_command could succeed partially and core_file_command + would try to kill it. */ + && !have_inferiors ()) +- catch_command_errors (core_file_command, pid_or_core_arg, +- !batch_flag); ++ ret = catch_command_errors (core_file_command, ++ pid_or_core_arg, ++ !batch_flag); ++ } ++ else ++ { ++ /* Can't be a pid, better be a corefile. */ ++ ret = catch_command_errors (core_file_command, ++ pid_or_core_arg, ++ !batch_flag); + } +- else /* Can't be a pid, better be a corefile. */ +- catch_command_errors (core_file_command, pid_or_core_arg, +- !batch_flag); + } + + if (ttyarg != NULL) +@@ -1180,7 +1192,7 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + { + auto_load_local_gdbinit_loaded = 1; + +- catch_command_errors (source_script, local_gdbinit, 0); ++ ret = catch_command_errors (source_script, local_gdbinit, 0); + } + } + +@@ -1200,12 +1212,12 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + switch (cmdarg_p.type) + { + case CMDARG_FILE: +- catch_command_errors (source_script, cmdarg_p.string, +- !batch_flag); ++ ret = catch_command_errors (source_script, cmdarg_p.string, ++ !batch_flag); + break; + case CMDARG_COMMAND: +- catch_command_errors (execute_command, cmdarg_p.string, +- !batch_flag); ++ ret = catch_command_errors (execute_command, cmdarg_p.string, ++ !batch_flag); + break; + } + } +@@ -1217,8 +1229,11 @@ captured_main_1 (struct captured_main_args *context, int &python_script) + + if (batch_flag) + { ++ int error_status = EXIT_FAILURE; ++ int *exit_arg = ret == 0 ? &error_status : NULL; ++ + /* We have hit the end of the batch file. */ +- quit_force (NULL, 0); ++ quit_force (exit_arg, 0); + } + } + +diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog +--- a/gdb/testsuite/ChangeLog ++++ b/gdb/testsuite/ChangeLog +@@ -1,3 +1,10 @@ ++2018-08-16 Gary Benson ++ ++ PR gdb/13000: ++ * gdb.base/batch-exit-status.exp: New file. ++ * gdb.base/batch-exit-status.good-commands: Likewise. ++ * gdb.base/batch-exit-status.bad-commands: Likewise. ++ + 2018-07-11 Sergio Durigan Junior + Jan Kratochvil + Paul Fertser +diff --git a/gdb/testsuite/gdb.base/batch-exit-status.bad-commands b/gdb/testsuite/gdb.base/batch-exit-status.bad-commands +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/batch-exit-status.bad-commands +@@ -0,0 +1 @@ ++bork +diff --git a/gdb/testsuite/gdb.base/batch-exit-status.exp b/gdb/testsuite/gdb.base/batch-exit-status.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/batch-exit-status.exp +@@ -0,0 +1,63 @@ ++# Copyright (C) 2018 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 . ++ ++# Check that "gdb -batch" exits with appropriate status. ++ ++standard_testfile ++ ++set good_commands "$srcdir/$subdir/batch-exit-status.good-commands" ++set bad_commands "$srcdir/$subdir/batch-exit-status.bad-commands" ++ ++proc _test_exit_status {expect_status cmdline_opts} { ++ global gdb_spawn_id ++ ++ gdb_exit ++ if {[gdb_spawn_with_cmdline_opts $cmdline_opts] != 0} { ++ fail "spawn" ++ return ++ } ++ ++ set result [wait -i $gdb_spawn_id] ++ verbose $result ++ gdb_assert { [lindex $result 2] == 0 } ++ set actual_status [lindex $result 3] ++ gdb_assert { $actual_status == $expect_status } ++} ++ ++proc test_exit_status {expect_status cmdline_opts} { ++ with_test_prefix $cmdline_opts { ++ _test_exit_status $expect_status $cmdline_opts ++ } ++} ++ ++# gdb -batch with nothing to do should exit 0. ++test_exit_status 0 "-batch" ++ ++# Bad command-line options should cause exit 1. ++test_exit_status 1 "-batch -jslkflsdjlkfjlksdjf" ++ ++# gdb -batch with good commands should exit 0. ++test_exit_status 0 "-batch -ex \"info source\"" ++test_exit_status 0 "-batch -x $good_commands" ++ ++# gdb -batch with bad commands should exit 1. ++test_exit_status 1 "-batch -ex \"set not-a-thing 4\"" ++test_exit_status 1 "-batch -x $bad_commands" ++ ++# Success or failure of the last thing determines the exit code. ++test_exit_status 0 "-batch -ex \"set not-a-thing 4\" -x $good_commands" ++test_exit_status 0 "-batch -x $bad_commands -ex \"info source\"" ++test_exit_status 1 "-batch -x $good_commands -x $bad_commands" ++test_exit_status 1 "-batch -x $good_commands -ex \"set not-a-thing 4\"" +diff --git a/gdb/testsuite/gdb.base/batch-exit-status.good-commands b/gdb/testsuite/gdb.base/batch-exit-status.good-commands +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/batch-exit-status.good-commands +@@ -0,0 +1 @@ ++info mem diff --git a/SOURCES/gdb-rhbz1491128-batch-mode-exit-status-2of2.patch b/SOURCES/gdb-rhbz1491128-batch-mode-exit-status-2of2.patch new file mode 100644 index 0000000..b1ba523 --- /dev/null +++ b/SOURCES/gdb-rhbz1491128-batch-mode-exit-status-2of2.patch @@ -0,0 +1,65 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Gary Benson +Date: Mon, 3 Sep 2018 16:14:55 +0100 +Subject: gdb-rhbz1491128-batch-mode-exit-status-2of2.patch + +;; Fix for 'gdb in batch mode always exit with status 0' (Gary Benson) +;; RHBZ #1491128 + +Fix batch exit status test failure on Fedora 28 + +This commit adds calls to remote_close and clear_gdb_spawn_id to +gdb.base/batch-exit-status.exp, fixing failures reported by buildbot +on Fedora 28 where gdb_spawn_id not being reset by the previous test +caused default_gdb_spawn to return without spawning. + +This commit also changes the test to use detect GDB's exit using +gdb_test_multiple expecting 'eof', rather than using 'wait -i' alone. +This means the testcase won't hang forever on failure as fixed in +gdb.base/quit.exp by commit 15763a09d4ae ("Fix 'gdb.base/quit.exp +hangs forever' if the test fails"). + +gdb/testsuite/ChangeLog: + + * gdb.base/batch-exit-status.exp: Use gdb_test_multiple and expect + 'eof' before 'wait -i'. Use remote_close and clear_gdb_spawn_id. + +diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog +--- a/gdb/testsuite/ChangeLog ++++ b/gdb/testsuite/ChangeLog +@@ -1,3 +1,8 @@ ++2018-09-04 Gary Benson ++ ++ * gdb.base/batch-exit-status.exp: Use gdb_test_multiple and expect ++ 'eof' before 'wait -i'. Use remote_close and clear_gdb_spawn_id. ++ + 2018-08-16 Gary Benson + + PR gdb/13000: +diff --git a/gdb/testsuite/gdb.base/batch-exit-status.exp b/gdb/testsuite/gdb.base/batch-exit-status.exp +--- a/gdb/testsuite/gdb.base/batch-exit-status.exp ++++ b/gdb/testsuite/gdb.base/batch-exit-status.exp +@@ -29,11 +29,18 @@ proc _test_exit_status {expect_status cmdline_opts} { + return + } + +- set result [wait -i $gdb_spawn_id] +- verbose $result +- gdb_assert { [lindex $result 2] == 0 } +- set actual_status [lindex $result 3] +- gdb_assert { $actual_status == $expect_status } ++ gdb_test_multiple "" "run til exit" { ++ eof { ++ set result [wait -i $gdb_spawn_id] ++ verbose $result ++ ++ gdb_assert { [lindex $result 2] == 0 } ++ gdb_assert { [lindex $result 3] == $expect_status } ++ ++ remote_close host ++ clear_gdb_spawn_id ++ } ++ } + } + + proc test_exit_status {expect_status cmdline_opts} { diff --git a/SOURCES/gdb-rhbz1553104-s390x-arch12-test.patch b/SOURCES/gdb-rhbz1553104-s390x-arch12-test.patch new file mode 100644 index 0000000..2cb15e5 --- /dev/null +++ b/SOURCES/gdb-rhbz1553104-s390x-arch12-test.patch @@ -0,0 +1,81 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 23 Mar 2018 20:42:44 +0100 +Subject: gdb-rhbz1553104-s390x-arch12-test.patch + +;; [s390x] Backport arch12 instructions decoding (RH BZ 1553104). +;; =fedoratest + +diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.S b/gdb/testsuite/gdb.arch/s390x-arch12.S +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/s390x-arch12.S +@@ -0,0 +1,4 @@ ++.text ++.globl load_guarded ++load_guarded: ++.byte 0xeb,0xbf,0xf0,0x58,0x00,0x24,0xe3,0xf0,0xff,0x50,0xff,0x71,0xb9,0x04,0x00,0xbf,0xe3,0x20,0xb0,0xa0,0x00,0x24,0xe3,0x10,0xb0,0xa0,0x00,0x04,0xe3,0x10,0x10,0x00,0x00,0x4c,0xe3,0x10,0xb0,0xa8,0x00,0x24,0xe3,0x10,0xb0,0xa8,0x00,0x04,0xb9,0x04,0x00,0x21,0xe3,0x40,0xb1,0x20,0x00,0x04,0xeb,0xbf,0xb1,0x08,0x00,0x04,0x07,0xf4 +diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.exp b/gdb/testsuite/gdb.arch/s390x-arch12.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/s390x-arch12.exp +@@ -0,0 +1,34 @@ ++# Copyright 2018 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 s390x-*linux-*] || ![is_lp64_target] } { ++# verbose "Skipping s390x-prologue-skip.exp" ++# return ++#} ++ ++set testfile "s390x-arch12" ++set uufile "${srcdir}/${subdir}/${testfile}.o.uu" ++set ofile "${srcdir}/${subdir}/${testfile}.o" ++ ++if { [catch "system \"uudecode -o ${ofile} ${uufile}\"" ] != 0 } { ++ untested "failed uudecode" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_load $ofile ++ ++gdb_test "disas load_guarded" " <\\+28>:\tlgg\t%r1,0\\(%r1\\)\r\n\[^\r\n\]* <\\+34>:\tstg\t%r1,168\\(%r11\\)\r\n.*" +diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.o.uu b/gdb/testsuite/gdb.arch/s390x-arch12.o.uu +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/s390x-arch12.o.uu +@@ -0,0 +1,20 @@ ++begin 644 s390x-arch12.o ++M?T5,1@("`0`````````````!`!8````!```````````````````````````` ++M``$X``````!```````!```<`!.N_\%@`)./P_U#_<;D$`+_C(+"@`"3C$+"@ ++M``3C$!```$SC$+"H`"3C$+"H``2Y!``AXT"Q(``$Z[^Q"``$!_0`+G-Y;71A ++M8@`N +Date: Fri, 11 Jan 2019 10:52:17 -0500 +Subject: + gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-1of5.patch + +;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +;; Keith Seitz, RHBZ#1560010. + +gdb/23712: Introduce multidictionary's + +gdb/23712 is a new manifestation of the now-infamous (at least to me) +symtab/23010 assertion failure (DICT_LANGUAGE == SYMBOL_LANGAUGE). + +An example of the problem (using test case from symtab/23010): + +Reading symbols from /home/rdiez/rdiez/arduino/JtagDue/BuildOutput/JtagDue-obj-release/firmware.elf...done. +(gdb) p SysTick_Handler +dwarf2read.c:9715: internal-error: void dw2_add_symbol_to_list(symbol*, pending**): Assertion `(*listhead) == NULL || (SYMBOL_LANGUAGE ((*listhead)->symbol[0]) == SYMBOL_LANGUAGE (symbol))' failed. +A problem internal to GDB has been detected, +further debugging may prove unreliable. +Quit this debugging session? (y or n) + +This assertion was added specifically to catch this condition (of adding +symbols of different languages to a single pending list). + +The problems we're now seeing on systems utilizing DWARF debugging seem to +be caused by the use of LTO, which adds a CU with an artificial DIE of +language C99 which references DIEs in other CUs of language C++. + +Thus, we create a dictionary containing symbols of C99 but end up +stuffing C++ symbols into it, and the dw2_add_symbol_to_list triggers. + +The approach taken here to fix this is to introduce multi-language +dictionaries to "replace" the standard, single-language dictionaries +used today. + +Note to reviewers: This patch introduces some temporary functions to +aide with review. This and other artifacts (such as "See dictionary.h" +which appear incorrect) will all be valid at the end of the series. + +This first patch introduces the new multidictionary and its API (which +is, by design, identical to the old dictionary interface). It also +mutates dict_create_hashed and dict_create_linear so that they take +a std::vector instead of the usual struct pending linked list. This will +be needed later on. + +This patch does /not/ actually enable multidictionary's. That is left +for a subsequent patch in the series. + +I've done exhaustive performance testing with this approach, and I've +attempted to minimize the overhead for the (overwhelmingly) most common +one-language scenario. + +On average, a -g3 -O0 GDB (the one we developers use) will see +approximately a 4% slowdown when initially reading symbols. [I've +tested only GDB and firefox with -readnow.] When using -O2, this +difference shrinks to ~0.5%. Since a number of runs with these +patches actually run /faster/ than unpatched GDB, I conclude that +these tests have at least a 0.5% error margin. + +On our own gdb.perf test suite, again, results appear to be pretty +negligible. Differences to unpatched GDB range from -7.8% (yes, +patched version is again faster than unpatched) to 27%. All tests +lying outside "negligible," such as the 27% slowdown, involve a total +run time of 0.0007 (or less) with smaller numbers of CUs/DSOs (usually 10 +or 100). In all cases, the follow-up tests with more CUs/DSOs is never +more than 3% difference to the baseline, unpatched GDB. + +In my opinion, these results are satisfactory. + +gdb/ChangeLog: + + PR gdb/23712 + PR symtab/23010 + * dictionary.c: Include unordered_map. + (pending_to_vector): New function. + (dict_create_hashed_1, dict_create_linear_1, dict_add_pending_1): + Rewrite the non-"_1" functions to take vector instead + of linked list. + (dict_create_hashed, dict_create_linear, dict_add_pending): Use the + "new" _1 versions of the same name. + (multidictionary): Define. + (std::hash + + /* This file implements dictionaries, which are tables that associate + symbols to names. They are represented by an opaque type 'struct +@@ -341,53 +342,66 @@ static void insert_symbol_hashed (struct dictionary *dict, + + static void expand_hashtable (struct dictionary *dict); + ++/* A function to convert a linked list into a vector. */ ++ ++static std::vector ++pending_to_vector (const struct pending *symbol_list) ++{ ++ std::vector symlist; ++ ++ for (const struct pending *list_counter = symbol_list; ++ list_counter != nullptr; list_counter = list_counter->next) ++ { ++ for (int i = list_counter->nsyms - 1; i >= 0; --i) ++ symlist.push_back (list_counter->symbol[i]); ++ } ++ ++ return symlist; ++} ++ + /* The creation functions. */ + +-/* See dictionary.h. */ ++/* A function to transition dict_create_hashed to new API. */ + +-struct dictionary * +-dict_create_hashed (struct obstack *obstack, +- enum language language, +- const struct pending *symbol_list) ++static struct dictionary * ++dict_create_hashed_1 (struct obstack *obstack, ++ enum language language, ++ const std::vector &symbol_list) + { +- struct dictionary *retval; +- int nsyms = 0, nbuckets, i; +- struct symbol **buckets; +- const struct pending *list_counter; +- +- retval = XOBNEW (obstack, struct dictionary); ++ /* Allocate the dictionary. */ ++ struct dictionary *retval = XOBNEW (obstack, struct dictionary); + DICT_VECTOR (retval) = &dict_hashed_vector; + DICT_LANGUAGE (retval) = language_def (language); + +- /* Calculate the number of symbols, and allocate space for them. */ +- for (list_counter = symbol_list; +- list_counter != NULL; +- list_counter = list_counter->next) +- { +- nsyms += list_counter->nsyms; +- } +- nbuckets = DICT_HASHTABLE_SIZE (nsyms); ++ /* Allocate space for symbols. */ ++ int nsyms = symbol_list.size (); ++ int nbuckets = DICT_HASHTABLE_SIZE (nsyms); + DICT_HASHED_NBUCKETS (retval) = nbuckets; +- buckets = XOBNEWVEC (obstack, struct symbol *, nbuckets); ++ struct symbol **buckets = XOBNEWVEC (obstack, struct symbol *, nbuckets); + memset (buckets, 0, nbuckets * sizeof (struct symbol *)); + DICT_HASHED_BUCKETS (retval) = buckets; + + /* Now fill the buckets. */ +- for (list_counter = symbol_list; +- list_counter != NULL; +- list_counter = list_counter->next) +- { +- for (i = list_counter->nsyms - 1; i >= 0; --i) +- { +- insert_symbol_hashed (retval, list_counter->symbol[i]); +- } +- } ++ for (const auto &sym : symbol_list) ++ insert_symbol_hashed (retval, sym); + + return retval; + } + + /* See dictionary.h. */ + ++struct dictionary * ++dict_create_hashed (struct obstack *obstack, ++ enum language language, ++ const struct pending *symbol_list) ++{ ++ std::vector symlist = pending_to_vector (symbol_list); ++ ++ return dict_create_hashed_1 (obstack, language, symlist); ++} ++ ++/* See dictionary.h. */ ++ + extern struct dictionary * + dict_create_hashed_expandable (enum language language) + { +@@ -403,52 +417,45 @@ dict_create_hashed_expandable (enum language language) + return retval; + } + +-/* See dictionary.h. */ ++/* A function to transition dict_create_linear to new API. */ + +-struct dictionary * +-dict_create_linear (struct obstack *obstack, +- enum language language, +- const struct pending *symbol_list) ++static struct dictionary * ++dict_create_linear_1 (struct obstack *obstack, ++ enum language language, ++ const std::vector &symbol_list) + { +- struct dictionary *retval; +- int nsyms = 0, i, j; +- struct symbol **syms; +- const struct pending *list_counter; +- +- retval = XOBNEW (obstack, struct dictionary); ++ struct dictionary *retval = XOBNEW (obstack, struct dictionary); + DICT_VECTOR (retval) = &dict_linear_vector; + DICT_LANGUAGE (retval) = language_def (language); + +- /* Calculate the number of symbols, and allocate space for them. */ +- for (list_counter = symbol_list; +- list_counter != NULL; +- list_counter = list_counter->next) +- { +- nsyms += list_counter->nsyms; +- } ++ /* Allocate space for symbols. */ ++ int nsyms = symbol_list.size (); + DICT_LINEAR_NSYMS (retval) = nsyms; +- syms = XOBNEWVEC (obstack, struct symbol *, nsyms ); ++ struct symbol **syms = XOBNEWVEC (obstack, struct symbol *, nsyms); + DICT_LINEAR_SYMS (retval) = syms; + +- /* Now fill in the symbols. Start filling in from the back, so as +- to preserve the original order of the symbols. */ +- for (list_counter = symbol_list, j = nsyms - 1; +- list_counter != NULL; +- list_counter = list_counter->next) +- { +- for (i = list_counter->nsyms - 1; +- i >= 0; +- --i, --j) +- { +- syms[j] = list_counter->symbol[i]; +- } +- } ++ /* Now fill in the symbols. */ ++ int idx = nsyms - 1; ++ for (const auto &sym : symbol_list) ++ syms[idx--] = sym; + + return retval; + } + + /* See dictionary.h. */ + ++struct dictionary * ++dict_create_linear (struct obstack *obstack, ++ enum language language, ++ const struct pending *symbol_list) ++{ ++ std::vector symlist = pending_to_vector (symbol_list); ++ ++ return dict_create_linear_1 (obstack, language, symlist); ++} ++ ++/* See dictionary.h. */ ++ + struct dictionary * + dict_create_linear_expandable (enum language language) + { +@@ -483,20 +490,26 @@ dict_add_symbol (struct dictionary *dict, struct symbol *sym) + (DICT_VECTOR (dict))->add_symbol (dict, sym); + } + ++/* A function to transition dict_add_pending to new API. */ ++ ++static void ++dict_add_pending_1 (struct dictionary *dict, ++ const std::vector &symbol_list) ++{ ++ /* Preserve ordering by reversing the list. */ ++ for (auto sym = symbol_list.rbegin (); sym != symbol_list.rend (); ++sym) ++ dict_add_symbol (dict, *sym); ++} ++ + /* Utility to add a list of symbols to a dictionary. + DICT must be an expandable dictionary. */ + + void + dict_add_pending (struct dictionary *dict, const struct pending *symbol_list) + { +- const struct pending *list; +- int i; ++ std::vector symlist = pending_to_vector (symbol_list); + +- for (list = symbol_list; list != NULL; list = list->next) +- { +- for (i = 0; i < list->nsyms; ++i) +- dict_add_symbol (dict, list->symbol[i]); +- } ++ dict_add_pending_1 (dict, symlist); + } + + /* Initialize ITERATOR to point at the first symbol in DICT, and +@@ -929,3 +942,408 @@ add_symbol_linear_expandable (struct dictionary *dict, + + DICT_LINEAR_SYM (dict, nsyms - 1) = sym; + } ++ ++/* Multi-language dictionary support. */ ++ ++/* The structure describing a multi-language dictionary. */ ++ ++struct multidictionary ++{ ++ /* An array of dictionaries, one per language. All dictionaries ++ must be of the same type. This should be free'd for expandable ++ dictionary types. */ ++ struct dictionary **dictionaries; ++ ++ /* The number of language dictionaries currently allocated. ++ Only used for expandable dictionaries. */ ++ unsigned short n_allocated_dictionaries; ++}; ++ ++/* A hasher for enum language. Injecting this into std is a convenience ++ when using unordered_map with C++11. */ ++ ++namespace std ++{ ++ template<> struct hash ++ { ++ typedef enum language argument_type; ++ typedef std::size_t result_type; ++ ++ result_type operator() (const argument_type &l) const noexcept ++ { ++ return static_cast (l); ++ } ++ }; ++} /* namespace std */ ++ ++/* A helper function to collate symbols on the pending list by language. */ ++ ++static std::unordered_map> ++collate_pending_symbols_by_language (const struct pending *symbol_list) ++{ ++ std::unordered_map> nsyms; ++ ++ for (const struct pending *list_counter = symbol_list; ++ list_counter != nullptr; list_counter = list_counter->next) ++ { ++ for (int i = list_counter->nsyms - 1; i >= 0; --i) ++ { ++ enum language language = SYMBOL_LANGUAGE (list_counter->symbol[i]); ++ nsyms[language].push_back (list_counter->symbol[i]); ++ } ++ } ++ ++ return nsyms; ++} ++ ++/* See dictionary.h. */ ++ ++struct multidictionary * ++mdict_create_hashed (struct obstack *obstack, ++ const struct pending *symbol_list) ++{ ++ struct multidictionary *retval ++ = XOBNEW (obstack, struct multidictionary); ++ std::unordered_map> nsyms ++ = collate_pending_symbols_by_language (symbol_list); ++ ++ /* Loop over all languages and create/populate dictionaries. */ ++ retval->dictionaries ++ = XOBNEWVEC (obstack, struct dictionary *, nsyms.size ()); ++ retval->n_allocated_dictionaries = nsyms.size (); ++ ++ int idx = 0; ++ for (const auto &pair : nsyms) ++ { ++ enum language language = pair.first; ++ std::vector symlist = pair.second; ++ ++ retval->dictionaries[idx++] ++ = dict_create_hashed_1 (obstack, language, symlist); ++ } ++ ++ return retval; ++} ++ ++/* See dictionary.h. */ ++ ++struct multidictionary * ++mdict_create_hashed_expandable (enum language language) ++{ ++ struct multidictionary *retval = XNEW (struct multidictionary); ++ ++ /* We have no symbol list to populate, but we create an empty ++ dictionary of the requested language to populate later. */ ++ retval->n_allocated_dictionaries = 1; ++ retval->dictionaries = XNEW (struct dictionary *); ++ retval->dictionaries[0] = dict_create_hashed_expandable (language); ++ ++ return retval; ++} ++ ++/* See dictionary.h. */ ++ ++struct multidictionary * ++mdict_create_linear (struct obstack *obstack, ++ const struct pending *symbol_list) ++{ ++ struct multidictionary *retval ++ = XOBNEW (obstack, struct multidictionary); ++ std::unordered_map> nsyms ++ = collate_pending_symbols_by_language (symbol_list); ++ ++ /* Loop over all languages and create/populate dictionaries. */ ++ retval->dictionaries ++ = XOBNEWVEC (obstack, struct dictionary *, nsyms.size ()); ++ retval->n_allocated_dictionaries = nsyms.size (); ++ ++ int idx = 0; ++ for (const auto &pair : nsyms) ++ { ++ enum language language = pair.first; ++ std::vector symlist = pair.second; ++ ++ retval->dictionaries[idx++] ++ = dict_create_linear_1 (obstack, language, symlist); ++ } ++ ++ return retval; ++} ++ ++/* See dictionary.h. */ ++ ++struct multidictionary * ++mdict_create_linear_expandable (enum language language) ++{ ++ struct multidictionary *retval = XNEW (struct multidictionary); ++ ++ /* We have no symbol list to populate, but we create an empty ++ dictionary to populate later. */ ++ retval->n_allocated_dictionaries = 1; ++ retval->dictionaries = XNEW (struct dictionary *); ++ retval->dictionaries[0] = dict_create_linear_expandable (language); ++ ++ return retval; ++} ++ ++/* See dictionary.h. */ ++ ++void ++mdict_free (struct multidictionary *mdict) ++{ ++ /* Grab the type of dictionary being used. */ ++ enum dict_type type = mdict->dictionaries[0]->vector->type; ++ ++ /* Loop over all dictionaries and free them. */ ++ for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx) ++ dict_free (mdict->dictionaries[idx]); ++ ++ /* Free the dictionary list, if needed. */ ++ switch (type) ++ { ++ case DICT_HASHED: ++ case DICT_LINEAR: ++ /* Memory was allocated on an obstack when created. */ ++ break; ++ ++ case DICT_HASHED_EXPANDABLE: ++ case DICT_LINEAR_EXPANDABLE: ++ xfree (mdict->dictionaries); ++ break; ++ } ++} ++ ++/* Helper function to find the dictionary associated with LANGUAGE ++ or NULL if there is no dictionary of that language. */ ++ ++static struct dictionary * ++find_language_dictionary (const struct multidictionary *mdict, ++ enum language language) ++{ ++ for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx) ++ { ++ if (DICT_LANGUAGE (mdict->dictionaries[idx])->la_language == language) ++ return mdict->dictionaries[idx]; ++ } ++ ++ return nullptr; ++} ++ ++/* Create a new language dictionary for LANGUAGE and add it to the ++ multidictionary MDICT's list of dictionaries. If MDICT is not ++ based on expandable dictionaries, this function throws an ++ internal error. */ ++ ++static struct dictionary * ++create_new_language_dictionary (struct multidictionary *mdict, ++ enum language language) ++{ ++ struct dictionary *retval = nullptr; ++ ++ /* We use the first dictionary entry to decide what create function ++ to call. Not optimal but sufficient. */ ++ gdb_assert (mdict->dictionaries[0] != nullptr); ++ switch (mdict->dictionaries[0]->vector->type) ++ { ++ case DICT_HASHED: ++ case DICT_LINEAR: ++ internal_error (__FILE__, __LINE__, ++ _("create_new_language_dictionary: attempted to expand " ++ "non-expandable multidictionary")); ++ ++ case DICT_HASHED_EXPANDABLE: ++ retval = dict_create_hashed_expandable (language); ++ break; ++ ++ case DICT_LINEAR_EXPANDABLE: ++ retval = dict_create_linear_expandable (language); ++ break; ++ } ++ ++ /* Grow the dictionary vector and save the new dictionary. */ ++ mdict->dictionaries ++ = (struct dictionary **) xrealloc (mdict->dictionaries, ++ (++mdict->n_allocated_dictionaries ++ * sizeof (struct dictionary *))); ++ mdict->dictionaries[mdict->n_allocated_dictionaries - 1] = retval; ++ ++ return retval; ++} ++ ++/* See dictionary.h. */ ++ ++void ++mdict_add_symbol (struct multidictionary *mdict, struct symbol *sym) ++{ ++ struct dictionary *dict ++ = find_language_dictionary (mdict, SYMBOL_LANGUAGE (sym)); ++ ++ if (dict == nullptr) ++ { ++ /* SYM is of a new language that we haven't previously seen. ++ Create a new dictionary for it. */ ++ dict = create_new_language_dictionary (mdict, SYMBOL_LANGUAGE (sym)); ++ } ++ ++ dict_add_symbol (dict, sym); ++} ++ ++/* See dictionary.h. */ ++ ++void ++mdict_add_pending (struct multidictionary *mdict, ++ const struct pending *symbol_list) ++{ ++ std::unordered_map> nsyms ++ = collate_pending_symbols_by_language (symbol_list); ++ ++ for (const auto &pair : nsyms) ++ { ++ enum language language = pair.first; ++ std::vector symlist = pair.second; ++ struct dictionary *dict = find_language_dictionary (mdict, language); ++ ++ if (dict == nullptr) ++ { ++ /* The language was not previously seen. Create a new dictionary ++ for it. */ ++ dict = create_new_language_dictionary (mdict, language); ++ } ++ ++ dict_add_pending_1 (dict, symlist); ++ } ++} ++ ++/* See dictionary.h. */ ++ ++struct symbol * ++mdict_iterator_first (const multidictionary *mdict, ++ struct mdict_iterator *miterator) ++{ ++ miterator->mdict = mdict; ++ miterator->current_idx = 0; ++ ++ for (unsigned short idx = miterator->current_idx; ++ idx < mdict->n_allocated_dictionaries; ++idx) ++ { ++ struct symbol *result ++ = dict_iterator_first (mdict->dictionaries[idx], &miterator->iterator); ++ ++ if (result != nullptr) ++ { ++ miterator->current_idx = idx; ++ return result; ++ } ++ } ++ ++ return nullptr; ++} ++ ++/* See dictionary.h. */ ++ ++struct symbol * ++mdict_iterator_next (struct mdict_iterator *miterator) ++{ ++ struct symbol *result = dict_iterator_next (&miterator->iterator); ++ ++ if (result != nullptr) ++ return result; ++ ++ /* The current dictionary had no matches -- move to the next ++ dictionary, if any. */ ++ for (unsigned short idx = ++miterator->current_idx; ++ idx < miterator->mdict->n_allocated_dictionaries; ++idx) ++ { ++ result ++ = dict_iterator_first (miterator->mdict->dictionaries[idx], ++ &miterator->iterator); ++ if (result != nullptr) ++ { ++ miterator->current_idx = idx; ++ return result; ++ } ++ } ++ ++ return nullptr; ++} ++ ++/* See dictionary.h. */ ++ ++struct symbol * ++mdict_iter_match_first (const struct multidictionary *mdict, ++ const lookup_name_info &name, ++ struct mdict_iterator *miterator) ++{ ++ miterator->mdict = mdict; ++ miterator->current_idx = 0; ++ ++ for (unsigned short idx = miterator->current_idx; ++ idx < mdict->n_allocated_dictionaries; ++idx) ++ { ++ struct symbol *result ++ = dict_iter_match_first (mdict->dictionaries[idx], name, ++ &miterator->iterator); ++ ++ if (result != nullptr) ++ return result; ++ } ++ ++ return nullptr; ++} ++ ++/* See dictionary.h. */ ++ ++struct symbol * ++mdict_iter_match_next (const lookup_name_info &name, ++ struct mdict_iterator *miterator) ++{ ++ /* Search the current dictionary. */ ++ struct symbol *result = dict_iter_match_next (name, &miterator->iterator); ++ ++ if (result != nullptr) ++ return result; ++ ++ /* The current dictionary had no matches -- move to the next ++ dictionary, if any. */ ++ for (unsigned short idx = ++miterator->current_idx; ++ idx < miterator->mdict->n_allocated_dictionaries; ++idx) ++ { ++ result ++ = dict_iter_match_first (miterator->mdict->dictionaries[idx], ++ name, &miterator->iterator); ++ if (result != nullptr) ++ { ++ miterator->current_idx = idx; ++ return result; ++ } ++ } ++ ++ return nullptr; ++} ++ ++/* See dictionary.h. */ ++ ++int ++mdict_size (const struct multidictionary *mdict) ++{ ++ int size = 0; ++ ++ for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx) ++ size += dict_size (mdict->dictionaries[idx]); ++ ++ return size; ++} ++ ++/* See dictionary.h. */ ++ ++bool ++mdict_empty (const struct multidictionary *mdict) ++{ ++ for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx) ++ { ++ if (!dict_empty (mdict->dictionaries[idx])) ++ return false; ++ } ++ ++ return true; ++} +diff --git a/gdb/dictionary.h b/gdb/dictionary.h +--- a/gdb/dictionary.h ++++ b/gdb/dictionary.h +@@ -113,6 +113,21 @@ struct dict_iterator + struct symbol *current; + }; + ++/* The multi-language dictionary iterator. Like dict_iterator above, ++ these contents should be considered private. */ ++ ++struct mdict_iterator ++{ ++ /* The multidictionary with whcih this iterator is associated. */ ++ const struct multidictionary *mdict; ++ ++ /* The iterator used to iterate through individual dictionaries. */ ++ struct dict_iterator iterator; ++ ++ /* The current index of the dictionary being iterated over. */ ++ unsigned short current_idx; ++}; ++ + /* Initialize ITERATOR to point at the first symbol in DICT, and + return that first symbol, or NULL if DICT is empty. */ + diff --git a/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-2of5.patch b/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-2of5.patch new file mode 100644 index 0000000..f86ce0b --- /dev/null +++ b/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-2of5.patch @@ -0,0 +1,644 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Sergio Durigan Junior +Date: Fri, 11 Jan 2019 11:25:11 -0500 +Subject: + gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-2of5.patch + +;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +;; Keith Seitz, RHBZ#1560010. + +gdb/23712: Use new multidictionary API + +This patch builds on the previous by enabling the `new' multidictionary +API. A lot of the hunks are simply textual replacements of "dict_" +with "mdict_" and similar transformations. + +A word of warning, even with the use of multidictionaries, the code +still does not satisfactorily fix the reported problems with gdb/23712 +(or gdb/23010). We still have additional changes to make before that +happens. + +gdb/ChangeLog: + + PR gdb/23712 + PR symtab/23010 + * dictionary.h (struct dictionary): Replace declaration with + multidictionary. + (dict_create_hashed, dict_create_hashed_expandable) + (dict_create_linear, dict_create_linear_expandable) + (dict_free, dict_add_symbol, dict_add_pending, dict_empty) + (dict_iterator_first, dict_iterator_next, dict_iter_match_first) + (dict_iter_match_next, dict_size): Rename to "mdict_" versions + taking multidictionary argument. + [ALL_DICT_SYMBOLS]: Update for multidictionary. + * block.h (struct block) : Change to multidictionary + and rename `multidict'. + * block.c, buildsym.c, jit.c, mdebugread.c, objfiles.c, + symmisc.c: Update all dictionary references to multidictionary. + +diff --git a/gdb/block.c b/gdb/block.c +--- a/gdb/block.c ++++ b/gdb/block.c +@@ -387,9 +387,9 @@ block_global_block (const struct block *block) + zero/NULL. This is useful for creating "dummy" blocks that don't + correspond to actual source files. + +- Warning: it sets the block's BLOCK_DICT to NULL, which isn't a ++ Warning: it sets the block's BLOCK_MULTIDICT to NULL, which isn't a + valid value. If you really don't want the block to have a +- dictionary, then you should subsequently set its BLOCK_DICT to ++ dictionary, then you should subsequently set its BLOCK_MULTIDICT to + dict_create_linear (obstack, NULL). */ + + struct block * +@@ -544,10 +544,11 @@ block_iterator_step (struct block_iterator *iterator, int first) + + block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), + iterator->which); +- sym = dict_iterator_first (BLOCK_DICT (block), &iterator->dict_iter); ++ sym = mdict_iterator_first (BLOCK_MULTIDICT (block), ++ &iterator->mdict_iter); + } + else +- sym = dict_iterator_next (&iterator->dict_iter); ++ sym = mdict_iterator_next (&iterator->mdict_iter); + + if (sym != NULL) + return sym; +@@ -569,7 +570,7 @@ block_iterator_first (const struct block *block, + initialize_block_iterator (block, iterator); + + if (iterator->which == FIRST_LOCAL_BLOCK) +- return dict_iterator_first (block->dict, &iterator->dict_iter); ++ return mdict_iterator_first (block->multidict, &iterator->mdict_iter); + + return block_iterator_step (iterator, 1); + } +@@ -580,7 +581,7 @@ struct symbol * + block_iterator_next (struct block_iterator *iterator) + { + if (iterator->which == FIRST_LOCAL_BLOCK) +- return dict_iterator_next (&iterator->dict_iter); ++ return mdict_iterator_next (&iterator->mdict_iter); + + return block_iterator_step (iterator, 0); + } +@@ -612,11 +613,11 @@ block_iter_match_step (struct block_iterator *iterator, + + block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), + iterator->which); +- sym = dict_iter_match_first (BLOCK_DICT (block), name, +- &iterator->dict_iter); ++ sym = mdict_iter_match_first (BLOCK_MULTIDICT (block), name, ++ &iterator->mdict_iter); + } + else +- sym = dict_iter_match_next (name, &iterator->dict_iter); ++ sym = mdict_iter_match_next (name, &iterator->mdict_iter); + + if (sym != NULL) + return sym; +@@ -639,7 +640,8 @@ block_iter_match_first (const struct block *block, + initialize_block_iterator (block, iterator); + + if (iterator->which == FIRST_LOCAL_BLOCK) +- return dict_iter_match_first (block->dict, name, &iterator->dict_iter); ++ return mdict_iter_match_first (block->multidict, name, ++ &iterator->mdict_iter); + + return block_iter_match_step (iterator, name, 1); + } +@@ -651,7 +653,7 @@ block_iter_match_next (const lookup_name_info &name, + struct block_iterator *iterator) + { + if (iterator->which == FIRST_LOCAL_BLOCK) +- return dict_iter_match_next (name, &iterator->dict_iter); ++ return mdict_iter_match_next (name, &iterator->mdict_iter); + + return block_iter_match_step (iterator, name, 0); + } +@@ -731,7 +733,7 @@ block_lookup_symbol_primary (const struct block *block, const char *name, + const domain_enum domain) + { + struct symbol *sym, *other; +- struct dict_iterator dict_iter; ++ struct mdict_iterator mdict_iter; + + lookup_name_info lookup_name (name, symbol_name_match_type::FULL); + +@@ -740,9 +742,10 @@ block_lookup_symbol_primary (const struct block *block, const char *name, + || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL); + + other = NULL; +- for (sym = dict_iter_match_first (block->dict, lookup_name, &dict_iter); ++ for (sym ++ = mdict_iter_match_first (block->multidict, lookup_name, &mdict_iter); + sym != NULL; +- sym = dict_iter_match_next (lookup_name, &dict_iter)) ++ sym = mdict_iter_match_next (lookup_name, &mdict_iter)) + { + if (SYMBOL_DOMAIN (sym) == domain) + return sym; +diff --git a/gdb/block.h b/gdb/block.h +--- a/gdb/block.h ++++ b/gdb/block.h +@@ -111,7 +111,7 @@ struct block + + /* This is used to store the symbols in the block. */ + +- struct dictionary *dict; ++ struct multidictionary *multidict; + + /* Contains information about namespace-related info relevant to this block: + using directives and the current namespace scope. */ +@@ -143,7 +143,7 @@ struct global_block + #define BLOCK_END(bl) (bl)->endaddr + #define BLOCK_FUNCTION(bl) (bl)->function + #define BLOCK_SUPERBLOCK(bl) (bl)->superblock +-#define BLOCK_DICT(bl) (bl)->dict ++#define BLOCK_MULTIDICT(bl) (bl)->multidict + #define BLOCK_NAMESPACE(bl) (bl)->namespace_info + + /* Accessor for ranges field within block BL. */ +@@ -298,9 +298,9 @@ struct block_iterator + + enum block_enum which; + +- /* The underlying dictionary iterator. */ ++ /* The underlying multidictionary iterator. */ + +- struct dict_iterator dict_iter; ++ struct mdict_iterator mdict_iter; + }; + + /* Initialize ITERATOR to point at the first symbol in BLOCK, and +diff --git a/gdb/buildsym.c b/gdb/buildsym.c +--- a/gdb/buildsym.c ++++ b/gdb/buildsym.c +@@ -349,23 +349,21 @@ finish_block_internal (struct symbol *symbol, + + if (symbol) + { +- BLOCK_DICT (block) +- = dict_create_linear (&objfile->objfile_obstack, +- buildsym_compunit->language, *listhead); ++ BLOCK_MULTIDICT (block) ++ = mdict_create_linear (&objfile->objfile_obstack, *listhead); + } + else + { + if (expandable) + { +- BLOCK_DICT (block) +- = dict_create_hashed_expandable (buildsym_compunit->language); +- dict_add_pending (BLOCK_DICT (block), *listhead); ++ BLOCK_MULTIDICT (block) ++ = mdict_create_hashed_expandable (buildsym_compunit->language); ++ mdict_add_pending (BLOCK_MULTIDICT (block), *listhead); + } + else + { +- BLOCK_DICT (block) = +- dict_create_hashed (&objfile->objfile_obstack, +- buildsym_compunit->language, *listhead); ++ BLOCK_MULTIDICT (block) = ++ mdict_create_hashed (&objfile->objfile_obstack, *listhead); + } + } + +@@ -377,7 +375,7 @@ finish_block_internal (struct symbol *symbol, + if (symbol) + { + struct type *ftype = SYMBOL_TYPE (symbol); +- struct dict_iterator iter; ++ struct mdict_iterator miter; + SYMBOL_BLOCK_VALUE (symbol) = block; + BLOCK_FUNCTION (block) = symbol; + +@@ -391,7 +389,7 @@ finish_block_internal (struct symbol *symbol, + + /* Here we want to directly access the dictionary, because + we haven't fully initialized the block yet. */ +- ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym) ++ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym) + { + if (SYMBOL_IS_ARGUMENT (sym)) + nparams++; +@@ -405,7 +403,7 @@ finish_block_internal (struct symbol *symbol, + iparams = 0; + /* Here we want to directly access the dictionary, because + we haven't fully initialized the block yet. */ +- ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym) ++ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym) + { + if (iparams == nparams) + break; +@@ -1448,7 +1446,7 @@ end_symtab_with_blockvector (struct block *static_block, + { + struct block *block = BLOCKVECTOR_BLOCK (blockvector, block_i); + struct symbol *sym; +- struct dict_iterator iter; ++ struct mdict_iterator miter; + + /* Inlined functions may have symbols not in the global or + static symbol lists. */ +@@ -1459,7 +1457,7 @@ end_symtab_with_blockvector (struct block *static_block, + /* Note that we only want to fix up symbols from the local + blocks, not blocks coming from included symtabs. That is why + we use ALL_DICT_SYMBOLS here and not ALL_BLOCK_SYMBOLS. */ +- ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym) ++ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym) + if (symbol_symtab (sym) == NULL) + symbol_set_symtab (sym, symtab); + } +@@ -1598,7 +1596,7 @@ augment_type_symtab (void) + to the primary symtab. */ + set_missing_symtab (file_symbols, cust); + +- dict_add_pending (BLOCK_DICT (block), file_symbols); ++ mdict_add_pending (BLOCK_MULTIDICT (block), file_symbols); + } + + if (global_symbols != NULL) +@@ -1609,7 +1607,7 @@ augment_type_symtab (void) + to the primary symtab. */ + set_missing_symtab (global_symbols, cust); + +- dict_add_pending (BLOCK_DICT (block), global_symbols); ++ mdict_add_pending (BLOCK_MULTIDICT (block), global_symbols); + } + + reset_symtab_globals (); +diff --git a/gdb/dictionary.h b/gdb/dictionary.h +--- a/gdb/dictionary.h ++++ b/gdb/dictionary.h +@@ -25,10 +25,10 @@ + + #include "symfile.h" + +-/* An opaque type for dictionaries; only dictionary.c should know +- about its innards. */ ++/* An opaque type for multi-language dictionaries; only dictionary.c should ++ know about its innards. */ + +-struct dictionary; ++struct multidictionary; + + /* Other types needed for declarations. */ + +@@ -38,65 +38,64 @@ struct pending; + struct language_defn; + + /* The creation functions for various implementations of +- dictionaries. */ ++ multi-language dictionaries. */ + +-/* Create a dictionary of symbols of language LANGUAGE implemented via ++/* Create a multi-language dictionary of symbols implemented via + a fixed-size hashtable. All memory it uses is allocated on + OBSTACK; the environment is initialized from SYMBOL_LIST. */ + +-extern struct dictionary *dict_create_hashed (struct obstack *obstack, +- enum language language, +- const struct pending +- *symbol_list); ++extern struct multidictionary * ++ mdict_create_hashed (struct obstack *obstack, ++ const struct pending *symbol_list); + +-/* Create a dictionary of symbols of language LANGUAGE, implemented +- via a hashtable that grows as necessary. The dictionary is +- initially empty; to add symbols to it, call dict_add_symbol(). +- Call dict_free() when you're done with it. */ ++/* Create a multi-language dictionary of symbols, implemented ++ via a hashtable that grows as necessary. The initial dictionary of ++ LANGUAGE is empty; to add symbols to it, call mdict_add_symbol(). ++ Call mdict_free() when you're done with it. */ + +-extern struct dictionary * +- dict_create_hashed_expandable (enum language language); ++extern struct multidictionary * ++ mdict_create_hashed_expandable (enum language language); + +-/* Create a dictionary of symbols of language LANGUAGE, implemented ++/* Create a multi-language dictionary of symbols, implemented + via a fixed-size array. All memory it uses is allocated on + OBSTACK; the environment is initialized from the SYMBOL_LIST. The + symbols are ordered in the same order that they're found in + SYMBOL_LIST. */ + +-extern struct dictionary *dict_create_linear (struct obstack *obstack, +- enum language language, +- const struct pending +- *symbol_list); ++extern struct multidictionary * ++ mdict_create_linear (struct obstack *obstack, ++ const struct pending *symbol_list); + +-/* Create a dictionary of symbols of language LANGUAGE, implemented +- via an array that grows as necessary. The dictionary is initially +- empty; to add symbols to it, call dict_add_symbol(). Call +- dict_free() when you're done with it. */ ++/* Create a multi-language dictionary of symbols, implemented ++ via an array that grows as necessary. The multidictionary initially ++ contains a single empty dictionary of LANGUAGE; to add symbols to it, ++ call mdict_add_symbol(). Call mdict_free() when you're done with it. */ + +-extern struct dictionary * +- dict_create_linear_expandable (enum language language); ++extern struct multidictionary * ++ mdict_create_linear_expandable (enum language language); + +-/* The functions providing the interface to dictionaries. Note that +- the most common parts of the interface, namely symbol lookup, are +- only provided via iterator functions. */ ++/* The functions providing the interface to multi-language dictionaries. ++ Note that the most common parts of the interface, namely symbol lookup, ++ are only provided via iterator functions. */ + +-/* Free the memory used by a dictionary that's not on an obstack. (If ++/* Free the memory used by a multidictionary that's not on an obstack. (If + any.) */ + +-extern void dict_free (struct dictionary *dict); ++extern void mdict_free (struct multidictionary *mdict); + +-/* Add a symbol to an expandable dictionary. */ ++/* Add a symbol to an expandable multidictionary. */ + +-extern void dict_add_symbol (struct dictionary *dict, struct symbol *sym); ++extern void mdict_add_symbol (struct multidictionary *mdict, ++ struct symbol *sym); + +-/* Utility to add a list of symbols to a dictionary. */ ++/* Utility to add a list of symbols to a multidictionary. */ + +-extern void dict_add_pending (struct dictionary *dict, +- const struct pending *symbol_list); ++extern void mdict_add_pending (struct multidictionary *mdict, ++ const struct pending *symbol_list); + +-/* Is the dictionary empty? */ ++/* Is the multidictionary empty? */ + +-extern int dict_empty (struct dictionary *dict); ++extern int mdict_empty (struct multidictionary *mdict); + + /* A type containing data that is used when iterating over all symbols + in a dictionary. Don't ever look at its innards; this type would +@@ -128,44 +127,46 @@ struct mdict_iterator + unsigned short current_idx; + }; + +-/* Initialize ITERATOR to point at the first symbol in DICT, and +- return that first symbol, or NULL if DICT is empty. */ ++/* Initialize ITERATOR to point at the first symbol in MDICT, and ++ return that first symbol, or NULL if MDICT is empty. */ + +-extern struct symbol *dict_iterator_first (const struct dictionary *dict, +- struct dict_iterator *iterator); ++extern struct symbol * ++ mdict_iterator_first (const struct multidictionary *mdict, ++ struct mdict_iterator *miterator); + +-/* Advance ITERATOR, and return the next symbol, or NULL if there are ++/* Advance MITERATOR, and return the next symbol, or NULL if there are + no more symbols. Don't call this if you've previously received +- NULL from dict_iterator_first or dict_iterator_next on this ++ NULL from mdict_iterator_first or mdict_iterator_next on this + iteration. */ + +-extern struct symbol *dict_iterator_next (struct dict_iterator *iterator); ++extern struct symbol *mdict_iterator_next (struct mdict_iterator *miterator); + +-/* Initialize ITERATOR to point at the first symbol in DICT whose ++/* Initialize MITERATOR to point at the first symbol in MDICT whose + SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (which must use + the same conventions as strcmp_iw and be compatible with any + dictionary hashing function), and return that first symbol, or NULL + if there are no such symbols. */ + +-extern struct symbol *dict_iter_match_first (const struct dictionary *dict, +- const lookup_name_info &name, +- struct dict_iterator *iterator); ++extern struct symbol * ++ mdict_iter_match_first (const struct multidictionary *mdict, ++ const lookup_name_info &name, ++ struct mdict_iterator *miterator); + +-/* Advance ITERATOR to point at the next symbol in DICT whose ++/* Advance MITERATOR to point at the next symbol in MDICT whose + SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (see + dict_iter_match_first), or NULL if there are no more such symbols. + Don't call this if you've previously received NULL from +- dict_iterator_match_first or dict_iterator_match_next on this +- iteration. And don't call it unless ITERATOR was created by a +- previous call to dict_iter_match_first with the same NAME and COMPARE. */ ++ mdict_iterator_match_first or mdict_iterator_match_next on this ++ iteration. And don't call it unless MITERATOR was created by a ++ previous call to mdict_iter_match_first with the same NAME and COMPARE. */ + +-extern struct symbol *dict_iter_match_next (const lookup_name_info &name, +- struct dict_iterator *iterator); ++extern struct symbol *mdict_iter_match_next (const lookup_name_info &name, ++ struct mdict_iterator *miterator); + +-/* Return some notion of the size of the dictionary: the number of ++/* Return some notion of the size of the multidictionary: the number of + symbols if we have that, the number of hash buckets otherwise. */ + +-extern int dict_size (const struct dictionary *dict); ++extern int mdict_size (const struct multidictionary *mdict); + + /* Macro to loop through all symbols in a dictionary DICT, in no + particular order. ITER is a struct dict_iterator (NOTE: __not__ a +@@ -175,8 +176,8 @@ extern int dict_size (const struct dictionary *dict); + early by a break if you desire. */ + + #define ALL_DICT_SYMBOLS(dict, iter, sym) \ +- for ((sym) = dict_iterator_first ((dict), &(iter)); \ ++ for ((sym) = mdict_iterator_first ((dict), &(iter)); \ + (sym); \ +- (sym) = dict_iterator_next (&(iter))) ++ (sym) = mdict_iterator_next (&(iter))) + + #endif /* DICTIONARY_H */ +diff --git a/gdb/jit.c b/gdb/jit.c +--- a/gdb/jit.c ++++ b/gdb/jit.c +@@ -651,14 +651,12 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) + size_t blockvector_size; + CORE_ADDR begin, end; + struct blockvector *bv; +- enum language language; + + actual_nblocks = FIRST_LOCAL_BLOCK + stab->nblocks; + + cust = allocate_compunit_symtab (objfile, stab->file_name); + allocate_symtab (cust, stab->file_name); + add_compunit_symtab_to_objfile (cust); +- language = compunit_language (cust); + + /* JIT compilers compile in memory. */ + COMPUNIT_DIRNAME (cust) = NULL; +@@ -702,8 +700,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) + TARGET_CHAR_BIT, + "void"); + +- BLOCK_DICT (new_block) = dict_create_linear (&objfile->objfile_obstack, +- language, NULL); ++ BLOCK_MULTIDICT (new_block) ++ = mdict_create_linear (&objfile->objfile_obstack, NULL); + /* The address range. */ + BLOCK_START (new_block) = (CORE_ADDR) gdb_block_iter->begin; + BLOCK_END (new_block) = (CORE_ADDR) gdb_block_iter->end; +@@ -740,8 +738,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) + new_block = (i == GLOBAL_BLOCK + ? allocate_global_block (&objfile->objfile_obstack) + : allocate_block (&objfile->objfile_obstack)); +- BLOCK_DICT (new_block) = dict_create_linear (&objfile->objfile_obstack, +- language, NULL); ++ BLOCK_MULTIDICT (new_block) ++ = mdict_create_linear (&objfile->objfile_obstack, NULL); + BLOCK_SUPERBLOCK (new_block) = block_iter; + block_iter = new_block; + +diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c +--- a/gdb/mdebugread.c ++++ b/gdb/mdebugread.c +@@ -4534,7 +4534,7 @@ static void + add_symbol (struct symbol *s, struct symtab *symtab, struct block *b) + { + symbol_set_symtab (s, symtab); +- dict_add_symbol (BLOCK_DICT (b), s); ++ mdict_add_symbol (BLOCK_MULTIDICT (b), s); + } + + /* Add a new block B to a symtab S. */ +@@ -4762,7 +4762,7 @@ new_bvect (int nblocks) + } + + /* Allocate and zero a new block of language LANGUAGE, and set its +- BLOCK_DICT. If function is non-zero, assume the block is ++ BLOCK_MULTIDICT. If function is non-zero, assume the block is + associated to a function, and make sure that the symbols are stored + linearly; otherwise, store them hashed. */ + +@@ -4775,9 +4775,9 @@ new_block (enum block_type type, enum language language) + struct block *retval = XCNEW (struct block); + + if (type == FUNCTION_BLOCK) +- BLOCK_DICT (retval) = dict_create_linear_expandable (language); ++ BLOCK_MULTIDICT (retval) = mdict_create_linear_expandable (language); + else +- BLOCK_DICT (retval) = dict_create_hashed_expandable (language); ++ BLOCK_MULTIDICT (retval) = mdict_create_hashed_expandable (language); + + return retval; + } +diff --git a/gdb/objfiles.c b/gdb/objfiles.c +--- a/gdb/objfiles.c ++++ b/gdb/objfiles.c +@@ -813,40 +813,40 @@ objfile_relocate1 (struct objfile *objfile, + } + + ALL_OBJFILE_COMPUNITS (objfile, cust) +- { +- const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust); +- int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust); +- +- if (BLOCKVECTOR_MAP (bv)) +- addrmap_relocate (BLOCKVECTOR_MAP (bv), +- ANOFFSET (delta, block_line_section)); +- +- for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i) +- { +- struct block *b; +- struct symbol *sym; +- struct dict_iterator iter; +- +- b = BLOCKVECTOR_BLOCK (bv, i); +- BLOCK_START (b) += ANOFFSET (delta, block_line_section); +- BLOCK_END (b) += ANOFFSET (delta, block_line_section); +- +- if (BLOCK_RANGES (b) != nullptr) +- for (int j = 0; j < BLOCK_NRANGES (b); j++) ++ { ++ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust); ++ int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust); ++ ++ if (BLOCKVECTOR_MAP (bv)) ++ addrmap_relocate (BLOCKVECTOR_MAP (bv), ++ ANOFFSET (delta, block_line_section)); ++ ++ for (int i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i) ++ { ++ struct block *b; ++ struct symbol *sym; ++ struct mdict_iterator miter; ++ ++ b = BLOCKVECTOR_BLOCK (bv, i); ++ BLOCK_START (b) += ANOFFSET (delta, block_line_section); ++ BLOCK_END (b) += ANOFFSET (delta, block_line_section); ++ ++ if (BLOCK_RANGES (b) != nullptr) ++ for (int j = 0; j < BLOCK_NRANGES (b); j++) ++ { ++ BLOCK_RANGE_START (b, j) ++ += ANOFFSET (delta, block_line_section); ++ BLOCK_RANGE_END (b, j) += ANOFFSET (delta, block_line_section); ++ } ++ ++ /* We only want to iterate over the local symbols, not any ++ symbols in included symtabs. */ ++ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (b), miter, sym) + { +- BLOCK_RANGE_START (b, j) +- += ANOFFSET (delta, block_line_section); +- BLOCK_RANGE_END (b, j) += ANOFFSET (delta, block_line_section); ++ relocate_one_symbol (sym, objfile, delta); + } +- +- /* We only want to iterate over the local symbols, not any +- symbols in included symtabs. */ +- ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym) +- { +- relocate_one_symbol (sym, objfile, delta); +- } +- } +- } ++ } ++ } + } + + /* Relocate isolated symbols. */ +diff --git a/gdb/symmisc.c b/gdb/symmisc.c +--- a/gdb/symmisc.c ++++ b/gdb/symmisc.c +@@ -275,7 +275,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) + struct objfile *objfile = SYMTAB_OBJFILE (symtab); + struct gdbarch *gdbarch = get_objfile_arch (objfile); + int i; +- struct dict_iterator iter; ++ struct mdict_iterator miter; + int len; + struct linetable *l; + const struct blockvector *bv; +@@ -331,7 +331,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) + even if we're using a hashtable, but nothing else but this message + wants it. */ + fprintf_filtered (outfile, ", %d syms/buckets in ", +- dict_size (BLOCK_DICT (b))); ++ mdict_size (BLOCK_MULTIDICT (b))); + fputs_filtered (paddress (gdbarch, BLOCK_START (b)), outfile); + fprintf_filtered (outfile, ".."); + fputs_filtered (paddress (gdbarch, BLOCK_END (b)), outfile); +@@ -349,7 +349,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) + /* Now print each symbol in this block (in no particular order, if + we're using a hashtable). Note that we only want this + block, not any blocks from included symtabs. */ +- ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym) ++ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (b), miter, sym) + { + TRY + { diff --git a/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-3of5.patch b/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-3of5.patch new file mode 100644 index 0000000..25b8320 --- /dev/null +++ b/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-3of5.patch @@ -0,0 +1,232 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Sergio Durigan Junior +Date: Fri, 11 Jan 2019 11:26:59 -0500 +Subject: + gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-3of5.patch + +;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +;; Keith Seitz, RHBZ#1560010. + +gdb/23712: Cleanup/Remove temporary dictionary functions + +Now that multidictionary's are being used, there is no longer any need +to retain the four temporary functions introduced in the beginning of +this series. + +This patch removes them. + +As an additional cleanup, since the single-language dictionaries are +no longer used outside dictionary.c, make all of those functions +static. + +gdb/ChangeLog: + + PR gdb/23712 + PR symtab/23010 + * dictionary.c (pending_to_vector): Remove. + (dict_create_hashed_1, dict_create_linear_1, dict_add_pending_1): + Remove _1 suffix, replacing functions of the same name. Update + all callers. + (dict_create_hashed, dict_create_hashed_expandable) + (dict_create_linear, dict_create_linear_expandable, dict_free) + (dict_add_symbol, dict_add_pending, dict_size, dict_empty): + Make functions static. + +diff --git a/gdb/dictionary.c b/gdb/dictionary.c +--- a/gdb/dictionary.c ++++ b/gdb/dictionary.c +@@ -342,31 +342,14 @@ static void insert_symbol_hashed (struct dictionary *dict, + + static void expand_hashtable (struct dictionary *dict); + +-/* A function to convert a linked list into a vector. */ +- +-static std::vector +-pending_to_vector (const struct pending *symbol_list) +-{ +- std::vector symlist; +- +- for (const struct pending *list_counter = symbol_list; +- list_counter != nullptr; list_counter = list_counter->next) +- { +- for (int i = list_counter->nsyms - 1; i >= 0; --i) +- symlist.push_back (list_counter->symbol[i]); +- } +- +- return symlist; +-} +- + /* The creation functions. */ + +-/* A function to transition dict_create_hashed to new API. */ ++/* Create a hashed dictionary of a given language. */ + + static struct dictionary * +-dict_create_hashed_1 (struct obstack *obstack, +- enum language language, +- const std::vector &symbol_list) ++dict_create_hashed (struct obstack *obstack, ++ enum language language, ++ const std::vector &symbol_list) + { + /* Allocate the dictionary. */ + struct dictionary *retval = XOBNEW (obstack, struct dictionary); +@@ -388,21 +371,9 @@ dict_create_hashed_1 (struct obstack *obstack, + return retval; + } + +-/* See dictionary.h. */ +- +-struct dictionary * +-dict_create_hashed (struct obstack *obstack, +- enum language language, +- const struct pending *symbol_list) +-{ +- std::vector symlist = pending_to_vector (symbol_list); +- +- return dict_create_hashed_1 (obstack, language, symlist); +-} ++/* Create an expandable hashed dictionary of a given language. */ + +-/* See dictionary.h. */ +- +-extern struct dictionary * ++static struct dictionary * + dict_create_hashed_expandable (enum language language) + { + struct dictionary *retval = XNEW (struct dictionary); +@@ -417,12 +388,12 @@ dict_create_hashed_expandable (enum language language) + return retval; + } + +-/* A function to transition dict_create_linear to new API. */ ++/* Create a linear dictionary of a given language. */ + + static struct dictionary * +-dict_create_linear_1 (struct obstack *obstack, +- enum language language, +- const std::vector &symbol_list) ++dict_create_linear (struct obstack *obstack, ++ enum language language, ++ const std::vector &symbol_list) + { + struct dictionary *retval = XOBNEW (obstack, struct dictionary); + DICT_VECTOR (retval) = &dict_linear_vector; +@@ -442,21 +413,9 @@ dict_create_linear_1 (struct obstack *obstack, + return retval; + } + +-/* See dictionary.h. */ +- +-struct dictionary * +-dict_create_linear (struct obstack *obstack, +- enum language language, +- const struct pending *symbol_list) +-{ +- std::vector symlist = pending_to_vector (symbol_list); +- +- return dict_create_linear_1 (obstack, language, symlist); +-} +- +-/* See dictionary.h. */ ++/* Create an expandable linear dictionary of a given language. */ + +-struct dictionary * ++static struct dictionary * + dict_create_linear_expandable (enum language language) + { + struct dictionary *retval = XNEW (struct dictionary); +@@ -476,7 +435,7 @@ dict_create_linear_expandable (enum language language) + /* Free the memory used by a dictionary that's not on an obstack. (If + any.) */ + +-void ++static void + dict_free (struct dictionary *dict) + { + (DICT_VECTOR (dict))->free (dict); +@@ -484,34 +443,24 @@ dict_free (struct dictionary *dict) + + /* Add SYM to DICT. DICT had better be expandable. */ + +-void ++static void + dict_add_symbol (struct dictionary *dict, struct symbol *sym) + { + (DICT_VECTOR (dict))->add_symbol (dict, sym); + } + +-/* A function to transition dict_add_pending to new API. */ ++/* Utility to add a list of symbols to a dictionary. ++ DICT must be an expandable dictionary. */ + + static void +-dict_add_pending_1 (struct dictionary *dict, +- const std::vector &symbol_list) ++dict_add_pending (struct dictionary *dict, ++ const std::vector &symbol_list) + { + /* Preserve ordering by reversing the list. */ + for (auto sym = symbol_list.rbegin (); sym != symbol_list.rend (); ++sym) + dict_add_symbol (dict, *sym); + } + +-/* Utility to add a list of symbols to a dictionary. +- DICT must be an expandable dictionary. */ +- +-void +-dict_add_pending (struct dictionary *dict, const struct pending *symbol_list) +-{ +- std::vector symlist = pending_to_vector (symbol_list); +- +- dict_add_pending_1 (dict, symlist); +-} +- + /* Initialize ITERATOR to point at the first symbol in DICT, and + return that first symbol, or NULL if DICT is empty. */ + +@@ -548,7 +497,7 @@ dict_iter_match_next (const lookup_name_info &name, + ->iter_match_next (name, iterator); + } + +-int ++static int + dict_size (const struct dictionary *dict) + { + return (DICT_VECTOR (dict))->size (dict); +@@ -560,7 +509,7 @@ dict_size (const struct dictionary *dict) + + /* Test to see if DICT is empty. */ + +-int ++static int + dict_empty (struct dictionary *dict) + { + struct dict_iterator iter; +@@ -1019,7 +968,7 @@ mdict_create_hashed (struct obstack *obstack, + std::vector symlist = pair.second; + + retval->dictionaries[idx++] +- = dict_create_hashed_1 (obstack, language, symlist); ++ = dict_create_hashed (obstack, language, symlist); + } + + return retval; +@@ -1064,7 +1013,7 @@ mdict_create_linear (struct obstack *obstack, + std::vector symlist = pair.second; + + retval->dictionaries[idx++] +- = dict_create_linear_1 (obstack, language, symlist); ++ = dict_create_linear (obstack, language, symlist); + } + + return retval; +@@ -1210,7 +1159,7 @@ mdict_add_pending (struct multidictionary *mdict, + dict = create_new_language_dictionary (mdict, language); + } + +- dict_add_pending_1 (dict, symlist); ++ dict_add_pending (dict, symlist); + } + } + diff --git a/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-4of5.patch b/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-4of5.patch new file mode 100644 index 0000000..354c494 --- /dev/null +++ b/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-4of5.patch @@ -0,0 +1,90 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Sergio Durigan Junior +Date: Fri, 11 Jan 2019 11:29:25 -0500 +Subject: + gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-4of5.patch + +;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +;; Keith Seitz, RHBZ#1560010. + +gdb/23712: Remove dw2_add_symbol_to_list + +Finally, we can remove dw2_add_symbol_to_list since the wrapper function +originally introduced to catch this multi-language scenario is no longer +needed. With multi-language dictionaries, we can now support adding +symbols of multiple languages, negating the need for the assertion +entirely. + +This patch should now fix gdb/23712 (and symtab/23010). At least it will +if the NULL buildsym_compunit problem doesn't strike first (see gdb/23773). + +gdb/ChangeLog: + + PR gdb/23712 + PR symtab/23010 + * dwarf2read.c (dw2_add_symbol_to_list): Remove. + (fixup_go_packaging, new_symbol): Use add_symbol_to_list. + +diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -9715,23 +9715,6 @@ compute_delayed_physnames (struct dwarf2_cu *cu) + cu->method_list.clear (); + } + +-/* A wrapper for add_symbol_to_list to ensure that SYMBOL's language is +- the same as all other symbols in LISTHEAD. If a new symbol is added +- with a different language, this function asserts. */ +- +-static inline void +-dw2_add_symbol_to_list (struct symbol *symbol, struct pending **listhead) +-{ +- /* Only assert if LISTHEAD already contains symbols of a different +- language (dict_create_hashed/insert_symbol_hashed requires that all +- symbols in this list are of the same language). */ +- gdb_assert ((*listhead) == NULL +- || (SYMBOL_LANGUAGE ((*listhead)->symbol[0]) +- == SYMBOL_LANGUAGE (symbol))); +- +- add_symbol_to_list (symbol, listhead); +-} +- + /* Go objects should be embedded in a DW_TAG_module DIE, + and it's not clear if/how imported objects will appear. + To keep Go support simple until that's worked out, +@@ -9803,7 +9786,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) + SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF; + SYMBOL_TYPE (sym) = type; + +- dw2_add_symbol_to_list (sym, &global_symbols); ++ add_symbol_to_list (sym, &global_symbols); + + xfree (package_name); + } +@@ -21387,7 +21370,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, + SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_core_addr; + SYMBOL_DOMAIN (sym) = LABEL_DOMAIN; + SYMBOL_ACLASS_INDEX (sym) = LOC_LABEL; +- dw2_add_symbol_to_list (sym, cu->list_in_scope); ++ add_symbol_to_list (sym, cu->list_in_scope); + break; + case DW_TAG_subprogram: + /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by +@@ -21645,7 +21628,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, + case DW_TAG_common_block: + SYMBOL_ACLASS_INDEX (sym) = LOC_COMMON_BLOCK; + SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN; +- dw2_add_symbol_to_list (sym, cu->list_in_scope); ++ add_symbol_to_list (sym, cu->list_in_scope); + break; + default: + /* Not a tag we recognize. Hopefully we aren't processing +@@ -21665,7 +21648,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, + } + + if (list_to_add != NULL) +- dw2_add_symbol_to_list (sym, list_to_add); ++ add_symbol_to_list (sym, list_to_add); + + /* For the benefit of old versions of GCC, check for anonymous + namespaces based on the demangled name. */ diff --git a/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch b/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch new file mode 100644 index 0000000..959b577 --- /dev/null +++ b/SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch @@ -0,0 +1,183 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Sergio Durigan Junior +Date: Fri, 11 Jan 2019 11:31:59 -0500 +Subject: + gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch + +;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.' +;; Keith Seitz, RHBZ#1560010. + +gdb/23712: Test case for multidictionary + +This is a test derived from one of the reproducers in symtab/23010. +The DIE tree used here is typical of compilations with LTO, where an +artificial parent DIE of language C99 imports DIEs of other languages. + +gdb/testsuite/ChangeLog: + + PR gdb/23712 + PR symtab/23010 + * gdb.dwarf2/multidictionary.exp: New file. + +diff --git a/gdb/testsuite/gdb.dwarf2/multidictionary.exp b/gdb/testsuite/gdb.dwarf2/multidictionary.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/multidictionary.exp +@@ -0,0 +1,157 @@ ++# Copyright 2019 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 . ++ ++# A test of multi-language dictionaries, a solution to symtab/23010 et al. ++ ++load_lib dwarf.exp ++ ++# This test can only be run on targets which support DWARF. ++if {![dwarf2_support]} { ++ return 0 ++} ++ ++standard_testfile main.c .S ++ ++# Create the DWARF. This is derived from the reproducer in the bug ++# mentioned above. This DIE tree is typical of compilations wtih ++# LTO enabled. ++ ++set asm_file [standard_output_file $srcfile2] ++Dwarf::assemble $asm_file { ++ declare_labels D45d9 D5079 D5080 D50a9 D50af D5ab2 D5ac2 D5ace D5acf ++ declare_labels D2135f D2216a D22171 D226c4 D226ca D244ca \ ++ D245da D245e6 ++ declare_labels D41c21 D42025 D42045 D42038 D42045 D420b5 ++ ++ cu {} { ++ D45d9: compile_unit { ++ {language @DW_LANG_C_plus_plus} ++ {name "SerialPortUtils.cpp"} ++ } { ++ D5079: base_type { ++ {byte_size 1 sdata} ++ {encoding @DW_ATE_unsigned} ++ {name "char"} ++ } ++ ++ D5080: const_type { ++ {type :$D5079} ++ } ++ ++ D50a9: pointer_type { ++ {byte_size 4 sdata} ++ {type :$D5080} ++ } ++ ++ D50af: const_type { ++ {type :$D50a9} ++ } ++ ++ D5ab2: subprogram { ++ {external 1 flag} ++ {linkage_name "_Z18SerialSyncWriteStrPKc"} ++ } { ++ D5ac2: formal_parameter { ++ {name "msg"} ++ {type :$D50af} ++ } ++ D5ace: lexical_block {} { ++ D5acf: DW_TAG_variable { ++ {name "p"} ++ {type :$D50a9} ++ } ++ } ++ } ++ } ++ } ++ ++ cu {} { ++ D2135f: compile_unit { ++ {language @DW_LANG_C_plus_plus} ++ {name "Main.cpp"} ++ } { ++ D2216a: base_type { ++ {byte_size 1 sdata} ++ {encoding @DW_ATE_unsigned_char} ++ {name "char"} ++ } ++ ++ D22171: const_type { ++ {type :$D2216a} ++ } ++ ++ D226c4: pointer_type { ++ {byte_size 4 sdata} ++ {type :$D22171} ++ } ++ ++ D226ca: const_type { ++ {type :$D226c4} ++ } ++ ++ D245da: subprogram { ++ {name "PrintPanicMsg"} ++ } { ++ D245e6: formal_parameter { ++ {name "msg"} ++ {type :$D226ca} ++ } ++ } ++ } ++ } ++ ++ cu {} { ++ D41c21: compile_unit { ++ {language @DW_LANG_C99} ++ {name ""} ++ } { ++ D42025: subprogram { ++ {abstract_origin %$D245da} ++ {low_pc 0x80b60 addr} ++ {high_pc 0x6c data4} ++ } { ++ D42038: formal_parameter { ++ {abstract_origin %$D245e6} ++ } ++ ++ D42045: inlined_subroutine { ++ {abstract_origin %$D5ab2} ++ {low_pc 0x8060 addr} ++ {high_pc 0xc data4} ++ } { ++ D420b5: formal_parameter { ++ {abstract_origin %$D5ac2} ++ } ++ } ++ } ++ } ++ } ++} ++ ++# Build the test executable. ++if {[build_executable $testfile.exp $testfile [list $asm_file $srcfile] {}] \ ++ == -1} { ++ return -1 ++} ++ ++# We force the DIEs above to be read in via "-readnow". ++gdb_spawn_with_cmdline_opts "-readnow" ++gdb_load $binfile ++ ++# All we need to do is check whether GDB is alive. Without ++# multidictionaries, it will either crash, assert, or throw an ++# internal_error. ++gdb_test "p 1" "= 1" "GDB is alive" ++ diff --git a/SOURCES/gdb-rhbz1639242-fix-dwarf2_find_containing_comp_unit-binary-search.patch b/SOURCES/gdb-rhbz1639242-fix-dwarf2_find_containing_comp_unit-binary-search.patch new file mode 100644 index 0000000..b56aee1 --- /dev/null +++ b/SOURCES/gdb-rhbz1639242-fix-dwarf2_find_containing_comp_unit-binary-search.patch @@ -0,0 +1,176 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Sergio Durigan Junior +Date: Fri, 30 Nov 2018 15:20:27 -0500 +Subject: + gdb-rhbz1639242-fix-dwarf2_find_containing_comp_unit-binary-search.patch + +;; Fix for 'py-bt is broken, results in exception'. +;; RHBZ 1639242 + +Fix dwarf2read.c:dwarf2_find_containing_comp_unit's binary search + +First of all, I would like to express my gratitude to Keith Seitz, Jan +Kratochvil and Tom Tromey, who were really kind and helped a lot with +this bug. The patch itself was authored by Jan. + +This all began with: + + https://bugzilla.redhat.com/show_bug.cgi?id=1639242 + py-bt is broken, results in exception + +In summary, the error reported by the bug above is: + + $ gdb -args python3 + GNU gdb (GDB) Fedora 8.1.1-3.fc28 + (...) + Reading symbols from python3...Reading symbols from /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug...done. + done. + Dwarf Error: could not find partial DIE containing offset 0x316 [in module /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug] + +After a long investigation, and after thinking that the problem might +actually be on DWZ's side, we were able to determine that there's +something wrong going on when +dwarf2read.c:dwarf2_find_containing_comp_unit performs a binary search +over all of the CUs belonging to an objfile in order to find the CU +which contains a DIE at an specific offset. The current algorithm is: + + static struct dwarf2_per_cu_data * + dwarf2_find_containing_comp_unit (sect_offset sect_off, + unsigned int offset_in_dwz, + struct dwarf2_per_objfile *dwarf2_per_objfile) + { + struct dwarf2_per_cu_data *this_cu; + int low, high; + const sect_offset *cu_off; + + low = 0; + high = dwarf2_per_objfile->all_comp_units.size () - 1; + while (high > low) + { + struct dwarf2_per_cu_data *mid_cu; + int mid = low + (high - low) / 2; + + mid_cu = dwarf2_per_objfile->all_comp_units[mid]; + cu_off = &mid_cu->sect_off; + if (mid_cu->is_dwz > offset_in_dwz + || (mid_cu->is_dwz == offset_in_dwz && *cu_off >= sect_off)) + high = mid; + else + low = mid + 1; + } + +For the sake of this example, let's consider that "sect_off = +0x7d". + +There are a few important things going on here. First, +"dwarf2_per_objfile->all_comp_units ()" will be sorted first by +whether the CU is a DWZ CU, and then by cu->sect_off. In this +specific bug, "offset_in_dwz" is false, which means that, for the most +part of the loop, we're going to do "high = mid" (i.e, we'll work with +the lower part of the vector). + +In our particular case, when we reach the part where "mid_cu->is_dwz +== offset_in_dwz" (i.e, both are false), we end up with "high = 2" and +"mid = 1". I.e., there are only 2 elements in the vector who are not +DWZ. The vector looks like this: + + #0: cu->sect_off = 0; length = 114; is_dwz = false <-- low + #1: cu->sect_off = 114; length = 7796; is_dwz = false <-- mid + #2: cu->sect_off = 0; length = 28; is_dwz = true <-- high + ... + +The CU we want is #1, which is exactly where "mid" is. Also, #1 is +not DWZ, which is also exactly what we want. So we perform the second +comparison: + + (mid_cu->is_dwz == offset_in_dwz && *cu_off >= sect_off) + ^^^^^^^^^^^^^^^^^^^ + +Because "*cu_off = 114" and "sect_off = 0x7d", this evaluates to +false, so we end up with "low = mid + 1 = 2", which actually gives us +the wrong CU (i.e., a CU that is DWZ). Next in the code, GDB does: + + gdb_assert (low == high); + this_cu = dwarf2_per_objfile->all_comp_units[low]; + cu_off = &this_cu->sect_off; + if (this_cu->is_dwz != offset_in_dwz || *cu_off > sect_off) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + { + if (low == 0 || this_cu->is_dwz != offset_in_dwz) + error (_("Dwarf Error: could not find partial DIE containing " + "offset %s [in module %s]"), + sect_offset_str (sect_off), + bfd_get_filename (dwarf2_per_objfile->objfile->obfd)); + ... + +Triggering the error we saw in the original bug report. + +It's important to notice that we see the error message because the +selected CU is a DWZ one, but we're looking for a non-DWZ CU here. +However, even when the selected CU is *not* a DWZ (and we don't see +any error message), we still end up with the wrong CU. For example, +suppose that the vector had: + + #0: cu->sect_off = 0; length = 114; is_dwz = false + #1: cu->sect_off = 114; length = 7796; is_dwz = false + #2: cu->sect_off = 7910; length = 28; is_dwz = false + ... + +I.e., #2's "is_dwz" is false instead of true. In this case, we still +want #1, because that's where the DIE is located. After the loop ends +up in #2, we have "is_dwz" as false, which is what we wanted, so we +compare offsets. In this case, "7910 >= 0x7d", so we set "mid = high += 2". Next iteration, we have "mid = 0 + (2 - 0) / 2 = 1", and thus +we examining #1. "is_dwz" is still false, but "114 >= 0x7d" also +evaluates to false, so "low = mid + 1 = 2", which makes the loop stop. +Therefore, we end up choosing #2 as our CU, even though #1 is the +right one. + +The problem here is happening because we're comparing "sect_off" +directly against "*cu_off", while we should actually be comparing +against "*cu_off + mid_cu->length" (i.e., the end offset): + + ... + || (mid_cu->is_dwz == offset_in_dwz + && *cu_off + mid_cu->length >= sect_off)) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ... + +And this is what the patch does. The idea is that if GDB is searching +for an offset that falls above the *end* of the CU being +analyzed (i.e., "mid"), then the next iteration should try a +higher-offset CU next. The previous algorithm was using +the *beginning* of the CU. + +Unfortunately, I could not devise a testcase for this problem, so I am +proposing a fix with this huge explanation attached to it in the hope +that it is sufficient. After talking a bit to Keith (our testcase +guru), it seems that one would have to create an objfile with both DWZ +and non-DWZ sections, which may prove very hard to do, I think. + +I ran this patch on our BuildBot, and no regressions were detected. + +gdb/ChangeLog: +2018-11-30 Jan Kratochvil + Keith Seitz + Tom Tromey + Sergio Durigan Junior + + https://bugzilla.redhat.com/show_bug.cgi?id=1613614 + * dwarf2read.c (dwarf2_find_containing_comp_unit): Add + 'mid_cu->length' to '*cu_off' when checking if 'sect_off' is + inside the CU. + +diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -25039,7 +25039,8 @@ dwarf2_find_containing_comp_unit (sect_offset sect_off, + mid_cu = dwarf2_per_objfile->all_comp_units[mid]; + cu_off = &mid_cu->sect_off; + if (mid_cu->is_dwz > offset_in_dwz +- || (mid_cu->is_dwz == offset_in_dwz && *cu_off >= sect_off)) ++ || (mid_cu->is_dwz == offset_in_dwz ++ && *cu_off + mid_cu->length >= sect_off)) + high = mid; + else + low = mid + 1; diff --git a/SOURCES/gdb-rhbz1653410-avoid-crash-when-calling-warning-too-early.patch b/SOURCES/gdb-rhbz1653410-avoid-crash-when-calling-warning-too-early.patch new file mode 100644 index 0000000..59bb698 --- /dev/null +++ b/SOURCES/gdb-rhbz1653410-avoid-crash-when-calling-warning-too-early.patch @@ -0,0 +1,145 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Tom Tromey +Date: Fri, 5 Oct 2018 14:54:35 -0600 +Subject: gdb-rhbz1653410-avoid-crash-when-calling-warning-too-early.patch + +;; Fix for 'GDB crashes when running from a deleted directory' +;; (Tom Tromey, RHBZ#1653410) + +Avoid crash when calling warning too early + +I noticed that if you pass the name of an existing file (not a +directory) as the argument to --data-directory, gdb will crash: + + $ ./gdb -nx --data-directory ./gdb + ../../binutils-gdb/gdb/target.c:590:56: runtime error: member call on null pointer of type 'struct target_ops' + +This was later reported as PR gdb/23838. + +This happens because warning ends up calling +target_supports_terminal_ours, which calls current_top_target, which +returns nullptr this early. + +This fixes the problem by handling this case specially in +target_supports_terminal_ours. I also changed +target_supports_terminal_ours to return bool. + +gdb/ChangeLog +2018-11-08 Tom Tromey + + PR gdb/23555: + PR gdb/23838: + * target.h (target_supports_terminal_ours): Return bool. + * target.c (target_supports_terminal_ours): Handle case where + current_top_target returns nullptr. Return bool. + +gdb/testsuite/ChangeLog +2018-11-08 Tom Tromey + + PR gdb/23555: + PR gdb/23838: + * gdb.base/warning.exp: New file. + +diff --git a/gdb/ChangeLog b/gdb/ChangeLog +--- a/gdb/ChangeLog ++++ b/gdb/ChangeLog +@@ -1,3 +1,11 @@ ++2018-11-08 Tom Tromey ++ ++ PR gdb/23555: ++ PR gdb/23838: ++ * target.h (target_supports_terminal_ours): Return bool. ++ * target.c (target_supports_terminal_ours): Handle case where ++ current_top_target returns nullptr. Return bool. ++ + 2018-08-16 Gary Benson + + PR gdb/13000: +diff --git a/gdb/target.c b/gdb/target.c +--- a/gdb/target.c ++++ b/gdb/target.c +@@ -584,10 +584,16 @@ target_terminal::info (const char *arg, int from_tty) + + /* See target.h. */ + +-int ++bool + target_supports_terminal_ours (void) + { +- return current_top_target ()->supports_terminal_ours (); ++ /* This can be called before there is any target, so we must check ++ for nullptr here. */ ++ target_ops *top = current_top_target (); ++ ++ if (top == nullptr) ++ return false; ++ return top->supports_terminal_ours (); + } + + static void +diff --git a/gdb/target.h b/gdb/target.h +--- a/gdb/target.h ++++ b/gdb/target.h +@@ -1576,7 +1576,7 @@ extern int target_remove_breakpoint (struct gdbarch *gdbarch, + /* Return true if the target stack has a non-default + "terminal_ours" method. */ + +-extern int target_supports_terminal_ours (void); ++extern bool target_supports_terminal_ours (void); + + /* Kill the inferior process. Make it go away. */ + +diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog +--- a/gdb/testsuite/ChangeLog ++++ b/gdb/testsuite/ChangeLog +@@ -1,3 +1,9 @@ ++2018-11-08 Tom Tromey ++ ++ PR gdb/23555: ++ PR gdb/23838: ++ * gdb.base/warning.exp: New file. ++ + 2018-09-04 Gary Benson + + * gdb.base/batch-exit-status.exp: Use gdb_test_multiple and expect +diff --git a/gdb/testsuite/gdb.base/warning.exp b/gdb/testsuite/gdb.base/warning.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/warning.exp +@@ -0,0 +1,36 @@ ++# Copyright 2018 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Test that an early warning does not cause a crash. ++ ++if {[is_remote host]} { ++ unsupported "warning.exp can only run on local host" ++ return ++} ++ ++set tname [standard_temp_file warning] ++set fd [open $tname w] ++puts $fd "anything" ++close $fd ++ ++set save $INTERNAL_GDBFLAGS ++set INTERNAL_GDBFLAGS "-nw -nx -data-directory $tname" ++ ++gdb_start ++ ++# Make sure gdb started up. ++gdb_test "echo 23\\n" "23" ++ ++set INTERNAL_GDBFLAGS $save diff --git a/SOURCES/gdb-rhbz1666249-suggest-yum-instead-of-dnf.patch b/SOURCES/gdb-rhbz1666249-suggest-yum-instead-of-dnf.patch new file mode 100644 index 0000000..39ed2d1 --- /dev/null +++ b/SOURCES/gdb-rhbz1666249-suggest-yum-instead-of-dnf.patch @@ -0,0 +1,20 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 8 Mar 2019 11:39:10 -0800 +Subject: gdb-rhbz1666249-suggest-yum-instead-of-dnf.patch + +;; Fix 'gdb suggests using "dnf debuginfo-install' +;; Keith Seitz, RHBZ 1666249 + +diff --git a/gdb/build-id.c b/gdb/build-id.c +--- a/gdb/build-id.c ++++ b/gdb/build-id.c +@@ -1013,6 +1013,8 @@ missing_rpm_list_print (void) + printf_unfiltered (_("Missing separate debuginfos, use: %s"), + #ifdef DNF_DEBUGINFO_INSTALL + "dnf " ++#else ++ "yum " + #endif + "debuginfo-install"); + for (array_iter = array; array_iter < array + missing_rpm_list_entries; diff --git a/SOURCES/gdb-rhbz1668635-libiberty-demangle_template-memleak.patch b/SOURCES/gdb-rhbz1668635-libiberty-demangle_template-memleak.patch new file mode 100644 index 0000000..885bc66 --- /dev/null +++ b/SOURCES/gdb-rhbz1668635-libiberty-demangle_template-memleak.patch @@ -0,0 +1,1699 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Fri, 8 Mar 2019 14:33:02 -0800 +Subject: gdb-rhbz1668635-libiberty-demangle_template-memleak.patch + +;; Fix 'libiberty: Memory leak in demangle_template function resulting in a denial of service" +;; Simon Marchi, RH BZ 1668635 + +gdb: Remove support for old mangling schemes + +An upcoming sync with gcc's libiberty [1] will remove support for old +mangling schemes (GNU v2, Lucid, ARM, HP and EDG). It will remove the +cplus_demangle_opname function, so we need to get rid of its usages in +GDB (it's a GNU v2 specific function). + +I think the changes are mostly relatively obvious, some hacks that were +necessary to support overloaded operators with GNU v2 mangling are not +needed anymore. + +The change in stabsread.c is perhaps less obvious. I think we could get +rid of more code in that region that is specific to old mangling +schemes, but I chose to do only the minimal changes required to remove +the cplus_demangle_opname uses. There is also a detailed comment just +above that explaining how GNU v2 and v3 mangled symbols are handled, I +decided to leave it as-is, since I wasn't sure which part to remove, +change or leave there. + +[1] The commit "Remove support for demangling GCC 2.x era mangling +schemes.", specifically. + +gdb/ChangeLog: + + * gdbtypes.c (check_stub_method_group): Remove handling of old + mangling schemes. + * linespec.c (find_methods): Likewise. + * stabsread.c (read_member_functions): Likewise. + * valops.c (search_struct_method): Likewise. + (value_struct_elt_for_reference): Likewise. + * NEWS: Mention this change. + +gdb/testsuite/ChangeLog: + + * gdb.cp/demangle.exp (test_gnu_style_demangling): Rename to... + (test_gnuv3_style_demangling): ... this. + (test_lucid_style_demangling): Remove. + (test_arm_style_demangling): Remove. + (test_hp_style_demangling): Remove. + (do_tests): Remove calls to the above. + +gdb/doc/ChangeLog: + + * gdb.texinfo (Print Settings): Remove mention of specific + demangle-style values, just refer to the in-process help. + +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -10390,31 +10390,10 @@ or demangled form. + @cindex symbol decoding style, C@t{++} + @kindex set demangle-style + @item set demangle-style @var{style} +-Choose among several encoding schemes used by different compilers to +-represent C@t{++} names. The choices for @var{style} are currently: +- +-@table @code +-@item auto +-Allow @value{GDBN} to choose a decoding style by inspecting your program. +-This is the default. +- +-@item gnu +-Decode based on the @sc{gnu} C@t{++} compiler (@code{g++}) encoding algorithm. +- +-@item hp +-Decode based on the HP ANSI C@t{++} (@code{aCC}) encoding algorithm. +- +-@item lucid +-Decode based on the Lucid C@t{++} compiler (@code{lcc}) encoding algorithm. +- +-@item arm +-Decode using the algorithm in the @cite{C@t{++} Annotated Reference Manual}. +-@strong{Warning:} this setting alone is not sufficient to allow +-debugging @code{cfront}-generated executables. @value{GDBN} would +-require further enhancement to permit that. +- +-@end table +-If you omit @var{style}, you will see a list of possible formats. ++Choose among several encoding schemes used by different compilers to represent ++C@t{++} names. If you omit @var{style}, you will see a list of possible ++formats. The default value is @var{auto}, which lets @value{GDBN} choose a ++decoding style by inspecting your program. + + @item show demangle-style + Display the encoding style currently in use for decoding C@t{++} symbols. +diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c +--- a/gdb/gdbtypes.c ++++ b/gdb/gdbtypes.c +@@ -2779,37 +2779,11 @@ check_stub_method_group (struct type *type, int method_id) + { + int len = TYPE_FN_FIELDLIST_LENGTH (type, method_id); + struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id); +- int j, found_stub = 0; + +- for (j = 0; j < len; j++) +- if (TYPE_FN_FIELD_STUB (f, j)) +- { +- found_stub = 1; ++ for (int j = 0; j < len; j++) ++ { ++ if (TYPE_FN_FIELD_STUB (f, j)) + check_stub_method (type, method_id, j); +- } +- +- /* GNU v3 methods with incorrect names were corrected when we read +- in type information, because it was cheaper to do it then. The +- only GNU v2 methods with incorrect method names are operators and +- destructors; destructors were also corrected when we read in type +- information. +- +- Therefore the only thing we need to handle here are v2 operator +- names. */ +- if (found_stub && !startswith (TYPE_FN_FIELD_PHYSNAME (f, 0), "_Z")) +- { +- int ret; +- char dem_opname[256]; +- +- ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, +- method_id), +- dem_opname, DMGL_ANSI); +- if (!ret) +- ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, +- method_id), +- dem_opname, 0); +- if (ret) +- TYPE_FN_FIELDLIST_NAME (type, method_id) = xstrdup (dem_opname); + } + } + +diff --git a/gdb/linespec.c b/gdb/linespec.c +--- a/gdb/linespec.c ++++ b/gdb/linespec.c +@@ -1234,17 +1234,6 @@ find_methods (struct type *t, enum language t_lang, const char *name, + --method_counter) + { + const char *method_name = TYPE_FN_FIELDLIST_NAME (t, method_counter); +- char dem_opname[64]; +- +- if (startswith (method_name, "__") || +- startswith (method_name, "op") || +- startswith (method_name, "type")) +- { +- if (cplus_demangle_opname (method_name, dem_opname, DMGL_ANSI)) +- method_name = dem_opname; +- else if (cplus_demangle_opname (method_name, dem_opname, 0)) +- method_name = dem_opname; +- } + + if (symbol_name_compare (method_name, lookup_name, NULL)) + { +diff --git a/gdb/stabsread.c b/gdb/stabsread.c +--- a/gdb/stabsread.c ++++ b/gdb/stabsread.c +@@ -2553,7 +2553,6 @@ read_member_functions (struct field_info *fip, const char **pp, + } + else + { +- int has_stub = 0; + int has_destructor = 0, has_other = 0; + int is_v3 = 0; + struct next_fnfield *tmp_sublist; +@@ -2617,8 +2616,6 @@ read_member_functions (struct field_info *fip, const char **pp, + tmp_sublist = sublist; + while (tmp_sublist != NULL) + { +- if (tmp_sublist->fn_field.is_stub) +- has_stub = 1; + if (tmp_sublist->fn_field.physname[0] == '_' + && tmp_sublist->fn_field.physname[1] == 'Z') + is_v3 = 1; +@@ -2705,23 +2702,6 @@ read_member_functions (struct field_info *fip, const char **pp, + "~", main_fn_name, (char *)NULL); + xfree (main_fn_name); + } +- else if (!has_stub) +- { +- char dem_opname[256]; +- int ret; +- +- ret = cplus_demangle_opname (new_fnlist->fn_fieldlist.name, +- dem_opname, DMGL_ANSI); +- if (!ret) +- ret = cplus_demangle_opname (new_fnlist->fn_fieldlist.name, +- dem_opname, 0); +- if (ret) +- new_fnlist->fn_fieldlist.name +- = ((const char *) +- obstack_copy0 (&objfile->objfile_obstack, dem_opname, +- strlen (dem_opname))); +- xfree (main_fn_name); +- } + + new_fnlist->fn_fieldlist.fn_fields + = OBSTACK_CALLOC (&objfile->objfile_obstack, length, fn_field); +diff --git a/gdb/testsuite/gdb.cp/demangle.exp b/gdb/testsuite/gdb.cp/demangle.exp +--- a/gdb/testsuite/gdb.cp/demangle.exp ++++ b/gdb/testsuite/gdb.cp/demangle.exp +@@ -110,419 +110,13 @@ proc test_demangling_exact {test result} { + test_demangling_core gdb_test_exact $test $result + } + +- +- + # +-# Test gnu style name demangling ++# Test gnu-v3 style name demangling + # + +-proc test_gnu_style_demangling {} { ++proc test_gnuv3_style_demangling {} { + global gdb_prompt + +- test_demangling "gnu: Abort__FP6EditoriPCc" \ +- "Abort\[(\]+Editor \[*\]+, int, (const char|char const) \[*\]+\[)\]+" +- test_demangling_exact "gnu: AddAlignment__9ivTSolverUiP12ivInteractorP7ivTGlue" "ivTSolver::AddAlignment(unsigned int, ivInteractor *, ivTGlue *)" +- test_demangling "gnu: Append__15NameChooserViewPCc" \ +- "NameChooserView::Append\[(\]+(const char|char const) \[*\]+\[)\]+" +- test_demangling_exact "gnu: ArrowheadIntersects__9ArrowLineP9ArrowheadR6BoxObjP7Graphic" "ArrowLine::ArrowheadIntersects(Arrowhead *, BoxObj &, Graphic *)" +- test_demangling_exact "gnu: AtEnd__13ivRubberGroup" "ivRubberGroup::AtEnd(void)" +- test_demangling_exact "gnu: BgFilter__9ivTSolverP12ivInteractor" "ivTSolver::BgFilter(ivInteractor *)" +- test_demangling "gnu: BitPatterntoa__FRC10BitPatternccc" \ +- "BitPatterntoa\[(\]+(const BitPattern|BitPattern const) &, char, char, char\[)\]+" +- test_demangling_exact "gnu: Check__6UArrayi" "UArray::Check(int)" +- test_demangling_exact "gnu: CoreConstDecls__8TextCodeR7ostream" "TextCode::CoreConstDecls(ostream &)" +- test_demangling_exact "gnu: Detach__8StateVarP12StateVarView" "StateVar::Detach(StateVarView *)" +- test_demangling_exact "gnu: Done__9ComponentG8Iterator" "Component::Done(Iterator)" +- test_demangling "gnu: DrawDestinationTransformedImage__FP7_XImageiiT0iiUlUiiiUiUlUlP4_XGCRC13ivTransformeriiii" \ +- "DrawDestinationTransformedImage\[(\]+_XImage \[*\]+, int, int, _XImage \[*\]+, int, int, unsigned long, unsigned int, int, int, unsigned int, unsigned long, unsigned long, _XGC \[*\]+, (const ivTransformer|ivTransformer const) &, int, int, int, int\[)\]+" +- +- test_demangling "gnu: Edit__12StringEditorPCcii" \ +- "StringEditor::Edit\[(\]+(const char|char const) \[*\]+, int, int\[)\]+" +- test_demangling_exact "gnu: Effect__11RelateManipR7ivEvent" "RelateManip::Effect(ivEvent &)" +- test_demangling "gnu: FilterName__FPCc" \ +- "FilterName\[(\]+(const char|char const) \[*\]+\[)\]+" +- test_demangling "gnu: Filter__6PSTextPCci" \ +- "PSText::Filter\[(\]+(const char|char const) \[*\]+, int\[)\]+" +- test_demangling "gnu: FindColor__7CatalogPCciii" \ +- "Catalog::FindColor\[(\]+(const char|char const) \[*\]+, int, int, int\[)\]+" +- test_demangling_exact "gnu: FindFixed__FRP4CNetP4CNet" "FindFixed(CNet *&, CNet *)" +- test_demangling "gnu: FindFont__7CatalogPCcN21" \ +- "Catalog::FindFont\[(\]+(const char|char const) \[*\]+, (const char|char const) \[*\]+, (const char|char const) \[*\]+\[)\]+" +- test_demangling_exact "gnu: Fix48_abort__FR8twolongs" "Fix48_abort(twolongs &)" +- test_demangling_exact "gnu: GetBarInfo__15iv2_6_VScrollerP13ivPerspectiveRiT2" "iv2_6_VScroller::GetBarInfo(ivPerspective *, int &, int &)" +- test_demangling_exact "gnu: GetBgColor__C9ivPainter" "ivPainter::GetBgColor(void) const" +- +- test_demangling "gnu: Iisdouble__FPC6IntRep" \ +- "Iisdouble\[(\]+(const IntRep|IntRep const) \[*\]+\[)\]+" +- test_demangling_exact "gnu: InsertBody__15H_PullrightMenuii" "H_PullrightMenu::InsertBody(int, int)" +- test_demangling_exact "gnu: InsertCharacter__9TextManipc" "TextManip::InsertCharacter(char)" +- +- test_demangling_exact "gnu: InsertToplevel__7ivWorldP12ivInteractorT1" "ivWorld::InsertToplevel(ivInteractor *, ivInteractor *)" +- test_demangling_exact "gnu: InsertToplevel__7ivWorldP12ivInteractorT1iiUi" "ivWorld::InsertToplevel(ivInteractor *, ivInteractor *, int, int, unsigned int)" +- test_demangling "gnu: IsADirectory__FPCcR4stat" \ +- "IsADirectory\[(\]+(const char|char const) \[*\]+, stat &\[)\]+" +- test_demangling_exact "gnu: IsAGroup__FP11GraphicViewP11GraphicComp" "IsAGroup(GraphicView *, GraphicComp *)" +- test_demangling_exact "gnu: IsA__10ButtonCodeUl" "ButtonCode::IsA(unsigned long)" +- +- test_demangling_exact "gnu: ReadName__FR7istreamPc" "ReadName(istream &, char *)" +- test_demangling_exact "gnu: Redraw__13StringBrowseriiii" "StringBrowser::Redraw(int, int, int, int)" +- test_demangling_exact "gnu: Rotate__13ivTransformerf" "ivTransformer::Rotate(float)" +- test_demangling_exact "gnu: Rotated__C13ivTransformerf" "ivTransformer::Rotated(float) const" +- test_demangling_exact "gnu: Round__Ff" "Round(float)" +- +- test_demangling_exact "gnu: SetExport__16MemberSharedNameUi" "MemberSharedName::SetExport(unsigned int)" +- test_demangling_exact "gnu: Set__14ivControlState13ControlStatusUi" "ivControlState::Set(ControlStatus, unsigned int)" +- test_demangling_exact "gnu: Set__5DFacePcii" "DFace::Set(char *, int, int)" +- +- test_demangling_exact "gnu: VConvert__9ivTSolverP12ivInteractorRP8TElementT2" "ivTSolver::VConvert(ivInteractor *, TElement *&, TElement *&)" +- test_demangling_exact "gnu: VConvert__9ivTSolverP7ivTGlueRP8TElement" "ivTSolver::VConvert(ivTGlue *, TElement *&)" +- test_demangling_exact "gnu: VOrder__9ivTSolverUiRP12ivInteractorT2" "ivTSolver::VOrder(unsigned int, ivInteractor *&, ivInteractor *&)" +- test_demangling "gnu: Valid__7CatalogPCcRP4Tool" \ +- "Catalog::Valid\[(\]+(const char|char const) \[*\]+, Tool \[*\]+&\[)\]+" +- test_demangling_exact "gnu: _10PageButton\$__both" "PageButton::__both" +- test_demangling_exact "gnu: _3RNG\$singleMantissa" "RNG::singleMantissa" +- test_demangling_exact "gnu: _5IComp\$_release" "IComp::_release" +- test_demangling_exact "gnu: _\$_10BitmapComp" "BitmapComp::~BitmapComp(void)" +- +- test_demangling_exact "gnu: _\$_9__io_defs" "__io_defs::~__io_defs(void)" +- test_demangling_exact "gnu: _\$_Q23foo3bar" "foo::bar::~bar(void)" +- test_demangling_exact "gnu: _\$_Q33foo3bar4bell" "foo::bar::bell::~bell(void)" +- test_demangling_exact "gnu: __10ivTelltaleiP7ivGlyph" "ivTelltale::ivTelltale(int, ivGlyph *)" +- test_demangling_exact "gnu: __10ivViewportiP12ivInteractorUi" "ivViewport::ivViewport(int, ivInteractor *, unsigned int)" +- test_demangling_exact "gnu: __10ostrstream" "ostrstream::ostrstream(void)" +- test_demangling_exact "gnu: __10ostrstreamPcii" "ostrstream::ostrstream(char *, int, int)" +- test_demangling "gnu: __11BasicDialogiPCcP13ivButtonStateN22Ui" \ +- "BasicDialog::BasicDialog\[(\]+int, (const char|char const) \[*\]+, ivButtonState \[*\]+, (const char|char const) \[*\]+, (const char|char const) \[*\]+, unsigned int\[)\]+" +- test_demangling_exact "gnu: __11BitmapTablei" "BitmapTable::BitmapTable(int)" +- test_demangling_exact "gnu: __12ViewportCodeP12ViewportComp" "ViewportCode::ViewportCode(ViewportComp *)" +- test_demangling "gnu: __12iv2_6_BorderiPCci" \ +- "iv2_6_Border::iv2_6_Border\[(\]+int, (const char|char const) \[*\]+, int\[)\]+" +- test_demangling_exact "gnu: __12iv2_6_Borderii" "iv2_6_Border::iv2_6_Border(int, int)" +- test_demangling "gnu: __12ivBackgroundiP7ivGlyphPC7ivColor" \ +- "ivBackground::ivBackground\[(\]+int, ivGlyph \[*\]+, (const ivColor|ivColor const) \[*\]+\[)\]+" +- test_demangling_exact "gnu: __12ivBreak_Listl" "ivBreak_List::ivBreak_List(long)" +- test_demangling "gnu: __14TextInteractoriPCcUi" \ +- "TextInteractor::TextInteractor\[(\]+int, (const char|char const) \[*\]+, unsigned int\[)\]+" +- test_demangling_exact "gnu: __14iv2_6_MenuItemiP12ivInteractor" "iv2_6_MenuItem::iv2_6_MenuItem(int, ivInteractor *)" +- test_demangling "gnu: __14iv2_6_MenuItemiPCcP12ivInteractor" \ +- "iv2_6_MenuItem::iv2_6_MenuItem\[(\]+int, (const char|char const) \[*\]+, ivInteractor \[*\]+\[)\]+" +- +- test_demangling_exact "gnu: __20DisplayList_IteratorR11DisplayList" "DisplayList_Iterator::DisplayList_Iterator(DisplayList &)" +- test_demangling_exact "gnu: __3fooRT0" "foo::foo(foo &)" +- test_demangling_exact "gnu: __3fooiN31" "foo::foo(int, int, int, int)" +- test_demangling "gnu: __3fooiPCc" \ +- "foo::foo\[(\]+int, (const char|char const) \[*\]+\[)\]+" +- test_demangling_exact "gnu: __3fooiRT0iT2iT2" "foo::foo(int, foo &, int, foo &, int, foo &)" +- test_demangling "gnu: __6GetOptiPPcPCc" \ +- "GetOpt::GetOpt\[(\]+int, char \[*\]+\[*\]+, (const char|char const) \[*\]+\[)\]+" +- test_demangling_exact "gnu: __6KeyMapPT0" "KeyMap::KeyMap(KeyMap *)" +- test_demangling "gnu: __7ivWorldPCcRiPPcPC12ivOptionDescPC14ivPropertyData" \ +- "ivWorld::ivWorld\[(\]+(const char|char const) \[*\]+, int &, char \[*\]+\[*\]+, (const ivOptionDesc|ivOptionDesc const) \[*\]+, (const ivPropertyData|ivPropertyData const) \[*\]+\[)\]+" +- test_demangling "gnu: __7procbufPCci" \ +- "procbuf::procbuf\[(\]+(const char|char const) \[*\]+, int\[)\]+" +- test_demangling_exact "gnu: __8ArrowCmdP6EditorUiUi" "ArrowCmd::ArrowCmd(Editor *, unsigned int, unsigned int)" +- +- test_demangling_exact "gnu: __9F_EllipseiiiiP7Graphic" "F_Ellipse::F_Ellipse(int, int, int, int, Graphic *)" +- test_demangling_exact "gnu: __9FrameDataP9FrameCompi" "FrameData::FrameData(FrameComp *, int)" +- test_demangling_exact "gnu: __9HVGraphicP9CanvasVarP7Graphic" "HVGraphic::HVGraphic(CanvasVar *, Graphic *)" +- test_demangling_exact "gnu: __Q23foo3bar" "foo::bar::bar(void)" +- test_demangling_exact "gnu: __Q33foo3bar4bell" "foo::bar::bell::bell(void)" +- test_demangling_exact "gnu: __aa__3fooRT0" "foo::operator&&(foo &)" +- test_demangling_exact "gnu: __aad__3fooRT0" "foo::operator&=(foo &)" +- test_demangling_exact "gnu: __ad__3fooRT0" "foo::operator&(foo &)" +- test_demangling_exact "gnu: __adv__3fooRT0" "foo::operator/=(foo &)" +- test_demangling_exact "gnu: __aer__3fooRT0" "foo::operator^=(foo &)" +- test_demangling_exact "gnu: __als__3fooRT0" "foo::operator<<=(foo &)" +- test_demangling_exact "gnu: __amd__3fooRT0" "foo::operator%=(foo &)" +- test_demangling_exact "gnu: __ami__3fooRT0" "foo::operator-=(foo &)" +- test_demangling_exact "gnu: __aml__3FixRT0" "Fix::operator*=(Fix &)" +- test_demangling_exact "gnu: __aml__5Fix16i" "Fix16::operator*=(int)" +- test_demangling_exact "gnu: __aml__5Fix32RT0" "Fix32::operator*=(Fix32 &)" +- test_demangling_exact "gnu: __aor__3fooRT0" "foo::operator|=(foo &)" +- test_demangling_exact "gnu: __apl__3fooRT0" "foo::operator+=(foo &)" +- test_demangling_exact "gnu: __ars__3fooRT0" "foo::operator>>=(foo &)" +- +- test_demangling_exact "gnu: __as__3fooRT0" "foo::operator=(foo &)" +- test_demangling_exact "gnu: __cl__3fooRT0" "foo::operator()(foo &)" +- test_demangling_exact "gnu: __cl__6Normal" "Normal::operator()(void)" +- test_demangling_exact "gnu: __cl__6Stringii" "String::operator()(int, int)" +- test_demangling_exact "gnu: __cm__3fooRT0" "foo::operator, (foo &)" +- test_demangling_exact "gnu: __co__3foo" "foo::operator~(void)" +- test_demangling_exact "gnu: __dl__3fooPv" "foo::operator delete(void *)" +- test_demangling_exact "gnu: __dv__3fooRT0" "foo::operator/(foo &)" +- test_demangling_exact "gnu: __eq__3fooRT0" "foo::operator==(foo &)" +- test_demangling_exact "gnu: __er__3fooRT0" "foo::operator^(foo &)" +- test_demangling_exact "gnu: __ge__3fooRT0" "foo::operator>=(foo &)" +- test_demangling_exact "gnu: __gt__3fooRT0" "foo::operator>(foo &)" +- test_demangling_exact "gnu: __le__3fooRT0" "foo::operator<=(foo &)" +- test_demangling_exact "gnu: __ls__3fooRT0" "foo::operator<<(foo &)" +- test_demangling_exact "gnu: __ls__FR7ostreamPFR3ios_R3ios" "operator<<(ostream &, ios &(*)(ios &))" +- test_demangling_exact "gnu: __ls__FR7ostreamR3Fix" "operator<<(ostream &, Fix &)" +- test_demangling_exact "gnu: __lt__3fooRT0" "foo::operator<(foo &)" +- test_demangling_exact "gnu: __md__3fooRT0" "foo::operator%(foo &)" +- test_demangling_exact "gnu: __mi__3fooRT0" "foo::operator-(foo &)" +- test_demangling_exact "gnu: __ml__3fooRT0" "foo::operator*(foo &)" +- test_demangling_exact "gnu: __mm__3fooi" "foo::operator--(int)" +- +- test_demangling_exact "gnu: __ne__3fooRT0" "foo::operator!=(foo &)" +- test_demangling "gnu: __ne__FRC7ComplexT0" \ +- "operator!=\[(\]+(const Complex|Complex const) &, (const Complex|Complex const) &\[)\]+" +- test_demangling "gnu: __ne__FRC7Complexd" \ +- "operator!=\[(\]+(const Complex|Complex const) &, double\[)\]+" +- test_demangling "gnu: __ne__FRC9SubStringRC6String" \ +- "operator!=\[(\]+(const SubString|SubString const) &, (const String|String const) &\[)\]+" +- test_demangling_exact "gnu: __nt__3foo" "foo::operator!(void)" +- test_demangling_exact "gnu: __nw__3fooi" "foo::operator new(int)" +- test_demangling_exact "gnu: __oo__3fooRT0" "foo::operator||(foo &)" +- test_demangling_exact "gnu: __opPc__3foo" "foo::operator char *(void)" +- test_demangling_exact "gnu: __opi__3foo" "foo::operator int(void)" +- test_demangling_exact "gnu: __or__3fooRT0" "foo::operator|(foo &)" +- test_demangling_exact "gnu: __pl__3fooRT0" "foo::operator+(foo &)" +- test_demangling_exact "gnu: __pp__3fooi" "foo::operator++(int)" +- test_demangling_exact "gnu: __rf__3foo" "foo::operator->(void)" +- test_demangling_exact "gnu: __rm__3fooRT0" "foo::operator->*(foo &)" +- test_demangling_exact "gnu: __rs__3fooRT0" "foo::operator>>(foo &)" +- test_demangling "gnu: __vc__3fooRT0" "foo::operator\\\[\\\]\\(foo &\\)" +- test_demangling "gnu: _gsub__6StringRC5RegexPCci" \ +- "String::_gsub\[(\]+(const Regex|Regex const) &, (const char|char const) \[*\]+, int\[)\]+" +- test_demangling_exact "gnu: _new_Fix__FUs" "_new_Fix(unsigned short)" +- +- # gcc 2.4.5 (and earlier) style virtual tables. We want to continue to +- # correctly demangle these even if newer compilers use a different form. +- test_demangling_exact "gnu: _vt.foo" "foo virtual table" +- test_demangling_exact "gnu: _vt.foo.bar" "foo::bar virtual table" +- test_demangling_exact "gnu: _vt\$foo" "foo virtual table" +- test_demangling_exact "gnu: _vt\$foo\$bar" "foo::bar virtual table" +- +- test_demangling_exact "gnu: append__7ivGlyphPT0" "ivGlyph::append(ivGlyph *)" +- test_demangling "gnu: arg__FRC7Complex" \ +- "arg\[(\]+(const Complex|Complex const) &\[)\]+" +- test_demangling_exact "gnu: clearok__FP7_win_sti" "clearok(_win_st *, int)" +- +- test_demangling_exact "gnu: complexfunc2__FPFPc_i" "complexfunc2(int (*)(char *))" +- test_demangling_exact "gnu: complexfunc3__FPFPFPl_s_i" "complexfunc3(int (*)(short (*)(long *)))" +- test_demangling_exact "gnu: complexfunc4__FPFPFPc_s_i" "complexfunc4(int (*)(short (*)(char *)))" +- test_demangling_exact "gnu: complexfunc5__FPFPc_PFl_i" "complexfunc5(int (*(*)(char *))(long))" +- test_demangling_exact "gnu: complexfunc6__FPFPi_PFl_i" "complexfunc6(int (*(*)(int *))(long))" +- test_demangling_exact "gnu: complexfunc7__FPFPFPc_i_PFl_i" "complexfunc7(int (*(*)(int (*)(char *)))(long))" +- test_demangling "gnu: contains__C9BitStringRC10BitPattern" \ +- "BitString::contains\[(\]+(const BitPattern|BitPattern const) &\[)\]+ const" +- test_demangling "gnu: contains__C9BitStringRC12BitSubStringi" \ +- "BitString::contains\[(\]+(const BitSubString|BitSubString const) &, int\[)\]+ const" +- test_demangling "gnu: contains__C9BitStringRT0" \ +- "BitString::contains\[(\]+(const BitString|BitString const) &\[)\]+ const" +- test_demangling "gnu: div__FPC6IntRepT0P6IntRep" \ +- "div\[(\]+(const IntRep|IntRep const) \[*\]+, (const IntRep|IntRep const) \[*\]+, IntRep \[*\]+\[)\]+" +- test_demangling "gnu: div__FPC6IntReplP6IntRep" \ +- "div\[(\]+(const IntRep|IntRep const) \[*\]+, long, IntRep \[*\]+\[)\]+" +- test_demangling "gnu: div__FRC8RationalT0R8Rational" \ +- "div\[(\]+(const Rational|Rational const) &, (const Rational|Rational const) &, Rational &\[)\]+" +- test_demangling "gnu: divide__FRC7IntegerT0R7IntegerT2" \ +- "divide\[(\]+(const Integer|Integer const) &, (const Integer|Integer const) &, Integer &, Integer &\[)\]+" +- test_demangling "gnu: divide__FRC7IntegerlR7IntegerRl" \ +- "divide\[(\]+(const Integer|Integer const) &, long, Integer &, long &\[)\]+" +- test_demangling "gnu: enable__14DocumentViewerPCcUi" \ +- "DocumentViewer::enable\[(\]+(const char|char const) \[*\]+, unsigned int\[)\]+" +- +- test_demangling_exact "gnu: foo__FiN30" "foo(int, int, int, int)" +- test_demangling_exact "gnu: foo__FiR3fooiT1iT1" "foo(int, foo &, int, foo &, int, foo &)" +- test_demangling_exact "gnu: foo___3barl" "bar::foo_(long)" +- test_demangling_exact "gnu: insert__15ivClippingStacklRP8_XRegion" "ivClippingStack::insert(long, _XRegion *&)" +- test_demangling_exact "gnu: insert__16ChooserInfo_ListlR11ChooserInfo" "ChooserInfo_List::insert(long, ChooserInfo &)" +- test_demangling_exact "gnu: insert__17FontFamilyRepListlRP15ivFontFamilyRep" "FontFamilyRepList::insert(long, ivFontFamilyRep *&)" +- test_demangling_exact "gnu: leaveok__FP7_win_stc" "leaveok(_win_st *, char)" +- test_demangling_exact "gnu: left_mover__C7ivMFKitP12ivAdjustableP7ivStyle" "ivMFKit::left_mover(ivAdjustable *, ivStyle *) const" +- test_demangling "gnu: matches__C9BitStringRC10BitPatterni" \ +- "BitString::matches\[(\]+(const BitPattern|BitPattern const) &, int\[)\]+ const" +- test_demangling "gnu: matches__C9SubStringRC5Regex" \ +- "SubString::matches\[(\]+(const Regex|Regex const) &\[)\]+ const" +- +- test_demangling_exact "gnu: overload1arg__FSc" "overload1arg(signed char)" +- test_demangling_exact "gnu: overload1arg__FUc" "overload1arg(unsigned char)" +- test_demangling_exact "gnu: overload1arg__FUi" "overload1arg(unsigned int)" +- test_demangling_exact "gnu: overload1arg__FUl" "overload1arg(unsigned long)" +- test_demangling_exact "gnu: overload1arg__FUs" "overload1arg(unsigned short)" +- test_demangling_exact "gnu: overload1arg__Fc" "overload1arg(char)" +- test_demangling_exact "gnu: overload1arg__Fd" "overload1arg(double)" +- test_demangling_exact "gnu: overload1arg__Ff" "overload1arg(float)" +- test_demangling_exact "gnu: overload1arg__Fi" "overload1arg(int)" +- test_demangling_exact "gnu: overload1arg__Fl" "overload1arg(long)" +- test_demangling_exact "gnu: overload1arg__Fs" "overload1arg(short)" +- test_demangling_exact "gnu: overload1arg__Fv" "overload1arg(void)" +- test_demangling_exact "gnu: overloadargs__Fi" "overloadargs(int)" +- test_demangling_exact "gnu: overloadargs__Fii" "overloadargs(int, int)" +- test_demangling_exact "gnu: overloadargs__Fiii" "overloadargs(int, int, int)" +- test_demangling_exact "gnu: overloadargs__Fiiii" "overloadargs(int, int, int, int)" +- +- test_demangling_exact "gnu: overloadargs__Fiiiii" "overloadargs(int, int, int, int, int)" +- test_demangling_exact "gnu: overloadargs__Fiiiiii" "overloadargs(int, int, int, int, int, int)" +- test_demangling_exact "gnu: overloadargs__Fiiiiiii" "overloadargs(int, int, int, int, int, int, int)" +- test_demangling_exact "gnu: overloadargs__Fiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int)" +- test_demangling_exact "gnu: overloadargs__Fiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int)" +- test_demangling_exact "gnu: overloadargs__Fiiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int, int)" +- test_demangling_exact "gnu: overloadargs__Fiiiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int, int, int)" +- test_demangling "gnu: pick__13ivCompositionP8ivCanvasRC12ivAllocationiR5ivHit" \ +- "ivComposition::pick\[(\]+ivCanvas \[*\]+, (const ivAllocation|ivAllocation const) &, int, ivHit &\[)\]+" +- test_demangling "gnu: pointer__C11ivHScrollerRC7ivEventRC12ivAllocation" \ +- "ivHScroller::pointer\[(\]+(const ivEvent|ivEvent const) &, (const ivAllocation|ivAllocation const) &\[)\]+ const" +- test_demangling_exact "gnu: poke__8ivRasterUlUlffff" "ivRaster::poke(unsigned long, unsigned long, float, float, float, float)" +- test_demangling_exact "gnu: polar__Fdd" "polar(double, double)" +- test_demangling "gnu: read__10osStdInputRPCc" \ +- "osStdInput::read\[(\]+(const char|char const) \[*\]+&\[)\]+" +- +- test_demangling_exact "gnu: scale__13ivTransformerff" "ivTransformer::scale(float, float)" +- test_demangling "gnu: scanw__12CursesWindowPCce" \ +- "CursesWindow::scanw\[(\]+(const char|char const) \[*\]+,...\[)\]+" +- test_demangling "gnu: scmp__FPCcT0" \ +- "scmp\[(\]+(const char|char const) \[*\]+, (const char|char const) \[*\]+\[)\]+" +- test_demangling_exact "gnu: sgetn__7filebufPci" "filebuf::sgetn(char *, int)" +- test_demangling_exact "gnu: shift__FP5_FrepiT0" "shift(_Frep *, int, _Frep *)" +- test_demangling_exact "gnu: test__C6BitSeti" "BitSet::test(int) const" +- test_demangling_exact "gnu: test__C6BitSetii" "BitSet::test(int, int) const" +- test_demangling "gnu: testbit__FRC7Integerl" \ +- "testbit\[(\]+(const Integer|Integer const) &, long\[)\]+" +- test_demangling_exact "gnu: text_source__8Documentl" "Document::text_source(long)" +- test_demangling_exact "gnu: variance__6Erlangd" "Erlang::variance(double)" +- test_demangling "gnu: vform__8iostreamPCcPc" \ +- "iostream::vform\[(\]+(const char|char const) \[*\]+, char \[*\]+\[)\]+" +- test_demangling_exact "gnu: view__14DocumentViewerP8ItemViewP11TabularItem" "DocumentViewer::view(ItemView *, TabularItem *)" +- test_demangling_exact "gnu: xy_extents__11ivExtensionffff" "ivExtension::xy_extents(float, float, float, float)" +- test_demangling_exact "gnu: zero__8osMemoryPvUi" "osMemory::zero(void *, unsigned int)" +- test_demangling_exact "gnu: _2T4\$N" "T4::N" +- test_demangling_exact "gnu: _Q22T42t1\$N" "T4::t1::N" +- test_demangling_exact "gnu: get__2T1" "T1::get(void)" +- test_demangling_exact "gnu: get__Q22T11a" "T1::a::get(void)" +- test_demangling_exact "gnu: get__Q32T11a1b" "T1::a::b::get(void)" +- test_demangling_exact "gnu: get__Q42T11a1b1c" "T1::a::b::c::get(void)" +- test_demangling_exact "gnu: get__Q52T11a1b1c1d" "T1::a::b::c::d::get(void)" +- test_demangling_exact "gnu: put__2T1i" "T1::put(int)" +- test_demangling_exact "gnu: put__Q22T11ai" "T1::a::put(int)" +- test_demangling_exact "gnu: put__Q32T11a1bi" "T1::a::b::put(int)" +- test_demangling_exact "gnu: put__Q42T11a1b1ci" "T1::a::b::c::put(int)" +- test_demangling_exact "gnu: put__Q52T11a1b1c1di" "T1::a::b::c::d::put(int)" +- +- test_demangling_exact "gnu: bar__3fooPv" "foo::bar(void *)" +- test_demangling "gnu: bar__3fooPCv" \ +- "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+" +- test_demangling_exact "gnu: bar__C3fooPv" "foo::bar(void *) const" +- test_demangling "gnu: bar__C3fooPCv" \ +- "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+ const" +- test_demangling_exact "gnu: __eq__3fooRT0" "foo::operator==(foo &)" +- test_demangling "gnu: __eq__3fooRC3foo" \ +- "foo::operator==\[(\]+(const foo|foo const) &\[)\]+" +- test_demangling_exact "gnu: __eq__C3fooR3foo" "foo::operator==(foo &) const" +- test_demangling "gnu: __eq__C3fooRT0" \ +- "foo::operator==\[(\]+(const foo|foo const) &\[)\]+ const" +- +- test_demangling_exact "gnu: elem__t6vector1Zdi" "vector::elem(int)" +- test_demangling_exact "gnu: elem__t6vector1Zii" "vector::elem(int)" +- test_demangling_exact "gnu: __t6vector1Zdi" "vector::vector(int)" +- test_demangling_exact "gnu: __t6vector1Zii" "vector::vector(int)" +- test_demangling_exact "gnu: _\$_t6vector1Zdi" "vector::~vector(int)" +- test_demangling_exact "gnu: _\$_t6vector1Zii" "vector::~vector(int)" +- +- test_demangling_exact "gnu: __nw__t2T11ZcUi" "T1::operator new(unsigned int)" +- test_demangling_exact "gnu: __nw__t2T11Z1tUi" "T1::operator new(unsigned int)" +- test_demangling_exact "gnu: __dl__t2T11ZcPv" "T1::operator delete(void *)" +- test_demangling_exact "gnu: __dl__t2T11Z1tPv" "T1::operator delete(void *)" +- test_demangling_exact "gnu: __t2T11Zci" "T1::T1(int)" +- test_demangling_exact "gnu: __t2T11Zc" "T1::T1(void)" +- test_demangling_exact "gnu: __t2T11Z1ti" "T1::T1(int)" +- test_demangling_exact "gnu: __t2T11Z1t" "T1::T1(void)" +- +- test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3Pix" \ +- "List::Pix::Pix(void)" +- +- test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3PixPQ2t4List1Z10VHDLEntity7element" \ +- "List::Pix::Pix(List::element *)" +- +- test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3PixRCQ2t4List1Z10VHDLEntity3Pix" \ +- "List::Pix::Pix(List::Pix const &)" +- +- test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRC10VHDLEntityPT0" \ +- "List::element::element(VHDLEntity const &, List::element *)" +- +- test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRCQ2t4List1Z10VHDLEntity7element" \ +- "List::element::element(List::element const &)" +- +- test_demangling_exact "gnu: __cl__C11VHDLLibraryGt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ +- "VHDLLibrary::operator()(PixX >) const" +- +- test_demangling_exact "gnu: __cl__Ct4List1Z10VHDLEntityRCQ2t4List1Z10VHDLEntity3Pix" \ +- "List::operator()(List::Pix const &) const" +- +- test_demangling_exact "gnu: __ne__FPvRCQ2t4List1Z10VHDLEntity3Pix" \ +- "operator!=(void *, List::Pix const &)" +- +- test_demangling_exact "gnu: __ne__FPvRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ +- "operator!=(void *, PixX > const &)" +- +- test_demangling_exact "gnu: __t4List1Z10VHDLEntityRCt4List1Z10VHDLEntity" \ +- "List::List(List const &)" +- +- test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ +- "PixX >::PixX(void)" +- +- test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityP14VHDLLibraryRepGQ2t4List1Z10VHDLEntity3Pix" \ +- "PixX >::PixX(VHDLLibraryRep *, List::Pix)" +- +- test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ +- "PixX >::PixX(PixX > const &)" +- +- test_demangling_exact "gnu: nextE__C11VHDLLibraryRt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ +- "VHDLLibrary::nextE(PixX > &) const" +- +- test_demangling_exact "gnu: next__Ct4List1Z10VHDLEntityRQ2t4List1Z10VHDLEntity3Pix" \ +- "List::next(List::Pix &) const" +- +- test_demangling_exact "gnu: _GLOBAL_\$D\$set" "global destructors keyed to set" +- +- test_demangling_exact "gnu: _GLOBAL_\$I\$set" "global constructors keyed to set" +- +- test_demangling_exact "gnu: __as__t5ListS1ZUiRCt5ListS1ZUi" \ +- "ListS::operator=(ListS const &)" +- +- test_demangling_exact "gnu: __cl__Ct5ListS1ZUiRCQ2t5ListS1ZUi3Vix" \ +- "ListS::operator()(ListS::Vix const &) const" +- +- test_demangling_exact "gnu: __cl__Ct5SetLS1ZUiRCQ2t5SetLS1ZUi3Vix" \ +- "SetLS::operator()(SetLS::Vix const &) const" +- +- test_demangling_exact "gnu: __t10ListS_link1ZUiRCUiPT0" \ +- "ListS_link::ListS_link(unsigned int const &, ListS_link *)" +- +- test_demangling_exact "gnu: __t10ListS_link1ZUiRCt10ListS_link1ZUi" \ +- "ListS_link::ListS_link(ListS_link const &)" +- +- test_demangling_exact "gnu: __t5ListS1ZUiRCt5ListS1ZUi" \ +- "ListS::ListS(ListS const &)" +- +- test_demangling_exact "gnu: next__Ct5ListS1ZUiRQ2t5ListS1ZUi3Vix" \ +- "ListS::next(ListS::Vix &) const" +- +- test_demangling_exact "gnu: __ne__FPvRCQ2t5SetLS1ZUi3Vix" \ +- "operator!=(void *, SetLS::Vix const &)" +- test_demangling_exact "gnu: __t8ListElem1Z5LabelRt4List1Z5Label" \ +- "ListElem