Rebase system gdb to 14-2, syncing with gcc-toolset-14 on RHEL8

This commit is contained in:
Guinevere Larsen 2024-05-31 15:54:27 -03:00 committed by root
parent 02fab25d92
commit 56190eb06f
151 changed files with 14791 additions and 23502 deletions

3
.gdb.metadata Normal file
View File

@ -0,0 +1,3 @@
1ad1d2c6f0141b37bbe32b8add91b5691ecc6412 gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz
4f38f7c24d523b6923f22404b7dee4152a00d0d4 gdb-14.2.tar.xz
fc22d7dfb0c4c686d7dfde9da2aa5b41c475899e v2.0.5.tar.gz

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
/gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz
/gdb-10.2.tar.xz
/v2.0.4.tar.gz
/gdb-14.2.tar.xz
/v2.0.5.tar.gz

View File

@ -1,5 +1,4 @@
# Match the Fedora's version info.
#=fedora
# Check distro name is included in the version output.
Patch001: gdb-6.3-rh-testversion-20041202.patch
# Add a wrapper script to GDB that implements pstack using the
@ -7,606 +6,228 @@ Patch001: gdb-6.3-rh-testversion-20041202.patch
#=push
Patch002: gdb-6.3-gstack-20050411.patch
# Test support of multiple destructors just like multiple constructors
#=fedoratest
Patch003: gdb-6.3-test-dtorfix-20050121.patch
# Fix to support executable moving
#=fedoratest
Patch004: gdb-6.3-test-movedir-20050125.patch
# Test sibling threads to set threaded watchpoints for x86 and x86-64
#=fedoratest
Patch005: gdb-6.3-threaded-watchpoints2-20050225.patch
# Notify observers that the inferior has been created
#=fedoratest
Patch006: gdb-6.3-inferior-notification-20050721.patch
# Verify printing of inherited members test
#=fedoratest
Patch007: gdb-6.3-inheritancetest-20050726.patch
# Support TLS symbols (+`errno' suggestion if no pthread is found) (BZ 185337).
#=push+jan: It should be replaced by Infinity project.
Patch008: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
Patch003: 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.
Patch009: 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.
Patch010: gdb-6.5-BEA-testsuite.patch
# Testcase for deadlocking on last address space byte; for corrupted backtraces.
# Test sideeffects of skipping ppc .so libs trampolines (BZ 218379).
#=fedoratest
Patch011: gdb-6.5-last-address-space-byte-test.patch
# Fix readline segfault on excessively long hand-typed lines.
#=fedoratest
Patch012: gdb-6.5-readline-long-line-crash-test.patch
# Fix lockup on trampoline vs. its function lookup; unreproducible (BZ 218379).
#=fedora
Patch013: gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch
# Find symbols properly at their original (included) file (BZ 109921).
#=fedoratest
Patch014: gdb-6.5-bz109921-DW_AT_decl_file-test.patch
# Update PPC unwinding patches to their upstream variants (BZ 140532).
#=fedoratest
Patch015: gdb-6.3-bz140532-ppc-unwinding-test.patch
# Testcase for exec() from threaded program (BZ 202689).
#=fedoratest
Patch016: gdb-6.3-bz202689-exec-from-pthread-test.patch
# Testcase for PPC Power6/DFP instructions disassembly (BZ 230000).
#=fedoratest
Patch017: gdb-6.6-bz230000-power6-disassembly-test.patch
Patch004: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
# Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517).
#=fedoratest
Patch018: gdb-6.6-bz229517-gcore-without-terminal.patch
Patch005: gdb-6.6-bz229517-gcore-without-terminal.patch
# Avoid too long timeouts on failing cases of "annota1.exp annota3.exp".
#=fedoratest
Patch019: gdb-6.6-testsuite-timeouts.patch
Patch006: gdb-6.6-testsuite-timeouts.patch
# Support for stepping over PPC atomic instruction sequences (BZ 237572).
#=fedoratest
Patch020: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
Patch007: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
# Test kernel VDSO decoding while attaching to an i386 process.
#=fedoratest
Patch021: gdb-6.3-attach-see-vdso-test.patch
Patch008: gdb-6.3-attach-see-vdso-test.patch
# Test leftover zombie process (BZ 243845).
#=fedoratest
Patch022: gdb-6.5-bz243845-stale-testing-zombie-test.patch
Patch009: gdb-6.5-bz243845-stale-testing-zombie-test.patch
# New locating of the matching binaries from the pure core file (build-id).
#=push+jan
Patch023: gdb-6.6-buildid-locate.patch
Patch010: 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
Patch024: gdb-6.6-buildid-locate-solib-missing-ids.patch
Patch011: gdb-6.6-buildid-locate-solib-missing-ids.patch
#=push+jan
Patch025: 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.
Patch026: gdb-6.7-charsign-test.patch
Patch012: gdb-6.6-buildid-locate-rpm.patch
# Test PPC hiding of call-volatile parameter register.
#=fedoratest
Patch027: gdb-6.7-ppc-clobbered-registers-O2-test.patch
# Testsuite fixes for more stable/comparable results.
#=fedoratest
Patch028: gdb-6.7-testsuite-stable-results.patch
# Test ia64 memory leaks of the code using libunwind.
#=fedoratest
Patch029: gdb-6.5-ia64-libunwind-leak-test.patch
# Test hiding unexpected breakpoints on intentional step commands.
#=fedoratest
Patch030: gdb-6.5-missed-trap-on-step-test.patch
Patch013: gdb-6.7-ppc-clobbered-registers-O2-test.patch
# Test gcore memory and time requirements for large inferiors.
#=fedoratest
Patch031: gdb-6.5-gcore-buffer-limit-test.patch
Patch014: 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.
Patch032: gdb-6.3-mapping-zero-inode-test.patch
# Test a crash on `focus cmd', `focus prev' commands.
#=fedoratest
Patch033: gdb-6.3-focus-cmd-prev-test.patch
# Test various forms of threads tracking across exec() (BZ 442765).
#=fedoratest
Patch034: gdb-6.8-bz442765-threaded-exec-test.patch
Patch015: gdb-6.3-mapping-zero-inode-test.patch
# Test a crash on libraries missing the .text section.
#=fedoratest
Patch035: gdb-6.5-section-num-fixup-test.patch
Patch016: gdb-6.5-section-num-fixup-test.patch
# Fix resolving of variables at locations lists in prelinked libs (BZ 466901).
#=fedoratest
Patch036: gdb-6.8-bz466901-backtrace-full-prelinked.patch
Patch017: gdb-6.8-bz466901-backtrace-full-prelinked.patch
# New test for step-resume breakpoint placed in multiple threads at once.
#=fedoratest
Patch037: gdb-simultaneous-step-resume-breakpoint-test.patch
Patch018: 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@.*>
Patch038: gdb-core-open-vdso-warning.patch
# Workaround ccache making lineno non-zero for command-line definitions.
#=fedoratest: ccache is rarely used and it is even fixed now.
Patch039: gdb-ccache-workaround.patch
# Testcase for "Do not make up line information" fix by Daniel Jacobowitz.
#=fedoratest
Patch040: gdb-lineno-makeup-test.patch
# Test power7 ppc disassembly.
#=fedoratest
Patch041: gdb-ppc-power7-test.patch
Patch019: gdb-core-open-vdso-warning.patch
# Fix follow-exec for C++ programs (bugreported by Martin Stransky).
#=fedoratest
Patch042: gdb-archer-next-over-throw-cxx-exec.patch
# Backport DWARF-4 support (BZ 601887, Tom Tromey).
#=fedoratest
Patch043: gdb-bz601887-dwarf4-rh-test.patch
Patch020: gdb-archer-next-over-throw-cxx-exec.patch
# Workaround librpm BZ 643031 due to its unexpected exit() calls (BZ 642879).
#=push+jan
Patch044: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
Patch021: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
# [delayed-symfile] Test a backtrace regression on CFIs without DIE (BZ 614604).
#=fedoratest
Patch045: gdb-test-bt-cfi-without-die.patch
Patch022: gdb-test-bt-cfi-without-die.patch
# Verify GDB Python built-in function gdb.solib_address exists (BZ # 634108).
#=fedoratest
Patch046: gdb-bz634108-solib_address.patch
# New test gdb.arch/x86_64-pid0-core.exp for kernel PID 0 cores (BZ 611435).
#=fedoratest
Patch047: gdb-test-pid0-core.patch
Patch023: gdb-bz634108-solib_address.patch
# [archer-tromey-delayed-symfile] New test gdb.dwarf2/dw2-aranges.exp.
#=fedoratest
Patch048: gdb-test-dw2-aranges.patch
# [archer-keiths-expr-cumulative+upstream] Import C++ testcases.
#=fedoratest
Patch049: gdb-test-expr-cumulative-archer.patch
# Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz).
#=fedoratest
Patch050: gdb-physname-pr11734-test.patch
# Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz).
#=fedoratest
Patch051: gdb-physname-pr12273-test.patch
# Test GDB opcodes/ disassembly of Intel Ivy Bridge instructions (BZ 696890).
#=fedoratest
Patch052: gdb-test-ivy-bridge.patch
# Hack for proper PIE run of the testsuite.
#=fedoratest
Patch053: gdb-runtest-pie-override.patch
Patch024: gdb-test-dw2-aranges.patch
# Workaround PR libc/14166 for inferior calls of strstr.
#=fedoratest: Compatibility with RHELs (unchecked which ones).
Patch054: gdb-glibc-strstr-workaround.patch
# Include testcase for `Unable to see a variable inside a module (XLF)' (BZ 823789).
#=fedoratest
Patch055: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch
Patch025: gdb-glibc-strstr-workaround.patch
# Testcase for `Setting solib-absolute-prefix breaks vDSO' (BZ 818343).
#=fedoratest
Patch056: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch
Patch026: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch
# Import regression test for `gdb/findvar.c:417: internal-error:
# read_var_value: Assertion `frame' failed.' (RH BZ 947564) from RHEL 6.5.
#=fedoratest
Patch057: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch
Patch027: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch
# Fix 'memory leak in infpy_read_memory()' (RH BZ 1007614)
#=fedoratest
Patch058: gdb-rhbz1007614-memleak-infpy_read_memory-test.patch
Patch028: 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
Patch059: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
# Display Fortran strings in backtraces.
#=fedoratest
Patch060: gdb-fortran-frame-string.patch
Patch029: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
# Testcase for '[SAP] Recursive dlopen causes SAP HANA installer to
# crash.' (RH BZ 1156192).
#=fedoratest
Patch061: gdb-rhbz1156192-recursive-dlopen-test.patch
Patch030: gdb-rhbz1156192-recursive-dlopen-test.patch
# Fix '`catch syscall' doesn't work for parent after `fork' is called'
# (Philippe Waroquiers, RH BZ 1149205).
#=fedoratest
Patch062: 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
Patch063: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch
# Test 'info type-printers' Python error (RH BZ 1350436).
#=fedoratest
Patch064: gdb-rhbz1350436-type-printers-error.patch
Patch031: gdb-rhbz1149205-catch-syscall-after-fork-test.patch
# Fix '[ppc64] and [s390x] wrong prologue skip on -O2 -g code' (Jan
# Kratochvil, RH BZ 1084404).
#=fedoratest
Patch065: gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch
Patch032: gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch
# Force libncursesw over libncurses to match the includes (RH BZ 1270534).
#=push+jan
Patch066: gdb-fedora-libncursesw.patch
# Test clflushopt instruction decode (for RH BZ 1262471).
#=fedoratest
Patch067: gdb-opcodes-clflushopt-test.patch
# [SCL] Skip deprecated .gdb_index warning for Red Hat built files (BZ 953585).
#=push+jan
Patch068: gdb-6.6-buildid-locate-rpm-scl.patch
Patch033: gdb-fedora-libncursesw.patch
# [aarch64] Fix hardware watchpoints (RH BZ 1261564).
#=fedoratest
Patch069: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
Patch034: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
# Add messages suggesting more recent RHEL gdbserver (RH BZ 1321114).
#=fedora
Patch070: gdb-container-rh-pkg.patch
# New test for Python "Cannot locate object file for block" (for RH BZ 1325795).
#=fedoratest
Patch071: gdb-rhbz1325795-framefilters-test.patch
Patch035: gdb-container-rh-pkg.patch
# [dts+el7] [x86*] Bundle linux_perf.h for libipt (RH BZ 1256513).
#=fedora
Patch072: gdb-linux_perf-bundle.patch
Patch036: gdb-linux_perf-bundle.patch
# Fix gdb-headless /usr/bin/ executables (BZ 1390251).
# Update gdb-add-index.sh such that, when the GDB environment
# variable is not set, the script is smarter than just looking for
# 'gdb' in the $PATH.
#
# Also, make /usr/bin/gdb.minimal be the default GDB used, if it's
# present. For rationale, see:
# The actual search order is now: /usr/bin/gdb.minimal, gdb (in the
# $PATH), then /usr/libexec/gdb.
#
# For the rationale of looking for gdb.minimal see:
#
# https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot
#
#=fedora
Patch073: gdb-libexec-add-index.patch
Patch037: gdb-add-index.patch
# New testcase for: Fix <tab>-completion crash (Gary Benson, RH BZ 1398387).
#=fedoratest
Patch074: gdb-rhbz1398387-tab-crash-test.patch
# Back-port upstream commit 1f0fab7ff86 as part of a fix for
# non-deterministic gdb-index generation (RH BZ 2232086).
Patch038: gdb-rhbz2232086-refactor-selftest-support.patch
# [s390x] Backport arch12 instructions decoding (RH BZ 1553104).
# =fedoratest
Patch075: gdb-rhbz1553104-s390x-arch12-test.patch
# Back-port upstream commit aa19bc1d259 as part of a fix for
# non-deterministic gdb-index generation (RH BZ 2232086).
Patch039: gdb-rhbz-2232086-reduce-size-of-gdb-index.patch
# Fix off-by-one error in ada_fold_name.patch (RH BZ 1905996)
# Upstream patch proposal: https://sourceware.org/pipermail/gdb-patches/2020-December/173935.html
# =fedoratest
Patch076: gdb-rhbz1905996-fix-off-by-one-error-in-ada_fold_name.patch
# Back-port upstream commit acc117b57f7 as part of a fix for
# non-deterministic gdb-index generation (RH BZ 2232086).
Patch040: gdb-rhbz-2232086-cpp-ify-mapped-symtab.patch
# Backport fix for libstdc++ assert when performing tab completion
# (RH BZ 1912985).
Patch077: gdb-rhbz1912985-libstdc++-assert.patch
# Back-port upstream commit aff250145af as part of a fix for
# non-deterministic gdb-index generation (RH BZ 2232086).
Patch041: gdb-rhbz-2232086-generate-gdb-index-consistently.patch
# Backport fix for frame_id_p assertion failure (RH BZ 1909902).
Patch078: gdb-rhbz1909902-frame_id_p-assert-1.patch
# Back-port upstream commit 3644f41dc80 as part of a fix for
# non-deterministic gdb-index generation (RH BZ 2232086).
Patch042: gdb-rhbz-2232086-generate-dwarf-5-index-consistently.patch
# Backport patch #2 which fixes a frame_id_p assertion failure (RH BZ 1909902).
Patch079: gdb-rhbz1909902-frame_id_p-assert-2.patch
# Backport change which fixes gdbserver testing hang on f34 and rawhide.
Patch080: gdb-rhbz1941080-fix-gdbserver-hang.patch
Patch043: gdb-rhbz2250652-gdbpy_gil.patch
# Backport "Disable bracketed paste mode in GDB tests"
# (Tom Tromey)
Patch081: testing-custom-inputrc.patch
# Backport "Save/restore file offset while reading notes in core file"
# (Keith Seitz, RHBZ 1931344)
Patch082: gdb-rhbz1931344-bfd_seek-elf_read_notes.patch
Patch044: gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
# [fortran] Backport Andrew Burgess's commit which cleans up
# array/string expression evaluation.
Patch083: gdb-rhbz1964167-fortran-clean-up-array-expression-evaluation.patch
# [fortran] Backport Andrew Burgess's commit which moves Fortran
# expression handling to f-lang.c.
Patch084: gdb-rhbz1964167-move-fortran-expr-handling.patch
Patch045: gdb-ftbs-swapped-calloc-args.patch
# [fortran] Backport Andrew Burgess's commit which eliminates undesirable
# whitespace when printing arrays.
Patch085: gdb-rhbz1964167-fortran-whitespace_array.patch
# [fortran] Backport Andrew Burgess's commit which changes enum
# range_type into a bit field enum.
Patch086: gdb-rhbz1964167-convert-enum-range_type.patch
# [fortran] Backport Andrew Burgess's commit which renames enum
# range_type to enum range_flag.
Patch087: gdb-rhbz1964167-fortran-range_type-to-range_flag.patch
# [fortran] Backport Andrew Burgess's commit which adds support
# for array strides in expressions.
Patch088: gdb-rhbz1964167-fortran-array-strides-in-expressions.patch
# [fortran] Backport Andrew Burgess's commit for Fortran array
# slice support
Patch089: gdb-rhbz1964167-fortran-array-slices-at-prompt.patch
# [fortran] Backport Simon Marchi's commit which fixes a 32-bit build
# problem in gdb/f-lang.c.
Patch090: gdb-rhbz1964167-fortran-fix-type-format-mismatch-in-f-lang.c.patch
# Backport of "Exclude debuginfo files from 'outside of ELF segments'
# warning" (Keith Seitz)
Patch091: gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch
# Backport of "Correct recording of 'store on condition' insns"
# Andreas Arnaz (RH BZ 1903374)
Patch092: gdb-rhbz1903375-s390x-store-on-condition.patch
# Backport "Fix crash when expanding partial symtabs with DW_TAG_imported_unit"
# (Tom Tromey, gdb/27743)
Patch093: gdb-gdb27743-psymtab-imported-unit.patch
# Backport "[gdb/server] Don't overwrite fs/gs_base with -m32"
# (Tom de Vries)
Patch094: gdb-dont-overwrite-fsgsbase-m32.patch
# Backport "Fix gdb.fortran/array-slices.exp with -m32"
# (Tom de Vres)
Patch095: gdb-testsuite26997-fix-array-slices-m32.patch
# Backport "adjust gdb.python/flexible-array-member.exp expected pattern"
# (Simon Marchi)
Patch096: gdb-flexible-array-member-expected-pattern.patch
# Backport "gdb: try to load libthread_db only after reading all
# shared libraries when attaching / handling a fork child"
# (Simon Marchi, RH BZ 1971095)
Patch097: gdb-rhbz1971095-libthread_db-update-1of5.patch
# Backport "libthread_db initialization changes related to upcoming
# glibc-2.34"
# (Kevin Buettner, RH BZ 19710950
Patch098: gdb-rhbz1971095-libthread_db-update-2of5.patch
# Backport "testsuite/glib-2.34: Match/consume optional libthread_db
# related output"
# (Kevin Buettner, RH BZ 19710950
Patch099: gdb-rhbz1971095-libthread_db-update-3of5.patch
# Backport "print-symbol-loading.exp: Allow libc symbols to be already loaded"
# (Kevin Buettner, RH BZ 1971095)
Patch100: gdb-rhbz1971095-libthread_db-update-4of5.patch
# Backport "mi-sym-info.exp: Increase timeout for 114-symbol-info-functions"
# (Kevin Buettner, RH BZ 1971095)
Patch101: gdb-rhbz1971095-libthread_db-update-5of5.patch
# Backport "PowerPC remove 512 bytes region limit if 2nd DAWR is available"
# (Rogerio Alves, RHBZ 1870029)
Patch102: gdb-rhbz1870029-powerpc-remove-region-limit-dawr.patch
# Backport "displaced stepping across addpcis/lnia"
# (Will Schmidt, RHBZ 1870031)
Patch103: gdb-rhbz1870031-p10-prefixed-insn-1of3.patch
# Backport "gdb-power10-single-step"
# (Will Schmidt, RHBZ 1870031)
Patch104: gdb-rhbz1870031-p10-prefixed-insn-2of3.patch
# Backport "Fix build failure for 32-bit targets with..."
# (Luis Machado, RHBZ 1870031)
Patch105: gdb-rhbz1870031-p10-prefixed-insn-3of3.patch
# IBM Z: Add support for HLASM extended mnemonics
# (Andreas Krebbel, RHBZ 2012819)
Patch106: gdb-rhbz2012819-ibmz-update-1of5.patch
# IBM Z: Add risbgz and risbgnz extended mnemonics
# (Andreas Krebbel, RHBZ 2012819)
Patch107: gdb-rhbz2012819-ibmz-update-2of5.patch
# IBM Z: Implement instruction set extensions
# (Andreas Krebbel, RHBZ 2012819)
Patch108: gdb-rhbz2012819-ibmz-update-3of5.patch
# IBM Z: Remove lpswey parameter
# (Andreas Krebbel, RH BZ 2012819)
Patch109: gdb-rhbz2012819-ibmz-update-4of5.patch
# IBM Z: Add another arch14 instruction
# (Andreas Krebbel, RHBZ 2012819)
Patch110: gdb-rhbz2012819-ibmz-update-5of5.patch
# Backport "Add Power 10 PLT instruction patterns"
# (Carl Love, RHBZ 1870017)
Patch111: gdb-rhbz1870017-p10-plt-prologue-skipping.patch
# Backport "fix logic of find_comp_unit and set_comp_unit"
# (Simon Marchi, RHBZ 2086761)
Patch112: gdb-rhbz2086761-unknown-cfa-rule.patch
# Backport "Fix assertion failure in copy_type"
# (Tom Tromey, RHBZ2155439)
Patch113: gdb-rhbz2155439-assert-failure-copy_type.patch
# Backport "[gdb/testsuite] Fix PR20630 regression test in gdb.base/printcmds.exp"
# (Tom de Vries)
Patch114: gdb-fix-gdb.base-printcmds-s390x-regressions.patch
# Backport "[gdb/breakpoint] Fix assert in jit_event_handler"
# (Tom de Vries, RHBZ2130624)
Patch115: gdb-rhbz-2130624-assert_in_jit_event_handler.patch
# Backport libiberty: prevent buffer overflow when decoding user input
# (Luís Ferreira, RHBZ2132600)
Patch116: libiberty-rhbz-2132600-prevent-buffer-overflow.patch
# Backport: Fix crash in Fortran code
# (Tom Tromey, RHEL-7328)
Patch117: gdb-rhel-7328-fix-fortran-28801.patch
# Backport "libiberty: Fix infinite recursion in rust demangler."
# (Nick Clifton)
Patch118: libiberty-infinite-recursion-fix-1-of-3.patch
# Backport Add a recursion limit to the demangle_const function in the Rust demangler.
# (Nick Clifton, RHEL-4234)
Patch119: libiberty-infinite-recursion-fix-2-of-3.patch
# Backport Fix typo in recent code to add stack recursion limit to the Rust demangler.
# (Nick Clifton)
Patch120: libiberty-infinite-recursion-fix-3-of-3.patch
# Backport "gdbsupport: make gdb_abspath return an std::string"
# (Simon Marchi)
Patch121: gdb-find_and_open_source-empty-string-ub-1of4.patch
# Backport "gdbsupport: add path_join function"
# (Simon Marchi)
Patch122: gdb-find_and_open_source-empty-string-ub-2of4.patch
# Backport "Fix undefined behaviour dereferencing empty string"
# (Magne Hov, RHEL-17631)
Patch123: gdb-find_and_open_source-empty-string-ub-3of4.patch
# Backport "gdbsupport: change path_join parameter to
# array_view<const char *>"
# (Simon Marchi)
Patch124: gdb-find_and_open_source-empty-string-ub-4of4.patch
# Backport "Fix GDB internal error by using text (instead of data)
# section offset"
# (Kevin Buettner, RHEL-107399)
Patch125: gdb-rhel-17399-sect_index_data-not-initialized.patch
# Backport upstream workaround for GCC 14 problem which cause assertion
# failures in GDB.
Patch046: gdb-rhbz2261580-intrusive_list-assertion-fix.patch
# Backport "gdb: s390: Add arch14 record/replay support"
# (Andreas Arnez, RHEL-10550)
Patch126: gdb-rhel-10550-add-arch14-record.patch
# (Andreas Arnez, RHEL-36225)
Patch047: gdb-rhel-36225-add-arch14-record.patch
# Backport "x86: Add an x86_xsave_layout structure to
# handle variable XSAVE layouts."
# (John Baldwin, RHEL-10464)
Patch127: gdb-rhel-10464-xsave-update-1of21.patch
# Backport "PowerPC: Add support for Power11 options"
# (Peter Bergner, RHEL-36518)
Patch048: gdb-rhel-36518-add-power11-support.patch
# Backport "gdb: Store an x86_xsave_layout in i386_gdbarch_tdep."
# (John Baldwin, RHEL-10464)
Patch128: gdb-rhel-10464-xsave-update-2of21.patch
# Update x86 disassembler
Patch049: gdb-rhel-36527-apx-disasm.patch
# Backport "core: Support fetching x86 XSAVE layout from architectures."
# (John Baldwin, RHEL-10464)
Patch129: gdb-rhel-10464-xsave-update-3of21.patch
#Revert "gdb: remove unnecessary parameter wait_ptid from do_target_wait"
#(Andrew Burgess, RHEL-13298)
Patch050: gdb-rhel-13298-inferior-funcall-bp-condition-1-of-5.patch
# Backport "nat/x86--cpuid.h: Add x86_cpuid_count wrapper around
# __get_cpuid_count."
# (John Baldwin, RHEL-10464)
Patch130: gdb-rhel-10464-xsave-update-4of21.patch
#gdb: fix b/p conditions with infcalls in multi-threaded inferiors
#(Andrew Burgess, RHEL-13298)
Patch051: gdb-rhel-13298-inferior-funcall-bp-condition-2-of-5.patch
# Backport "x86 nat: Add helper functions to save the XSAVE layout for
# the host."
# (John Baldwin, RHEL-10464)
Patch131: gdb-rhel-10464-xsave-update-5of21.patch
#gdb: add timeouts for inferior function calls
#(Andrew Burgess, RHEL-13298)
Patch052: gdb-rhel-13298-inferior-funcall-bp-condition-3-of-5.patch
# Backport "gdb: Update x86 Linux architectures to support XSAVE layouts."
# (John Baldwin, RHEL-10464)
Patch132: gdb-rhel-10464-xsave-update-6of21.patch
#gdb: introduce unwind-on-timeout setting
#(Andrew Burgess, RHEL-13298)
Patch053: gdb-rhel-13298-inferior-funcall-bp-condition-4-of-5.patch
# Backport "gdb: Support XSAVE layouts for the current host in the Linux
# x86 targets."
# (John Baldwin, RHEL-10464)
Patch133: gdb-rhel-10464-xsave-update-7of21.patch
#gdb: rename unwindonsignal to unwind-on-signal
#(Andrew Burgess, RHEL-13298)
Patch054: gdb-rhel-13298-inferior-funcall-bp-condition-5-of-5.patch
# Backport "gdb: Use x86_xstate_layout to parse the XSAVE extended state area."
# (John Baldwin, RHEL-10464)
Patch134: gdb-rhel-10464-xsave-update-8of21.patch
# Backport "gdbserver: Add a function to set the XSAVE mask and size."
# (John Baldwin, RHEL-10464)
Patch135: gdb-rhel-10464-xsave-update-9of21.patch
# Backport "x86: Remove X86_XSTATE_SIZE and related constants."
# (John Baldwin, RHEL-10464)
Patch136: gdb-rhel-10464-xsave-update-10of21.patch
# Backport "[gdb/tdep] Fix avx512 -m32 support in gdbserver"
# (Tom de Vries, RHEL-10464)
Patch137: gdb-rhel-10464-xsave-update-11of21.patch
# Backport "gdbserver: Use x86_xstate_layout to parse the XSAVE extended
# state area."
# (Aleksandar Paunovic, RHEL-10464)
Patch138: gdb-rhel-10464-xsave-update-12of21.patch
# Backport "gdbserver: Simplify handling of ZMM registers."
# (John Baldwin, RHEL-10464)
Patch139: gdb-rhel-10464-xsave-update-13of21.patch
# Backport "gdbserver: Refactor the legacy region within the xsave struct"
# (Aleksandar Paunovic, RHEL-10464)
Patch140: gdb-rhel-10464-xsave-update-14of21.patch
# Backport "gdbserver: Fix style of struct declarations in i387-fp.cc"
# (John Baldwin, RHEL-10464)
Patch141: gdb-rhel-10464-xsave-update-15of21.patch
# Backport "nat/x86-cpuid.h: Remove non-x86 fallbacks"
# (John Baldwin, RHEL-10464)
Patch142: gdb-rhel-10464-xsave-update-16of21.patch
# Backport "i386: Use a fallback XSAVE layout for remote targets"
# (John Baldwin, RHEL-10464)
Patch143: gdb-rhel-10464-xsave-update-17of21.patch
# Backport "gdbserver: i387_cache_to_xsave: fix copy dest of zmm registers"
# (Simon Marchi, RHEL-10464)
Patch144: gdb-rhel-10464-xsave-update-18of21.patch
# Backport "bfd/binutils: support for gdb target descriptions in the core file"
# (Andrew Burgess, RHEL-10464)
Patch145: gdb-rhel-10464-xsave-update-19of21.patch
# Backport "gdb: write target description into core file"
# (Andrew Burgess, RHEL-10464)
Patch146: gdb-rhel-10464-xsave-update-20of21.patch
# Backport "gdb/corefile: write NT_GDB_TDESC based on signalled thread"
# (Andrew Burgess, RHEL-10464)
Patch147: gdb-rhel-10464-xsave-update-21of21.patch
#gdb/unwinders: better support for $pc not saved
#(Andrew Burgess, RHEL-19390)
Patch055: gdb-rhel-19390-pc-not-saved.patch

View File

@ -53,95 +53,3 @@
%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

View File

@ -1 +1 @@
ce35d7163e779b1321058b22f005c70ce1524b25
02c10eaecb63e5dbb99cbfdd1c5385e53ed031ff

View File

@ -1,20 +1,7 @@
gdb-6.3-rh-testversion-20041202.patch
gdb-6.3-gstack-20050411.patch
gdb-6.3-test-dtorfix-20050121.patch
gdb-6.3-test-movedir-20050125.patch
gdb-6.3-threaded-watchpoints2-20050225.patch
gdb-6.3-inferior-notification-20050721.patch
gdb-6.3-inheritancetest-20050726.patch
gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
gdb-6.5-sharedlibrary-path.patch
gdb-6.5-BEA-testsuite.patch
gdb-6.5-last-address-space-byte-test.patch
gdb-6.5-readline-long-line-crash-test.patch
gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch
gdb-6.5-bz109921-DW_AT_decl_file-test.patch
gdb-6.3-bz140532-ppc-unwinding-test.patch
gdb-6.3-bz202689-exec-from-pthread-test.patch
gdb-6.6-bz230000-power6-disassembly-test.patch
gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
gdb-6.6-bz229517-gcore-without-terminal.patch
gdb-6.6-testsuite-timeouts.patch
gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
@ -23,125 +10,46 @@ gdb-6.5-bz243845-stale-testing-zombie-test.patch
gdb-6.6-buildid-locate.patch
gdb-6.6-buildid-locate-solib-missing-ids.patch
gdb-6.6-buildid-locate-rpm.patch
gdb-6.7-charsign-test.patch
gdb-6.7-ppc-clobbered-registers-O2-test.patch
gdb-6.7-testsuite-stable-results.patch
gdb-6.5-ia64-libunwind-leak-test.patch
gdb-6.5-missed-trap-on-step-test.patch
gdb-6.5-gcore-buffer-limit-test.patch
gdb-6.3-mapping-zero-inode-test.patch
gdb-6.3-focus-cmd-prev-test.patch
gdb-6.8-bz442765-threaded-exec-test.patch
gdb-6.5-section-num-fixup-test.patch
gdb-6.8-bz466901-backtrace-full-prelinked.patch
gdb-simultaneous-step-resume-breakpoint-test.patch
gdb-core-open-vdso-warning.patch
gdb-ccache-workaround.patch
gdb-lineno-makeup-test.patch
gdb-ppc-power7-test.patch
gdb-archer-next-over-throw-cxx-exec.patch
gdb-bz601887-dwarf4-rh-test.patch
gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
gdb-test-bt-cfi-without-die.patch
gdb-bz634108-solib_address.patch
gdb-test-pid0-core.patch
gdb-test-dw2-aranges.patch
gdb-test-expr-cumulative-archer.patch
gdb-physname-pr11734-test.patch
gdb-physname-pr12273-test.patch
gdb-test-ivy-bridge.patch
gdb-runtest-pie-override.patch
gdb-glibc-strstr-workaround.patch
gdb-rhel5.9-testcase-xlf-var-inside-mod.patch
gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch
gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch
gdb-rhbz1007614-memleak-infpy_read_memory-test.patch
gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
gdb-fortran-frame-string.patch
gdb-rhbz1156192-recursive-dlopen-test.patch
gdb-rhbz1149205-catch-syscall-after-fork-test.patch
gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch
gdb-rhbz1350436-type-printers-error.patch
gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch
gdb-fedora-libncursesw.patch
gdb-opcodes-clflushopt-test.patch
gdb-6.6-buildid-locate-rpm-scl.patch
gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
gdb-container-rh-pkg.patch
gdb-rhbz1325795-framefilters-test.patch
gdb-linux_perf-bundle.patch
gdb-libexec-add-index.patch
gdb-rhbz1398387-tab-crash-test.patch
gdb-rhbz1553104-s390x-arch12-test.patch
gdb-rhbz1905996-fix-off-by-one-error-in-ada_fold_name.patch
gdb-rhbz1912985-libstdc++-assert.patch
gdb-rhbz1909902-frame_id_p-assert-1.patch
gdb-rhbz1909902-frame_id_p-assert-2.patch
gdb-rhbz1941080-fix-gdbserver-hang.patch
testing-custom-inputrc.patch
gdb-rhbz1931344-bfd_seek-elf_read_notes.patch
gdb-rhbz1964167-fortran-clean-up-array-expression-evaluation.patch
gdb-rhbz1964167-move-fortran-expr-handling.patch
gdb-rhbz1964167-fortran-whitespace_array.patch
gdb-rhbz1964167-convert-enum-range_type.patch
gdb-rhbz1964167-fortran-range_type-to-range_flag.patch
gdb-rhbz1964167-fortran-array-strides-in-expressions.patch
gdb-rhbz1964167-fortran-array-slices-at-prompt.patch
gdb-rhbz1964167-fortran-fix-type-format-mismatch-in-f-lang.c.patch
gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch
gdb-rhbz1903375-s390x-store-on-condition.patch
gdb-gdb27743-psymtab-imported-unit.patch
gdb-dont-overwrite-fsgsbase-m32.patch
gdb-testsuite26997-fix-array-slices-m32.patch
gdb-flexible-array-member-expected-pattern.patch
gdb-rhbz1971095-libthread_db-update-1of5.patch
gdb-rhbz1971095-libthread_db-update-2of5.patch
gdb-rhbz1971095-libthread_db-update-3of5.patch
gdb-rhbz1971095-libthread_db-update-4of5.patch
gdb-rhbz1971095-libthread_db-update-5of5.patch
gdb-rhbz1870029-powerpc-remove-region-limit-dawr.patch
gdb-rhbz1870031-p10-prefixed-insn-1of3.patch
gdb-rhbz1870031-p10-prefixed-insn-2of3.patch
gdb-rhbz1870031-p10-prefixed-insn-3of3.patch
gdb-rhbz2012819-ibmz-update-1of5.patch
gdb-rhbz2012819-ibmz-update-2of5.patch
gdb-rhbz2012819-ibmz-update-3of5.patch
gdb-rhbz2012819-ibmz-update-4of5.patch
gdb-rhbz2012819-ibmz-update-5of5.patch
gdb-rhbz1870017-p10-plt-prologue-skipping.patch
gdb-rhbz2086761-unknown-cfa-rule.patch
gdb-rhbz2155439-assert-failure-copy_type.patch
gdb-fix-gdb.base-printcmds-s390x-regressions.patch
gdb-rhbz-2130624-assert_in_jit_event_handler.patch
libiberty-rhbz-2132600-prevent-buffer-overflow.patch
gdb-rhel-7328-fix-fortran-28801.patch
libiberty-infinite-recursion-fix-1-of-3.patch
libiberty-infinite-recursion-fix-2-of-3.patch
libiberty-infinite-recursion-fix-3-of-3.patch
gdb-find_and_open_source-empty-string-ub-1of4.patch
gdb-find_and_open_source-empty-string-ub-2of4.patch
gdb-find_and_open_source-empty-string-ub-3of4.patch
gdb-find_and_open_source-empty-string-ub-4of4.patch
gdb-rhel-17399-sect_index_data-not-initialized.patch
gdb-rhel-10550-add-arch14-record.patch
gdb-rhel-10464-xsave-update-1of21.patch
gdb-rhel-10464-xsave-update-2of21.patch
gdb-rhel-10464-xsave-update-3of21.patch
gdb-rhel-10464-xsave-update-4of21.patch
gdb-rhel-10464-xsave-update-5of21.patch
gdb-rhel-10464-xsave-update-6of21.patch
gdb-rhel-10464-xsave-update-7of21.patch
gdb-rhel-10464-xsave-update-8of21.patch
gdb-rhel-10464-xsave-update-9of21.patch
gdb-rhel-10464-xsave-update-10of21.patch
gdb-rhel-10464-xsave-update-11of21.patch
gdb-rhel-10464-xsave-update-12of21.patch
gdb-rhel-10464-xsave-update-13of21.patch
gdb-rhel-10464-xsave-update-14of21.patch
gdb-rhel-10464-xsave-update-15of21.patch
gdb-rhel-10464-xsave-update-16of21.patch
gdb-rhel-10464-xsave-update-17of21.patch
gdb-rhel-10464-xsave-update-18of21.patch
gdb-rhel-10464-xsave-update-19of21.patch
gdb-rhel-10464-xsave-update-20of21.patch
gdb-rhel-10464-xsave-update-21of21.patch
gdb-add-index.patch
gdb-rhbz2232086-refactor-selftest-support.patch
gdb-rhbz-2232086-reduce-size-of-gdb-index.patch
gdb-rhbz-2232086-cpp-ify-mapped-symtab.patch
gdb-rhbz-2232086-generate-gdb-index-consistently.patch
gdb-rhbz-2232086-generate-dwarf-5-index-consistently.patch
gdb-rhbz2250652-gdbpy_gil.patch
gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
gdb-ftbs-swapped-calloc-args.patch
gdb-rhbz2261580-intrusive_list-assertion-fix.patch
gdb-rhel-36225-add-arch14-record.patch
gdb-rhel-36518-add-power11-support.patch
gdb-rhel-36527-apx-disasm.patch
gdb-rhel-13298-inferior-funcall-bp-condition-1-of-5.patch
gdb-rhel-13298-inferior-funcall-bp-condition-2-of-5.patch
gdb-rhel-13298-inferior-funcall-bp-condition-3-of-5.patch
gdb-rhel-13298-inferior-funcall-bp-condition-4-of-5.patch
gdb-rhel-13298-inferior-funcall-bp-condition-5-of-5.patch
gdb-rhel-19390-pc-not-saved.patch

View File

@ -1,320 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <stdlib.h>
+
+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 <stdlib.h>
+
+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
}

View File

@ -1,109 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
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 <jan.kratochvil@redhat.com>
* 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 <stddef.h>
+#include <pthread.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+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"
+ }
+}

View File

@ -1,53 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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
+ }
+}

View File

@ -16,7 +16,7 @@ Subject: gdb-6.3-gstack-20050411.patch
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1726,7 +1726,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
@@ -2035,7 +2035,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
install: all
@$(MAKE) $(FLAGS_TO_PASS) install-only
@ -25,7 +25,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e "$$t"` ; \
if test "x$$transformed_name" = x; then \
@@ -1775,7 +1775,25 @@ install-guile:
@@ -2085,7 +2085,25 @@ install-guile:
install-python:
$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
@ -52,8 +52,8 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e $$t` ; \
if test "x$$transformed_name" = x; then \
@@ -1798,6 +1816,18 @@ uninstall: force $(CONFIG_UNINSTALL)
fi
@@ -2116,6 +2134,18 @@ uninstall: force $(CONFIG_UNINSTALL)
rm -f $(DESTDIR)$(bindir)/$$transformed_name
@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+.PHONY: uninstall-gstack

View File

@ -1,324 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jeff Johnston <jjohnstn@redhat.com>
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 <jjohnstn@redhat.com>
* 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 <jan.kratochvil@redhat.com>
* 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 <stdio.h>
+
+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,246 @@
+# Copyright 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# 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 {[use_gdb_stub]} {
+ untested "skipping test because of use_gdb_stub"
+ return -1
+}
+
+set testfile "attach-32"
+set srcfile ${testfile}.c
+set srcfile2 ${testfile}b.c
+set binfile [standard_output_file ${testfile}]
+set binfile2 [standard_output_file ${testfile}b]
+set escapedbinfile [string_to_regexp [standard_output_file ${testfile}]]
+
+#execute_anywhere "rm -f ${binfile} ${binfile2}"
+remote_exec build "rm -f ${binfile} ${binfile2}"
+# For debugging this test
+#
+#log_user 1
+
+# build the first test case
+#
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-m32"]] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+# Build the in-system-call test
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable [list debug "additional_flags=-m32"]] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+if [get_compiler_info ${binfile}] {
+ return -1
+}
+
+proc do_attach_tests {} {
+ global gdb_prompt
+ global binfile
+ global escapedbinfile
+ global srcfile
+ global testfile
+ global objdir
+ global subdir
+ global timeout
+ global testpid
+
+ # Verify that we can "see" the variable "should_exit" in the
+ # program, and that it is zero.
+
+ gdb_test "print should_exit" " = 0" "after attach-32, print should_exit"
+
+ # Verify that we can modify the variable "should_exit" in the
+ # program.
+
+ gdb_test "set should_exit=1" "" "after attach-32, set should_exit"
+
+ # Verify that the modification really happened.
+
+ send_gdb "tbreak 19\n"
+ gdb_expect {
+ -re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $" {
+ pass "after attach-32, set tbreak postloop"
+ }
+ -re "$gdb_prompt $" {
+ fail "after attach-32, set tbreak postloop"
+ }
+ timeout {
+ fail "(timeout) after attach-32, set tbreak postloop"
+ }
+ }
+ send_gdb "continue\n"
+ gdb_expect {
+ -re "main.*at.*$srcfile:19.*$gdb_prompt $" {
+ pass "after attach-32, reach tbreak postloop"
+ }
+ -re "$gdb_prompt $" {
+ fail "after attach-32, reach tbreak postloop"
+ }
+ timeout {
+ fail "(timeout) after attach-32, reach tbreak postloop"
+ }
+ }
+
+ # Allow the test process to exit, to cleanup after ourselves.
+
+ gdb_test "continue" {\[Inferior .* exited normally\]} "after attach-32, exit"
+
+ # Make sure we don't leave a process around to confuse
+ # the next test run (and prevent the compile by keeping
+ # the text file busy), in case the "set should_exit" didn't
+ # work.
+
+ remote_exec build "kill -9 ${testpid}"
+
+ # Start the program running and then wait for a bit, to be sure
+ # that it can be attached to.
+
+ set testpid [eval exec $binfile &]
+ exec sleep 2
+ if { [istarget "*-*-cygwin*"] } {
+ # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
+ # different due to the way fork/exec works.
+ set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
+ }
+
+ # Verify that we can attach to the process, and find its a.out
+ # when we're cd'd to some directory that doesn't contain the
+ # a.out. (We use the source path set by the "dir" command.)
+
+ gdb_test "dir ${objdir}/${subdir}" "Source directories searched: .*" \
+ "set source path"
+
+ gdb_test "cd /tmp" "Working directory /tmp." \
+ "cd away from process working directory"
+
+ # Explicitly flush out any knowledge of the previous attachment.
+
+ set test "before attach-32-3, flush symbols"
+ gdb_test_multiple "symbol" "$test" {
+ -re "Discard symbol table from.*y or n. $" {
+ gdb_test "y" "No symbol file now." \
+ "$test"
+ }
+ -re "No symbol file now.*$gdb_prompt $" {
+ pass "$test"
+ }
+ }
+
+ gdb_test "exec" "No executable file now." \
+ "before attach-32-3, flush exec"
+
+ gdb_test "attach $testpid" \
+ "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*" \
+ "attach-32 when process' a.out not in cwd"
+
+ set test "after attach-32-3, exit"
+ gdb_test_multiple "kill" "$test" {
+ -re "Kill the program being debugged.*y or n. $" {
+ gdb_test "y" "" "$test"
+ }
+ }
+
+ # Another "don't leave a process around"
+ remote_exec build "kill -9 ${testpid}"
+}
+
+proc do_call_attach_tests {} {
+ global gdb_prompt
+ global binfile2
+ global testpid
+
+ # See if other registers are problems
+
+ set test "info other register"
+ gdb_test_multiple "i r r3" "$test" {
+ -re "warning: reading register.*$gdb_prompt $" {
+ fail "$test"
+ }
+ -re "r3.*$gdb_prompt $" {
+ pass "$test"
+ }
+ }
+
+ # Get rid of the process
+
+ gdb_test "p should_exit = 1"
+ gdb_test "c" {\[Inferior .* exited normally\]}
+
+ # Be paranoid
+
+ remote_exec build "kill -9 ${testpid}"
+}
+
+
+# Start with a fresh gdb
+
+gdb_exit
+set testpid [eval exec $binfile &]
+exec sleep 3
+if { [istarget "*-*-cygwin*"] } {
+ # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
+ # different due to the way fork/exec works.
+ set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
+}
+
+set GDBFLAGS_orig $GDBFLAGS
+set GDBFLAGS "-iex \"set height 0\" --pid=$testpid"
+gdb_start
+set GDBFLAGS $GDBFLAGS_orig
+
+gdb_reinitialize_dir $srcdir/$subdir
+
+# This is a test of gdb's ability to attach to a running process.
+
+do_attach_tests
+
+# Test attaching when the target is inside a system call
+
+gdb_exit
+set testpid [eval exec $binfile2 &]
+exec sleep 3
+if { [istarget "*-*-cygwin*"] } {
+ # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
+ # different due to the way fork/exec works.
+ set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
+}
+
+set GDBFLAGS_orig $GDBFLAGS
+set GDBFLAGS "-iex \"set height 0\" --pid=$testpid"
+gdb_start
+set GDBFLAGS $GDBFLAGS_orig
+
+gdb_reinitialize_dir $srcdir/$subdir
+do_call_attach_tests
+
+return 0
diff --git a/gdb/testsuite/gdb.base/attach-32b.c b/gdb/testsuite/gdb.base/attach-32b.c
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/attach-32b.c
@@ -0,0 +1,24 @@
+/* This program is intended to be started outside of gdb, and then
+ attached to by gdb. Thus, it simply spins in a loop. The loop
+ is exited when & if the variable 'should_exit' is non-zero. (It
+ is initialized to zero in this program, so the loop will never
+ exit unless/until gdb sets the variable to non-zero.)
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+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);
+}

View File

@ -1,160 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jeff Johnston <jjohnstn@redhat.com>
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 <jjohnstn@redhat.com>
* 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,31 @@
+#include "b146835.h"
+#include <iostream>
+
+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) {}

View File

@ -1,38 +1,34 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Elena Zannoni <ezannoni@redhat.com>
From: Andrew Burgess <aburgess@redhat.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.3-rh-testversion-20041202.patch
;; Match the Fedora's version info.
;;=fedora
;; Check distro name is included in the version output.
2003-02-24 Elena Zannoni <ezannoni@redhat.com>
* gdb.gdb/selftest.exp: Add matching on specific Red Hat only version
string.
diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
--- a/gdb/testsuite/gdb.gdb/selftest.exp
+++ b/gdb/testsuite/gdb.gdb/selftest.exp
@@ -53,6 +53,9 @@ proc test_with_self { } {
-re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" {
pass "printed version with cast"
}
+ -re ".\[0-9\]+ = .(Fedora|Red Hat Enterprise Linux) \[\\(\\)0-9.a-z\\-\]+.*$gdb_prompt $" {
+ pass "printed version Fedora or Red Hat Enterprise Linux only"
+ }
}
# start the "xgdb" process
diff --git a/gdb/top.c b/gdb/top.c
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -2163,7 +2163,7 @@ init_gdb_version_vars (void)
struct internalvar *major_version_var = create_internalvar ("_gdb_major");
struct internalvar *minor_version_var = create_internalvar ("_gdb_minor");
int vmajor = 0, vminor = 0, vrevision = 0;
- sscanf (version, "%d.%d.%d", &vmajor, &vminor, &vrevision);
+ sscanf (version, "Red Hat Enterprise Linux %d.%d.%d", &vmajor, &vminor, &vrevision);
set_internalvar_integer (major_version_var, vmajor);
set_internalvar_integer (minor_version_var, vminor + (vrevision > 0));
}
diff --git a/gdb/testsuite/gdb.base/fedora-version.exp b/gdb/testsuite/gdb.base/fedora-version.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/fedora-version.exp
@@ -0,0 +1,22 @@
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Start with a fresh gdb
+clean_restart
+
+# Check the version string contains either the Fedora or RHEL distro
+# name, and that the version number looks roughly correct in format.
+gdb_test "show version" \
+ "GNU gdb \\((Fedora Linux|Red Hat Enterprise Linux)\\) \[0-9\]+\\.\[0-9\]+-\[0-9\]+.*"

View File

@ -1,247 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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"

View File

@ -1,101 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Elena Zannoni <ezannoni@redhat.com>
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 <ezannoni@redhat.com>
* 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,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+#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,6 @@
+#include <stdlib.h>
+
+void other() {
+ const char* ostring = "other";
+ printf ("%s\n", ostring);;
+}

View File

@ -1,253 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jeff Johnston <jjohnstn@redhat.com>
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 <jjohnstn@redhat.com>
* 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,65 @@
+/* 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 <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+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].*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].*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
+}

View File

@ -1,938 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <signal handler called>
+ * #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 <signal handler called>
+ * #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 <signal handler called>
+ * #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 <signal handler called>
+ * #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 <pthread.h>
+#include <signal.h>
+#include <assert.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#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 \<name of threadcrash binary\> [\<gdb binary\> \<args...\>]
+ 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 <<EOF
+set width 0
+t a a bt 100
+quit
+EOF
+ cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" core* > $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 <<EOF
+handle SIGQUIT pass noprint nostop
+handle SIGUSR1 pass noprint nostop
+handle SIGUSR2 pass noprint nostop
+handle SIGALRM pass noprint nostop
+run
+gcore
+quit
+EOF
+ cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" > /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 <<EOF
+set width 0
+t a a bt 100
+quit
+EOF
+ cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" core* > $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 <<EOF
+handle SIGQUIT pass noprint nostop
+handle SIGUSR1 pass noprint nostop
+handle SIGUSR2 pass noprint nostop
+handle SIGALRM pass noprint nostop
+set width 0
+run
+t a a bt 100
+quit
+EOF
+ cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" > $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 \<name of threadcrash binary\>
+ 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 <<EOF
+set width 0
+t a a bt 100
+quit
+EOF
+ cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" core* > $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 <<EOF
+handle SIGQUIT pass noprint nostop
+handle SIGUSR1 pass noprint nostop
+handle SIGUSR2 pass noprint nostop
+handle SIGALRM pass noprint nostop
+run
+gcore
+quit
+EOF
+ cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" > /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 <<EOF
+set width 0
+t a a bt 100
+quit
+EOF
+ cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" core* > $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 <<EOF
+handle SIGQUIT pass noprint nostop
+handle SIGUSR1 pass noprint nostop
+handle SIGUSR2 pass noprint nostop
+handle SIGALRM pass noprint nostop
+set width 0
+run
+t a a bt 100
+quit
+EOF
+ cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" > $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

View File

@ -1,134 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
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 <jan.kratochvil@redhat.com>
Daniel Jacobowitz <dan@codesourcery.com>
* gdb.base/included.c, gdb.base/included.exp,
gdb.base/included.h: New files.
------------------------------------------------------------------------------
2007-01-09 Jan Kratochvil <jan.kratochvil@redhat.com>
* 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;

View File

@ -44,17 +44,18 @@ glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug:
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1210,6 +1210,10 @@ print_command_1 (const char *args, int voidprint)
@@ -1308,6 +1308,11 @@ process_print_command_args (const char *args, value_print_options *print_opts,
if (exp != nullptr && *exp)
{
+ /* '*((int *(*) (void)) __errno_location) ()' is incompatible with
+ function descriptors. */
+ if (target_has_execution && strcmp (exp, "errno") == 0)
+ if (target_has_execution () && strcmp (exp, "errno") == 0)
+ exp = "*(*(int *(*)(void)) __errno_location) ()";
expression_up expr = parse_expression (exp);
val = evaluate_expression (expr.get ());
}
+
/* This setting allows large arrays to be printed by limiting the
number of elements that are loaded into GDB's memory; we only
need to load as many array elements as we plan to print. */
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.c b/gdb/testsuite/gdb.dwarf2/dw2-errno.c
new file mode 100644
--- /dev/null

View File

@ -1,22 +1,21 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.5-missed-trap-on-step-test.patch
Subject: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
;; Test hiding unexpected breakpoints on intentional step commands.
;; Test sideeffects of skipping ppc .so libs trampolines (BZ 218379).
;;=fedoratest
Fix has been committed to:
gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379
diff --git a/gdb/testsuite/gdb.base/watchpoint-during-step.c b/gdb/testsuite/gdb.base/watchpoint-during-step.c
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/watchpoint-during-step.c
@@ -0,0 +1,30 @@
+++ b/gdb/testsuite/gdb.base/step-over-trampoline.c
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2007 Free Software Foundation, Inc.
+ 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
@ -35,21 +34,19 @@ new file mode 100644
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@prep.ai.mit.edu */
+
+static int var;
+#include <stdio.h>
+
+int main()
+int main (void)
+{
+ var = 1;
+ var = 2;
+ var = 3;
+ return 0;
+ puts ("hello world");
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/watchpoint-during-step.exp b/gdb/testsuite/gdb.base/watchpoint-during-step.exp
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/watchpoint-during-step.exp
@@ -0,0 +1,44 @@
+# Copyright 2007 Free Software Foundation, Inc.
+++ b/gdb/testsuite/gdb.base/step-over-trampoline.exp
@@ -0,0 +1,59 @@
+# Copyright 2006 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
@ -65,7 +62,16 @@ new file mode 100644
+# 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
+if {[use_gdb_stub]} {
+ untested "skipping test because of use_gdb_stub"
+ return -1
+}
+
+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}] != "" } {
@ -80,16 +86,22 @@ new file mode 100644
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+runto_main
+# For C programs, "start" should stop in main().
+
+gdb_breakpoint [gdb_get_line_number "var = 2"]
+gdb_continue_to_breakpoint "Find the first var set"
+gdb_test "start" \
+ "main \\(\\) at .*$srcfile.*" \
+ "start"
+
+gdb_test "step" ".*var = 3;" "Step to the next var set"
+# main () at hello2.c:5
+# 5 puts("hello world\n");
+# (gdb) next
+# 0x100007e0 in call___do_global_ctors_aux ()
+
+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"
+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"
+ }
+}

View File

@ -1,27 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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
@@ -3169,6 +3169,13 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
msymbol->linkage_name ()); */
;
/* fall through */
+ /* `msymbol' trampoline may be located before its .text symbol
+ but this text symbol may be the address we were looking for.
+ Avoid `find_pc_sect_line'<->`find_pc_line' infinite loop.
+ Red Hat Bug 218379. */
+ else if (BMSYMBOL_VALUE_ADDRESS (mfunsym) == pc)
+ warning ("In stub for %s (0x%s); interlocked, please submit the binary to http://bugzilla.redhat.com", msymbol.minsym->linkage_name (), paddress (target_gdbarch (), pc));
+ /* fall through */
else
{
/* Detect an obvious case of infinite recursion. If this

View File

@ -1,135 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <unistd.h>
+
+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,88 @@
+# Copyright 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+if {[use_gdb_stub]} {
+ untested "skipping test because of use_gdb_stub"
+ return -1
+}
+
+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
+ }
+}

View File

@ -1,62 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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}

View File

@ -1,111 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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,96 @@
+# Copyright 2006 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# 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 <jan.kratochvil@redhat.com>
+
+# This file is part of the gdb testsuite.
+
+#
+# Tests for readline buffer overflow.
+#
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+global env
+
+save_vars { env(GDBHISTFILE) env(HISTSIZE) TERM timeout } {
+ # The arrow key test relies on the standard VT100 bindings, so
+ # make sure that an appropriate terminal is selected. The same
+ # bug doesn't show up if we use ^P / ^N instead.
+ setenv TERM vt100
+
+ set timeout 600
+
+ set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history"
+ set env(HISTSIZE) "10"
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+
+ set width 11
+ gdb_test "set width $width" \
+ "" \
+ "Setting width to $width."
+ #gdb_test "set height 1" \
+ # "" \
+ # "Setting height to 1."
+ send_gdb "run X"
+ set i 0
+ # It crashes using `set width 7' on `set total 3560'.
+ # Sometimes it corrupts screen on `set width 7'.
+ # Bugreport used `set total 130001':
+ # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196
+ # Check also `timeout' above.
+ set total 4200
+ gdb_expect {
+ -re X {
+ incr i
+ if {$i <= $total} {
+ send_gdb "X"
+ exp_continue
+ }
+ }
+ -re "\[ \b\r\n\]" {
+ exp_continue
+ }
+ eof {
+ fail "gdb sending total $total characters"
+ note "Failed after sending $i characters, reason: EOF"
+ gdb_clear_suppressed
+ }
+ timeout {
+ fail "gdb sending total $total characters"
+ note "Failed after sending $i characters (timeout $timeout), reason: TIMEOUT"
+ gdb_clear_suppressed
+ }
+ default {
+ fail "gdb sending total $total characters"
+ note "Failed after sending $i characters, reason: 0=\[$expect_out(0,string)\] buffer=\[$expect_out(buffer)\]"
+ gdb_clear_suppressed
+ }
+ }
+ send_gdb "\r"
+ gdb_test "" \
+ "No executable file specified..*" \
+ "All the characters transferred"
+}

View File

@ -1,193 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
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 <jan.kratochvil@redhat.com>
* solib-svr4.c (svr4_fetch_objfile_link_map): Match even absolute
requested pathnames to the internal loaded relative pathnames.
2007-10-16 Jan Kratochvil <jan.kratochvil@redhat.com>
Port to GDB-6.7.
2008-02-27 Jan Kratochvil <jan.kratochvil@redhat.com>
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,31 @@
+/* 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 <pthread.h>
+
+extern __thread int var;
+
+int main()
+{
+ /* Ensure we link against pthreads even with --as-needed. */
+ pthread_testcancel();
+ return var;
+}
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
new file mode 100644
--- /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,94 @@
+# Copyright 2006 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This test uses gdb_exit and gdb_start, which are not supported
+# on non-extended-remote sessions.
+if {[use_gdb_stub]} {
+ untested "skipping test because of stub"
+ return 0
+}
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+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"
+}

View File

@ -6,29 +6,6 @@ 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
@@ -708,6 +708,19 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
#include <dlfcn.h>
#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

View File

@ -1,128 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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
@@ -742,7 +742,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;
@@ -849,7 +853,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;
@@ -967,6 +975,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);
}
@@ -976,6 +1015,20 @@ missing_rpm_enlist (const char *filename)
return count;
}
+#ifdef GDB_INDEX_VERIFY_VENDOR
+missing_rpm_enlist (const char *filename)
+{
+ return missing_rpm_enlist_1 (filename, 0);
+}
+
+extern int rpm_verify_vendor (const char *filename);
+int
+rpm_verify_vendor (const char *filename)
+{
+ return missing_rpm_enlist_1 (filename, 1);
+}
+#endif
+
static bool
missing_rpm_list_compar (const char *ap, const char *bp)
{
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -3034,6 +3034,16 @@ read_gdb_index_from_buffer (const char *filename,
"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)
{
@@ -3045,6 +3055,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),

View File

@ -1,6 +1,6 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
From: Kevin Buettner <kevinb@redhat.com>
Date: Wed, 22 Feb 2023 22:30:40 -0700
Subject: gdb-6.6-buildid-locate-rpm.patch
;;=push+jan
@ -235,458 +235,41 @@ diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4
diff --git a/gdb/build-id.c b/gdb/build-id.c
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -33,6 +33,7 @@
#include "gdb_bfd.h"
#include "gdbcmd.h"
#include "gdbcore.h"
+#include "inferior.h"
#include "objfiles.h"
#include "observable.h"
#include "symfile.h"
@@ -697,8 +698,374 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
return result;
}
@@ -780,10 +780,10 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
static rpmts (*rpmtsCreate_p) (void);
extern rpmts rpmtsFree(rpmts ts);
static rpmts (*rpmtsFree_p) (rpmts ts);
- extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
+ extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
const void * keyp, size_t keylen);
static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
- rpmTag rpmtag,
+ rpmDbiTagVal rpmtag,
const void *keyp,
size_t keylen);
#else /* !DLOPEN_LIBRPM */
@@ -838,7 +838,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
&& (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"))))
+ && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmDbiTagVal rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator"))))
{
warning (_("Opened library \"%s\" is incompatible (%s), "
"missing debuginfos notifications will not be displayed"),
@@ -926,7 +926,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
+#ifdef HAVE_LIBRPM
+
+#include <rpm/rpmlib.h>
+#include <rpm/rpmts.h>
+#include <rpm/rpmdb.h>
+#include <rpm/header.h>
+#ifdef DLOPEN_LIBRPM
+#include <dlfcn.h>
+#endif
+
+/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
+ and avoid their duplicities during a single inferior run. */
+
+static struct htab *missing_rpm_hash;
+
+/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
+ all the rpms right before the nearest GDB prompt. It gets cleared after
+ each such print (it is questionable if we should clear it after the print).
+ */
+
+struct missing_rpm
+ {
+ struct missing_rpm *next;
+ char rpm[1];
+ };
+static struct missing_rpm *missing_rpm_list;
+static int missing_rpm_list_entries;
+
+/* Returns the count of newly added rpms. */
+
+static int
+missing_rpm_enlist (const char *filename)
+{
+ static int rpm_init_done = 0;
+ rpmts ts;
+ rpmdbMatchIterator mi;
+ int count = 0;
+
+#ifdef DLOPEN_LIBRPM
+ /* Duplicate here the declarations to verify they match. The same sanity
+ check is present also in `configure.ac'. */
+ extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
+ static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
+ extern int rpmReadConfigFiles(const char * file, const char * target);
+ static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
+ extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
+ static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
+ extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
+ static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
+ extern rpmts rpmtsCreate(void);
+ static rpmts (*rpmtsCreate_p) (void);
+ extern rpmts rpmtsFree(rpmts ts);
+ static rpmts (*rpmtsFree_p) (rpmts ts);
+ extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
+ const void * keyp, size_t keylen);
+ static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
+ rpmTag rpmtag,
+ const void *keyp,
+ size_t keylen);
+#else /* !DLOPEN_LIBRPM */
+# define headerFormat_p headerFormat
+# define rpmReadConfigFiles_p rpmReadConfigFiles
+# define rpmdbFreeIterator_p rpmdbFreeIterator
+# define rpmdbNextIterator_p rpmdbNextIterator
+# define rpmtsCreate_p rpmtsCreate
+# define rpmtsFree_p rpmtsFree
+# define rpmtsInitIterator_p rpmtsInitIterator
+#endif /* !DLOPEN_LIBRPM */
+
+ gdb_assert (filename != NULL);
+
+ if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
+ return 0;
+
+ if (is_target_filename (filename))
+ return 0;
+
+ if (filename[0] != '/')
+ {
+ warning (_("Ignoring non-absolute filename: <%s>"), filename);
+ return 0;
+ }
+
+ if (!rpm_init_done)
+ {
+ static int init_tried;
+
+ /* Already failed the initialization before? */
+ if (init_tried)
+ return 0;
+ init_tried = 1;
+
+#ifdef DLOPEN_LIBRPM
+ {
+ void *h;
+
+ h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
+ if (!h)
+ {
+ warning (_("Unable to open \"%s\" (%s), "
+ "missing debuginfos notifications will not be displayed"),
+ DLOPEN_LIBRPM, dlerror ());
+ return 0;
+ }
+
+ if (!((headerFormat_p = (char *(*) (Header h, const char * fmt, errmsg_t *errmsg)) dlsym (h, "headerFormat"))
+ && (rpmReadConfigFiles_p = (int (*) (const char * file, const char * target)) dlsym (h, "rpmReadConfigFiles"))
+ && (rpmdbFreeIterator_p = (rpmdbMatchIterator (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbFreeIterator"))
+ && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator"))
+ && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate"))
+ && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree"))
+ && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator"))))
+ {
+ warning (_("Opened library \"%s\" is incompatible (%s), "
+ "missing debuginfos notifications will not be displayed"),
+ DLOPEN_LIBRPM, dlerror ());
+ if (dlclose (h))
+ warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
+ dlerror ());
+ return 0;
+ }
+ }
+#endif /* DLOPEN_LIBRPM */
+
+ if (rpmReadConfigFiles_p (NULL, NULL) != 0)
+ {
+ warning (_("Error reading the rpm configuration files"));
+ return 0;
+ }
+
+ rpm_init_done = 1;
+ }
+
+ ts = rpmtsCreate_p ();
+
+ mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
+ if (mi != NULL)
+ {
+ for (;;)
+ {
+ Header h;
+ char *debuginfo, **slot, *s, *s2;
+ errmsg_t err;
+ size_t srcrpmlen = sizeof (".src.rpm") - 1;
+ size_t debuginfolen = sizeof ("-debuginfo") - 1;
+ rpmdbMatchIterator mi_debuginfo;
+
+ h = rpmdbNextIterator_p (mi);
+ if (h == NULL)
+ break;
+
+ /* Verify the debuginfo file is not already installed. */
+
+ debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
+ &err);
+ if (!debuginfo)
+ {
+ warning (_("Error querying the rpm file `%s': %s"), filename,
+ err);
+ continue;
+ }
+ /* s = `.src.rpm-debuginfo.%{arch}' */
+ s = strrchr (debuginfo, '-') - srcrpmlen;
+ s2 = NULL;
+ if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
+ {
+ /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
+ s2 = (char *) memrchr (debuginfo, '-', s - debuginfo);
+ }
+ if (s2)
+ {
+ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
+ s2 = (char *) memrchr (debuginfo, '-', s2 - debuginfo);
+ }
+ if (!s2)
+ {
+ warning (_("Error querying the rpm file `%s': %s"), filename,
+ debuginfo);
+ xfree (debuginfo);
+ continue;
+ }
+ /* s = `.src.rpm-debuginfo.%{arch}' */
+ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
+ memmove (s2 + debuginfolen, s2, s - s2);
+ memcpy (s2, "-debuginfo", debuginfolen);
+ /* s = `XXXX.%{arch}' */
+ /* strlen ("XXXX") == srcrpmlen + debuginfolen */
+ /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
+ /* strlen ("XX") == srcrpmlen */
+ memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
+ strlen (s + srcrpmlen + debuginfolen) + 1);
+ /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
+
+ /* RPMDBI_PACKAGES requires keylen == sizeof (int). */
+ /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */
+ mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0);
+ xfree (debuginfo);
+ if (mi_debuginfo)
+ {
+ rpmdbFreeIterator_p (mi_debuginfo);
+ count = 0;
+ break;
+ }
+
+ /* The allocated memory gets utilized below for MISSING_RPM_HASH. */
+ debuginfo = headerFormat_p (h,
+ "%{name}-%{version}-%{release}.%{arch}",
+ &err);
+ if (!debuginfo)
+ {
+ warning (_("Error querying the rpm file `%s': %s"), filename,
+ err);
+ continue;
+ }
+
+ /* Base package name for `debuginfo-install'. We do not use the
+ `yum' command directly as the line
+ yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
+ would be more complicated than just:
+ debuginfo-install NAME-VERSION-RELEASE.ARCH
+ Do not supply the rpm base name (derived from .src.rpm name) as
+ debuginfo-install is unable to install the debuginfo package if
+ the base name PKG binary rpm is not installed while for example
+ PKG-libs would be installed (RH Bug 467901).
+ FUTURE: After multiple debuginfo versions simultaneously installed
+ get supported the support for the VERSION-RELEASE tags handling
+ may need an update. */
+
+ if (missing_rpm_hash == NULL)
+ {
+ /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
+ should not deallocate the entries. */
+
+ missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
+ (int (*) (const void *, const void *)) streq,
+ NULL, xcalloc, xfree);
+ }
+ slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
+ /* XCALLOC never returns NULL. */
+ gdb_assert (slot != NULL);
+ if (*slot == NULL)
+ {
+ struct missing_rpm *missing_rpm;
+
+ *slot = debuginfo;
+
+ missing_rpm = (struct missing_rpm *) xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
+ strcpy (missing_rpm->rpm, debuginfo);
+ missing_rpm->next = missing_rpm_list;
+ missing_rpm_list = missing_rpm;
+ missing_rpm_list_entries++;
+ }
+ else
+ xfree (debuginfo);
+ count++;
+ }
+
+ rpmdbFreeIterator_p (mi);
+ }
+
+ rpmtsFree_p (ts);
+
+ return count;
+}
+
+static bool
+missing_rpm_list_compar (const char *ap, const char *bp)
+{
+ return strcoll (ap, bp) < 0;
+}
+
+/* It returns a NULL-terminated array of strings needing to be FREEd. It may
+ also return only NULL. */
+
+static void
+missing_rpm_list_print (void)
+{
+ struct missing_rpm *list_iter;
+
+ if (missing_rpm_list_entries == 0)
+ return;
+
+ std::vector<const char *> array (missing_rpm_list_entries);
+ size_t idx = 0;
+
+ for (list_iter = missing_rpm_list; list_iter != NULL;
+ list_iter = list_iter->next)
+ {
+ array[idx++] = list_iter->rpm;
+ }
+ gdb_assert (idx == missing_rpm_list_entries);
+
+ std::sort (array.begin (), array.end (), missing_rpm_list_compar);
+
+ /* We zero out the number of missing RPMs here because of a nasty
+ bug (see RHBZ 1801974).
+
+ When we call 'puts_unfiltered' below, if pagination is on and if
+ the number of missing RPMs is big enough to trigger pagination,
+ we will end up in an infinite recursion. The call chain looks
+ like this:
+
+ missing_rpm_list_print -> puts_unfiltered -> fputs_maybe_filtered
+ -> prompt_for_continue -> display_gdb_prompt ->
+ debug_flush_missing -> missing_rpm_list_print ...
+
+ For this reason, we make sure MISSING_RPM_LIST_ENTRIES is zero
+ *before* calling any print function. */
+ missing_rpm_list_entries = 0;
+
+ printf_unfiltered (_("Missing separate debuginfos, use: %s"),
+#ifdef DNF_DEBUGINFO_INSTALL
+ "dnf "
+#endif
+ "debuginfo-install");
+ for (const char *el : array)
+ {
+ puts_unfiltered (" ");
+ puts_unfiltered (el);
+ }
+ puts_unfiltered ("\n");
+
+ while (missing_rpm_list != NULL)
+ {
+ list_iter = missing_rpm_list;
+ missing_rpm_list = list_iter->next;
+ xfree (list_iter);
+ }
+}
+
+static void
+missing_rpm_change (void)
+{
+ debug_flush_missing ();
+
+ gdb_assert (missing_rpm_list == NULL);
+ if (missing_rpm_hash != NULL)
+ {
+ htab_delete (missing_rpm_hash);
+ missing_rpm_hash = NULL;
+ }
+}
+
+enum missing_exec
+ {
+ /* Init state. EXEC_BFD also still could be NULL. */
+ MISSING_EXEC_NOT_TRIED,
+ /* We saw a non-NULL EXEC_BFD but RPM has no info about it. */
+ MISSING_EXEC_NOT_FOUND,
+ /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
+ or separate) or the main executable's RPM is now contained in
+ MISSING_RPM_HASH. */
+ MISSING_EXEC_ENLISTED
+ };
+static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
+
+#endif /* HAVE_LIBRPM */
+
+void
+debug_flush_missing (void)
+{
+#ifdef HAVE_LIBRPM
+ missing_rpm_list_print ();
+#endif
+}
+
/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
- Try to install the hash file ...
+ yum --enablerepo='*debug*' install ...
avoidance. */
struct missing_filepair
@@ -752,11 +1119,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 ();
}
@@ -823,14 +1196,38 @@ debug_print_missing (const char *binary, const char *debug)
*slot = missing_filepair;
- /* We do not collect and flush these messages as each such message
- already requires its own separate lines. */
+#ifdef HAVE_LIBRPM
+ if (missing_exec == MISSING_EXEC_NOT_TRIED)
+ {
+ const char *execfilename = get_exec_file (0);
- fprintf_unfiltered (gdb_stdlog,
- _("Missing separate debuginfo for %s\n"), binary);
- if (debug != NULL)
- fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
- debug);
+ if (execfilename != NULL)
+ {
+ if (missing_rpm_enlist (execfilename) == 0)
+ missing_exec = MISSING_EXEC_NOT_FOUND;
+ else
+ missing_exec = MISSING_EXEC_ENLISTED;
+ }
+ }
+ if (missing_exec != MISSING_EXEC_ENLISTED)
+ if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
+ && (debug == NULL || missing_rpm_enlist (debug) == 0))
+#endif /* HAVE_LIBRPM */
+ {
+ /* We do not collect and flush these messages as each such message
+ already requires its own separate lines. */
+
+ fprintf_unfiltered (gdb_stdlog,
+ _("Missing separate debuginfo for %s\n"), binary);
+ if (debug != NULL)
+ fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
+#ifdef DNF_DEBUGINFO_INSTALL
+ "dnf"
+#else
+ "yum"
+#endif
+ " --enablerepo='*debug*' install", debug);
+ }
}
/* See build-id.h. */
/* 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);
+ mi_debuginfo = rpmtsInitIterator_p (ts, (rpmDbiTagVal) RPMDBI_LABEL, debuginfo, 0);
xfree (debuginfo);
if (mi_debuginfo)
{
diff --git a/gdb/config.in b/gdb/config.in
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -39,6 +39,9 @@
@@ -42,6 +42,9 @@
/* Handle .ctf type-info sections */
#undef ENABLE_LIBCTF
@ -696,9 +279,9 @@ diff --git a/gdb/config.in b/gdb/config.in
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
@@ -247,6 +250,9 @@
/* Define if you have the mpfr library. */
#undef HAVE_LIBMPFR
@@ -265,6 +268,9 @@
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
+/* Define if librpm library is being used. */
+#undef HAVE_LIBRPM
@ -709,9 +292,9 @@ diff --git a/gdb/config.in b/gdb/config.in
diff --git a/gdb/configure b/gdb/configure
--- a/gdb/configure
+++ b/gdb/configure
@@ -769,6 +769,11 @@ PKG_CONFIG
HAVE_NATIVE_GCORE_TARGET
TARGET_OBS
@@ -778,6 +778,11 @@ AMD_DBGAPI_CFLAGS
ENABLE_BFD_64_BIT_FALSE
ENABLE_BFD_64_BIT_TRUE
subdirs
+RPM_LIBS
+RPM_CFLAGS
@ -721,25 +304,25 @@ diff --git a/gdb/configure b/gdb/configure
GDB_DATADIR
DEBUGDIR
MAKEINFO_EXTRA_FLAGS
@@ -873,6 +878,7 @@ with_gdb_datadir
@@ -911,6 +916,7 @@ with_gdb_datadir
with_relocated_sources
with_auto_load_dir
with_auto_load_safe_path
+with_rpm
enable_targets
enable_64_bit_bfd
enable_gdbmi
@@ -949,6 +955,8 @@ PKG_CONFIG_PATH
PKG_CONFIG_LIBDIR
with_amd_dbgapi
@@ -988,6 +994,8 @@ AMD_DBGAPI_CFLAGS
AMD_DBGAPI_LIBS
DEBUGINFOD_CFLAGS
DEBUGINFOD_LIBS
+RPM_CFLAGS
+RPM_LIBS
YACC
YFLAGS
XMKMF'
@@ -1621,6 +1629,8 @@ Optional Packages:
do not restrict auto-loaded files locations
ZSTD_CFLAGS
@@ -1679,6 +1687,8 @@ Optional Packages:
--with-amd-dbgapi support for the amd-dbgapi target (yes / no / auto)
--with-debuginfod Enable debuginfo lookups with debuginfod
(auto/yes/no)
+ --with-rpm query rpm database for missing debuginfos (yes/no,
@ -747,7 +330,7 @@ diff --git a/gdb/configure b/gdb/configure
--with-libunwind-ia64 use libunwind frame unwinding for ia64 targets
--with-curses use the curses library instead of the termcap
library
@@ -1702,6 +1712,8 @@ Some influential environment variables:
@@ -1759,6 +1769,8 @@ Some influential environment variables:
C compiler flags for DEBUGINFOD, overriding pkg-config
DEBUGINFOD_LIBS
linker flags for DEBUGINFOD, overriding pkg-config
@ -756,7 +339,7 @@ diff --git a/gdb/configure b/gdb/configure
YACC The `Yet Another Compiler Compiler' implementation to use.
Defaults to the first program found out of: `bison -y', `byacc',
`yacc'.
@@ -6666,6 +6678,494 @@ _ACEOF
@@ -18039,6 +18051,495 @@ _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
$as_echo "$with_auto_load_safe_path" >&6; }
@ -820,6 +403,7 @@ diff --git a/gdb/configure b/gdb/configure
+#include <rpm/rpmlib.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <string.h>
+
+int
+main ()
@ -936,7 +520,7 @@ diff --git a/gdb/configure b/gdb/configure
+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
+extern rpmts rpmtsCreate(void);
+extern rpmts rpmtsFree(rpmts ts);
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
+ const void * keyp, size_t keylen);
+
+int
@ -1198,7 +782,7 @@ diff --git a/gdb/configure b/gdb/configure
+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
+extern rpmts rpmtsCreate(void);
+extern rpmts rpmtsFree(rpmts ts);
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
+ const void * keyp, size_t keylen);
+
+int
@ -1254,7 +838,7 @@ diff --git a/gdb/configure b/gdb/configure
diff --git a/gdb/configure.ac b/gdb/configure.ac
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -143,6 +143,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
@@ -173,6 +173,200 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
[Directories safe to hold auto-loaded files.])
AC_MSG_RESULT([$with_auto_load_safe_path])
@ -1304,6 +888,7 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac
+#include <rpm/rpmlib.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <string.h>
+ ]], [[
+ void *h;
+ const char *const *rpmverp;
@ -1398,7 +983,7 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac
+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
+extern rpmts rpmtsCreate(void);
+extern rpmts rpmtsFree(rpmts ts);
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
+ const void * keyp, size_t keylen);
+ ]]), [
+ LIBRPM_COMPAT=true
@ -1457,15 +1042,15 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac
diff --git a/gdb/event-top.c b/gdb/event-top.c
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -42,6 +42,7 @@
#include "gdbsupport/gdb_select.h"
#include "gdbsupport/gdb-sigmask.h"
@@ -43,6 +43,7 @@
#include "async-event.h"
#include "bt-utils.h"
#include "pager.h"
+#include "symfile.h"
/* readline include files. */
#include "readline/readline.h"
@@ -364,6 +365,8 @@ display_gdb_prompt (const char *new_prompt)
@@ -404,6 +405,8 @@ display_gdb_prompt (const char *new_prompt)
/* Reset the nesting depth used when trace-commands is set. */
reset_command_nest_depth ();
@ -1474,7 +1059,7 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
/* Do not call the python hook on an explicit prompt change as
passed to this function, as this forms a secondary/local prompt,
IE, displayed but not set. */
@@ -773,7 +776,10 @@ command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl)
@@ -788,7 +791,10 @@ command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl)
command_handler (cmd);
if (ui->prompt_state != PROMPTED)
@ -1489,11 +1074,11 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
diff --git a/gdb/symfile.h b/gdb/symfile.h
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -560,6 +560,7 @@ extern void generic_load (const char *args, int from_tty);
@@ -367,6 +367,7 @@ extern void generic_load (const char *args, int from_tty);
/* build-id support. */
extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
extern void debug_print_missing (const char *binary, const char *debug);
+extern void debug_flush_missing (void);
#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
/* From dwarf2read.c */
/* From minidebug.c. */

View File

@ -14,7 +14,7 @@ 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
@@ -1340,14 +1340,27 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
@@ -1320,14 +1320,28 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
}
{
@ -38,13 +38,14 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
+ not do any build-id checking of the libraries. There may be missing
+ build-ids dumped in the core file and we would map all the libraries
+ to the only existing file loaded that time - the executable. */
+ if (symfile_objfile != NULL
+ && (symfile_objfile->flags & OBJF_BUILD_ID_CORE_LOADED) != 0)
+ if (current_program_space->symfile_object_file != NULL
+ && (current_program_space->symfile_object_file->flags
+ & OBJF_BUILD_ID_CORE_LOADED) != 0)
+ build_id = build_id_addr_get (li->l_ld);
if (build_id != NULL)
{
char *name, *build_id_filename;
@@ -1362,23 +1375,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
@@ -1342,23 +1356,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
xfree (name);
}
else
@ -60,8 +61,8 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
- instead) if the on-disk files no longer match the
- running program version. */
-
- if (symfile_objfile != NULL
- && (symfile_objfile->flags
- if (current_program_space->symfile_object_file != NULL
- && (current_program_space->symfile_object_file->flags
- & OBJF_BUILD_ID_CORE_LOADED) != 0)
- newobj->so_name[0] = 0;
- }

File diff suppressed because it is too large Load Diff

View File

@ -1,94 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 */

View File

@ -9,7 +9,7 @@ Subject: gdb-6.6-testsuite-timeouts.patch
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
@@ -37,6 +37,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
clean_restart ${binfile}
@ -21,7 +21,7 @@ diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1
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
@@ -36,6 +36,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
clean_restart ${binfile}

View File

@ -1,130 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
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 <jan.kratochvil@redhat.com>
* gdb.base/charsign.exp, gdb.base/charsign.c: New files.
[ stripped ]
2007-10-19 Jan Kratochvil <jan.kratochvil@redhat.com>
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}

View File

@ -1,104 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
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 <jan.kratochvil@redhat.com>
* 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
@@ -559,6 +559,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

View File

@ -1,181 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <stddef.h>
-#include <pthread.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
+#include <stdio.h>
+#ifdef THREADS
+
+# include <pthread.h>
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 <non-threaded> <threaded> <phase>\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 [list ${binfile_nothreads} ${binfile_threads} 0]
gdb_test_multiple {} "Program exited" {
-re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {

77
gdb-add-index.patch Normal file
View File

@ -0,0 +1,77 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-add-index.patch
;; Update gdb-add-index.sh such that, when the GDB environment
;; variable is not set, the script is smarter than just looking for
;; 'gdb' in the $PATH.
;;
;; The actual search order is now: /usr/bin/gdb.minimal, gdb (in the
;; $PATH), then /usr/libexec/gdb.
;;
;; For the rationale of looking for gdb.minimal see:
;;
;; https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot
;;
;;=fedora
diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh
--- a/gdb/contrib/gdb-add-index.sh
+++ b/gdb/contrib/gdb-add-index.sh
@@ -16,14 +16,52 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# This program assumes gdb and objcopy are in $PATH.
-# If not, or you want others, pass the following in the environment
-GDB=${GDB:=gdb}
+# This program assumes objcopy and readelf are in $PATH. If not, or
+# you want others, pass the following in the environment
OBJCOPY=${OBJCOPY:=objcopy}
READELF=${READELF:=readelf}
myname="${0##*/}"
+# For GDB itself we need to be a little smarter. If GDB is set in the
+# environment then we will use that. But if GDB is not set in the
+# environment then we have a couple of options that we need to check
+# through.
+#
+# Our default choice is for /usr/bin/gdb.minimal. For an explanation
+# of why this is chosen, check out:
+# https://bugzilla.redhat.com/show_bug.cgi?id=1695015
+# https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot
+#
+# If gdb.minimal is not found then we look for a 'gdb' executable on
+# the path.
+#
+# And finally, we check for /usr/libexec/gdb.
+#
+# If none of those result in a useable GDB then we give an error and
+# exit.
+if test -z "$GDB"; then
+ for possible_gdb in /usr/bin/gdb.minimal gdb /usr/libexec/gdb; do
+ if ! which "$possible_gdb" >/dev/null 2>&1; then
+ continue
+ fi
+
+ possible_gdb=$(which "$possible_gdb")
+
+ if ! test -x "$possible_gdb"; then
+ continue
+ fi
+
+ GDB="$possible_gdb"
+ break
+ done
+
+ if test -z "$GDB"; then
+ echo "$myname: Failed to find a useable GDB binary" 1>&2
+ exit 1
+ fi
+fi
+
dwarf5=""
if [ "$1" = "-dwarf-5" ]; then
dwarf5="$1"

View File

@ -1,254 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <http://www.gnu.org/licenses/>. */
+
+ .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 <http://www.gnu.org/licenses/>. */
+
+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 <http://www.gnu.org/licenses/>.
+
+# 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\)}

View File

@ -1,26 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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}" \

View File

@ -9,10 +9,10 @@ Subject: gdb-container-rh-pkg.patch
diff --git a/gdb/remote.c b/gdb/remote.c
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -14031,7 +14031,17 @@ remote_target::pid_to_exec_file (int pid)
@@ -14742,7 +14742,17 @@ remote_target::pid_to_exec_file (int pid)
char *annex = NULL;
if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)
if (m_features.packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)
- return NULL;
+ {
+ warning (_("Remote gdbserver does not support determining executable "

View File

@ -19,24 +19,22 @@ 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"
@@ -27,6 +27,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
@@ -71,8 +72,26 @@ gdb_test "br foo2" \
if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
|| [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
@@ -61,4 +62,28 @@ 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
@ -49,10 +47,12 @@ diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/so
+ 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"
+
gdb_exit

View File

@ -1,139 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Tue, 1 Jun 2021 10:14:31 -0700
Subject: gdb-dont-overwrite-fsgsbase-m32.patch
;; Backport "[gdb/server] Don't overwrite fs/gs_base with -m32"
;; (Tom de Vries)
Consider a minimal test-case test.c:
...
int main (void) { return 0; }
...
compiled with -m32:
...
$ gcc test.c -m32
...
When running the exec using gdbserver on openSUSE Factory (currently running a
linux kernel version 5.10.5):
...
$ gdbserver localhost:12345 a.out
...
to which we connect in a gdb session, we run into a segfault in the inferior:
...
$ gdb -batch -q -ex "target remote localhost:12345" -ex continue
Program received signal SIGSEGV, Segmentation fault.
0xf7dd8bd2 in init_cacheinfo () at ../sysdeps/x86/cacheinfo.c:761
...
The segfault is caused by gdbserver overwriting $gs_base with 0 using
PTRACE_SETREGS. After it is overwritten, the next use of $gs in the inferior
will trigger the segfault.
Before linux kernel version 5.9, the value used by PTRACE_SETREGS for $gs_base
was ignored, but starting version 5.9, the linux kernel has support for
intel architecture extension FSGSBASE, which allows users to modify $gs_base,
and consequently PTRACE_SETREGS can no longer ignore the $gs_base value.
The overwrite of $gs_base with 0 is done by a memset in x86_fill_gregset,
which was added in commit 9e0aa64f551 "Fix gdbserver qGetTLSAddr for
x86_64 -m32". The memset intends to zero-extend 32-bit registers that are
tracked in the regcache to 64-bit when writing them into the PTRACE_SETREGS
data argument. But in addition, it overwrites other registers that are
not tracked in the regcache, such as $gs_base.
Fix the segfault by redoing the fix from commit 9e0aa64f551 in minimal form.
Tested on x86_64-linux:
- openSUSE Leap 15.2 (using kernel version 5.3.18):
- native
- gdbserver -m32
- -m32
- openSUSE Factory (using kernel version 5.10.5):
- native
- m32
gdbserver/ChangeLog:
2021-01-20 Tom de Vries <tdevries@suse.de>
* linux-x86-low.cc (collect_register_i386): New function.
(x86_fill_gregset): Remove memset. Use collect_register_i386.
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -397,6 +397,35 @@ x86_target::low_cannot_fetch_register (int regno)
return regno >= I386_NUM_REGS;
}
+static void
+collect_register_i386 (struct regcache *regcache, int regno, void *buf)
+{
+ collect_register (regcache, regno, buf);
+
+#ifdef __x86_64__
+ /* In case of x86_64 -m32, collect_register only writes 4 bytes, but the
+ space reserved in buf for the register is 8 bytes. Make sure the entire
+ reserved space is initialized. */
+
+ gdb_assert (register_size (regcache->tdesc, regno) == 4);
+
+ if (regno == RAX)
+ {
+ /* Sign extend EAX value to avoid potential syscall restart
+ problems.
+
+ See amd64_linux_collect_native_gregset() in
+ gdb/amd64-linux-nat.c for a detailed explanation. */
+ *(int64_t *) buf = *(int32_t *) buf;
+ }
+ else
+ {
+ /* Zero-extend. */
+ *(uint64_t *) buf = *(uint32_t *) buf;
+ }
+#endif
+}
+
static void
x86_fill_gregset (struct regcache *regcache, void *buf)
{
@@ -411,32 +440,14 @@ x86_fill_gregset (struct regcache *regcache, void *buf)
return;
}
-
- /* 32-bit inferior registers need to be zero-extended.
- Callers would read uninitialized memory otherwise. */
- memset (buf, 0x00, X86_64_USER_REGS * 8);
#endif
for (i = 0; i < I386_NUM_REGS; i++)
- collect_register (regcache, i, ((char *) buf) + i386_regmap[i]);
-
- collect_register_by_name (regcache, "orig_eax",
- ((char *) buf) + ORIG_EAX * REGSIZE);
+ collect_register_i386 (regcache, i, ((char *) buf) + i386_regmap[i]);
-#ifdef __x86_64__
- /* Sign extend EAX value to avoid potential syscall restart
- problems.
-
- See amd64_linux_collect_native_gregset() in gdb/amd64-linux-nat.c
- for a detailed explanation. */
- if (register_size (regcache->tdesc, 0) == 4)
- {
- void *ptr = ((gdb_byte *) buf
- + i386_regmap[find_regno (regcache->tdesc, "eax")]);
-
- *(int64_t *) ptr = *(int32_t *) ptr;
- }
-#endif
+ /* Handle ORIG_EAX, which is not in i386_regmap. */
+ collect_register_i386 (regcache, find_regno (regcache->tdesc, "orig_eax"),
+ ((char *) buf) + ORIG_EAX * REGSIZE);
}
static void

View File

@ -12,7 +12,269 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1270534
diff --git a/gdb/configure b/gdb/configure
--- a/gdb/configure
+++ b/gdb/configure
@@ -9649,6 +9649,7 @@ if test x"$prefer_curses" = xyes; then
@@ -780,9 +780,6 @@ ENABLE_BFD_64_BIT_TRUE
subdirs
RPM_LIBS
RPM_CFLAGS
-PKG_CONFIG_LIBDIR
-PKG_CONFIG_PATH
-PKG_CONFIG
GDB_DATADIR
DEBUGDIR
MAKEINFO_EXTRA_FLAGS
@@ -990,12 +987,12 @@ PKG_CONFIG_PATH
PKG_CONFIG_LIBDIR
MAKEINFO
MAKEINFOFLAGS
+RPM_CFLAGS
+RPM_LIBS
AMD_DBGAPI_CFLAGS
AMD_DBGAPI_LIBS
DEBUGINFOD_CFLAGS
DEBUGINFOD_LIBS
-RPM_CFLAGS
-RPM_LIBS
YACC
YFLAGS
ZSTD_CFLAGS
@@ -1684,11 +1681,11 @@ 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-amd-dbgapi support for the amd-dbgapi target (yes / no / auto)
--with-debuginfod Enable debuginfo lookups with debuginfod
(auto/yes/no)
- --with-rpm query rpm database for missing debuginfos (yes/no,
- def. auto=librpm.so)
--with-libunwind-ia64 use libunwind frame unwinding for ia64 targets
--with-curses use the curses library instead of the termcap
library
@@ -1761,6 +1758,8 @@ Some influential environment variables:
MAKEINFO Parent configure detects if it is of sufficient version.
MAKEINFOFLAGS
Parameters for MAKEINFO.
+ RPM_CFLAGS C compiler flags for RPM, overriding pkg-config
+ RPM_LIBS linker flags for RPM, overriding pkg-config
AMD_DBGAPI_CFLAGS
C compiler flags for AMD_DBGAPI, overriding pkg-config
AMD_DBGAPI_LIBS
@@ -1769,8 +1768,6 @@ Some influential environment variables:
C compiler flags for DEBUGINFOD, overriding pkg-config
DEBUGINFOD_LIBS
linker flags for DEBUGINFOD, overriding pkg-config
- RPM_CFLAGS C compiler flags for RPM, overriding pkg-config
- RPM_LIBS linker flags for RPM, overriding pkg-config
YACC The `Yet Another Compiler Compiler' implementation to use.
Defaults to the first program found out of: `bison -y', `byacc',
`yacc'.
@@ -11495,7 +11492,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11486 "configure"
+#line 11495 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11601,7 +11598,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11592 "configure"
+#line 11601 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -18102,8 +18099,8 @@ $as_echo_n "checking specific librpm version... " >&6; }
if test "$cross_compiling" = yes; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot run test program while cross compiling
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -18275,132 +18272,12 @@ $as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
$as_echo "no" >&6; }
LIBS="$save_LIBS"
if $DLOPEN_REQUIRE; then
- as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
+ as_fn_error $? "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
fi
-
-
-
-
-
-
-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; }
+{ $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"
@@ -18437,6 +18314,30 @@ fi
pkg_failed=untried
fi
+if test $pkg_failed = no; then
+ pkg_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $pkg_cv_RPM_LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+ pkg_failed=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS=$pkg_save_LDFLAGS
+fi
+
if test $pkg_failed = yes; then
@@ -18531,7 +18432,7 @@ $as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
LIBS="$LIBS $RPM_LIBS"
else
if $RPM_REQUIRE; then
- as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
+ as_fn_error $? "$RPM_PKG_ERRORS" "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
@@ -21164,6 +21065,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.
@ -20,7 +282,7 @@ diff --git a/gdb/configure b/gdb/configure
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing waddstr" >&5
$as_echo_n "checking for library containing waddstr... " >&6; }
if ${ac_cv_search_waddstr+:} false; then :
@@ -9673,7 +9674,7 @@ return waddstr ();
@@ -21188,7 +21090,7 @@ return waddstr ();
return 0;
}
_ACEOF
@ -29,7 +291,7 @@ diff --git a/gdb/configure b/gdb/configure
if test -z "$ac_lib"; then
ac_res="none required"
else
@@ -9747,6 +9748,7 @@ case $host_os in
@@ -21260,6 +21162,7 @@ case $host_os in
esac
# These are the libraries checked by Readline.
@ -37,7 +299,7 @@ diff --git a/gdb/configure b/gdb/configure
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
$as_echo_n "checking for library containing tgetent... " >&6; }
if ${ac_cv_search_tgetent+:} false; then :
@@ -9771,7 +9773,7 @@ return tgetent ();
@@ -21284,7 +21187,7 @@ return tgetent ();
return 0;
}
_ACEOF
@ -49,17 +311,17 @@ diff --git a/gdb/configure b/gdb/configure
diff --git a/gdb/configure.ac b/gdb/configure.ac
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -712,7 +712,8 @@ if test x"$prefer_curses" = xyes; then
@@ -749,7 +749,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])
- 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
@@ -754,7 +755,8 @@ case $host_os in
+ AC_SEARCH_LIBS(waddstr, [ncursesw],
[curses_found=yes
AC_DEFINE([HAVE_LIBCURSES], [1],
[Define to 1 if curses is enabled.])
@@ -789,7 +790,8 @@ case $host_os in
esac
# These are the libraries checked by Readline.

View File

@ -1,327 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Mon, 4 Dec 2023 11:04:22 -0800
Subject: gdb-find_and_open_source-empty-string-ub-1of4.patch
;; Backport "gdbsupport: make gdb_abspath return an std::string"
;; (Simon Marchi)
I'm trying to switch these functions to use std::string instead of char
arrays, as much as possible. Some callers benefit from it (can avoid
doing a copy of the result), while others suffer (have to make one more
copy).
Change-Id: Iced49b8ee2f189744c5072a3b217aab5af17a993
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -295,8 +295,8 @@ compile_file_command (const char *args, int from_tty)
error (_("You must provide a filename for this command."));
args = skip_spaces (args);
- gdb::unique_xmalloc_ptr<char> abspath = gdb_abspath (args);
- std::string buffer = string_printf ("#include \"%s\"\n", abspath.get ());
+ std::string abspath = gdb_abspath (args);
+ std::string buffer = string_printf ("#include \"%s\"\n", abspath.c_str ());
eval_compile_command (NULL, buffer.c_str (), scope, NULL);
}
diff --git a/gdb/completer.c b/gdb/completer.c
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -2036,7 +2036,7 @@ gdb_completion_word_break_characters_throw ()
rl_basic_quote_characters = NULL;
}
- return rl_completer_word_break_characters;
+ return (char *) rl_completer_word_break_characters;
}
char *
diff --git a/gdb/corelow.c b/gdb/corelow.c
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -447,7 +447,7 @@ core_target_open (const char *arg, int from_tty)
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
if (!IS_ABSOLUTE_PATH (filename.get ()))
- filename = gdb_abspath (filename.get ());
+ filename = make_unique_xstrdup (gdb_abspath (filename.get ()).c_str ());
flags = O_BINARY | O_LARGEFILE;
if (write_files)
diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
--- a/gdb/dwarf2/index-cache.c
+++ b/gdb/dwarf2/index-cache.c
@@ -291,7 +291,8 @@ set_index_cache_directory_command (const char *arg, int from_tty,
cmd_list_element *element)
{
/* Make sure the index cache directory is absolute and tilde-expanded. */
- gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (index_cache_directory));
+ gdb::unique_xmalloc_ptr<char> abs
+ = make_unique_xstrdup (gdb_abspath (index_cache_directory).c_str ());
xfree (index_cache_directory);
index_cache_directory = abs.release ();
global_index_cache.set_directory (index_cache_directory);
diff --git a/gdb/main.c b/gdb/main.c
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -135,12 +135,7 @@ set_gdb_data_directory (const char *new_datadir)
"../foo" and "../foo" doesn't exist then we'll record $(pwd)/../foo which
isn't canonical, but that's ok. */
if (!IS_ABSOLUTE_PATH (gdb_datadir.c_str ()))
- {
- gdb::unique_xmalloc_ptr<char> abs_datadir
- = gdb_abspath (gdb_datadir.c_str ());
-
- gdb_datadir = abs_datadir.get ();
- }
+ gdb_datadir = gdb_abspath (gdb_datadir.c_str ());
}
/* Relocate a file or directory. PROGNAME is the name by which gdb
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -341,7 +341,7 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
objfile_alloc_data (this);
- gdb::unique_xmalloc_ptr<char> name_holder;
+ std::string name_holder;
if (name == NULL)
{
gdb_assert (abfd == NULL);
@@ -354,7 +354,7 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
else
{
name_holder = gdb_abspath (name);
- expanded_name = name_holder.get ();
+ expanded_name = name_holder.c_str ();
}
original_name = obstack_strdup (&objfile_obstack, expanded_name);
diff --git a/gdb/source.c b/gdb/source.c
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -512,15 +512,15 @@ add_path (const char *dirname, char **which_path, int parse_separators)
for (const gdb::unique_xmalloc_ptr<char> &name_up : dir_vec)
{
- char *name = name_up.get ();
+ const char *name = name_up.get ();
char *p;
struct stat st;
- gdb::unique_xmalloc_ptr<char> new_name_holder;
+ std::string new_name_holder;
/* Spaces and tabs will have been removed by buildargv().
NAME is the start of the directory.
P is the '\0' following the end. */
- p = name + strlen (name);
+ p = name_up.get () + strlen (name);
while (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
@@ -561,16 +561,18 @@ add_path (const char *dirname, char **which_path, int parse_separators)
}
if (name[0] == '~')
- new_name_holder.reset (tilde_expand (name));
+ new_name_holder
+ = gdb::unique_xmalloc_ptr<char[]> (tilde_expand (name)).get ();
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
- new_name_holder.reset (concat (name, ".", (char *) NULL));
+ new_name_holder = std::string (name) + ".";
#endif
else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
new_name_holder = gdb_abspath (name);
else
- new_name_holder.reset (savestring (name, p - name));
- name = new_name_holder.get ();
+ new_name_holder = std::string (name, p - name);
+
+ name = new_name_holder.c_str ();
/* Unless it's a variable, check existence. */
if (name[0] != '$')
@@ -915,7 +917,8 @@ openp (const char *path, openp_flags opts, const char *string,
else if ((opts & OPF_RETURN_REALPATH) != 0)
*filename_opened = gdb_realpath (filename);
else
- *filename_opened = gdb_abspath (filename);
+ *filename_opened
+ = make_unique_xstrdup (gdb_abspath (filename).c_str ());
}
errno = last_errno;
diff --git a/gdb/top.c b/gdb/top.c
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -2065,8 +2065,7 @@ init_history (void)
const char *fname = ".gdb_history";
#endif
- gdb::unique_xmalloc_ptr<char> temp (gdb_abspath (fname));
- history_filename = temp.release ();
+ history_filename = xstrdup (gdb_abspath (fname).c_str ());
}
if (!history_filename_empty ())
@@ -2150,10 +2149,10 @@ set_history_filename (const char *args,
that was read. */
if (!history_filename_empty () && !IS_ABSOLUTE_PATH (history_filename))
{
- gdb::unique_xmalloc_ptr<char> temp (gdb_abspath (history_filename));
+ std::string temp = gdb_abspath (history_filename);
xfree (history_filename);
- history_filename = temp.release ();
+ history_filename = xstrdup (temp.c_str ());
}
}
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -471,7 +471,7 @@ tfile_target_open (const char *arg, int from_tty)
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
if (!IS_ABSOLUTE_PATH (filename.get ()))
- filename = gdb_abspath (filename.get ());
+ filename = make_unique_xstrdup (gdb_abspath (filename.get ()).c_str ());
flags = O_BINARY | O_LARGEFILE;
flags |= O_RDONLY;
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -93,31 +93,31 @@ bool non_stop;
static struct {
/* Set the PROGRAM_PATH. Here we adjust the path of the provided
binary if needed. */
- void set (gdb::unique_xmalloc_ptr<char> &&path)
+ void set (const char *path)
{
- m_path = std::move (path);
+ m_path = path;
/* Make sure we're using the absolute path of the inferior when
creating it. */
- if (!contains_dir_separator (m_path.get ()))
+ if (!contains_dir_separator (m_path.c_str ()))
{
int reg_file_errno;
/* Check if the file is in our CWD. If it is, then we prefix
its name with CURRENT_DIRECTORY. Otherwise, we leave the
name as-is because we'll try searching for it in $PATH. */
- if (is_regular_file (m_path.get (), &reg_file_errno))
- m_path = gdb_abspath (m_path.get ());
+ if (is_regular_file (m_path.c_str (), &reg_file_errno))
+ m_path = gdb_abspath (m_path.c_str ());
}
}
/* Return the PROGRAM_PATH. */
- char *get ()
- { return m_path.get (); }
+ const char *get ()
+ { return m_path.empty () ? nullptr : m_path.c_str (); }
private:
/* The program name, adjusted if needed. */
- gdb::unique_xmalloc_ptr<char> m_path;
+ std::string m_path;
} program_path;
static std::vector<char *> program_args;
static std::string wrapper_argv;
@@ -3054,7 +3054,7 @@ handle_v_run (char *own_buf)
}
}
else
- program_path.set (gdb::unique_xmalloc_ptr<char> (new_program_name));
+ program_path.set (new_program_name);
/* Free the old argv and install the new one. */
free_vector_argv (program_args);
@@ -3845,7 +3845,7 @@ captured_main (int argc, char *argv[])
int i, n;
n = argc - (next_arg - argv);
- program_path.set (make_unique_xstrdup (next_arg[0]));
+ program_path.set (next_arg[0]);
for (i = 1; i < n; i++)
program_args.push_back (xstrdup (next_arg[i]));
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
--- a/gdbsupport/pathstuff.cc
+++ b/gdbsupport/pathstuff.cc
@@ -126,23 +126,23 @@ gdb_realpath_keepfile (const char *filename)
/* See gdbsupport/pathstuff.h. */
-gdb::unique_xmalloc_ptr<char>
+std::string
gdb_abspath (const char *path)
{
gdb_assert (path != NULL && path[0] != '\0');
if (path[0] == '~')
- return gdb_tilde_expand_up (path);
+ return gdb_tilde_expand (path);
if (IS_ABSOLUTE_PATH (path) || current_directory == NULL)
- return make_unique_xstrdup (path);
+ return path;
/* Beware the // my son, the Emacs barfs, the botch that catch... */
- return gdb::unique_xmalloc_ptr<char>
- (concat (current_directory,
- IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
- ? "" : SLASH_STRING,
- path, (char *) NULL));
+ return string_printf
+ ("%s%s%s", current_directory,
+ (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
+ ? "" : SLASH_STRING),
+ path);
}
/* See gdbsupport/pathstuff.h. */
@@ -225,8 +225,8 @@ get_standard_cache_dir ()
if (xdg_cache_home != NULL)
{
/* Make sure the path is absolute and tilde-expanded. */
- gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (xdg_cache_home));
- return string_printf ("%s/gdb", abs.get ());
+ std::string abs = gdb_abspath (xdg_cache_home);
+ return string_printf ("%s/gdb", abs.c_str ());
}
#endif
@@ -234,8 +234,8 @@ get_standard_cache_dir ()
if (home != NULL)
{
/* Make sure the path is absolute and tilde-expanded. */
- gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (home));
- return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.get ());
+ std::string abs = gdb_abspath (home);
+ return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.c_str ());
}
return {};
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -49,7 +49,7 @@ extern gdb::unique_xmalloc_ptr<char>
If CURRENT_DIRECTORY is NULL, this function returns a copy of
PATH. */
-extern gdb::unique_xmalloc_ptr<char> gdb_abspath (const char *path);
+extern std::string gdb_abspath (const char *path);
/* If the path in CHILD is a child of the path in PARENT, return a
pointer to the first component in the CHILD's pathname below the

View File

@ -1,475 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Mon, 4 Dec 2023 11:02:16 -0800
Subject: gdb-find_and_open_source-empty-string-ub-2of4.patch
;; Backport "gdbsupport: add path_join function"
;; (Simon Marchi)
In this review [1], Eli pointed out that we should be careful when
concatenating file names to avoid duplicated slashes. On Windows, a
double slash at the beginning of a file path has a special meaning. So
naively concatenating "/" and "foo/bar" would give "//foo/bar", which
would not give the desired results. We already have a few spots doing:
if (first_path ends with a slash)
path = first_path + second_path
else
path = first_path + slash + second_path
In general, I think it's nice to avoid superfluous slashes in file
paths, since they might end up visible to the user and look a bit
unprofessional.
Introduce the path_join function that can be used to join multiple path
components together (along with unit tests).
I initially wanted to make it possible to join two absolute paths, to
support the use case of prepending a sysroot path to a target file path,
or the prepending the debug-file-directory to a target file path. But
the code in solib_find_1 shows that it is more complex than this anyway
(for example, when the right hand side is a Windows path with a drive
letter). So I don't think we need to support that case in path_join.
That also keeps the implementation simpler.
Change a few spots to use path_join to show how it can be used. I
believe that all the spots I changed are guarded by some checks that
ensure the right hand side operand is not an absolute path.
Regression-tested on Ubuntu 18.04. Built-tested on Windows, and I also
ran the new unit-test there.
[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187559.html
Change-Id: I0df889f7e3f644e045f42ff429277b732eb6c752
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -446,6 +446,7 @@ SELFTESTS_SRCS = \
unittests/observable-selftests.c \
unittests/optional-selftests.c \
unittests/parse-connection-spec-selftests.c \
+ unittests/path-join-selftests.c \
unittests/ptid-selftests.c \
unittests/main-thread-selftests.c \
unittests/mkdir-recursive-selftests.c \
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -19,6 +19,7 @@
#include "defs.h"
#include "buildsym-legacy.h"
#include "bfd.h"
+#include "gdbsupport/pathstuff.h"
#include "gdb_obstack.h"
#include "symtab.h"
#include "symfile.h"
@@ -512,27 +513,22 @@ buildsym_compunit::start_subfile (const char *name)
for (subfile = m_subfiles; subfile; subfile = subfile->next)
{
- char *subfile_name;
+ std::string subfile_name;
/* If NAME is an absolute path, and this subfile is not, then
attempt to create an absolute path to compare. */
if (IS_ABSOLUTE_PATH (name)
&& !IS_ABSOLUTE_PATH (subfile->name)
&& subfile_dirname != NULL)
- subfile_name = concat (subfile_dirname, SLASH_STRING,
- subfile->name, (char *) NULL);
+ subfile_name = path_join (subfile_dirname, subfile->name);
else
subfile_name = subfile->name;
- if (FILENAME_CMP (subfile_name, name) == 0)
+ if (FILENAME_CMP (subfile_name.c_str (), name) == 0)
{
m_current_subfile = subfile;
- if (subfile_name != subfile->name)
- xfree (subfile_name);
return;
}
- if (subfile_name != subfile->name)
- xfree (subfile_name);
}
/* This subfile is not known. Add an entry for it. */
diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
--- a/gdb/dwarf2/line-header.c
+++ b/gdb/dwarf2/line-header.c
@@ -24,6 +24,7 @@
#include "dwarf2/read.h"
#include "complaints.h"
#include "filenames.h"
+#include "gdbsupport/pathstuff.h"
void
line_header::add_include_dir (const char *include_dir)
@@ -73,9 +74,7 @@ line_header::file_file_name (int file) const
{
const char *dir = fe->include_dir (this);
if (dir != NULL)
- return gdb::unique_xmalloc_ptr<char> (concat (dir, SLASH_STRING,
- fe->name,
- (char *) NULL));
+ return make_unique_xstrdup (path_join (dir, fe->name).c_str ());
}
return make_unique_xstrdup (fe->name);
}
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12782,14 +12782,13 @@ open_dwo_file (dwarf2_per_objfile *per_objfile,
if (comp_dir != NULL)
{
- gdb::unique_xmalloc_ptr<char> path_to_try
- (concat (comp_dir, SLASH_STRING, file_name, (char *) NULL));
+ std::string path_to_try = path_join (comp_dir, file_name);
/* NOTE: If comp_dir is a relative path, this will also try the
search path, which seems useful. */
- gdb_bfd_ref_ptr abfd (try_open_dwop_file (per_objfile, path_to_try.get (),
- 0 /*is_dwp*/,
- 1 /*search_cwd*/));
+ gdb_bfd_ref_ptr abfd (try_open_dwop_file
+ (per_objfile, path_to_try.c_str (), 0 /*is_dwp*/, 1 /*search_cwd*/));
+
if (abfd != NULL)
return abfd;
}
@@ -20537,7 +20536,7 @@ static const char *
psymtab_include_file_name (const struct line_header *lh, const file_entry &fe,
const dwarf2_psymtab *pst,
const char *comp_dir,
- gdb::unique_xmalloc_ptr<char> *name_holder)
+ std::string &name_holder)
{
const char *include_name = fe.name;
const char *include_name_to_compare = include_name;
@@ -20546,7 +20545,7 @@ psymtab_include_file_name (const struct line_header *lh, const file_entry &fe,
const char *dir_name = fe.include_dir (lh);
- gdb::unique_xmalloc_ptr<char> hold_compare;
+ std::string hold_compare;
if (!IS_ABSOLUTE_PATH (include_name)
&& (dir_name != NULL || comp_dir != NULL))
{
@@ -20573,26 +20572,23 @@ psymtab_include_file_name (const struct line_header *lh, const file_entry &fe,
if (dir_name != NULL)
{
- name_holder->reset (concat (dir_name, SLASH_STRING,
- include_name, (char *) NULL));
- include_name = name_holder->get ();
+ name_holder = path_join (dir_name, include_name);
+ include_name = name_holder.c_str ();
include_name_to_compare = include_name;
}
if (!IS_ABSOLUTE_PATH (include_name) && comp_dir != NULL)
{
- hold_compare.reset (concat (comp_dir, SLASH_STRING,
- include_name, (char *) NULL));
- include_name_to_compare = hold_compare.get ();
+ hold_compare = path_join (comp_dir, include_name);
+ include_name_to_compare = hold_compare.c_str ();
}
}
pst_filename = pst->filename;
- gdb::unique_xmalloc_ptr<char> copied_name;
+ std::string copied_name;
if (!IS_ABSOLUTE_PATH (pst_filename) && pst->dirname != NULL)
{
- copied_name.reset (concat (pst->dirname, SLASH_STRING,
- pst_filename, (char *) NULL));
- pst_filename = copied_name.get ();
+ copied_name = path_join (pst->dirname, pst_filename);
+ pst_filename = copied_name.c_str ();
}
file_is_pst = FILENAME_CMP (include_name_to_compare, pst_filename) == 0;
@@ -21303,10 +21299,10 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
for (auto &file_entry : lh->file_names ())
if (file_entry.included_p == 1)
{
- gdb::unique_xmalloc_ptr<char> name_holder;
+ std::string name_holder;
const char *include_name =
psymtab_include_file_name (lh, file_entry, pst,
- comp_dir, &name_holder);
+ comp_dir, name_holder);
if (include_name != NULL)
dwarf2_create_include_psymtab (include_name, pst, objfile);
}
@@ -21360,7 +21356,7 @@ static void
dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
const char *dirname)
{
- gdb::unique_xmalloc_ptr<char> copy;
+ std::string copy;
/* In order not to lose the line information directory,
we concatenate it to the filename when it makes sense.
@@ -21371,8 +21367,8 @@ dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
{
- copy.reset (concat (dirname, SLASH_STRING, filename, (char *) NULL));
- filename = copy.get ();
+ copy = path_join (dirname, filename);
+ filename = copy.c_str ();
}
cu->get_builder ()->start_subfile (filename);
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "gdbsupport/pathstuff.h"
#include "gdb_obstack.h"
#include "splay-tree.h"
#include "filenames.h"
@@ -1071,5 +1072,5 @@ macro_source_fullname (struct macro_source_file *file)
if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename))
return file->filename;
- return std::string (comp_dir) + SLASH_STRING + file->filename;
+ return path_join (comp_dir, file->filename);
}
diff --git a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
--- a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
+++ b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
@@ -36,6 +36,12 @@ if { [regsub {^(/[^/]+)/} $srcfileabs {\1subst/} srcfileabssubst] != 1
return -1
}
+# Generate a regular expression which to match $srcfileabs with
+# or without the doubled slash. This is used by the substituted
+# fullname test.
+set srcfileabssubst_regexp [string_to_regexp $srcfileabssubst]
+regsub {//} $srcfileabssubst_regexp {\0?} srcfileabssubst_regexp
+
set f [open $srcfileabs "w"]
puts $f "int main (void) { return 0; }"
close $f
@@ -54,7 +60,7 @@ mi_gdb_test "-interpreter-exec console \"set substitute-path ${initdir} ${initdi
mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\".*\".*" "fullname present"
-mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"[string_to_regexp $srcfileabssubst]\".*" "substituted fullname"
+mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"$srcfileabssubst_regexp\".*" "substituted fullname"
# Test compare_filenames_for_search does not falsely use absolute filename as
# a relative one.
diff --git a/gdb/unittests/path-join-selftests.c b/gdb/unittests/path-join-selftests.c
new file mode 100644
--- /dev/null
+++ b/gdb/unittests/path-join-selftests.c
@@ -0,0 +1,73 @@
+/* Self tests for path_join for GDB, the GNU debugger.
+
+ Copyright (C) 2022 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 <http://www.gnu.org/licenses/>. */
+
+#include "defs.h"
+#include "gdbsupport/pathstuff.h"
+#include "gdbsupport/selftest.h"
+
+namespace selftests {
+namespace path_join {
+
+template <typename ...Args>
+static void
+test_one (const char *expected, Args... paths)
+{
+ std::string actual = ::path_join (paths...);
+
+ SELF_CHECK (actual == expected);
+}
+
+/* Test path_join. */
+
+static void
+test ()
+{
+ test_one ("/foo/bar", "/foo", "bar");
+ test_one ("/bar", "/", "bar");
+ test_one ("foo/bar/", "foo", "bar", "");
+ test_one ("foo", "", "foo");
+ test_one ("foo/bar", "foo", "", "bar");
+ test_one ("foo/", "foo", "");
+ test_one ("foo/", "foo/", "");
+
+ test_one ("D:/foo/bar", "D:/foo", "bar");
+ test_one ("D:/foo/bar", "D:/foo/", "bar");
+
+#if defined(_WIN32)
+ /* The current implementation doesn't recognize backslashes as directory
+ separators on Unix-like systems, so only run these tests on Windows. If
+ we ever switch our implementation to use std::filesystem::path, they
+ should work anywhere, in theory. */
+ test_one ("D:\\foo/bar", "D:\\foo", "bar");
+ test_one ("D:\\foo\\bar", "D:\\foo\\", "bar");
+ test_one ("\\\\server\\dir\\file", "\\\\server\\dir\\", "file");
+ test_one ("\\\\server\\dir/file", "\\\\server\\dir", "file");
+#endif /* _WIN32 */
+}
+
+}
+}
+
+void _initialize_path_join_selftests ();
+void
+_initialize_path_join_selftests ()
+{
+ selftests::register_test ("path_join",
+ selftests::path_join::test);
+}
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
--- a/gdbsupport/pathstuff.cc
+++ b/gdbsupport/pathstuff.cc
@@ -87,7 +87,6 @@ gdb_realpath_keepfile (const char *filename)
{
const char *base_name = lbasename (filename);
char *dir_name;
- char *result;
/* Extract the basename of filename, and return immediately
a copy of filename if it does not contain any directory prefix. */
@@ -116,12 +115,7 @@ gdb_realpath_keepfile (const char *filename)
directory separator, avoid doubling it. */
gdb::unique_xmalloc_ptr<char> path_storage = gdb_realpath (dir_name);
const char *real_path = path_storage.get ();
- if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1]))
- result = concat (real_path, base_name, (char *) NULL);
- else
- result = concat (real_path, SLASH_STRING, base_name, (char *) NULL);
-
- return gdb::unique_xmalloc_ptr<char> (result);
+ return make_unique_xstrdup (path_join (real_path, base_name).c_str ());
}
/* See gdbsupport/pathstuff.h. */
@@ -137,12 +131,7 @@ gdb_abspath (const char *path)
if (IS_ABSOLUTE_PATH (path) || current_directory == NULL)
return path;
- /* Beware the // my son, the Emacs barfs, the botch that catch... */
- return string_printf
- ("%s%s%s", current_directory,
- (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
- ? "" : SLASH_STRING),
- path);
+ return path_join (current_directory, path);
}
/* See gdbsupport/pathstuff.h. */
@@ -197,6 +186,29 @@ child_path (const char *parent, const char *child)
/* See gdbsupport/pathstuff.h. */
+std::string
+path_join (gdb::array_view<const gdb::string_view> paths)
+{
+ std::string ret;
+
+ for (int i = 0; i < paths.size (); ++i)
+ {
+ const gdb::string_view path = paths[i];
+
+ if (i > 0)
+ gdb_assert (!IS_ABSOLUTE_PATH (path));
+
+ if (!ret.empty () && !IS_DIR_SEPARATOR (ret.back ()))
+ ret += '/';
+
+ ret.append (path.begin (), path.end ());
+ }
+
+ return ret;
+}
+
+/* See gdbsupport/pathstuff.h. */
+
bool
contains_dir_separator (const char *path)
{
@@ -226,7 +238,7 @@ get_standard_cache_dir ()
{
/* Make sure the path is absolute and tilde-expanded. */
std::string abs = gdb_abspath (xdg_cache_home);
- return string_printf ("%s/gdb", abs.c_str ());
+ return path_join (abs.c_str (), "gdb");
}
#endif
@@ -235,7 +247,7 @@ get_standard_cache_dir ()
{
/* Make sure the path is absolute and tilde-expanded. */
std::string abs = gdb_abspath (home);
- return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.c_str ());
+ return path_join (abs.c_str (), HOME_CACHE_DIR, "gdb");
}
return {};
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -21,6 +21,7 @@
#define COMMON_PATHSTUFF_H
#include "gdbsupport/byte-vector.h"
+#include "gdbsupport/array-view.h"
/* Path utilities. */
@@ -57,6 +58,28 @@ extern std::string gdb_abspath (const char *path);
extern const char *child_path (const char *parent, const char *child);
+/* Join elements in PATHS into a single path.
+
+ The first element can be absolute or relative. All the others must be
+ relative. */
+
+extern std::string path_join (gdb::array_view<const gdb::string_view> paths);
+
+/* Same as the above, but accept paths as distinct parameters. */
+
+template<typename ...Args>
+std::string
+path_join (Args... paths)
+{
+ /* It doesn't make sense to join less than two paths. */
+ gdb_static_assert (sizeof... (Args) >= 2);
+
+ std::array<gdb::string_view, sizeof... (Args)> views
+ { gdb::string_view (paths)... };
+
+ return path_join (gdb::array_view<const gdb::string_view> (views));
+}
+
/* Return whether PATH contains a directory separator character. */
extern bool contains_dir_separator (const char *path);

View File

@ -1,47 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Tue, 5 Dec 2023 08:47:16 -0800
Subject: gdb-find_and_open_source-empty-string-ub-3of4.patch
;; Backport "Fix undefined behaviour dereferencing empty string"
;; (Magne Hov, RHEL-17631)
When a source file's dirname is solely made up of directory separators
we end up trying to dereference the last character of an empty string
with std::string::back, which results in undefined behaviour. A typical
use case where this can happen is when the root directory "/" is used as
a compilation directory.
With libstdc++.so.6.0.28 we get no out-of-bounds checks and the byte
preceding the storage of the empty string is returned. The character
value of this byte depends on heap implementation and usage, but when
this byte happens to hold the value of the directory separator character
we go on to call std::string::pop_back on the empty string which results
in an out_of_range exception which terminates GDB.
Fix this by using path_join. prepare_path_for_appending ensures that the
filename component is relative.
The testsuite has been run before and after the change and no
regressions were found.
diff --git a/gdb/source.c b/gdb/source.c
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1111,15 +1111,7 @@ find_and_open_source (const char *filename,
helpful if part of the compilation directory was removed,
e.g. using gcc's -fdebug-prefix-map, and we have added the missing
prefix to source_path. */
- std::string cdir_filename (dirname);
-
- /* Remove any trailing directory separators. */
- while (IS_DIR_SEPARATOR (cdir_filename.back ()))
- cdir_filename.pop_back ();
-
- /* Add our own directory separator. */
- cdir_filename.append (SLASH_STRING);
- cdir_filename.append (filename_start);
+ std::string cdir_filename = path_join (dirname, filename_start);
result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH,
cdir_filename.c_str (), OPEN_MODE, fullname);

View File

@ -1,113 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Wed, 6 Dec 2023 07:19:49 -0800
Subject: gdb-find_and_open_source-empty-string-ub-4of4.patch
;; Backport "gdbsupport: change path_join parameter to
;; array_view<const char *>"
;; (Simon Marchi)
When a GDB built with -D_GLIBCXX_DEBUG=1 reads a binary with a single
character name, we hit this assertion failure:
$ ./gdb -q --data-directory=data-directory -nx ./x
/usr/include/c++/12.1.0/string_view:239: constexpr const std::basic_string_view<_CharT, _Traits>::value_type& std::basic_string_view<_CharT, _Traits>::operator[](size_type) const [with _CharT = char; _Traits = std::char_traits<char>; const_reference = const char&; size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed.
The backtrace:
#3 0x00007ffff6c0f002 in std::__glibcxx_assert_fail (file=<optimized out>, line=<optimized out>, function=<optimized out>, condition=<optimized out>) at /usr/src/debug/gcc/libstdc++-v3/src/c++11/debug.cc:60
#4 0x000055555da8a864 in std::basic_string_view<char, std::char_traits<char> >::operator[] (this=0x7fffffffcc30, __pos=1) at /usr/include/c++/12.1.0/string_view:239
#5 0x00005555609dcb88 in path_join[abi:cxx11](gdb::array_view<std::basic_string_view<char, std::char_traits<char> > const>) (paths=...) at /home/simark/src/binutils-gdb/gdbsupport/pathstuff.cc:203
#6 0x000055555e0443f4 in path_join<char const*, char const*> () at /home/simark/src/binutils-gdb/gdb/../gdbsupport/pathstuff.h:84
#7 0x00005555609dc336 in gdb_realpath_keepfile[abi:cxx11](char const*) (filename=0x6060000a8d40 "/home/simark/build/binutils-gdb-one-target/gdb/./x") at /home/simark/src/binutils-gdb/gdbsupport/pathstuff.cc:122
#8 0x000055555ebd2794 in exec_file_attach (filename=0x7fffffffe0f9 "./x", from_tty=1) at /home/simark/src/binutils-gdb/gdb/exec.c:471
#9 0x000055555f2b3fb0 in catch_command_errors (command=0x55555ebd1ab6 <exec_file_attach(char const*, int)>, arg=0x7fffffffe0f9 "./x", from_tty=1, do_bp_actions=false) at /home/simark/src/binutils-gdb/gdb/main.c:513
#10 0x000055555f2b7e11 in captured_main_1 (context=0x7fffffffdb60) at /home/simark/src/binutils-gdb/gdb/main.c:1209
#11 0x000055555f2b9144 in captured_main (data=0x7fffffffdb60) at /home/simark/src/binutils-gdb/gdb/main.c:1319
#12 0x000055555f2b9226 in gdb_main (args=0x7fffffffdb60) at /home/simark/src/binutils-gdb/gdb/main.c:1344
#13 0x000055555d938c5e in main (argc=5, argv=0x7fffffffdcf8) at /home/simark/src/binutils-gdb/gdb/gdb.c:32
The problem is this line in path_join:
gdb_assert (strlen (path) == 0 || !IS_ABSOLUTE_PATH (path));
... where `path` is "x". IS_ABSOLUTE_PATH eventually calls
HAS_DRIVE_SPEC_1:
#define HAS_DRIVE_SPEC_1(dos_based, f) \
((f)[0] && ((f)[1] == ':') && (dos_based))
This macro accesses indices 0 and 1 of the input string. However, `f`
is a string_view of length 1, so it's incorrect to try to access index
1. We know that the string_view's underlying object is a null-terminated
string, so in practice there's no harm. But as far as the string_view
is concerned, index 1 is considered out of bounds.
This patch makes the easy fix, that is to change the path_join parameter
from a vector of to a vector of `const char *`. Another solution would
be to introduce a non-standard gdb::cstring_view class, which would be a
view over a null-terminated string. With that class, it would be
correct to access index 1, it would yield the NUL character. If there
is interest in having this class (it has been mentioned a few times in
the past) I can do it and use it here.
This was found by running tests such as gdb.ada/arrayidx.exp, which
produce 1-char long filenames, so adding a new test is not necessary.
Change-Id: Ia41a16c7243614636b18754fd98a41860756f7af
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
--- a/gdbsupport/pathstuff.cc
+++ b/gdbsupport/pathstuff.cc
@@ -187,21 +187,21 @@ child_path (const char *parent, const char *child)
/* See gdbsupport/pathstuff.h. */
std::string
-path_join (gdb::array_view<const gdb::string_view> paths)
+path_join (gdb::array_view<const char *> paths)
{
std::string ret;
for (int i = 0; i < paths.size (); ++i)
{
- const gdb::string_view path = paths[i];
+ const char *path = paths[i];
if (i > 0)
- gdb_assert (!IS_ABSOLUTE_PATH (path));
+ gdb_assert (strlen (path) == 0 || !IS_ABSOLUTE_PATH (path));
if (!ret.empty () && !IS_DIR_SEPARATOR (ret.back ()))
ret += '/';
- ret.append (path.begin (), path.end ());
+ ret.append (path);
}
return ret;
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -63,7 +63,7 @@ extern const char *child_path (const char *parent, const char *child);
The first element can be absolute or relative. All the others must be
relative. */
-extern std::string path_join (gdb::array_view<const gdb::string_view> paths);
+extern std::string path_join (gdb::array_view<const char *> paths);
/* Same as the above, but accept paths as distinct parameters. */
@@ -74,10 +74,10 @@ path_join (Args... paths)
/* It doesn't make sense to join less than two paths. */
gdb_static_assert (sizeof... (Args) >= 2);
- std::array<gdb::string_view, sizeof... (Args)> views
- { gdb::string_view (paths)... };
+ std::array<const char *, sizeof... (Args)> path_array
+ { paths... };
- return path_join (gdb::array_view<const gdb::string_view> (views));
+ return path_join (gdb::array_view<const char *> (path_array));
}
/* Return whether PATH contains a directory separator character. */

View File

@ -1,71 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Mon, 12 Dec 2022 15:21:33 +0100
Subject: gdb-fix-gdb.base-printcmds-s390x-regressions.patch
;; Backport "[gdb/testsuite] Fix PR20630 regression test in gdb.base/printcmds.exp"
;; (Tom de Vries)
On s390x-linux, I run into:
...
(gdb) print {unsigned char}{65}^M
$749 = 0 '\000'^M
(gdb) FAIL: gdb.base/printcmds.exp: print {unsigned char}{65}
...
In contrast, on x86_64-linux, we have:
...
(gdb) print {unsigned char}{65}^M
$749 = 65 'A'^M
(gdb) PASS: gdb.base/printcmds.exp: print {unsigned char}{65}
...
The first problem here is that the test is supposed to be a regression test
for PR20630, which can be reproduced (for an unfixed gdb) like this:
...
(gdb) p {unsigned char[]}{0x17}
gdbtypes.c:4641: internal-error: copy_type: \
Assertion `TYPE_OBJFILE_OWNED (type)' failed.
...
but it's not due to insufficient quoting (note the dropped '[]').
That's easy to fix, but after that we have on s390 (big endian):
...
(gdb) print {unsigned char[]}{65}^M
$749 = ""^M
...
and on x86_64 (little endian):
...
(gdb) print {unsigned char[]}{65}^M
$749 = "A"^M
...
Fix this by using 0xffffffff, such that in both cases we have:
...
(gdb) print {unsigned char[]}{0xffffffff}^M
$749 = "\377\377\377\377"^M
...
Tested on x86_64-linux and s390x-linux.
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -717,6 +717,7 @@ proc test_print_string_constants {} {
}
proc test_print_array_constants {} {
+ global hex
if [target_info exists gdb,cannot_call_functions] {
unsupported "this target can not call functions"
@@ -735,7 +736,8 @@ proc test_print_array_constants {} {
gdb_test "print *&{4,5,6}\[1\]" "Attempt to take address of value not located in memory."
# This used to cause a crash.
- gdb_test "print {unsigned char[]}{65}" " = 65 'A'"
+ set val [string_to_regexp {"\377\377\377\377"}]
+ gdb_test "print {unsigned char\[\]}{0xffffffff}" " = $val"
}
proc test_print_enums {} {

View File

@ -1,88 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@efficios.com>
Date: Tue, 4 May 2021 11:20:09 -0400
Subject: gdb-flexible-array-member-expected-pattern.patch
;; Backport "adjust gdb.python/flexible-array-member.exp expected pattern"
;; (Simon Marchi)
The `Type.range ()` tests in gdb.python/flexible-array-member.exp pass
when the test is compiled with gcc 9 or later, but not with gcc 8 or
earlier:
$ make check TESTS="gdb.python/flexible-array-member.exp" RUNTESTFLAGS="CC_FOR_TARGET='gcc-8'"
python print(zs['items'].type.range())^M
(0, 0)^M
(gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zs['items'].type.range())
python print(zso['items'].type.range())^M
(0, 0)^M
(gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zso['items'].type.range())
The value that we get for the upper bound of a flexible array member
declared with a "0" size is 0 with gcc <= 8 and is -1 for gcc >= 9.
This is due to different debug info. For this member, gcc 8 does:
0x000000d5: DW_TAG_array_type
DW_AT_type [DW_FORM_ref4] (0x00000034 "int")
DW_AT_sibling [DW_FORM_ref4] (0x000000e4)
0x000000de: DW_TAG_subrange_type
DW_AT_type [DW_FORM_ref4] (0x0000002d "long unsigned int")
For the same type, gcc 9 does:
0x000000d5: DW_TAG_array_type
DW_AT_type [DW_FORM_ref4] (0x00000034 "int")
DW_AT_sibling [DW_FORM_ref4] (0x000000e5)
0x000000de: DW_TAG_subrange_type
DW_AT_type [DW_FORM_ref4] (0x0000002d "long unsigned int")
DW_AT_count [DW_FORM_data1] (0x00)
Ideally, GDB would present a consistent and documented value for an
array member declared with size 0, regardless of how the debug info
looks like. But for now, just change the test to accept the two
values, to get rid of the failure and make the test in sync
I also realized (by looking at the py-type.exp test) that calling the
fields method on an array type yields one field representing the "index"
of the array. The type of that field is of type range
(gdb.TYPE_CODE_RANGE). When calling `.range()` on that range type, it
yields the same range tuple as when calling `.range()` on the array type
itself. For completeness, add some tests to access the range tuple
through that range type as well.
gdb/testsuite/ChangeLog:
* gdb.python/flexible-array-member.exp: Adjust expected range
value for member declared with 0 size. Test accessing range
tuple through range type.
Change-Id: Ie4e06d99fe9315527f04577888f48284d649ca4c
diff --git a/gdb/testsuite/gdb.python/flexible-array-member.exp b/gdb/testsuite/gdb.python/flexible-array-member.exp
--- a/gdb/testsuite/gdb.python/flexible-array-member.exp
+++ b/gdb/testsuite/gdb.python/flexible-array-member.exp
@@ -76,9 +76,17 @@ gdb_test "python print(zso\['items'\] == zso\['items'\]\[0\].address)" "True"
gdb_test "python print(zso\['items'\]\[0\].address + 1 == zso\['items'\]\[1\].address)" "True"
# Verify the range attribute. It looks a bit inconsistent that the high bound
-# is sometimes 0, sometimes -1, but that's what GDB produces today, so that's
-# what we test.
+# is sometimes 0, sometimes -1. It depends on the way the flexible array
+# member is specified and on the compiler version (the debug info is
+# different). But that's what GDB produces today, so that's what we test.
gdb_test "python print(ns\['items'\].type.range())" "\\(0, 0\\)"
-gdb_test "python print(zs\['items'\].type.range())" "\\(0, -1\\)"
-gdb_test "python print(zso\['items'\].type.range())" "\\(0, -1\\)"
+gdb_test "python print(zs\['items'\].type.range())" "\\(0, (0|-1)\\)"
+gdb_test "python print(zso\['items'\].type.range())" "\\(0, (0|-1)\\)"
+
+# Test the same thing, but going explicitly through the array index's range
+# type.
+
+gdb_test "python print(ns\['items'\].type.fields()\[0\].type.range())" "\\(0, 0\\)"
+gdb_test "python print(zs\['items'\].type.fields()\[0\].type.range())" "\\(0, (0|-1)\\)"
+gdb_test "python print(zso\['items'\].type.fields()\[0\].type.range())" "\\(0, (0|-1)\\)"

View File

@ -1,104 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <jakub@redhat.com>.
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
+
+ subroutine f(s)
+ character*3 s
+ s = s
+ end
+
+ program main
+ call f ('foo')
+ end

View File

@ -0,0 +1,42 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Wed, 17 Jan 2024 12:53:53 -0700
Subject: gdb-ftbs-swapped-calloc-args.patch
Backport upstream commit 54195469c18ec9873cc5ba6907f768509473fa9b
which fixes a build problem in which arguments to calloc were swapped.
[opcodes] ARC + PPC: Fix -Walloc-size warnings
Recently, -Walloc-size warnings started to kick in. Fix these two
calloc() calls to match the intended usage pattern.
opcodes/ChangeLog:
* arc-dis.c (init_arc_disasm_info): Fix calloc() call.
* ppc-dis.c (powerpc_init_dialect): Ditto.
diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -147,7 +147,7 @@ static bool
init_arc_disasm_info (struct disassemble_info *info)
{
struct arc_disassemble_info *arc_infop
- = calloc (sizeof (*arc_infop), 1);
+ = calloc (1, sizeof (*arc_infop));
if (arc_infop == NULL)
return false;
diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c
--- a/opcodes/ppc-dis.c
+++ b/opcodes/ppc-dis.c
@@ -348,7 +348,7 @@ powerpc_init_dialect (struct disassemble_info *info)
{
ppc_cpu_t dialect = 0;
ppc_cpu_t sticky = 0;
- struct dis_private *priv = calloc (sizeof (*priv), 1);
+ struct dis_private *priv = calloc (1, sizeof (*priv));
if (priv == NULL)
return;

View File

@ -1,281 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@adacore.com>
Date: Fri, 23 Apr 2021 11:28:48 -0600
Subject: gdb-gdb27743-psymtab-imported-unit.patch
;; Backport "Fix crash when expanding partial symtabs with DW_TAG_imported_unit"
;; (Tom Tromey, gdb/27743)
From e7d77ce0c408e7019f9885b8be64c9cdb46dd312 Mon Sep 17 00:00:00 2001
Subject: [PATCH] Fix crash when expanding partial symtabs with
DW_TAG_imported_unit
PR gdb/27743 points out a gdb crash when expanding partial symtabs,
where one of the compilation units uses DW_TAG_imported_unit.
The bug is that partial_map_expand_apply expects only to be called for
the outermost psymtab. However, filename searching doesn't (and
probably shouldn't) guarantee this. The fix is to walk upward to find
the outermost CU.
A new test case is included. It is mostly copied from other test
cases, which really sped up the effort.
This bug does not occur on trunk. There,
psym_map_symtabs_matching_filename is gone, replaced by
psymbol_functions::expand_symtabs_matching. When this find a match,
it calls psymtab_to_symtab, which does this same upward walk.
Tested on x86-64 Fedora 32.
I propose checking in this patch on the gdb-10 branch, and just the
new test case on trunk.
gdb/ChangeLog
2021-04-23 Tom Tromey <tromey@adacore.com>
PR gdb/27743:
* psymtab.c (partial_map_expand_apply): Expand outermost psymtab.
gdb/testsuite/ChangeLog
2021-04-23 Tom Tromey <tromey@adacore.com>
PR gdb/27743:
* gdb.dwarf2/imported-unit-bp.exp: New file.
* gdb.dwarf2/imported-unit-bp-main.c: New file.
* gdb.dwarf2/imported-unit-bp-alt.c: New file.
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -127,9 +127,10 @@ partial_map_expand_apply (struct objfile *objfile,
{
struct compunit_symtab *last_made = objfile->compunit_symtabs;
- /* Shared psymtabs should never be seen here. Instead they should
- be handled properly by the caller. */
- gdb_assert (pst->user == NULL);
+ /* We may see a shared psymtab here, but we want to expand the
+ outermost symtab. */
+ while (pst->user != nullptr)
+ pst = pst->user;
/* Don't visit already-expanded psymtabs. */
if (pst->readin_p (objfile))
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-bp-alt.c b/gdb/testsuite/gdb.dwarf2/imported-unit-bp-alt.c
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-bp-alt.c
@@ -0,0 +1,50 @@
+/* Copyright 2020-2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Used to insert labels with which we can build a fake line table. */
+#define LL(N) asm ("line_label_" #N ": .globl line_label_" #N)
+
+volatile int var;
+volatile int bar;
+
+/* Generate some code to take up some space. */
+#define FILLER do { \
+ var = 99; \
+} while (0)
+
+int
+func (void)
+{ /* func prologue */
+ asm ("func_label: .globl func_label");
+ LL (1); // F1, Ln 16
+ FILLER;
+ LL (2); // F1, Ln 17
+ FILLER;
+ LL (3); // F2, Ln 21
+ FILLER;
+ LL (4); // F2, Ln 22 // F1, Ln 18, !S
+ FILLER;
+ LL (5); // F1, Ln 19 !S
+ FILLER;
+ LL (6); // F1, Ln 20
+ FILLER;
+ LL (7);
+ FILLER;
+ return 0; /* func end */
+}
+
+#ifdef WITHMAIN
+int main () { return 0; }
+#endif
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-bp-main.c b/gdb/testsuite/gdb.dwarf2/imported-unit-bp-main.c
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-bp-main.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2004-2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+extern int func (void);
+
+int
+main()
+{
+ return func ();
+}
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp
@@ -0,0 +1,128 @@
+# Copyright 2020-2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test that "break /absolute/file:line" works ok with imported CUs.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+ return 0
+}
+
+# The .c files use __attribute__.
+if [get_compiler_info] {
+ return -1
+}
+if !$gcc_compiled {
+ return 0
+}
+
+standard_testfile imported-unit-bp-alt.c .S imported-unit-bp-main.c
+
+set build_options {nodebug optimize=-O1}
+
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+ global srcdir subdir srcfile srcfile
+ global build_options
+ declare_labels lines_label callee_subprog_label cu_label
+
+ get_func_info func "$build_options additional_flags=-DWITHMAIN"
+
+ cu {} {
+ compile_unit {
+ {language @DW_LANG_C}
+ {name "<artificial>"}
+ } {
+ imported_unit {
+ {import %$cu_label}
+ }
+ }
+ }
+
+ cu {} {
+ cu_label: compile_unit {
+ {producer "gcc"}
+ {language @DW_LANG_C}
+ {name ${srcfile}}
+ {comp_dir "/tmp"}
+ {low_pc 0 addr}
+ {stmt_list ${lines_label} DW_FORM_sec_offset}
+ } {
+ callee_subprog_label: subprogram {
+ {external 1 flag}
+ {name callee}
+ {inline 3 data1}
+ }
+ subprogram {
+ {external 1 flag}
+ {name func}
+ {low_pc $func_start addr}
+ {high_pc "$func_start + $func_len" addr}
+ } {
+ }
+ }
+ }
+
+ lines {version 2 default_is_stmt 1} lines_label {
+ include_dir "/tmp"
+ file_name "$srcfile" 1
+
+ program {
+ {DW_LNE_set_address line_label_1}
+ {DW_LNS_advance_line 15}
+ {DW_LNS_copy}
+
+ {DW_LNE_set_address line_label_2}
+ {DW_LNS_advance_line 1}
+ {DW_LNS_copy}
+
+ {DW_LNE_set_address line_label_3}
+ {DW_LNS_advance_line 4}
+ {DW_LNS_copy}
+
+ {DW_LNE_set_address line_label_4}
+ {DW_LNS_advance_line 1}
+ {DW_LNS_copy}
+
+ {DW_LNS_advance_line -4}
+ {DW_LNS_negate_stmt}
+ {DW_LNS_copy}
+
+ {DW_LNE_set_address line_label_5}
+ {DW_LNS_advance_line 1}
+ {DW_LNS_copy}
+
+ {DW_LNE_set_address line_label_6}
+ {DW_LNS_advance_line 1}
+ {DW_LNS_negate_stmt}
+ {DW_LNS_copy}
+
+ {DW_LNE_set_address line_label_7}
+ {DW_LNE_end_sequence}
+ }
+ }
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $asm_file $srcfile3] $build_options] } {
+ return -1
+}
+
+gdb_reinitialize_dir /tmp
+
+# Using an absolute path is important to see the bug.
+gdb_test "break /tmp/${srcfile}:19" "Breakpoint .* file $srcfile, line .*"

View File

@ -1,37 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-libexec-add-index.patch
;; Fix gdb-headless /usr/bin/ executables (BZ 1390251).
;;
;; Also, make /usr/bin/gdb.minimal be the default GDB used, if it's
;; present. For rationale, see:
;;
;; https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot
;;=fedora
diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh
--- a/gdb/contrib/gdb-add-index.sh
+++ b/gdb/contrib/gdb-add-index.sh
@@ -22,6 +22,20 @@ GDB=${GDB:=gdb}
OBJCOPY=${OBJCOPY:=objcopy}
READELF=${READELF:=readelf}
+GDB2=/usr/libexec/gdb
+if test -x $GDB2 && ! which $GDB &>/dev/null; then
+ GDB=$GDB2
+fi
+
+# We default to using /usr/bin/gdb.minimal if it's present. See
+# https://bugzilla.redhat.com/show_bug.cgi?id=1695015 and
+# https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot for
+# explanations.
+GDB3=/usr/bin/gdb.minimal
+if test -x $GDB3; then
+ GDB=$GDB3
+fi
+
myname="${0##*/}"
dwarf5=""

View File

@ -1,165 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <http://www.gnu.org/licenses/>. */
+
+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 <http://www.gnu.org/licenses/>. */
+
+/* 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 <http://www.gnu.org/licenses/>.
+
+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\]+ = {<text variable, no debug info>} (0x\[0-9a-f\]+) <func>\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
+ }
+}

View File

@ -9,9 +9,9 @@ Subject: gdb-linux_perf-bundle.patch
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"
@@ -21,6 +21,10 @@
#include "interps.h"
#include "run-on-main-thread.h"
+#ifdef PERF_ATTR_SIZE_VER5_BUNDLE
+extern "C" void __libipt_init(void);
@ -20,6 +20,8 @@ diff --git a/gdb/gdb.c b/gdb/gdb.c
int
main (int argc, char **argv)
{
@@ -32,6 +36,10 @@ main (int argc, char **argv)
struct captured_main_args args;
+#ifdef PERF_ATTR_SIZE_VER5_BUNDLE
@ -32,7 +34,7 @@ diff --git a/gdb/gdb.c b/gdb/gdb.c
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
@@ -27,6 +27,177 @@
@@ -28,6 +28,177 @@
# include <linux/perf_event.h>
#endif
@ -213,7 +215,7 @@ diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
--- a/gdbsupport/common.m4
+++ b/gdbsupport/common.m4
@@ -145,7 +145,7 @@ AC_DEFUN([GDB_AC_COMMON], [
@@ -168,7 +168,7 @@ AC_DEFUN([GDB_AC_COMMON], [
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
#include <linux/perf_event.h>
#ifndef PERF_ATTR_SIZE_VER5

View File

@ -1,62 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <http://www.gnu.org/licenses/>.
+
+ 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 <http://www.gnu.org/licenses/>.
+
+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"

View File

@ -1,229 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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,29 @@
+/* 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 <http://www.gnu.org/licenses/>.
+
+ 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,26 @@
+/* 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 <http://www.gnu.org/licenses/>.
+
+ 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,26 @@
+/* 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 <http://www.gnu.org/licenses/>.
+
+ 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,26 @@
+/* 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 <http://www.gnu.org/licenses/>.
+
+ 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 <http://www.gnu.org/licenses/>.
+
+# 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,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 <http://www.gnu.org/licenses/>.
+
+ 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 *);
+};

View File

@ -1,103 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <http://www.gnu.org/licenses/>. */
+
+template <typename T>
+class GDB
+{
+ public:
+ static int simple (void) { return 0; }
+ static int harder (T a) { return 1; }
+ template <typename X>
+ static X even_harder (T a) { return static_cast<X> (a); }
+ int operator == (GDB const& other)
+ { return 1; }
+};
+
+int main(int argc, char **argv)
+{
+ GDB<int> a, b;
+ if (a == b)
+ return GDB<char>::harder('a') + GDB<int>::harder(3)
+ + GDB<char>::even_harder<int> ('a');
+ return GDB<int>::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 <http://www.gnu.org/licenses/>.
+
+# 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<char>::even_harder<int>(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<int>::operator ==" \
+ "GDB<int>::operator==(GDB<int> const&)" \
+ "GDB<char>::harder(char)" \
+ "GDB<int>::harder(int)" \
+ {"int GDB<char>::even_harder<int>(char)"} \
+ "GDB<int>::simple()"]
+
+foreach sym $min_syms {
+ if {[gdb_breakpoint $sym]} {
+ pass "setting breakpoint at $sym"
+ }
+}
+
+gdb_exit

View File

@ -1,303 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <func+24>: 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 */

View File

@ -1,115 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Fri, 21 May 2021 15:09:14 +0200
Subject: gdb-rhbz-2130624-assert_in_jit_event_handler.patch
;; Backport "[gdb/breakpoint] Fix assert in jit_event_handler"
;; (Tom de Vries, RHBZ2130624)
Consider a minimal test-case test.c:
...
int main (void) { return 0; }
...
which we can compile into llvm byte code using clang:
...
$ clang -g -S -emit-llvm --target=x86_64-unknown-unknown-elf test.c
...
and then run using lli, which uses the llvm jit:
...
$ lli test.ll
...
If we run this under gdb, we run into an assert:
...
$ gdb -q -batch -ex run --args /usr/bin/lli test.ll
Dwarf Error: Cannot not find DIE at 0x18a936e7 \
[from module libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
src/gdb/jit.c:1178: internal-error: \
void jit_event_handler(gdbarch*, objfile*): \
Assertion `jiter->jiter_data != nullptr' failed.
...
This is caused by the following.
When running jit_breakpoint_re_set_internal, we first handle
libLLVM.so.10.debug, and set a jit breakpoint.
Next we handle libLLVM.so.10:
...
(gdb) p the_objfile.original_name
$42 = 0x2494170 "libLLVM.so.10"
...
but the minimal symbols we find are from libLLVM.so.10.debug:
...
(gdb) p reg_symbol.objfile.original_name
$43 = 0x38e7c50 "libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug"
(gdb) p desc_symbol.objfile.original_name
$44 = 0x38e7c50 "libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug"
...
and consequently, the objf_data is the one from libLLVM.so.10.debug:
...
jiter_objfile_data *objf_data
= get_jiter_objfile_data (reg_symbol.objfile);
...
and so we hit this:
...
if (objf_data->cached_code_address == addr)
continue;
...
and no second jit breakpoint is inserted.
Subsequently, the jit breakpoint is triggered and handled, but when finding
the symbol for the breakpoint address we get:
...
(gdb) p jit_bp_sym.objfile.original_name
$52 = 0x2494170 "libLLVM.so.10"
...
The assert 'jiter->jiter_data != nullptr' triggers because it checks
libLLVM.so.10 while the one with jiter_data setup is libLLVM.so.10.debug.
This fixes the assert:
...
jiter_objfile_data *objf_data
- = get_jiter_objfile_data (reg_symbol.objfile);
- = get_jiter_objfile_data (the_objfile);
...
but consequently we'll have two jit breakpoints, so we also make sure we don't
set a jit breakpoint on separate debug objects like libLLVM.so.10.debug.
Tested on x86_64-linux.
gdb/ChangeLog:
2021-05-21 Tom de Vries <tdevries@suse.de>
PR breakpoint/27889
* jit.c (jit_breakpoint_re_set_internal): Skip separate debug
objects. Call get_jiter_objfile_data with the_objfile.
diff --git a/gdb/jit.c b/gdb/jit.c
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -893,6 +893,10 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
{
for (objfile *the_objfile : pspace->objfiles ())
{
+ /* Skip separate debug objects. */
+ if (the_objfile->separate_debug_objfile_backlink != nullptr)
+ continue;
+
if (the_objfile->skip_jit_symbol_lookup)
continue;
@@ -919,7 +923,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
}
jiter_objfile_data *objf_data
- = get_jiter_objfile_data (reg_symbol.objfile);
+ = get_jiter_objfile_data (the_objfile);
objf_data->register_code = reg_symbol.minsym;
objf_data->descriptor = desc_symbol.minsym;

View File

@ -0,0 +1,264 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andrew Burgess <aburgess@redhat.com>
Date: Sat, 25 Nov 2023 10:35:37 +0000
Subject: gdb-rhbz-2232086-cpp-ify-mapped-symtab.patch
;; Back-port upstream commit acc117b57f7 as part of a fix for
;; non-deterministic gdb-index generation (RH BZ 2232086).
gdb: C++-ify mapped_symtab from dwarf2/index-write.c
Make static the functions add_index_entry, find_slot, and hash_expand,
member functions of the mapped_symtab class.
Fold an additional snippet of code from write_gdbindex into
mapped_symtab::minimize, this code relates to minimisation, so this
seems like a good home for it.
Make the n_elements, data, and m_string_obstack member variables of
mapped_symtab private. Provide a new obstack() member function to
provide access to the obstack when needed, and also add member
functions begin(), end(), cbegin(), and cend() so that the
mapped_symtab class can be treated like a contained and iterated
over.
I've also taken this opportunity to split out the logic for whether
the hash table (m_data) needs expanding, this is the new function
hash_needs_expanding. This will be useful in a later commit.
There should be no user visible changes after this commit.
Approved-By: Tom Tromey <tom@tromey.com>
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -187,86 +187,135 @@ struct mapped_symtab
{
mapped_symtab ()
{
- data.resize (1024);
+ m_data.resize (1024);
}
- /* Minimize each entry in the symbol table, removing duplicates. */
+ /* If there are no elements in the symbol table, then reduce the table
+ size to zero. Otherwise call symtab_index_entry::minimize each entry
+ in the symbol table. */
+
void minimize ()
{
- for (symtab_index_entry &item : data)
+ if (m_element_count == 0)
+ m_data.resize (0);
+
+ for (symtab_index_entry &item : m_data)
item.minimize ();
}
- offset_type n_elements = 0;
- std::vector<symtab_index_entry> data;
+ /* Add an entry to SYMTAB. NAME is the name of the symbol. CU_INDEX is
+ the index of the CU in which the symbol appears. IS_STATIC is one if
+ the symbol is static, otherwise zero (global). */
+
+ void add_index_entry (const char *name, int is_static,
+ gdb_index_symbol_kind kind, offset_type cu_index);
+
+ /* Access the obstack. */
+ struct obstack *obstack ()
+ { return &m_string_obstack; }
+
+private:
+
+ /* Find a slot in SYMTAB for the symbol NAME. Returns a reference to
+ the slot.
+
+ Function is used only during write_hash_table so no index format
+ backward compatibility is needed. */
+
+ symtab_index_entry &find_slot (const char *name);
+
+ /* Expand SYMTAB's hash table. */
+
+ void hash_expand ();
+
+ /* Return true if the hash table in data needs to grow. */
+
+ bool hash_needs_expanding () const
+ { return 4 * m_element_count / 3 >= m_data.size (); }
+
+ /* A vector that is used as a hash table. */
+ std::vector<symtab_index_entry> m_data;
+
+ /* The number of elements stored in the m_data hash. */
+ offset_type m_element_count = 0;
/* Temporary storage for names. */
auto_obstack m_string_obstack;
-};
-/* Find a slot in SYMTAB for the symbol NAME. Returns a reference to
- the slot.
+public:
+ using iterator = decltype (m_data)::iterator;
+ using const_iterator = decltype (m_data)::const_iterator;
- Function is used only during write_hash_table so no index format backward
- compatibility is needed. */
+ iterator begin ()
+ { return m_data.begin (); }
-static symtab_index_entry &
-find_slot (struct mapped_symtab *symtab, const char *name)
+ iterator end ()
+ { return m_data.end (); }
+
+ const_iterator cbegin ()
+ { return m_data.cbegin (); }
+
+ const_iterator cend ()
+ { return m_data.cend (); }
+};
+
+/* See class definition. */
+
+symtab_index_entry &
+mapped_symtab::find_slot (const char *name)
{
offset_type index, step, hash = mapped_index_string_hash (INT_MAX, name);
- index = hash & (symtab->data.size () - 1);
- step = ((hash * 17) & (symtab->data.size () - 1)) | 1;
+ index = hash & (m_data.size () - 1);
+ step = ((hash * 17) & (m_data.size () - 1)) | 1;
for (;;)
{
- if (symtab->data[index].name == NULL
- || strcmp (name, symtab->data[index].name) == 0)
- return symtab->data[index];
- index = (index + step) & (symtab->data.size () - 1);
+ if (m_data[index].name == NULL
+ || strcmp (name, m_data[index].name) == 0)
+ return m_data[index];
+ index = (index + step) & (m_data.size () - 1);
}
}
-/* Expand SYMTAB's hash table. */
+/* See class definition. */
-static void
-hash_expand (struct mapped_symtab *symtab)
+void
+mapped_symtab::hash_expand ()
{
- auto old_entries = std::move (symtab->data);
+ auto old_entries = std::move (m_data);
- symtab->data.clear ();
- symtab->data.resize (old_entries.size () * 2);
+ gdb_assert (m_data.size () == 0);
+ m_data.resize (old_entries.size () * 2);
for (auto &it : old_entries)
if (it.name != NULL)
{
- auto &ref = find_slot (symtab, it.name);
+ auto &ref = this->find_slot (it.name);
ref = std::move (it);
}
}
-/* Add an entry to SYMTAB. NAME is the name of the symbol.
- CU_INDEX is the index of the CU in which the symbol appears.
- IS_STATIC is one if the symbol is static, otherwise zero (global). */
+/* See class definition. */
-static void
-add_index_entry (struct mapped_symtab *symtab, const char *name,
- int is_static, gdb_index_symbol_kind kind,
- offset_type cu_index)
+void
+mapped_symtab::add_index_entry (const char *name, int is_static,
+ gdb_index_symbol_kind kind,
+ offset_type cu_index)
{
- symtab_index_entry *slot = &find_slot (symtab, name);
+ symtab_index_entry *slot = &this->find_slot (name);
if (slot->name == NULL)
{
/* This is a new element in the hash table. */
- ++symtab->n_elements;
+ ++this->m_element_count;
/* We might need to grow the hash table. */
- if (4 * symtab->n_elements / 3 >= symtab->data.size ())
+ if (this->hash_needs_expanding ())
{
- hash_expand (symtab);
+ this->hash_expand ();
/* This element will have a different slot in the new table. */
- slot = &find_slot (symtab, name);
+ slot = &this->find_slot (name);
/* But it should still be a new element in the hash table. */
gdb_assert (slot->name == nullptr);
@@ -387,7 +436,7 @@ write_hash_table (mapped_symtab *symtab, data_buf &output, data_buf &cpool)
/* We add all the index vectors to the constant pool first, to
ensure alignment is ok. */
- for (symtab_index_entry &entry : symtab->data)
+ for (symtab_index_entry &entry : *symtab)
{
if (entry.name == NULL)
continue;
@@ -416,7 +465,7 @@ write_hash_table (mapped_symtab *symtab, data_buf &output, data_buf &cpool)
/* Now write out the hash table. */
std::unordered_map<c_str_view, offset_type, c_str_view_hasher> str_table;
- for (const auto &entry : symtab->data)
+ for (const auto &entry : *symtab)
{
offset_type str_off, vec_off;
@@ -1151,7 +1200,7 @@ write_cooked_index (cooked_index *table,
const auto it = cu_index_htab.find (entry->per_cu);
gdb_assert (it != cu_index_htab.cend ());
- const char *name = entry->full_name (&symtab->m_string_obstack);
+ const char *name = entry->full_name (symtab->obstack ());
if (entry->per_cu->lang () == language_ada)
{
@@ -1159,7 +1208,7 @@ write_cooked_index (cooked_index *table,
gdb, it has to use the encoded name, with any
suffixes stripped. */
std::string encoded = ada_encode (name, false);
- name = obstack_strdup (&symtab->m_string_obstack,
+ name = obstack_strdup (symtab->obstack (),
encoded.c_str ());
}
else if (entry->per_cu->lang () == language_cplus
@@ -1191,8 +1240,8 @@ write_cooked_index (cooked_index *table,
else
kind = GDB_INDEX_SYMBOL_KIND_TYPE;
- add_index_entry (symtab, name, (entry->flags & IS_STATIC) != 0,
- kind, it->second);
+ symtab->add_index_entry (name, (entry->flags & IS_STATIC) != 0,
+ kind, it->second);
}
}
@@ -1267,8 +1316,6 @@ write_gdbindex (dwarf2_per_bfd *per_bfd, cooked_index *table,
symtab.minimize ();
data_buf symtab_vec, constant_pool;
- if (symtab.n_elements == 0)
- symtab.data.resize (0);
write_hash_table (&symtab, symtab_vec, constant_pool);

View File

@ -0,0 +1,101 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andrew Burgess <aburgess@redhat.com>
Date: Mon, 27 Nov 2023 13:19:39 +0000
Subject: gdb-rhbz-2232086-generate-dwarf-5-index-consistently.patch
;; Back-port upstream commit 3644f41dc80 as part of a fix for
;; non-deterministic gdb-index generation (RH BZ 2232086).
gdb: generate dwarf-5 index identically as worker-thread count changes
Similar to the previous commit, this commit ensures that the dwarf-5
index files are generated identically as the number of worker-threads
changes.
Building the dwarf-5 index makes use of a closed hash table, the
bucket_hash local within debug_names::build(). Entries are added to
bucket_hash from m_name_to_value_set, which, in turn, is populated
by calls to debug_names::insert() in write_debug_names. The insert
calls are ordered based on the entries within the cooked_index, and
the ordering within cooked_index depends on the number of worker
threads that GDB is using.
My proposal is to sort each chain within the bucket_hash closed hash
table prior to using this to build the dwarf-5 index.
The buckets within bucket_hash will always have the same ordering (for
a given GDB build with a given executable), and by sorting the chains
within each bucket, we can be sure that GDB will see each entry in a
deterministic order.
I've extended the index creation test to cover this case.
Approved-By: Tom Tromey <tom@tromey.com>
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -452,6 +452,11 @@ class c_str_view
return strcmp (m_cstr, other.m_cstr) == 0;
}
+ bool operator< (const c_str_view &other) const
+ {
+ return strcmp (m_cstr, other.m_cstr) < 0;
+ }
+
/* Return the underlying C string. Note, the returned string is
only a reference with lifetime of this object. */
const char *c_str () const
@@ -771,10 +776,18 @@ class debug_names
}
for (size_t bucket_ix = 0; bucket_ix < bucket_hash.size (); ++bucket_ix)
{
- const std::forward_list<hash_it_pair> &hashitlist
- = bucket_hash[bucket_ix];
+ std::forward_list<hash_it_pair> &hashitlist = bucket_hash[bucket_ix];
if (hashitlist.empty ())
continue;
+
+ /* Sort the items within each bucket. This ensures that the
+ generated index files will be the same no matter the order in
+ which symbols were added into the index. */
+ hashitlist.sort ([] (const hash_it_pair &a, const hash_it_pair &b)
+ {
+ return a.it->first < b.it->first;
+ });
+
uint32_t &bucket_slot = m_bucket_table[bucket_ix];
/* The hashes array is indexed starting at 1. */
store_unsigned_integer (reinterpret_cast<gdb_byte *> (&bucket_slot),
diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp
--- a/gdb/testsuite/gdb.gdb/index-file.exp
+++ b/gdb/testsuite/gdb.gdb/index-file.exp
@@ -47,6 +47,9 @@ remote_exec host "mkdir -p ${dir1}"
with_timeout_factor $timeout_factor {
gdb_test_no_output "save gdb-index $dir1" \
"create gdb-index file"
+
+ gdb_test_no_output "save gdb-index -dwarf-5 $dir1" \
+ "create dwarf-index files"
}
# Close GDB.
@@ -143,13 +146,16 @@ if { $worker_threads > 1 } {
with_timeout_factor $timeout_factor {
gdb_test_no_output "save gdb-index $dir2" \
"create second gdb-index file"
+
+ gdb_test_no_output "save gdb-index -dwarf-5 $dir2" \
+ "create second dwarf-index files"
}
# Close GDB.
gdb_exit
# Now check that the index files are identical.
- foreach suffix { gdb-index } {
+ foreach suffix { gdb-index debug_names debug_str } {
set result \
[remote_exec host \
"cmp -s \"$dir1/${index_filename_base}.${suffix}\" \"$dir2/${index_filename_base}.${suffix}\""]

View File

@ -0,0 +1,230 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andrew Burgess <aburgess@redhat.com>
Date: Fri, 24 Nov 2023 12:04:36 +0000
Subject: gdb-rhbz-2232086-generate-gdb-index-consistently.patch
;; Back-port upstream commit aff250145af as part of a fix for
;; non-deterministic gdb-index generation (RH BZ 2232086).
gdb: generate gdb-index identically regardless of work thread count
It was observed that changing the number of worker threads that GDB
uses (maintenance set worker-threads NUM) would have an impact on the
layout of the generated gdb-index.
The cause seems to be how the CU are distributed between threads, and
then symbols that appear in multiple CU can be encountered earlier or
later depending on whether a particular CU moves between threads.
I certainly found this behaviour was reproducible when generating an
index for GDB itself, like:
gdb -q -nx -nh -batch \
-eiex 'maint set worker-threads NUM' \
-ex 'save gdb-index /tmp/'
And then setting different values for NUM will change the generated
index.
Now, the question is: does this matter?
I would like to suggest that yes, this does matter. At Red Hat we
generate a gdb-index as part of the build process, and we would
ideally like to have reproducible builds: for the same source,
compiled with the same tool-chain, we should get the exact same output
binary. And we do .... except for the index.
Now we could simply force GDB to only use a single worker thread when
we build the index, but, I don't think the idea of reproducible builds
is that strange, so I think we should ensure that our generated
indexes are always reproducible.
To achieve this, I propose that we add an extra step when building the
gdb-index file. After constructing the initial symbol hash table
contents, we will pull all the symbols out of the hash, sort them,
then re-insert them in sorted order. This will ensure that the
structure of the generated hash will remain consistent (given the same
set of symbols).
I've extended the existing index-file test to check that the generated
index doesn't change if we adjust the number of worker threads used.
Given that this test is already rather slow, I've only made one change
to the worker-thread count. Maybe this test should be changed to use
a smaller binary, which is quicker to load, and for which we could
then try many different worker thread counts.
Approved-By: Tom Tromey <tom@tromey.com>
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -210,6 +210,13 @@ struct mapped_symtab
void add_index_entry (const char *name, int is_static,
gdb_index_symbol_kind kind, offset_type cu_index);
+ /* When entries are originally added into the data hash the order will
+ vary based on the number of worker threads GDB is configured to use.
+ This function will rebuild the hash such that the final layout will be
+ deterministic regardless of the number of worker threads used. */
+
+ void sort ();
+
/* Access the obstack. */
struct obstack *obstack ()
{ return &m_string_obstack; }
@@ -296,6 +303,65 @@ mapped_symtab::hash_expand ()
}
}
+/* See mapped_symtab class declaration. */
+
+void mapped_symtab::sort ()
+{
+ /* Move contents out of this->data vector. */
+ std::vector<symtab_index_entry> original_data = std::move (m_data);
+
+ /* Restore the size of m_data, this will avoid having to expand the hash
+ table (and rehash all elements) when we reinsert after sorting.
+ However, we do reset the element count, this allows for some sanity
+ checking asserts during the reinsert phase. */
+ gdb_assert (m_data.size () == 0);
+ m_data.resize (original_data.size ());
+ m_element_count = 0;
+
+ /* Remove empty entries from ORIGINAL_DATA, this makes sorting quicker. */
+ auto it = std::remove_if (original_data.begin (), original_data.end (),
+ [] (const symtab_index_entry &entry) -> bool
+ {
+ return entry.name == nullptr;
+ });
+ original_data.erase (it, original_data.end ());
+
+ /* Sort the existing contents. */
+ std::sort (original_data.begin (), original_data.end (),
+ [] (const symtab_index_entry &a,
+ const symtab_index_entry &b) -> bool
+ {
+ /* Return true if A is before B. */
+ gdb_assert (a.name != nullptr);
+ gdb_assert (b.name != nullptr);
+
+ return strcmp (a.name, b.name) < 0;
+ });
+
+ /* Re-insert each item from the sorted list. */
+ for (auto &entry : original_data)
+ {
+ /* We know that ORIGINAL_DATA contains no duplicates, this data was
+ taken from a hash table that de-duplicated entries for us, so
+ count this as a new item.
+
+ As we retained the original size of m_data (see above) then we
+ should never need to grow m_data_ during this re-insertion phase,
+ assert that now. */
+ ++m_element_count;
+ gdb_assert (!this->hash_needs_expanding ());
+
+ /* Lookup a slot. */
+ symtab_index_entry &slot = this->find_slot (entry.name);
+
+ /* As discussed above, we should not find duplicates. */
+ gdb_assert (slot.name == nullptr);
+
+ /* Move this item into the slot we found. */
+ slot = std::move (entry);
+ }
+}
+
/* See class definition. */
void
@@ -1311,6 +1377,9 @@ write_gdbindex (dwarf2_per_bfd *per_bfd, cooked_index *table,
for (auto map : table->get_addrmaps ())
write_address_map (map, addr_vec, cu_index_htab);
+ /* Ensure symbol hash is built domestically. */
+ symtab.sort ();
+
/* Now that we've processed all symbols we can shrink their cu_indices
lists. */
symtab.minimize ();
diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp
--- a/gdb/testsuite/gdb.gdb/index-file.exp
+++ b/gdb/testsuite/gdb.gdb/index-file.exp
@@ -38,6 +38,9 @@ with_timeout_factor $timeout_factor {
clean_restart $filename
}
+# Record how many worker threads GDB is using.
+set worker_threads [gdb_get_worker_threads]
+
# Generate an index file.
set dir1 [standard_output_file "index_1"]
remote_exec host "mkdir -p ${dir1}"
@@ -116,3 +119,41 @@ proc check_symbol_table_usage { filename } {
set index_filename_base [file tail $filename]
check_symbol_table_usage "$dir1/${index_filename_base}.gdb-index"
+
+# If GDB is using more than 1 worker thread then reduce the number of
+# worker threads, regenerate the index, and check that we get the same
+# index file back. At one point the layout of the index would vary
+# based on the number of worker threads used.
+if { $worker_threads > 1 } {
+ # Start GDB, but don't load a file yet.
+ clean_restart
+
+ # Adjust the number of threads to use.
+ set reduced_threads [expr $worker_threads / 2]
+ gdb_test_no_output "maint set worker-threads $reduced_threads"
+
+ with_timeout_factor $timeout_factor {
+ # Now load the test binary.
+ gdb_file_cmd $filename
+ }
+
+ # Generate an index file.
+ set dir2 [standard_output_file "index_2"]
+ remote_exec host "mkdir -p ${dir2}"
+ with_timeout_factor $timeout_factor {
+ gdb_test_no_output "save gdb-index $dir2" \
+ "create second gdb-index file"
+ }
+
+ # Close GDB.
+ gdb_exit
+
+ # Now check that the index files are identical.
+ foreach suffix { gdb-index } {
+ set result \
+ [remote_exec host \
+ "cmp -s \"$dir1/${index_filename_base}.${suffix}\" \"$dir2/${index_filename_base}.${suffix}\""]
+ gdb_assert { [lindex $result 0] == 0 } \
+ "$suffix files are identical"
+ }
+}
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
@@ -10033,6 +10033,21 @@ proc is_target_non_stop { {testname ""} } {
return $is_non_stop
}
+# Return the number of worker threads that GDB is currently using.
+
+proc gdb_get_worker_threads { {testname ""} } {
+ set worker_threads "UNKNOWN"
+ gdb_test_multiple "maintenance show worker-threads" $testname {
+ -wrap -re "The number of worker threads GDB can use is unlimited \\(currently ($::decimal)\\)\\." {
+ set worker_threads $expect_out(1,string)
+ }
+ -wrap -re "The number of worker threads GDB can use is ($::decimal)\\." {
+ set worker_threads $expect_out(1,string)
+ }
+ }
+ return $worker_threads
+}
+
# Check if the compiler emits epilogue information associated
# with the closing brace or with the last statement line.
#

View File

@ -0,0 +1,222 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andrew Burgess <aburgess@redhat.com>
Date: Fri, 24 Nov 2023 11:50:35 +0000
Subject: gdb-rhbz-2232086-reduce-size-of-gdb-index.patch
;; Back-port upstream commit aa19bc1d259 as part of a fix for
;; non-deterministic gdb-index generation (RH BZ 2232086).
gdb: reduce size of generated gdb-index file
I noticed in passing that out algorithm for generating the gdb-index
file is incorrect. When building the hash table in add_index_entry we
count every incoming entry rehash when the number of entries gets too
large. However, some of the incoming entries will be duplicates,
which don't actually result in new items being added to the hash
table.
As a result, we grow the gdb-index hash table far too often.
With an unmodified GDB, generating a gdb-index for GDB, I see a file
size of 90M, with a hash usage (in the generated index file) of just
2.6%.
With a patched GDB, generating a gdb-index for the _same_ GDB binary,
I now see a gdb-index file size of 30M, with a hash usage of 41.9%.
This is a 67% reduction in gdb-index file size.
Obviously, not every gdb-index file is going to see such big savings,
however, the larger a program, and the more symbols that are
duplicated between compilation units, the more GDB would over count,
and so, over-grow the index.
The gdb-index hash table we create has a minimum size of 1024, and
then we grow the hash when it is 75% full, doubling the hash table at
that time. Given this, then we expect that either:
a. The hash table is size 1024, and less than 75% full, or
b. The hash table is between 37.5% and 75% full.
I've include a test that checks some of these constraints -- I've not
bothered to check the upper limit, and over full hash table isn't
really a problem here, but if the fill percentage is less than 37.5%
then this indicates that we've done something wrong (obviously, I also
check for the 1024 minimum size).
Approved-By: Tom Tromey <tom@tromey.com>
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -254,20 +254,29 @@ add_index_entry (struct mapped_symtab *symtab, const char *name,
int is_static, gdb_index_symbol_kind kind,
offset_type cu_index)
{
- offset_type cu_index_and_attrs;
+ symtab_index_entry *slot = &find_slot (symtab, name);
+ if (slot->name == NULL)
+ {
+ /* This is a new element in the hash table. */
+ ++symtab->n_elements;
- ++symtab->n_elements;
- if (4 * symtab->n_elements / 3 >= symtab->data.size ())
- hash_expand (symtab);
+ /* We might need to grow the hash table. */
+ if (4 * symtab->n_elements / 3 >= symtab->data.size ())
+ {
+ hash_expand (symtab);
- symtab_index_entry &slot = find_slot (symtab, name);
- if (slot.name == NULL)
- {
- slot.name = name;
+ /* This element will have a different slot in the new table. */
+ slot = &find_slot (symtab, name);
+
+ /* But it should still be a new element in the hash table. */
+ gdb_assert (slot->name == nullptr);
+ }
+
+ slot->name = name;
/* index_offset is set later. */
}
- cu_index_and_attrs = 0;
+ offset_type cu_index_and_attrs = 0;
DW2_GDB_INDEX_CU_SET_VALUE (cu_index_and_attrs, cu_index);
DW2_GDB_INDEX_SYMBOL_STATIC_SET_VALUE (cu_index_and_attrs, is_static);
DW2_GDB_INDEX_SYMBOL_KIND_SET_VALUE (cu_index_and_attrs, kind);
@@ -279,7 +288,7 @@ add_index_entry (struct mapped_symtab *symtab, const char *name,
the last entry pushed), but a symbol could have multiple kinds in one CU.
To keep things simple we don't worry about the duplication here and
sort and uniquify the list after we've processed all symbols. */
- slot.cu_indices.push_back (cu_index_and_attrs);
+ slot->cu_indices.push_back (cu_index_and_attrs);
}
/* See symtab_index_entry. */
diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.gdb/index-file.exp
@@ -0,0 +1,118 @@
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Load the GDB executable, and then 'save gdb-index', and make some
+# checks of the generated index file.
+
+load_lib selftest-support.exp
+
+# Can't save an index with readnow.
+if {[readnow]} {
+ untested "cannot create an index when readnow is in use"
+ return -1
+}
+
+# A multiplier used to ensure slow tasks are less likely to timeout.
+set timeout_factor 20
+
+set filename [selftest_prepare]
+if { $filename eq "" } {
+ unsupported "${gdb_test_file_name}.exp"
+ return -1
+}
+
+with_timeout_factor $timeout_factor {
+ # Start GDB, load FILENAME.
+ clean_restart $filename
+}
+
+# Generate an index file.
+set dir1 [standard_output_file "index_1"]
+remote_exec host "mkdir -p ${dir1}"
+with_timeout_factor $timeout_factor {
+ gdb_test_no_output "save gdb-index $dir1" \
+ "create gdb-index file"
+}
+
+# Close GDB.
+gdb_exit
+
+# Validate that the index-file FILENAME has made efficient use of its
+# symbol hash table. Calculate the number of symbols in the hash
+# table and the total hash table size. The hash table starts with
+# 1024 entries, and then doubles each time it is filled to 75%. At
+# 75% filled, doubling the size takes it to 37.5% filled.
+#
+# Thus, the hash table is correctly filled if:
+# 1. Its size is 1024 (i.e. it has not yet had its first doubling), or
+# 2. Its filled percentage is over 37%
+#
+# We could check that it is not over filled, but I don't as that's not
+# really an issue. But we did once have a bug where the table was
+# doubled incorrectly, in which case we'd see a filled percentage of
+# around 2% in some cases, which is a huge waste of disk space.
+proc check_symbol_table_usage { filename } {
+ # Open the file in binary mode and read-only mode.
+ set fp [open $filename rb]
+
+ # Configure the channel to use binary translation.
+ fconfigure $fp -translation binary
+
+ # Read the first 8 bytes of the file, which contain the header of
+ # the index section.
+ set header [read $fp [expr 7 * 4]]
+
+ # Scan the header to get the version, the CU list offset, and the
+ # types CU list offset.
+ binary scan $header iiiiii version \
+ _ _ _ symbol_table_offset shortcut_offset
+
+ # The length of the symbol hash table (in entries).
+ set len [expr ($shortcut_offset - $symbol_table_offset) / 8]
+
+ # Now walk the hash table and count how many entries are in use.
+ set offset $symbol_table_offset
+ set count 0
+ while { $offset < $shortcut_offset } {
+ seek $fp $offset
+ set entry [read $fp 8]
+ binary scan $entry ii name_ptr flags
+ if { $name_ptr != 0 } {
+ incr count
+ }
+
+ incr offset 8
+ }
+
+ # Close the file.
+ close $fp
+
+ # Calculate how full the cache is.
+ set pct [expr (100 * double($count)) / $len]
+
+ # Write our results out to the gdb.log.
+ verbose -log "Hash table size: $len"
+ verbose -log "Hash table entries: $count"
+ verbose -log "Percentage usage: $pct%"
+
+ # The minimum fill percentage is actually 37.5%, but we give TCL a
+ # little flexibility in case the FP maths give a result a little
+ # off.
+ gdb_assert { $len == 1024 || $pct > 37 } \
+ "symbol hash table usage"
+}
+
+set index_filename_base [file tail $filename]
+check_symbol_table_usage "$dir1/${index_filename_base}.gdb-index"

View File

@ -1,135 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <http://www.gnu.org/licenses/>. */
+
+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 <http://www.gnu.org/licenses/>. */
+
+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 <http://www.gnu.org/licenses/>.
+
+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 .*"

View File

@ -1,176 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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 <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <assert.h>
+
+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 <http://www.gnu.org/licenses/>.
+
+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 <http://www.gnu.org/licenses/>.
+
+# 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()

View File

@ -1,81 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
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<basic_string> 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<string>"
+
+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())

View File

@ -1,454 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-rhbz1398387-tab-crash-test.patch
;; New testcase for: Fix <tab>-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=_____________________________________
+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
+`
+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 <http://www.gnu.org/licenses/>.
+
+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"

View File

@ -1,81 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
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 <http://www.gnu.org/licenses/>.
+
+#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<W1R=&%B`"YS:'-T<G1A8@`N=&5X=``N9&%T80`N8G-S````````````
+M`````````````````````````````````P```0``````````````````````
+M`````P```@```````````````````````````P```P``````````````````
+M```````!$````0``````````````````````;&]A9%]G=6%R9&5D````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````!L````!``````````8`````````````````
+M``!``````````$`````````````````````$```````````````A`````0``
+M```````#````````````````````@```````````````````````````````
+M!```````````````)P````@``````````P```````````````````(``````
+M``````````````````````````0``````````````!$````#````````````
+M``````````````````"``````````"P````````````````````!````````
+M```````!`````@``````````````````````````````L`````````!X````
+M!@````0`````````"``````````8````"0````,`````````````````````
+H`````````2@`````````#@````````````````````$`````````````
+`
+end

View File

@ -1,298 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Carl Love <cel@us.ibm.com>
Date: Thu, 29 Apr 2021 17:19:13 -0500
Subject: gdb-rhbz1870017-p10-plt-prologue-skipping.patch
;; Backport "Add Power 10 PLT instruction patterns"
;; (Carl Love, RHBZ 1870017)
gdb/ChangeLog:
2021-06-07 Carl Love <cel@us.ibm.com>
* ppc-tdep.h (ppc_insn_prefix_dform): Declare.
* ppc64-tdep.c(insn_md, insn_x, insn_xo): New macros.
(ppc64_plt_pcrel_entry_point, ppc64_pcrel_linkage1_target,
ppc64_pcrel_linkage2_target): New functions.
(ppc64_standard_linkage9, ppc64_standard_linkage10,
ppc64_standard_linkage11, ppc64_standard_linkage12): New ppc
instruction patterns.
(ppc64_standard_linkage9, ppc64_standard_linkage10,
ppc64_standard_linkage11, ppc64_standard_linkage12): New variables
in define MAX expression.
(ppc64_skip_trampoline_code_1): Handle ppc64_standard_linkage9,
ppc64_standard_linkage10, ppc64_standard_linkage11,
ppc64_standard_linkage12.
* (ppc_insn_prefix_dform): New function.
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -426,6 +426,8 @@ extern int ppc_insns_match_pattern (struct frame_info *frame, CORE_ADDR pc,
extern CORE_ADDR ppc_insn_d_field (unsigned int insn);
extern CORE_ADDR ppc_insn_ds_field (unsigned int insn);
+extern CORE_ADDR ppc_insn_prefix_dform (unsigned int insn1,
+ unsigned int insn2);
extern int ppc_process_record (struct gdbarch *gdbarch,
struct regcache *regcache, CORE_ADDR addr);
diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c
--- a/gdb/ppc64-tdep.c
+++ b/gdb/ppc64-tdep.c
@@ -49,6 +49,38 @@
| (((unsigned (spr)) & 0x3e0) << 6) \
| (((unsigned (xo)) & 0x3ff) << 1))
+#define prefix(a, b, R, do) \
+ (((0x1) << 26) \
+ | (((unsigned (a)) & 0x3) << 24) \
+ | (((unsigned (b)) & 0x1) << 23) \
+ | (((unsigned (R)) & 0x1) << 20) \
+ | ((unsigned (do)) & 0x3ffff))
+
+#define insn_md(opcd, ra, rs, sh, me, rc) \
+ ((((unsigned (opcd)) & 0x3f) << 26) \
+ | (((unsigned (rs)) & 0x1f) << 21) \
+ | (((unsigned (ra)) & 0x1f) << 16) \
+ | (((unsigned (sh)) & 0x3e) << 11) \
+ | (((unsigned (me)) & 0x3f) << 25) \
+ | (((unsigned (sh)) & 0x1) << 1) \
+ | ((unsigned (rc)) & 0x1))
+
+#define insn_x(opcd, rt, ra, rb, opc2) \
+ ((((unsigned (opcd)) & 0x3f) << 26) \
+ | (((unsigned (rt)) & 0x1f) << 21) \
+ | (((unsigned (ra)) & 0x1f) << 16) \
+ | (((unsigned (rb)) & 0x3e) << 11) \
+ | (((unsigned (opc2)) & 0x3FF) << 1))
+
+#define insn_xo(opcd, rt, ra, rb, oe, rc, opc2) \
+ ((((unsigned (opcd)) & 0x3f) << 26) \
+ | (((unsigned (rt)) & 0x1f) << 21) \
+ | (((unsigned (ra)) & 0x1f) << 16) \
+ | (((unsigned (rb)) & 0x3e) << 11) \
+ | (((unsigned (oe)) & 0x1) << 10) \
+ | (((unsigned (opc2)) & 0x1FF) << 1) \
+ | (((unsigned (rc)))))
+
/* PLT_OFF is the TOC-relative offset of a 64-bit PowerPC PLT entry.
Return the function's entry point. */
@@ -75,6 +107,18 @@ ppc64_plt_entry_point (struct frame_info *frame, CORE_ADDR plt_off)
return read_memory_unsigned_integer (tocp + plt_off, 8, byte_order);
}
+static CORE_ADDR
+ppc64_plt_pcrel_entry_point (struct frame_info *frame, CORE_ADDR plt_off,
+ CORE_ADDR pc)
+{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
+ /* Execution direction doesn't matter, entry is pc + plt_off either way.
+ The first word of the PLT entry is the function entry point. */
+ return read_memory_unsigned_integer (pc + plt_off, 8, byte_order);
+}
+
/* Patterns for the standard linkage functions. These are built by
build_plt_stub in bfd/elf64-ppc.c. */
@@ -342,6 +386,110 @@ static const struct ppc_insn_pattern ppc64_standard_linkage8[] =
{ 0, 0, 0 }
};
+/* Power 10 ELFv2 PLT call stubs */
+static const struct ppc_insn_pattern ppc64_standard_linkage9[] =
+ {
+ /* std %r2,0+40(%r1) <optional> */
+ { insn_ds (-1, -1, -1, 0, 1), insn_ds (62, 2, 1, 40, 0), 1 },
+
+ /* pld r12, <any> */
+ { prefix (-1, -1, 1, 0), prefix (0, 0, 1, 0), 0 },
+ { insn_d (-1, -1, -1, 0), insn_d (57, 12, 0, 0), 0 },
+
+ /* mtctr r12 */
+ { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 },
+
+ /* bctr */
+ { (unsigned) -1, 0x4e800420, 0 },
+
+ { 0, 0, 0 }
+ };
+
+static const struct ppc_insn_pattern ppc64_standard_linkage10[] =
+ {
+ /* std %r2,0+40(%r1) <optional> */
+ { insn_ds (-1, -1, -1, 0, 1), insn_ds (62, 2, 1, 40, 0), 1 },
+
+ /* paddi r12,<any> */
+ { prefix (-1, -1, 1, 0), prefix (2, 0, 1, 0), 0 },
+ { insn_d (-1, -1, -1, 0), insn_d (14, 12, 0, 0), 0 },
+
+ /* mtctr r12 <optional> */
+ { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 },
+
+ /* bctr */
+ { (unsigned) -1, 0x4e800420, 0 },
+
+ { 0, 0, 0 }
+ };
+
+static const struct ppc_insn_pattern ppc64_standard_linkage11[] =
+ {
+ /* std %r2,0+40(%r1) <optional> */
+ { insn_ds (-1, -1, -1, 0, 1), insn_ds (62, 2, 1, 40, 0), 1 },
+
+ /* li %r11,0 <optional> */
+ { insn_d (-1, -1, -1, 0), insn_d (14, 11, 0, 0), 1 },
+
+ /* sldi %r11,%r11,34 <eq to rldicr rx,ry,n, 63-n> <optional> */
+ { insn_md (-1, -1, -1, 0, 0, 1), insn_md (30, 11, 11, 34, 63-34, 0), 1 },
+
+ /* paddi r12, <any> */
+ { prefix (-1, -1, 1, 0), prefix (2, 0, 1, 0), 0 },
+ { insn_d (-1, -1, -1, 0), insn_d (14, 12, 0, 0), 0 },
+
+ /* ldx %r12,%r11,%r12 <optional> */
+ { (unsigned) -1, insn_x (31, 12, 11, 12, 21), 1 },
+
+ /* add %r12,%r11,%r12 <optional> */
+ { (unsigned) -1, insn_xo (31, 12, 11, 12, 0, 0, 40), 1 },
+
+ /* mtctr r12 */
+ { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 },
+
+ /* bctr */ // 13, 14, 15, 16
+ { (unsigned) -1, 0x4e800420, 0 },
+
+ { 0, 0, 0 }
+ };
+
+static const struct ppc_insn_pattern ppc64_standard_linkage12[] =
+ {
+ /* std %r2,0+40(%r1) <optional> */
+ { insn_ds (-1, -1, -1, 0, 1), insn_ds (62, 2, 1, 40, 0), 1 },
+
+ /* lis %r11,xxx@ha <equivalent addis rx, 0, val> */
+ /* addis r12, r2, <any> */
+ { insn_d (-1, -1, -1, 0), insn_d (15, 12, 2, 0), 0 },
+
+ /* ori %r11,%r11,xxx@l */
+ { insn_d (-1, -1, -1, 0), insn_d (24, 11, 11, 0), 0 },
+
+ /* sldi %r11,%r11,34 <optional> */
+ { (unsigned) -1, insn_md (30, 11, 11, 34, 63-34, 0), 1 },
+
+ /*paddi r12,<any> */
+ { prefix (-1, -1, 1, 0), prefix (2, 0, 1, 0), 0 },
+ { insn_d (-1, -1, -1, 0), insn_d (14, 12, 0, 0), 0 },
+
+ /* sldi %r11,%r11,34 <optional> */
+ { (unsigned) -1, insn_md (30, 11, 11, 34, 63-34, 0), 1 },
+
+ /* ldx %r12,%r11,%r12 <optional> */
+ { (unsigned) -1, insn_x (31, 12, 11, 12, 21), 1 },
+
+ /* add %r12,%r11,%r12 <optional> */
+ { (unsigned) -1, insn_xo (31, 12, 11, 12, 0, 0, 40), 1 },
+
+ /* mtctr r12 */
+ { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 },
+
+ /* bctr */ // 17, 18, 19, 20
+ { (unsigned) -1, 0x4e800420, 0 },
+
+ { 0, 0, 0 }
+ };
+
/* When the dynamic linker is doing lazy symbol resolution, the first
call to a function in another object will go like this:
@@ -432,6 +580,29 @@ ppc64_standard_linkage4_target (struct frame_info *frame, unsigned int *insn)
return ppc64_plt_entry_point (frame, plt_off);
}
+static CORE_ADDR
+ppc64_pcrel_linkage1_target (struct frame_info *frame, unsigned int *insn,
+ CORE_ADDR pc)
+{
+ /* insn[0] is for the std instruction. */
+ CORE_ADDR plt_off = ppc_insn_prefix_dform (insn[1], insn[2]);
+
+ return ppc64_plt_pcrel_entry_point (frame, plt_off, pc);
+}
+
+static CORE_ADDR
+ppc64_pcrel_linkage2_target (struct frame_info *frame, unsigned int *insn,
+ CORE_ADDR pc)
+{
+ CORE_ADDR plt_off;
+
+ /* insn[0] is for the std instruction.
+ insn[1] is for the li r11 instruction */
+ plt_off = ppc_insn_prefix_dform (insn[2], insn[3]);
+
+ return ppc64_plt_pcrel_entry_point (frame, plt_off, pc);
+}
+
/* Given that we've begun executing a call trampoline at PC, return
the entry point of the function the trampoline will go to.
@@ -447,10 +618,15 @@ ppc64_skip_trampoline_code_1 (struct frame_info *frame, CORE_ADDR pc)
ARRAY_SIZE (ppc64_standard_linkage2)),
MAX (ARRAY_SIZE (ppc64_standard_linkage3),
ARRAY_SIZE (ppc64_standard_linkage4))),
- MAX (MAX (ARRAY_SIZE (ppc64_standard_linkage5),
+ MAX(MAX (MAX (ARRAY_SIZE (ppc64_standard_linkage5),
ARRAY_SIZE (ppc64_standard_linkage6)),
MAX (ARRAY_SIZE (ppc64_standard_linkage7),
- ARRAY_SIZE (ppc64_standard_linkage8))))
+ ARRAY_SIZE (ppc64_standard_linkage8))),
+ MAX (MAX (ARRAY_SIZE (ppc64_standard_linkage9),
+ ARRAY_SIZE (ppc64_standard_linkage10)),
+ MAX (ARRAY_SIZE (ppc64_standard_linkage11),
+ ARRAY_SIZE (ppc64_standard_linkage12)))))
+
- 1];
CORE_ADDR target;
int scan_limit, i;
@@ -463,7 +639,19 @@ ppc64_skip_trampoline_code_1 (struct frame_info *frame, CORE_ADDR pc)
for (i = 0; i < scan_limit; i++)
{
- if (i < ARRAY_SIZE (ppc64_standard_linkage8) - 1
+ if (i < ARRAY_SIZE (ppc64_standard_linkage12) - 1
+ && ppc_insns_match_pattern (frame, pc, ppc64_standard_linkage12, insns))
+ pc = ppc64_pcrel_linkage1_target (frame, insns, pc);
+ else if (i < ARRAY_SIZE (ppc64_standard_linkage11) - 1
+ && ppc_insns_match_pattern (frame, pc, ppc64_standard_linkage11, insns))
+ pc = ppc64_pcrel_linkage2_target (frame, insns, pc);
+ else if (i < ARRAY_SIZE (ppc64_standard_linkage10) - 1
+ && ppc_insns_match_pattern (frame, pc, ppc64_standard_linkage10, insns))
+ pc = ppc64_pcrel_linkage1_target (frame, insns, pc);
+ else if (i < ARRAY_SIZE (ppc64_standard_linkage9) - 1
+ && ppc_insns_match_pattern (frame, pc, ppc64_standard_linkage9, insns))
+ pc = ppc64_pcrel_linkage1_target (frame, insns, pc);
+ else if (i < ARRAY_SIZE (ppc64_standard_linkage8) - 1
&& ppc_insns_match_pattern (frame, pc, ppc64_standard_linkage8, insns))
pc = ppc64_standard_linkage4_target (frame, insns);
else if (i < ARRAY_SIZE (ppc64_standard_linkage7) - 1
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -7361,6 +7361,14 @@ ppc_insn_ds_field (unsigned int insn)
return ((((CORE_ADDR) insn & 0xfffc) ^ 0x8000) - 0x8000);
}
+CORE_ADDR
+ppc_insn_prefix_dform (unsigned int insn1, unsigned int insn2)
+{
+ /* result is 34-bits */
+ return (CORE_ADDR) ((((insn1 & 0x3ffff) ^ 0x20000) - 0x20000) << 16)
+ | (CORE_ADDR)(insn2 & 0xffff);
+}
+
/* Initialization code. */
void _initialize_rs6000_tdep ();

View File

@ -1,79 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Wed, 5 May 2021 09:11:12 -0700
Subject: gdb-rhbz1870029-powerpc-remove-region-limit-dawr.patch
;; Backport "PowerPC remove 512 bytes region limit if 2nd DAWR is available"
;; (Rogerio Alves, RHBZ 1870029)
commit 539d71e89a21990d9fd15641477e4790129bdb11
Author: Rogerio Alves <rcardoso@linux.ibm.com>
Date: Tue Dec 1 16:53:38 2020 -0300
PowerPC remove 512 bytes region limit if 2nd DAWR is avaliable.
Power 10 introduces the 2nd DAWR (second watchpoint) and also removed
a restriction that limit the watch region to 512 bytes.
2020-11-08 Rogerio A. Cardoso <rcardoso@linux.ibm.com>
/gdb
* ppc-linux-nat.c: (PPC_DEBUG_FEATURE_DATA_BP_ARCH_31): New define.
(region_ok_for_hw_watchpoint): Check if 2nd DAWR is avaliable before
set region.
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
@@ -138,6 +138,11 @@ struct ppc_hw_breakpoint
#define PPC_DEBUG_FEATURE_DATA_BP_DAWR 0x10
#endif /* PPC_DEBUG_FEATURE_DATA_BP_DAWR */
+/* Feature defined on Linux kernel v5.1: Second watchpoint support. */
+#ifndef PPC_DEBUG_FEATURE_DATA_BP_ARCH_31
+#define PPC_DEBUG_FEATURE_DATA_BP_ARCH_31 0x20
+#endif /* PPC_DEBUG_FEATURE_DATA_BP_ARCH_31 */
+
/* The version of the PowerPC HWDEBUG kernel interface that we will use, if
available. */
#define PPC_DEBUG_CURRENT_VERSION 1
@@ -2108,9 +2113,10 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
watchpoints. */
if (m_dreg_interface.hwdebug_p ())
{
- int region_size;
const struct ppc_debug_info &hwdebug_info = (m_dreg_interface
.hwdebug_info ());
+ int region_size = hwdebug_info.data_bp_alignment;
+ int region_align = region_size;
/* Embedded DAC-based processors, like the PowerPC 440 have ranged
watchpoints and can watch any access within an arbitrary memory
@@ -2122,15 +2128,19 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
return 2;
/* Check if the processor provides DAWR interface. */
if (hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_DAWR)
- /* DAWR interface allows to watch up to 512 byte wide ranges which
- can't cross a 512 byte boundary. */
- region_size = 512;
- else
- region_size = hwdebug_info.data_bp_alignment;
+ {
+ /* DAWR interface allows to watch up to 512 byte wide ranges. */
+ region_size = 512;
+ /* DAWR interface allows to watch up to 512 byte wide ranges which
+ can't cross a 512 byte bondary on machines that doesn't have a
+ second DAWR (P9 or less). */
+ if (!(hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_ARCH_31))
+ region_align = 512;
+ }
/* Server processors provide one hardware watchpoint and addr+len should
fall in the watchable region provided by the ptrace interface. */
- if (region_size
- && (addr + len > (addr & ~(region_size - 1)) + region_size))
+ if (region_align
+ && (addr + len > (addr & ~(region_align - 1)) + region_size))
return 0;
}
/* addr+len must fall in the 8 byte watchable region for DABR-based

View File

@ -1,89 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Thu, 6 May 2021 14:12:00 -0400
Subject: gdb-rhbz1870031-p10-prefixed-insn-1of3.patch
;; Backport "displaced stepping across addpcis/lnia"
;; (Will Schmidt, RHBZ 1870031)
commit e3d528d7e6a6b863d30aaecf74adf8c78286f84c
Author: Will Schmidt <will_schmidt@vnet.ibm.com>
Date: Mon Apr 12 13:35:54 2021 -0500
[PATCH, rs6000, v3][PR gdb/27525] displaced stepping across addpcis/lnia.
This addresses PR gdb/27525. The lnia and other variations
of the addpcis instruction write the value of the NIA into a target register.
If we are single-stepping across a breakpoint, the instruction is executed
from a displaced location, and thusly the written value of the PC/NIA
will be incorrect. The changes here will measure the displacement
offset, and adjust the target register value to compensate.
YYYY-MM-DD Will Schmidt <will_schmidt@vnet.ibm.com>
gdb/ChangeLog:
* rs6000-tdep.c (ppc_displaced_step_fixup): Update to handle
the addpcis/lnia instruction.
gdb/testsuite/ChangeLog:
* gdb.arch/powerpc-addpcis.exp: Testcase harness to
exercise single-stepping over subpcis,lnia,addpcis instructions
with displacement.
* gdb.arch/powerpc-addpcis.s: Testcase with stream
of addpcis/lnia/subpcis instructions.
* gdb.arch/powerpc-lnia.exp: Testcase harness to exercise
single-stepping over lnia instructions with displacement.
* gdb.arch/powerpc-lnia.s: Testcase with stream of
lnia instructions.
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -836,6 +836,12 @@ typedef BP_MANIPULATION_ENDIAN (little_breakpoint, big_breakpoint)
#define STHCX_INSTRUCTION 0x7c0005ad
#define STQCX_INSTRUCTION 0x7c00016d
+/* Instruction masks for single-stepping of addpcis/lnia. */
+#define ADDPCIS_INSN 0x4c000004
+#define ADDPCIS_INSN_MASK 0xfc00003e
+#define ADDPCIS_TARGET_REGISTER 0x03F00000
+#define ADDPCIS_INSN_REGSHIFT 21
+
/* Check if insn is one of the Load And Reserve instructions used for atomic
sequences. */
#define IS_LOAD_AND_RESERVE_INSN(insn) ((insn & LOAD_AND_RESERVE_MASK) == LWARX_INSTRUCTION \
@@ -923,8 +929,31 @@ ppc_displaced_step_fixup (struct gdbarch *gdbarch,
paddress (gdbarch, from), paddress (gdbarch, to));
+ /* Handle the addpcis/lnia instruction. */
+ if ((insn & ADDPCIS_INSN_MASK) == ADDPCIS_INSN)
+ {
+ LONGEST displaced_offset;
+ ULONGEST current_val;
+ /* Measure the displacement. */
+ displaced_offset = from - to;
+ /* Identify the target register that was updated by the instruction. */
+ int regnum = (insn & ADDPCIS_TARGET_REGISTER) >> ADDPCIS_INSN_REGSHIFT;
+ /* Read and update the target value. */
+ regcache_cooked_read_unsigned (regs, regnum , &current_val);
+ if (debug_displaced)
+ fprintf_unfiltered (gdb_stdlog,
+ "displaced: {ppc} addpcis target regnum %d was "
+ "0x%lx now 0x%lx",
+ regnum, current_val,
+ current_val + displaced_offset);
+ regcache_cooked_write_unsigned (regs, regnum,
+ current_val + displaced_offset);
+ /* point the PC back at the non-displaced instruction. */
+ regcache_cooked_write_unsigned (regs, gdbarch_pc_regnum (gdbarch),
+ from + offset);
+ }
/* Handle PC-relative branch instructions. */
- if (opcode == B_INSN || opcode == BC_INSN || opcode == BXL_INSN)
+ else if (opcode == B_INSN || opcode == BC_INSN || opcode == BXL_INSN)
{
ULONGEST current_pc;

View File

@ -1,633 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Thu, 6 May 2021 14:53:00 -0400
Subject: gdb-rhbz1870031-p10-prefixed-insn-2of3.patch
;; Backport "gdb-power10-single-step"
;; (Will Schmidt, RHBZ 1870031)
commit c8a379440e0f8bf94ed5730e823c9256e64bf37c
Author: Will Schmidt <will_schmidt@vnet.ibm.com>
Date: Mon Apr 12 14:11:02 2021 -0500
[PATCH] gdb-power10-single-step
Hi,
This is based on a patch originally written by Alan Modra.
Powerpc / Power10 ISA 3.1 adds prefixed instructions, which
are 8 bytes in length. This is in contrast to powerpc previously
always having 4 byte instruction length. This patch implements
changes to allow GDB to better detect prefixed instructions, and
handle single stepping across the 8 byte instructions.
Added #defines to help test for PNOP and prefix instructions.
Update ppc_displaced_step_copy_insn() to handle pnop and prefixed
instructions whem R=0 (non-pc-relative).
Updated ppc_displaced_step_fixup() to properly handle the offset
value matching the current instruction size
Updated the for-loop within ppc_deal_with_atomic_sequence() to
count instructions properly in case we have a mix of 4-byte and
8-byte instructions within the atomic_sequence_length.
Added testcase and harness to exercise pc-relative load/store
instructions with R=0.
2021-04-12 Will Schmidt <will_schmidt@vnet.ibm.com>
gdb/ChangeLog:
* rs6000-tdep.c: Add support for single-stepping of
prefixed instructions.
gdb/testsuite/ChangeLog:
* gdb.arch/powerpc-plxv-nonrel.s: Testcase using
non-relative plxv instructions.
* gdb.arch/powerpc-plxv-nonrel.exp: Testcase harness.
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -814,7 +814,7 @@ typedef BP_MANIPULATION_ENDIAN (little_breakpoint, big_breakpoint)
rs6000_breakpoint;
/* Instruction masks for displaced stepping. */
-#define BRANCH_MASK 0xfc000000
+#define OP_MASK 0xfc000000
#define BP_MASK 0xFC0007FE
#define B_INSN 0x48000000
#define BC_INSN 0x40000000
@@ -842,6 +842,11 @@ typedef BP_MANIPULATION_ENDIAN (little_breakpoint, big_breakpoint)
#define ADDPCIS_TARGET_REGISTER 0x03F00000
#define ADDPCIS_INSN_REGSHIFT 21
+#define PNOP_MASK 0xfff3ffff
+#define PNOP_INSN 0x07000000
+#define R_MASK 0x00100000
+#define R_ZERO 0x00000000
+
/* Check if insn is one of the Load And Reserve instructions used for atomic
sequences. */
#define IS_LOAD_AND_RESERVE_INSN(insn) ((insn & LOAD_AND_RESERVE_MASK) == LWARX_INSTRUCTION \
@@ -873,10 +878,38 @@ ppc_displaced_step_copy_insn (struct gdbarch *gdbarch,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int insn;
- read_memory (from, buf, len);
+ len = target_read (current_inferior()->top_target(), TARGET_OBJECT_MEMORY, NULL,
+ buf, from, len);
+ if ((ssize_t) len < PPC_INSN_SIZE)
+ memory_error (TARGET_XFER_E_IO, from);
insn = extract_signed_integer (buf, PPC_INSN_SIZE, byte_order);
+ /* Check for PNOP and for prefixed instructions with R=0. Those
+ instructions are safe to displace. Prefixed instructions with R=1
+ will read/write data to/from locations relative to the current PC.
+ We would not be able to fixup after an instruction has written data
+ into a displaced location, so decline to displace those instructions. */
+ if ((insn & OP_MASK) == 1 << 26)
+ {
+ if (((insn & PNOP_MASK) != PNOP_INSN)
+ && ((insn & R_MASK) != R_ZERO))
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "displaced: {ppc} Not displacing prefixed "
+ "instruction %08x at %s",
+ insn, paddress (gdbarch, from));
+ return NULL;
+ }
+ }
+ else
+ /* Non-prefixed instructions.. */
+ {
+ /* Set the instruction length to 4 to match the actual instruction
+ length. */
+ len = 4;
+ }
+
/* Assume all atomic sequences start with a Load and Reserve instruction. */
if (IS_LOAD_AND_RESERVE_INSN (insn))
{
@@ -917,11 +950,17 @@ ppc_displaced_step_fixup (struct gdbarch *gdbarch,
ppc_displaced_step_closure *closure = (ppc_displaced_step_closure *) closure_;
ULONGEST insn = extract_unsigned_integer (closure->buf.data (),
PPC_INSN_SIZE, byte_order);
- ULONGEST opcode = 0;
+ ULONGEST opcode;
/* Offset for non PC-relative instructions. */
- LONGEST offset = PPC_INSN_SIZE;
+ LONGEST offset;
- opcode = insn & BRANCH_MASK;
+ opcode = insn & OP_MASK;
+
+ /* Set offset to 8 if this is an 8-byte (prefixed) instruction. */
+ if ((opcode) == 1 << 26)
+ offset = 2 * PPC_INSN_SIZE;
+ else
+ offset = PPC_INSN_SIZE;
if (debug_displaced)
fprintf_unfiltered (gdb_stdlog,
@@ -1058,13 +1097,16 @@ ppc_deal_with_atomic_sequence (struct regcache *regcache)
instructions. */
for (insn_count = 0; insn_count < atomic_sequence_length; ++insn_count)
{
- loc += PPC_INSN_SIZE;
+ if ((insn & OP_MASK) == 1 << 26)
+ loc += 2 * PPC_INSN_SIZE;
+ else
+ loc += PPC_INSN_SIZE;
insn = read_memory_integer (loc, PPC_INSN_SIZE, byte_order);
/* Assume that there is at most one conditional branch in the atomic
sequence. If a conditional branch is found, put a breakpoint in
its destination address. */
- if ((insn & BRANCH_MASK) == BC_INSN)
+ if ((insn & OP_MASK) == BC_INSN)
{
int immediate = ((insn & 0xfffc) ^ 0x8000) - 0x8000;
int absolute = insn & 2;
@@ -7095,7 +7137,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_displaced_step_location (gdbarch,
displaced_step_at_entry_point);
- set_gdbarch_max_insn_length (gdbarch, PPC_INSN_SIZE);
+ set_gdbarch_max_insn_length (gdbarch, 2 * PPC_INSN_SIZE);
/* Hook in ABI-specific overrides, if they have been registered. */
info.target_desc = tdesc;
diff --git a/gdb/testsuite/gdb.arch/powerpc-addpcis.exp b/gdb/testsuite/gdb.arch/powerpc-addpcis.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-addpcis.exp
@@ -0,0 +1,104 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Test to confirm that gdb is properly single stepping over the
+# displaced addpcis instruction.
+# The addpcis instruction and its extended mnemonics lnia and subpcis
+# apply an immediate shifted value (X || 0x0000) to the current PC/NIA
+# value, and store that value into the instructions target register.
+# When the instruction is displaced, it needs special handling.
+
+# lnia Rx == addpcis Rx,0
+# subcis Rx,value == addpcis Rx,-value
+
+if { ![istarget powerpc*-*] } {
+ verbose "Skipping powerpc addpcis test."
+ return
+}
+
+set retval 0
+
+standard_testfile .s
+
+if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
+ {debug quiet}] } {
+ return -1
+}
+
+if ![runto_main] then {
+ return
+}
+
+set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
+set bp1 *$check_pc+4
+set bp2 *$check_pc+12
+set bp3 *$check_pc+16
+gdb_breakpoint $bp1
+gdb_breakpoint $bp2
+gdb_breakpoint $bp3
+
+gdb_test "stepi" "" "set r3 "
+set check_r3 [get_hexadecimal_valueof "\$r3" "default0"]
+gdb_test "stepi" "" "set r4"
+set check_r4 [get_hexadecimal_valueof "\$r4" "default0"]
+gdb_test "stepi" "" "set r5"
+set check_r5 [get_hexadecimal_valueof "\$r5" "default0"]
+gdb_test "stepi" "" "set r6"
+set check_r6 [get_hexadecimal_valueof "\$r6" "default0"]
+gdb_test "stepi" "" "set r7"
+set check_r7 [get_hexadecimal_valueof "\$r7" "default0"]
+gdb_test "stepi" "" "set r8"
+set check_r8 [get_hexadecimal_valueof "\$r8" "default0"]
+gdb_test "stepi" "" "set r9"
+set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
+
+# R6 will contain the reference value. All other
+# instructions in this test will be storing values
+# relative to what is stored in R6.
+
+# subpcis 3,+0x100 # /* set r3 */
+# subpcis 4,+0x10 # /* set r4 */
+# subpcis 5,+0x1 # /* set r5 */
+# lnia 6 # /* set r6 */
+# addpcis 7,+0x1 # /* set r7 */
+# addpcis 8,+0x10 # /* set r8 */
+# addpcis 9,+0x100 # /* set r9 */
+
+if [expr $check_r3 + 0x1000000 != $check_r6 - 0xc ] {
+ fail "unexpected value r3 + 0x1,000,000 != r6 + 0xc ; r3: $check_r3 r6: $check_r6 "
+}
+if [expr $check_r4 + 0x100000 != $check_r6 - 0x8 ] {
+ fail "unexpected value r4 + 0x100,000 != r6 - 0x8 ; r4: $check_r4 r6: $check_r6 "
+}
+if [expr $check_r5 + 0x10000 != $check_r6 - 0x4 ] {
+ fail "unexpected value r5 + 0x10,000 != r6 , r5: $check_r5 r6: $check_r6 "
+}
+if [expr $check_r6 != $check_r6] {
+ fail "unexpected value r6 != r6 , r6: $check_r6 r6: $check_r6 "
+}
+if [expr $check_r7 - 0x10000 != $check_r6 + 0x4] {
+ fail "unexpected value r7 - 0x10,000 != r6 + 0x4 , r7: $check_r7 r7: $check_r6 "
+}
+if [expr $check_r8 - 0x100000 != $check_r6 + 0x8 ] {
+ fail "unexpected value r8 - 0x100,000 != r6 , r8: $check_r8 r8: $check_r6 "
+}
+if [expr $check_r9 - 0x1000000 != $check_r6 + 0xc ] {
+ fail "unexpected value r9 - 0x1,000,000 != r6 + 0xc , r9: $check_r9 r6: $check_r6 "
+}
+
+gdb_test "info break"
+gdb_test "info register r3 r4 r5 r6 r7 r8 r9"
+gdb_test "disas main"
diff --git a/gdb/testsuite/gdb.arch/powerpc-addpcis.s b/gdb/testsuite/gdb.arch/powerpc-addpcis.s
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-addpcis.s
@@ -0,0 +1,33 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+/* Test to confirm that gdb is properly single stepping over the
+ displaced addpcis instruction. */
+
+.global main
+.type main,function
+# addpcis: the sum of NIA + ( D || 0x0000) is placed in RT.
+main:
+ subpcis 3,+0x100 # /* set r3 */
+ subpcis 4,+0x10 # /* set r4 */
+ subpcis 5,+0x1 # /* set r5 */
+ lnia 6 # /* set r6 */
+ addpcis 7,+0x1 # /* set r7 */
+ addpcis 8,+0x10 # /* set r8 */
+ addpcis 9,+0x100 # /* set r9 */
+ blr
diff --git a/gdb/testsuite/gdb.arch/powerpc-lnia.exp b/gdb/testsuite/gdb.arch/powerpc-lnia.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-lnia.exp
@@ -0,0 +1,100 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test to see if gdb is properly single stepping over the
+# displaced lnia instruction. This test checks that a series
+# of lnia instructions are loading ascending values as expected.
+
+# lnia is an extended mnemonic for the addpcis instruction, which
+# stores the $NIA plus an immediate value into a register.
+#
+# lnia Rx == addpcis Rx,0 == lnia Rx
+# subcis Rx,value == addpcis Rx,-value
+
+if { ![istarget powerpc*-*] } {
+ verbose "Skipping powerpc lnia test."
+ return
+}
+
+set retval 0
+
+standard_testfile .s
+
+if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
+ {debug quiet}] } {
+ return -1
+}
+
+if ![runto_main] then {
+ return
+}
+
+set before_pc 0
+set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
+
+# set some breakpoints on the instructions below main().
+set bp1 *$check_pc+4
+set bp2 *$check_pc+12
+set bp3 *$check_pc+16
+gdb_breakpoint $bp1
+gdb_breakpoint $bp2
+gdb_breakpoint $bp3
+
+# single-step through the lnia instructions, and retrieve the
+# register values as we proceed.
+gdb_test "stepi" "" "set r3"
+set check_r3 [get_hexadecimal_valueof "\$r3" "default0"]
+gdb_test "stepi" "" "set r4"
+set check_r4 [get_hexadecimal_valueof "\$r4" "default0"]
+gdb_test "stepi" "" "set r5"
+set check_r5 [get_hexadecimal_valueof "\$r5" "default0"]
+gdb_test "stepi" "" "set r6"
+set check_r6 [get_hexadecimal_valueof "\$r6" "default0"]
+gdb_test "stepi" "" "set r7"
+set check_r7 [get_hexadecimal_valueof "\$r7" "default0"]
+gdb_test "stepi" "" "set r8"
+set check_r8 [get_hexadecimal_valueof "\$r8" "default0"]
+gdb_test "stepi" "" "set r9"
+set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
+
+# Ensure that our register values are as expected.
+# Specifically that the values loaded by the lnia instruction
+# reflect the value of the PC as if the instruction was
+# not displaced.
+if [expr $check_r3 + 4 != $check_r4] {
+ fail "unexpected value r3+4 != r4 , r3: $check_r3 r4: $check_r4 "
+}
+if [expr $check_r4 + 4 != $check_r5] {
+ fail "unexpected value r4+4 != r5 , r4: $check_r4 r5: $check_r5 "
+}
+if [expr $check_r5 + 4 != $check_r6] {
+ fail "unexpected value r5+4 != r6 , r5: $check_r5 r6: $check_r6 "
+}
+if [expr $check_r6 + 4 != $check_r7] {
+ fail "unexpected value r6+4 != r7 , r6: $check_r6 r7: $check_r7 "
+}
+if [expr $check_r7 + 4 != $check_r8] {
+ fail "unexpected value r7+4 != r8 , r7: $check_r7 r8: $check_r8 "
+}
+if [expr $check_r8 + 4 != $check_r9] {
+ fail "unexpected value r8+4 != r9 , r8: $check_r8 r9: $check_r9 "
+}
+
+gdb_test "info break"
+gdb_test "info register r3 r4 r5 r6 r7 r8 r9"
+gdb_test "disas main"
+
+# Let the inferior store all vector registers in a buffer, then dump
+# the buffer and check it.
diff --git a/gdb/testsuite/gdb.arch/powerpc-lnia.s b/gdb/testsuite/gdb.arch/powerpc-lnia.s
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-lnia.s
@@ -0,0 +1,32 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Test to confirm that gdb properly handles lnia instructions
+ that load the current PC into a target register when executed
+ from a displaced location. */
+
+.global main
+.type main,function
+main:
+ lnia 3 # /* set r3 */
+ lnia 4 # /* set r4 */
+ lnia 5 # /* set r5 */
+ lnia 6 # /* set r6 */
+ lnia 7 # /* set r7 */
+ lnia 8 # /* set r8 */
+ lnia 9 # /* set r9 */
+ blr
diff --git a/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp b/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp
@@ -0,0 +1,130 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test to see if gdb is properly single stepping over the
+# displaced plxv instruction.
+
+if { ![istarget powerpc*-*] } {
+ verbose "Skipping powerpc plxv test."
+ return
+}
+
+set retval 0
+
+standard_testfile .s
+
+if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
+ {debug quiet}] } {
+ return -1
+}
+
+gdb_test "set radix 0b10000"
+gdb_test "set debug displaced"
+
+if ![runto_main] then {
+ return
+}
+
+gdb_test "set debug displaced on"
+
+# Proc to extract the uint128 hex value from the output of
+# a print vector statement.
+proc get_vector_hexadecimal_valueof { exp default {test ""} } {
+ set val "0x0000"
+ global gdb_prompt
+ if {$test == ""} {
+ set test "get vector_hexadecimal valueof \"${exp}\""
+ }
+ gdb_test_multiple "print $${exp}.uint128" $test {
+ -re -wrap "\\$\[0-9\]* = (0x\[0-9a-zA-Z\]+).*" {
+ set val $expect_out(1,string)
+ pass "$test"
+ }
+ -re -wrap ".*Illegal instruction.* $" {
+ fail "Illegal instruction on print."
+ set val 0xffff
+ }
+ }
+ return ${val}
+}
+
+# Proc to do a single-step, and ensure we gently handle
+# an illegal instruction situation.
+proc stepi_over_instruction { xyz } {
+ global gdb_prompt
+ gdb_test_multiple "stepi" "${xyz} " {
+ -re -wrap ".*Illegal instruction.*" {
+ fail "Illegal instruction on single step."
+ return
+ }
+ -re -wrap ".*" {
+ pass "stepi ${xyz}"
+ }
+ }
+}
+
+set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
+
+# set some breakpoints on the instructions below main().
+gdb_test "disas /r main"
+set bp1 *$check_pc+4
+set bp2 *$check_pc+0d12
+set bp3 *$check_pc+0d20
+set bp4 *$check_pc+0d28
+gdb_breakpoint $bp1
+gdb_breakpoint $bp2
+gdb_breakpoint $bp3
+gdb_breakpoint $bp4
+
+# single-step through the plxv instructions, and retrieve the
+# register values as we proceed.
+
+stepi_over_instruction "stepi over NOP"
+stepi_over_instruction "stepi over lnia"
+stepi_over_instruction "stepi over addi"
+
+stepi_over_instruction "stepi over vs4 assignment"
+set check_vs4 [get_vector_hexadecimal_valueof "vs4" "default0"]
+
+stepi_over_instruction "stepi over vs5 assignment"
+set check_vs5 [get_vector_hexadecimal_valueof "vs5" "default0"]
+
+stepi_over_instruction "stepi over vs6 assignment"
+set check_vs6 [get_vector_hexadecimal_valueof "vs6" "default0"]
+
+stepi_over_instruction "stepi over vs7 assignment"
+set check_vs7 [get_vector_hexadecimal_valueof "vs7" "default0"]
+
+set vs4_expected 0xa5b5c5d5a4b4c4d4a3b3c3d3a2b2c2d2
+set vs5_expected 0xa7b7c7d7a6b6c6d6a5b5c5d5a4b4c4d4
+set vs6_expected 0xa9b9c9d9a8b8c8d8a7b7c7d7a6b6c6d6
+set vs7_expected 0xabbbcbdbaabacadaa9b9c9d9a8b8c8d8
+
+if [expr $check_vs4 != $vs4_expected] {
+ fail "unexpected value vs4; actual:$check_vs4 expected:$vs4_expected"
+}
+if [expr $check_vs5 != $vs5_expected ] {
+ fail "unexpected value vs5; actual:$check_vs5 expected:$vs5_expected"
+}
+if [expr $check_vs6 != $vs6_expected ] {
+ fail "unexpected value vs6; actual:$check_vs6 expected:$vs6_expected"
+}
+if [expr $check_vs7 != $vs7_expected ] {
+ fail "unexpected value vs7; actual:$check_vs7 expected:$vs7_expected"
+}
+
+gdb_test "info break"
+gdb_test "info register vs4 vs5 vs6 vs7 "
+gdb_test "disas main #2"
diff --git a/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.s b/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.s
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.s
@@ -0,0 +1,44 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# test to verify that the prefixed instructions that
+# load/store non-relative values work OK.
+
+.global main
+.type main,function
+main:
+ nop
+ lnia 4
+ addi 4,4,40
+ plxv 4,4(4),0
+ plxv 5,12(4),0
+ plxv 6,20(4),0
+ plxv 7,28(4),0
+check_here:
+ blr
+mydata:
+ .long 0xa1b1c1d1 # <<-
+ .long 0xa2b2c2d2 # <<- loaded into vs4
+ .long 0xa3b3c3d3 # <<- loaded into vs4
+ .long 0xa4b4c4d4 # <<- loaded into vs4, vs5
+ .long 0xa5b5c5d5 # <<- loaded into vs4, vs5
+ .long 0xa6b6c6d6 # <<- loaded into vs5, vs6
+ .long 0xa7b7c7d7 # <<- loaded into vs5, vs6
+ .long 0xa8b8c8d8 # <<- loaded into vs6, vs7
+ .long 0xa9b9c9d9 # <<- loaded into vs6, vs7
+ .long 0xaabacada # <<- loaded into vs7
+ .long 0xabbbcbdb # <<- loaded into vs7
+ .long 0xacbcccdc # <<-

View File

@ -1,39 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Thu, 6 May 2021 15:39:45 -0400
Subject: gdb-rhbz1870031-p10-prefixed-insn-3of3.patch
;; Backport "Fix build failure for 32-bit targets with..."
;; (Luis Machado, RHBZ 1870031)
commit d9d2ef05f11736bf2e889047cc7588d0c0dd907e
Author: Luis Machado <luis.machado@linaro.org>
Date: Tue Apr 13 09:19:52 2021 -0300
Fix build failure for 32-bit targets with --enable-targets=all
Replace use of %lx with %s.
gdb/ChangeLog:
2021-04-13 Luis Machado <luis.machado@linaro.org>
* rs6000-tdep.c (ppc_displaced_step_fixup): Use %s to print
hex values.
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -982,9 +982,9 @@ ppc_displaced_step_fixup (struct gdbarch *gdbarch,
if (debug_displaced)
fprintf_unfiltered (gdb_stdlog,
"displaced: {ppc} addpcis target regnum %d was "
- "0x%lx now 0x%lx",
- regnum, current_val,
- current_val + displaced_offset);
+ "%s now %s",
+ regnum, paddress (gdbarch, current_val),
+ paddress (gdbarch, current_val + displaced_offset));
regcache_cooked_write_unsigned (regs, regnum,
current_val + displaced_offset);
/* point the PC back at the non-displaced instruction. */

View File

@ -1,67 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Mon, 16 Nov 2020 12:42:09 -0500
Subject: gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch
;; Backport of "Exclude debuginfo files from 'outside of ELF segments'
;; warning" (Keith Seitz)
Exclude debuginfo files from "outside of ELF segments" warning
When GDB loads an ELF file, it will warn when a section is not located
in an ELF segment:
$ ./gdb -q -iex "set build-id-verbose 0" --ex "b systemctl_main" -ex "r" -batch --args systemctl kexec
Breakpoint 1 at 0xc24d: file ../src/systemctl/systemctl.c, line 8752.
warning: Loadable section ".note.gnu.property" outside of ELF segments
in .gnu_debugdata for /lib64/libgcc_s.so.1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
warning: Loadable section ".note.gnu.property" outside of ELF segments
in .gnu_debugdata for /lib64/libcap.so.2
warning: Loadable section ".note.gnu.property" outside of ELF segments
in .gnu_debugdata for /lib64/libacl.so.1
warning: Loadable section ".note.gnu.property" outside of ELF segments
in .gnu_debugdata for /lib64/libcryptsetup.so.12
warning: Loadable section ".note.gnu.property" outside of ELF segments
in .gnu_debugdata for /lib64/libgcrypt.so.20
warning: Loadable section ".note.gnu.property" outside of ELF segments
in .gnu_debugdata for /lib64/libip4tc.so.2
[snip]
This has feature has also been reported by various users, most notably
the Fedora-EOL'd bug 1553086.
Mark Wielaard explains the issue quite nicely in
https://sourceware.org/bugzilla/show_bug.cgi?id=24717#c2
The short of it is, the ELF program headers for debuginfo files are
not suited to this particular use case. Consequently, the warning
generated above really is useless and should be ignored.
This patch follows the same heuristic that BFD itself uses.
gdb/ChangeLog
2020-11-13 Keith Seitz <keiths@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1553086
* elfread.c (elf_symfile_segments): Omit "Loadable section ...
outside of ELF segments" warning for debugin
diff --git a/gdb/elfread.c b/gdb/elfread.c
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -147,7 +147,12 @@ elf_symfile_segments (bfd *abfd)
RealView) use SHT_NOBITS for uninitialized data. Since it is
uninitialized, it doesn't need a program header. Such
binaries are not relocatable. */
- if (bfd_section_size (sect) > 0 && j == num_segments
+
+ /* Exclude debuginfo files from this warning, too, since those
+ are often not strictly compliant with the standard. See, e.g.,
+ ld/24717 for more discussion. */
+ if (!is_debuginfo_file (abfd)
+ && bfd_section_size (sect) > 0 && j == num_segments
&& (bfd_section_flags (sect) & SEC_LOAD) != 0)
warning (_("Loadable section \"%s\" outside of ELF segments"),
bfd_section_name (sect));

View File

@ -1,64 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.ibm.com>
Date: Thu, 19 Nov 2020 19:10:58 +0100
Subject: gdb-rhbz1903375-s390x-store-on-condition.patch
;; Backport of "Correct recording of 'store on condition' insns"
;; Andreas Arnaz (RH BZ 1903374)
gdb/s390: Correct recording of "store on condition" insns
The "store on condition" instructions STOC, STOCG, and STOCFH are recorded
as if their instruction formats resembled that of STG. This is wrong,
usually resulting in "failed to record execution log" errors when trying
to record code with any of these instructions.
This patch fixes the recording of these instructions.
gdb/ChangeLog:
PR tdep/26916
* s390-tdep.c (s390_process_record): Fix recording of STOC, STOCG,
and STOCFH.
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -5382,7 +5382,6 @@ s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
case 0xe325: /* NTSTG - nontransactional store */
case 0xe326: /* CVDY - convert to decimal */
case 0xe32f: /* STRVG - store reversed */
- case 0xebe3: /* STOCG - store on condition */
case 0xed67: /* STDY - store */
oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
if (record_full_arch_list_add_mem (oaddr, 8))
@@ -5411,8 +5410,6 @@ s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
case 0xe33e: /* STRV - store reversed */
case 0xe350: /* STY - store */
case 0xe3cb: /* STFH - store high */
- case 0xebe1: /* STOCFH - store high on condition */
- case 0xebf3: /* STOC - store on condition */
case 0xed66: /* STEY - store */
oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
if (record_full_arch_list_add_mem (oaddr, 4))
@@ -6125,6 +6122,20 @@ s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
/* 0xeb9c-0xebbf undefined */
/* 0xebc1-0xebdb undefined */
+
+ case 0xebe1: /* STOCFH - store high on condition */
+ case 0xebf3: /* STOC - store on condition */
+ oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
+ if (record_full_arch_list_add_mem (oaddr, 4))
+ return -1;
+ break;
+
+ case 0xebe3: /* STOCG - store on condition */
+ oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
+ if (record_full_arch_list_add_mem (oaddr, 8))
+ return -1;
+ break;
+
/* 0xebe5 undefined */
/* 0xebe9 undefined */
/* 0xebeb-0xebf1 undefined */

View File

@ -1,82 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Tue, 8 Dec 2020 14:07:45 -0700
Subject: gdb-rhbz1905996-fix-off-by-one-error-in-ada_fold_name.patch
;; Fix off-by-one error in ada_fold_name.patch (RH BZ 1905996)
;; Upstream patch proposal: https://sourceware.org/pipermail/gdb-patches/2020-December/173935.html
;; =fedoratest
Fix off-by-one error in ada_fold_name
I'm seeing a libstdc++ assertion failure when running GDB's "maint selftest"
command when GDB is configured with the following CFLAGS and CXXFLAGS as
part of the configure line:
CFLAGS='-D_GLIBCXX_DEBUG -g3 -O0' CXXFLAGS='-D_GLIBCXX_DEBUG -g3 -O0'
This is what I see when running the self tests:
(gdb) maint selftest
Running selftest aarch64-analyze-prologue.
Running selftest aarch64-process-record.
Running selftest arm-record.
Running selftest arm_analyze_prologue.
Running selftest array_view.
Running selftest child_path.
Running selftest cli_utils.
Running selftest command_structure_invariants.
Running selftest copy_bitwise.
Running selftest copy_integer_to_size.
Running selftest cp_remove_params.
Running selftest cp_symbol_name_matches.
Running selftest dw2_expand_symtabs_matching.
/usr/include/c++/11/string_view:211: constexpr const value_type& std::basic_string_view<_CharT, _Traits>::operator[](std::basic_string_view<_CharT, _Traits>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; std::basic_string_view<_CharT, _Traits>::const_reference = const char&; std::basic_string_view<_CharT, _Traits>::size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed.
Aborted (core dumped)
Here's a partial stack trace:
#0 0x00007ffff6ef6262 in raise () from /lib64/libc.so.6
#1 0x00007ffff6edf8a4 in abort () from /lib64/libc.so.6
#2 0x00000000004249bf in std::__replacement_assert (
__file=0xef7480 "/usr/include/c++/11/string_view", __line=211,
__function=0xef7328 "constexpr const value_type& std::basic_string_view<_CharT, _Traits>::operator[](std::basic_string_view<_CharT, _Traits>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; std::ba"...,
__condition=0xef7311 "__pos < this->_M_len")
at /usr/include/c++/11/x86_64-redhat-linux/bits/c++config.h:2624
#3 0x0000000000451737 in std::basic_string_view<char, std::char_traits<char> >::operator[] (this=0x7fffffffc200, __pos=8)
at /usr/include/c++/11/string_view:211
#4 0x00000000004329f5 in ada_fold_name (name="function")
at /ironwood1/sourceware-git/rawhide-master/bld/../../worktree-master/gdb/ada-lang.c:988
And, looking at frame #4...
(top-gdb) up 4
at /ironwood1/sourceware-git/rawhide-master/bld/../../worktree-master/gdb/ada-lang.c:988
988 fold_buffer[i] = tolower (name[i]);
(top-gdb) p i
$1 = 8
(top-gdb) p name.size()
$2 = 8
My patch adjusts the comparison to only copy name.size() characters
from the string. I've added a separate statement for NUL character
termination of fold_buffer[].
gdb/ChangeLog:
* ada-lang.c (ada_fold_name): Fix off-by-one error.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1006,8 +1006,9 @@ ada_fold_name (gdb::string_view name)
{
int i;
- for (i = 0; i <= len; i += 1)
+ for (i = 0; i < len; i += 1)
fold_buffer[i] = tolower (name[i]);
+ fold_buffer[i] = '\0';
}
return fold_buffer;

View File

@ -1,593 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Date: Fri, 30 Oct 2020 18:26:15 +0100
Subject: gdb-rhbz1909902-frame_id_p-assert-1.patch
;; Backport fix for frame_id_p assertion failure (RH BZ 1909902).
Make scoped_restore_current_thread's cdtors exception free (RFC)
If the remote target closes while we're reading registers/memory for
restoring the selected frame in scoped_restore_current_thread's dtor,
the corresponding TARGET_CLOSE_ERROR error is swallowed by the
scoped_restore_current_thread's dtor, because letting exceptions
escape from a dtor is bad. It isn't great to lose that errors like
that, though. I've been thinking about how to avoid it, and I came up
with this patch.
The idea here is to make scoped_restore_current_thread's dtor do as
little as possible, to avoid any work that might throw in the first
place. And to do that, instead of having the dtor call
restore_selected_frame, which re-finds the previously selected frame,
just record the frame_id/level of the desired selected frame, and have
get_selected_frame find the frame the next time it is called. In
effect, this implements most of Cagney's suggestion, here:
/* On demand, create the selected frame and then return it. If the
selected frame can not be created, this function prints then throws
an error. When MESSAGE is non-NULL, use it for the error message,
otherwize use a generic error message. */
/* FIXME: cagney/2002-11-28: At present, when there is no selected
frame, this function always returns the current (inner most) frame.
It should instead, when a thread has previously had its frame
selected (but not resumed) and the frame cache invalidated, find
and then return that thread's previously selected frame. */
extern struct frame_info *get_selected_frame (const char *message);
The only thing missing to fully implement that would be to make
reinit_frame_cache just clear selected_frame instead of calling
select_frame(NULL), and the call select_frame(NULL) explicitly in the
places where we really wanted reinit_frame_cache to go back to the
current frame too. That can done separately, though, I'm not
proposing to do that in this patch.
Note that this patch renames restore_selected_frame to
lookup_selected_frame, and adds a new restore_selected_frame function
that doesn't throw, to be paired with the also-new save_selected_frame
function.
There's a restore_selected_frame function in infrun.c that I think can
be replaced by the new one in frame.c.
Also done in this patch is make the get_selected_frame's parameter be
optional, so that we don't have to pass down nullptr explicitly all
over the place.
lookup_selected_frame should really move from thread.c to frame.c, but
I didn't do that here, just to avoid churn in the patch while it
collects comments. I did make it extern and declared it in frame.h
already, preparing for the move. I will do the move as a follow up
patch if people agree with this approach.
Incidentally, this patch alone would fix the crashes fixed by the
previous patches in the series, because with this,
scoped_restore_current_thread's constructor doesn't throw either.
gdb/ChangeLog:
* blockframe.c (block_innermost_frame): Use get_selected_frame.
* frame.c
(scoped_restore_selected_frame::scoped_restore_selected_frame):
Use save_selected_frame. Save language as well.
(scoped_restore_selected_frame::~scoped_restore_selected_frame):
Use restore_selected_frame, and restore language as well.
(selected_frame_id, selected_frame_level): New.
(selected_frame): Update comments.
(save_selected_frame, restore_selected_frame): New.
(get_selected_frame): Use lookup_selected_frame.
(get_selected_frame_if_set): Delete.
(select_frame): Record selected_frame_level and selected_frame_id.
* frame.h (scoped_restore_selected_frame) <m_level, m_lang>: New
fields.
(get_selected_frame): Make 'message' parameter optional.
(get_selected_frame_if_set): Delete declaration.
(select_frame): Update comments.
(save_selected_frame, restore_selected_frame)
(lookup_selected_frame): Declare.
* gdbthread.h (scoped_restore_current_thread) <m_lang>: New field.
* infrun.c (struct infcall_control_state) <selected_frame_level>:
New field.
(save_infcall_control_state): Use save_selected_frame.
(restore_selected_frame): Delete.
(restore_infcall_control_state): Use restore_selected_frame.
* stack.c (select_frame_command_core, frame_command_core): Use
get_selected_frame.
* thread.c (restore_selected_frame): Rename to ...
(lookup_selected_frame): ... this and make extern. Select the
current frame if the frame level is -1.
(scoped_restore_current_thread::restore): Also restore the
language.
(scoped_restore_current_thread::~scoped_restore_current_thread):
Don't try/catch.
(scoped_restore_current_thread::scoped_restore_current_thread):
Save the language as well. Use save_selected_frame.
Change-Id: I73fd1cfc40d8513c28e5596383b7ecd8bcfe700f
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -464,14 +464,10 @@ find_gnu_ifunc_target_type (CORE_ADDR resolver_funaddr)
struct frame_info *
block_innermost_frame (const struct block *block)
{
- struct frame_info *frame;
-
if (block == NULL)
return NULL;
- frame = get_selected_frame_if_set ();
- if (frame == NULL)
- frame = get_current_frame ();
+ frame_info *frame = get_selected_frame ();
while (frame != NULL)
{
const struct block *frame_block = get_frame_block (frame, NULL);
diff --git a/gdb/frame.c b/gdb/frame.c
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -317,17 +317,15 @@ frame_stash_invalidate (void)
/* See frame.h */
scoped_restore_selected_frame::scoped_restore_selected_frame ()
{
- m_fid = get_frame_id (get_selected_frame (NULL));
+ m_lang = current_language->la_language;
+ save_selected_frame (&m_fid, &m_level);
}
/* See frame.h */
scoped_restore_selected_frame::~scoped_restore_selected_frame ()
{
- frame_info *frame = frame_find_by_id (m_fid);
- if (frame == NULL)
- warning (_("Unable to restore previously selected frame."));
- else
- select_frame (frame);
+ restore_selected_frame (m_fid, m_level);
+ set_language (m_lang);
}
/* Flag to control debugging. */
@@ -1685,10 +1683,63 @@ get_current_frame (void)
}
/* The "selected" stack frame is used by default for local and arg
- access. May be zero, for no selected frame. */
-
+ access.
+
+ The "single source of truth" for the selected frame is the
+ SELECTED_FRAME_ID / SELECTED_FRAME_LEVEL pair.
+
+ Frame IDs can be saved/restored across reinitializing the frame
+ cache, while frame_info pointers can't (frame_info objects are
+ invalidated). If we know the corresponding frame_info object, it
+ is cached in SELECTED_FRAME.
+
+ If SELECTED_FRAME_ID / SELECTED_FRAME_LEVEL are null_frame_id / -1,
+ and the target has stack and is stopped, the selected frame is the
+ current (innermost) frame. This means that SELECTED_FRAME_LEVEL is
+ never 0 and SELECTED_FRAME_ID is never the ID of the innermost
+ frame.
+
+ If SELECTED_FRAME_ID / SELECTED_FRAME_LEVEL are null_frame_id / -1,
+ and the target has no stack or is executing, then there's no
+ selected frame. */
+static frame_id selected_frame_id = null_frame_id;
+static int selected_frame_level = -1;
+
+/* The cached frame_info object pointing to the selected frame.
+ Looked up on demand by get_selected_frame. */
static struct frame_info *selected_frame;
+/* See frame.h. */
+
+void
+save_selected_frame (frame_id *frame_id, int *frame_level)
+ noexcept
+{
+ *frame_id = selected_frame_id;
+ *frame_level = selected_frame_level;
+}
+
+/* See frame.h. */
+
+void
+restore_selected_frame (frame_id frame_id, int frame_level)
+ noexcept
+{
+ /* save_selected_frame never returns level == 0, so we shouldn't see
+ it here either. */
+ gdb_assert (frame_level != 0);
+
+ /* FRAME_ID can be null_frame_id only IFF frame_level is -1. */
+ gdb_assert ((frame_level == -1 && !frame_id_p (frame_id))
+ || (frame_level != -1 && frame_id_p (frame_id)));
+
+ selected_frame_id = frame_id;
+ selected_frame_level = frame_level;
+
+ /* Will be looked up later by get_selected_frame. */
+ selected_frame = nullptr;
+}
+
bool
has_stack_frames ()
{
@@ -1715,9 +1766,7 @@ has_stack_frames ()
return true;
}
-/* Return the selected frame. Always non-NULL (unless there isn't an
- inferior sufficient for creating a frame) in which case an error is
- thrown. */
+/* See frame.h. */
struct frame_info *
get_selected_frame (const char *message)
@@ -1726,24 +1775,14 @@ get_selected_frame (const char *message)
{
if (message != NULL && !has_stack_frames ())
error (("%s"), message);
- /* Hey! Don't trust this. It should really be re-finding the
- last selected frame of the currently selected thread. This,
- though, is better than nothing. */
- select_frame (get_current_frame ());
+
+ lookup_selected_frame (selected_frame_id, selected_frame_level);
}
/* There is always a frame. */
gdb_assert (selected_frame != NULL);
return selected_frame;
}
-/* If there is a selected frame, return it. Otherwise, return NULL. */
-
-struct frame_info *
-get_selected_frame_if_set (void)
-{
- return selected_frame;
-}
-
/* This is a variant of get_selected_frame() which can be called when
the inferior does not have a frame; in that case it will return
NULL instead of calling error(). */
@@ -1756,12 +1795,42 @@ deprecated_safe_get_selected_frame (void)
return get_selected_frame (NULL);
}
-/* Select frame FI (or NULL - to invalidate the current frame). */
+/* Select frame FI (or NULL - to invalidate the selected frame). */
void
select_frame (struct frame_info *fi)
{
selected_frame = fi;
+ selected_frame_level = frame_relative_level (fi);
+ if (selected_frame_level == 0)
+ {
+ /* Treat the current frame especially -- we want to always
+ save/restore it without warning, even if the frame ID changes
+ (see lookup_selected_frame). E.g.:
+
+ // The current frame is selected, the target had just stopped.
+ {
+ scoped_restore_selected_frame restore_frame;
+ some_operation_that_changes_the_stack ();
+ }
+ // scoped_restore_selected_frame's dtor runs, but the
+ // original frame_id can't be found. No matter whether it
+ // is found or not, we still end up with the now-current
+ // frame selected. Warning in lookup_selected_frame in this
+ // case seems pointless.
+
+ Also get_frame_id may access the target's registers/memory,
+ and thus skipping get_frame_id optimizes the common case.
+
+ Saving the selected frame this way makes get_selected_frame
+ and restore_current_frame return/re-select whatever frame is
+ the innermost (current) then. */
+ selected_frame_level = -1;
+ selected_frame_id = null_frame_id;
+ }
+ else
+ selected_frame_id = get_frame_id (fi);
+
/* NOTE: cagney/2002-05-04: FI can be NULL. This occurs when the
frame is being invalidated. */
diff --git a/gdb/frame.h b/gdb/frame.h
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -186,8 +186,14 @@ class scoped_restore_selected_frame
private:
- /* The ID of the previously selected frame. */
+ /* The ID and level of the previously selected frame. */
struct frame_id m_fid;
+ int m_level;
+
+ /* Save/restore the language as well, because selecting a frame
+ changes the current language to the frame's language if "set
+ language auto". */
+ enum language m_lang;
};
/* Methods for constructing and comparing Frame IDs. */
@@ -316,24 +322,49 @@ extern bool has_stack_frames ();
modifies the target invalidating the frame cache). */
extern void reinit_frame_cache (void);
-/* On demand, create the selected frame and then return it. If the
- selected frame can not be created, this function prints then throws
- an error. When MESSAGE is non-NULL, use it for the error message,
+/* Return the selected frame. Always returns non-NULL. If there
+ isn't an inferior sufficient for creating a frame, an error is
+ thrown. When MESSAGE is non-NULL, use it for the error message,
otherwise use a generic error message. */
/* FIXME: cagney/2002-11-28: At present, when there is no selected
frame, this function always returns the current (inner most) frame.
It should instead, when a thread has previously had its frame
selected (but not resumed) and the frame cache invalidated, find
and then return that thread's previously selected frame. */
-extern struct frame_info *get_selected_frame (const char *message);
-
-/* If there is a selected frame, return it. Otherwise, return NULL. */
-extern struct frame_info *get_selected_frame_if_set (void);
+extern struct frame_info *get_selected_frame (const char *message = nullptr);
-/* Select a specific frame. NULL, apparently implies re-select the
- inner most frame. */
+/* Select a specific frame. NULL implies re-select the inner most
+ frame. */
extern void select_frame (struct frame_info *);
+/* Save the frame ID and frame level of the selected frame in FRAME_ID
+ and FRAME_LEVEL, to be restored later with restore_selected_frame.
+
+ This is preferred over getting the same info out of
+ get_selected_frame directly because this function does not create
+ the selected-frame's frame_info object if it hasn't been created
+ yet, and thus is more efficient and doesn't throw. */
+extern void save_selected_frame (frame_id *frame_id, int *frame_level)
+ noexcept;
+
+/* Restore selected frame as saved with save_selected_frame.
+
+ Does not try to find the corresponding frame_info object. Instead
+ the next call to get_selected_frame will look it up and cache the
+ result.
+
+ This function does not throw. It is designed to be safe to called
+ from the destructors of RAII types. */
+extern void restore_selected_frame (frame_id frame_id, int frame_level)
+ noexcept;
+
+/* Lookup the frame_info object for the selected frame FRAME_ID /
+ FRAME_LEVEL and cache the result.
+
+ If FRAME_LEVEL > 0 and the originally selected frame isn't found,
+ warn and select the innermost (current) frame. */
+extern void lookup_selected_frame (frame_id frame_id, int frame_level);
+
/* Given a FRAME, return the next (more inner, younger) or previous
(more outer, older) frame. */
extern struct frame_info *get_prev_frame (struct frame_info *);
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -673,6 +673,10 @@ class scoped_restore_current_thread
frame_id m_selected_frame_id;
int m_selected_frame_level;
bool m_was_stopped;
+ /* Save/restore the language as well, because selecting a frame
+ changes the current language to the frame's language if "set
+ language auto". */
+ enum language m_lang;
};
/* Returns a pointer into the thread_info corresponding to
diff --git a/gdb/infrun.c b/gdb/infrun.c
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9006,8 +9006,10 @@ struct infcall_control_state
enum stop_stack_kind stop_stack_dummy = STOP_NONE;
int stopped_by_random_signal = 0;
- /* ID if the selected frame when the inferior function call was made. */
+ /* ID and level of the selected frame when the inferior function
+ call was made. */
struct frame_id selected_frame_id {};
+ int selected_frame_level = -1;
};
/* Save all of the information associated with the inferior<==>gdb
@@ -9036,27 +9038,12 @@ save_infcall_control_state ()
inf_status->stop_stack_dummy = stop_stack_dummy;
inf_status->stopped_by_random_signal = stopped_by_random_signal;
- inf_status->selected_frame_id = get_frame_id (get_selected_frame (NULL));
+ save_selected_frame (&inf_status->selected_frame_id,
+ &inf_status->selected_frame_level);
return inf_status;
}
-static void
-restore_selected_frame (const frame_id &fid)
-{
- frame_info *frame = frame_find_by_id (fid);
-
- /* If inf_status->selected_frame_id is NULL, there was no previously
- selected frame. */
- if (frame == NULL)
- {
- warning (_("Unable to restore previously selected frame."));
- return;
- }
-
- select_frame (frame);
-}
-
/* Restore inferior session state to INF_STATUS. */
void
@@ -9084,21 +9071,8 @@ restore_infcall_control_state (struct infcall_control_state *inf_status)
if (target_has_stack)
{
- /* The point of the try/catch is that if the stack is clobbered,
- walking the stack might encounter a garbage pointer and
- error() trying to dereference it. */
- try
- {
- restore_selected_frame (inf_status->selected_frame_id);
- }
- catch (const gdb_exception_error &ex)
- {
- exception_fprintf (gdb_stderr, ex,
- "Unable to restore previously selected frame:\n");
- /* Error in restoring the selected frame. Select the
- innermost frame. */
- select_frame (get_current_frame ());
- }
+ restore_selected_frame (inf_status->selected_frame_id,
+ inf_status->selected_frame_level);
}
delete inf_status;
diff --git a/gdb/stack.c b/gdb/stack.c
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1842,9 +1842,9 @@ trailing_outermost_frame (int count)
static void
select_frame_command_core (struct frame_info *fi, bool ignored)
{
- struct frame_info *prev_frame = get_selected_frame_if_set ();
+ frame_info *prev_frame = get_selected_frame ();
select_frame (fi);
- if (get_selected_frame_if_set () != prev_frame)
+ if (get_selected_frame () != prev_frame)
gdb::observers::user_selected_context_changed.notify (USER_SELECTED_FRAME);
}
@@ -1863,10 +1863,9 @@ select_frame_for_mi (struct frame_info *fi)
static void
frame_command_core (struct frame_info *fi, bool ignored)
{
- struct frame_info *prev_frame = get_selected_frame_if_set ();
-
+ frame_info *prev_frame = get_selected_frame ();
select_frame (fi);
- if (get_selected_frame_if_set () != prev_frame)
+ if (get_selected_frame () != prev_frame)
gdb::observers::user_selected_context_changed.notify (USER_SELECTED_FRAME);
else
print_selected_thread_frame (current_uiout, USER_SELECTED_FRAME);
diff --git a/gdb/thread.c b/gdb/thread.c
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1325,20 +1325,26 @@ switch_to_thread (process_stratum_target *proc_target, ptid_t ptid)
switch_to_thread (thr);
}
-static void
-restore_selected_frame (struct frame_id a_frame_id, int frame_level)
+/* See frame.h. */
+
+void
+lookup_selected_frame (struct frame_id a_frame_id, int frame_level)
{
struct frame_info *frame = NULL;
int count;
- /* This means there was no selected frame. */
+ /* This either means there was no selected frame, or the selected
+ frame was the current frame. In either case, select the current
+ frame. */
if (frame_level == -1)
{
- select_frame (NULL);
+ select_frame (get_current_frame ());
return;
}
- gdb_assert (frame_level >= 0);
+ /* select_frame never saves 0 in SELECTED_FRAME_LEVEL, so we
+ shouldn't see it here. */
+ gdb_assert (frame_level > 0);
/* Restore by level first, check if the frame id is the same as
expected. If that fails, try restoring by frame id. If that
@@ -1409,64 +1415,28 @@ scoped_restore_current_thread::restore ()
&& target_has_stack
&& target_has_memory)
restore_selected_frame (m_selected_frame_id, m_selected_frame_level);
+
+ set_language (m_lang);
}
scoped_restore_current_thread::~scoped_restore_current_thread ()
{
if (!m_dont_restore)
- {
- try
- {
- restore ();
- }
- catch (const gdb_exception &ex)
- {
- /* We're in a dtor, there's really nothing else we can do
- but swallow the exception. */
- }
- }
+ restore ();
}
scoped_restore_current_thread::scoped_restore_current_thread ()
{
m_inf = inferior_ref::new_reference (current_inferior ());
+ m_lang = current_language->la_language;
+
if (inferior_ptid != null_ptid)
{
m_thread = thread_info_ref::new_reference (inferior_thread ());
- struct frame_info *frame;
-
m_was_stopped = m_thread->state == THREAD_STOPPED;
- if (m_was_stopped
- && target_has_registers
- && target_has_stack
- && target_has_memory)
- {
- /* When processing internal events, there might not be a
- selected frame. If we naively call get_selected_frame
- here, then we can end up reading debuginfo for the
- current frame, but we don't generally need the debuginfo
- at this point. */
- frame = get_selected_frame_if_set ();
- }
- else
- frame = NULL;
-
- try
- {
- m_selected_frame_id = get_frame_id (frame);
- m_selected_frame_level = frame_relative_level (frame);
- }
- catch (const gdb_exception_error &ex)
- {
- m_selected_frame_id = null_frame_id;
- m_selected_frame_level = -1;
-
- /* Better let this propagate. */
- if (ex.error == TARGET_CLOSE_ERROR)
- throw;
- }
+ save_selected_frame (&m_selected_frame_id, &m_selected_frame_level);
}
}

View File

@ -1,169 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Date: Sat, 31 Oct 2020 00:27:18 +0000
Subject: gdb-rhbz1909902-frame_id_p-assert-2.patch
;; Backport patch #2 which fixes a frame_id_p assertion failure (RH BZ 1909902).
Fix frame cycle detection
The recent commit to make scoped_restore_current_thread's cdtors
exception free regressed gdb.base/eh_return.exp:
Breakpoint 1, 0x00000000004012bb in eh2 (gdb/frame.c:641: internal-error: frame_id get_frame_id(frame_info*): Assertion `stashed' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.base/eh_return.exp: hit breakpoint (GDB internal error)
That testcase uses __builtin_eh_return and, before the regression, the
backtrace at eh2 looked like this:
(gdb) bt
#0 0x00000000004006eb in eh2 (p=0x4006ec <continuation>) at src/gdb/testsuite/gdb.base/eh_return.c:54
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
That "previous frame identical to this frame" is caught by the cycle
detection based on frame id.
The assertion failing is this one:
638 /* Since this is the first frame in the chain, this should
639 always succeed. */
640 bool stashed = frame_stash_add (fi);
641 gdb_assert (stashed);
originally added by
commit f245535cf583ae4ca13b10d47b3c7d3334593ece
Author: Pedro Alves <palves@redhat.com>
AuthorDate: Mon Sep 5 18:41:38 2016 +0100
Fix PR19927: Avoid unwinder recursion if sniffer uses calls parse_and_eval
The assertion is failing because frame #1's frame id was stashed
before the id of frame #0 is stashed. The frame id of frame #1 was
stashed here:
(top-gdb) bt
#0 frame_stash_add (frame=0x1e24c90) at src/gdb/frame.c:276
#1 0x0000000000669c1b in get_prev_frame_if_no_cycle (this_frame=0x19f8370) at src/gdb/frame.c:2120
#2 0x000000000066a339 in get_prev_frame_always_1 (this_frame=0x19f8370) at src/gdb/frame.c:2303
#3 0x000000000066a360 in get_prev_frame_always (this_frame=0x19f8370) at src/gdb/frame.c:2319
#4 0x000000000066b56c in get_frame_unwind_stop_reason (frame=0x19f8370) at src/gdb/frame.c:3028
#5 0x000000000059f929 in dwarf2_frame_cfa (this_frame=0x19f8370) at src/gdb/dwarf2/frame.c:1462
#6 0x00000000005ce434 in dwarf_evaluate_loc_desc::get_frame_cfa (this=0x7fffffffc070) at src/gdb/dwarf2/loc.c:666
#7 0x00000000005989a9 in dwarf_expr_context::execute_stack_op (this=0x7fffffffc070, op_ptr=0x1b2a053 "\364\003", op_end=0x1b2a053 "\364\003") at src/gdb/dwarf2/expr.c:1161
#8 0x0000000000596af6 in dwarf_expr_context::eval (this=0x7fffffffc070, addr=0x1b2a052 "\234\364\003", len=1) at src/gdb/dwarf2/expr.c:303
#9 0x0000000000597b4e in dwarf_expr_context::execute_stack_op (this=0x7fffffffc070, op_ptr=0x1b2a063 "", op_end=0x1b2a063 "") at src/gdb/dwarf2/expr.c:865
#10 0x0000000000596af6 in dwarf_expr_context::eval (this=0x7fffffffc070, addr=0x1b2a061 "\221X", len=2) at src/gdb/dwarf2/expr.c:303
#11 0x00000000005c8b5a in dwarf2_evaluate_loc_desc_full (type=0x1b564d0, frame=0x19f8370, data=0x1b2a061 "\221X", size=2, per_cu=0x1b28760, per_objfile=0x1a84930, subobj_type=0x1b564d0, subobj_byte_offset=0) at src/gdb/dwarf2/loc.c:2260
#12 0x00000000005c9243 in dwarf2_evaluate_loc_desc (type=0x1b564d0, frame=0x19f8370, data=0x1b2a061 "\221X", size=2, per_cu=0x1b28760, per_objfile=0x1a84930) at src/gdb/dwarf2/loc.c:2444
#13 0x00000000005cb769 in locexpr_read_variable (symbol=0x1b59840, frame=0x19f8370) at src/gdb/dwarf2/loc.c:3687
#14 0x0000000000663137 in language_defn::read_var_value (this=0x122ea60 <c_language_defn>, var=0x1b59840, var_block=0x0, frame=0x19f8370) at src/gdb/findvar.c:618
#15 0x0000000000663c3b in read_var_value (var=0x1b59840, var_block=0x0, frame=0x19f8370) at src/gdb/findvar.c:822
#16 0x00000000008c7d9f in read_frame_arg (fp_opts=..., sym=0x1b59840, frame=0x19f8370, argp=0x7fffffffc470, entryargp=0x7fffffffc490) at src/gdb/stack.c:542
#17 0x00000000008c89cd in print_frame_args (fp_opts=..., func=0x1b597c0, frame=0x19f8370, num=-1, stream=0x1aba860) at src/gdb/stack.c:890
#18 0x00000000008c9bf8 in print_frame (fp_opts=..., frame=0x19f8370, print_level=0, print_what=SRC_AND_LOC, print_args=1, sal=...) at src/gdb/stack.c:1394
#19 0x00000000008c92b9 in print_frame_info (fp_opts=..., frame=0x19f8370, print_level=0, print_what=SRC_AND_LOC, print_args=1, set_current_sal=1) at src/gdb/stack.c:1119
#20 0x00000000008c75f0 in print_stack_frame (frame=0x19f8370, print_level=0, print_what=SRC_AND_LOC, set_current_sal=1) at src/gdb/stack.c:366
#21 0x000000000070250b in print_stop_location (ws=0x7fffffffc9e0) at src/gdb/infrun.c:8110
#22 0x0000000000702569 in print_stop_event (uiout=0x1a8b9e0, displays=true) at src/gdb/infrun.c:8126
#23 0x000000000096d04b in tui_on_normal_stop (bs=0x1bcd1c0, print_frame=1) at src/gdb/tui/tui-interp.c:98
...
Before the commit to make scoped_restore_current_thread's cdtors
exception free, scoped_restore_current_thread's dtor would call
get_frame_id on the selected frame, and we use
scoped_restore_current_thread pervasively. That had the side effect
of stashing the frame id of frame #0 before reaching the path shown in
the backtrace. I.e., the frame id of frame #0 happened to be stashed
before the frame id of frame #1. But that was by chance, not by
design.
This commit:
commit 256ae5dbc73d1348850f86ee77a0dc3b04bc7cc0
Author: Kevin Buettner <kevinb@redhat.com>
AuthorDate: Mon Oct 31 12:47:42 2016 -0700
Stash frame id of current frame before stashing frame id for previous frame
Fixed a similar problem, by making sure get_prev_frame computes the
frame id of the current frame before unwinding the previous frame, so
that the cycle detection works properly. That fix misses the scenario
we're now running against, because if you notice, the backtrace above
shows that frame #4 calls get_prev_frame_always, not get_prev_frame.
I.e., nothing is calling get_frame_id on the current frame.
The fix here is to move Kevin's fix down from get_prev_frame to
get_prev_frame_always. Or actually, a bit further down to
get_prev_frame_always_1 -- note that inline_frame_this_id calls
get_prev_frame_always, so we need to be careful to avoid recursion in
that scenario.
gdb/ChangeLog:
* frame.c (get_prev_frame): Move get_frame_id call from here ...
(get_prev_frame_always_1): ... to here.
* inline-frame.c (inline_frame_this_id): Mention
get_prev_frame_always_1 in comment.
Change-Id: Id960c98ab2d072c48a436c3eb160cc4b2a5cfd1d
diff --git a/gdb/frame.c b/gdb/frame.c
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2133,6 +2133,23 @@ get_prev_frame_always_1 (struct frame_info *this_frame)
if (get_frame_type (this_frame) == INLINE_FRAME)
return get_prev_frame_if_no_cycle (this_frame);
+ /* If this_frame is the current frame, then compute and stash its
+ frame id prior to fetching and computing the frame id of the
+ previous frame. Otherwise, the cycle detection code in
+ get_prev_frame_if_no_cycle() will not work correctly. When
+ get_frame_id() is called later on, an assertion error will be
+ triggered in the event of a cycle between the current frame and
+ its previous frame.
+
+ Note we do this after the INLINE_FRAME check above. That is
+ because the inline frame's frame id computation needs to fetch
+ the frame id of its previous real stack frame. I.e., we need to
+ avoid recursion in that case. This is OK since we're sure the
+ inline frame won't create a cycle with the real stack frame. See
+ inline_frame_this_id. */
+ if (this_frame->level == 0)
+ get_frame_id (this_frame);
+
/* Check that this frame is unwindable. If it isn't, don't try to
unwind to the prev frame. */
this_frame->stop_reason
@@ -2410,16 +2427,6 @@ get_prev_frame (struct frame_info *this_frame)
something should be calling get_selected_frame() or
get_current_frame(). */
gdb_assert (this_frame != NULL);
-
- /* If this_frame is the current frame, then compute and stash
- its frame id prior to fetching and computing the frame id of the
- previous frame. Otherwise, the cycle detection code in
- get_prev_frame_if_no_cycle() will not work correctly. When
- get_frame_id() is called later on, an assertion error will
- be triggered in the event of a cycle between the current
- frame and its previous frame. */
- if (this_frame->level == 0)
- get_frame_id (this_frame);
frame_pc_p = get_frame_pc_if_available (this_frame, &frame_pc);
diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
--- a/gdb/inline-frame.c
+++ b/gdb/inline-frame.c
@@ -161,7 +161,8 @@ inline_frame_this_id (struct frame_info *this_frame,
real frame's this_id method. So we must call
get_prev_frame_always. Because we are inlined into some
function, there must be previous frames, so this is safe - as
- long as we're careful not to create any cycles. */
+ long as we're careful not to create any cycles. See related
+ comments in get_prev_frame_always_1. */
*this_id = get_frame_id (get_prev_frame_always (this_frame));
/* We need a valid frame ID, so we need to be based on a valid

View File

@ -1,64 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Wed, 17 Feb 2021 17:58:54 -0700
Subject: gdb-rhbz1912985-libstdc++-assert.patch
;; Backport fix for libstdc++ assert when performing tab completion
;; (RH BZ 1912985).
Fix completion related libstdc++ assert when using -D_GLIBCXX_DEBUG
This commit fixes a libstdc++ assertion failure encountered when
running gdb.base/completion.exp. In order to see this problem,
GDB must be built with the follow CFLAGS and CXXFLAGS as part
of the configure line:
CFLAGS='-D_GLIBCXX_DEBUG' CXXFLAGS='-D_GLIBCXX_DEBUG'
(Also, this problem was encountered using Fedora rawhide. It might
not be reproducible in Fedora versions prior to Fedora 34.)
Using the gdb.base/completion.exp test program, the problem can be
observed as follows:
[kev@rawhide-1 gdb]$ ./gdb -q testsuite/outputs/gdb.base/completion/completion
Reading symbols from testsuite/outputs/gdb.base/completion/completion...
(gdb) start
Temporary breakpoint 1 at 0x401179: file ../../worktree-master/gdb/testsuite/gdb.base/break.c, line 43.
Starting program: testsuite/outputs/gdb.base/completion/completion
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffd718, envp=0x7fffffffd728) at ../../worktree-master/gdb/testsuite/gdb.base/break.c:43
43 if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
(gdb) p <TAB>/usr/include/c++/11/string_view:211: constexpr const value_type& std::basic_string_view<_CharT, _Traits>::operator[](std::basic_string_view<_CharT, _Traits>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; std::basic_string_view<_CharT, _Traits>::const_reference = const char&; std::basic_string_view<_CharT, _Traits>::size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed.
Aborted (core dumped)
(Note that I added "<TAB>" to make it clear where the tab key was
pressed.)
gdb/ChangeLog:
* ada-lang.c (ada_fold_name): Check for non-empty string prior
to accessing it.
(ada_lookup_name_info): Likewise.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -997,7 +997,7 @@ ada_fold_name (gdb::string_view name)
int len = name.size ();
GROW_VECT (fold_buffer, fold_buffer_size, len + 1);
- if (name[0] == '\'')
+ if (!name.empty () && name[0] == '\'')
{
strncpy (fold_buffer, name.data () + 1, len - 2);
fold_buffer[len - 2] = '\000';
@@ -13597,7 +13597,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
{
gdb::string_view user_name = lookup_name.name ();
- if (user_name[0] == '<')
+ if (!user_name.empty () && user_name[0] == '<')
{
if (user_name.back () == '>')
m_encoded_name

View File

@ -1,87 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Thu, 25 Mar 2021 10:31:48 -0700
Subject: gdb-rhbz1931344-bfd_seek-elf_read_notes.patch
;; Backport "Save/restore file offset while reading notes in core file"
;; (Keith Seitz, RHBZ 1931344)
A recent bug (RH BZ 1931344) has exposed a bug in the core file
build-ID support that I introduced a while ago. It is pretty
easy to demonstate the problem following a simplified procedure
outlined in that bug:
[shell1]
shell1$ /usr/libexec/qemu-kvm
[shell2]
shell2$ pkill -SEGV -x qemu-kvm
[shell1]
Segmentation fault (core dumped)
Load this core file into GDB without specifying an executable
(an unfortunate Fedora/RHEL-ism), and GDB will inform the user
to install debuginfo for the "missing" executable:
$ gdb -nx -q core.12345
...
Missing separate debuginfo for the main executable file
Try: dnf --enablerepo='*debug*' install /usr/lib/debug/.build-id/e2/e9c66d3117fb2bbb5b2be122f04f2664e5df54
Core was generated by `/usr/libexec/qemu-kvm'.
Program terminated with signal SIGSEGV, Segmentation fault.
...
The suggested build-ID is actaully for gmp not qemu-kvm. The problem
lies in _bfd_elf_core_find_build_id, where we loop over program headers
looking for note segments:
/* Read in program headers and parse notes. */
for (i = 0; i < i_ehdr.e_phnum; ++i, ++i_phdr)
{
Elf_External_Phdr x_phdr;
if (bfd_bread (&x_phdr, sizeof (x_phdr), abfd) != sizeof (x_phdr))
goto fail;
elf_swap_phdr_in (abfd, &x_phdr, i_phdr);
if (i_phdr->p_type == PT_NOTE && i_phdr->p_filesz > 0)
{
elf_read_notes (abfd, offset + i_phdr->p_offset,
i_phdr->p_filesz, i_phdr->p_align);
if (abfd->build_id != NULL)
return TRUE;
}
elf_read_notes uses bfd_seek to forward the stream to the location of
the note segment. When control returns to _bfd_elf_core_fild_build_id,
the stream is no longer in the location looking at program headers, and
all subsequent reads will read from the wrong file offset.
To fix this, this patch marks the stream location and ensures
that it is restored after elf_read_notes is called.
bfd/ChangeLog
2021-03-26 Keith Seitz <keiths@redhat.com>
* elfcore.h (_bfd_elf_core_find_build_id): Seek file
offset of program headers after calling elf_read_notes.
diff --git a/bfd/elfcore.h b/bfd/elfcore.h
--- a/bfd/elfcore.h
+++ b/bfd/elfcore.h
@@ -410,6 +410,13 @@ NAME(_bfd_elf, core_find_build_id)
{
elf_read_notes (abfd, offset + i_phdr->p_offset,
i_phdr->p_filesz, i_phdr->p_align);
+
+ /* Make sure ABFD returns to processing the program headers. */
+ if (bfd_seek (abfd, (file_ptr) (offset + i_ehdr.e_phoff
+ + (i + 1) * sizeof (x_phdr)),
+ SEEK_SET) != 0)
+ goto fail;
+
if (abfd->build_id != NULL)
return TRUE;
}

View File

@ -1,58 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Fri, 19 Mar 2021 11:07:11 -0700
Subject: gdb-rhbz1941080-fix-gdbserver-hang.patch
;; Backport change which fixes gdbserver testing hang on f34 and rawhide.
Fix potential hang during gdbserver testing
We're currently seeing testing of native-extended-gdbserver hang while
testing the x86_64 architecture on both Fedora 34 and Fedora Rawhide.
The test responsible for the hang is gdb.threads/fork-plus-threads.exp.
While there is clearly a problem/bug with this test on F34 and
Rawhide, it's also the case that testing should not hang. This commit
prevents the hang by waiting with the "-nowait" flag in
close_gdbserver.
The -nowait flag is also used in the kill_wait_spawned_process proc in
gdb/testsuite/lib/gdb.exp, so there is precedent for doing this.
There are also 15 other uses of "wait -i" scattered throughout the
test suite. While it's tempting to change these to also use the
-nowait flag, I think it might be safer to defer doing so until we
actually see a problem.
I've tested this patch on Fedora 32, 33, 34, and Rawhide. Results are
comparable on Fedora 32 and 33. On Fedora 34 and Rawhide, with this
commit in place, testing completes when the target_board is
native-extended-gdbserver. On those OSes, when not using this commit,
testing usually hangs due to a problem with
gdb.threads/fork-plus-threads.exp. I've also tested on all of the
mentioned OSes with target_board=native-gdbserver; for that testing,
I achieved comparable results over a number of runs. (Unfortunately
results are rarely identical due to racy tests.)
gdb/testsuite/ChangeLog:
* lib/gdbserver-support.exp (gdbserver_exit): Use the
"-nowait" flag when waiting for gdbserver to exit.
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -418,7 +418,12 @@ proc close_gdbserver {} {
verbose "Quitting GDBserver"
catch "close -i $server_spawn_id"
- catch "wait -i $server_spawn_id"
+
+ # If gdbserver misbehaves, and ignores the close, waiting for it
+ # without the -nowait flag will cause testing to hang. Passing
+ # -nowait makes expect tell Tcl to wait for the process in the
+ # background.
+ catch "wait -nowait -i $server_spawn_id"
unset server_spawn_id
}

View File

@ -1,375 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Mon, 24 May 2021 17:10:28 -0700
Subject: gdb-rhbz1964167-convert-enum-range_type.patch
;; [fortran] Backport Andrew Burgess's commit which changes enum
;; range_type into a bit field enum.
gdb: Convert enum range_type to a bit field enum
The expression range_type enum represents the following ideas:
- Lower bound is set to default,
- Upper bound is set to default,
- Upper bound is exclusive.
There are currently 6 entries in the enum to represent the combination
of all those ideas.
In a future commit I'd like to add stride information to the range,
this could in theory appear with any of the existing enum entries, so
this would take us to 12 enum entries.
This feels like its getting a little out of hand, so in this commit I
switch the range_type enum over to being a flags style enum. There's
one entry to represent no flags being set, then 3 flags to represent
the 3 ideas above. Adding stride information will require adding only
one more enum flag.
I've then gone through and updated the code to handle this change.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* expprint.c (print_subexp_standard): Update to reflect changes to
enum range_type.
(dump_subexp_body_standard): Likewise.
* expression.h (enum range_type): Convert to a bit field enum, and
make the enum unsigned.
* f-exp.y (subrange): Update to reflect changes to enum
range_type.
* f-lang.c (value_f90_subarray): Likewise.
* parse.c (operator_length_standard): Likewise.
* rust-exp.y (rust_parser::convert_ast_to_expression): Likewise.
* rust-lang.c (rust_range): Likewise.
(rust_compute_range): Likewise.
(rust_subscript): Likewise.
diff --git a/gdb/expprint.c b/gdb/expprint.c
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -584,17 +584,13 @@ print_subexp_standard (struct expression *exp, int *pos,
longest_to_int (exp->elts[pc + 1].longconst);
*pos += 2;
- if (range_type == NONE_BOUND_DEFAULT_EXCLUSIVE
- || range_type == LOW_BOUND_DEFAULT_EXCLUSIVE)
+ if (range_type & RANGE_HIGH_BOUND_EXCLUSIVE)
fputs_filtered ("EXCLUSIVE_", stream);
fputs_filtered ("RANGE(", stream);
- if (range_type == HIGH_BOUND_DEFAULT
- || range_type == NONE_BOUND_DEFAULT
- || range_type == NONE_BOUND_DEFAULT_EXCLUSIVE)
+ if (!(range_type & RANGE_LOW_BOUND_DEFAULT))
print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
fputs_filtered ("..", stream);
- if (range_type == LOW_BOUND_DEFAULT
- || range_type == NONE_BOUND_DEFAULT)
+ if (!(range_type & RANGE_HIGH_BOUND_DEFAULT))
print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
fputs_filtered (")", stream);
return;
@@ -1114,36 +1110,19 @@ dump_subexp_body_standard (struct expression *exp,
longest_to_int (exp->elts[elt].longconst);
elt += 2;
- switch (range_type)
- {
- case BOTH_BOUND_DEFAULT:
- fputs_filtered ("Range '..'", stream);
- break;
- case LOW_BOUND_DEFAULT:
- fputs_filtered ("Range '..EXP'", stream);
- break;
- case LOW_BOUND_DEFAULT_EXCLUSIVE:
- fputs_filtered ("ExclusiveRange '..EXP'", stream);
- break;
- case HIGH_BOUND_DEFAULT:
- fputs_filtered ("Range 'EXP..'", stream);
- break;
- case NONE_BOUND_DEFAULT:
- fputs_filtered ("Range 'EXP..EXP'", stream);
- break;
- case NONE_BOUND_DEFAULT_EXCLUSIVE:
- fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream);
- break;
- default:
- fputs_filtered ("Invalid Range!", stream);
- break;
- }
+ if (range_type & RANGE_HIGH_BOUND_EXCLUSIVE)
+ fputs_filtered ("Exclusive", stream);
+ fputs_filtered ("Range '", stream);
+ if (!(range_type & RANGE_LOW_BOUND_DEFAULT))
+ fputs_filtered ("EXP", stream);
+ fputs_filtered ("..", stream);
+ if (!(range_type & RANGE_HIGH_BOUND_DEFAULT))
+ fputs_filtered ("EXP", stream);
+ fputs_filtered ("'", stream);
- if (range_type == HIGH_BOUND_DEFAULT
- || range_type == NONE_BOUND_DEFAULT)
+ if (!(range_type & RANGE_LOW_BOUND_DEFAULT))
elt = dump_subexp (exp, stream, elt);
- if (range_type == LOW_BOUND_DEFAULT
- || range_type == NONE_BOUND_DEFAULT)
+ if (!(range_type & RANGE_HIGH_BOUND_DEFAULT))
elt = dump_subexp (exp, stream, elt);
}
break;
diff --git a/gdb/expression.h b/gdb/expression.h
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -185,22 +185,22 @@ extern void dump_prefix_expression (struct expression *, struct ui_file *);
or inclusive. So we have six sorts of subrange. This enumeration
type is to identify this. */
-enum range_type
+enum range_type : unsigned
{
- /* Neither the low nor the high bound was given -- so this refers to
- the entire available range. */
- BOTH_BOUND_DEFAULT,
- /* The low bound was not given and the high bound is inclusive. */
- LOW_BOUND_DEFAULT,
- /* The high bound was not given and the low bound in inclusive. */
- HIGH_BOUND_DEFAULT,
- /* Both bounds were given and both are inclusive. */
- NONE_BOUND_DEFAULT,
- /* The low bound was not given and the high bound is exclusive. */
- NONE_BOUND_DEFAULT_EXCLUSIVE,
- /* Both bounds were given. The low bound is inclusive and the high
- bound is exclusive. */
- LOW_BOUND_DEFAULT_EXCLUSIVE,
+ /* This is a standard range. Both the lower and upper bounds are
+ defined, and the bounds are inclusive. */
+ RANGE_STANDARD = 0,
+
+ /* The low bound was not given. */
+ RANGE_LOW_BOUND_DEFAULT = 1 << 0,
+
+ /* The high bound was not given. */
+ RANGE_HIGH_BOUND_DEFAULT = 1 << 1,
+
+ /* The high bound of this range is exclusive. */
+ RANGE_HIGH_BOUND_EXCLUSIVE = 1 << 2,
};
+DEF_ENUM_FLAGS_TYPE (enum range_type, range_types);
+
#endif /* !defined (EXPRESSION_H) */
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -287,26 +287,30 @@ arglist : arglist ',' exp %prec ABOVE_COMMA
/* There are four sorts of subrange types in F90. */
subrange: exp ':' exp %prec ABOVE_COMMA
- { write_exp_elt_opcode (pstate, OP_RANGE);
- write_exp_elt_longcst (pstate, NONE_BOUND_DEFAULT);
+ { write_exp_elt_opcode (pstate, OP_RANGE);
+ write_exp_elt_longcst (pstate, RANGE_STANDARD);
write_exp_elt_opcode (pstate, OP_RANGE); }
;
subrange: exp ':' %prec ABOVE_COMMA
{ write_exp_elt_opcode (pstate, OP_RANGE);
- write_exp_elt_longcst (pstate, HIGH_BOUND_DEFAULT);
+ write_exp_elt_longcst (pstate,
+ RANGE_HIGH_BOUND_DEFAULT);
write_exp_elt_opcode (pstate, OP_RANGE); }
;
subrange: ':' exp %prec ABOVE_COMMA
{ write_exp_elt_opcode (pstate, OP_RANGE);
- write_exp_elt_longcst (pstate, LOW_BOUND_DEFAULT);
+ write_exp_elt_longcst (pstate,
+ RANGE_LOW_BOUND_DEFAULT);
write_exp_elt_opcode (pstate, OP_RANGE); }
;
subrange: ':' %prec ABOVE_COMMA
{ write_exp_elt_opcode (pstate, OP_RANGE);
- write_exp_elt_longcst (pstate, BOTH_BOUND_DEFAULT);
+ write_exp_elt_longcst (pstate,
+ (RANGE_LOW_BOUND_DEFAULT
+ | RANGE_HIGH_BOUND_DEFAULT));
write_exp_elt_opcode (pstate, OP_RANGE); }
;
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -131,12 +131,12 @@ value_f90_subarray (struct value *array,
*pos += 3;
- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
+ if (range_type & RANGE_LOW_BOUND_DEFAULT)
low_bound = range->bounds ()->low.const_val ();
else
low_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
+ if (range_type & RANGE_HIGH_BOUND_DEFAULT)
high_bound = range->bounds ()->high.const_val ();
else
high_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
diff --git a/gdb/parse.c b/gdb/parse.c
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -921,21 +921,13 @@ operator_length_standard (const struct expression *expr, int endpos,
range_type = (enum range_type)
longest_to_int (expr->elts[endpos - 2].longconst);
- switch (range_type)
- {
- case LOW_BOUND_DEFAULT:
- case LOW_BOUND_DEFAULT_EXCLUSIVE:
- case HIGH_BOUND_DEFAULT:
- args = 1;
- break;
- case BOTH_BOUND_DEFAULT:
- args = 0;
- break;
- case NONE_BOUND_DEFAULT:
- case NONE_BOUND_DEFAULT_EXCLUSIVE:
- args = 2;
- break;
- }
+ /* Assume the range has 2 arguments (low bound and high bound), then
+ reduce the argument count if any bounds are set to default. */
+ args = 2;
+ if (range_type & RANGE_LOW_BOUND_DEFAULT)
+ --args;
+ if (range_type & RANGE_HIGH_BOUND_DEFAULT)
+ --args;
break;
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -2492,24 +2492,29 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
case OP_RANGE:
{
- enum range_type kind = BOTH_BOUND_DEFAULT;
+ enum range_type kind = (RANGE_HIGH_BOUND_DEFAULT
+ | RANGE_LOW_BOUND_DEFAULT);
if (operation->left.op != NULL)
{
convert_ast_to_expression (operation->left.op, top);
- kind = HIGH_BOUND_DEFAULT;
+ kind &= ~RANGE_LOW_BOUND_DEFAULT;
}
if (operation->right.op != NULL)
{
convert_ast_to_expression (operation->right.op, top);
- if (kind == BOTH_BOUND_DEFAULT)
- kind = (operation->inclusive
- ? LOW_BOUND_DEFAULT : LOW_BOUND_DEFAULT_EXCLUSIVE);
+ if (kind == (RANGE_HIGH_BOUND_DEFAULT | RANGE_LOW_BOUND_DEFAULT))
+ {
+ kind = RANGE_LOW_BOUND_DEFAULT;
+ if (!operation->inclusive)
+ kind |= RANGE_HIGH_BOUND_EXCLUSIVE;
+ }
else
{
- gdb_assert (kind == HIGH_BOUND_DEFAULT);
- kind = (operation->inclusive
- ? NONE_BOUND_DEFAULT : NONE_BOUND_DEFAULT_EXCLUSIVE);
+ gdb_assert (kind == RANGE_HIGH_BOUND_DEFAULT);
+ kind = RANGE_STANDARD;
+ if (!operation->inclusive)
+ kind |= RANGE_HIGH_BOUND_EXCLUSIVE;
}
}
else
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1082,13 +1082,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst);
*pos += 3;
- if (kind == HIGH_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT
- || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
+ if (!(kind & RANGE_LOW_BOUND_DEFAULT))
low = evaluate_subexp (nullptr, exp, pos, noside);
- if (kind == LOW_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT_EXCLUSIVE
- || kind == NONE_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
+ if (!(kind & RANGE_HIGH_BOUND_DEFAULT))
high = evaluate_subexp (nullptr, exp, pos, noside);
- bool inclusive = (kind == NONE_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT);
+ bool inclusive = !(kind & RANGE_HIGH_BOUND_EXCLUSIVE);
if (noside == EVAL_SKIP)
return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
@@ -1171,13 +1169,13 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
static void
rust_compute_range (struct type *type, struct value *range,
LONGEST *low, LONGEST *high,
- enum range_type *kind)
+ range_types *kind)
{
int i;
*low = 0;
*high = 0;
- *kind = BOTH_BOUND_DEFAULT;
+ *kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
if (type->num_fields () == 0)
return;
@@ -1185,15 +1183,15 @@ rust_compute_range (struct type *type, struct value *range,
i = 0;
if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
{
- *kind = HIGH_BOUND_DEFAULT;
+ *kind = RANGE_HIGH_BOUND_DEFAULT;
*low = value_as_long (value_field (range, 0));
++i;
}
if (type->num_fields () > i
&& strcmp (TYPE_FIELD_NAME (type, i), "end") == 0)
{
- *kind = (*kind == BOTH_BOUND_DEFAULT
- ? LOW_BOUND_DEFAULT : NONE_BOUND_DEFAULT);
+ *kind = (*kind == (RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT)
+ ? RANGE_LOW_BOUND_DEFAULT : RANGE_STANDARD);
*high = value_as_long (value_field (range, i));
if (rust_inclusive_range_type_p (type))
@@ -1211,7 +1209,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
struct type *rhstype;
LONGEST low, high_bound;
/* Initialized to appease the compiler. */
- enum range_type kind = BOTH_BOUND_DEFAULT;
+ range_types kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
LONGEST high = 0;
int want_slice = 0;
@@ -1308,8 +1306,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
else
error (_("Cannot subscript non-array type"));
- if (want_slice
- && (kind == BOTH_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT))
+ if (want_slice && (kind & RANGE_LOW_BOUND_DEFAULT))
low = low_bound;
if (low < 0)
error (_("Index less than zero"));
@@ -1327,7 +1324,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
CORE_ADDR addr;
struct value *addrval, *tem;
- if (kind == BOTH_BOUND_DEFAULT || kind == HIGH_BOUND_DEFAULT)
+ if (kind & RANGE_HIGH_BOUND_DEFAULT)
high = high_bound;
if (high < 0)
error (_("High index less than zero"));

File diff suppressed because it is too large Load Diff

View File

@ -1,193 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Mon, 24 May 2021 22:30:32 -0700
Subject: gdb-rhbz1964167-fortran-array-strides-in-expressions.patch
;; [fortran] Backport Andrew Burgess's commit which adds support
;; for array strides in expressions.
gdb/fortran: add support for parsing array strides in expressions
With this commit GDB now understands the syntax of Fortran array
strides, a user can type an expression including an array stride, but
they will only get an error informing them that array strides are not
supported.
This alone is an improvement on what we had before in GDB, better to
give the user a helpful message that a particular feature is not
supported than to just claim a syntax error.
Before:
(gdb) p array (1:10:2, 2:10:2)
A syntax error in expression, near `:2, 2:10:2)'.
Now:
(gdb) p array (1:10:2, 2:10:2)
Fortran array strides are not currently supported
Later commits will allow GDB to handle array strides correctly.
gdb/ChangeLog:
* expprint.c (dump_subexp_body_standard): Print RANGE_HAS_STRIDE.
* expression.h (enum range_type): Add RANGE_HAS_STRIDE.
* f-exp.y (arglist): Allow for a series of subranges.
(subrange): Add cases for subranges with strides.
* f-lang.c (value_f90_subarray): Catch use of array strides and
throw an error.
* parse.c (operator_length_standard): Handle RANGE_HAS_STRIDE.
gdb/testsuite/ChangeLog:
* gdb.fortran/array-slices.exp: Add a new test.
diff --git a/gdb/expprint.c b/gdb/expprint.c
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -1118,12 +1118,16 @@ dump_subexp_body_standard (struct expression *exp,
fputs_filtered ("..", stream);
if (!(range_flag & RANGE_HIGH_BOUND_DEFAULT))
fputs_filtered ("EXP", stream);
+ if (range_flag & RANGE_HAS_STRIDE)
+ fputs_filtered (":EXP", stream);
fputs_filtered ("'", stream);
if (!(range_flag & RANGE_LOW_BOUND_DEFAULT))
elt = dump_subexp (exp, stream, elt);
if (!(range_flag & RANGE_HIGH_BOUND_DEFAULT))
elt = dump_subexp (exp, stream, elt);
+ if (range_flag & RANGE_HAS_STRIDE)
+ elt = dump_subexp (exp, stream, elt);
}
break;
diff --git a/gdb/expression.h b/gdb/expression.h
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -199,6 +199,9 @@ enum range_flag : unsigned
/* The high bound of this range is exclusive. */
RANGE_HIGH_BOUND_EXCLUSIVE = 1 << 2,
+
+ /* The range has a stride. */
+ RANGE_HAS_STRIDE = 1 << 3,
};
DEF_ENUM_FLAGS_TYPE (enum range_flag, range_flags);
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -284,6 +284,10 @@ arglist : arglist ',' exp %prec ABOVE_COMMA
{ pstate->arglist_len++; }
;
+arglist : arglist ',' subrange %prec ABOVE_COMMA
+ { pstate->arglist_len++; }
+ ;
+
/* There are four sorts of subrange types in F90. */
subrange: exp ':' exp %prec ABOVE_COMMA
@@ -314,6 +318,38 @@ subrange: ':' %prec ABOVE_COMMA
write_exp_elt_opcode (pstate, OP_RANGE); }
;
+/* And each of the four subrange types can also have a stride. */
+subrange: exp ':' exp ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_RANGE);
+ write_exp_elt_longcst (pstate, RANGE_HAS_STRIDE);
+ write_exp_elt_opcode (pstate, OP_RANGE); }
+ ;
+
+subrange: exp ':' ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_RANGE);
+ write_exp_elt_longcst (pstate,
+ (RANGE_HIGH_BOUND_DEFAULT
+ | RANGE_HAS_STRIDE));
+ write_exp_elt_opcode (pstate, OP_RANGE); }
+ ;
+
+subrange: ':' exp ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_RANGE);
+ write_exp_elt_longcst (pstate,
+ (RANGE_LOW_BOUND_DEFAULT
+ | RANGE_HAS_STRIDE));
+ write_exp_elt_opcode (pstate, OP_RANGE); }
+ ;
+
+subrange: ':' ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_RANGE);
+ write_exp_elt_longcst (pstate,
+ (RANGE_LOW_BOUND_DEFAULT
+ | RANGE_HIGH_BOUND_DEFAULT
+ | RANGE_HAS_STRIDE));
+ write_exp_elt_opcode (pstate, OP_RANGE); }
+ ;
+
complexnum: exp ',' exp
{ }
;
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -124,7 +124,7 @@ value_f90_subarray (struct value *array,
struct expression *exp, int *pos, enum noside noside)
{
int pc = (*pos) + 1;
- LONGEST low_bound, high_bound;
+ LONGEST low_bound, high_bound, stride;
struct type *range = check_typedef (value_type (array)->index_type ());
enum range_flag range_flag
= (enum range_flag) longest_to_int (exp->elts[pc].longconst);
@@ -141,6 +141,14 @@ value_f90_subarray (struct value *array,
else
high_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
+ if (range_flag & RANGE_HAS_STRIDE)
+ stride = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
+ else
+ stride = 1;
+
+ if (stride != 1)
+ error (_("Fortran array strides are not currently supported"));
+
return value_slice (array, low_bound, high_bound - low_bound + 1);
}
diff --git a/gdb/parse.c b/gdb/parse.c
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -924,6 +924,8 @@ operator_length_standard (const struct expression *expr, int endpos,
/* Assume the range has 2 arguments (low bound and high bound), then
reduce the argument count if any bounds are set to default. */
args = 2;
+ if (range_flag & RANGE_HAS_STRIDE)
+ ++args;
if (range_flag & RANGE_LOW_BOUND_DEFAULT)
--args;
if (range_flag & RANGE_HIGH_BOUND_DEFAULT)
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -66,3 +66,19 @@ foreach result $array_contents msg $message_strings {
}
gdb_continue_to_breakpoint "continue to Final Breakpoint"
+
+# Next test that asking for an array with stride at the CLI gives an
+# error.
+clean_restart ${testfile}
+
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
+ continue
+}
+
+gdb_breakpoint "show"
+gdb_continue_to_breakpoint "show"
+gdb_test "up" ".*"
+gdb_test "p array (1:10:2, 1:10:2)" \
+ "Fortran array strides are not currently supported" \
+ "using array stride gives an error"

View File

@ -1,209 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Mon, 24 May 2021 16:53:22 -0700
Subject: gdb-rhbz1964167-fortran-clean-up-array-expression-evaluation.patch
;; [fortran] Backport Andrew Burgess's commit which cleans up
;; array/string expression evaluation.
gdb/fortran: Clean up array/string expression evaluation
This commit is a refactor of part of the Fortran array and string
handling code.
The current code is split into two blocks, linked, weirdly, with a
goto. After this commit all the code is moved to its own function,
and arrays and strings are now handled using the same code; this will
be useful later when I want to add array stride support where strings
will want to be treated just like arrays, but is a good clean up even
without the array stride work, which is why I'm merging it now.
For now the new function is added as a static within eval.c, even
though the function is Fortran only. A following commit will remove
some of the Fortran specific code from eval.c into one of the Fortran
specific files, including this new function.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* eval.c (fortran_value_subarray): New function, content is taken
from...
(evaluate_subexp_standard): ...here, in two places. Now arrays
and strings both call the new function.
(calc_f77_array_dims): Add header comment, handle strings.
diff --git a/gdb/eval.c b/gdb/eval.c
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1260,6 +1260,67 @@ is_integral_or_integral_reference (struct type *type)
&& is_integral_type (TYPE_TARGET_TYPE (type)));
}
+/* Called from evaluate_subexp_standard to perform array indexing, and
+ sub-range extraction, for Fortran. As well as arrays this function
+ also handles strings as they can be treated like arrays of characters.
+ ARRAY is the array or string being accessed. EXP, POS, and NOSIDE are
+ as for evaluate_subexp_standard, and NARGS is the number of arguments
+ in this access (e.g. 'array (1,2,3)' would be NARGS 3). */
+
+static struct value *
+fortran_value_subarray (struct value *array, struct expression *exp,
+ int *pos, int nargs, enum noside noside)
+{
+ if (exp->elts[*pos].opcode == OP_RANGE)
+ return value_f90_subarray (array, exp, pos, noside);
+
+ if (noside == EVAL_SKIP)
+ {
+ skip_undetermined_arglist (nargs, exp, pos, noside);
+ /* Return the dummy value with the correct type. */
+ return array;
+ }
+
+ LONGEST subscript_array[MAX_FORTRAN_DIMS];
+ int ndimensions = 1;
+ struct type *type = check_typedef (value_type (array));
+
+ if (nargs > MAX_FORTRAN_DIMS)
+ error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
+
+ ndimensions = calc_f77_array_dims (type);
+
+ if (nargs != ndimensions)
+ error (_("Wrong number of subscripts"));
+
+ gdb_assert (nargs > 0);
+
+ /* Now that we know we have a legal array subscript expression let us
+ actually find out where this element exists in the array. */
+
+ /* Take array indices left to right. */
+ for (int i = 0; i < nargs; i++)
+ {
+ /* Evaluate each subscript; it must be a legal integer in F77. */
+ value *arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
+
+ /* Fill in the subscript array. */
+ subscript_array[i] = value_as_long (arg2);
+ }
+
+ /* Internal type of array is arranged right to left. */
+ for (int i = nargs; i > 0; i--)
+ {
+ struct type *array_type = check_typedef (value_type (array));
+ LONGEST index = subscript_array[i - 1];
+
+ array = value_subscripted_rvalue (array, index,
+ f77_get_lowerbound (array_type));
+ }
+
+ return array;
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -1953,33 +2014,8 @@ evaluate_subexp_standard (struct type *expect_type,
switch (code)
{
case TYPE_CODE_ARRAY:
- if (exp->elts[*pos].opcode == OP_RANGE)
- return value_f90_subarray (arg1, exp, pos, noside);
- else
- {
- if (noside == EVAL_SKIP)
- {
- skip_undetermined_arglist (nargs, exp, pos, noside);
- /* Return the dummy value with the correct type. */
- return arg1;
- }
- goto multi_f77_subscript;
- }
-
case TYPE_CODE_STRING:
- if (exp->elts[*pos].opcode == OP_RANGE)
- return value_f90_subarray (arg1, exp, pos, noside);
- else
- {
- if (noside == EVAL_SKIP)
- {
- skip_undetermined_arglist (nargs, exp, pos, noside);
- /* Return the dummy value with the correct type. */
- return arg1;
- }
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
- return value_subscript (arg1, value_as_long (arg2));
- }
+ return fortran_value_subarray (arg1, exp, pos, nargs, noside);
case TYPE_CODE_PTR:
case TYPE_CODE_FUNC:
@@ -2400,49 +2436,6 @@ evaluate_subexp_standard (struct type *expect_type,
}
return (arg1);
- multi_f77_subscript:
- {
- LONGEST subscript_array[MAX_FORTRAN_DIMS];
- int ndimensions = 1, i;
- struct value *array = arg1;
-
- if (nargs > MAX_FORTRAN_DIMS)
- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
-
- ndimensions = calc_f77_array_dims (type);
-
- if (nargs != ndimensions)
- error (_("Wrong number of subscripts"));
-
- gdb_assert (nargs > 0);
-
- /* Now that we know we have a legal array subscript expression
- let us actually find out where this element exists in the array. */
-
- /* Take array indices left to right. */
- for (i = 0; i < nargs; i++)
- {
- /* Evaluate each subscript; it must be a legal integer in F77. */
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
-
- /* Fill in the subscript array. */
-
- subscript_array[i] = value_as_long (arg2);
- }
-
- /* Internal type of array is arranged right to left. */
- for (i = nargs; i > 0; i--)
- {
- struct type *array_type = check_typedef (value_type (array));
- LONGEST index = subscript_array[i - 1];
-
- array = value_subscripted_rvalue (array, index,
- f77_get_lowerbound (array_type));
- }
-
- return array;
- }
-
case BINOP_LOGICAL_AND:
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
if (noside == EVAL_SKIP)
@@ -3354,12 +3347,17 @@ parse_and_eval_type (char *p, int length)
return expr->elts[1].type;
}
+/* Return the number of dimensions for a Fortran array or string. */
+
int
calc_f77_array_dims (struct type *array_type)
{
int ndimen = 1;
struct type *tmp_type;
+ if ((array_type->code () == TYPE_CODE_STRING))
+ return 1;
+
if ((array_type->code () != TYPE_CODE_ARRAY))
error (_("Can't get dimensions for a non-array type"));

View File

@ -1,128 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Tue, 25 May 2021 17:34:57 -0700
Subject: gdb-rhbz1964167-fortran-fix-type-format-mismatch-in-f-lang.c.patch
;; [fortran] Backport Simon Marchi's commit which fixes a 32-bit build
;; problem in gdb/f-lang.c.
gdb: fix format string warnings in f-lang.c
I get a bunch of these warnings when compiling for i386 (32-bit):
CXX f-lang.o
/home/simark/src/binutils-gdb/gdb/f-lang.c: In function 'value* fortran_value_subarray(value*, expression*, int*, int, noside)':
/home/simark/src/binutils-gdb/gdb/f-lang.c:453:48: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'LONGEST' {aka 'long long int'} [-Werror=format=]
453 | debug_printf ("| | |-> Low bound: %ld\n", lb);
| ~~^ ~~
| | |
| | LONGEST {aka long long int}
| long int
| %lld
Fix them by using plongest/pulongest.
gdb/ChangeLog:
* f-lang.c (fortran_value_subarray): Use plongest/pulongest.
Change-Id: I666ead5593653d5a1a3dab2ffdc72942c928c7d2
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -463,21 +463,21 @@ fortran_value_subarray (struct value *array, struct expression *exp,
std::string str = type_to_string (dim_type);
debug_printf ("| |-> Type: %s\n", str.c_str ());
debug_printf ("| |-> Array:\n");
- debug_printf ("| | |-> Low bound: %ld\n", lb);
- debug_printf ("| | |-> High bound: %ld\n", ub);
- debug_printf ("| | |-> Bit stride: %ld\n", sd);
- debug_printf ("| | |-> Byte stride: %ld\n", sd / 8);
- debug_printf ("| | |-> Type size: %ld\n",
- TYPE_LENGTH (dim_type));
- debug_printf ("| | '-> Target type size: %ld\n",
- TYPE_LENGTH (target_type));
+ debug_printf ("| | |-> Low bound: %s\n", plongest (lb));
+ debug_printf ("| | |-> High bound: %s\n", plongest (ub));
+ debug_printf ("| | |-> Bit stride: %s\n", plongest (sd));
+ debug_printf ("| | |-> Byte stride: %s\n", plongest (sd / 8));
+ debug_printf ("| | |-> Type size: %s\n",
+ pulongest (TYPE_LENGTH (dim_type)));
+ debug_printf ("| | '-> Target type size: %s\n",
+ pulongest (TYPE_LENGTH (target_type)));
debug_printf ("| |-> Accessing:\n");
- debug_printf ("| | |-> Low bound: %ld\n",
- low);
- debug_printf ("| | |-> High bound: %ld\n",
- high);
- debug_printf ("| | '-> Element stride: %ld\n",
- stride);
+ debug_printf ("| | |-> Low bound: %s\n",
+ plongest (low));
+ debug_printf ("| | |-> High bound: %s\n",
+ plongest (high));
+ debug_printf ("| | '-> Element stride: %s\n",
+ plongest (stride));
}
/* Check the user hasn't asked for something invalid. */
@@ -519,13 +519,17 @@ fortran_value_subarray (struct value *array, struct expression *exp,
if (fortran_array_slicing_debug)
{
debug_printf ("| '-> Results:\n");
- debug_printf ("| |-> Offset = %ld\n", offset);
- debug_printf ("| |-> Elements = %ld\n", e_count);
- debug_printf ("| |-> Low bound = %ld\n", new_low);
- debug_printf ("| |-> High bound = %ld\n", new_high);
- debug_printf ("| |-> Byte stride = %ld\n", new_stride);
- debug_printf ("| |-> Last element = %ld\n", last_elem);
- debug_printf ("| |-> Remainder = %ld\n", remainder);
+ debug_printf ("| |-> Offset = %s\n", plongest (offset));
+ debug_printf ("| |-> Elements = %s\n", plongest (e_count));
+ debug_printf ("| |-> Low bound = %s\n", plongest (new_low));
+ debug_printf ("| |-> High bound = %s\n",
+ plongest (new_high));
+ debug_printf ("| |-> Byte stride = %s\n",
+ plongest (new_stride));
+ debug_printf ("| |-> Last element = %s\n",
+ plongest (last_elem));
+ debug_printf ("| |-> Remainder = %s\n",
+ plongest (remainder));
debug_printf ("| '-> Contiguous = %s\n",
(is_dim_contiguous ? "Yes" : "No"));
}
@@ -561,14 +565,16 @@ fortran_value_subarray (struct value *array, struct expression *exp,
std::string str = type_to_string (dim_type);
debug_printf ("| |-> Type: %s\n", str.c_str ());
debug_printf ("| |-> Array:\n");
- debug_printf ("| | |-> Low bound: %ld\n", lb);
- debug_printf ("| | |-> High bound: %ld\n", ub);
- debug_printf ("| | |-> Byte stride: %ld\n", sd);
- debug_printf ("| | |-> Type size: %ld\n", TYPE_LENGTH (dim_type));
- debug_printf ("| | '-> Target type size: %ld\n",
- TYPE_LENGTH (target_type));
+ debug_printf ("| | |-> Low bound: %s\n", plongest (lb));
+ debug_printf ("| | |-> High bound: %s\n", plongest (ub));
+ debug_printf ("| | |-> Byte stride: %s\n", plongest (sd));
+ debug_printf ("| | |-> Type size: %s\n",
+ pulongest (TYPE_LENGTH (dim_type)));
+ debug_printf ("| | '-> Target type size: %s\n",
+ pulongest (TYPE_LENGTH (target_type)));
debug_printf ("| '-> Accessing:\n");
- debug_printf ("| '-> Index: %ld\n", index);
+ debug_printf ("| '-> Index: %s\n",
+ plongest (index));
}
/* If the array has actual content then check the index is in
@@ -625,7 +631,8 @@ fortran_value_subarray (struct value *array, struct expression *exp,
debug_printf ("'-> Final result:\n");
debug_printf (" |-> Type: %s\n",
type_to_string (array_slice_type).c_str ());
- debug_printf (" |-> Total offset: %ld\n", total_offset);
+ debug_printf (" |-> Total offset: %s\n",
+ plongest (total_offset));
debug_printf (" |-> Base address: %s\n",
core_addr_to_string (value_address (array)));
debug_printf (" '-> Contiguous = %s\n",

View File

@ -1,224 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Mon, 24 May 2021 17:15:27 -0700
Subject: gdb-rhbz1964167-fortran-range_type-to-range_flag.patch
;; [fortran] Backport Andrew Burgess's commit which renames enum
;; range_type to enum range_flag.
gdb: rename 'enum range_type' to 'enum range_flag'
To avoid confusion with other parts of GDB relating to types and
ranges, rename this enum to make it clearer that it is a set of
individual flags rather than an enumeration of different types of
range.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* expprint.c (print_subexp_standard): Change enum range_type to
range_flag and rename variables to match.
(dump_subexp_body_standard): Likewise.
* expression.h (enum range_type): Rename to...
(enum range_flag): ...this.
(range_types): Rename to...
(range_flags): ...this.
* f-lang.c (value_f90_subarray): Change enum range_type to
range_flag and rename variables to match.
* parse.c (operator_length_standard): Likewise.
* rust-exp.y (rust_parser::convert_ast_to_expression): Change enum
range_type to range_flag.
* rust-lang.c (rust_evaluate_funcall): Likewise.
(rust_range): Likewise.
(rust_compute_range): Likewise.
(rust_subscript): Likewise.
diff --git a/gdb/expprint.c b/gdb/expprint.c
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -578,19 +578,19 @@ print_subexp_standard (struct expression *exp, int *pos,
case OP_RANGE:
{
- enum range_type range_type;
+ enum range_flag range_flag;
- range_type = (enum range_type)
+ range_flag = (enum range_flag)
longest_to_int (exp->elts[pc + 1].longconst);
*pos += 2;
- if (range_type & RANGE_HIGH_BOUND_EXCLUSIVE)
+ if (range_flag & RANGE_HIGH_BOUND_EXCLUSIVE)
fputs_filtered ("EXCLUSIVE_", stream);
fputs_filtered ("RANGE(", stream);
- if (!(range_type & RANGE_LOW_BOUND_DEFAULT))
+ if (!(range_flag & RANGE_LOW_BOUND_DEFAULT))
print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
fputs_filtered ("..", stream);
- if (!(range_type & RANGE_HIGH_BOUND_DEFAULT))
+ if (!(range_flag & RANGE_HIGH_BOUND_DEFAULT))
print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
fputs_filtered (")", stream);
return;
@@ -1104,25 +1104,25 @@ dump_subexp_body_standard (struct expression *exp,
break;
case OP_RANGE:
{
- enum range_type range_type;
+ enum range_flag range_flag;
- range_type = (enum range_type)
+ range_flag = (enum range_flag)
longest_to_int (exp->elts[elt].longconst);
elt += 2;
- if (range_type & RANGE_HIGH_BOUND_EXCLUSIVE)
+ if (range_flag & RANGE_HIGH_BOUND_EXCLUSIVE)
fputs_filtered ("Exclusive", stream);
fputs_filtered ("Range '", stream);
- if (!(range_type & RANGE_LOW_BOUND_DEFAULT))
+ if (!(range_flag & RANGE_LOW_BOUND_DEFAULT))
fputs_filtered ("EXP", stream);
fputs_filtered ("..", stream);
- if (!(range_type & RANGE_HIGH_BOUND_DEFAULT))
+ if (!(range_flag & RANGE_HIGH_BOUND_DEFAULT))
fputs_filtered ("EXP", stream);
fputs_filtered ("'", stream);
- if (!(range_type & RANGE_LOW_BOUND_DEFAULT))
+ if (!(range_flag & RANGE_LOW_BOUND_DEFAULT))
elt = dump_subexp (exp, stream, elt);
- if (!(range_type & RANGE_HIGH_BOUND_DEFAULT))
+ if (!(range_flag & RANGE_HIGH_BOUND_DEFAULT))
elt = dump_subexp (exp, stream, elt);
}
break;
diff --git a/gdb/expression.h b/gdb/expression.h
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -185,7 +185,7 @@ extern void dump_prefix_expression (struct expression *, struct ui_file *);
or inclusive. So we have six sorts of subrange. This enumeration
type is to identify this. */
-enum range_type : unsigned
+enum range_flag : unsigned
{
/* This is a standard range. Both the lower and upper bounds are
defined, and the bounds are inclusive. */
@@ -201,6 +201,6 @@ enum range_type : unsigned
RANGE_HIGH_BOUND_EXCLUSIVE = 1 << 2,
};
-DEF_ENUM_FLAGS_TYPE (enum range_type, range_types);
+DEF_ENUM_FLAGS_TYPE (enum range_flag, range_flags);
#endif /* !defined (EXPRESSION_H) */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -126,17 +126,17 @@ value_f90_subarray (struct value *array,
int pc = (*pos) + 1;
LONGEST low_bound, high_bound;
struct type *range = check_typedef (value_type (array)->index_type ());
- enum range_type range_type
- = (enum range_type) longest_to_int (exp->elts[pc].longconst);
+ enum range_flag range_flag
+ = (enum range_flag) longest_to_int (exp->elts[pc].longconst);
*pos += 3;
- if (range_type & RANGE_LOW_BOUND_DEFAULT)
+ if (range_flag & RANGE_LOW_BOUND_DEFAULT)
low_bound = range->bounds ()->low.const_val ();
else
low_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
- if (range_type & RANGE_HIGH_BOUND_DEFAULT)
+ if (range_flag & RANGE_HIGH_BOUND_DEFAULT)
high_bound = range->bounds ()->high.const_val ();
else
high_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
diff --git a/gdb/parse.c b/gdb/parse.c
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -774,7 +774,7 @@ operator_length_standard (const struct expression *expr, int endpos,
{
int oplen = 1;
int args = 0;
- enum range_type range_type;
+ enum range_flag range_flag;
int i;
if (endpos < 1)
@@ -918,15 +918,15 @@ operator_length_standard (const struct expression *expr, int endpos,
case OP_RANGE:
oplen = 3;
- range_type = (enum range_type)
+ range_flag = (enum range_flag)
longest_to_int (expr->elts[endpos - 2].longconst);
/* Assume the range has 2 arguments (low bound and high bound), then
reduce the argument count if any bounds are set to default. */
args = 2;
- if (range_type & RANGE_LOW_BOUND_DEFAULT)
+ if (range_flag & RANGE_LOW_BOUND_DEFAULT)
--args;
- if (range_type & RANGE_HIGH_BOUND_DEFAULT)
+ if (range_flag & RANGE_HIGH_BOUND_DEFAULT)
--args;
break;
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -2492,7 +2492,7 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
case OP_RANGE:
{
- enum range_type kind = (RANGE_HIGH_BOUND_DEFAULT
+ unsigned int kind = (RANGE_HIGH_BOUND_DEFAULT
| RANGE_LOW_BOUND_DEFAULT);
if (operation->left.op != NULL)
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1070,7 +1070,6 @@ rust_evaluate_funcall (struct expression *exp, int *pos, enum noside noside)
static struct value *
rust_range (struct expression *exp, int *pos, enum noside noside)
{
- enum range_type kind;
struct value *low = NULL, *high = NULL;
struct value *addrval, *result;
CORE_ADDR addr;
@@ -1079,7 +1078,8 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
struct type *temp_type;
const char *name;
- kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst);
+ auto kind
+ = (enum range_flag) longest_to_int (exp->elts[*pos + 1].longconst);
*pos += 3;
if (!(kind & RANGE_LOW_BOUND_DEFAULT))
@@ -1169,7 +1169,7 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
static void
rust_compute_range (struct type *type, struct value *range,
LONGEST *low, LONGEST *high,
- range_types *kind)
+ range_flags *kind)
{
int i;
@@ -1209,7 +1209,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
struct type *rhstype;
LONGEST low, high_bound;
/* Initialized to appease the compiler. */
- range_types kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
+ range_flags kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
LONGEST high = 0;
int want_slice = 0;

View File

@ -1,137 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Mon, 24 May 2021 17:07:36 -0700
Subject: gdb-rhbz1964167-fortran-whitespace_array.patch
;; [fortran] Backport Andrew Burgess's commit which eliminates undesirable
;; whitespace when printing arrays.
gdb/fortran: Change whitespace when printing arrays
This commit makes the whitespace usage when printing Fortran arrays
more consistent, and more inline with how we print C arrays.
Currently a 2 dimensional Fotran array is printed like this, I find
the marked whitespace unpleasant:
(( 1, 2, 3) ( 4, 5, 6) )
^ ^ ^
After this commit the same array is printed like this:
((1, 2, 3) (4, 5, 6))
Which seems more inline with how we print C arrays, in the case of C
arrays we don't add extra whitespace before the first element.
gdb/ChangeLog:
* f-valprint.c (f77_print_array_1): Adjust printing of whitespace
for arrays.
gdb/testsuite/ChangeLog:
* gdb.fortran/array-slices.exp: Update expected results.
* gdb.fortran/class-allocatable-array.exp: Likewise.
* gdb.fortran/multi-dim.exp: Likewise.
* gdb.fortran/vla-type.exp: Likewise.
* gdb.mi/mi-vla-fortran.exp: Likewise.
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -137,14 +137,17 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
(TYPE_TARGET_TYPE (type), value_contents_for_printing_const (val)
+ offs, addr + offs);
- fprintf_filtered (stream, "( ");
+ fprintf_filtered (stream, "(");
f77_print_array_1 (nss + 1, ndimensions, value_type (subarray),
value_contents_for_printing (subarray),
value_embedded_offset (subarray),
value_address (subarray),
stream, recurse, subarray, options, elts);
offs += byte_stride;
- fprintf_filtered (stream, ") ");
+ fprintf_filtered (stream, ")");
+
+ if (i < upperbound)
+ fprintf_filtered (stream, " ");
}
if (*elts >= options->print_max && i < upperbound)
fprintf_filtered (stream, "...");
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -38,14 +38,14 @@ gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
set array_contents \
[list \
- " = \\(\\( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\) \\( 11, 12, 13, 14, 15, 16, 17, 18, 19, 20\\) \\( 21, 22, 23, 24, 25, 26, 27, 28, 29, 30\\) \\( 31, 32, 33, 34, 35, 36, 37, 38, 39, 40\\) \\( 41, 42, 43, 44, 45, 46, 47, 48, 49, 50\\) \\( 51, 52, 53, 54, 55, 56, 57, 58, 59, 60\\) \\( 61, 62, 63, 64, 65, 66, 67, 68, 69, 70\\) \\( 71, 72, 73, 74, 75, 76, 77, 78, 79, 80\\) \\( 81, 82, 83, 84, 85, 86, 87, 88, 89, 90\\) \\( 91, 92, 93, 94, 95, 96, 97, 98, 99, 100\\) \\)" \
- " = \\(\\( 1, 2, 3, 4, 5\\) \\( 11, 12, 13, 14, 15\\) \\( 21, 22, 23, 24, 25\\) \\( 31, 32, 33, 34, 35\\) \\( 41, 42, 43, 44, 45\\) \\)" \
- " = \\(\\( 1, 3, 5, 7, 9\\) \\( 21, 23, 25, 27, 29\\) \\( 41, 43, 45, 47, 49\\) \\( 61, 63, 65, 67, 69\\) \\( 81, 83, 85, 87, 89\\) \\)" \
- " = \\(\\( 1, 4, 7, 10\\) \\( 21, 24, 27, 30\\) \\( 41, 44, 47, 50\\) \\( 61, 64, 67, 70\\) \\( 81, 84, 87, 90\\) \\)" \
- " = \\(\\( 1, 5, 9\\) \\( 31, 35, 39\\) \\( 61, 65, 69\\) \\( 91, 95, 99\\) \\)" \
- " = \\(\\( -26, -25, -24, -23, -22, -21, -20, -19, -18, -17\\) \\( -19, -18, -17, -16, -15, -14, -13, -12, -11, -10\\) \\( -12, -11, -10, -9, -8, -7, -6, -5, -4, -3\\) \\( -5, -4, -3, -2, -1, 0, 1, 2, 3, 4\\) \\( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11\\) \\( 9, 10, 11, 12, 13, 14, 15, 16, 17, 18\\) \\( 16, 17, 18, 19, 20, 21, 22, 23, 24, 25\\) \\( 23, 24, 25, 26, 27, 28, 29, 30, 31, 32\\) \\( 30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\) \\( 37, 38, 39, 40, 41, 42, 43, 44, 45, 46\\) \\)" \
- " = \\(\\( -26, -25, -24, -23, -22, -21\\) \\( -19, -18, -17, -16, -15, -14\\) \\( -12, -11, -10, -9, -8, -7\\) \\)" \
- " = \\(\\( -26, -24, -22, -20, -18\\) \\( -5, -3, -1, 1, 3\\) \\( 16, 18, 20, 22, 24\\) \\( 37, 39, 41, 43, 45\\) \\)" ]
+ " = \\(\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\) \\(11, 12, 13, 14, 15, 16, 17, 18, 19, 20\\) \\(21, 22, 23, 24, 25, 26, 27, 28, 29, 30\\) \\(31, 32, 33, 34, 35, 36, 37, 38, 39, 40\\) \\(41, 42, 43, 44, 45, 46, 47, 48, 49, 50\\) \\(51, 52, 53, 54, 55, 56, 57, 58, 59, 60\\) \\(61, 62, 63, 64, 65, 66, 67, 68, 69, 70\\) \\(71, 72, 73, 74, 75, 76, 77, 78, 79, 80\\) \\(81, 82, 83, 84, 85, 86, 87, 88, 89, 90\\) \\(91, 92, 93, 94, 95, 96, 97, 98, 99, 100\\)\\)" \
+ " = \\(\\(1, 2, 3, 4, 5\\) \\(11, 12, 13, 14, 15\\) \\(21, 22, 23, 24, 25\\) \\(31, 32, 33, 34, 35\\) \\(41, 42, 43, 44, 45\\)\\)" \
+ " = \\(\\(1, 3, 5, 7, 9\\) \\(21, 23, 25, 27, 29\\) \\(41, 43, 45, 47, 49\\) \\(61, 63, 65, 67, 69\\) \\(81, 83, 85, 87, 89\\)\\)" \
+ " = \\(\\(1, 4, 7, 10\\) \\(21, 24, 27, 30\\) \\(41, 44, 47, 50\\) \\(61, 64, 67, 70\\) \\(81, 84, 87, 90\\)\\)" \
+ " = \\(\\(1, 5, 9\\) \\(31, 35, 39\\) \\(61, 65, 69\\) \\(91, 95, 99\\)\\)" \
+ " = \\(\\(-26, -25, -24, -23, -22, -21, -20, -19, -18, -17\\) \\(-19, -18, -17, -16, -15, -14, -13, -12, -11, -10\\) \\(-12, -11, -10, -9, -8, -7, -6, -5, -4, -3\\) \\(-5, -4, -3, -2, -1, 0, 1, 2, 3, 4\\) \\(2, 3, 4, 5, 6, 7, 8, 9, 10, 11\\) \\(9, 10, 11, 12, 13, 14, 15, 16, 17, 18\\) \\(16, 17, 18, 19, 20, 21, 22, 23, 24, 25\\) \\(23, 24, 25, 26, 27, 28, 29, 30, 31, 32\\) \\(30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\) \\(37, 38, 39, 40, 41, 42, 43, 44, 45, 46\\)\\)" \
+ " = \\(\\(-26, -25, -24, -23, -22, -21\\) \\(-19, -18, -17, -16, -15, -14\\) \\(-12, -11, -10, -9, -8, -7\\)\\)" \
+ " = \\(\\(-26, -24, -22, -20, -18\\) \\(-5, -3, -1, 1, 3\\) \\(16, 18, 20, 22, 24\\) \\(37, 39, 41, 43, 45\\)\\)" ]
set message_strings \
[list \
diff --git a/gdb/testsuite/gdb.fortran/class-allocatable-array.exp b/gdb/testsuite/gdb.fortran/class-allocatable-array.exp
--- a/gdb/testsuite/gdb.fortran/class-allocatable-array.exp
+++ b/gdb/testsuite/gdb.fortran/class-allocatable-array.exp
@@ -40,4 +40,4 @@ gdb_continue_to_breakpoint "Break Here"
# cetainly going to fail.
gdb_test "print this" " = \\( _data = \[^\r\n\]+, _vptr = \[^\r\n\]+\\)"
gdb_test "print this%_data" " = \\(PTR TO -> \\( Type test_type \\)\\) \[^\r\n\]+"
-gdb_test "print this%_data%b" " = \\(\\( 1, 2, 3\\) \\( 4, 5, 6\\) \\)"
+gdb_test "print this%_data%b" " = \\(\\(1, 2, 3\\) \\(4, 5, 6\\)\\)"
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -57,7 +57,7 @@ gdb_test "print foo(3,3,4)" \
"print an invalid array index (3,3,4)"
gdb_test "print foo" \
- { = \(\( \( 10, 10\) \( 10, 10\) \( 10, 10\) \) \( \( 10, 10\) \( 10, 10\) \( 10, 10\) \) \( \( 10, 10\) \( 10, 10\) \( 10, 10\) \) \( \( 10, 10\) \( 10, 10\) \( 10, 20\) \) \)} \
+ { = \(\(\(10, 10\) \(10, 10\) \(10, 10\)\) \(\(10, 10\) \(10, 10\) \(10, 10\)\) \(\(10, 10\) \(10, 10\) \(10, 10\)\) \(\(10, 10\) \(10, 10\) \(10, 20\)\)\)} \
"print full contents of the array"
gdb_breakpoint [gdb_get_line_number "break-variable"]
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -66,9 +66,9 @@ gdb_test "ptype twov" \
"\\s+$int, allocatable :: ivla1\\\(5,12,99\\\)" \
"\\s+$int, allocatable :: ivla2\\\(9,12\\\)" \
"End Type two" ]
-gdb_test "print twov" " = \\\( ivla1 = \\\(\\\( \\\( 1, 1, 1, 1, 1\\\)\
- \\\( 1, 1, 321, 1, 1\\\)\
- \\\( 1, 1, 1, 1, 1\\\) .*"
+gdb_test "print twov" " = \\\( ivla1 = \\\(\\\(\\\(1, 1, 1, 1, 1\\\)\
+ \\\(1, 1, 321, 1, 1\\\)\
+ \\\(1, 1, 1, 1, 1\\\) .*"
# Check type with attribute at beginn of type
gdb_breakpoint [gdb_get_line_number "threev-filled"]
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -180,7 +180,7 @@ mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
mi_gdb_test "590-data-evaluate-expression pvla2" \
- "590\\^done,value=\"\\(\\( 2, 2, 2, 2, 2\\) \\( 2, 2, 2, 2, 2\\) \\)\"" \
+ "590\\^done,value=\"\\(\\(2, 2, 2, 2, 2\\) \\(2, 2, 2, 2, 2\\)\\)\"" \
"evaluate associated vla"
mi_create_varobj_checked pvla2_associated pvla2 \

View File

@ -1,787 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Mon, 24 May 2021 17:00:17 -0700
Subject: gdb-rhbz1964167-move-fortran-expr-handling.patch
;; [fortran] Backport Andrew Burgess's commit which moves Fortran
;; expression handling to f-lang.c.
gdb/fortran: Move Fortran expression handling into f-lang.c
The Fortran specific OP_F77_UNDETERMINED_ARGLIST is currently handled
in the generic expression handling code. There's no reason why this
should be the case, so this commit moves handling of this into Fortran
specific files.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* eval.c: Remove 'f-lang.h' include.
(value_f90_subarray): Moved to f-lang.c.
(eval_call): Renamed to...
(evaluate_subexp_do_call): ...this, is no longer static, header
comment moved into header file.
(evaluate_funcall): Update call to eval_call.
(skip_undetermined_arglist): Moved to f-lang.c.
(fortran_value_subarray): Likewise.
(evaluate_subexp_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to evaluate_subexp_f.
(calc_f77_array_dims): Moved to f-lang.c
* expprint.c (print_subexp_funcall): New function.
(print_subexp_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to print_subexp_f, OP_FUNCALL uses new function.
(dump_subexp_body_funcall): New function.
(dump_subexp_body_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to dump_subexp_f, OP_FUNCALL uses new function.
* expression.h (evaluate_subexp_do_call): Declare.
* f-lang.c (value_f90_subarray): Moved from eval.c.
(skip_undetermined_arglist): Likewise.
(calc_f77_array_dims): Likewise.
(fortran_value_subarray): Likewise.
(evaluate_subexp_f): Add OP_F77_UNDETERMINED_ARGLIST support.
(operator_length_f): Likewise.
(print_subexp_f): Likewise.
(dump_subexp_body_f): Likewise.
* fortran-operator.def (OP_F77_UNDETERMINED_ARGLIST): Move
declaration of this operation to here.
* parse.c (operator_length_standard): OP_F77_UNDETERMINED_ARGLIST
support moved to operator_length_f.
* parser-defs.h (dump_subexp_body_funcall): Declare.
(print_subexp_funcall): Declare.
* std-operator.def (OP_F77_UNDETERMINED_ARGLIST): Moved to
fortran-operator.def.
diff --git a/gdb/eval.c b/gdb/eval.c
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -26,7 +26,6 @@
#include "frame.h"
#include "gdbthread.h"
#include "language.h" /* For CAST_IS_CONVERSION. */
-#include "f-lang.h" /* For array bound stuff. */
#include "cp-abi.h"
#include "infcall.h"
#include "objc-lang.h"
@@ -371,32 +370,6 @@ init_array_element (struct value *array, struct value *element,
return index;
}
-static struct value *
-value_f90_subarray (struct value *array,
- struct expression *exp, int *pos, enum noside noside)
-{
- int pc = (*pos) + 1;
- LONGEST low_bound, high_bound;
- struct type *range = check_typedef (value_type (array)->index_type ());
- enum range_type range_type
- = (enum range_type) longest_to_int (exp->elts[pc].longconst);
-
- *pos += 3;
-
- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
- low_bound = range->bounds ()->low.const_val ();
- else
- low_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
-
- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
- high_bound = range->bounds ()->high.const_val ();
- else
- high_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
-
- return value_slice (array, low_bound, high_bound - low_bound + 1);
-}
-
-
/* Promote value ARG1 as appropriate before performing a unary operation
on this argument.
If the result is not appropriate for any particular language then it
@@ -749,17 +722,13 @@ eval_skip_value (expression *exp)
return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
}
-/* Evaluate a function call. The function to be called is in
- ARGVEC[0] and the arguments passed to the function are in
- ARGVEC[1..NARGS]. FUNCTION_NAME is the name of the function, if
- known. DEFAULT_RETURN_TYPE is used as the function's return type
- if the return type is unknown. */
+/* See expression.h. */
-static value *
-eval_call (expression *exp, enum noside noside,
- int nargs, value **argvec,
- const char *function_name,
- type *default_return_type)
+value *
+evaluate_subexp_do_call (expression *exp, enum noside noside,
+ int nargs, value **argvec,
+ const char *function_name,
+ type *default_return_type)
{
if (argvec[0] == NULL)
error (_("Cannot evaluate function -- may be inlined"));
@@ -1230,20 +1199,8 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos,
/* Nothing to be done; argvec already correctly set up. */
}
- return eval_call (exp, noside, nargs, argvec, var_func_name, expect_type);
-}
-
-/* Helper for skipping all the arguments in an undetermined argument list.
- This function was designed for use in the OP_F77_UNDETERMINED_ARGLIST
- case of evaluate_subexp_standard as multiple, but not all, code paths
- require a generic skip. */
-
-static void
-skip_undetermined_arglist (int nargs, struct expression *exp, int *pos,
- enum noside noside)
-{
- for (int i = 0; i < nargs; ++i)
- evaluate_subexp (nullptr, exp, pos, noside);
+ return evaluate_subexp_do_call (exp, noside, nargs, argvec,
+ var_func_name, expect_type);
}
/* Return true if type is integral or reference to integral */
@@ -1260,67 +1217,6 @@ is_integral_or_integral_reference (struct type *type)
&& is_integral_type (TYPE_TARGET_TYPE (type)));
}
-/* Called from evaluate_subexp_standard to perform array indexing, and
- sub-range extraction, for Fortran. As well as arrays this function
- also handles strings as they can be treated like arrays of characters.
- ARRAY is the array or string being accessed. EXP, POS, and NOSIDE are
- as for evaluate_subexp_standard, and NARGS is the number of arguments
- in this access (e.g. 'array (1,2,3)' would be NARGS 3). */
-
-static struct value *
-fortran_value_subarray (struct value *array, struct expression *exp,
- int *pos, int nargs, enum noside noside)
-{
- if (exp->elts[*pos].opcode == OP_RANGE)
- return value_f90_subarray (array, exp, pos, noside);
-
- if (noside == EVAL_SKIP)
- {
- skip_undetermined_arglist (nargs, exp, pos, noside);
- /* Return the dummy value with the correct type. */
- return array;
- }
-
- LONGEST subscript_array[MAX_FORTRAN_DIMS];
- int ndimensions = 1;
- struct type *type = check_typedef (value_type (array));
-
- if (nargs > MAX_FORTRAN_DIMS)
- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
-
- ndimensions = calc_f77_array_dims (type);
-
- if (nargs != ndimensions)
- error (_("Wrong number of subscripts"));
-
- gdb_assert (nargs > 0);
-
- /* Now that we know we have a legal array subscript expression let us
- actually find out where this element exists in the array. */
-
- /* Take array indices left to right. */
- for (int i = 0; i < nargs; i++)
- {
- /* Evaluate each subscript; it must be a legal integer in F77. */
- value *arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
-
- /* Fill in the subscript array. */
- subscript_array[i] = value_as_long (arg2);
- }
-
- /* Internal type of array is arranged right to left. */
- for (int i = nargs; i > 0; i--)
- {
- struct type *array_type = check_typedef (value_type (array));
- LONGEST index = subscript_array[i - 1];
-
- array = value_subscripted_rvalue (array, index,
- f77_get_lowerbound (array_type));
- }
-
- return array;
-}
-
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -1335,7 +1231,6 @@ evaluate_subexp_standard (struct type *expect_type,
struct type *type;
int nargs;
struct value **argvec;
- int code;
int ix;
long mem_offset;
struct type **arg_types;
@@ -1976,84 +1871,6 @@ evaluate_subexp_standard (struct type *expect_type,
case OP_FUNCALL:
return evaluate_funcall (expect_type, exp, pos, noside);
- case OP_F77_UNDETERMINED_ARGLIST:
-
- /* Remember that in F77, functions, substring ops and
- array subscript operations cannot be disambiguated
- at parse time. We have made all array subscript operations,
- substring operations as well as function calls come here
- and we now have to discover what the heck this thing actually was.
- If it is a function, we process just as if we got an OP_FUNCALL. */
-
- nargs = longest_to_int (exp->elts[pc + 1].longconst);
- (*pos) += 2;
-
- /* First determine the type code we are dealing with. */
- arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- type = check_typedef (value_type (arg1));
- code = type->code ();
-
- if (code == TYPE_CODE_PTR)
- {
- /* Fortran always passes variable to subroutines as pointer.
- So we need to look into its target type to see if it is
- array, string or function. If it is, we need to switch
- to the target value the original one points to. */
- struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
-
- if (target_type->code () == TYPE_CODE_ARRAY
- || target_type->code () == TYPE_CODE_STRING
- || target_type->code () == TYPE_CODE_FUNC)
- {
- arg1 = value_ind (arg1);
- type = check_typedef (value_type (arg1));
- code = type->code ();
- }
- }
-
- switch (code)
- {
- case TYPE_CODE_ARRAY:
- case TYPE_CODE_STRING:
- return fortran_value_subarray (arg1, exp, pos, nargs, noside);
-
- case TYPE_CODE_PTR:
- case TYPE_CODE_FUNC:
- case TYPE_CODE_INTERNAL_FUNCTION:
- /* It's a function call. */
- /* Allocate arg vector, including space for the function to be
- called in argvec[0] and a terminating NULL. */
- argvec = (struct value **)
- alloca (sizeof (struct value *) * (nargs + 2));
- argvec[0] = arg1;
- tem = 1;
- for (; tem <= nargs; tem++)
- {
- argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
- /* Arguments in Fortran are passed by address. Coerce the
- arguments here rather than in value_arg_coerce as otherwise
- the call to malloc to place the non-lvalue parameters in
- target memory is hit by this Fortran specific logic. This
- results in malloc being called with a pointer to an integer
- followed by an attempt to malloc the arguments to malloc in
- target memory. Infinite recursion ensues. */
- if (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC)
- {
- bool is_artificial
- = TYPE_FIELD_ARTIFICIAL (value_type (arg1), tem - 1);
- argvec[tem] = fortran_argument_convert (argvec[tem],
- is_artificial);
- }
- }
- argvec[tem] = 0; /* signal end of arglist */
- if (noside == EVAL_SKIP)
- return eval_skip_value (exp);
- return eval_call (exp, noside, nargs, argvec, NULL, expect_type);
-
- default:
- error (_("Cannot perform substring on this type"));
- }
-
case OP_COMPLEX:
/* We have a complex number, There should be 2 floating
point numbers that compose it. */
@@ -3346,27 +3163,3 @@ parse_and_eval_type (char *p, int length)
error (_("Internal error in eval_type."));
return expr->elts[1].type;
}
-
-/* Return the number of dimensions for a Fortran array or string. */
-
-int
-calc_f77_array_dims (struct type *array_type)
-{
- int ndimen = 1;
- struct type *tmp_type;
-
- if ((array_type->code () == TYPE_CODE_STRING))
- return 1;
-
- if ((array_type->code () != TYPE_CODE_ARRAY))
- error (_("Can't get dimensions for a non-array type"));
-
- tmp_type = array_type;
-
- while ((tmp_type = TYPE_TARGET_TYPE (tmp_type)))
- {
- if (tmp_type->code () == TYPE_CODE_ARRAY)
- ++ndimen;
- }
- return ndimen;
-}
diff --git a/gdb/expprint.c b/gdb/expprint.c
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -53,6 +53,25 @@ print_subexp (struct expression *exp, int *pos,
exp->language_defn->la_exp_desc->print_subexp (exp, pos, stream, prec);
}
+/* See parser-defs.h. */
+
+void
+print_subexp_funcall (struct expression *exp, int *pos,
+ struct ui_file *stream)
+{
+ (*pos) += 2;
+ unsigned nargs = longest_to_int (exp->elts[*pos].longconst);
+ print_subexp (exp, pos, stream, PREC_SUFFIX);
+ fputs_filtered (" (", stream);
+ for (unsigned tem = 0; tem < nargs; tem++)
+ {
+ if (tem != 0)
+ fputs_filtered (", ", stream);
+ print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
+ }
+ fputs_filtered (")", stream);
+}
+
/* Standard implementation of print_subexp for use in language_defn
vectors. */
void
@@ -187,18 +206,7 @@ print_subexp_standard (struct expression *exp, int *pos,
return;
case OP_FUNCALL:
- case OP_F77_UNDETERMINED_ARGLIST:
- (*pos) += 2;
- nargs = longest_to_int (exp->elts[pc + 1].longconst);
- print_subexp (exp, pos, stream, PREC_SUFFIX);
- fputs_filtered (" (", stream);
- for (tem = 0; tem < nargs; tem++)
- {
- if (tem != 0)
- fputs_filtered (", ", stream);
- print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
- }
- fputs_filtered (")", stream);
+ print_subexp_funcall (exp, pos, stream);
return;
case OP_NAME:
@@ -796,6 +804,22 @@ dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt)
return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt);
}
+/* See parser-defs.h. */
+
+int
+dump_subexp_body_funcall (struct expression *exp,
+ struct ui_file *stream, int elt)
+{
+ int nargs = longest_to_int (exp->elts[elt].longconst);
+ fprintf_filtered (stream, "Number of args: %d", nargs);
+ elt += 2;
+
+ for (int i = 1; i <= nargs + 1; i++)
+ elt = dump_subexp (exp, stream, elt);
+
+ return elt;
+}
+
/* Default value for subexp_body in exp_descriptor vector. */
int
@@ -931,18 +955,7 @@ dump_subexp_body_standard (struct expression *exp,
elt += 2;
break;
case OP_FUNCALL:
- case OP_F77_UNDETERMINED_ARGLIST:
- {
- int i, nargs;
-
- nargs = longest_to_int (exp->elts[elt].longconst);
-
- fprintf_filtered (stream, "Number of args: %d", nargs);
- elt += 2;
-
- for (i = 1; i <= nargs + 1; i++)
- elt = dump_subexp (exp, stream, elt);
- }
+ elt = dump_subexp_body_funcall (exp, stream, elt);
break;
case OP_ARRAY:
{
diff --git a/gdb/expression.h b/gdb/expression.h
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -155,6 +155,18 @@ enum noside
extern struct value *evaluate_subexp_standard
(struct type *, struct expression *, int *, enum noside);
+/* Evaluate a function call. The function to be called is in ARGVEC[0] and
+ the arguments passed to the function are in ARGVEC[1..NARGS].
+ FUNCTION_NAME is the name of the function, if known.
+ DEFAULT_RETURN_TYPE is used as the function's return type if the return
+ type is unknown. */
+
+extern struct value *evaluate_subexp_do_call (expression *exp,
+ enum noside noside,
+ int nargs, value **argvec,
+ const char *function_name,
+ type *default_return_type);
+
/* From expprint.c */
extern void print_expression (struct expression *, struct ui_file *);
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -114,6 +114,134 @@ enum f_primitive_types {
nr_f_primitive_types
};
+/* Called from fortran_value_subarray to take a slice of an array or a
+ string. ARRAY is the array or string to be accessed. EXP, POS, and
+ NOSIDE are as for evaluate_subexp_standard. Return a value that is a
+ slice of the array. */
+
+static struct value *
+value_f90_subarray (struct value *array,
+ struct expression *exp, int *pos, enum noside noside)
+{
+ int pc = (*pos) + 1;
+ LONGEST low_bound, high_bound;
+ struct type *range = check_typedef (value_type (array)->index_type ());
+ enum range_type range_type
+ = (enum range_type) longest_to_int (exp->elts[pc].longconst);
+
+ *pos += 3;
+
+ if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
+ low_bound = range->bounds ()->low.const_val ();
+ else
+ low_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
+
+ if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
+ high_bound = range->bounds ()->high.const_val ();
+ else
+ high_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
+
+ return value_slice (array, low_bound, high_bound - low_bound + 1);
+}
+
+/* Helper for skipping all the arguments in an undetermined argument list.
+ This function was designed for use in the OP_F77_UNDETERMINED_ARGLIST
+ case of evaluate_subexp_standard as multiple, but not all, code paths
+ require a generic skip. */
+
+static void
+skip_undetermined_arglist (int nargs, struct expression *exp, int *pos,
+ enum noside noside)
+{
+ for (int i = 0; i < nargs; ++i)
+ evaluate_subexp (nullptr, exp, pos, noside);
+}
+
+/* Return the number of dimensions for a Fortran array or string. */
+
+int
+calc_f77_array_dims (struct type *array_type)
+{
+ int ndimen = 1;
+ struct type *tmp_type;
+
+ if ((array_type->code () == TYPE_CODE_STRING))
+ return 1;
+
+ if ((array_type->code () != TYPE_CODE_ARRAY))
+ error (_("Can't get dimensions for a non-array type"));
+
+ tmp_type = array_type;
+
+ while ((tmp_type = TYPE_TARGET_TYPE (tmp_type)))
+ {
+ if (tmp_type->code () == TYPE_CODE_ARRAY)
+ ++ndimen;
+ }
+ return ndimen;
+}
+
+/* Called from evaluate_subexp_standard to perform array indexing, and
+ sub-range extraction, for Fortran. As well as arrays this function
+ also handles strings as they can be treated like arrays of characters.
+ ARRAY is the array or string being accessed. EXP, POS, and NOSIDE are
+ as for evaluate_subexp_standard, and NARGS is the number of arguments
+ in this access (e.g. 'array (1,2,3)' would be NARGS 3). */
+
+static struct value *
+fortran_value_subarray (struct value *array, struct expression *exp,
+ int *pos, int nargs, enum noside noside)
+{
+ if (exp->elts[*pos].opcode == OP_RANGE)
+ return value_f90_subarray (array, exp, pos, noside);
+
+ if (noside == EVAL_SKIP)
+ {
+ skip_undetermined_arglist (nargs, exp, pos, noside);
+ /* Return the dummy value with the correct type. */
+ return array;
+ }
+
+ LONGEST subscript_array[MAX_FORTRAN_DIMS];
+ int ndimensions = 1;
+ struct type *type = check_typedef (value_type (array));
+
+ if (nargs > MAX_FORTRAN_DIMS)
+ error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
+
+ ndimensions = calc_f77_array_dims (type);
+
+ if (nargs != ndimensions)
+ error (_("Wrong number of subscripts"));
+
+ gdb_assert (nargs > 0);
+
+ /* Now that we know we have a legal array subscript expression let us
+ actually find out where this element exists in the array. */
+
+ /* Take array indices left to right. */
+ for (int i = 0; i < nargs; i++)
+ {
+ /* Evaluate each subscript; it must be a legal integer in F77. */
+ value *arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
+
+ /* Fill in the subscript array. */
+ subscript_array[i] = value_as_long (arg2);
+ }
+
+ /* Internal type of array is arranged right to left. */
+ for (int i = nargs; i > 0; i--)
+ {
+ struct type *array_type = check_typedef (value_type (array));
+ LONGEST index = subscript_array[i - 1];
+
+ array = value_subscripted_rvalue (array, index,
+ f77_get_lowerbound (array_type));
+ }
+
+ return array;
+}
+
/* Special expression evaluation cases for Fortran. */
static struct value *
@@ -285,6 +413,87 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
TYPE_LENGTH (type));
return value_from_longest (builtin_type (exp->gdbarch)->builtin_int,
TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
+
+
+ case OP_F77_UNDETERMINED_ARGLIST:
+ /* Remember that in F77, functions, substring ops and array subscript
+ operations cannot be disambiguated at parse time. We have made
+ all array subscript operations, substring operations as well as
+ function calls come here and we now have to discover what the heck
+ this thing actually was. If it is a function, we process just as
+ if we got an OP_FUNCALL. */
+ int nargs = longest_to_int (exp->elts[pc + 1].longconst);
+ (*pos) += 2;
+
+ /* First determine the type code we are dealing with. */
+ arg1 = evaluate_subexp (nullptr, exp, pos, noside);
+ type = check_typedef (value_type (arg1));
+ enum type_code code = type->code ();
+
+ if (code == TYPE_CODE_PTR)
+ {
+ /* Fortran always passes variable to subroutines as pointer.
+ So we need to look into its target type to see if it is
+ array, string or function. If it is, we need to switch
+ to the target value the original one points to. */
+ struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
+
+ if (target_type->code () == TYPE_CODE_ARRAY
+ || target_type->code () == TYPE_CODE_STRING
+ || target_type->code () == TYPE_CODE_FUNC)
+ {
+ arg1 = value_ind (arg1);
+ type = check_typedef (value_type (arg1));
+ code = type->code ();
+ }
+ }
+
+ switch (code)
+ {
+ case TYPE_CODE_ARRAY:
+ case TYPE_CODE_STRING:
+ return fortran_value_subarray (arg1, exp, pos, nargs, noside);
+
+ case TYPE_CODE_PTR:
+ case TYPE_CODE_FUNC:
+ case TYPE_CODE_INTERNAL_FUNCTION:
+ {
+ /* It's a function call. Allocate arg vector, including
+ space for the function to be called in argvec[0] and a
+ termination NULL. */
+ struct value **argvec = (struct value **)
+ alloca (sizeof (struct value *) * (nargs + 2));
+ argvec[0] = arg1;
+ int tem = 1;
+ for (; tem <= nargs; tem++)
+ {
+ argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
+ /* Arguments in Fortran are passed by address. Coerce the
+ arguments here rather than in value_arg_coerce as
+ otherwise the call to malloc to place the non-lvalue
+ parameters in target memory is hit by this Fortran
+ specific logic. This results in malloc being called
+ with a pointer to an integer followed by an attempt to
+ malloc the arguments to malloc in target memory.
+ Infinite recursion ensues. */
+ if (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC)
+ {
+ bool is_artificial
+ = TYPE_FIELD_ARTIFICIAL (value_type (arg1), tem - 1);
+ argvec[tem] = fortran_argument_convert (argvec[tem],
+ is_artificial);
+ }
+ }
+ argvec[tem] = 0; /* signal end of arglist */
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ return evaluate_subexp_do_call (exp, noside, nargs, argvec, NULL,
+ expect_type);
+ }
+
+ default:
+ error (_("Cannot perform substring on this type"));
+ }
}
/* Should be unreachable. */
@@ -318,6 +527,11 @@ operator_length_f (const struct expression *exp, int pc, int *oplenp,
oplen = 1;
args = 2;
break;
+
+ case OP_F77_UNDETERMINED_ARGLIST:
+ oplen = 3;
+ args = 1 + longest_to_int (exp->elts[pc - 2].longconst);
+ break;
}
*oplenp = oplen;
@@ -390,6 +604,10 @@ print_subexp_f (struct expression *exp, int *pos,
case BINOP_FORTRAN_MODULO:
print_binop_subexp_f (exp, pos, stream, prec, "MODULO");
return;
+
+ case OP_F77_UNDETERMINED_ARGLIST:
+ print_subexp_funcall (exp, pos, stream);
+ return;
}
}
@@ -432,6 +650,9 @@ dump_subexp_body_f (struct expression *exp,
case BINOP_FORTRAN_MODULO:
operator_length_f (exp, (elt + 1), &oplen, &nargs);
break;
+
+ case OP_F77_UNDETERMINED_ARGLIST:
+ return dump_subexp_body_funcall (exp, stream, elt);
}
elt += oplen;
diff --git a/gdb/fortran-operator.def b/gdb/fortran-operator.def
--- a/gdb/fortran-operator.def
+++ b/gdb/fortran-operator.def
@@ -17,6 +17,14 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This is EXACTLY like OP_FUNCALL but is semantically different.
+ In F77, array subscript expressions, substring expressions and
+ function calls are all exactly the same syntactically. They
+ may only be disambiguated at runtime. Thus this operator,
+ which indicates that we have found something of the form
+ <name> ( <stuff> ). */
+OP (OP_F77_UNDETERMINED_ARGLIST)
+
/* Single operand builtins. */
OP (UNOP_FORTRAN_KIND)
OP (UNOP_FORTRAN_FLOOR)
diff --git a/gdb/parse.c b/gdb/parse.c
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -817,7 +817,6 @@ operator_length_standard (const struct expression *expr, int endpos,
break;
case OP_FUNCALL:
- case OP_F77_UNDETERMINED_ARGLIST:
oplen = 3;
args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
break;
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -338,6 +338,13 @@ extern int dump_subexp (struct expression *, struct ui_file *, int);
extern int dump_subexp_body_standard (struct expression *,
struct ui_file *, int);
+/* Dump (to STREAM) a function call like expression at position ELT in the
+ expression array EXP. Return a new value for ELT just after the
+ function call expression. */
+
+extern int dump_subexp_body_funcall (struct expression *exp,
+ struct ui_file *stream, int elt);
+
extern void operator_length (const struct expression *, int, int *, int *);
extern void operator_length_standard (const struct expression *, int, int *,
@@ -440,6 +447,15 @@ extern void print_subexp (struct expression *, int *, struct ui_file *,
extern void print_subexp_standard (struct expression *, int *,
struct ui_file *, enum precedence);
+/* Print a function call like expression to STREAM. This is called as a
+ helper function by which point the expression node identifying this as a
+ function call has already been stripped off and POS should point to the
+ number of function call arguments. EXP is the object containing the
+ list of expression elements. */
+
+extern void print_subexp_funcall (struct expression *exp, int *pos,
+ struct ui_file *stream);
+
/* Function used to avoid direct calls to fprintf
in the code generated by the bison parser. */
diff --git a/gdb/std-operator.def b/gdb/std-operator.def
--- a/gdb/std-operator.def
+++ b/gdb/std-operator.def
@@ -168,14 +168,6 @@ OP (OP_FUNCALL)
pointer. This is an Objective C message. */
OP (OP_OBJC_MSGCALL)
-/* This is EXACTLY like OP_FUNCALL but is semantically different.
- In F77, array subscript expressions, substring expressions and
- function calls are all exactly the same syntactically. They
- may only be disambiguated at runtime. Thus this operator,
- which indicates that we have found something of the form
- <name> ( <stuff> ). */
-OP (OP_F77_UNDETERMINED_ARGLIST)
-
/* OP_COMPLEX takes a type in the following element, followed by another
OP_COMPLEX, making three exp_elements. It is followed by two double
args, and converts them into a complex number of the given type. */

View File

@ -1,306 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Tue, 8 Jun 2021 16:50:53 -0400
Subject: gdb-rhbz1971095-libthread_db-update-1of5.patch
;; Backport "gdb: try to load libthread_db only after reading all
;; shared libraries when attaching / handling a fork child"
;; (Simon Marchi, RH BZ 1971095)
When trying to attach to a pthread process on a Linux system with glibc 2.33,
we get:
$ ./gdb -q -nx --data-directory=data-directory -p 1472010
Attaching to process 1472010
[New LWP 1472013]
[New LWP 1472014]
[New LWP 1472015]
Error while reading shared library symbols for /usr/lib/libpthread.so.0:
Cannot find user-level thread for LWP 1472015: generic error
0x00007ffff6d3637f in poll () from /usr/lib/libc.so.6
(gdb)
When attaching to a process (or handling a fork child, an operation very
similar to attaching), GDB reads the shared library list from the
process. For each shared library (if "set auto-solib-add" is on), it
reads its symbols and calls the "new_objfile" observable.
The libthread-db code monitors this observable, and if it sees an
objfile named somewhat like "libpthread.so" go by, it tries to load
libthread_db.so in the GDB process itself. libthread_db knows how to
navigate libpthread's data structures to get information about the
existing threads.
To locate these data structures, libthread_db calls ps_pglobal_lookup
(implemented in proc-service.c), passing in a symbol name and expecting
an address in return.
Before glibc 2.33, libthread_db always asked for symbols found in
libpthread. There was no ordering problem: since we were always trying
to load libthread_db in reaction to processing libpthread (and reading
in its symbols) and libthread_db only asked symbols from libpthread, the
requested symbols could always be found. Starting with glibc 2.33,
libthread_db now asks for a symbol name that can be found in
/lib/ld-linux-x86-64.so.2 (_rtld_global). And the ordering in which GDB
reads the shared libraries from the inferior when attaching is
unfortunate, in that libpthread is processed before ld-linux. So when
loading libthread_db in reaction to processing libpthread, and
libthread_db requests the symbol that is from ld-linux, GDB is not yet
able to supply it.
That problematic symbol lookup happens in the thread_from_lwp function,
when we call td_ta_map_lwp2thr_p, and an exception is thrown at this
point:
#0 0x00007ffff6681012 in __cxxabiv1::__cxa_throw (obj=0x60e000006100, tinfo=0x555560033b50 <typeinfo for gdb_exception_error>, dest=0x55555d9404bc <gdb_exception_error::~gdb_exception_error()>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:78
#1 0x000055555e5d3734 in throw_it(return_reason, errors, const char *, typedef __va_list_tag __va_list_tag *) (reason=RETURN_ERROR, error=GENERIC_ERROR, fmt=0x55555f0c5360 "Cannot find user-level thread for LWP %ld: %s", ap=0x7fffffffaae0) at /home/simark/src/binutils-gdb/gdbsupport/common-exceptions.cc:200
#2 0x000055555e5d37d4 in throw_verror (error=GENERIC_ERROR, fmt=0x55555f0c5360 "Cannot find user-level thread for LWP %ld: %s", ap=0x7fffffffaae0) at /home/simark/src/binutils-gdb/gdbsupport/common-exceptions.cc:208
#3 0x000055555e0b0ed2 in verror (string=0x55555f0c5360 "Cannot find user-level thread for LWP %ld: %s", args=0x7fffffffaae0) at /home/simark/src/binutils-gdb/gdb/utils.c:171
#4 0x000055555e5e898a in error (fmt=0x55555f0c5360 "Cannot find user-level thread for LWP %ld: %s") at /home/simark/src/binutils-gdb/gdbsupport/errors.cc:43
#5 0x000055555d06b4bc in thread_from_lwp (stopped=0x617000035d80, ptid=...) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:418
#6 0x000055555d07040d in try_thread_db_load_1 (info=0x60c000011140) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:912
#7 0x000055555d071103 in try_thread_db_load (library=0x55555f0c62a0 "libthread_db.so.1", check_auto_load_safe=false) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1014
#8 0x000055555d072168 in try_thread_db_load_from_sdir () at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1091
#9 0x000055555d072d1c in thread_db_load_search () at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1146
#10 0x000055555d07365c in thread_db_load () at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1203
#11 0x000055555d07373e in check_for_thread_db () at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1246
#12 0x000055555d0738ab in thread_db_new_objfile (objfile=0x61300000c0c0) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1275
#13 0x000055555bd10740 in std::__invoke_impl<void, void (*&)(objfile*), objfile*> (__f=@0x616000068d88: 0x55555d073745 <thread_db_new_objfile(objfile*)>) at /usr/include/c++/10.2.0/bits/invoke.h:60
#14 0x000055555bd02096 in std::__invoke_r<void, void (*&)(objfile*), objfile*> (__fn=@0x616000068d88: 0x55555d073745 <thread_db_new_objfile(objfile*)>) at /usr/include/c++/10.2.0/bits/invoke.h:153
#15 0x000055555bce0392 in std::_Function_handler<void (objfile*), void (*)(objfile*)>::_M_invoke(std::_Any_data const&, objfile*&&) (__functor=..., __args#0=@0x7fffffffb4a0: 0x61300000c0c0) at /usr/include/c++/10.2.0/bits/std_function.h:291
#16 0x000055555d3595c0 in std::function<void (objfile*)>::operator()(objfile*) const (this=0x616000068d88, __args#0=0x61300000c0c0) at /usr/include/c++/10.2.0/bits/std_function.h:622
#17 0x000055555d356b7f in gdb::observers::observable<objfile*>::notify (this=0x555566727020 <gdb::observers::new_objfile>, args#0=0x61300000c0c0) at /home/simark/src/binutils-gdb/gdb/../gdbsupport/observable.h:106
#18 0x000055555da3f228 in symbol_file_add_with_addrs (abfd=0x61200001ccc0, name=0x6190000d9090 "/usr/lib/libpthread.so.0", add_flags=..., addrs=0x7fffffffbc10, flags=..., parent=0x0) at /home/simark/src/binutils-gdb/gdb/symfile.c:1131
#19 0x000055555da3f763 in symbol_file_add_from_bfd (abfd=0x61200001ccc0, name=0x6190000d9090 "/usr/lib/libpthread.so.0", add_flags=<error reading variable: Cannot access memory at address 0xffffffffffffffb0>, addrs=0x7fffffffbc10, flags=<error reading variable: Cannot access memory at address 0xffffffffffffffc0>, parent=0x0) at /home/simark/src/binutils-gdb/gdb/symfile.c:1167
#20 0x000055555d95f9fa in solib_read_symbols (so=0x6190000d8e80, flags=...) at /home/simark/src/binutils-gdb/gdb/solib.c:681
#21 0x000055555d96233d in solib_add (pattern=0x0, from_tty=0, readsyms=1) at /home/simark/src/binutils-gdb/gdb/solib.c:987
#22 0x000055555d93646e in enable_break (info=0x608000008f20, from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib-svr4.c:2238
#23 0x000055555d93cfc0 in svr4_solib_create_inferior_hook (from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib-svr4.c:3049
#24 0x000055555d96610d in solib_create_inferior_hook (from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib.c:1195
#25 0x000055555cdee318 in post_create_inferior (from_tty=0) at /home/simark/src/binutils-gdb/gdb/infcmd.c:318
#26 0x000055555ce00e6e in setup_inferior (from_tty=0) at /home/simark/src/binutils-gdb/gdb/infcmd.c:2439
#27 0x000055555ce59c34 in handle_one (event=...) at /home/simark/src/binutils-gdb/gdb/infrun.c:4887
#28 0x000055555ce5cd00 in stop_all_threads () at /home/simark/src/binutils-gdb/gdb/infrun.c:5064
#29 0x000055555ce7f0da in stop_waiting (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:8006
#30 0x000055555ce67f5c in handle_signal_stop (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:6062
#31 0x000055555ce63653 in handle_inferior_event (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:5727
#32 0x000055555ce4f297 in fetch_inferior_event () at /home/simark/src/binutils-gdb/gdb/infrun.c:4105
#33 0x000055555cdbe3bf in inferior_event_handler (event_type=INF_REG_EVENT) at /home/simark/src/binutils-gdb/gdb/inf-loop.c:42
#34 0x000055555d018047 in handle_target_event (error=0, client_data=0x0) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:4060
#35 0x000055555e5ea77e in handle_file_event (file_ptr=0x60600008b1c0, ready_mask=1) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:575
#36 0x000055555e5eb09c in gdb_wait_for_event (block=0) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:701
#37 0x000055555e5e8d19 in gdb_do_one_event () at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:212
#38 0x000055555dd6e0d4 in wait_sync_command_done () at /home/simark/src/binutils-gdb/gdb/top.c:528
#39 0x000055555dd6e372 in maybe_wait_sync_command_done (was_sync=0) at /home/simark/src/binutils-gdb/gdb/top.c:545
#40 0x000055555d0ec7c8 in catch_command_errors (command=0x55555ce01bb8 <attach_command(char const*, int)>, arg=0x7fffffffe28d "1472010", from_tty=1, do_bp_actions=false) at /home/simark/src/binutils-gdb/gdb/main.c:452
#41 0x000055555d0f03ad in captured_main_1 (context=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1149
#42 0x000055555d0f1239 in captured_main (data=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1232
#43 0x000055555d0f1315 in gdb_main (args=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1257
#44 0x000055555bb70cf9 in main (argc=7, argv=0x7fffffffde88) at /home/simark/src/binutils-gdb/gdb/gdb.c:32
The exception is caught here:
#0 __cxxabiv1::__cxa_begin_catch (exc_obj_in=0x60e0000060e0) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_catch.cc:84
#1 0x000055555d95fded in solib_read_symbols (so=0x6190000d8e80, flags=...) at /home/simark/src/binutils-gdb/gdb/solib.c:689
#2 0x000055555d96233d in solib_add (pattern=0x0, from_tty=0, readsyms=1) at /home/simark/src/binutils-gdb/gdb/solib.c:987
#3 0x000055555d93646e in enable_break (info=0x608000008f20, from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib-svr4.c:2238
#4 0x000055555d93cfc0 in svr4_solib_create_inferior_hook (from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib-svr4.c:3049
#5 0x000055555d96610d in solib_create_inferior_hook (from_tty=0) at /home/simark/src/binutils-gdb/gdb/solib.c:1195
#6 0x000055555cdee318 in post_create_inferior (from_tty=0) at /home/simark/src/binutils-gdb/gdb/infcmd.c:318
#7 0x000055555ce00e6e in setup_inferior (from_tty=0) at /home/simark/src/binutils-gdb/gdb/infcmd.c:2439
#8 0x000055555ce59c34 in handle_one (event=...) at /home/simark/src/binutils-gdb/gdb/infrun.c:4887
#9 0x000055555ce5cd00 in stop_all_threads () at /home/simark/src/binutils-gdb/gdb/infrun.c:5064
#10 0x000055555ce7f0da in stop_waiting (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:8006
#11 0x000055555ce67f5c in handle_signal_stop (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:6062
#12 0x000055555ce63653 in handle_inferior_event (ecs=0x7fffffffd170) at /home/simark/src/binutils-gdb/gdb/infrun.c:5727
#13 0x000055555ce4f297 in fetch_inferior_event () at /home/simark/src/binutils-gdb/gdb/infrun.c:4105
#14 0x000055555cdbe3bf in inferior_event_handler (event_type=INF_REG_EVENT) at /home/simark/src/binutils-gdb/gdb/inf-loop.c:42
#15 0x000055555d018047 in handle_target_event (error=0, client_data=0x0) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:4060
#16 0x000055555e5ea77e in handle_file_event (file_ptr=0x60600008b1c0, ready_mask=1) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:575
#17 0x000055555e5eb09c in gdb_wait_for_event (block=0) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:701
#18 0x000055555e5e8d19 in gdb_do_one_event () at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:212
#19 0x000055555dd6e0d4 in wait_sync_command_done () at /home/simark/src/binutils-gdb/gdb/top.c:528
#20 0x000055555dd6e372 in maybe_wait_sync_command_done (was_sync=0) at /home/simark/src/binutils-gdb/gdb/top.c:545
#21 0x000055555d0ec7c8 in catch_command_errors (command=0x55555ce01bb8 <attach_command(char const*, int)>, arg=0x7fffffffe28d "1472010", from_tty=1, do_bp_actions=false) at /home/simark/src/binutils-gdb/gdb/main.c:452
#22 0x000055555d0f03ad in captured_main_1 (context=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1149
#23 0x000055555d0f1239 in captured_main (data=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1232
#24 0x000055555d0f1315 in gdb_main (args=0x7fffffffdd10) at /home/simark/src/binutils-gdb/gdb/main.c:1257
#25 0x000055555bb70cf9 in main (argc=7, argv=0x7fffffffde88) at /home/simark/src/binutils-gdb/gdb/gdb.c:32
Catching the exception at this point means that the thread_db_info
object for this inferior will be left in place, despite the failure to
load libthread_db. This means that there won't be further attempts at
loading libthread_db, because thread_db_load will think that
libthread_db is already loaded for this inferior and will always exit
early. To fix this, add a try/catch around calling try_thread_db_load_1
in try_thread_db_load, such that if some exception is thrown while
trying to load libthread_db, we reset / delete the thread_db_info for
that inferior. That alone makes attach work fine again, because
check_for_thread_db is called again in the thread_db_inferior_created
observer (that happens after we learned about all shared libraries and
their symbols), and libthread_db is successfully loaded then.
When attaching, I think that the inferior_created observer is a good
place to try to load libthread_db: it is called once everything has
stabilized, when we learned about all shared libraries.
The only problem then is that when we first try (and fail) to load
libthread_db, in reaction to learning about libpthread, we show this
warning:
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
This is misleading, because we do succeed in loading it later. So when
attaching, I think we shouldn't try to load libthread_db in reaction to
the new_objfile events, we should wait until we have learned about all
shared libraries (using the inferior_created observable). To do so, add
an `in_initial_library_scan` flag to struct inferior. This flag is used
to postpone loading libthread_db if we are attaching or handling a fork
child.
When debugging remotely with GDBserver, the same problem happens, except
that the qSymbol mechanism (allowing the remote side to ask GDB for
symbols values) is involved. The fix there is the same idea, we make
GDB wait until all shared libraries and their symbols are known before
sending out a qSymbol packet. This way, we never present the remote
side a state where libpthread.so's symbols are known but ld-linux's
symbols aren't.
gdb/ChangeLog:
* inferior.h (class inferior) <in_initial_library_scan>: New.
* infcmd.c (post_create_inferior): Set in_initial_library_scan.
* infrun.c (follow_fork_inferior): Likewise.
* linux-thread-db.c (try_thread_db_load): Catch exception thrown
by try_thread_db_load_1
(thread_db_load): Return early if in_initial_library_scan is
set.
* remote.c (remote_new_objfile): Return early if
in_initial_library_scan is set.
Change-Id: I7a279836cfbb2b362b4fde11b196b4aab82f5efb
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -313,6 +313,10 @@ post_create_inferior (struct target_ops *target, int from_tty)
const unsigned solib_add_generation
= current_program_space->solib_add_generation;
+ scoped_restore restore_in_initial_library_scan
+ = make_scoped_restore (&current_inferior ()->in_initial_library_scan,
+ true);
+
/* Create the hooks to handle shared library load and unload
events. */
solib_create_inferior_hook (from_tty);
diff --git a/gdb/inferior.h b/gdb/inferior.h
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -511,6 +511,10 @@ class inferior : public refcounted_object
architecture/description. */
bool needs_setup = false;
+ /* True when we are reading the library list of the inferior during an
+ attach or handling a fork child. */
+ bool in_initial_library_scan = false;
+
/* Private data used by the target vector implementation. */
std::unique_ptr<private_inferior> priv;
diff --git a/gdb/infrun.c b/gdb/infrun.c
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -540,6 +540,9 @@ holding the child stopped. Try \"set detach-on-fork\" or \
breakpoint. If a "cloned-VM" event was propagated
better throughout the core, this wouldn't be
required. */
+ scoped_restore restore_in_initial_library_scan
+ = make_scoped_restore (&child_inf->in_initial_library_scan,
+ true);
solib_create_inferior_hook (0);
}
}
@@ -675,6 +678,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \
shared libraries, and install the solib event breakpoint.
If a "cloned-VM" event was propagated better throughout
the core, this wouldn't be required. */
+ scoped_restore restore_in_initial_library_scan
+ = make_scoped_restore (&child_inf->in_initial_library_scan, true);
solib_create_inferior_hook (0);
}
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1012,8 +1012,17 @@ try_thread_db_load (const char *library, bool check_auto_load_safe)
if (strchr (library, '/') != NULL)
info->filename = gdb_realpath (library).release ();
- if (try_thread_db_load_1 (info))
- return true;
+ try
+ {
+ if (try_thread_db_load_1 (info))
+ return true;
+ }
+ catch (const gdb_exception_error &except)
+ {
+ if (libthread_db_debug)
+ exception_fprintf (gdb_stdlog, except,
+ "Warning: While trying to load libthread_db: ");
+ }
/* This library "refused" to work on current inferior. */
delete_thread_db_info (current_inferior ()->process_target (),
@@ -1184,10 +1193,15 @@ has_libpthread (void)
static bool
thread_db_load (void)
{
- struct thread_db_info *info;
+ inferior *inf = current_inferior ();
- info = get_thread_db_info (current_inferior ()->process_target (),
- inferior_ptid.pid ());
+ /* When attaching / handling fork child, don't try loading libthread_db
+ until we know about all shared libraries. */
+ if (inf->in_initial_library_scan)
+ return false;
+
+ thread_db_info *info = get_thread_db_info (inf->process_target (),
+ inferior_ptid.pid ());
if (info != NULL)
return true;
diff --git a/gdb/remote.c b/gdb/remote.c
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -14299,8 +14299,26 @@ remote_new_objfile (struct objfile *objfile)
{
remote_target *remote = get_current_remote_target ();
- if (remote != NULL) /* Have a remote connection. */
- remote->remote_check_symbols ();
+ /* First, check whether the current inferior's process target is a remote
+ target. */
+ if (remote == nullptr)
+ return;
+
+ /* When we are attaching or handling a fork child and the shared library
+ subsystem reads the list of loaded libraries, we receive new objfile
+ events in between each found library. The libraries are read in an
+ undefined order, so if we gave the remote side a chance to look up
+ symbols between each objfile, we might give it an inconsistent picture
+ of the inferior. It could appear that a library A appears loaded but
+ a library B does not, even though library A requires library B. That
+ would present a state that couldn't normally exist in the inferior.
+
+ So, skip these events, we'll give the remote a chance to look up symbols
+ once all the loaded libraries and their symbols are known to GDB. */
+ if (current_inferior ()->in_initial_library_scan)
+ return;
+
+ remote->remote_check_symbols ();
}
/* Pull all the tracepoints defined on the target and create local

View File

@ -1,148 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Wed, 9 Jun 2021 18:07:45 -0700
Subject: gdb-rhbz1971095-libthread_db-update-2of5.patch
;; Backport "libthread_db initialization changes related to upcoming
;; glibc-2.34"
;; (Kevin Buettner, RH BZ 19710950
This commit makes some adjustments to accomodate the upcoming
glibc-2.34 release. Beginning with glibc-2.34, functionality formerly
contained in libpthread has been moved to libc. For the time being,
libpthread.so still exists in the file system, but it won't show up in
ldd output and therefore won't be able to trigger initialization of
libthread_db related code. E.g...
Fedora 34 / glibc-2.33.9000:
[kev@f34-2 gdb]$ ldd testsuite/outputs/gdb.threads/tls/tls
linux-vdso.so.1 (0x00007ffcf94fa000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007ff0ba9af000)
libm.so.6 => /lib64/libm.so.6 (0x00007ff0ba8d4000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff0ba8b9000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff0ba6c6000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff0babf0000)
Fedora 34 / glibc-2.33:
[kev@f34-1 gdb]$ ldd testsuite/outputs/gdb.threads/tls/tls
linux-vdso.so.1 (0x00007fff32dc0000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f815f6de000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f815f4bf000)
libm.so.6 => /lib64/libm.so.6 (0x00007f815f37b000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f815f360000)
libc.so.6 => /lib64/libc.so.6 (0x00007f815f191000)
/lib64/ld-linux-x86-64.so.2 (0x00007f815f721000)
Note that libpthread is missing from the ldd output for the
glibc-2.33.9000 machine.
This means that (unless we happen to think of some entirely different
mechanism), we'll now need to potentially match "libc" in addition to
"libpthread" as libraries which might be thread libraries. This
accounts for the change made in solib.c. Note that the new code
attempts to match "/libc." via strstr(). That trailing dot (".")
avoids inadvertently matching libraries such as libcrypt (and
all the other many libraries which begin with "libc").
To avoid attempts to load libthread_db when encountering older
versions of libc, we now attempt to find "pthread_create" (which is a
symbol that we'd expect to be in any pthread library) in the
associated objfile. This accounts for the changes in
linux-thread-db.c.
I think that other small adjustments will need to be made elsewhere
too. I've been working through regressions on my glibc-2.33.9000
machine; I've fixed some fairly "obvious" changes in the testsuite
(which are in other commits). For the rest, it's not yet clear to me
whether the handful of remaining failures represent a problem in glibc
or gdb. I'm still investigating, however, I'll note that these are
problems that I only see on my glibc-2.33.9000 machine.
gdb/ChangeLog:
* solib.c (libpthread_name_p): Match "libc" in addition
to "libpthread".
* linux-thread-db.c (libpthread_objfile_p): New function.
(libpthread_name_p): Adjust preexisting callers to use
libpthread_objfile_p().
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -800,6 +800,24 @@ check_thread_db (struct thread_db_info *info, bool log_progress)
return test_passed;
}
+/* Predicate which tests whether objfile OBJ refers to the library
+ containing pthread related symbols. Historically, this library has
+ been named in such a way that looking for "libpthread" in the name
+ was sufficient to identify it. As of glibc-2.34, the C library
+ (libc) contains the thread library symbols. Therefore we check
+ that the name matches a possible thread library, but we also check
+ that it contains at least one of the symbols (pthread_create) that
+ we'd expect to find in the thread library. */
+
+static bool
+libpthread_objfile_p (objfile *obj)
+{
+ return (libpthread_name_p (objfile_name (obj))
+ && lookup_minimal_symbol ("pthread_create",
+ NULL,
+ obj).minsym != NULL);
+}
+
/* Attempt to initialize dlopen()ed libthread_db, described by INFO.
Return true on success.
Failure could happen if libthread_db does not have symbols we expect,
@@ -1072,7 +1090,7 @@ try_thread_db_load_from_pdir (const char *subdir)
return false;
for (objfile *obj : current_program_space->objfiles ())
- if (libpthread_name_p (objfile_name (obj)))
+ if (libpthread_objfile_p (obj))
{
if (try_thread_db_load_from_pdir_1 (obj, subdir))
return true;
@@ -1181,7 +1199,7 @@ static bool
has_libpthread (void)
{
for (objfile *obj : current_program_space->objfiles ())
- if (libpthread_name_p (objfile_name (obj)))
+ if (libpthread_objfile_p (obj))
return true;
return false;
@@ -1295,7 +1313,7 @@ thread_db_new_objfile (struct objfile *objfile)
of the list of shared libraries to load, and in an app of several
thousand shared libraries, this can otherwise be painful. */
&& ((objfile->flags & OBJF_MAINLINE) != 0
- || libpthread_name_p (objfile_name (objfile))))
+ || libpthread_objfile_p (objfile)))
check_for_thread_db ();
}
diff --git a/gdb/solib.c b/gdb/solib.c
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -906,12 +906,17 @@ Do you need \"set solib-search-path\" or \"set sysroot\"?"),
Uses a fairly simplistic heuristic approach where we check
the file name against "/libpthread". This can lead to false
- positives, but this should be good enough in practice. */
+ positives, but this should be good enough in practice.
+
+ As of glibc-2.34, functions formerly residing in libpthread have
+ been moved to libc, so "/libc." needs to be checked too. (Matching
+ the "." will avoid matching libraries such as libcrypt.) */
bool
libpthread_name_p (const char *name)
{
- return (strstr (name, "/libpthread") != NULL);
+ return (strstr (name, "/libpthread") != NULL
+ || strstr (name, "/libc.") != NULL );
}
/* Return non-zero if SO is the libpthread shared library. */

View File

@ -1,71 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Wed, 9 Jun 2021 18:56:23 -0700
Subject: gdb-rhbz1971095-libthread_db-update-3of5.patch
;; Backport "testsuite/glib-2.34: Match/consume optional libthread_db
;; related output"
;; (Kevin Buettner, RH BZ 19710950
When using glibc-2.34, we now see messages related to the loading of
the thread library for non-thread programs. E.g. for the test case,
gdb.base/execl-update-breakpoints.exp, we will see the following when
starting the program:
(gdb) break -qualified main
Breakpoint 1 at 0x100118c: file /ironwood1/sourceware-git/f34-2-glibc244_fix/bld/../../worktree-glibc244_fix/gdb/testsuite/gdb.base/execl-update-breakpoints.c, line 34.
(gdb) run
Starting program: [...]/execl-update-breakpoints1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
The two lines of output related to libthread_db are new; we didn't see
these in the past. This is a side effect of libc now containing the
pthread API - we can no longer tell whether the program is
multi-threaded by simply looking for libpthread.so. That said, I
think that we now want to load libthread_db anyway since it's used to
resolve TLS variables; i.e. we need it for correctly determining the
value of errno.
This commit adds the necessary regular expressions to match this
(optional) additional output in the two tests which were failing
without it.
gdb/testsuite/ChangeLog:
* gdb.base/execl-update-breakpoints.exp: Add regular
expression for optionally matching output related to
libthread_db.
* gdb.base/fork-print-inferior-events.exp: Likewise.
diff --git a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp
--- a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp
+++ b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp
@@ -132,6 +132,7 @@ proc test { always_inserted } {
"Continuing\\.\r\n" \
"${not_nl} is executing new program: ${not_nl}\r\n" \
"(Reading ${not_nl} from remote target\\.\\.\\.\r\n)*" \
+ "(?:.Thread debugging using .*? enabled.\r\nUsing .*? library .*?\\.\r\n)?" \
"\r\n" \
"Breakpoint 1, main.*$gdb_prompt $"
set message "continue across exec"
diff --git a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
--- a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
+++ b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
@@ -59,6 +59,7 @@ set detach_child_re "${reading_re}\\\[Detaching after fork from child .*\\\]\r\n
set detach_parent_re "${reading_re}\\\[Detaching after fork from parent .*\\\]\r\n"
set new_inf_re "${reading_re}\\\[New inferior $decimal \\(.*\\)\\\]\r\n"
set inf_detached_re "${reading_re}\\\[Inferior $decimal \\(.*\\) detached\\\]\r\n"
+set thread_db_re "(?:\\\[Thread debugging using .*? enabled\\\]\r\nUsing .*? library .*?\\.\r\n)?"
set expected_output [list \
"${attach_child_re}${new_inf_re}${detach_parent_re}${inf_detached_re}" \
@@ -84,7 +85,7 @@ foreach_with_prefix print_inferior_events { "on" "off" } {
set output [lindex $expected_output $i]
# Always add the "Starting program..." string so that we
# match exactly the lines we want.
- set output "Starting program: $binfile\\s*\r\n${output}${exited_normally_re}"
+ set output "Starting program: $binfile\\s*\r\n${thread_db_re}${output}${thread_db_re}${exited_normally_re}"
set i [expr $i + 1]
gdb_test "run" $output
}

View File

@ -1,88 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Wed, 9 Jun 2021 19:31:18 -0700
Subject: gdb-rhbz1971095-libthread_db-update-4of5.patch
;; Backport "print-symbol-loading.exp: Allow libc symbols to be already loaded"
;; (Kevin Buettner, RH BZ 1971095)
One consequence of changing libpthread_name_p() in solib.c to (also)
match libc is that the symbols for libc will now be loaded by
solib_add() in solib.c. I think this is mostly harmless because
we'll likely want these symbols to be loaded anyway, but it did cause
two failures in gdb.base/print-symbol-loading.exp.
Specifically...
1)
sharedlibrary .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib
now looks like this:
sharedlibrary .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib
2)
sharedlibrary .*
Loading symbols for shared libraries: .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib
now looks like this:
sharedlibrary .*
Loading symbols for shared libraries: .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib
Fixing case #2 ended up being easier than #1. #1 had been using
gdb_test_no_output to correctly match this no-output case. I
ended up replacing it with gdb_test_multiple, matching the exact
expected output for each of the two now acceptable cases.
For case #2, I simply added an optional non-capturing group
for the potential new output.
gdb/testsuite/ChangeLog:
* gdb.base/print-symbol-loading.exp (proc test_load_shlib):
Allow "Symbols already loaded for..." messages.
diff --git a/gdb/testsuite/gdb.base/print-symbol-loading.exp b/gdb/testsuite/gdb.base/print-symbol-loading.exp
--- a/gdb/testsuite/gdb.base/print-symbol-loading.exp
+++ b/gdb/testsuite/gdb.base/print-symbol-loading.exp
@@ -96,6 +96,7 @@ test_load_core full
proc test_load_shlib { print_symbol_loading } {
global binfile
+ global gdb_prompt
with_test_prefix "shlib ${print_symbol_loading}" {
clean_restart ${binfile}
gdb_test_no_output "set auto-solib-add off"
@@ -106,12 +107,20 @@ proc test_load_shlib { print_symbol_loading } {
set test_name "load shared-lib"
switch ${print_symbol_loading} {
"off" {
- gdb_test_no_output "sharedlibrary .*" \
- ${test_name}
+ set cmd "sharedlibrary .*"
+ set cmd_regex [string_to_regexp $cmd]
+ gdb_test_multiple $cmd $test_name {
+ -re "^$cmd_regex\r\n$gdb_prompt $" {
+ pass $test_name
+ }
+ -re "^$cmd_regex\r\nSymbols already loaded for\[^\r\n\]*\\/libc\\.\[^\r\n\]*\r\n$gdb_prompt $" {
+ pass $test_name
+ }
+ }
}
"brief" {
gdb_test "sharedlibrary .*" \
- "Loading symbols for shared libraries: \\.\\*" \
+ "Loading symbols for shared libraries: \\.\\*.*?(?:Symbols already loaded for .*?libc)?" \
${test_name}
}
"full" {

View File

@ -1,85 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Wed, 9 Jun 2021 19:52:08 -0700
Subject: gdb-rhbz1971095-libthread_db-update-5of5.patch
;; Backport "mi-sym-info.exp: Increase timeout for 114-symbol-info-functions"
;; (Kevin Buettner, RH BZ 1971095)
Loading libc.so's symbols increased the amount of time needed for
114-symbol-info-function to fetch symbols, causing a timeout during my
testing. I enclosed the entire block with a "with_timeout_factor 4",
which fixes the problem for me. (Using 2 also fixed it for me, but it
might not be enough when running this test on slower machines.)
gdb/testsuite/ChangeLog:
* gdb.mi/mi-sym-info.exp (114-symbol-info-function test): Increase
timeout.
diff --git a/gdb/testsuite/gdb.mi/mi-sym-info.exp b/gdb/testsuite/gdb.mi/mi-sym-info.exp
--- a/gdb/testsuite/gdb.mi/mi-sym-info.exp
+++ b/gdb/testsuite/gdb.mi/mi-sym-info.exp
@@ -122,33 +122,35 @@ gdb_test_multiple $cmd $testname -prompt "${mi_gdb_prompt}$" {
# (from the symbol table). There's often so much output output from
# this command that we overflow expect's buffers, avoid this by
# fetching the output piece by piece.
-set testname "List all functions"
-set cmd "114-symbol-info-functions --include-nondebug"
-set state 0
-gdb_test_multiple $cmd ${testname} -prompt "${mi_gdb_prompt}$" {
- -re "114\\^done,symbols=\{" {
- if { $state == 0 } { set state 1 }
- exp_continue
- }
- -re "debug=\\\[${symtab_re}" {
- if { $state == 1 } { set state 2 }
- exp_continue
- }
- -re ",${symtab_re}" {
- exp_continue
- }
- -re "\\\],nondebug=\\\[" {
- if { $state == 2 } { set state 3 }
- exp_continue
- }
- -re "\{address=${qstr},name=${qstr}\}," {
- exp_continue
- }
- -re "\{address=${qstr},name=${qstr}\}\\\]\}\r\n${mi_gdb_prompt}$" {
- if { $state == 3 } {
- pass $gdb_test_name
- } else {
- fail $gdb_test_name
+with_timeout_factor 4 {
+ set testname "List all functions"
+ set cmd "114-symbol-info-functions --include-nondebug"
+ set state 0
+ gdb_test_multiple $cmd ${testname} -prompt "${mi_gdb_prompt}$" {
+ -re "114\\^done,symbols=\{" {
+ if { $state == 0 } { set state 1 }
+ exp_continue
+ }
+ -re "debug=\\\[${symtab_re}" {
+ if { $state == 1 } { set state 2 }
+ exp_continue
+ }
+ -re ",${symtab_re}" {
+ exp_continue
+ }
+ -re "\\\],nondebug=\\\[" {
+ if { $state == 2 } { set state 3 }
+ exp_continue
+ }
+ -re "\{address=${qstr},name=${qstr}\}," {
+ exp_continue
+ }
+ -re "\{address=${qstr},name=${qstr}\}\\\]\}\r\n${mi_gdb_prompt}$" {
+ if { $state == 3 } {
+ pass $gdb_test_name
+ } else {
+ fail $gdb_test_name
+ }
}
}
}

View File

@ -1,99 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andreas Krebbel <krebbel@linux.ibm.com>
Date: Thu, 3 Dec 2020 16:31:15 +0100
Subject: gdb-rhbz2012819-ibmz-update-1of5.patch
;; IBM Z: Add support for HLASM extended mnemonics
;; (Andreas Krebbel, RHBZ 2012819)
Add extended mnemonics used in the HLASM assembler. All of them are
just aliases for instructions we already support and help when
assembling code which was written for the HLASM assembler.
The HLASM mnemonics are documented here:
https://www.ibm.com/support/knowledgecenter/SSENW6_1.6.0/com.ibm.hlasm.v1r6.asm/asmr1023.pdf
See the 'Branching with extended mnemonic codes' chapter.
objdump will still print the existing mnemonics with the exception of
relative nop branches (i.e. conditional branches with an empty
condition code mask). Now we have jnop and jgnop which will be used
by objdump when possible.
The same change have been applied to the LLVM assembler:
https://reviews.llvm.org/D92185
opcodes/
* s390-opc.txt: Add extended mnemonics.
gas/
* testsuite/gas/s390/esa-g5.s: Test new extended mnemonics.
* testsuite/gas/s390/esa-g5.d: Likewise.
* testsuite/gas/s390/esa-z900.s: Likewise.
* testsuite/gas/s390/esa-z900.d: Likewise.
* testsuite/gas/s390/zarch-z900.s: Likewise.
* testsuite/gas/s390/zarch-z900.d: Likewise.
ld/
* testsuite/ld-s390/tlsbin_64.dd: The newly added jgnop mnemonic
replaces long relative branches with empty condition code mask.
diff --git a/opcodes/s390-opc.txt b/opcodes/s390-opc.txt
--- a/opcodes/s390-opc.txt
+++ b/opcodes/s390-opc.txt
@@ -246,10 +246,14 @@ d7 xc SS_L0RDRD "exclusive OR" g5 esa,zarch
f8 zap SS_LLRDRD "zero and add" g5 esa,zarch
a70a ahi RI_RI "add halfword immediate" g5 esa,zarch
84 brxh RSI_RRP "branch relative on index high" g5 esa,zarch
+84 jxh RSI_RRP "branch relative on index high" g5 esa,zarch
85 brxle RSI_RRP "branch relative on index low or equal" g5 esa,zarch
+85 jxle RSI_RRP "branch relative on index low or equal" g5 esa,zarch
a705 bras RI_RP "branch relative and save" g5 esa,zarch
+a705 jas RI_RP "branch relative and save" g5 esa,zarch
a704 brc RI_UP "branch relative on condition" g5 esa,zarch
a706 brct RI_RP "branch relative on count" g5 esa,zarch
+a706 jct RI_RP "branch relative on count" g5 esa,zarch
b241 cksm RRE_RR "checksum" g5 esa,zarch
a70e chi RI_RI "compare halfword immediate" g5 esa,zarch
a9 clcle RS_RRRD "compare logical long extended" g5 esa,zarch
@@ -268,8 +272,11 @@ a701 tml RI_RU "test under mask low" g5 esa,zarch
4700 nop RX_0RRD "no operation" g5 esa,zarch optparm
4700 b*8 RX_0RRD "conditional branch" g5 esa,zarch
47f0 b RX_0RRD "unconditional branch" g5 esa,zarch
+a704 jnop RI_0P "nop jump" g5 esa,zarch
a704 j*8 RI_0P "conditional jump" g5 esa,zarch
+a704 br*8 RI_0P "conditional jump" g5 esa,zarch
a7f4 j RI_0P "unconditional jump" g5 esa,zarch
+a7f4 bru RI_0P "unconditional jump" g5 esa,zarch
b34a axbr RRE_FEFE "add extended bfp" g5 esa,zarch
b31a adbr RRE_FF "add long bfp" g5 esa,zarch
ed000000001a adb RXE_FRRD "add long bfp" g5 esa,zarch
@@ -437,7 +444,9 @@ e3000000001b slgf RXE_RRRD "subtract logical 64<32" z900 zarch
e3000000000c msg RXE_RRRD "multiply single 64" z900 zarch
e3000000001c msgf RXE_RRRD "multiply single 64<32" z900 zarch
ec0000000044 brxhg RIE_RRP "branch relative on index high 64" z900 zarch
+ec0000000044 jxhg RIE_RRP "branch relative on index high 64" z900 zarch
ec0000000045 brxlg RIE_RRP "branch relative on index low or equal 64" z900 zarch
+ec0000000045 jxleg RIE_RRP "branch relative on index low or equal 64" z900 zarch
eb0000000044 bxhg RSE_RRRD "branch on index high 64" z900 zarch
eb0000000045 bxleg RSE_RRRD "branch on index low or equal 64" z900 zarch
eb000000000c srlg RSE_RRRD "shift right single logical 64" z900 zarch
@@ -462,10 +471,15 @@ eb0000000080 icmh RSE_RURD "insert characters under mask high" z900 zarch
a702 tmhh RI_RU "test under mask high high" z900 zarch
a703 tmhl RI_RU "test under mask high low" z900 zarch
c004 brcl RIL_UP "branch relative on condition long" z900 esa,zarch
+c004 jgnop RIL_0P "nop jump long" z900 esa,zarch
c004 jg*8 RIL_0P "conditional jump long" z900 esa,zarch
+c004 br*8l RIL_0P "conditional jump long" z900 esa,zarch
c0f4 jg RIL_0P "unconditional jump long" z900 esa,zarch
+c0f4 brul RIL_0P "unconditional jump long" z900 esa,zarch
c005 brasl RIL_RP "branch relative and save long" z900 esa,zarch
+c005 jasl RIL_RP "branch relative and save long" z900 esa,zarch
a707 brctg RI_RP "branch relative on count 64" z900 zarch
+a707 jctg RI_RP "branch relative on count 64" z900 zarch
a709 lghi RI_RI "load halfword immediate 64" z900 zarch
a70b aghi RI_RI "add halfword immediate 64" z900 zarch
a70d mghi RI_RI "multiply halfword immediate 64" z900 zarch

View File

@ -1,113 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andreas Krebbel <krebbel@linux.ibm.com>
Date: Fri, 4 Dec 2020 09:00:43 +0100
Subject: gdb-rhbz2012819-ibmz-update-2of5.patch
;; IBM Z: Add risbgz and risbgnz extended mnemonics
;; (Andreas Krebbel, RHBZ 2012819)
These two extended mnemonics are documented in the Principles of
Operations manual but currently not supported by Binutils. They
provide aliases for already supported instructions with the zero flag
being set. The flag otherwise is mingled into one of the immediate
operands what makes asm code much harder to read.
opcodes/
* s390-opc.txt: Add risbgz and risbgnz.
* s390-opc.c (U6_26): New operand type.
(INSTR_RIE_RRUUU2, MASK_RIE_RRUUU2): New instruction format and
mask.
gas/
* testsuite/gas/s390/zarch-z10.s: Add tests for risbgz.
* testsuite/gas/s390/zarch-z10.d: Add regexp for risbgz.
* testsuite/gas/s390/zarch-zEC12.s: Add tests for risbgnz.
* testsuite/gas/s390/zarch-zEC12.d: Add regexp for risbgnz.
diff --git a/opcodes/s390-opc.c b/opcodes/s390-opc.c
--- a/opcodes/s390-opc.c
+++ b/opcodes/s390-opc.c
@@ -218,32 +218,34 @@ const struct s390_operand s390_operands[] =
{ 8, 8, 0 },
#define U8_16 68 /* 8 bit unsigned value starting at 16 */
{ 8, 16, 0 },
-#define U8_24 69 /* 8 bit unsigned value starting at 24 */
+#define U6_26 69 /* 6 bit unsigned value starting at 26 */
+ { 6, 26, 0 },
+#define U8_24 70 /* 8 bit unsigned value starting at 24 */
{ 8, 24, 0 },
-#define U8_28 70 /* 8 bit unsigned value starting at 28 */
+#define U8_28 71 /* 8 bit unsigned value starting at 28 */
{ 8, 28, 0 },
-#define U8_32 71 /* 8 bit unsigned value starting at 32 */
+#define U8_32 72 /* 8 bit unsigned value starting at 32 */
{ 8, 32, 0 },
-#define U12_16 72 /* 12 bit unsigned value starting at 16 */
+#define U12_16 73 /* 12 bit unsigned value starting at 16 */
{ 12, 16, 0 },
-#define U16_16 73 /* 16 bit unsigned value starting at 16 */
+#define U16_16 74 /* 16 bit unsigned value starting at 16 */
{ 16, 16, 0 },
-#define U16_32 74 /* 16 bit unsigned value starting at 32 */
+#define U16_32 75 /* 16 bit unsigned value starting at 32 */
{ 16, 32, 0 },
-#define U32_16 75 /* 32 bit unsigned value starting at 16 */
+#define U32_16 76 /* 32 bit unsigned value starting at 16 */
{ 32, 16, 0 },
/* PC-relative address operands. */
-#define J12_12 76 /* 12 bit PC relative offset at 12 */
+#define J12_12 77 /* 12 bit PC relative offset at 12 */
{ 12, 12, S390_OPERAND_PCREL },
-#define J16_16 77 /* 16 bit PC relative offset at 16 */
+#define J16_16 78 /* 16 bit PC relative offset at 16 */
{ 16, 16, S390_OPERAND_PCREL },
-#define J16_32 78 /* 16 bit PC relative offset at 32 */
+#define J16_32 79 /* 16 bit PC relative offset at 32 */
{ 16, 32, S390_OPERAND_PCREL },
-#define J24_24 79 /* 24 bit PC relative offset at 24 */
+#define J24_24 80 /* 24 bit PC relative offset at 24 */
{ 24, 24, S390_OPERAND_PCREL },
-#define J32_16 80 /* 32 bit PC relative offset at 16 */
+#define J32_16 81 /* 32 bit PC relative offset at 16 */
{ 32, 16, S390_OPERAND_PCREL },
};
@@ -313,6 +315,7 @@ const struct s390_operand s390_operands[] =
#define INSTR_RIE_R0U0 6, { R_8,U16_16,0,0,0,0 } /* e.g. clfitne */
#define INSTR_RIE_RUI0 6, { R_8,I16_16,U4_12,0,0,0 } /* e.g. lochi */
#define INSTR_RIE_RRUUU 6, { R_8,R_12,U8_16,U8_24,U8_32,0 } /* e.g. rnsbg */
+#define INSTR_RIE_RRUUU2 6, { R_8,R_12,U8_16,U6_26,U8_32,0 } /* e.g. rnsbg */
#define INSTR_RIL_0P 6, { J32_16,0,0,0,0 } /* e.g. jg */
#define INSTR_RIL_RP 6, { R_8,J32_16,0,0,0,0 } /* e.g. brasl */
#define INSTR_RIL_UP 6, { U4_8,J32_16,0,0,0,0 } /* e.g. brcl */
@@ -534,6 +537,7 @@ const struct s390_operand s390_operands[] =
#define MASK_RIE_R0U0 { 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff }
#define MASK_RIE_RUI0 { 0xff, 0x00, 0x00, 0x00, 0xff, 0xff }
#define MASK_RIE_RRUUU { 0xff, 0x00, 0x00, 0x00, 0x00, 0xff }
+#define MASK_RIE_RRUUU2 { 0xff, 0x00, 0x00, 0xc0, 0x00, 0xff }
#define MASK_RIL_0P { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }
#define MASK_RIL_RP { 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00 }
#define MASK_RIL_UP { 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00 }
diff --git a/opcodes/s390-opc.txt b/opcodes/s390-opc.txt
--- a/opcodes/s390-opc.txt
+++ b/opcodes/s390-opc.txt
@@ -970,6 +970,7 @@ ec0000000054 rnsbg RIE_RRUUU "rotate then and selected bits" z10 zarch
ec0000000057 rxsbg RIE_RRUUU "rotate then exclusive or selected bits" z10 zarch
ec0000000056 rosbg RIE_RRUUU "rotate then or selected bits" z10 zarch
ec0000000055 risbg RIE_RRUUU "rotate then insert selected bits" z10 zarch
+ec0000800055 risbgz RIE_RRUUU2 "rotate then insert selected bits and zero remaining bits" z10 zarch
c40f strl RIL_RP "store relative long (32)" z10 zarch
c40b stgrl RIL_RP "store relative long (64)" z10 zarch
c407 sthrl RIL_RP "store halfword relative long" z10 zarch
@@ -1153,6 +1154,7 @@ eb0000000023 clt$12 RSY_R0RD "compare logical and trap 32 bit reg-mem" zEC12 zar
eb000000002b clgt RSY_RURD "compare logical and trap 64 bit reg-mem" zEC12 zarch
eb000000002b clgt$12 RSY_R0RD "compare logical and trap 64 bit reg-mem" zEC12 zarch
ec0000000059 risbgn RIE_RRUUU "rotate then insert selected bits nocc" zEC12 zarch
+ec0000800059 risbgnz RIE_RRUUU2 "rotate then insert selected bits and zero remaining bits nocc" zEC12 zarch
ed00000000aa cdzt RSL_LRDFU "convert from zoned long" zEC12 zarch
ed00000000ab cxzt RSL_LRDFEU "convert from zoned extended" zEC12 zarch
ed00000000a8 czdt RSL_LRDFU "convert to zoned long" zEC12 zarch

View File

@ -1,84 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andreas Krebbel <krebbel@linux.ibm.com>
Date: Mon, 15 Feb 2021 14:20:00 +0100
Subject: gdb-rhbz2012819-ibmz-update-3of5.patch
;; IBM Z: Implement instruction set extensions
;; (Andreas Krebbel, RHBZ 2012819)
opcodes/
* s390-mkopc.c (main): Accept arch14 as cpu string.
* s390-opc.txt: Add new arch14 instructions.
include/
* opcode/s390.h (enum s390_opcode_cpu_val): Add
S390_OPCODE_ARCH14.
gas/
* config/tc-s390.c (s390_parse_cpu): New entry for arch14.
* doc/c-s390.texi: Document arch14 march option.
* testsuite/gas/s390/s390.exp: Run the arch14 related tests.
* testsuite/gas/s390/zarch-arch14.d: New test.
* testsuite/gas/s390/zarch-arch14.s: New test.
diff --git a/include/opcode/s390.h b/include/opcode/s390.h
--- a/include/opcode/s390.h
+++ b/include/opcode/s390.h
@@ -44,6 +44,7 @@ enum s390_opcode_cpu_val
S390_OPCODE_Z13,
S390_OPCODE_ARCH12,
S390_OPCODE_ARCH13,
+ S390_OPCODE_ARCH14,
S390_OPCODE_MAXCPU
};
diff --git a/opcodes/s390-mkopc.c b/opcodes/s390-mkopc.c
--- a/opcodes/s390-mkopc.c
+++ b/opcodes/s390-mkopc.c
@@ -381,6 +381,8 @@ main (void)
else if (strcmp (cpu_string, "z15") == 0
|| strcmp (cpu_string, "arch13") == 0)
min_cpu = S390_OPCODE_ARCH13;
+ else if (strcmp (cpu_string, "arch14") == 0)
+ min_cpu = S390_OPCODE_ARCH14;
else {
fprintf (stderr, "Couldn't parse cpu string %s\n", cpu_string);
exit (1);
diff --git a/opcodes/s390-opc.txt b/opcodes/s390-opc.txt
--- a/opcodes/s390-opc.txt
+++ b/opcodes/s390-opc.txt
@@ -2016,3 +2016,31 @@ e60000000052 vcvbg VRR_RV0UU "vector convert to binary 64 bit" arch13 zarch optp
# Message Security Assist Extension 9
b93a kdsa RRE_RR "compute digital signature authentication" arch13 zarch
+
+
+# arch14 instructions
+
+e60000000074 vschp VRR_VVV0U0U " " arch14 zarch
+e60000002074 vschsp VRR_VVV0U0 " " arch14 zarch
+e60000003074 vschdp VRR_VVV0U0 " " arch14 zarch
+e60000004074 vschxp VRR_VVV0U0 " " arch14 zarch
+e6000000007c vscshp VRR_VVV " " arch14 zarch
+e6000000007d vcsph VRR_VVV0U0 " " arch14 zarch
+e60000000051 vclzdp VRR_VV0U2 " " arch14 zarch
+e60000000070 vpkzr VRI_VVV0UU2 " " arch14 zarch
+e60000000072 vsrpr VRI_VVV0UU2 " " arch14 zarch
+e60000000054 vupkzh VRR_VV0U2 " " arch14 zarch
+e6000000005c vupkzl VRR_VV0U2 " " arch14 zarch
+
+b93b nnpa RRE_00 " " arch14 zarch
+e60000000056 vclfnh VRR_VV0UU2 " " arch14 zarch
+e6000000005e vclfnl VRR_VV0UU2 " " arch14 zarch
+e60000000075 vcrnf VRR_VVV0UU " " arch14 zarch
+e6000000005d vcfn VRR_VV0UU2 " " arch14 zarch
+e60000000055 vcnf VRR_VV0UU2 " " arch14 zarch
+
+b98B rdp RRF_RURR2 " " arch14 zarch optparm
+
+eb0000000071 lpswey SIY_URD " " arch14 zarch
+b200 lbear S_RD " " arch14 zarch
+b201 stbear S_RD " " arch14 zarch

View File

@ -1,50 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andreas Krebbel <krebbel@linux.ibm.com>
Date: Wed, 4 Aug 2021 16:51:36 +0200
Subject: gdb-rhbz2012819-ibmz-update-4of5.patch
;; IBM Z: Remove lpswey parameter
;; (Andreas Krebbel, RH BZ 2012819)
opcodes/
* s390-opc.c (INSTR_SIY_RD): New instruction format.
(MASK_SIY_RD): New instruction mask.
* s390-opc.txt: Change instruction format of lpswey to SIY_RD.
gas/
* testsuite/gas/s390/zarch-arch14.d: Remove last operand of
lpswey.
* testsuite/gas/s390/zarch-arch14.s: Likewise.
(cherry picked from commit a164bbda300d1da6f97bfa14ba7fa22475e61d17)
diff --git a/opcodes/s390-opc.c b/opcodes/s390-opc.c
--- a/opcodes/s390-opc.c
+++ b/opcodes/s390-opc.c
@@ -442,6 +442,7 @@ const struct s390_operand s390_operands[] =
#define INSTR_RX_URRD 4, { U4_8,D_20,X_12,B_16,0,0 } /* e.g. bc */
#define INSTR_SI_RD 4, { D_20,B_16,0,0,0,0 } /* e.g. lpsw */
#define INSTR_SI_URD 4, { D_20,B_16,U8_8,0,0,0 } /* e.g. cli */
+#define INSTR_SIY_RD 6, { D20_20,B_16,0,0,0,0 } /* e.g. lpswey*/
#define INSTR_SIY_URD 6, { D20_20,B_16,U8_8,0,0,0 } /* e.g. tmy */
#define INSTR_SIY_IRD 6, { D20_20,B_16,I8_8,0,0,0 } /* e.g. asi */
#define INSTR_SIL_RDI 6, { D_20,B_16,I16_32,0,0,0 } /* e.g. chhsi */
@@ -664,6 +665,7 @@ const struct s390_operand s390_operands[] =
#define MASK_RX_URRD { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 }
#define MASK_SI_RD { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 }
#define MASK_SI_URD { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 }
+#define MASK_SIY_RD { 0xff, 0xff, 0x00, 0x00, 0x00, 0xff }
#define MASK_SIY_URD { 0xff, 0x00, 0x00, 0x00, 0x00, 0xff }
#define MASK_SIY_IRD { 0xff, 0x00, 0x00, 0x00, 0x00, 0xff }
#define MASK_SIL_RDI { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }
diff --git a/opcodes/s390-opc.txt b/opcodes/s390-opc.txt
--- a/opcodes/s390-opc.txt
+++ b/opcodes/s390-opc.txt
@@ -2041,6 +2041,6 @@ e60000000055 vcnf VRR_VV0UU2 " " arch14 zarch
b98B rdp RRF_RURR2 " " arch14 zarch optparm
-eb0000000071 lpswey SIY_URD " " arch14 zarch
+eb0000000071 lpswey SIY_RD " " arch14 zarch
b200 lbear S_RD " " arch14 zarch
b201 stbear S_RD " " arch14 zarch

View File

@ -1,28 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andreas Krebbel <krebbel@linux.ibm.com>
Date: Wed, 7 Jul 2021 14:05:00 +0200
Subject: gdb-rhbz2012819-ibmz-update-5of5.patch
;; IBM Z: Add another arch14 instruction
;; (Andreas Krebbel, RHBZ 2012819)
opcodes/
* opcodes/s390-opc.txt: Add qpaci.
gas/
* testsuite/gas/s390/zarch-arch14.d: Add qpaci.
* testsuite/gas/s390/zarch-arch14.s: Add qpaci.
(cherry picked from commit e4cc3b47ec2c4bdb1892db7e9759f90576742f31)
diff --git a/opcodes/s390-opc.txt b/opcodes/s390-opc.txt
--- a/opcodes/s390-opc.txt
+++ b/opcodes/s390-opc.txt
@@ -2044,3 +2044,5 @@ b98B rdp RRF_RURR2 " " arch14 zarch optparm
eb0000000071 lpswey SIY_RD " " arch14 zarch
b200 lbear S_RD " " arch14 zarch
b201 stbear S_RD " " arch14 zarch
+
+b28f qpaci S_RD " " arch14 zarch

View File

@ -1,54 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Tue, 24 May 2022 07:39:17 -0700
Subject: gdb-rhbz2086761-unknown-cfa-rule.patch
;; Backport "fix logic of find_comp_unit and set_comp_unit"
;; (Simon Marchi, RHBZ 2086761)
The logic in find_comp_unit and set_comp_unit is reversed. When the BFD
requires relocation, we want to put the comp_unit structure in the
map where the comp_unit objects are not shared, that is the one indexed
by objfile. If the BFD does not require relocation, then, we can share
a single comp_unit structure for all users of that BFD, so we want to
put it in the BFD-indexed map. The comments on top of
dwarf2_frame_bfd_data and dwarf2_frame_objfile_data make that clear.
Fix it by swapping the two in find_comp_unit and set_comp_unit.
I don't have a test for this, because I don't see how to write one in a
reasonable amount of time.
gdb/ChangeLog:
PR gdb/26876
* dwarf2/frame.c (find_comp_unit, set_comp_unit): Reverse use of
dwarf2_frame_bfd_data and dwarf2_frame_objfile_data.
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -1640,8 +1640,9 @@ find_comp_unit (struct objfile *objfile)
{
bfd *abfd = objfile->obfd;
if (gdb_bfd_requires_relocations (abfd))
- return dwarf2_frame_bfd_data.get (abfd);
- return dwarf2_frame_objfile_data.get (objfile);
+ return dwarf2_frame_objfile_data.get (objfile);
+
+ return dwarf2_frame_bfd_data.get (abfd);
}
/* Store the comp_unit on OBJFILE, or the corresponding BFD, as
@@ -1652,8 +1653,9 @@ set_comp_unit (struct objfile *objfile, struct comp_unit *unit)
{
bfd *abfd = objfile->obfd;
if (gdb_bfd_requires_relocations (abfd))
- return dwarf2_frame_bfd_data.set (abfd, unit);
- return dwarf2_frame_objfile_data.set (objfile, unit);
+ return dwarf2_frame_objfile_data.set (objfile, unit);
+
+ return dwarf2_frame_bfd_data.set (abfd, unit);
}
/* Find the FDE for *PC. Return a pointer to the FDE, and store the

Some files were not shown because too many files have changed in this diff Show More